# SetRandomWriteTarget

> Set random write target for Shader Model 4.5 level pixel shaders.

## Definition

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

## SetRandomWriteTarget(int, RenderTargetIdentifier)

Set random write target for [Shader Model 4.5](/engine/6000.5/manual/materials-and-shaders/shaders/writing-custom/shader-writing/writing-shader-tags/sl-shader-compile-targets.md) level pixel shaders.

```csharp
public void SetRandomWriteTarget(int index, RenderTargetIdentifier rt)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the random write target in the shader.**** (\[RenderTargetIdentifier]\(/engine/6000.5/script-reference/unityengine/rendering/rendertargetidentifier)): RenderTargetIdentifier to set as the write target.

### Remarks

This is the CommandBuffer equivalent of [Graphics.SetRandomWriteTarget](/engine/6000.5/script-reference/unityengine/graphics/setrandomwritetarget.md). The same limitations and exceptions apply to this call as to [Graphics.SetRandomWriteTarget](/engine/6000.5/script-reference/unityengine/graphics/setrandomwritetarget.md).

## SetRandomWriteTarget(int, ComputeBuffer, bool)

Set random write target for [Shader Model 4.5](/engine/6000.5/manual/materials-and-shaders/shaders/writing-custom/shader-writing/writing-shader-tags/sl-shader-compile-targets.md) level pixel shaders.

```csharp
public void SetRandomWriteTarget(int index, ComputeBuffer buffer, bool preserveCounterValue)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the random write target in the shader.**** (\[ComputeBuffer]\(/engine/6000.5/script-reference/unityengine/computebuffer)): Buffer to set as the write target.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to leave the append/consume counter value unchanged.

### Remarks

This is the CommandBuffer equivalent of [Graphics.SetRandomWriteTarget](/engine/6000.5/script-reference/unityengine/graphics/setrandomwritetarget.md). The same limitations and exceptions apply to this call as to [Graphics.SetRandomWriteTarget](/engine/6000.5/script-reference/unityengine/graphics/setrandomwritetarget.md).

## SetRandomWriteTarget(int, ComputeBuffer)

Set random write target for [Shader Model 4.5](/engine/6000.5/manual/materials-and-shaders/shaders/writing-custom/shader-writing/writing-shader-tags/sl-shader-compile-targets.md) level pixel shaders.

```csharp
public void SetRandomWriteTarget(int index, ComputeBuffer buffer)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the random write target in the shader.**** (\[ComputeBuffer]\(/engine/6000.5/script-reference/unityengine/computebuffer)): Buffer to set as the write target.

### Remarks

This is the CommandBuffer equivalent of [Graphics.SetRandomWriteTarget](/engine/6000.5/script-reference/unityengine/graphics/setrandomwritetarget.md). The same limitations and exceptions apply to this call as to [Graphics.SetRandomWriteTarget](/engine/6000.5/script-reference/unityengine/graphics/setrandomwritetarget.md).

## SetRandomWriteTarget(int, GraphicsBuffer, bool)

Set random write target for [Shader Model 4.5](/engine/6000.5/manual/materials-and-shaders/shaders/writing-custom/shader-writing/writing-shader-tags/sl-shader-compile-targets.md) level pixel shaders.

```csharp
public void SetRandomWriteTarget(int index, GraphicsBuffer buffer, bool preserveCounterValue)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the random write target in the shader.**** (\[GraphicsBuffer]\(/engine/6000.5/script-reference/unityengine/graphicsbuffer)): Buffer to set as the write target.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Whether to leave the append/consume counter value unchanged.

### Remarks

This is the CommandBuffer equivalent of [Graphics.SetRandomWriteTarget](/engine/6000.5/script-reference/unityengine/graphics/setrandomwritetarget.md). The same limitations and exceptions apply to this call as to [Graphics.SetRandomWriteTarget](/engine/6000.5/script-reference/unityengine/graphics/setrandomwritetarget.md).

## SetRandomWriteTarget(int, GraphicsBuffer)

Set random write target for [Shader Model 4.5](/engine/6000.5/manual/materials-and-shaders/shaders/writing-custom/shader-writing/writing-shader-tags/sl-shader-compile-targets.md) level pixel shaders.

```csharp
public void SetRandomWriteTarget(int index, GraphicsBuffer buffer)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the random write target in the shader.**** (\[GraphicsBuffer]\(/engine/6000.5/script-reference/unityengine/graphicsbuffer)): Buffer to set as the write target.

### Remarks

This is the CommandBuffer equivalent of [Graphics.SetRandomWriteTarget](/engine/6000.5/script-reference/unityengine/graphics/setrandomwritetarget.md). The same limitations and exceptions apply to this call as to [Graphics.SetRandomWriteTarget](/engine/6000.5/script-reference/unityengine/graphics/setrandomwritetarget.md).
