RTCFORWARDINTERSECT1(3embree4)

πŸ’… rtcForwardIntersect1/Ex β€” Embree Ray Tracing Kernels 4 πŸ’…

ok so bestie, welcome to the rtcForwardIntersect1/Ex page, part of the Embree Ray Tracing Kernels 4 manual. this one is about forwarding a single ray to a new scene from a user geometry callback. yes it's a mouthful. no you're not dumb. let's go πŸ¦‹


✨ NAME ✨

rtcForwardIntersect1/Ex β€” forwards a single ray to new scene from user geometry callback


✨ SYNOPSIS ✨

#include <embree4/rtcore.h>

void rtcForwardIntersect1(
  const struct RTCIntersectFunctionNArguments* args,
  RTCScene scene,
  struct RTCRay* ray,
  unsigned int instID
);

void rtcForwardIntersect1Ex(
  const struct RTCIntersectFunctionNArguments* args,
  RTCScene scene,
  struct RTCRay* ray,
  unsigned int instID,
  unsigned int instPrimID,
);
yes the Ex version really does end with that trailing comma. we do not touch it. it is iconic and it stays. πŸ™ˆ

✨ DESCRIPTION ✨

okay so the way that rtcForwardIntersect1 and rtcForwardIntersect1Ex work is: they forward the traversal of a transformed ray (that's the ray argument) into a scene (that's the scene argument), and you do it from a user geometry callback. group project energy, but make it ray tracing.

important deets, no cap:

  • this function can only get invoked from a user geometry callback for a ray traversal that was initiated with the rtcIntersect1 function.
  • the callback arguments structure of the callback invokation has to get passed to the ray forwarding (that's the args argument).
  • the user geometry callback should instantly terminate after invoking the rtcForwardIntersect1/Ex function. like, do the thing and LEAVE. don't linger. πŸ’€

Only the ray origin and ray direction members of the ray argument are used for forwarding β€” all the other ray properties are inherited from the initial ray traversal invokation of rtcIntersect1. so don't think you can sneak extra stuff in there, bestie, it's not reading it. πŸ™ˆ

The implementation of rtcForwardIntersect1 recursively continues the ray traversal into the specified scene and pushes the provided instance ID (the instID argument) to the instance ID stack. Hit information gets updated into the ray hit structure that was passed to the original rtcIntersect1 invokation. very demure, very mindful.

You can use this function to implement user defined instancing using user geometries β€” like by transforming the ray in a special way, and/or picking between different scenes to instantiate. main character customisation energy fr fr ✨

For user defined instance arrays, the rtcForwardIntersect1Ex variant has an additional instPrimID argument which gets pushed to the instance primitive ID stack. Instance primitive IDs identify which instance of an instance array was hit. that's the whole point of the Ex. it's giving "which one of you did this". πŸŽ€

🌸 the CPU vs SYCL tea 🌸

When you're using Embree on the CPU, it's possible to recursively invoke rtcIntersect1 directly from a user geometry callback. easy. cute. love that for you.

However β€” and this is the plot twist 😭 β€” when SYCL is used, recursively tracing rays is not directly supported, and the rtcForwardIntersect1/Ex functions must be used. so like, no shortcuts. use the forward function. periodt. πŸ’…

⭐ The ray structure must be aligned to 16 bytes. not 15. not "close enough". sixteen. 16. do it. πŸ’–

✨ EXIT STATUS ✨

For performance reasons this function does not do any error checks, thus it will not set any error flags on failure. she's fast and she's not checking your work. that's the deal. πŸ”₯


✨ SEE ALSO ✨

  • [rtcIntersect1]
  • [RTCRay]

and that's the whole page bestie, you ate it up πŸ’œβœ¨

this was rtcForwardIntersect1/Ex(3) from Embree Ray Tracing Kernels 4 β€” go forth, forward your rays, push your instance IDs, and stay 16-byte aligned. mwah. πŸ’…πŸŽ€πŸ¦‹πŸŒΈπŸ«Ά

πŸ“¦ where this page comes from