Tracing Ray To Each Triangle

I’m writing an application in which I would like to trace a ray to every triangle in the scene. My impression from reading up on the forums and doing some reading on how optix works is that I would need to precalculate the ray directions to each triangle then store them in some buffer for the ray generation program to access. Is there another way to do this?

Somewhat of a side thought; on the surface it seemed like Optix would be a good fit for my problem but the more research I’ve done the more I think I’m defeating the point of the optimizations that are built into the framework by casting a ray to every triangle.

Thanks for any advice / input!

There are a couple of ways to accomplish this. Yes, you could precompute a set of directions, one to each triangle, store them in a buffer, and read from this buffer in your ray-generation program.

More idiomatic would be to let your ray-generation program calculate the directions itself. If you have a list of triangles and an origin, the ray-generation program could just read its triangle, pick a point on the triangle, and trace away.

Thanks kmorley! I’ll start there.

I guess what I’m concerned about is that I’m defeating the purpose of the optimization structures by tracing to each triangle instead of casting rays. Actually now that I think about it I’m not defeating the purpose b/c if I rolled my own tracing engine I’d have to figure out an optimized method of intersecting with things that are not the triangle of interest!

Thanks for the insight!