RTC_GEOMETRY_TYPE_USER(3embree3)

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

πŸ’– RTC_GEOMETRY_TYPE_USER(3) β€” user geometry type πŸ’–

okay bestie, welcome to the Embree Ray Tracing Kernels 3 manual, section 3, and today's main character is RTC_GEOMETRY_TYPE_USER. sit down, hydrate, let's get into it 🫢


✨ NAME ✨

RTC_GEOMETRY_TYPE_USER β€” the user geometry type. yes that's literally it, that's the whole name, she's simple and she's iconic πŸ’…


🌸 SYNOPSIS 🌸

#include <embree3/rtcore.h>

RTCGeometry geometry =
  rtcNewGeometry(device, RTC_GEOMETRY_TYPE_USER);

look at her. two lines. no cap, that's the whole vibe check right there ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea, bestie: user-defined geometries hold a bunch of user-defined primitives, the exact same way triangle meshes hold a bunch of triangles. like, same energy, different shape. and the shape of those primitives? that's all you, because you specify it through registered callback functions β€” which is the whole slay, because it means you can extend Embree with literally any type of primitive you can dream up 🌈

You create user-defined geometries by passing RTC_GEOMETRY_TYPE_USER to the rtcNewGeometry function call. easy. but then you have to actually set things up, and there's a lil checklist, so let's go:

  • set the number of primitives (peep rtcSetGeometryUserPrimitiveCount)
  • set a user data pointer (that's rtcSetGeometryUserData)
  • set a bounding function closure (hi rtcSetGeometryBoundsFunction)
  • set your user-defined intersect callback (say hey to rtcSetGeometryIntersectFunction)
  • and set your occluded callback (rtcSetGeometryOccludedFunction, obviously)

The bounding function is what gets used to query the bounds of all time steps of a user primitive. meanwhile the intersect and occluded callback functions get called when it's time to intersect the primitive with a ray. and the user data pointer? that gets passed to each callback invocation, and it's there so you can point at your application's representation of the user geometry. it's giving personal assistant for your primitives, fr fr πŸ’–

The creation of a user geometry typically looks the following:

RTCGeometry geometry = rtcNewGeometry(device, RTC_GEOMETRY_TYPE_USER);
rtcSetGeometryUserPrimitiveCount(geometry, numPrimitives);
rtcSetGeometryUserData(geometry, userGeometryRepresentation);
rtcSetGeometryBoundsFunction(geometry, boundsFunction);
rtcSetGeometryIntersectFunction(geometry, intersectFunction);
rtcSetGeometryOccludedFunction(geometry, occludedFunction);

okay but like β€” please have a look at the rtcSetGeometryBoundsFunction, rtcSetGeometryIntersectFunction, and rtcSetGeometryOccludedFunction functions for the actual implementation of the callback functions. do not just copy this block and hope, bestie, i'm begging πŸ™ˆ

⚠️ big important one: primitives of a user geometry are ignored during rendering when their bounds are empty β€” meaning the bounds have lower>upper in at least one dimension. so if your primitive is mysteriously invisible, check the bounds, not your feelings πŸ’€

See tutorial [User Geometry] for an example of how to use the user-defined geometries. go read it, she ate πŸ”₯


πŸ‘‘ EXIT STATUS πŸ‘‘

On failure NULL is returned and an error code is set that can be queried using rtcGetDeviceError. so if you get NULL, it's not you, it's the error code β€” go check it πŸŽ€


πŸ’œ SEE ALSO πŸ’œ

  • [rtcNewGeometry]
  • [rtcSetGeometryUserPrimitiveCount]
  • [rtcSetGeometryUserData]
  • [rtcSetGeometryBoundsFunction]
  • [rtcSetGeometryIntersectFunction]
  • [rtcSetGeometryOccludedFunction]

the whole friend group, all linked up, all essential 🌸


and that's the page, bestie!! this was RTC_GEOMETRY_TYPE_USER(3) from the Embree Ray Tracing Kernels 3, and she understood the assignment. go build some cursed custom primitives, ily, mwah πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from