# SetGlobalRayTracingAccelerationStructure

> Adds a command to bind the RayTracingAccelerationStructure object to all shader stages.

## Definition

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

## SetGlobalRayTracingAccelerationStructure(string, RayTracingAccelerationStructure)

Adds a command to bind the [RayTracingAccelerationStructure](/engine/6000.7/script-reference/unityengine/rendering/raytracingaccelerationstructure.md) object to all shader stages.

```csharp
public void SetGlobalRayTracingAccelerationStructure(string name, RayTracingAccelerationStructure accelerationStructure)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the acceleration structure in shader code.**** (\[RayTracingAccelerationStructure]\(/engine/6000.7/script-reference/unityengine/rendering/raytracingaccelerationstructure)): The acceleration structure to set.

### Remarks

This command binds a [RayTracingAccelerationStructure](/engine/6000.7/script-reference/unityengine/rendering/raytracingaccelerationstructure.md) object to all shader stages. You can use the structure for inline ray tracing (ray queries) or as an argument in `TraceRay` calls in ray tracing shaders. The [RayTracingAccelerationStructure](/engine/6000.7/script-reference/unityengine/rendering/raytracingaccelerationstructure.md) object must be built using the [CommandBuffer.BuildRayTracingAccelerationStructure](/engine/6000.7/script-reference/unityengine/rendering/commandbuffer/buildraytracingaccelerationstructure.md) method before calling this command.

Ray queries can be used to perform acceleration structure traversal and geometry intersection tests. To access this functionality, the HLSL code must be compiled using the `#pragma require inlineraytracing` directive or by using the built-in shader keyword `UNITY_DEVICE_SUPPORTS_INLINE_RAY_TRACING` (for example, #pragma multi\_compile \_ UNITY\_DEVICE\_SUPPORTS\_INLINE\_RAY\_TRACING).

Additional Resources: [Shader.SetGlobalRayTracingAccelerationStructure](/engine/6000.7/script-reference/unityengine/shader/setglobalraytracingaccelerationstructure.md), [SystemInfo.supportsRayTracingShaders](/engine/6000.7/script-reference/unityengine/systeminfo/supportsraytracingshaders.md), [SystemInfo.supportsInlineRayTracing](/engine/6000.7/script-reference/unityengine/systeminfo/supportsinlineraytracing.md).

## SetGlobalRayTracingAccelerationStructure(int, RayTracingAccelerationStructure)

Adds a command to bind the [RayTracingAccelerationStructure](/engine/6000.7/script-reference/unityengine/rendering/raytracingaccelerationstructure.md) object to all shader stages.

```csharp
public void SetGlobalRayTracingAccelerationStructure(int nameID, RayTracingAccelerationStructure accelerationStructure)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The name ID of the acceleration structure in shader code. Use [Shader.PropertyToID](/engine/6000.7/script-reference/unityengine/shader/propertytoid.md) to get this value.**** (\[RayTracingAccelerationStructure]\(/engine/6000.7/script-reference/unityengine/rendering/raytracingaccelerationstructure)): The acceleration structure to set.

### Remarks

This command binds a [RayTracingAccelerationStructure](/engine/6000.7/script-reference/unityengine/rendering/raytracingaccelerationstructure.md) object to all shader stages. You can use the structure for inline ray tracing (ray queries) or as an argument in `TraceRay` calls in ray tracing shaders. The [RayTracingAccelerationStructure](/engine/6000.7/script-reference/unityengine/rendering/raytracingaccelerationstructure.md) object must be built using the [CommandBuffer.BuildRayTracingAccelerationStructure](/engine/6000.7/script-reference/unityengine/rendering/commandbuffer/buildraytracingaccelerationstructure.md) method before calling this command.

Ray queries can be used to perform acceleration structure traversal and geometry intersection tests. To access this functionality, the HLSL code must be compiled using the `#pragma require inlineraytracing` directive or by using the built-in shader keyword `UNITY_DEVICE_SUPPORTS_INLINE_RAY_TRACING` (for example, #pragma multi\_compile \_ UNITY\_DEVICE\_SUPPORTS\_INLINE\_RAY\_TRACING).

Additional Resources: [Shader.SetGlobalRayTracingAccelerationStructure](/engine/6000.7/script-reference/unityengine/shader/setglobalraytracingaccelerationstructure.md), [SystemInfo.supportsRayTracingShaders](/engine/6000.7/script-reference/unityengine/systeminfo/supportsraytracingshaders.md), [SystemInfo.supportsInlineRayTracing](/engine/6000.7/script-reference/unityengine/systeminfo/supportsinlineraytracing.md).
