This primitive encapsulates an implicit surface given as a signed distance function of the form F(P) = 0. The function "F" should evaluate positive outside the surface and negative inside. This function is given the renderer in a shared object (dll/so). Your shared object must export the following three functions given in "implicit.h" in the @PIXIEHOME@/include directory:
extern "C" {
LIB_EXPORT void *implicitInit(int,float *,float *);
LIB_EXPORT float implicitEval(float *,void *,const float *);
LIB_EXPORT void implicitTini(void *);
};
implicitInit function should init your surface. The first argument is the frame number. This function should return the minimum and maximum corners of the bounding box in the second and third arguments respectively. This function should return a transparent handle that will be used to identify the surface. If case of a failure, this function should return NULL (0).
implicitEval function should evaluate the function at the point given in the third argument and should return the value of the function. It should also set the first argument to the gradient of the function. The second argument is the transparent data handle returned by the implicitInit call.
implicitTini function should destroy the surface.
For example, the following code implements a sphere:
void *implicitInit(int frame,float *bmin,float *bmax) {
// Init the bounding box
bmin[0] = -1;
bmin[1] = -1;
bmin[2] = -1;
bmax[0] = 1;
bmax[1] = 1;
bmax[2] = 1;
return (void *) 1;
}
float implicitEval(float *dF,void *data,const float *P) {
dF[0] = 2*P[0];
dF[1] = 2*P[1];
dF[2] = 2*P[2];
return P[0]*P[0] + P[1]*P[1] + P[2]*P[2] - 1;
}
void implicitTini(void *) {
// Nothing to do here
}
You can now instantiate your sphere by
Geometry "implicit" "string file" "sphere.dll" "float stepSize" [0.01] "float intersectionBias" [0.00001]
In this call "file" argument gives the name of the shared object implementing the primitive, "stepSize" is the maximum step size to take during the ray marching and "intersectionBias" gives the maximum distance to the surface to count as an intersection. Pixie uses Newton root finding to find the surface so "stepSize" is the maximum size of a step.
Important: This primitive is only visibile in raytracing mode. The hiders "hidden", "zbuffer" and "opengl" will skip this primitive. Also since such implicit objects do not have a parametrication, only the position (P) and the normal (N) can be used during the shading. This means, no texturemapping or differentiation.