A real curve ball: non-linear ray tracing

I’ve been writing Optix-based ray-tracing simulations for radar, sonar and lidar for a few years now with simple treatments for 3-D refracting media based on piece-wise constant refractive index approximations and Snell’s law. Lately, with a view to increasing efficiency, I have been thinking of implementing analytic (probably parabolic) ray-tracing for n-squared linear media and believe I have found the necessary intersection algorithms for parabolic curves and triangle primatives. One remaining problem appears to be BVH traversal, which I would also like to use parabolic, rather than linear rays. Is there any way to customize this aspect of Optix in current or future versions?

I currently use Optix 5.1.1, but am preparing for a major re-write for many of my codes following the release of Optix 7.

Hi david.battle,

That sounds like an interesting & fun project! The easiest way I can think of to customize OptiX to use non-linear ray traversal is to cast rays in short linear segments that change direction slightly at every step to approximate your parabolic ray path. The risk of this is that it might be slow and/or require heavy tuning to keep it fast.

An alternative approach you might want to consider, if possible, is to pre-un-warp your entire scene so that rays become linear. This most likely means warping your geometry, and it might be easy if you approximate your curved surfaces with finely tessellated meshes. Then all you have to do is offset your mesh vertices using your inverse warp function. This is only possible, of course, if a coherent continuous warping function exists and all your rays are locally bending in the same directions.

I’m just thinking out loud, but it might be possible to pre-un-warp only the bounds of objects in your scene, then let OptiX use linear traversal, and in your custom intersection programs do analytic non-linear calculations. I say this might work because I’m not sure it can be done - I’ve never done it and compensating for the concavities and convexities of your warp might be tricky. I also worry that even if this did work correctly, the BVH bounds might have severe overlap problems that could compromise your traversal efficiency.

Anyway, I hope that gives you a few ideas. For true non-linear approaches, it’s certainly worth looking around at ray-marching alternatives to OptiX, or at writing a CUDA ray tracer that handles non-linear rays natively. I think this type of thing is potentially possible in OptiX, but without knowing more, I can’t be sure OptiX would be the easiest or fastest way for you.