|
![](/i/fill.gif) |
I faced this bugreport and hope to have found where's the problem.
It seems that when computing the normal of the superellipsoid some
kind of over/underflow occurs with n or e very small, reordering the
computation produces a better image. Here's the diff to be applied
to super.cpp and a scene that shows the difference.
Massimo
#macro S(E,N,P)
superellipsoid { <E, N> translate P scale 2*y+1 pigment {rgb
<1,1,0>} }
#end
light_source { -35*z, rgb 1 }
camera {location -35*z look_at 0 }
#declare E = 5;
#declare P = -20*x;
#while (E > 0.00001)
S(E,.1,P+3.5*y)
S(E, E, P)
S(.1,E,P-3.5*y)
#declare P = P + 5*x;
#declare E = E / 5;
#end
479,480d478
< DBL k, x, y, z;
< VECTOR P, N, E;
481a480,481
> VECTOR const& E = Superellipsoid->Power;
> VECTOR P;
487,498c487,494
< Assign_Vector(E, Superellipsoid->Power);
<
< x = fabs(P[X]);
< y = fabs(P[Y]);
< z = fabs(P[Z]);
<
< k = power(power(x, E[X]) + power(y, E[X]), E[Y] - 1.0);
<
< N[X] = k * SGNX(P[X]) * power(x, E[X] - 1.0);
< N[Y] = k * SGNX(P[Y]) * power(y, E[X] - 1.0);
< N[Z] = SGNX(P[Z]) * power(z, E[Z] - 1.0);
<
---
> DBL x = P[X] != 0 ? power(fabs(P[X]), E[X]) : 0;
> DBL y = P[Y] != 0 ? power(fabs(P[Y]), E[X]) : 0;
> DBL z = P[Z] != 0 ? power(fabs(P[Z]), E[Z]) : 0;
>
> P[X] = x ? (1 - z) * x / P[X] : 0;
> P[Y] = y ? (1 - z) * y / P[Y] : 0;
> P[Z] = z ? (x+y) ? (x + y) * z / P[Z] : 1 : 0;
>
501c497
< MTransNormal(Result, N, Superellipsoid->Trans);
---
> MTransNormal(Result, P, Superellipsoid->Trans);
Post a reply to this message
|
![](/i/fill.gif) |