.\" Automatically generated by Pandoc 2.5 .\" .TH "rtcSetGeometryDisplacementFunction" "3" "" "" "Embree Ray Tracing Kernels 3" .hy .SS NAME .IP .nf \f[C] rtcSetGeometryDisplacementFunction \- sets the displacement function for a subdivision geometry \f[R] .fi .SS SYNOPSIS .IP .nf \f[C] #include 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 ); \f[R] .fi .SS DESCRIPTION .PP The \f[C]rtcSetGeometryDisplacementFunction\f[R] function registers a displacement callback function (\f[C]displacement\f[R] argument) for the specified subdivision geometry (\f[C]geometry\f[R] argument). .PP Only a single callback function can be registered per geometry, and further invocations overwrite the previously set callback function. Passing \f[C]NULL\f[R] as function pointer disables the registered callback function. .PP The registered displacement callback function is invoked to displace points on the subdivision geometry during spatial acceleration structure construction, during the \f[C]rtcCommitScene\f[R] call. .PP The callback function of type \f[C]RTCDisplacementFunctionN\f[R] is invoked with a number of arguments stored inside the \f[C]RTCDisplacementFunctionNArguments\f[R] structure. The provided user data pointer of the geometry (\f[C]geometryUserPtr\f[R] member) can be used to point to the application\[cq]s representation of the subdivision mesh. A number \f[C]N\f[R] of points to displace are specified in a structure of array layout. For each point to displace, the local patch UV coordinates (\f[C]u\f[R] and \f[C]v\f[R] arrays), the normalized geometry normal (\f[C]Ng_x\f[R], \f[C]Ng_y\f[R], and \f[C]Ng_z\f[R] arrays), and the position (\f[C]P_x\f[R], \f[C]P_y\f[R], and \f[C]P_z\f[R] arrays) are provided. The task of the displacement function is to use this information and change the position data. .PP The geometry handle (\f[C]geometry\f[R] member) and primitive ID (\f[C]primID\f[R] member) of the patch to displace are additionally provided as well as the time step \f[C]timeStep\f[R], which can be important if the displacement is time\-dependent and motion blur is used. .PP All passed arrays must be aligned to 64 bytes and properly padded to make wide vector processing inside the displacement function easily possible. .PP Also see tutorial [Displacement Geometry] for an example of how to use the displacement mapping functions. .SS EXIT STATUS .PP On failure an error code is set that can be queried using \f[C]rtcGetDeviceError\f[R]. .SS SEE ALSO .PP [RTC_GEOMETRY_TYPE_SUBDIVISION]