RTC_GEOMETRY_TYPE_GRID(3embree4)

πŸ’– RTC_GEOMETRY_TYPE_GRID πŸ’–

okay bestie, so this is the grid geometry type page from the Embree Ray Tracing Kernels 4 manual (the 3embree4 section, iykyk) and we're gonna make grids make sense, fr fr πŸ¦‹


✨ NAME ✨

RTC_GEOMETRY_TYPE_GRID β€” it's the grid geometry type, that's the whole vibe πŸ’…


🌸 SYNOPSIS 🌸

#include <embree4/rtcore.h>

RTCGeometry geometry =
  rtcNewGeometry(device, RTC_GEOMETRY_TYPE_GRID);

like. that's it. that's the entrance ✨


πŸŽ€ DESCRIPTION πŸŽ€

So here's the tea: grid meshes are made by passing RTC_GEOMETRY_TYPE_GRID into the rtcNewGeometry function call, and a grid mesh contains an array of grid primitives. Not one grid β€” a whole array of them. She contains multitudes πŸ’œ

You tell Embree about that array of grids by setting up a grid buffer (with RTC_BUFFER_TYPE_GRID type and RTC_FORMAT_GRID format), and you set the grid mesh vertices by setting a vertex buffer (RTC_BUFFER_TYPE_VERTEX type). If you wanna know more about how to set buffers, go peek at rtcSetGeometryBuffer and rtcSetSharedGeometryBuffer β€” they're the buffer girlies 🫢

Also the number of grid primitives in the grid mesh is inferred from the size of the grid buffer, so like, no need to count them yourself, she already knows 😌

The vertex buffer contains an array of single precision x, y, z floating point coordinates (RTC_FORMAT_FLOAT3 format), and the number of vertices is inferred from the size of that buffer. Same energy, different buffer.


πŸ¦‹ the RTCGrid struct πŸ¦‹

Each grid in the grid buffer is of the type RTCGrid:

struct RTCGrid
{
  unsigned int startVertexID;
  unsigned int stride;
  unsigned short width,height;
};

The RTCGrid structure describes a 2D grid of vertices (with respect to the vertex buffer of the grid mesh). Periodt.

  • width and height β€” these specify the number of vertices in the u and v direction. So like, setting both width and height to 3 sets up a 3Γ—3 vertex grid. Iconic. The maximum allowed width and height is 32767 ⚠️ so don't get too ambitious.
  • startVertexID β€” specifies the ID of the top-left vertex in the vertex grid. Like, where the grid begins in the vertex buffer, that's her.
  • stride β€” specifies a stride (in number of vertices) used to step to the next row. That's the lil hop between rows πŸ’…

🌈 how the grid actually renders 🌈

A vertex grid of dimensions width and height is treated as a (width-1) x (height-1) grid of quads (triangle-pairs), with the same shared edge handling as for regular quad meshes. No cap.

But here's the plot twist bestie: the u/v coordinates have the uniform range [0..1] for an entire vertex grid. So the whole grid gets that full 0 to 1 glow-up ✨ The u direction follows the width of the grid, while the v direction follows the height. That's the mapping, that's the assignment, she ate πŸ’…


🧚 multi-segment motion blur 🧚

For multi-segment motion blur, the number of time steps must first be specified using the rtcSetGeometryTimeStepCount call. Then a vertex buffer for each time step can be set using different buffer slots β€” and heads up, all these buffers must have the same stride and size. Not optional. She said consistency, she said uniform πŸ”₯


πŸ’€ EXIT STATUS πŸ’€

On failure NULL is returned and an error code is set that you can query using rtcGetDeviceError. So if you get nothing back, don't panic β€” just go ask rtcGetDeviceError what happened 😭


πŸ‘‘ SEE ALSO πŸ‘‘

  • [rtcNewGeometry]

lowkey the whole thing is just: buffer in, grid out, mind your stride, respect the 32767 cap, and set your time steps before your buffers. that's the vibe check πŸ“

and that's the page bestie!! this was RTC_GEOMETRY_TYPE_GRID(3) from the Embree Ray Tracing Kernels 4 manual, mwah, go build something gorgeous with your grids πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from