RTCRay(3)

πŸ’– RTCRay(3) πŸ’–

okay bestie, welcome to the Embree Ray Tracing Kernels 4 manual, and today's main character is RTCRay β€” the single ray structure. yes, THE ray. the one that does the actual ray-ing. πŸŽ€


✨ SYNOPSIS ✨

#include <embree4/rtcore_ray.h>

struct RTC_ALIGN(16) RTCRay
{
  float org_x;        // x coordinate of ray origin
  float org_y;        // y coordinate of ray origin
  float org_z;        // z coordinate of ray origin
  float tnear;        // start of ray segment

  float dir_x;        // x coordinate of ray direction
  float dir_y;        // y coordinate of ray direction
  float dir_z;        // z coordinate of ray direction
  float time;         // time of this ray for motion blur

  float tfar;         // end of ray segment (set to hit distance)
  unsigned int mask;  // ray mask
  unsigned int id;    // ray ID
  unsigned int flags; // ray flags
};

no cap, that's the whole vibe right there. πŸ’…


🌸 DESCRIPTION 🌸

so RTCRay defines the ray layout for a single ray. it's giving "one ray, fully described, no notes." πŸ¦‹

the ray carries:

  • its origin β€” that's the org_x, org_y, org_z members πŸ’«
  • its direction vector β€” the dir_x, dir_y, dir_z members ✨
  • its ray segment β€” the tnear and tfar members 🌈

and here's a thing bestie, listen up: the ray direction does not have to be normalized. you heard me. only the parameter range specified by the tnear/tfar interval is considered valid. so don't stress about normalizing, that's not the assignment. πŸ™ˆ

⚠️ okay so this part is important: the ray segment must be in the range [0, ∞]. that means ranges that start behind the ray origin are not allowed. but bestie, the ranges can reach to infinity. slay. πŸ‘‘

the ray further contains a bunch more little guys:

  • a motion blur time in the range [0, 1] β€” that's the time member ⏰
  • a ray mask β€” the mask member 🎭
  • a ray ID β€” the id member πŸ†”
  • ray flags β€” the flags member 🚩

the ray mask can be used to mask out some geometries for some rays (go peek at rtcSetGeometryMask for more details, iykyk). 🫢

the ray ID can be used to identify a ray inside a callback function β€” even if the order of rays inside a ray packet has changed. so like, your ray keeps its name tag at the party no matter how the seating chart gets shuffled. iconic behavior fr fr. πŸŽ‰


🧚 the SOA situation (still DESCRIPTION, bestie)

the embree4/rtcore_ray.h header additionally defines the same ray structure in structure of array (SOA) layout for API functions accepting ray packets of:

  • size 4 β€” the RTCRay4 type
  • size 8 β€” the RTCRay8 type
  • size 16 β€” the RTCRay16 type

and the header additionally defines an RTCRayNt template for ray packets of an arbitrary compile-time size. yes, arbitrary. it's giving flexible. it's giving limitless. it's giving template. πŸ’€βœ¨


πŸ’« EXIT STATUS πŸ’«

not me leaving this section absolutely empty β€” because it is. nothing here bestie. the void. the silence. πŸ•³οΈβœ¨

πŸ”₯ SEE ALSO πŸ”₯

  • [RTCHit]

go read about the hit next, it's literally the other half of the story. πŸ’–


and that's the page, bestie!! 🫢 this was RTCRay(3) from the Embree Ray Tracing Kernels 4 manual β€” stay hydrated, keep your tnear above zero, and go trace something gorgeous. mwah. πŸ’…πŸŒΈβœ¨

πŸ“¦ where this page comes from