3D Mandelbulb Ray Tracer
Published on 13 December 2009
There has been quite a stir in recent months with the discovery of the closest approach yet to generating a true 3D version of the Mandelbrot fractal, dubbed the Mandelbulb.
The search for a true 3D Mandelbrot has been sought unsuccessfully for a number of years. However, recently Daniel White, Paul Nylander and many others on FractalForums found that a slightly different approach yielded a true fractal structure in three dimensions; that is the images continue to reveal finer details the closer you look.
If you want to dive right in and give it a go then jump to the project page.
How it works
The fractal calculation follows a similar process as a normal Mandelbrot set using the same formula,
w' = wn + c, but instead of using standard complex numbers w and c are hyper-complex 'triplex' numbers with three components corresponding to the Cartesian x, y, and z co-ordinates.
The triplex number w is raised to a power n using the following terms:
w = {x, y, z}n = rn { sin(θn) cos(φn), sin(θn) sin(φn), cos(θn) }
where:
r = sqrt( x2 + y2 + z2 )
θ = atan2( sqrt( x2 + y2 ), z )
φ = atan2( y, x )
The fractal is ray traced using basically the same process as the 4D Quarternion Julia set fractal; for each pixel a ray is stepped into the scene by a small amount. The x, y and z co-ordinates of the ray at this point provide the input triplex number for the fractal equation, which is then iterated until the magnitude of the triplex number exceeds a bailout value (usually 4.0), or the maximum iteration count is reached.
At the end of the iteration loop a distance estimation function is used to calculate the closest point in any direction to the fractal surface. It is defined as:
distance estimation = 0.5 * |w| * log(|w|) / |δw|
where |w| is the magnitude of the triplex number w and δw is the derivative.
The distance estimation value is crucial to the ray tracing process. It tells us the maximum step distance the ray can move before we need to recalculate the fractal at the new location, which is far more efficient than a fixed step ray marching approach.
When the distance estimation value drops below a defined threshold, epsilon, we are within intersection distance of the approximate fractal surface. If this happens we calculate the vector normal based on the fractal surface gradient, which defines the shading of that point.
Download and usage details
Head over to the project page to download the scripts and learn what each of the parameters can do.
The Juliaberry, juicy and yet somehow quite grotesque!
Last updated: 15 December 2009
15 Comments
Links & further reading
- Mandelbulb ray tracer download
- The original forum discussion
- The unravelling of the Real 3D Mandelbulb
Related posts
- 4D Quaternion Julia Set Ray Tracer
- This GPU shader renders real-time Quaternion Julia set fractals with ambient occlusion.
- Artforms of Nature
- A fractal twist to the ever inspiring illustrations from the nineteenth century German biologist Ernst Haeckel.
- Fractal Explorer Pixel Bender Plugin
- Two filters for Pixel Bender for generating a wide variety of fractals. A key feature enables images to be mapped into fractal space.
- Fractals and generative art resources
- An overview with links of my talk at the Apple Store in Glasgow.
- More blog posts









thanks for putting all this together!
the results are amazing.
simply wow Tom!
before I die, I need to meet you. Man you inspire me to learn maths :) great work mate
I followed the discussion over at fractalforums for quite a while and i am very impressed that you made a plugin out of it. really good work!
Nice !
I love the screenshots. This is amazing work. And the AO approximation effect works so well, too.
Great work!
a|x
great and amazing job! thanx for sharing! ;-))
Your script and the results achieved are amazing! Congrats on this fantastic work and I hope you continue developing it!
-Rich
Spectacular!
I'm sitting here with my jaw on the desk.. this is the holy grail, I've wanted to play with fractals in 3D since the days of Fractint for DOS.
I've just played with this a bit in pixel bender, and I must be missing something- is it possible to render these out at a larger scale? I just got a computer with a GPU a month ago, I just bought Adobe CS, and this is the first time I've even loaded up Pixel Blender, so I'm entirely clueless. But I am SO digging what I'm seeing so far,
Now, if you can figure out a way to export these things in a 3D mesh... then I can die a happy man.
Hi Tom - I LOVE your work, and really appreciate you sharing your GPU-driven rendering of the Mandelbulb. I'm totally hooked. (I'm glacially rendering animations in UltraFractal too, so I really love the speed of your implementation!) I'd like to see if Quartz Composer can help me animate, but before I download the ~1GB Xcode to play with it, I'm wondering if there's a way to have it export the frames of an animation instead of just a .mov file? Any idea? I render hires fractal videos for planetariums, but for that output I need a sequence of images, not a movie. Thanks!!!
Steve: you can specify the output size, be careful though as it is possible to lock up your GPU if you push it too high, especially with anti-aliasing! Unfortunately it isn't possible to generate a 3D mesh from this implementation of the Mandebulb fractal. A completely different approach to render the shape using something like voxels would be required instead.
Jonathan: The best way to render out QuartzComposer patches is to use this little 3rd party app: Quartz Crystal http://kineme.net/product/QuartzCrystal It has quite a few export options as well as supporting image sequences instead of movies.
"be careful though as it is possible to lock up your GPU if you push it too high, especially with anti-aliasing"
Having same issue when using too 'expensive' shaders. The only solution i've found for now is not to draw a quad on the entire screen but i divide the huge square in little ones and i compute 1 little square by draw loop. It's of course more slow, but the GPU won't lock anymore you use use enough subdivision. (dunno if u understand my bad explanation). (I do it under JOGL not quartz).
Simply the most impressive 3d fractals i've seen.
I don't know if you're into that type of designs,
but would be awesome melted with H.r giger's Aliens designs
Anyway its alrealdy beautiful on its own.
Congrats !
You should really send artworks for the Alien 0 movie they're preparing. Not kidding.
Keep it up, see you !
man, this is awesome! keep up the good work and continue creating miracles.
greets,
the whole amazed e-berlin team