rtcInterpolate(3)

πŸ’– rtcInterpolate β€” bestie edition πŸ’–

okay so this is the manual page for rtcInterpolate, part of the Embree Ray Tracing Kernels 4 docs. yes i know, a C API manual page, and yes i'm about to make it cute. sit down, hydrate, let's go 🫢


✨ NAME ✨

rtcInterpolate β€” interpolates vertex attributes πŸ’…

like, it takes your per-vertex data and smooshes it all smooth across the surface. it's giving glow-up for point clouds, no cap.


🌸 SYNOPSIS 🌸

first things first, you gotta include the header:

#include <embree4/rtcore.h>

then there's this whole struct you pass your args in, and it looks like this, exactly like this, don't touch a single character:

struct RTCInterpolateArguments
{
  RTCGeometry geometry;
  unsigned int primID;
  float u;
  float v;
  enum RTCBufferType bufferType;
  unsigned int bufferSlot;
  float* P;
  float* dPdu;
  float* dPdv;
  float* ddPdudu;
  float* ddPdvdv;
  float* ddPdudv;
  unsigned int valueCount;
};

and then the actual function, which is literally just:

void rtcInterpolate(
  const struct RTCInterpolateArguments* args
);

one function. one pointer to the args struct. that's it. clean. minimal. iconic. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so what does rtcInterpolate actually do? it smoothly interpolates per-vertex data over the geometry. and bestie, this interpolation is supported for:

  • triangle meshes πŸ”Ί
  • quad meshes 🟦
  • curve geometries πŸŽ€
  • subdivision geometries 🌈

and it's not just the vertex attribute itself β€” you can also get the first order derivatives and the second order derivatives of that value. the whole derivative family is invited to the party. πŸ‘‘

⚠️ important vibe check: this interpolation ignores displacements of subdivision surfaces and always interpolates the underlying base surface. so don't come for it expecting the displaced version, because it simply is not doing that.

so here's how the call works. you pass a bunch of arguments inside a struct of type RTCInterpolateArguments. for some geometry (the geometry parameter), the function smoothly interpolates the per-vertex data stored inside the specified geometry buffer (the bufferType and bufferSlot parameters) to the u/v location (the u and v parameters) of the primitive (the primID parameter). 🎯

the number of floating point values to interpolate and store into the destination arrays? that's the valueCount parameter. you're in charge. πŸ’ͺ

and as the interpolation buffer, you can specify:

  • vertex buffers (RTC_BUFFER_TYPE_VERTEX)
  • vertex attribute buffers (RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE)

both are fair game, bestie. 🫢


πŸ’œ where the values actually land πŸ’œ

the interpolated value: rtcInterpolate stores valueCount number of interpolated floating point values to the memory location pointed to by P. and if you literally don't care about the value itself? set P to NULL and it just... won't store it. obsessed with the opt-out. πŸ™ˆ

first order derivatives: the first order derivative of the interpolation by u and v are stored at the dPdu and dPdv memory locations. want to skip those? set both dPdu and dPdv to NULL. note the "both" β€” that's the deal, that's the rule. ✌️

second order derivatives: those live at the ddPdudu, ddPdvdv, and ddPdudv memory locations. and to avoid storing second order derivatives you set these three pointers to NULL. all three. no partial skipping. periodt. πŸ’…


🧚 the rules, because there are always rules 🧚

to use rtcInterpolate for a geometry, all changes to that geometry must be properly committed using rtcCommitGeometry. like, commit your changes or this whole thing is not gonna go how you want it to. this is not optional, this is the law. πŸ“œ

and this one is lowkey important so i'm putting it in its own little callout:

🚨 all input buffers and output arrays must be padded to 16 bytes, because the implementation uses 16-byte SSE instructions to read and write into these buffers. if you don't pad, you're gonna have a bad time. the hardware said 16 bytes and it meant 16 bytes. 🧱

🌟 want an example? 🌟

see tutorial [Interpolation] for an example of using the rtcInterpolate function. go look, it's right there, it's your study guide. πŸ“šβœ¨


πŸ’€ EXIT STATUS πŸ’€

ngl, this is the part that will humble you:

for performance reasons this function does not do any error checks, thus will not set any error flags on failure.

so if something's wrong, it's not gonna tell you. it's just gonna vibe. silently. into the void. you have been warned, bestie. 😭


πŸ‘€ SEE ALSO πŸ‘€

  • [rtcInterpolateN]

that's the whole page, you ate that fr fr. πŸ’–

rtcInterpolate(3) β€” from the Embree Ray Tracing Kernels 4 manual pages. mwah, go interpolate something pretty. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from