# SetBuffer

> Binds an input or output compute buffer.

## Definition

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

## SetBuffer(int, ComputeBuffer)

Binds an input or output compute buffer.

```csharp
public void SetBuffer(int nameID, ComputeBuffer buffer)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The ID of the buffer name in shader code. Use [Shader.PropertyToID](/engine/6000.7/script-reference/unityengine/shader/propertytoid.md) to get this ID.**** (\[ComputeBuffer]\(/engine/6000.7/script-reference/unityengine/computebuffer)): The buffer to bind.

### Remarks

Only shaders defined in the .raytrace file can access the buffer you designate as the argument for this method. To make this buffer accessible to all ray tracing shader types (closest hit, any hit, miss, etc.), call the [Shader.SetGlobalBuffer](/engine/6000.7/script-reference/unityengine/shader/setglobalbuffer.md) method instead.

## SetBuffer(int, GraphicsBuffer)

Binds an input or output compute buffer.

```csharp
public void SetBuffer(int nameID, GraphicsBuffer buffer)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The ID of the buffer name in shader code. Use [Shader.PropertyToID](/engine/6000.7/script-reference/unityengine/shader/propertytoid.md) to get this ID.**** (\[GraphicsBuffer]\(/engine/6000.7/script-reference/unityengine/graphicsbuffer)): The buffer to bind.

### Remarks

Only shaders defined in the .raytrace file can access the buffer you designate as the argument for this method. To make this buffer accessible to all ray tracing shader types (closest hit, any hit, miss, etc.), call the [Shader.SetGlobalBuffer](/engine/6000.7/script-reference/unityengine/shader/setglobalbuffer.md) method instead.

## SetBuffer(int, GraphicsBufferHandle)

Binds an input or output compute buffer.

```csharp
public void SetBuffer(int nameID, GraphicsBufferHandle bufferHandle)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The ID of the buffer name in shader code. Use [Shader.PropertyToID](/engine/6000.7/script-reference/unityengine/shader/propertytoid.md) to get this ID.**** (\[GraphicsBufferHandle]\(/engine/6000.7/script-reference/unityengine/graphicsbufferhandle)): The handle of the buffer to bind.

### Remarks

Only shaders defined in the .raytrace file can access the buffer you designate as the argument for this method. To make this buffer accessible to all ray tracing shader types (closest hit, any hit, miss, etc.), call the [Shader.SetGlobalBuffer](/engine/6000.7/script-reference/unityengine/shader/setglobalbuffer.md) method instead.

## SetBuffer(string, ComputeBuffer)

Binds an input or output compute buffer.

```csharp
public void SetBuffer(string name, ComputeBuffer buffer)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the buffer in shader code.**** (\[ComputeBuffer]\(/engine/6000.7/script-reference/unityengine/computebuffer)): The buffer to bind.

### Remarks

Only shaders defined in the .raytrace file can access the buffer you designate as the argument for this method. To make this buffer accessible to all ray tracing shader types (closest hit, any hit, miss, etc.), call the [Shader.SetGlobalBuffer](/engine/6000.7/script-reference/unityengine/shader/setglobalbuffer.md) method instead.

## SetBuffer(string, GraphicsBuffer)

Binds an input or output compute buffer.

```csharp
public void SetBuffer(string name, GraphicsBuffer buffer)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the buffer in shader code.**** (\[GraphicsBuffer]\(/engine/6000.7/script-reference/unityengine/graphicsbuffer)): The buffer to bind.

### Remarks

Only shaders defined in the .raytrace file can access the buffer you designate as the argument for this method. To make this buffer accessible to all ray tracing shader types (closest hit, any hit, miss, etc.), call the [Shader.SetGlobalBuffer](/engine/6000.7/script-reference/unityengine/shader/setglobalbuffer.md) method instead.

## SetBuffer(string, GraphicsBufferHandle)

Binds an input or output compute buffer.

```csharp
public void SetBuffer(string name, GraphicsBufferHandle bufferHandle)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the buffer in shader code.**** (\[GraphicsBufferHandle]\(/engine/6000.7/script-reference/unityengine/graphicsbufferhandle)): The handle of the buffer to bind.

### Remarks

Only shaders defined in the .raytrace file can access the buffer you designate as the argument for this method. To make this buffer accessible to all ray tracing shader types (closest hit, any hit, miss, etc.), call the [Shader.SetGlobalBuffer](/engine/6000.7/script-reference/unityengine/shader/setglobalbuffer.md) method instead.
