# DepthState

> Values for the depth state.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine.Rendering](/engine/6000.7/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IEquatable\<DepthState>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public struct DepthState : IEquatable<DepthState>
```

## Remarks

Use this with [RenderStateBlock](/engine/6000.7/script-reference/unityengine/rendering/renderstateblock.md) and [ScriptableRenderContext.DrawRenderers](/engine/6000.7/script-reference/unityengine/rendering/scriptablerendercontext/drawrenderers.md) to override the GPU's render state.

Corresponds to the `ZTest` and `ZWrite` commands in [ShaderLab](/engine/6000.7/manual/materials-and-shaders/shaders/reference/sl-reference.md).

Additional Resources: [RenderStateBlock](/engine/6000.7/script-reference/unityengine/rendering/renderstateblock.md), \[\[ScriptableRenderContext.DrawRenderers], ShaderLab command: ZTest, [ShaderLab command: ZWrite](/engine/6000.7/manual/materials-and-shaders/shaders/reference/sl-reference/sl-commands/sl-zwrite.md).

## Constructors

| Constructor                                                                                                                                  | Description                                      |
| -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| [DepthState(System.Boolean,UnityEngine.Rendering.CompareFunction)](/engine/6000.7/script-reference/unityengine/rendering/depthstate/ctor.md) | Creates a new depth state with the given values. |

## Properties

| Property                                                                                               | Description                                                               |
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
| [compareFunction](/engine/6000.7/script-reference/unityengine/rendering/depthstate/comparefunction.md) | How should depth testing be performed.                                    |
| [writeEnabled](/engine/6000.7/script-reference/unityengine/rendering/depthstate/writeenabled.md)       | Controls whether pixels from this object are written to the depth buffer. |

## Static Properties

| Property                                                                                         | Description                         |
| ------------------------------------------------------------------------------------------------ | ----------------------------------- |
| [defaultValue](/engine/6000.7/script-reference/unityengine/rendering/depthstate/defaultvalue.md) | Default values for the depth state. |
