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.
Summary
Static Properties
DEFAULT | A default depth state that has the depth testing function set to FUNC_LESSEQUAL and depth writes enabled.[read only] |
NODEPTH | A depth state that always passes the fragment but does not write depth to the depth buffer.[read only] |
WRITEDEPTH | A depth state that always passes the fragment and writes depth to the depth buffer.[read only] |
Properties
func | Controls how the depth of the fragment is compared against the current depth contained in the depth buffer. |
test | If true, a shader fragment is only written to the current render target if it passes the depth test. |
write | If true, shader write a depth value to the depth buffer of the currently active render target. |
Methods
clone | Returns an identical copy of the specified depth state. |
copy | Copies the contents of a source depth state to this depth state. |
equals | Reports whether two DepthStates are equal. |
Details
Static Properties
DEFAULT | A default depth state that has the depth testing function set to FUNC_LESSEQUAL and depth writes enabled. [read only] |
NODEPTH | A depth state that always passes the fragment but does not write depth to the depth buffer. [read only] |
WRITEDEPTH | A depth state that always passes the fragment and writes depth to the depth buffer. [read only] |
Constructor
DepthState(func, write)
Create a new Depth State instance.
Parameters
func | number | 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 | If true, depth values are written to the depth buffer of the currently active render target. Defaults to true. |
Properties
Controls how the depth of the fragment is compared against the current depth contained in the depth buffer. Can be:
- FUNC_NEVER: don't draw
- FUNC_LESS: draw if new depth < depth buffer
- FUNC_EQUAL: draw if new depth == depth buffer
- FUNC_LESSEQUAL: draw if new depth <= depth buffer
- FUNC_GREATER: draw if new depth > depth buffer
- FUNC_NOTEQUAL: draw if new depth != depth buffer
- FUNC_GREATEREQUAL: draw if new depth >= depth buffer
- FUNC_ALWAYS: always draw
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.
If true, shader write a depth value to the depth buffer of the currently active render target. If false, no depth value is written.
Methods
clone()
Returns an identical copy of the specified depth state.
Returns
thisThe result of the cloning.
copy(rhs)
Copies the contents of a source depth state to this depth state.
Parameters
rhs | DepthState | A depth state to copy from. |
Returns
DepthStateSelf for chaining.
equals(rhs)
Reports whether two DepthStates are equal.
Parameters
rhs | DepthState | The depth state to compare to. |
Returns
booleanTrue if the depth states are equal and false otherwise.