- iOS 8.0+
- macOS 10.11+
- tvOS 9.0+
- Mac Catalyst 13.0+Beta
MTLDepth object is used to define a specific configuration of the depth and stencil stages of a rendering pipeline. To create a
MTLDepth object, use standard allocation and initialization techniques.
To enable writing the depth value to a depth attachment, set the depthWriteEnabled property to
The depthCompareFunction property specifies how the depth test is performed. If a fragment’s depth value fails the depth test, the fragment is discarded.
MTLCompare is a commonly used value for
depth, because fragment values that are farther away from the viewer than the pixel depth value (a previously written fragment) fail the depth test and are considered occluded by the earlier depth value.
back properties define two independent stencil descriptors: one for front-facing primitives and the other for back-facing primitives, respectively. Both properties can be set to the same MTLStencilDescriptor object.