# SetMatrix

> Sets the value of a matrix uniform.

## Definition

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

## SetMatrix(int, Matrix4x4)

Sets the value of a matrix uniform.

```csharp
public void SetMatrix(int nameID, Matrix4x4 val)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The ID of the property as given by Shader.PropertyToID.**** (\[Matrix4x4]\(/engine/6000.0/script-reference/unityengine/matrix4x4)): The matrix to set.

### Remarks

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

## SetMatrix(string, Matrix4x4)

Sets the value of a matrix uniform.

```csharp
public void SetMatrix(string name, Matrix4x4 val)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the property being set.**** (\[Matrix4x4]\(/engine/6000.0/script-reference/unityengine/matrix4x4)): The matrix to set.

### Remarks

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