How to make a RealityKit `Entity` respond to Environment light

I am developing an visionos app. I load a .usdz file as a Reality Entity(such as a cabbage). And I want such an effect:

When I turn on a desk lamp in real world near the Entity, the surface of the Entity will correctly respond to the light in the real world.

I want an effect like this:

https://www.reddit.com/r/virtualreality/comments/1as01mm/shiny_disco_ball_reflecting_my_room/

I look up the api such as ImageBasedLightComponent andVirtualEnvironmentProbeComponent in RealityKit、EnvironmentLightEstimationProvider in ARKit,but I do not know how to code.

Besides, it will be better if the shadow will also respond to the light correctly.

Answered by Vision Pro Engineer in 826628022

Hi @YaShiho

You can create a RealityKit Entity from a usd file. By default, all entities with a material that responds to light, respond to environment lighting. In other words it "just works" when you add the entity to a RealityView's content. If the entity is not responding to light, it's likely that your usd file is not using a lit material.

Update: RealityKit does not have much support for USD lighting. Refer to Validating feature support for USD files for a list of supported features. Given that, I suspect the disco ball, in the video you referenced, was a RealityKit entity (sphere) with a RealityKit material (PhysicallyBased) that responds to light. I suspect a shader was applied in Reality Composer Pro to make the sphere appear like a disco ball.

Accepted Answer

Hi @YaShiho

You can create a RealityKit Entity from a usd file. By default, all entities with a material that responds to light, respond to environment lighting. In other words it "just works" when you add the entity to a RealityView's content. If the entity is not responding to light, it's likely that your usd file is not using a lit material.

Update: RealityKit does not have much support for USD lighting. Refer to Validating feature support for USD files for a list of supported features. Given that, I suspect the disco ball, in the video you referenced, was a RealityKit entity (sphere) with a RealityKit material (PhysicallyBased) that responds to light. I suspect a shader was applied in Reality Composer Pro to make the sphere appear like a disco ball.

How to make a RealityKit `Entity` respond to Environment light
 
 
Q