my home page
fractals.3d.classic.algorithm




All the 3d Julia and Mandelbrot sets shown in this page are calculated with the mathemathics described in the math section. The algorithm used for the rendering was raytracing. The 3d Julias and Mandelbrot are encapsulated on a ray-tracing primitive, so that once the intersection and normal-calculation functions are written, you can incorporate the fractals on any standard 3d scene.

First of all the 3d fractal is bounded by a bounding-box so that no ray-fractal test is made if the a ray does not intersect the boundig box. Then, if the ray hits the box, the segment between the two intersection points have to be tested against the fractal. For the Julia sets the "interior" of the fractal is considered the Fatou set, ie, the points that do not escape to infinity under iteration. So each point of the segment should be tested under iteration to see if the orbit diverges or not. Of course this is provided a fixed maximal number of iterations (N). That point of the segment separating the interior from the exterior that is nearer to the ray origin is considered the intersection point.

The easier but slower way to find this point is to travel thru the segment in steps of some fixed width until the first non-scaping point is detected. This is really slow, and a modification of this "basic" algorithm is used in the generation of the images of this page.

Instead of using constant-width jumps, increments depending of the fractal potential are used. This makes the algorithm advance much faster in distant points than in the nearest ones. With this modification the algorithms catchs the intersection point in just some iterations.

Once the intersection point rutine is made, the next step is the normal calculation rutine. It is much easier than the intersection rutine. The only thing to do is to iterate the fractal in the intersection point together with the partial derivatives. Then the normal is the gradient of the escalar function under the fractal test. This function is the modulo of the Nth point of the orbit minus the bailout value:

f(z) = Xn·Xn + Yn·Yn + Zn·Zn - th·th

so that the interior of the fractal are those points for whitch

f(z) < 0

The normal is therefore


for the Julia sets and


for the Mandelbrot set. Diferenciating, for the julia set, we get






so the normal (gradient) can be writen as



Don't forget to normalize this vetor to unit length if you plan to use the normal to do shading calculations on your rendering system. Anyway, I gess a better normal might be obtained thru the gradient of the Douady-Hubbard potential.







iņigo quilez 2002