rtcIntersectNM & RTCRayHitN

rtcIntersectNM & RTCRayHitN

Hi community,

i'm trying to intersect geometry with the rtcIntersectNM method. 

signature: void rtcIntersectNM( RTCScene scene, struct RTCIntersectContext* context, struct RTCRayHitN* rayhit, unsigned int N, unsigned int M, size_t byteStride );

I don't unterstand how to create the RTCRayHitN*.

I've an array of RTCRayHit, a normal cast to (RTCRayHitN*) don't work.

Can anybody help me?

7 posts / 0 new

Do you trace just single rays (RTCRay + RTCHit)? If yes there's no need to use rtcIntersectNM. rtcIntersectNM is mostly useful for ray packets and/or stream of rays.

Currently I trace snigle rays, but i want to trace packets. 

I don't understand how to use the RTCRayHitN struct.
I have an array of RTCRayHit[64]. From this array i want to create the RTCRayHitN data.



OK, you have 64 single rays and want to trace them as packets. If you look in rtcore_ray.h we support explicit 4-wide, 8-wide, or 16-wide packets (RTCRayHit4, RTCRayHit8, RTCRayHit16), which means for your 64 single rays you get 16,8,or 4 ray packets. After initializing your packets, you can use rtcIntersect4/8/16 or rtcOccluded4/8/16 to trace them. A probably easier way to deal with packets is to use the ISPC compiler which uses Embree packet's interface per default.

I would like to implement different types of tracing rays. One of these type is packet tracing with Streams. For that i need the rtcIntersectNM method. And there is the problem, how do I handle the type RTCRayHitN? 

Maybe later i will use the ISPC compiler.


Best Reply

I would recommend to have look at the viewer_stream both for C++ and ISPC. Unfortunately we don't have an example which uses rtcIntersectNM with C++, only rtcIntersect1M. Probably the easiest way is to use ISPC to handle a stream of N-wide packets as in the viewer_stream_device.ispc example. BTW: In terms of performance the stream of packets makes only sense if you have a stream of extremely coherent rays. If you have less coherence in your stream I would recommend to use the standard packet interface.

Thanks for your help. That's what I wanted to hear. 

Leave a Comment

Please sign in to add a comment. Not a member? Join today