Engine API Reference - v2.6.1
    Preparing search index...

    Class DepthState

    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.

    Index

    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

    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 depthBias(): number

      Gets the constant depth bias added to each fragment's depth.

      Returns number

    • set depthBias(value: number): void

      Sets the constant depth bias added to each fragment's depth. Useful for decals to prevent z-fighting. Typically a small negative value (-0.1) is used to render the mesh slightly closer to the camera. Defaults to 0.

      Parameters

      • value: number

      Returns void

    • 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

    • get write(): boolean

      Gets whether depth writing is performed.

      Returns boolean

    • set write(value: boolean): void

      Sets whether depth writing is performed. If true, shader write a depth value to the depth buffer of the currently active render target. If false, no depth value is written.

      Parameters

      • value: boolean

      Returns void

    Methods