Develop

Depth API Material Graph

Updated: Apr 14, 2026
The Environment Depth material expression lets you sample the depth texture directly in your material graph. Depth is returned in world units (centimeters by default). The Environment Depth expression functions similarly to SceneDepth as a material expression that returns a per-pixel depth value. However, SceneDepth returns the depth of rendered virtual geometry from the scene’s Z-buffer, while Environment Depth returns real-world distance estimated by the headset’s stereo cameras and depth estimation system.
Use the Environment Depth expression to sample the depth texture. Depth is returned in world units (centimeters by default).
Note: The Environment Depth material expression node is only available in the Meta fork of the Unreal Engine. If you are using the stock engine, this node is not available and materials referencing it display as solid red. The basic Depth API features, such as StartEnvironmentDepth and occlusion modes, work with the standard Meta XR Plugin.

Prerequisites


Before using the Environment Depth material expression, ensure you have the following:
  • Device: Meta Quest 3
  • Engine: Meta fork of the Unreal Engine
  • Plugin: Meta XR Plugin
  • Scene support: In Edit > Project Settings > Meta XR, under Mobile, enable Scene Support
  • Scene permission: Request com.oculus.permission.USE_SCENE at runtime
  • Start environment depth: Call StartEnvironmentDepth (Blueprint node) or UOculusXRFunctionLibrary::StartEnvironmentDepth (C++) before the depth texture becomes available

Example use cases


The following examples demonstrate additional use cases beyond occlusion.
The first example gets the environment depth and maps it to the hue of a color, visualizing depth as a color gradient. The Environment Depth output connects to a hue mapping node, so the rendered color shifts continuously based on the estimated distance from the headset’s depth estimation system.
Environment Depth hue example.
The second example gets the environment depth and scene depth and compares the distance. An if-condition node compares the Environment Depth and SceneDepth outputs: if the environment depth is greater than the scene depth, the material renders red; otherwise it renders blue.
Environment Depth distance cutoff.

Depth API functions


The following Blueprint-callable functions are available in UOculusXRFunctionLibrary for controlling the depth texture:
FunctionDescription
StartEnvironmentDepth
Creates the environment depth texture swap chain and starts receiving the depth texture every frame
StopEnvironmentDepth
Destroys the environment depth texture swap chain
IsEnvironmentDepthStarted
Returns whether depth capture is currently running
SetEnvironmentDepthHandRemoval
When enabled, hand regions in the depth texture are replaced with an estimated depth of the environment behind the hands
For a complete working implementation, see the Unreal-OcclusionSample.