Develop

Occlusions Overview

Updated: Apr 14, 2026

What are occlusions?

The primary function of the Depth API is to enable real-world objects to obscure virtual objects in passthrough. There are two types of occlusion available:
  • Hard occlusion, which is cheaper to compute, but has a jagged edge and more visible temporal instability.
  • Soft occlusion, which is visually more appealing, but requires slightly more GPU.
Occlusions comparison

How do occlusions work?

Depth API provides real-time environment depth textures to your application. These textures can be passed to shaders, which use this information to determine a fragment’s position in relation to the real world. In other words, it determines if a fragment is in front of or behind real world objects.
Occlusions depth map

Limitations

Limitation
Reason
Suggested workaround
Occlusions flicker near surfaces
This is caused by an issue often referred to as “Z-fighting”. In 3D graphics, this usually happens when two virtual objects are rendered at the same depth. Environment depth values are produced within the error margin, so in this case, z-fighting is apparent even when the depth is not precisely the same across frames.
Consult this documentation’s section on Environment Depth Bias. However, it is recommended to offset objects that you place on Scene Model surfaces along the surface normal.
Occlusions aren’t matching the real-world and lag behind during fast motion
Real-time depth sensing has limitations that prevent pixel-perfect occlusions from being achieved at the same frame rate as app rendering.
Soft occlusion shaders reduce visibility issues, but apps must be designed considering this limitation.
Note: Hard occlusions are deprecated as of Meta XR Plugin for Unreal Engine 5.5. The EOculusXROcclusionsMode enum value has been renamed to HardOcclusions_Deprecated. Use soft occlusions for new projects.

Unreal Engine API overview

The Meta XR Plugin provides Blueprint-callable functions on UOculusXRFunctionLibrary for controlling environment depth occlusions:
FunctionTypeDescription
StartEnvironmentDepth()
BlueprintCallable
Creates the environment depth texture swap chain and starts receiving depth textures each frame
StopEnvironmentDepth()
BlueprintCallable
Destroys the swap chain and stops receiving depth textures
IsEnvironmentDepthStarted()
BlueprintPure
Returns true if environment depth is currently active
SetXROcclusionsMode(EOculusXROcclusionsMode)
BlueprintCallable
Sets the occlusion mode (Disabled, SoftOcclusions)
SetEnvironmentDepthHandRemoval(bool)
BlueprintCallable
Toggles hand removal from depth textures
The EOculusXROcclusionsMode enum has three values: Disabled (0), HardOcclusions_Deprecated (1), and SoftOcclusions (2).

Learn more