# ClearRenderTarget

> Adds a "clear render target" command.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Rendering](/engine/6000.7/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule

## ClearRenderTarget(bool, bool, Color)

Adds a "clear render target" command.

```csharp
public void ClearRenderTarget(bool clearDepth, bool clearColor, Color backgroundColor)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to clear both the depth buffer and the stencil buffer.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to clear the color buffer.**** (\[Color]\(/engine/6000.7/script-reference/unityengine/color)): Color to clear with. All color targets specified in `clearFlags` are cleared to this color.

## ClearRenderTarget(bool, bool, Color, float)

Adds a "clear render target" command.

```csharp
public void ClearRenderTarget(bool clearDepth, bool clearColor, Color backgroundColor, float depth)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to clear both the depth buffer and the stencil buffer.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to clear the color buffer.**** (\[Color]\(/engine/6000.7/script-reference/unityengine/color)): Color to clear with. All color targets specified in `clearFlags` are cleared to this color.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Depth to clear with (default is 1.0).

## ClearRenderTarget(bool, bool, Color, float, uint)

Adds a "clear render target" command.

```csharp
public void ClearRenderTarget(bool clearDepth, bool clearColor, Color backgroundColor, float depth = 1, uint stencil = 0)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to clear both the depth buffer and the stencil buffer.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to clear the color buffer.**** (\[Color]\(/engine/6000.7/script-reference/unityengine/color)): Color to clear with. All color targets specified in `clearFlags` are cleared to this color.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Depth to clear with (default is 1.0).**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): Stencil to clear with (default is 0).

## ClearRenderTarget(RTClearFlags, Color, float, uint)

Adds a "clear render target" command.

```csharp
public void ClearRenderTarget(RTClearFlags clearFlags, Color backgroundColor, float depth = 1, uint stencil = 0)
```

### Parameters

**** (\[RTClearFlags]\(/engine/6000.7/script-reference/unityengine/rendering/rtclearflags)): Which render targets to clear, defined using a bitwise OR combination of [RTClearFlags](/engine/6000.7/script-reference/unityengine/rendering/rtclearflags.md) values.**** (\[Color]\(/engine/6000.7/script-reference/unityengine/color)): Color to clear with. All color targets specified in `clearFlags` are cleared to this color.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Depth to clear with (default is 1.0).**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): Stencil to clear with (default is 0).

## ClearRenderTarget(RTClearFlags, Color\[], float, uint)

Adds a "clear render target" command.

```csharp
public void ClearRenderTarget(RTClearFlags clearFlags, Color[] backgroundColors, float depth = 1, uint stencil = 0)
```

### Parameters

**** (\[RTClearFlags]\(/engine/6000.7/script-reference/unityengine/rendering/rtclearflags)): Which render targets to clear, defined using a bitwise OR combination of [RTClearFlags](/engine/6000.7/script-reference/unityengine/rendering/rtclearflags.md) values.**** (\[Color\[]]\(/engine/6000.7/script-reference/unityengine/color)): Colors to clear with. If a subset of all color targets is selected using `clearFlags` then this array should be densely packed and its length should be equal to the total number of color targets selected.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Depth to clear with (default is 1.0).**** (\[uint]\(https\://learn.microsoft.com/dotnet/api/system.uint32)): Stencil to clear with (default is 0).
