Visit the new site

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.

Power 8 Mandelbulb

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.

Julia berryThe Juliaberry, juicy and yet somehow quite grotesque!

 

  Last updated: 15 December 2009

31 Comments

  • bec commented at 15 December 2009 at 03:59

    thanks for putting all this together!
    the results are amazing.

  • Frank commented at 15 December 2009 at 08:01

    simply wow Tom!

  • noj commented at 15 December 2009 at 10:35

    before I die, I need to meet you. Man you inspire me to learn maths :) great work mate

  • oppenheimer commented at 15 December 2009 at 16:33

    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!

  • vade commented at 15 December 2009 at 18:46

    Nice !

  • alx commented at 15 December 2009 at 21:59

    I love the screenshots. This is amazing work. And the AO approximation effect works so well, too.

    Great work!

    a|x

  • Prack! commented at 23 December 2009 at 11:21

    great and amazing job! thanx for sharing! ;-))

  • Rich commented at 23 December 2009 at 16:44

    Your script and the results achieved are amazing! Congrats on this fantastic work and I hope you continue developing it!

    -Rich

  • Silicon Soul commented at 10 January 2010 at 04:58

    Spectacular!

  • Steve commented at 20 January 2010 at 18:58

    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.

  • Jonathan Wolfe commented at 28 January 2010 at 19:41

    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!!!

  • Tom commented at 28 January 2010 at 22:22

    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.

  • wax78 commented at 16 February 2010 at 15:31

    "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).

  • clement commented at 21 February 2010 at 10:39

    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 !

  • e-berlin commented at 5 March 2010 at 13:37

    man, this is awesome! keep up the good work and continue creating miracles.

    greets,
    the whole amazed e-berlin team

  • tienda de scalextric commented at 13 April 2010 at 21:55

    Really amazing! congratulations

  • Alex commented at 20 April 2010 at 22:00

    Hi, this is really inspiring and amazing the way you do it. I have been using the Simple Attractor Renderer to do some Stop Motion animations while changing the Formulas, But the 3d and 4d ones you have done are much better. How do you do that? Congratulations

  • oppenheimer commented at 7 May 2010 at 18:54

    hi there!
    i did some mandelbulb animations which i like to share with you:

    http://www.vimeo.com/11548449
    http://www.vimeo.com/11103473

    best regards
    oppenheimer

  • Mr Towe commented at 12 May 2010 at 16:40

    That's fantastic! Never saw something like this in my life! I'm looking carefully to each detail and find it unique! More than well done :)

  • Janice Bulter commented at 18 May 2010 at 05:25

    It's Amazing. Another great work of art. Thanks for sharing!

  • Jarrod commented at 29 May 2010 at 16:27

    Awesome pics. That is amazing. I can't wait to see where we are with 3-D in a few years from now. I remember watching Jaws in 3-D way back in the day. I always wondered why this technology got abandoned. I was very impressed as a kid watching Jaws leaping out of the screen at me.

  • kimya commented at 4 June 2010 at 23:59

    Really amazing. Congrats on this fantastic work and I hope you continue developing it!

  • Essay commented at 22 June 2010 at 13:24

    Its incredible. A fine work of art. The 3d looks amazing. It has a fine details. I love it.

  • socboo commented at 26 July 2010 at 02:41

    That's amazing. I didn't know you could do that with fractals. Turn it into an oil painting and you could hang it in a museum-it's that good.

  • simulation assurance aut commented at 28 July 2010 at 03:38

    Hi there!
    The blog is absolutely fantastic. Lots of great information and inspiration, both of which we all need. Thanks.

  • Joe Art commented at 29 July 2010 at 05:41

    Amazing pieces of art! Thanks for sharing

  • harvey commented at 2 August 2010 at 11:53

    Wow, I stumbledupon this page. I'm not sure I really understand, but I must say that the fractals are some of the coolest pictures that i've seen! Thanks Tom.

  • Übersetzungen commented at 21 September 2010 at 18:49

    I still remember when about 20-25 years ago, I programmed my first fractals, with Turbo Pascal 7. What a great programming language it was and the fractals were really something. It was also quite easy to modify formulas by being creative and getting whole new classes of great shapes. And there was great book, by James Gleick: Chaos, which by the way also wrote a great biography of Feynman. Anyhow, images look really great. And I wonder if one can find something similar in nature, on coral reefs.

  • Sub Vet commented at 12 November 2010 at 03:49

    I am just starting to really explore your site. You have combined mathematics and artist ability to a wonderful flower for the eye.

  • Holländisch Übersetzer commented at 1 January 2011 at 14:53

    Hi there from germany. I don't get any of the fractual calculations, but the pictures and shapes are beautiful. Looks like nature fotography rather than the result of calculations. I love scuba diving and photography and the shape of this mandelbrot is very similar to some corals on the reef. Amazing! Also the other pictures are beautiful. Thanks for sharing them.

  • zhului commented at 31 May 2011 at 08:49

    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 640-553 test rendering animations in UltraFractal too, so I really love the speed of your implementation!) I'd like to see 350-018 test 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 CISSP test hires fractal videos for planetariums, but for that output I need a sequence of images, not a movie. Thanks!!!