Cast virtual light on real-world environments in VisionOS/RealityKit?

Hi everyone,

I've been exploring an idea that involves using virtual light sources in VisionOS/RealityKit to interact with real-world objects. Specifically, I'd like to simulate a scenario where a virtual spotlight or other light source casts light or shadows onto real-world environments, creating the effect of virtual lighting interacting with physical surroundings. Is this currently feasible within VisionOS/RealityKit?

Thank you!

By default, these dynamic lights will not affect the passthrough environment. But there is an interesting workaround that we can use.

We can use an entity either a shader graph material that uses the "ShadowReceivingOcclusionSurface" node.

This small demo scene has a 1x0.1x1 cube that is using that material. Then I dropped in a spotlight and some other cubes to block the light.

The spotlight can shine only the surface of the object using the occlusion material.

This works with shadows cast by virtual objects too, and it doesn't require the grounding shadow component.

The challenge will be determining what mesh/object to use for the occlusion material. Depending on your use case, simple shapes may work. Or you may want to use planes or the room mesh from ARKit.

Cast virtual light on real-world environments in VisionOS/RealityKit?
 
 
Q