Occlusion in Unity

Occlusion refers to hiding objects not visible to the camera when other objects block their view. This optimization technique is crucial for improving rendering performance and ensuring only objects visible to the camera are processed and rendered. Unity provides tools and components that help developers manage occlusion and enhance the efficiency of their scenes.

Without occlusion, your object will appear regardless of any real-world object obstructing its view.

Implement Occlusion

To implement occlusion on any of your AR projects, open your project. For this demo, the object placement project is being used. Just go to the main camera in the XR origin. In the inspector tab, add the AR occlusion manager component.

AR occlusion manager

According to your project requirements, change the following properties of occlusion:

Environment depth mode

It determines how the depth information of the environment will be calculated and utilized for occlusion cullingA feature that disables rendering of objects when they are not visible to the camera .. This information is crucial for understanding the spatial relationships between objects and deciding which objects should be visible or occluded.

Temporal smoothing

Temporal smoothing improves the stability and accuracy of occlusion culling over time. It uses depth information from previous frames to refine the occlusion culling process in the current frame. This technique helps prevent flickering or abrupt changes in the visibility of objects, providing a more visually consistent experience.

Human segmentation

This feature identifies and separates human figures from the objects of the scene. This is particularly valuable in scenarios involving augmented reality, virtual reality, or mixed reality applications where human interaction is a significant aspect of the experience.

Human segmentation stencil

It uses a specialized rendering pass to generate a stencil buffer that uniquely identifies pixels belonging to humans in the scene. This stencil buffer is then used to ensure precise occlusion interactions with humans, such as objects properly occluding behind or interacting with human figures.

Human segmentation depth

Human segmentation depth is a depth layer dedicated to human figures in the scene. By separating humans from the rest of the environment in terms of depth information, the occlusion system can better understand the spatial relationships involving humans and handle occlusion interactions more accurately.

Occlusion preference mode

This setting allows you to fine-tune the behavior of the occlusion culling system based on the project’s requirements. This mode controls how aggressively occlusion culling is applied, balancing rendering performance and visual quality.

Save the scene. Connect your Android or iOS device. Go to File > Build and Run.

Conclusion

Occlusion is a fundamental technique in Unity to optimize the rendering performance by only rendering objects visible to the camera. Through occlusion, you can create immersive environments that clearly differentiate between virtual and real objects.

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved