RTC_GEOME..._TRIANGLE(3)
β¨ NAME β¨
RTC_GEOMETRY_TYPE_TRIANGLE β bestie, it's the triangle geometry type π
This page lives in the Embree Ray Tracing Kernels 3 manual (section 3, iykyk).
πΈ SYNOPSIS πΈ
#include <embree3/rtcore.h>
RTCGeometry geometry =
rtcNewGeometry(device, RTC_GEOMETRY_TYPE_TRIANGLE);
π¦ DESCRIPTION π¦
So the way that triangle meshes work: you literally just pass RTC_GEOMETRY_TYPE_TRIANGLE into the rtcNewGeometry function call and boom, geometry created. β¨
Then you gotta feed it two things:
- The triangle indices β you set those by giving it an index buffer of type
RTC_BUFFER_TYPE_INDEX. - The triangle vertices β you set those by giving it a vertex buffer of type
RTC_BUFFER_TYPE_VERTEX.
Want the deets on how to actually set those buffers? Go read rtcSetGeometryBuffer and rtcSetSharedGeometryBuffer. They got you. π«Ά
Now the specs, no cap:
- The index buffer has to contain an array of three 32-bit indices per triangle (that's
RTC_FORMAT_UINT3format), and the number of primitives is inferred from the size of that buffer. - The vertex buffer has to contain an array of single precision
x,y,zfloating point coordinates (that'sRTC_FORMAT_FLOAT3format), and the number of vertices is inferred from the size of that buffer. - The vertex buffer can be at most 16 GB large. Yes, sixteen gigabytes. That's the ceiling. π«£
π The parametrization, bestie π
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. Iconic, honestly.
So that means 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)
π Which way is "up" though π
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.
π There's literally a picture right here in the real page showing exactly that. Picture it. Or don't β the counter-clockwise rule above is the whole tea.
β° Multi-segment motion blur β°
For multi-segment motion blur, the number of time steps must be first specified using the rtcSetGeometryTimeStepCount call. Then you can set a vertex buffer for each time step using different buffer slots β and heads up, all of these buffers have to have the same stride and size. No mismatches, periodt.
Also, if you want a whole worked example of how to create triangle meshes, go check the tutorial [Triangle Geometry]. It's giving tutorial energy. π₯
π EXIT STATUS π
On failure, NULL is returned and an error code is set that be get queried using rtcGetDeviceError. So if you get nothing back, go ask rtcGetDeviceError what went wrong. π
π SEE ALSO π
- [rtcNewGeometry]
Okay that's the whole page, bestie. Sending you all the good vibes from the Embree Ray Tracing Kernels 3 manual β this one's filed under RTC_GEOME..._TRIANGLE(3), in case you gotta cite it later. Now go render something gorgeous. πβ¨
π¦ where this page comes from
- epel 9: embree 3.13.5-4.el9 Β· Apache-2.0
- fedora 43: embree3 3.13.5-9.fc41 Β· Apache-2.0
- fedora 44: embree3 3.13.5-16.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms