.\" Automatically generated by Pandoc 2.5
.\"
.TH "rtcInitIntersectContext" "3" "" "" "Embree Ray Tracing Kernels 3"
.hy
.SS NAME
.IP
.nf
\f[C]
rtcInitIntersectContext \- initializes the intersection context
\f[R]
.fi
.SS SYNOPSIS
.IP
.nf
\f[C]
#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
);
\f[R]
.fi
.SS DESCRIPTION
.PP
A per ray\-query intersection context (\f[C]RTCIntersectContext\f[R]
type) is supported that can be used to configure intersection flags
(\f[C]flags\f[R] member), specify a filter callback function
(\f[C]filter\f[R] member), specify the chain of IDs of the current
instance (\f[C]instID\f[R] and \f[C]instStackSize\f[R] members), and to
attach arbitrary data to the query (e.g.\ per ray data).
.PP
The \f[C]rtcInitIntersectContext\f[R] function initializes the context
to default values and should be called to initialize every intersection
context.
This function gets inlined, which minimizes overhead and allows for
compiler optimizations.
.PP
The intersection context flag can be used to tune the behavior of the
traversal algorithm.
Using the \f[C]RTC_INTERSECT_CONTEXT_FLAG_INCOHERENT\f[R] flags uses an
optimized traversal algorithm for incoherent rays (default), while
\f[C]RTC_INTERSECT_CONTEXT_FLAG_COHERENT\f[R] uses an optimized
traversal algorithm for coherent rays (e.g.\ primary camera rays).
.PP
Best primary ray performance can be obtained by using the ray stream API
and setting the intersect context flag to
\f[C]RTC_INTERSECT_CONTEXT_FLAG_COHERENT\f[R].
For secondary rays, it is typically better to use the
\f[C]RTC_INTERSECT_CONTEXT_FLAG_INCOHERENT\f[R] flag, unless the rays
are known to be very coherent too (e.g.\ for primary transparency rays).
.PP
A filter function can be specified inside the context.
This filter function is invoked as a second filter stage after the
per\-geometry intersect or occluded filter function is invoked.
Only rays that passed the first filter stage are valid in this second
filter stage.
Having such a per ray\-query filter function can be useful to implement
modifications of the behavior of the query, such as collecting all hits
or accumulating transparencies.
The support for the context filter function must be enabled for a scene
by using the \f[C]RTC_SCENE_FLAG_CONTEXT_FILTER_FUNCTION\f[R] scene
flag.
In case of instancing this feature has to get enabled also for each
instantiated scene.
.PP
The minWidthDistanceFactor value controls the target size of the curve
radii when the min\-width feature is enabled.
Please see the [rtcSetGeometryMaxRadiusScale] function for more details
on the min\-width feature.
.PP
It is guaranteed that the pointer to the intersection context passed to
a ray query is directly passed to the registered callback functions.
This way it is possible to attach arbitrary data to the end of the
intersection context, such as a per\-ray payload.
.PP
Please note that the ray pointer is not guaranteed to be passed to the
callback functions, thus reading additional data from the ray pointer
passed to callbacks is not possible.
.SS EXIT STATUS
.PP
No error code is set by this function.
.SS SEE ALSO
.PP
[rtcIntersect1], [rtcOccluded1]
