RTCINITINTERSECTCONTEXT(3embree3)

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

✨ 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 flags member ✨)
  • specify a filter callback function (the filter member 🫢)
  • specify the chain of IDs of the current instance (the instID and instStackSize members πŸ‘‘)
  • 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