Search code examples
scenekitmetal

Physically Based lighting lost after using metal shader on another model?


i got 2 models on my scene (using SceneKit) - ring and diamond. Ring is with gold pbr material (SCNLightingModelPhysicallyBased) - second is diamond with "custom" material using Metal shader (SCNProgram). Right after developing diamond shader my golden ring stopped working and is pure black. Why is that ? When i simply set my ring to yellow and drop pbr lighting model it works, just not pbr - with pbr its solid black. I cant use SCNProgram with PBR ?

metal diamond


Solution

  • Are you setting the scene's lightingEnvironment? You will need a light source in the scene for the object to be lit. You can either use point lights or leverage image-based lighting (IBL) which is what the lightingEnvironment is for.

    You can also try the autoenablesDefaultLighting property. With it SceneKit will try to adjust and add light sources in the scene depending on its contents, but its behaviour is subject to changes.