<!--
{
  "availability" : [
    "Xcode: 16.0.0 -",
    "iOS: 13.0.0 -"
  ],
  "documentType" : "article",
  "framework" : "ARKit",
  "identifier" : "/documentation/ARKit/occluding-virtual-content-with-people",
  "metadataVersion" : "0.1.0",
  "role" : "sampleCode",
  "title" : "Occluding virtual content with people"
}
-->

# Occluding virtual content with people

Cover your app’s virtual content with people that ARKit perceives in the camera feed.

## Overview

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.

![Screenshot of virtual books drawn on top of a person.](images/com.apple.arkit/figure1-annotated.png)

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.

![Screenshot of the virtual books behind the person.](images/com.apple.arkit/figure2-annotated.png)

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](/documentation/ARKit/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.

```swift
guard ARWorldTrackingConfiguration.supportsFrameSemantics(.personSegmentationWithDepth) else {
    fatalError("People occlusion is not supported on this device.")
}
```

> Note: If your device doesn’t support people occlusion, the sample stops. However, if the user’s device doesn’t support people occlusion, you should continue your AR experience without it.

## Enable people occlusion

If the user’s device supports people occlusion, enable it by adding the

arconfiguration/framesemantics/3194576-personsegmentationwithdepth
[`personSegmentationWithDepth`](/documentation/ARKit/ARConfiguration/FrameSemantics-swift.struct/personSegmentationWithDepth) option to your configuration’s frame semantics.

```swift
config.frameSemantics.insert(.personSegmentationWithDepth)
```

Any time you change your session’s [`configuration`](/documentation/ARKit/ARSession/configuration), rerun the session to effect the configuration change.

```swift
arView.session.run(config)
```

The [`personSegmentationWithDepth`](/documentation/ARKit/ARConfiguration/FrameSemantics-swift.struct/personSegmentationWithDepth) option specifies that a person occludes a virtual object only when the person is closer to the camera than the virtual object.

![Screenshot of people occlusion with depth.](images/com.apple.arkit/figure3-annotated.png)

Alternatively, the [`personSegmentation`](/documentation/ARKit/ARConfiguration/FrameSemantics-swift.struct/personSegmentation) 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.

![Screenshot of people occlusion with virtual background.](images/com.apple.arkit/figure4-annotated.png)

## 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 <doc://com.apple.documentation/documentation/Foundation/ProcessInfo/thermalState-swift.property> (see <doc://com.apple.documentation/documentation/Foundation/ProcessInfo/ThermalState-swift.enum>). To temporarily disable people occlusion, remove that option from your app’s [`frameSemantics`](/documentation/ARKit/ARConfiguration/frameSemantics-swift.property).

```swift
config.frameSemantics.remove(.personSegmentationWithDepth)
```

Then, rerun your session to effect the configuration change.

```swift
arView.session.run(config)
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)