|
|
Dre wrote:
> Great, thanks for that, I'm going to have a play with that
> later tonight!
I almost forgot...
If you can compile your own version of POV-Ray, you may be interested in
this trick to speed up rendering *A LOT*
Load up isosurf.cpp, scroll down to the bottom, and replace the
Evaluate_Fuction code with the code shown below. This is basically a
pure C code version of my Sphere Sponge isosurface function, and as you
can imagine, can be evaluated much faster than the parsed SDL version.
DBL Evaluate_Function(FUNCTION funct, VECTOR fnvec)
{
DBL result = -1.0;
DBL x = fnvec[X]-0.5;
DBL y = fnvec[Y]-0.5;
DBL z = fnvec[Z]-0.5;
DBL max = fabs(x);
if (fabs(y) > max) { max = fabs(y); }
if (fabs(z) > max) { max = fabs(z); }
if ((fabs(x)+fabs(y)+fabs(z))/2 > max) { max =
(fabs(x)+fabs(y)+fabs(z))/2; }
DBL sphereScale = sqrt(x*x+y*y+z*z) / max;
x *= sphereScale;
y *= sphereScale;
z *= sphereScale;
x += 0.5;
y += 0.5;
z += 0.5;
DBL size = 0.5;
for (int level = 4; level > 0; --level)
{
size /= 3.0;
DBL a = size - fabs(fmod(x,size*6.0)-size*3.0);
DBL b = size - fabs(fmod(y,size*6.0)-size*3.0);
DBL c = size - fabs(fmod(z,size*6.0)-size*3.0);
if (a < b)
{
if (a > result) { result = a; }
}
else
{
if (b > result) { result = b; }
}
if (b < c)
{
if (b > result) { result = b; }
}
else
{
if (c > result) { result = c; }
}
if (c < a)
{
if (c > result) { result = c; }
}
else
{
if (a > result) { result = a; }
}
}
if (x-1 > result) { result = x-1; }
if (y-1 > result) { result = y-1; }
if (z-1 > result) { result = z-1; }
if (-x > result) { result = -x; }
if (-y > result) { result = -y; }
if (-z > result) { result = -z; }
if (-x+y-z-0.5 > result) { result = -x+y-z-0.5; }
if (+x+y-z-1.5 > result) { result = +x+y-z-1.5; }
if (-x-y-z+0.5 > result) { result = -x-y-z+0.5; }
if (+x-y-z-0.5 > result) { result = +x-y-z-0.5; }
if (-x+y+z-1.5 > result) { result = -x+y+z-1.5; }
if (+x+y+z-2.5 > result) { result = +x+y+z-2.5; }
if (-x-y+z-0.5 > result) { result = -x-y+z-0.5; }
if (+x-y+z-1.5 > result) { result = +x-y+z-1.5; }
return result;
}
Post a reply to this message
|
|