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

  • Create a new Depth State instance.

    Parameters

    • func: number = FUNC_LESSEQUAL

      Controls how the depth of the fragment is compared against the current depth contained in the depth buffer. See DepthState#func for details. Defaults to FUNC_LESSEQUAL.

    • write: boolean = true

      If true, depth values are written to the depth buffer of the currently active render target. Defaults to true.

    Returns DepthState

Properties

data: number = 0

Bitfield representing the depth state.

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
  • Returns boolean

  • set test(value): void
  • 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