<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/OcclusionMaterial",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation17OcclusionMaterialV"
  },
  "title" : "OcclusionMaterial"
}
-->

# OcclusionMaterial

An invisible material that hides objects rendered behind it.

```
struct OcclusionMaterial
```

## Overview

Add an `OcclusionMaterial` to a model by setting it as one of the
[`materials`](/documentation/RealityKit/ModelComponent/materials) in a [`ModelComponent`](/documentation/RealityKit/ModelComponent).

```swift
let model = ModelComponent(
    mesh: .generateBox(size: 1),
    materials: [OcclusionMaterial()]
)
smallBoxEntity.components.set(model)
```

For example, on the left is a case of two cubes, the larger red cube is slightly further from the camera and has a simple material.
The slightly smaller and closer cube has no material in the left image and an occlusion material on the right image.

|No material                                                                                                                                                                                                                                                    |Occlusion material                                                                                                                                                                                               |
|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|![A screenshot of two cubes in a living room scene. One cube is red and is slightly further from the camera, the other cube has a magenta striped material, is slightly closer to the camera, and is smaller than the red cube.](occlusionmaterial-not-applied)|![A screenshot of a partial red shape in a living room scene. The shape is of a cube with a cut-out in the shape of another cube slightly towards the upper right corner of the cube.](occlusionmaterial-applied)|

## Topics

### Creating an occlusion material

[`init(receivesDynamicLighting:)`](/documentation/RealityKit/OcclusionMaterial/init(receivesDynamicLighting:))

Creates an occlusion material.

[`init()`](/documentation/RealityKit/OcclusionMaterial/init())

### Receiving dynamic lighting

[`receivesDynamicLighting`](/documentation/RealityKit/OcclusionMaterial/receivesDynamicLighting)

A Boolean that indicates whether the occlusion material receives dynamic
lighting.

### Setting depth testing properties

[`readsDepth`](/documentation/RealityKit/OcclusionMaterial/readsDepth)

A boolean value that determines whether this material performs the depth test by reading RealityKit’s depth buffer.



---

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)