RTC_GEOME..._INSTANCE(3)
π NAME π
RTC_GEOMETRY_TYPE_INSTANCE β the instance geometry type, bestie. Yes, from the Embree Ray Tracing Kernels 4 manual, section 3. Buckle up, this one's a bop. π¦
β¨ SYNOPSIS β¨
#include <embree4/rtcore.h>
RTCGeometry geometry =
rtcNewGeometry(device, RTC_GEOMETRY_TYPE_INSTANCE);
πΈ DESCRIPTION πΈ
Okay so picture this: Embree lets you instance whole scenes using affine transformations β that's a 3Γ3 matrix plus a translation, the whole glow-up package. And the iconic part? The instanced scene gets stored only a single time, even if you plop it down in a million different locations. So you can build absolutely unhinged, complex scenes with a tiny little memory footprint. It's giving efficiency. It's giving main character energy. π
Embree serves both single-level instancing and multi-level instancing, no gatekeeping. The max instance nesting depth is RTC_MAX_INSTANCE_LEVEL_COUNT, and you can configure that at compile-time using the constant EMBREE_MAX_INSTANCE_LEVEL_COUNT. So like β adapt that constant to your needs, fr fr, because instances nested any deeper are silently ignored in release mode and cause assertions in debug mode. π Not a vibe, just a fact.
Instances get created by passing RTC_GEOMETRY_TYPE_INSTANCE to the rtcNewGeometry function call. Then:
- the instanced scene can be set with the
rtcSetGeometryInstancedScenecall π - the affine transformation can be set with the
rtcSetGeometryTransformfunction β¨
Bestie, listen closely:rtcCommitSceneon the instanced scene should be called first, thenrtcCommitGeometryon the instance, thenrtcCommitScenefor the top-level scene containing the instance. In that order. Periodt. The order is the whole personality here.
So when a ray hits the instance, the geomID and primID members of the hit get set to the geometry ID and primitive ID of the hit primitive in the instanced scene, and the instID member of the hit gets set to the geometry ID of the instance in the top-level scene. Clean. Tidy. Obsessed. π
You can also pull off the instancing scheme with user geometries, if that's more your thing. Here's the recipe:
- the user geometry code sets the
instIDmember of the ray query context to the geometry ID of the instance - then it traces the transformed ray
- and finally sets the
instIDfield of the ray query context back to-1π«Ά
And here's the cute little detail: the instID field is copied automatically by each primitive intersector into the instID field of the hit structure when the primitive is hit. See the [User Geometry] tutorial for an example, iykyk. π
For multi-segment motion blur, the number of time steps must be first specified using the rtcSetGeometryTimeStepCount function. Then a transformation for each time step can be specified using the rtcSetGeometryTransform function. One per step, no skipping. β
Also, go look at the tutorials [Instanced Geometry] and [Multi Level Instancing] for examples of how to use instances β they ate, honestly. π₯
π EXIT STATUS π
On failure, NULL is returned and an error code is set that can be queried using rtcGetDeviceError. So check it. Don't just sit there wondering why your geometry is giving nothing. π
π SEE ALSO π
- [rtcNewGeometry]
- [rtcSetGeometryInstancedScene]
- [rtcSetGeometryTransform]
Okay that's the whole page, bestie β straight from the Embree Ray Tracing Kernels 4 manual, RTC_GEOME..._INSTANCE(3), section 3 of the manual set. Go instance something iconic. πβ¨π§
π¦ 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