rtcSetGeo...tFunction(3)
π rtcSetGeometryDisplacementFunction π
okay bestie, welcome to the Embree Ray Tracing Kernels 3 manual page for rtcSetGeometryDisplacementFunction β yes the header truncates it to rtcSetGeo...tFunction(3) because apparently even manpages have to fit in the group chat preview. anyway. this one is about making your subdivision geometry move, and it's lowkey iconic.
β¨ NAME β¨
rtcSetGeometryDisplacementFunction β sets the displacement function for a subdivision geometry
πΈ SYNOPSIS πΈ
#include <embree3/rtcore.h>
struct RTCDisplacementFunctionNArguments
{
void* geometryUserPtr;
RTCGeometry geometry;
unsigned int primID;
unsigned int timeStep;
const float* u;
const float* v;
const float* Ng_x;
const float* Ng_y;
const float* Ng_z;
float* P_x;
float* P_y;
float* P_z;
unsigned int N;
};
typedef void (*RTCDisplacementFunctionN)(
const struct RTCDisplacementFunctionNArguments* args
);
void rtcSetGeometryDisplacementFunction(
RTCGeometry geometry,
RTCDisplacementFunctionN displacement
);
π¦ DESCRIPTION π¦
so the rtcSetGeometryDisplacementFunction function registers a displacement callback function (that's the displacement argument, bestie) for the subdivision geometry you point at with the geometry argument. it's giving "hey geometry, here's the glow-up routine."
you can only have ONE callback function registered per geometry, periodt. every further invocation just overwrites whatever callback was there before, no drama, no queue. and if you pass NULL as the function pointer? that disables the registered callback function entirely. poof. gone. π
the registered displacement callback gets invoked to displace points on the subdivision geometry during spatial acceleration structure construction β specifically during the rtcCommitScene call. so it's not vibing at render time, it's doing its thing while the acceleration structure is being built. important distinction, iykyk.
the callback function is of type RTCDisplacementFunctionN and it gets invoked with a bunch of arguments stored inside the RTCDisplacementFunctionNArguments structure. let's go through them because this is the part where people get lost:
- the provided user data pointer of the geometry (the
geometryUserPtrmember) can point to your application's representation of the subdivision mesh β that's your little pocket dimension for whatever data you need. - a number
Nof points to displace is specified in a structure of array layout. so like, arrays. obviously. - for each point to displace, you get:
- the local patch UV coordinates (the
uandvarrays) - the normalized geometry normal (the
Ng_x,Ng_y, andNg_zarrays) - the position (the
P_x,P_y, andP_zarrays)
- the local patch UV coordinates (the
and the task of the displacement function? use all of that info and change the position data. that's the whole job. slay.
the geometry handle (the geometry member) and the primitive ID (the primID member) of the patch to displace are additionally provided as well β and so is the time step timeStep, which can be important if the displacement is time-dependent and motion blur is used. β±οΈ
β οΈ real talk, bestie: all passed arrays must be aligned to 64 bytes and properly padded, so that wide vector processing inside the displacement function is easily possible. don't skip this. the vector unit will simply not be okay. π
also see the tutorial [Displacement Geometry] for an example of how to use the displacement mapping functions. π
π EXIT STATUS π
on failure an error code is set that you can query using rtcGetDeviceError. so like, check it. don't just assume it ate. π
π SEE ALSO π
[RTC_GEOMETRY_TYPE_SUBDIVISION]
and that's the whole page, bestie! this was rtcSetGeometryDisplacementFunction(3) from the Embree Ray Tracing Kernels 3 manual set β go forth and displace, you've got this. mwah. πβ¨π«Ά
π¦ where this page comes from
- epel 9: embree 3.13.5-4.el9 Β· Apache-2.0
- fedora 43: embree3 3.13.5-9.fc41 Β· Apache-2.0
- fedora 44: embree3 3.13.5-16.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms