- iOS 13.0+
- Xcode 11.0+
By default, virtual content covers anything in the camera feed. For example, when a person passes in front of a virtual object, the object is drawn on top of the person, which can break the illusion of the AR experience.
To cover your app’s virtual content with people that ARKit perceives in the camera feed, you enable people occlusion. Your app can then render a virtual object behind people who pass in front of the camera. ARKit accomplishes the occlusion by identifying regions in the camera feed where people reside, and preventing virtual content from drawing into that region’s pixels.
This sample renders its graphics using RealityKit, but you can follow the same steps to use people occlusion with SceneKit. To enable people occlusion in Metal apps, see Effecting People Occlusion in Custom Renderers.
Verify Device Support for People Occlusion
People occlusion is supported on Apple A12 and later devices. Before attempting to enable people occlusion, verify that the user’s device supports it.
Enable People Occlusion
If the user’s device supports people occlusion, enable it by adding the
person option to your configuration’s frame semantics.
Any time you change your session’s
configuration, rerun the session to effect the configuration change.
person option specifies that a person occludes a virtual object only when the person is closer to the camera than the virtual object.
person frame semantic gives you the option of always occluding virtual content with any people that ARKit perceives in the camera feed irrespective of depth. This technique is useful, for example, in green-screen scenarios.
Disable People Occlusion
You might choose to disable people occlusion for performance reasons if, for example, no virtual content is present in the scene, or if the device has reached a serious or critical
Process). To temporarily disable people occlusion, remove that option from your app’s
Then, rerun your session to effect the configuration change.