RTC_GEOMETRY_TYPE_QUAD(3embree3)

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

πŸ’– RTC_GEOMETRY_TYPE_QUAD πŸ’–

okay bestie, welcome to the RTC_GEOMETRY_TYPE_QUAD page from the Embree Ray Tracing Kernels 3 manual πŸ’… this is the one that tells you how quads work. quad geometry type. that's the whole vibe. let's go πŸ¦‹


✨ NAME ✨

RTC_GEOMETRY_TYPE_QUAD β€” quad geometry type, aka the four-cornered icon of the mesh world πŸ‘‘


🌸 SYNOPSIS 🌸

#include <embree3/rtcore.h>

RTCGeometry geometry =
  rtcNewGeometry(device, RTC_GEOMETRY_TYPE_QUAD);

πŸ’œ DESCRIPTION πŸ’œ

Quad meshes are literally created by passing RTC_GEOMETRY_TYPE_QUAD into the rtcNewGeometry function call. that's it, that's the birth of a quad mesh πŸŽ€

So how do you feed it? Two ways, two buffers, no cap:

  • the quad indices get specified by setting an index buffer β€” that's the RTC_BUFFER_TYPE_INDEX type
  • the quad vertices get specified by setting a vertex buffer β€” that's the RTC_BUFFER_TYPE_VERTEX type

and if you're like "bestie how do I even set buffers", go read rtcSetGeometryBuffer and rtcSetSharedGeometryBuffer, they have all the deets 🫢

Now the nitty gritty:

  • the index buffer holds an array of four 32-bit indices per quad, in RTC_FORMAT_UINT4 format, 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_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, so like, don't go feral

🧚 How a quad actually behaves internally 🧚

Not me exposing the quad's whole private life but okay: internally a quad is handled as a pair of two triangles, v0,v1,v3 and v2,v3,v1, and the u'/v' coordinates of that second triangle get corrected by u = 1-u' and v = 1-v' so that the resulting quad parametrization has u and v both in the range 0 to 1 ✨

So the parametrization of a quad uses:

  • the first vertex p0 as the base point
  • the vector p1 - p0 as the u-direction
  • the vector p3 - p0 as the v-direction

which means vertex attributes t0,t1,t2,t3 can be bilinearly interpolated over the quadrilateral like this, periodt:

t_uv = (1-v)((1-u)*t0 + u*t1) + v*((1-u)*t3 + u*t2)

🌈 Mixed triangle/quad meshes 🌈

Yes bestie, you CAN have both. Mixed triangle/quad meshes are supported by encoding a triangle as a quad β€” you do that by replicating the last triangle vertex:

v0,v1,v2 -> v0,v1,v2,v2

and the way that works is that the second triangle becomes a line (which can never get hit, so don't worry about it πŸ’€), and the parametrization of the first triangle stays compatible with the standard triangle parametrization. slay πŸ™ˆ


πŸ‘‘ Winding + normals πŸ‘‘

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. iconic behavior fr fr.


⭐ Multi-segment motion blur ⭐

For multi-segment motion blur, the number of time steps must first be specified using the rtcSetGeometryTimeStepCount call. Then you can set a vertex buffer for each time step using different buffer slots β€” and all these buffers must have the same stride and size. no exceptions, no shortcuts, the buffers are matching or they're nothing πŸŽ€


πŸ’€ EXIT STATUS πŸ’€

On failure, NULL is returned and an error code is set that you can query using rtcGetDeviceError. so like, check it. please. for me πŸ₯Ί


πŸ¦‹ SEE ALSO πŸ¦‹

  • [rtcNewGeometry]

and that's the whole page bestie, you're officially a quad girlie now πŸ’…βœ¨

signing off from the RTC_GEOMETRY_TYPE_QUAD(3) page of the Embree Ray Tracing Kernels 3 manual β€” stay interpolated, stay bilinear, and remember: 16 GB max on that vertex buffer πŸ«ΆπŸ’–πŸŽ€

πŸ“¦ where this page comes from