The occulution relationship of virtual content and real object

I am using Entity of RealityKit to display virtual content, however I find that sometimes the real object in front of the virtual content can not occulude the virtual content.
For example, I place an Entity in a room, but when I walk into another room, I can still see the Entity through the wall.
I wonder how should I fix the problem. Thank you!

We can use OcclusionMaterial to solve issues like this. Essentially, we can use ARKit features to get meshes that describe the real world environment, the assign OcclusionMaterial to them.

Apple has a neat example app you can try and a short tutorial that describes the process.

Obscuring virtual items in a scene behind real-world items

Bonus: You can also create your own material using ShaderGraph in Reality Composer Pro. There are two nodes that we can use.

  • Occlusion surface
  • Shadow receiving occlusion surface - use this one if your app needs to cast shadows or shine virtual lights on the environment.

The occulution relationship of virtual content and real object
 
 
Q