RTC_GEOMETRY_TYPE_GRID(3)
π 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.
widthandheightβ these specify the number of vertices in theuandvdirection. So like, setting bothwidthandheightto3sets up a3Γ3vertex grid. Iconic. The maximum allowedwidthandheightis32767β οΈ 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 yourstride, respect the32767cap, 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
- ubuntu stonking: libembree-dev 4.4.1+dfsg-2ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms