RTCHit(3)
π RTCHit β single hit structure π
okay bestie, pull up a chair πͺ because we're talking about RTCHit, which is literally the lil' receipt the Embree Ray Tracing Kernels (that's version 4, mwah) hand you every time a ray smacks into a primitive. it's giving "proof of collision" energy and honestly? iconic. π
β¨ SYNOPSIS β¨
first thing's first, you gotta bring in the header:
#include <embree4/rtcore.h>
and here's the whole struct, verbatim, no notes (jk there are notes, they're in the comments):
struct RTCHit
{
float Ng_x; // x coordinate of geometry normal
float Ng_y; // y coordinate of geometry normal
float Ng_z; // z coordinate of geometry normal
float u; // barycentric u coordinate of hit
float v; // barycentric v coordinate of hit
unsigned int primID; // geometry ID
unsigned int geomID; // primitive ID
unsigned int instID[RTC_MAX_INSTANCE_LEVEL_COUNT]; // instance ID
};
like look at her. so organized. so demure. π
π DESCRIPTION π
so RTCHit is the type that holds the result of a ray/primitive intersection. basically: ray goes in, hit comes out, and this struct is the hit. π¦
what's actually inside it, bestie:
- the unnormalized geometric normal, in object space</>, right at the hit location β that's the
Ng_x,Ng_y, andNg_zmembers. note the "unnormalized" and note the "object space", they're both doing heavy lifting, don't skip past them. - the barycentric coordinates of the hit β that's
uandv. π« - the primitive ID β the
primIDmember. - the geometry ID β the
geomIDmember. - the instance ID stack β the
instIDmember. π
and now the part that trips people up, so listen up fr fr: the parametric intersection distance is NOT stored inside the hit. it lives inside the tfar member of the ray instead. not the hit. the ray. i know. i know. but that's just how she is. π
π«Ά the SOA glow-up (still DESCRIPTION, bestie)
the embree4/rtcore_ray.h header also defines the exact same hit structure, but in structure of array (SOA)</> layout, for hit packets of:
- size 4 β the
RTCHit4type - size 8 β the
RTCHit8type - size 16 β the
RTCHit16type
and on top of all that, that same header defines an RTCHitNt template so you can make hit packets of whatever compile-time size your heart desires. no cap. π
π EXIT STATUS π
...yeah, there's nothing here. it's a struct, bestie, she doesn't exit. she just is. π
π SEE ALSO π
go read these next, i'm obsessed with them for you:
RTCRayMulti-Level Instancing
and that's the whole page! π this lil' slice of the Embree Ray Tracing Kernels 4 manual, filed under RTCHit(3), was written by the Embree team and is yours to go be a main character with. now go intersect something. π
β¨π¦
π¦ where this page comes from
- alpine 3.24: embree-doc 4.4.1-r0 Β· Apache-2.0
- arch rolling: embree 4.4.1-1 Β· Apache-2.0
- fedora 43: embree 4.4.1-1.fc43 Β· Apache-2.0
- fedora 44: embree 4.4.1-1.fc44 Β· Apache-2.0
- nixpkgs unstable: embree 4.4.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms