# SetRayTracingConstantBufferParam

> Adds a command to set a constant buffer on a RayTracingShader.

## Definition

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

## SetRayTracingConstantBufferParam(RayTracingShader, int, ComputeBuffer, int, int)

Adds a command to set a constant buffer on a [RayTracingShader](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader.md).

```csharp
public void SetRayTracingConstantBufferParam(RayTracingShader rayTracingShader, int nameID, ComputeBuffer buffer, int offset, int size)
```

### Parameters

**** (\[RayTracingShader]\(/engine/6000.3/script-reference/unityengine/rendering/raytracingshader)): The [RayTracingShader](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader.md) to set parameter for.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The ID of the property name for the constant buffer in shader code. Use [Shader.PropertyToID](/engine/6000.3/script-reference/unityengine/shader/propertytoid.md) to get this ID.**** (\[ComputeBuffer]\(/engine/6000.3/script-reference/unityengine/computebuffer)): The buffer to bind as constant buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The offset in bytes from the beginning of the buffer to bind. Must be a multiple of [SystemInfo.constantBufferOffsetAlignment](/engine/6000.3/script-reference/unityengine/systeminfo/constantbufferoffsetalignment.md), or 0 if that value is 0.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of bytes to bind.

### Remarks

Only shaders defined in the .raytrace file can access the constant buffer you designate as the argument for this method. To make this constant buffer accessible to all ray tracing shader types (closest hit, any hit, or miss, for example), call the [CommandBuffer.SetGlobalConstantBuffer](/engine/6000.3/script-reference/unityengine/rendering/commandbuffer/setglobalconstantbuffer.md) method instead.

See [RayTracingShader.SetConstantBuffer](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader/setconstantbuffer.md) for usage.

## SetRayTracingConstantBufferParam(RayTracingShader, string, ComputeBuffer, int, int)

Adds a command to set a constant buffer on a [RayTracingShader](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader.md).

```csharp
public void SetRayTracingConstantBufferParam(RayTracingShader rayTracingShader, string name, ComputeBuffer buffer, int offset, int size)
```

### Parameters

**** (\[RayTracingShader]\(/engine/6000.3/script-reference/unityengine/rendering/raytracingshader)): The [RayTracingShader](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader.md) to set parameter for.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the constant buffer in shader code.**** (\[ComputeBuffer]\(/engine/6000.3/script-reference/unityengine/computebuffer)): The buffer to bind as constant buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The offset in bytes from the beginning of the buffer to bind. Must be a multiple of [SystemInfo.constantBufferOffsetAlignment](/engine/6000.3/script-reference/unityengine/systeminfo/constantbufferoffsetalignment.md), or 0 if that value is 0.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of bytes to bind.

### Remarks

Only shaders defined in the .raytrace file can access the constant buffer you designate as the argument for this method. To make this constant buffer accessible to all ray tracing shader types (closest hit, any hit, or miss, for example), call the [CommandBuffer.SetGlobalConstantBuffer](/engine/6000.3/script-reference/unityengine/rendering/commandbuffer/setglobalconstantbuffer.md) method instead.

See [RayTracingShader.SetConstantBuffer](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader/setconstantbuffer.md) for usage.

## SetRayTracingConstantBufferParam(RayTracingShader, int, GraphicsBuffer, int, int)

Adds a command to set a constant buffer on a [RayTracingShader](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader.md).

```csharp
public void SetRayTracingConstantBufferParam(RayTracingShader rayTracingShader, int nameID, GraphicsBuffer buffer, int offset, int size)
```

### Parameters

**** (\[RayTracingShader]\(/engine/6000.3/script-reference/unityengine/rendering/raytracingshader)): The [RayTracingShader](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader.md) to set parameter for.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The ID of the property name for the constant buffer in shader code. Use [Shader.PropertyToID](/engine/6000.3/script-reference/unityengine/shader/propertytoid.md) to get this ID.**** (\[GraphicsBuffer]\(/engine/6000.3/script-reference/unityengine/graphicsbuffer)): The buffer to bind as constant buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The offset in bytes from the beginning of the buffer to bind. Must be a multiple of [SystemInfo.constantBufferOffsetAlignment](/engine/6000.3/script-reference/unityengine/systeminfo/constantbufferoffsetalignment.md), or 0 if that value is 0.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of bytes to bind.

### Remarks

Only shaders defined in the .raytrace file can access the constant buffer you designate as the argument for this method. To make this constant buffer accessible to all ray tracing shader types (closest hit, any hit, or miss, for example), call the [CommandBuffer.SetGlobalConstantBuffer](/engine/6000.3/script-reference/unityengine/rendering/commandbuffer/setglobalconstantbuffer.md) method instead.

See [RayTracingShader.SetConstantBuffer](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader/setconstantbuffer.md) for usage.

## SetRayTracingConstantBufferParam(RayTracingShader, string, GraphicsBuffer, int, int)

Adds a command to set a constant buffer on a [RayTracingShader](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader.md).

```csharp
public void SetRayTracingConstantBufferParam(RayTracingShader rayTracingShader, string name, GraphicsBuffer buffer, int offset, int size)
```

### Parameters

**** (\[RayTracingShader]\(/engine/6000.3/script-reference/unityengine/rendering/raytracingshader)): The [RayTracingShader](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader.md) to set parameter for.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the constant buffer in shader code.**** (\[GraphicsBuffer]\(/engine/6000.3/script-reference/unityengine/graphicsbuffer)): The buffer to bind as constant buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The offset in bytes from the beginning of the buffer to bind. Must be a multiple of [SystemInfo.constantBufferOffsetAlignment](/engine/6000.3/script-reference/unityengine/systeminfo/constantbufferoffsetalignment.md), or 0 if that value is 0.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of bytes to bind.

### Remarks

Only shaders defined in the .raytrace file can access the constant buffer you designate as the argument for this method. To make this constant buffer accessible to all ray tracing shader types (closest hit, any hit, or miss, for example), call the [CommandBuffer.SetGlobalConstantBuffer](/engine/6000.3/script-reference/unityengine/rendering/commandbuffer/setglobalconstantbuffer.md) method instead.

See [RayTracingShader.SetConstantBuffer](/engine/6000.3/script-reference/unityengine/rendering/raytracingshader/setconstantbuffer.md) for usage.
