RTCINITINTERSECTCONTEXT(3)
β¨ rtcInitIntersectContext β¨
okay bestie, pull up a chair π you're looking at rtcInitIntersectContext(3) from the Embree Ray Tracing Kernels 3 manual, and honestly? she's a little foundational queen. she sets up your intersection context so your ray queries actually know what vibe they're on. let's get into it π
πΈ NAME πΈ
rtcInitIntersectContext β initializes the intersection context π
π¦ SYNOPSIS π¦
#include <embree3/rtcore.h>
enum RTCIntersectContextFlags
{
RTC_INTERSECT_CONTEXT_FLAG_NONE,
RTC_INTERSECT_CONTEXT_FLAG_INCOHERENT,
RTC_INTERSECT_CONTEXT_FLAG_COHERENT,
};
struct RTCIntersectContext
{
enum RTCIntersectContextFlags flags;
RTCFilterFunctionN filter;
#if RTC_MAX_INSTANCE_LEVEL_COUNT > 1
unsigned int instStackSize;
#endif
unsigned int instID[RTC_MAX_INSTANCE_LEVEL_COUNT];
#if RTC_MIN_WIDTH
float minWidthDistanceFactor;
#endif
};
void rtcInitIntersectContext(
struct RTCIntersectContext* context
);
π DESCRIPTION π
so there's this thing called a per ray-query intersection context (the RTCIntersectContext type), and she's lowkey the control panel for your query ποΈ. with her you can:
- configure the intersection flags (that's the
flagsmember β¨) - specify a filter callback function (the
filtermember π«Ά) - specify the chain of IDs of the current instance (the
instIDandinstStackSizemembers π) - attach arbitrary data to the query (like, per ray data, you know? π«)
The rtcInitIntersectContext function initializes the context to default values, and bestie, you should call it to initialize every intersection context. no skipping, fr fr. it gets inlined, which keeps overhead tiny and lets the compiler do its little optimization magic β
π the flags, explained (iconically)
the intersection context flag tunes how the traversal algorithm behaves:
RTC_INTERSECT_CONTEXT_FLAG_INCOHERENTβ uses an optimized traversal algorithm for incoherent rays. this is the default, iykyk πRTC_INTERSECT_CONTEXT_FLAG_COHERENTβ uses an optimized traversal algorithm for coherent rays (think primary camera rays πΈ)
For the best primary ray performance, use the ray stream API and set the intersect context flag to RTC_INTERSECT_CONTEXT_FLAG_COHERENT. slay. β¨ For secondary rays, it's typically better to use the RTC_INTERSECT_CONTEXT_FLAG_INCOHERENT flag β unless the rays are known to be very coherent too (like, for primary transparency rays π).
π§ the filter function
You can specify a filter function inside the context. this filter function gets invoked as a second filter stage, right after the per-geometry intersect or occluded filter function is invoked. and listen β only rays that passed the first filter stage are valid in this second filter stage. no gate-crashing π
Having a per ray-query filter function like this is useful for implementing modifications to the behavior of the query, such as collecting all hits or accumulating transparencies π
β οΈ to get the context filter function supported, you have to enable it for a scene using the RTC_SCENE_FLAG_CONTEXT_FILTER_FUNCTION scene flag. and in the case of instancing, this feature has to get enabled for each instantiated scene too. every single one, bestie π
πΈ the minWidthDistanceFactor
The minWidthDistanceFactor value controls the target size of the curve radii when the min-width feature is enabled. for the full tea on the min-width feature, go see the [rtcSetGeometryMaxRadiusScale] function π
π«Ά the pointer promise
It is guaranteed that the pointer to the intersection context passed to a ray query is directly passed to the registered callback functions. which means β yes β you can attach arbitrary data to the end of the intersection context, like a per-ray payload. iconic behavior honestly π
π BUT. please note that the ray pointer is not guaranteed to be passed to the callback functions. so reading additional data from the ray pointer passed to callbacks? not possible. sorry babe.
π EXIT STATUS π
No error code is set by this function. she simply does not miss. π
β SEE ALSO β
- [
rtcIntersect1] - [
rtcOccluded1]
and that's the whole page, bestie!! π¦πβ¨ this came straight out of the Embree Ray Tracing Kernels 3 docs, and if you peek at the footer it's just the page name rtcInitIn...ectContext(3) hanging out down there (the title got truncated all cute like that, periodt π
). now go initialize your contexts, you main character π«ΆπΈ
π¦ where this page comes from
- debian bookworm: libembree-dev 3.13.5+dfsg-2 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms