Using RTX Acceleration for Voxel Tracing

Hi. I’ve written a simple voxel ray tracer that renders cubes instead of triangles. To do this, I have a bounding box program that’s self explanatory and an intersection program that uses the slabs algorithm to calculate t where the ray intersects the voxel. It performs super well, but obviously it’s a duplicate ray-aabb intersection test and doesn’t run on the RT cores. Does OptiX provide a better way to do this so I can take advantage of the RTX acceleration? Ideally the intersection just uses the results from the hardware’s aabb testing.

Thanks!

Hi @Lin20,

As long as you are using RTX hardware and OptiX 6, you do get RTX acceleration in the sense that BVH traversal is being done in hardware. In order to also accelerate the primitive intersection, the way to do that right now is to use the OptiX triangle API. That would mean meshing your visible voxel walls.

Meshing voxels might be feasible and reasonably fast if you have the memory for it and if you can build your triangle mesh in a CUDA kernel. You can estimate the upper bound of memory needed for voxel meshing: if you were to do the easiest thing and mesh each visible voxel individually but take some care to only have 1 wall between voxels and share vertices, then I think you could average just slightly over 1 vertex per voxel, and indices would average just over 6 triangles per voxel. If my napkin math is right, that would be roughly 34+64 = 36 bytes per visible voxel. If needed, you’d be able to do simple math in your closest hit shader to recover which voxel you intersect by looking at the hit point and ray direction.

Aside from that, OptiX doesn’t provide a way to return a hit point from the leaf BVH node. You are already doing it probably the most reasonable way that’s available without meshing. The main alternative approach that people use for voxel rendering is a voxel marching approach using pure CUDA.


David.

Thank you very much for the info! It’s greatly appreciated. Experimenting with meshing, or even some sort of hybrid where a triangle representation of the scene is used for the bounces, might be worth it. How funny, since it’s typically voxels accelerating triangle tracing (eg. VXGI).

I do hope that one day OptiX - and other ray tracing APIs for that matter - provide targeted support for more than just triangles. Fingers crossed!