rayTracingShader | RayTracingShader to set parameter for. |
passName | The Shader Pass to use when executing ray tracing shaders. |
Adds a command to select which Shader Pass to use when executing ray/geometry intersection shaders.
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.
The Shader Pass code can include optional closesthit or anyhit 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.
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 } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.