rtcIntersect1(3)
π rtcIntersect1 π
okay so bestie, welcome to rtcIntersect1(3) from the Embree Ray Tracing Kernels 4 manual. this one's a whole vibe: it's the "find me the closest hit for ONE single ray" girlie. let's get into it β¨
πΈ NAME πΈ
rtcIntersect1 β finds the closest hit for a single ray π―
β¨ SYNOPSIS β¨
#include <embree4/rtcore.h>
void rtcIntersect1(
RTCScene scene,
struct RTCRayHit* rayhit
struct RTCIntersectArguments* args = NULL
);
(yes the missing comma is canon, we don't touch the sacred text π )
π¦ DESCRIPTION π¦
so rtcIntersect1 finds the closest hit of a single ray (that's the rayhit argument) against the scene (the scene argument). the ray/hit structure you hand over carries the ray you wanna intersect plus some hit output fields that get filled in the moment a hit is found. and that optional args struct? it's for advanced use cases only, check the section [rtcInitIntersectArguments] for the deets π«Ά
to actually trace a ray, you gotta initialize all of this yourself, no cap:
- the ray origin (the
orgray member) - the ray direction (the
dirray member) - the ray segment (the
tnear,tfarray members) - the ray mask (the
maskray member) - and set the ray flags to
0(theflagsray member)
the ray time (the time ray member) must be initialized to a value in the range $[0, 1]$. the ray segment has to be in the range [0, β], so ranges that start behind the ray origin are not valid β but bestie, ranges can reach to infinity, slay. see Section [RTCRay] for the ray layout description.
the geometry ID (the geomID hit member) of the hit data must be initialized to RTC_INVALID_GEOMETRY_ID (-1). don't forget it, it's giving important π
when no intersection is found, the ray/hit data is not updated. when an intersection is found, the hit distance gets written into the tfar member of the ray, and all the hit data gets set, like:
- unnormalized geometry normal in object space (the
Nghit member) - local hit coordinates (the
u,vhit member) - instance ID stack (the
instIDhit member) - geometry ID (the
geomIDhit member) - primitive ID (the
primIDhit member)
see Section [RTCHit] for the hit layout description. it's all there π
π the instance ID stack lore π
if the instance ID stack has a prefix of values not equal to RTC_INVALID_GEOMETRY_ID, then:
- the instance ID on each level corresponds to the geometry ID of the hit instance of the higher-level scene
- the geometry ID corresponds to the hit geometry inside the hit instanced scene
- the primitive ID corresponds to the n-th primitive of that geometry
and if level 0 of the instance ID stack is equal to RTC_INVALID_GEOMETRY_ID, then:
- the geometry ID corresponds to the hit geometry inside the top-level scene
- the primitive ID corresponds to the n-th primitive of that geometry
iykyk π§
π the edge case warning (read this one fr fr) π
the implementation makes no guarantees that primitives whose hit distance is exactly at (or very close to)tnearortfarare hit or missed. this is genuinely undefined-ish territory, so if you want to exclude intersections attnear, just pass a slightly enlargedtnear. and if you want to include intersections attfar, pass a slightly enlargedtfar. that's the move, periodt.
also, the ray/hit structure must be aligned to 16 bytes. that's not a suggestion bestie, that's the law π
π EXIT STATUS π
for performance reasons this function does not do any error checks, so it will not set any error flags on failure. it simply does not have the energy to catch your mistakes, and honestly? relatable π
β SEE ALSO β
- [rtcOccluded1]
- [rtcIntersect4/8/16]
- [RTCRayHit]
- [rtcInitIntersectArguments]
and that's the whole page bestie!! this lil icon comes to you from the Embree Ray Tracing Kernels 4 era, dated rtcIntersect1(3) β go trace something iconic with it π
β¨πΈπ¦
π¦ where this page comes from
- ubuntu stonking: libembree-dev 4.4.1+dfsg-2ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms