RTC_GEOMETRY_TYPE_QUAD(3embree4)
π RTC_GEOMETRY_TYPE_QUAD β quad geometry type π¦
okay bestie, welcome to the Embree Ray Tracing Kernels 4 manual page for RTC_GEOMETRY_TYPE_QUAD. yes it's a whole manual page, no it's not scary, let's go π
β¨ SYNOPSIS β¨
#include <embree4/rtcore.h>
RTCGeometry geometry =
rtcNewGeometry(device, RTC_GEOMETRY_TYPE_QUAD);
πΈ DESCRIPTION πΈ
So you want quads. Quad meshes get born when you hand RTC_GEOMETRY_TYPE_QUAD over to the rtcNewGeometry function call. That's the whole origin story.
The quad indices? You set those by setting an index buffer (that's the RTC_BUFFER_TYPE_INDEX type, mwah). And the quad vertices? You set those by setting a vertex buffer (RTC_BUFFER_TYPE_VERTEX type, iconic). If you wanna know how to actually set buffers, go read rtcSetGeometryBuffer and rtcSetSharedGeometryBuffer β they're the ones with all the details, fr fr.
Now the deets on what's inside those buffers:
- The index buffer holds an array of four 32-bit indices per quad, in
RTC_FORMAT_UINT4format, and the number of primitives is inferred from the size of that buffer. - The vertex buffer holds 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. - The vertex buffer can be at most 16 GB large. that's the ceiling bestie, don't push it π
π§ how a quad is actually handled internally
A quad is internally handled as a pair of two triangles: v0,v1,v3 and v2,v3,v1. The u'/v' coordinates of that second triangle get corrected by u = 1-u' and v = 1-v' so you end up with a quad parametrization where u and v are in the range 0 to 1.
So the parametrization of a quad uses the first vertex p0 as base point, the vector p1 - p0 as u-direction, and p3 - p0 as v-direction. Obsessed with how clean that is.
Which means vertex attributes t0,t1,t2,t3 can be bilinearly interpolated over the quadrilateral like this:
t_uv = (1-v)((1-u)*t0 + u*t1) + v*((1-u)*t3 + u*t2)
π mixed triangle/quad meshes
Mixed triangle/quad meshes are supported β slay β and you do it by encoding a triangle as a quad. The way that works: replicate the last triangle vertex, so v0,v1,v2 becomes v0,v1,v2,v2. Then the second triangle is a line (which can never get hit, it's giving ghost π»), and the parametrization of the first triangle stays compatible with the standard triangle parametrization. no cap.
π normals + the picture
A quad whose vertices are laid out counter-clockwise has its geometry normal pointing upwards outside the front face β like illustrated in the following picture. (the original page has the pic, bestie, I can't paste an image in here, but you get the vibe β¨)
β±οΈ multi-segment motion blur
For multi-segment motion blur, the number of time steps must be first specified using the rtcSetGeometryTimeStepCount call. Then a vertex buffer for each time step can be set using different buffer slots, and all these buffers must have the same stride and size. same stride, same size, periodt.
π EXIT STATUS π
On failure NULL is returned and an error code is set that can be queried using rtcGetDeviceError. so if you get NULL back, don't panic β go ask rtcGetDeviceError what went wrong π«Ά
π SEE ALSO π
- [
rtcNewGeometry]
and that's the whole page bestie, you ate π β¨
sign-off: this was RTC_GEOMETRY_TYPE_QUAD(3) from the Embree Ray Tracing Kernels 4 manual β go forth and render some flawless quads, ily π¦π
π¦ where this page comes from
- alpine 3.24: embree-doc 4.4.1-r0 Β· Apache-2.0
- arch rolling: embree 4.4.1-1 Β· Apache-2.0
- fedora 43: embree 4.4.1-1.fc43 Β· Apache-2.0
- fedora 44: embree 4.4.1-1.fc44 Β· Apache-2.0
- nixpkgs unstable: embree 4.4.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms