The Mandelbulb explained

For decades people looked for a three-dimensional Mandelbrot set: a shape as rich as the famous black bug, but solid, with valleys and towers you could fly through. In 2009 a formula was found that comes close. The Mandelbulb, and the Mandelbox that followed a year later, can be drawn live by a graphics card, using a trick that tells every ray of light how far it may safely travel.

The power-8 Mandelbulb in bronze on a dark blue ground, its rings of bulbs covered in smaller bulbs
The power-8 Mandelbulb in bronze on a dark blue ground, its rings of bulbs covered in smaller bulbs

Why there is no true 3D Mandelbrot set

The Mandelbrot set comes from squaring complex numbers: z ↦ z² + c. Squaring a complex number doubles its angle and squares its distance from zero, and repeating that is what folds the plane into endless detail. Space has no such numbers. Frobenius proved in 1878 that besides the real and complex numbers, the only number system of this kind is the four-dimensional quaternions, and there is none in three dimensions. Using quaternions for the Mandelbrot formula gives a disappointingly smooth solid of revolution, the flat set simply spun around its axis.

Turning angles instead: the Mandelbulb

A point in space can be described by its distance r from the origin and two angles, like latitude and longitude. Daniel White and Paul Nylander took the recipe of the complex square and applied it to that description: multiply both angles by n and raise r to the power n, then add the starting point c, as in the Mandelbrot formula. Points whose orbit stays near the origin belong to the shape; points that run away do not. White published the formula in November 2009 under the name Mandelbulb. It is not a true number system, but it behaves enough like one to produce detail on every scale.

The power

The power n sets how many times the angles turn, and with it the symmetry: the bulb has n lobes around its vertical axis. Power 2, the direct analogue of the Mandelbrot set, gives a lumpy shape with little detail. From power 3 on, rings of bulbs appear, each covered in smaller bulbs, and power 8 has become the classic Mandelbulb because it shows the most varied surface: ornate towers next to smooth areas that fractal fans call whipped cream. Powers need not be whole numbers, so the explorer lets you slide between them and watch the bulb grow new lobes.

The Mandelbox: folding space

In 2010 Tom Lowe found a different recipe that needs no angles at all. Fold each coordinate back into the range from −1 to 1, as if space were a sheet of paper folded at the walls of a box. Then invert the point in a sphere: points close to the centre are pushed outwards, points just inside the sphere are turned inside out. Scale by a number s and add the starting point. With a positive scale the result is a cube full of rooms, pillars and arches; for scale 2 it fills the box from −6 to 6 in every direction. Negative scales give rounder shapes that look like corals or space stations.

Quaternion Julia sets: a slice of four dimensions

Quaternions are numbers with one real and three imaginary parts, invented by William Rowan Hamilton in 1843. They do square properly, so q ↦ q² + c works with them, and fixing c gives a quaternion Julia set, a four-dimensional shape. The explorer shows the three-dimensional slice where the fourth coordinate is zero, so what you see is a cross-section of something larger. Alan Norton drew the first ones in 1982, and in 1989 John Hart, Daniel Sandin and Louis Kauffman showed how to ray-trace them with a distance estimate, the method this explorer uses.

How the picture is drawn: ray marching

A fractal surface has no triangles to draw, so the explorer sends one ray from the eye through every pixel and finds where it first touches the shape. The formulas come with a distance estimate: from the speed at which an orbit runs away, one can compute a distance d that is guaranteed to contain no part of the fractal. The ray jumps forward by d, asks again, and repeats until it is closer than a pixel, a method John Hart called sphere tracing in 1996. Every pixel needs dozens of such steps, each with a dozen iterations of the formula, which is why the work is done by the graphics card, where thousands of pixels are computed at the same time.

Light, shadows and colour

Once a ray has hit the surface, the direction the surface faces is found from the distance estimate at a few nearby points, and lighting works as for any 3D object. Soft shadows send a second ray towards the light and see how close it passes to the shape. Ambient occlusion samples the distance in a few steps away from the surface: in a narrow crack the shape is close on all sides, so less light from the sky gets in and the crack is darker. The colours come from an orbit trap: how close the point's orbit came to the origin, which varies smoothly over the surface and brings out its structure.

Frequently asked questions

Is the Mandelbulb the real 3D Mandelbrot set?

No, because a real one would need a three-dimensional number system, and there is none. The Mandelbulb copies what complex squaring does to angles and distances, which gives a rich fractal but not every property of the Mandelbrot set: its slices are not the Mandelbrot set, and some regions are smooth instead of detailed.

Why is power 8 the classic Mandelbulb?

Because it shows the most variety. Low powers give few, large lobes and little detail; very high powers give many thin spikes. Around 8 the bulb has towers, spirals and smooth patches side by side, and the first famous renderings by Daniel White and Paul Nylander in 2009 used it.

How deep can I zoom in?

Double-click a spot to fly there and keep zooming with the wheel. The detail keeps coming for a long way, but the graphics card computes with about seven significant digits, so somewhere past a zoom of ten thousand the surface turns blocky. Raising Detail adds iterations, which sharpens fine structure but makes every frame slower.

What do soft shadows and ambient occlusion do?

Soft shadows darken the parts of the shape that the light cannot reach, with soft edges where the light passes close to the surface. Ambient occlusion darkens cracks and hollows, where light from the sky is blocked from many sides. Both make the shape look more solid, and both cost extra rays, so switching them off speeds the picture up.

Why does the picture look blurry while I turn it?

To keep turning smooth, the explorer draws a smaller picture without shadows while the view moves and stretches it over the canvas. As soon as you let go, the full picture is drawn in strips from the top, which takes a moment on slower devices. Quality chooses how many pixels the full picture has.

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

Open the Mandelbulb 3D explorer