An invisible material that hides objects rendered behind it.
Add an `OcclusionMaterial` to a model by setting it as one of the
``ModelComponent/materials`` in a ``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 |
|:-:|:-:|
|  | 
Members (6)
get · iOS 18.0+
readsDepth
TypeScript
get readsDepth(): boolean
Swift declaration
var readsDepth: Bool { get set }
A boolean value that determines whether this material performs the depth test by reading RealityKit's depth buffer.
If true, meshes with this material will depth test each of their fragments when being rendered.
If an object that writes depth is in front of this material, this material will be hidden.
If false, meshes with this material will ignore the depth test, and always render all of their
fragments during their draw call, regardless of the positioning of other objects in the scene.
Note that other objects may still render on top of this material, depending on draw order.
The default value is true.
set · iOS 18.0+
readsDepth
TypeScript
set readsDepth(value: boolean)
Swift declaration
var readsDepth: Bool { get set }
A boolean value that determines whether this material performs the depth test by reading RealityKit's depth buffer.
If true, meshes with this material will depth test each of their fragments when being rendered.
If an object that writes depth is in front of this material, this material will be hidden.
If false, meshes with this material will ignore the depth test, and always render all of their
fragments during their draw call, regardless of the positioning of other objects in the scene.
Note that other objects may still render on top of this material, depending on draw order.
The default value is true.
get · iOS 18.0+
faceCulling
TypeScript
get faceCulling(): MaterialParameterTypes_FaceCulling
Swift declaration
var faceCulling: OcclusionMaterial.FaceCulling { get set }
A process in which the system specifies polygons to remove before
rendering a mesh using this material.
To improve performance, RealityKit culls polygons, or faces, that it
determines won’t be visible. Discarding faces that aren’t part of the
final render eliminates the need to do any calculations for those
faces.
RealityKit recognizes when a face aims toward the camera (a front face)
or away from the camera (a back face). This value controls the type of
faces RealityKit culls.
This value defaults to ``MaterialParameterTypes/FaceCulling/back``,
which means RealityKit removes faces that point away from the camera.
Most of the time, this is the correct behavior, because back faces are
usually obscured by other front-facing polygons.
You can change the culling behavior to cull front faces instead or to
turn off face culling altogether, but be aware that turning off face
culling results in less efficient rendering and may negatively impact
your app’s frame rate.
set · iOS 18.0+
faceCulling
TypeScript
set faceCulling(value: MaterialParameterTypes_FaceCulling)
Swift declaration
var faceCulling: OcclusionMaterial.FaceCulling { get set }
A process in which the system specifies polygons to remove before
rendering a mesh using this material.
To improve performance, RealityKit culls polygons, or faces, that it
determines won’t be visible. Discarding faces that aren’t part of the
final render eliminates the need to do any calculations for those
faces.
RealityKit recognizes when a face aims toward the camera (a front face)
or away from the camera (a back face). This value controls the type of
faces RealityKit culls.
This value defaults to ``MaterialParameterTypes/FaceCulling/back``,
which means RealityKit removes faces that point away from the camera.
Most of the time, this is the correct behavior, because back faces are
usually obscured by other front-facing polygons.
You can change the culling behavior to cull front faces instead or to
turn off face culling altogether, but be aware that turning off face
culling results in less efficient rendering and may negatively impact
your app’s frame rate.