I have a vulkan ray tracer in which I uploaded my vertices as a single buffer (for all meshes in the scene) as a storage buffer. I have one closest hit shader per way-of-calculating-lighting (e.g. one for a blinn phong lighting calculation for opaque objects, one for blinn phong with refractive properties, one for the disney BRDF). I have one hitgroup record per closest hit shader. I map every closest hit shader to an index, and then in the shader binding table I insert the hit groups according to that map. I set a custom instance index in the TLAS instances and the SBT offset is also used according to my map.

In the shader, I read out the storage buffer to get to the vertex data (for this I jump through hoops - I have an extra buffer that stores offsets into my vertex buffer and all other buffers I have) and it works fine.

Now I was trying to port my ray tracer to OptiX which essentially should work with the same set up, but I came across actually putting data, such as Vertex Buffers, into Hit Group records.

Now my question is, should I change to a Hit Group record setup that utilizes these buffers meant for it (independent of OptiX or Vulkan, as both support this but I didn't know it before)? Are there any performance or other reasons to choose on over the other? As far as I can see, I'd need either a Hitgroup Record per shader - geometry combination such that I can read out the vertex buffer without calculating indices before hand and thus blow up my SBT, or I use the same idea of one giant vertex buffer and have to jump through the same hoops to get to my buffer indices.

So far as I can see in samples, the vulkan folks use storage buffers as I did (I think that's why I went that route to start with) and the OptiX people tend to write Vertex data into the Hit Group records (Nvidia themselves use storage buffers in their vulkan samples and record data in their OptiX samples).



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.