DepthState is a descriptor that defines how the depth value of the fragment is used by the rendering pipeline. A depth state can be set on a material using Material#depthState, or in some cases on the graphics device using GraphicsDevice#setDepthState.

For the best performance, do not modify depth state after it has been created, but create multiple depth states and assign them to the material or graphics device as needed.

Constructors

Properties

key: number = 0

A unique number representing the depth state. You can use this number to quickly compare two depth states for equality. The key is always maintained valid without a dirty flag, to avoid condition check at runtime, considering these change rarely.

DEFAULT: DepthState = ...

A default depth state that has the depth testing function set to FUNC_LESSEQUAL and depth writes enabled.

NODEPTH: DepthState = ...

A depth state that always passes the fragment but does not write depth to the depth buffer.

WRITEDEPTH: DepthState = ...

A depth state that always passes the fragment and writes depth to the depth buffer.

Accessors

  • get test(): boolean
  • Gets whether depth testing is performed.

    Returns boolean

  • set test(value: boolean): void
  • Sets whether depth testing is performed. If true, a shader fragment is only written to the current render target if it passes the depth test. If false, it is written regardless of what is in the depth buffer. Note that when depth testing is disabled, writes to the depth buffer are also disabled. Defaults to true.

    Parameters

    • value: boolean

    Returns void

Methods