SceneKit: Remove darkened areas that occur outside a spotlight's cone?

299 Views Asked by At

The goal is to simulate lighting similar to these images:

There is little documentation on SceneKit lighting, and how different lighting types interact with each other (e.g., what happens if you add a spot light to a scene with an ambient light already there), so through painful trial-and-error, we have gotten this far:

enter image description here

As shown in the Scene Graph, there is an ambient light and a spot light. (The omni light and the directional light are hidden.) The shadows and lighting are pretty good inside the spot's cone, but everything beyond the cone of light is black.

Question 1: how do you make it so the area outside the spot's cone is not black? There is an ambient light in the scene (not the default one, one was explicitly added), so shouldn't that brighten the areas outside the cone?

Question 2: Ideally, the whole scene would be litas if inside the cone while preserving the shadows. Is this possible? Moving the spot to a high Y value (e.g., 1000) lights up the whole scene, but the cool shadows vanish.

Question 3: In the screenshot below, enabling the omni light washes out the spot's cone. Is this expected behavior? How can you combine the lights so they don't wash each other out?

Screenshot 2 (enabling omni light washes out spot lighting):

enter image description here

1

There are 1 best solutions below

0
On

You can add additional light source to the scene with ambient type and low intensity.

Here is swift 4 example:

let light = SCNLight()
light.type = .ambient
let node = SCNNode()
node.light = alight
self.scene.rootNode.addChildNode(node)