RTCRayN(3)

πŸ“¦ version 3.13.5, in epel 9, fedora 43, fedora 44

πŸ’… RTCRayN β€” ray packet of runtime size πŸ’…

okay bestie, this one's from the Embree Ray Tracing Kernels 3 manual and it's literally the glow-up of ray packets when you don't know how big they are until runtime. let's get into it ✨


✨ SYNOPSIS ✨

#include <embree3/rtcore_ray.h>

struct RTCRayN;

float& RTCRayN_org_x(RTCRayN* ray, unsigned int N, unsigned int i);
float& RTCRayN_org_y(RTCRayN* ray, unsigned int N, unsigned int i);
float& RTCRayN_org_z(RTCRayN* ray, unsigned int N, unsigned int i);
float& RTCRayN_tnear(RTCRayN* ray, unsigned int N, unsigned int i);

float& RTCRayN_dir_x(RTCRayN* ray, unsigned int N, unsigned int i);
float& RTCRayN_dir_y(RTCRayN* ray, unsigned int N, unsigned int i);
float& RTCRayN_dir_z(RTCRayN* ray, unsigned int N, unsigned int i);
float& RTCRayN_time (RTCRayN* ray, unsigned int N, unsigned int i);

float&        RTCRayN_tfar (RTCRayN* ray, unsigned int N, unsigned int i);
unsigned int& RTCRayN_mask (RTCRayN* ray, unsigned int N, unsigned int i);
unsigned int& RTCRayN_id   (RTCRayN* ray, unsigned int N, unsigned int i);
unsigned int& RTCRayN_flags(RTCRayN* ray, unsigned int N, unsigned int i);

πŸŽ€ DESCRIPTION πŸŽ€

so here's the tea πŸ“ β€” sometimes the ray packet size just isn't known at compile time. like, genuinely. for example when Embree hands you back a ray packet inside the RTCFilterFuncN callback function. in those moments Embree is like "bestie I can't commit to a size at compile time" and it uses the RTCRayN type for ray packets instead.

and before you ask: these packets can only have sizes of 1, 4, 8, or 16. no other packet size will be used. periodt. πŸ’€

so you've got two vibes to choose from, and honestly both are valid:

  • implement different special code paths for each of those possible packet sizes, and cast the ray to the appropriate ray packet type πŸ‘‘
  • implement one general code path that uses the RTCRayN_XXX helper functions to access the ray packet components πŸ¦‹

now, about those helper functions β€” they take a pointer to the ray packet (that's the ray argument), the packet size (that's the N argument), and they return a reference to a component of the i-th ray of the packet (that's the i argument). and by "component" I mean stuff like the x-component of the origin. yes, they hand you a reference, not a copy, so you can lowkey just write straight into it. it's giving main character energy, fr fr ✨


πŸ’… EXIT STATUS πŸ’…

not me showing up to this section and it's just... empty. no exit statuses listed here, bestie. that's the whole section. we move 🫢

🌸 SEE ALSO 🌸

  • [RTCHitN]

and that's the whole page, no cap πŸŽ€ this was RTCRayN(3) from the Embree Ray Tracing Kernels 3 manual β€” tysm for reading, go slay those runtime-sized ray packets, ily πŸ’–βœ¨

πŸ“¦ where this page comes from