Table of Contents

Class DepthPreprocessor

Script that will preprocess depth data for meshing.

public class DepthPreprocessor : DontCreateNewSingleton<DepthPreprocessor>
Inheritance
object
DepthPreprocessor

Remarks

This script by itself does very little. It is meant to be used with shaders which utilize the data exposed by this script and with other scripts from this package, like DepthMesher and CPUDepthSampler.

This directly conflicts with Meta's EnvironmentDepthManager and any other script that acquires the depth textures using XROcclusionSubsystem.TryGetFrame, potentially including Unity's AROcclusionManager. This script automatically populates the following global shader variables, to keep some compatibility with EnvironmentDepthManager:

  • _EnvironmentDepthTexture
  • _EnvironmentDepthReprojectionMatrices
  • _EnvironmentDepthZBufferParams
  • _PreprocessedEnvironmentDepthTexture

The following custom global shader variables are also defined by this script:
  • _EnvironmentDepthInverseReprojectionMatricesThe inverse of _EnvironmentDepthReprojectionMatrices, used to convert points from the current depth texture frame into world space.
  • _EnvironmentDepthProjectionMatricesProjection matrices for the current depth texture frame.
  • _EnvironmentDepthViewMatricesView matrices for the current depth texture frame.
  • _EnvironmentDepthWorldPositionsTextureTexture containing world-space positions from the XR depth texture (computed for the left eye).
  • _EnvironmentDepthWorldNormalsTextureTexture containing world-space normals from the XR depth texture (computed for the left eye).

Fields

DepthInverseReprojectionMatrices

The inverse of DepthReprojectionMatrices, used to convert points from the current depth texture frame into world space.

public readonly Matrix4x4[] DepthInverseReprojectionMatrices

Field Value

Matrix4x4[]

DepthProjectionMatrices

Projection matrices for the current depth texture frame.

public readonly Matrix4x4[] DepthProjectionMatrices

Field Value

Matrix4x4[]

DepthReprojectionMatrices

Matrices used to convert points in world space to points in the current depth texture frame.

public readonly Matrix4x4[] DepthReprojectionMatrices

Field Value

Matrix4x4[]

DepthViewMatrices

View matrices for the current depth texture frame.

public readonly Matrix4x4[] DepthViewMatrices

Field Value

Matrix4x4[]

EnableSoftOcclusion

public bool EnableSoftOcclusion

Field Value

bool

OnDataAvailable

Invoked when this script processes its first depth frame after enabling.

public UnityEvent? OnDataAvailable

Field Value

UnityEvent?

Properties

IsDataAvailable

Flag set when this script processes its first depth frame after being enabled.

public bool IsDataAvailable { get; }

Property Value

bool

IsSupported

Is the Meta Quest Depth API supported on the current device?

public bool IsSupported { get; }

Property Value

bool

Remarks

Do not use this from Awake.

NormalsTexture

Texture containing the normal vectors of the points in the XR depth texture converted to world space.

public RenderTexture? NormalsTexture { get; }

Property Value

RenderTexture?

PositionsTexture

Texture containing the points in the XR depth texture converted to world space.

public RenderTexture? PositionsTexture { get; }

Property Value

RenderTexture?

Methods

Awake()

protected override void Awake()

OnDestroy()

protected void OnDestroy()

OnDisable()

protected void OnDisable()

OnEnable()

protected void OnEnable()