RTC_GEOME..._TRIANGLE(3)
π RTC_GEOME..._TRIANGLE(3) π
okay bestie, welcome to the Embree Ray Tracing Kernels 4 manual, section 3, and today's main character is RTC_GEOMETRY_TYPE_TRIANGLE. yes she's a triangle. yes she's iconic. let's go π¦
β¨ NAME β¨
RTC_GEOMETRY_TYPE_TRIANGLE β the triangle geometry type, no cap π
πΈ SYNOPSIS πΈ
#include <embree4/rtcore.h>
RTCGeometry geometry =
rtcNewGeometry(device, RTC_GEOMETRY_TYPE_TRIANGLE);
π DESCRIPTION π
so here's the tea π β you make triangle meshes by passing RTC_GEOMETRY_TYPE_TRIANGLE into the rtcNewGeometry function call. that's literally it, that's the whole vibe.
then you gotta feed her two buffers:
- the triangle indices β you set these by setting an index buffer (the
RTC_BUFFER_TYPE_INDEXtype) - the triangle vertices β you set these by setting a vertex buffer (the
RTC_BUFFER_TYPE_VERTEXtype)
if you're like "bestie how do I even set buffers" β go read rtcSetGeometryBuffer and rtcSetSharedGeometryBuffer, they've got the full rundown π
now the deets, and these ones MATTER:
- the index buffer must contain an array of three 32-bit indices per triangle, in
RTC_FORMAT_UINT3format. the number of primitives is inferred from the size of that buffer. inferred! she's mysterious like that β¨ - the vertex buffer must contain an array of single precision x, y, z floating point coordinates, in
RTC_FORMAT_FLOAT3format, and the number of vertices is inferred from the size of that buffer too. - > the vertex buffer can be at most 16 GB large. sixteen. gigabytes. she's got limits and we respect them π«Ά
π§ the parametrization (iykyk)
the parametrization of a triangle uses the first vertex p0 as the base point, the vector p1 - p0 as the u-direction, and the vector p2 - p0 as the v-direction.
so vertex attributes t0, t1, t2 can be linearly interpolated over the triangle like this:
t_uv = (1-u-v)*t0 + u*t1 + v*t2
= t0 + u*(t1-t0) + v*(t2-t0)
and orientation check π β a triangle whose vertices are laid out counter-clockwise has its geometry normal pointing upwards outside the front face, like illustrated in the following picture:
(picture moment πΌοΈβ¨)
π¦ multi-segment motion blur
for multi-segment motion blur, you have to specify the number of time steps first using the rtcSetGeometryTimeStepCount call. then a vertex buffer for each time step can be set using different buffer slots, and all these buffers have to have the same stride and size. no mixing and matching, bestie, she will notice π
also!! go peek at the tutorial [Triangle Geometry] if you want an example of how to actually create triangle meshes. highly recommend, ate π
π EXIT STATUS π
on failure, NULL is returned and an error code is set that can be queried using rtcGetDeviceError. so if you get a NULL, don't panic β go check the error code, she's trying to tell you something π
π SEE ALSO π
- [rtcNewGeometry]
okay that's the whole page, you're officially a triangle mesh girlie now πΈ stay hydrated, keep your indices 32-bit, and remember: inferred from the size of the buffer, periodt β¨
RTC_GEOME..._TRIANGLE(3) β from the Embree Ray Tracing Kernels 4 manual, section 3. 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