In the last post we looked at the Mandelbrot set, a beautiful 2d fractal with infinite complexity along its boundary. The challenge is to find a three dimensional version of the set, the Mandelbulb, which we can then lovingly render with dynamic lighting and shadows.

The Mandelbulb

The three-dimensional Mandelbulb

Mathematicians were doing work related to the Mandelbrot set in the very early 20th century. However, it wasn’t until the 1980s that computers were powerful enough to draw high quality pictures of it. The Mandelbulb is even more complicated, and requires even more computational power (once you’ve located the object, you then need to render it — this is where the computer spends most of its time). This is why we’ve not been able to see pictures of the Mandelbulb until very recently.

The first problem is determining the rule which will generate the Mandelbulb. For technical reasons there is no such thing as a 3d analogue of the complex numbers (the quaternions are the closest 4d analogue) and thus coming up with the ‘correct’ map is tricky. The key is to re-use the ideas of multiplying the radius, rotating the angles and then translating. Mathematicians use a set of coordinates for 3d space called spherical polar coordinates, which tell you location of a point in terms of the distance from the origin, r, and two other angles, \theta and \phi.

For those with the appropriate background, the map which takes you from one point to the next is given by composing a stretching and rotation:

(r,\theta,\phi) \to (r^n,n\theta,n\phi)

with a constant translation:

(x,y,z) \to (x+a,y+b,z+c)

Mandelbulb Zoom

A zoom of the Mandelbulb

We use spherical coordinates to do the first transformation, and cartesian coordinates to do the second. If the sequence of iterates remains bounded when using the parameters a, b and c then the point with coordinates (a,b,c) is part of the Mandelbulb. If the sequence diverges, then it is not.

We’ve introduced a parameter n into the map — this tells you how much to rotate the angles. If n is 2, that means we double the angles. If n is 3 we triple them, and so forth (in the 2d Mandelbrot set we only looked at n = 2). In three dimensions, the low values of n don’t give us a very interesting object. As we increase n the object gets progressively more complex. It turns out that n = 8 gives a nice balance between beauty and novelty.

Another Mandelbulb Zoom

Another zoom of the Mandelbulb

Now that we have the ingredients, all we need to do is complete the renders. This is a very computationally intensive process, but the results are worth it! By playing around with the color of lighting and the depth of shadows, we can create some truly stunning images — certainly the most striking examples of fractal beauty that I’ve ever seen.

All of the information in this post is sourced from the Mandelbulb page at Skytopia, which is well worth a visit!