🌌 Mandelbulb 3D Fractal
A real-time 3D Mandelbulb raymarched on the GPU. Tweak the power n, iterations and palette to watch the spiky-shell fractal emerge from honest distance-estimator math.
About this simulation
This simulator renders the Mandelbulb, the best-known three-dimensional analogue of the Mandelbrot set, by GPU raymarching against an analytic distance estimator. Every point is converted to spherical coordinates r, θ, φ, raised to the power n via r→rn, θ→nθ, φ→nφ, mapped back to Cartesian, and offset by the original point c — mirroring z→zn+c from the complex plane. A running derivative dr tracks how fast nearby points diverge, giving the safe step size DE = 0.5·log(r)·r/dr that the ray marches forward by. Escaping past the bailout radius sooner means being farther from the fractal surface; the escape-iteration count then drives the colour palette, while normals, soft shadows and ambient occlusion shade the result.
🔬 What it shows
A spiky, coral-like 3D surface built entirely from the escape-time of the iteration z→zn+c in spherical coordinates. Surface colour encodes how many iterations a point survived before crossing the bailout radius, and lighting comes from a raymarched normal, soft shadow and ambient-occlusion pass — all computed per pixel, every frame, on the GPU.
🎮 How to use
Drag the canvas to orbit the camera and scroll to zoom; both simply move the ray-origin and rotation matrix fed into the shader. Power n reshapes the fractal (n=8 is the canonical "bulb"), Max iterations trades detail for speed, Bailout sets the escape threshold, Palette recolours the escape count, and Quality scales the internal render resolution. Auto-rotate spins the view; Screenshot saves the current frame as a PNG.
💡 Did you know?
No formula produces a perfect 3D equivalent of the 2D Mandelbrot set — complex-number multiplication has no clean 3D generalisation — so the "triplex" power-n formula used here is an approximation invented by hobbyists on the Fractalforums community and only popularised in 2009, decades after Mandelbrot's original 1980 discovery.
Frequently asked questions
What is the distance estimator DE = 0.5·log(r)·r/dr, and why does raymarching need it?
Raymarching advances a ray step by step until it hits a surface, but without knowing how far away that surface is, it would need thousands of tiny, wasteful steps. The distance estimator uses the escape-time formula's radius r and its accumulated derivative dr to compute a mathematically safe upper bound on how far the ray can travel without overshooting the fractal — this simulator's shader marches forward by exactly that distance each of its up to 96 steps, which is what makes real-time frame rates possible on ordinary GPUs.
Why does changing the power n reshape the fractal so dramatically?
The power n controls how many times the angular coordinates θ and φ are multiplied (θ→nθ, φ→nφ) and how the radius is exponentiated (r→rn) on every iteration of z→zn+c. Small changes in n shift where points escape versus stay bounded, which reorganises the whole self-similar structure — n=8 gives the famous bulbous, cathedral-like form this simulation defaults to, while other values of n between 2 and 12 produce noticeably different lobe counts and surface textures.
Is there a mathematically "true" 3D version of the Mandelbrot set?
No — the 2D Mandelbrot set relies on complex-number multiplication, which has a clean geometric meaning (multiply magnitudes, add angles) that does not extend uniquely to three dimensions. The "triplex" spherical-coordinate formula this simulator implements — r→rn, θ→nθ, φ→nφ — is one popular choice among several competing 3D generalisations, valued for producing rich, organic detail rather than for being a unique mathematical extension of the original.
What do the Bailout and Max iterations controls actually do?
Bailout sets the escape radius: once a point's distance from the origin exceeds this value (checked as r² > bailout² in the shader), it is classed as having escaped and iteration stops early. Max iterations caps how many times z→zn+c is applied before giving up on convergence. Points that escape quickly sit far outside the fractal's surface; points that survive the full iteration budget are deep inside it — the boundary between those two behaviours is the fractal surface the raymarcher renders.
Why does raising Max iterations slow the frame rate but reveal finer detail?
Every raymarching step calls the distance-estimator function, and that function itself loops up to the current Max iterations value computing z→zn+c and updating the derivative dr. More iterations let the escape-time test distinguish finer and finer filigree near the fractal's boundary, but since this inner loop runs for every one of the roughly 96 marching steps per pixel, per frame, doubling the iteration budget roughly doubles the GPU work and lowers the FPS counter shown in the Stats panel.
Real-time 3D Mandelbulb raymarched on the GPU with an honest distance estimator de = 0.5·log(r)·r/dr. Slide the power n to morph the spiky shell, set iterations, swap colour palettes.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install