rtcInterpolate(3)

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

πŸ’– rtcInterpolate(3) β€” Embree Ray Tracing Kernels 3 πŸ’–

okay bestie, sit down, hydrate, because today we're interpolating vertex attributes and it's gonna be smooth ✨ (like, literally smoothly, that's the whole function)


🌸 NAME 🌸

rtcInterpolate β€” interpolates vertex attributes πŸŽ€


✨ SYNOPSIS ✨

#include <embree3/rtcore.h>

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;
};

void rtcInterpolate(
  const struct RTCInterpolateArguments* args
);

like, look at that struct. it's giving organised. we love a struct that knows what it wants πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so the way that rtcInterpolate works is it smoothly interpolates per-vertex data over the geometry. no cap, smoothly. it's supported for:

  • triangle meshes
  • quad meshes
  • curve geometries
  • subdivision geometries

and here's the slay part β€” you don't just get the vertex attribute itself, you can also pull the first and second order derivatives of that value. main character behaviour fr fr πŸ‘‘

⚠️ heads up bestie: this interpolation ignores displacements of subdivision surfaces and always interpolates the underlying base surface. just so you know. no surprises. 🫢

πŸ’œ the arguments situation

the rtcInterpolate call gets passed a whole little bundle of arguments inside a structure of type RTCInterpolateArguments.

so for some geometry (that's the geometry parameter), this function smoothly interpolates the per-vertex data stored inside the specified geometry buffer (that's bufferType and bufferSlot) to the u/v location (that's u and v) of the primitive (that's primID).

the number of floating point values to interpolate and store to the destination arrays? you say that with valueCount. and as interpolation buffer, you can specify vertex buffers (RTC_BUFFER_TYPE_VERTEX) and vertex attribute buffers (RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE) as well. so many options, we're obsessed πŸ’–


πŸŽ€ where the values go

rtcInterpolate stores valueCount number of interpolated floating point values to the memory location pointed to by P.

  • wanna skip storing the interpolated value? just set P to NULL. easy.

the first order derivative of the interpolation by u and v get stored at the dPdu and dPdv memory locations.

  • wanna skip the first order derivatives? set both dPdu and dPdv to NULL. both, bestie. both. πŸ‘€

the second order derivatives get stored at the ddPdudu, ddPdvdv, and ddPdudv memory locations.

  • wanna skip the second order derivatives? set these three pointers to NULL.

🌈 the commit thing (do not skip this)

to use rtcInterpolate for a geometry, all changes to that geometry must be properly committed using rtcCommitGeometry.

🚨 literally do not forget this one. uncommitted changes = not the vibe. it's giving chaos. commit first, interpolate second, periodt.

πŸ’€ the padding thing (also do not skip this)

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.

😭 yes bestie, 16 bytes. the SSE instructions said "we need alignment" and honestly? we respect it.

🧚 example time

see tutorial [Interpolation] for an example of using the rtcInterpolate function. go look, it's cute, it'll make it click ⭐


πŸ”₯ EXIT STATUS πŸ”₯

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

πŸ’€ so like... if it goes wrong, it goes wrong quietly. no error flags. no drama. just vibes and consequences. check your own stuff, bestie, the function is not gonna do it for you.

πŸ‘‘ SEE ALSO πŸ‘‘

  • rtcInterpolateN

and that's the whole page, you ate it, you understood it, iconic behaviour 🌟

this was rtcInterpolate(3) from the Embree Ray Tracing Kernels 3 β€” mwah, take care of your 16-byte padding and your commits, ily, bye πŸ’–πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from