RTC_GEOME..._TRIANGLE(3)

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

✨ 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_UINT3 format), 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, z floating point coordinates (that's RTC_FORMAT_FLOAT3 format), 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