# SetRayTracingShaderPass(RayTracingShader, string)

> Adds a command to select which Shader Pass to use when executing ray/geometry intersection shaders.

## Definition

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

```csharp
public void SetRayTracingShaderPass(RayTracingShader rayTracingShader, string passName)
```

### Parameters

**** (\[RayTracingShader]\(/engine/6000.0/script-reference/unityengine/rendering/raytracingshader)): [RayTracingShader](/engine/6000.0/script-reference/unityengine/rendering/raytracingshader.md) to set parameter for.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The Shader Pass to use when executing ray tracing shaders.

### Remarks

This name is specified in the ShaderLab shaders used by Materials applied to Renderers used in ray tracing. If a shader doesn't have a Shader Pass with the specified name, then no ray/geometry intersection code is executed. This method must be called before calling [CommandBuffer.DispatchRays](/engine/6000.0/script-reference/unityengine/rendering/commandbuffer/dispatchrays.md).

The Shader Pass code can include optional closest hit or any hit shaders.

For procedural ray-traced geometries, an intersection shader must be authored. The engine code will automatically enable a keywork named `RAY_TRACING_PROCEDURAL_GEOMETRY` if the geometry is proceduraly ray-traced.

### Examples

```csharp
SubShader
{
    Pass
    {
        // CommandBuffer.SetRayTracingShaderPass must use this name in order to execute the ray tracing shaders from this Pass.
        Name "Test"

        Tags{ "LightMode" = "RayTracing" }

        HLSLPROGRAM

        #pragma multi_compile_local RAY_TRACING_PROCEDURAL_GEOMETRY

        #pragma raytracing test

        struct AttributeData
        {
            float2 barycentrics;
        };

        struct RayPayload
        {
            float4 color;
        };

#if RAY_TRACING_PROCEDURAL_GEOMETRY
        [shader("intersection")]
        void IntersectionMain()
        {
            AttributeData attr;
            attr.barycentrics = float2(0, 0);
            ReportHit(0, 0, attr);
        }
#endif

        [shader("closesthit")]
        void ClosestHitMain(inout RayPayload payload : SV_RayPayload, AttributeData attribs : SV_IntersectionAttributes)
        {
            payload.color = float4(1, 0, 0, 1);
        }

        ENDHLSL
    }
}
```
