RTC_GEOMETRY_TYPE_USER(3)
π RTC_GEOMETRY_TYPE_USER β user geometry type π
okay bestie, welcome to the Embree Ray Tracing Kernels 4 manual, and today's main character is RTC_GEOMETRY_TYPE_USER, the geometry type that lets you be the boss of what a primitive even is. no cap. π¦
β¨ SYNOPSIS β¨
#include <embree4/rtcore.h>
RTCGeometry geometry =
rtcNewGeometry(device, RTC_GEOMETRY_TYPE_USER);
πΈ DESCRIPTION πΈ
so. user-defined geometries hold a whole bunch of user-defined primitives, the same way triangle meshes hold a whole bunch of triangles. that's it, that's the vibe. the shape of those user-defined primitives? you specify it through registered callback functions, which is literally how you extend Embree with whatever arbitrary types of primitives your heart desires. iconic behavior honestly. π
you create user-defined geometries by passing RTC_GEOMETRY_TYPE_USER into the rtcNewGeometry function call. then β and this part is not optional, bestie β you have to set:
- the number of primitives (peep
rtcSetGeometryUserPrimitiveCount) - a user data pointer (peep
rtcSetGeometryUserData) - a bounding function closure (peep
rtcSetGeometryBoundsFunction) - your user-defined intersect callback (peep
rtcSetGeometryIntersectFunction) - your user-defined occluded callback (peep
rtcSetGeometryOccludedFunction)
the bounding function is what gets used to query the bounds of all time steps of a user primitive, while the intersect and occluded callback functions get called to intersect the primitive with a ray. and the user data pointer? it gets passed to every single callback invocation, and you can use it to point at your application's representation of the user geometry. so convenient. obsessed. π
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);
please have a look at the rtcSetGeometryBoundsFunction, rtcSetGeometryIntersectFunction, and rtcSetGeometryOccludedFunction functions on the implementation of the callback functions. they're the blueprint, fr fr. πβ¨
β οΈ okay important one: primitives of a user geometry get 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 not showing up, check your bounds first, bestie. π
see tutorial [User Geometry] for an example of how to use the user-defined geometries. go look, it's giving tutorial energy. π§
π EXIT STATUS π
on failure, NULL is returned and an error code is set that can be queried using rtcGetDeviceError. so like, if you get NULL back, don't just sit there β go ask rtcGetDeviceError what happened. π«Ά
π SEE ALSO π
[rtcNewGeometry][rtcSetGeometryUserPrimitiveCount][rtcSetGeometryUserData][rtcSetGeometryBoundsFunction][rtcSetGeometryIntersectFunction][rtcSetGeometryOccludedFunction]
and that's the whole page, bestie, you ate it. π this was RTC_GEOMETRY_TYPE_USER(3) straight out of the Embree Ray Tracing Kernels 4 docs β go build something cursed and beautiful with it. mwah. πππ
π¦ where this page comes from
- ubuntu stonking: libembree-dev 4.4.1+dfsg-2ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms