The latest AR Foundation 3.1.0-preview.1 release introduces a new component AROcclusionManager
. Adding this new component to the AR camera in your scene provides depth data to the ARCameraBackground
component so that any available depth information may be passed to the camera background shader.
In this initial implementation, the people occlusion functionality of ARKit 3 is used to generate depth information about people detected in the real world. The camera background rendering then uses this depth information, thus allowing the people to occlude any virtual content that appears behind them in the scene.
At this time, only iOS devices that support the ARKit 3 people occlusion functionality will produce occlusion effects with the new AROcclusionManager
. These are devices with the A12, A12X, or A13 chips running iOS 13 (or later).
Future devices will be supported when depth map functionality is added to the respective SDKs.
Simply adding the new AROcclusionManager
component to the AR camera (along with both the ARCameraManager
and ARCameraBackground
components) will enable automatic human occlusion to occur on supported devices.
The new AROcclusionManager
has 2 parameters: HumanSegmentationStencilMode
and HumanSegmentationDepthMode
. These two settings allow you to balance the quality of the depth information from ARKit and the performance cost for rendering the occlusion pass.
HumanSegmentationStencilMode
has 4 possible values as follows:
Disabled
- No human stencil image is produced, and automatic human occlusion is disabled.Fastest
- A human stencil image with dimensions 256x192 is produced.Medium
- A human stencil image with dimensions 960x720 is produced.Best
- A human stencil image with dimensions 1920x1440 is produced.
HumanSegmentationDepthMode
has 3 possible values as follows:
Disabled
- No human depth image is produced, and automatic human occlusion is disabled.Fastest
- A human depth image with dimensions 256x192 is produced.Best
- A filtering pass is applied to enhance the 256x192 human depth image.
Note the previous dimensions/behaviors are produced by the ARKit 3 implementation and are subject to change in future devices and/or ARKit SDK versions.
Modify the HumanSegmentationStencilMode
value to alter the boundaries of the human segmentation. Modify the HumanSegmentationDepthMode
to alter how the real world depth is measured. Disabling either setting will disable automatic human occlusion.