Programatic use of Light Probes

When rendering a scene using environment lighting and the physically based lighting model, I have a need for an object to reflect another object. As I understand it, in this type of rendering, reflections are only based on the environment lighting and nothing else. As a solution I was intending to use a light probe placed between the object to be reflected and the reflecting object. My scene has been developed programatically and not through an XCode scene file. From Apple's WWDC 2016 presentation on SceneKit I could gather that light probes can be updated programatically through the use of the updateProbes method of the SCNRenderer class. I have the following code, where I am trying to initialize a light probe by using the updateProbes method:


let sceneView = SCNView(frame: self.view.frame)
self.view.addSubview(sceneView)
let scene = SCNScene()
sceneView.scene = scene

let lightProbeNode = SCNNode()
lightProbe = SCNLight()
lightProbeNode.light = lightProbe
lightProbe.type = .probe
scene.rootNode.addChildNode(lightProbeNode)

var initLightProbe = true

func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
        if initLightProbe {
            initLightProbe = false
            let scnRenderer = SCNRenderer(device: sceneView.device, options: nil)
            scnRenderer.scene = scene
            scnRenderer.updateProbes([lightProbeNode], atTime: time)
            print ("Initializing light probe")
        }
     }


I don't seem to get any light coming from this light probe. My question is simple, can the updateProbes method be used to initialize a lightProbe? If not, how can you initialize a light probe programatically?

  • Were you able to find a solution to this?

Add a Comment