Depth occlusion

Note: you are currently viewing documentation for a beta or an older version of Varjo

Depth occlusion allows you to composite and sort real and virtual worlds together by utilizing the depth sensing capabilities of XR-3 and XR-1 Developer Edition. This allows you to bring your real hands into the virtual world or, in the case of XR-3, even other people’s hands.

Follow the steps below to enable depth occlusion for your project.

Using depth occlusion

Enable the mixed reality cameras as described in Mixed reality with Varjo XR Plugin.

Make sure you have the Submit Depth flag enabled in Varjo settings.

To enable or disable depth estimation, call the respective methods in the VarjoMixedReality class.

For example, you can add these calls in the OnEnable and OnDisable functions of one of the MonoBehaviours in the scene. In addition to enabling or disabling the depth sensing capabilities of the headset, these methods set the Depth Sorting layer flag so that there is no need to set it separately.

private void OnEnable()
{
    // Enable Depth Estimation.
    VarjoMixedReality.EnableDepthEstimation();
}

private void OnDisable()
{
    // Disable Depth Estimation.
    VarjoMixedReality.DisableDepthEstimation();
}

We recommend that you set the depth test range to enable finer control over the range included in depth testing. To set a range, select Depth Test Range Enabled in the settings and adjusting Depth Test Near Z and Depth Test Far Z values.

For example, if you want to bring only your hands into the virtual environment, you could set the Depth Test Far Z value to 0.8, which corresponds to 0.8 meters from the mixed reality cameras or roughly an arm’s length.

You can also set these values from a script using the functions in the VarjoRendering class.