AR Shader Occlusion component
The ARShaderOcclusion component exposes depth render texture information directly to global shader memory, instead of working through the AR Camera Background component. With shader occlusion, you're able to customize occlusion functionality by writing your own shaders. You can use the occlusion and confidence maps to apply techniques such as custom edge smoothing, and visual effects.
Shader occlusion enables occlusion on devices with a Head-mounted Display (HMD). The AR Shader Occlusion component will only function on OpenXR platforms. The AR Shader Occlusion component may make available multiple depth render textures if stereo depth information is provided by the platform.
The component subscribes to AROcclusionManager.frameReceived to receive depth textures, then uses Graphics.CopyTexture to copy the textures from the GPU to the CPU. Once it has done so, it calls Shader.SetGlobalTexture to store the textures as a global texture for use in shaders.
AR Shader Occlusion component.
Add the AR Shader Occlusion component to your scene
To enable shader occlusion, add the ARShaderOcclusion
and AROcclusionManager to your Camera as outlined in Managers.
Shader occlusion samples
HMD occlusion shader example image.
For general information on writing shaders, consult the Writing shaders page in the Unity manual.
The AR Foundation Samples app provides an example of how to use HMD occlusion with shaders in the HMD Occlusion sample scene.