API reference

DepthTest

DepthTest

enum DepthTest : Enum<DepthTest>
Defines depth test comparison functions used in 3D rendering.
Depth testing is a technique used in 3D graphics to determine whether a fragment (pixel) should be drawn based on its depth value compared to the existing value in the depth buffer. This helps ensure that objects closer to the camera properly occlude objects that are farther away.
Each enum value represents a different comparison function that can be applied when testing the depth of a new fragment against the existing depth buffer value. The comparison determines whether the fragment passes the depth test and gets rendered.
Example usage:
// Configure a material to only render pixels that are closer to the camera than existing pixels
sceneMaterial.setDepthTest(DepthTest.LESS)

// Configure a material to always render regardless of depth (useful for debug lines)
sceneMaterial.setDepthTest(DepthTest.ALWAYS)

// Configure a material to only render pixels at exactly the same depth as existing pixels
sceneMaterial.setDepthTest(DepthTest.EQUAL)

Entries

NameSummary
NEVER

Never passes the depth test. The fragment is always discarded regardless of depth. Rarely used in practice.
LESS

Passes the depth test if the fragment’s depth is less than the stored depth. This is the most common depth test function for standard 3D rendering, as it ensures closer objects occlude farther ones.
EQUAL

Passes the depth test if the fragment’s depth is equal to the stored depth. Useful for drawing objects at exactly the same depth, like decals or overlays.
LESS_OR_EQUAL

Passes the depth test if the fragment’s depth is less than or equal to the stored depth. Similar to LESS, but also includes fragments at exactly the same depth.
GREATER

Passes the depth test if the fragment’s depth is greater than the stored depth. Can be used for special effects or rendering the back faces of objects.
NOT_EQUAL

Passes the depth test if the fragment’s depth is not equal to the stored depth. Rarely used in standard rendering.
GREATER_OR_EQUAL

Passes the depth test if the fragment’s depth is greater than or equal to the stored depth. Can be used for special effects or when rendering from back to front.
ALWAYS

Always passes the depth test. The fragment is always drawn regardless of depth. Useful for UI elements, skyboxes, or other objects that should not be occluded.

Properties

NameSummary
encoding
val encoding: Int

Integer value corresponding to the native graphics API encoding for this depth test function
name
val name: String
ordinal
val ordinal: Int

Functions

NameSummary
valueOf
fun valueOf(value: String): DepthTest

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
values
fun values(): Array<DepthTest>

Returns an array containing the constants of this enum type, in the order they’re declared.