I am thinking about using Intel Embree in my renderer and currently playing around with Embree tutorials.
So, the question is, is it possible to use Intel Embree efficiently via API?
I mean, I can see that the functions from <embree2/rtcore.h>, <embree2/rtcore_ray.h>, e.t.c
use some internal data structures like RTCRay
.
And obviously, since I can't overload any operators I always have to cast my data structures to Embree data structures and vice versa.
And that's not even just a type cast, that's a construction of a new object.
For example, before calling rtcIntersect(RTCScene scene, RTCRay ray);
I construct RTCRay
ray from my Ray
class object and then when the function returns some data, I copy some values back.
It doesn't look like a good way to use Intel Embree.
Constructing RTCRay, use rtcIntersect, then copy the data back. The overhead is negligible (<0.5%) compared to ray-traversing and primitive intersection.
I think Corona render uses RTCRay internally, so they save the 0.5% overhead.
I know that V-Ray does exactly constructing RTCRay, use rtcIntersect, then copy the data back.
General advice: Avoid premature optimization. Implement working code and then use profiler to guide your optimizations.