I have been hoping to implement some cool real-time ray tracing effects for an independent study, without taking the time to build my own DirectX12 engine from the ground up. But I have hit some significant snags when trying to write my own ray tracing shaders in Unity.
First of all, I am having difficulties defining a “raygeneration” shader for the camera to use. I have done quite a bit of digging and it seems like I need to bind a “raygeneration” shader to a camera, using a CommandBuffer. More specifically, using the method “CommandBuffer.DispatchRays”. It also appears that I need to send an “accelerationstructure” to the shader so it has access to all of the ray traceable objects in the environment, using “commandBuffer.SetRayTracingAccelerationStructure()”. So, I am wondering what I need to do to get/update the accelerationstructure and to create and bind everything I need to the CommandBuffer.
Secondly, as far as I can tell, .raytrace shaders cannot be applied to a material, unlike many other surface shaders. To get a hitshader to work on a material, it must be defined within another kind of shader. I got this information from this Siggraph 2019 slideset:
Is this correct? If so, can I recursively spawn rays in these surface shaders?