# 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'* = *w*^{n} + *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}* = r

*{ sin(θ*

^{n}*n*) cos(φ

*n*), sin(θ

*n*) sin(φ

*n*), cos(θ

*n*) }

where:

r = sqrt( x^{2} + y^{2} + z^{2} )

θ = atan2( sqrt( x^{2} + y^{2 }), 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

## 31 Comments

Older: 4D Quaternion Julia Set Ray Tracer Newer: The Formula

### Links & further reading

- Mandelbulb ray tracer download
- The original forum discussion
- The unravelling of the Real 3D Mandelbulb

### Related posts

- Introducing Frax
- The project I've been working on for the last two years...
- A Series of Snowflakes
- A selection of subverted seasonal snowflakes
- L'Eclaireur
- A series of looping animations from an installation at L'Eclaireur in Paris.
- Music Box
- A journey into a Fabergé inspired world.
- More blog posts

beccommented at 15 December 2009 at 03:59thanks for putting all this together!

the results are amazing.

Frankcommented at 15 December 2009 at 08:01simply wow Tom!

nojcommented at 15 December 2009 at 10:35before I die, I need to meet you. Man you inspire me to learn maths :) great work mate

oppenheimercommented at 15 December 2009 at 16:33I 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!

vadecommented at 15 December 2009 at 18:46Nice !

alxcommented at 15 December 2009 at 21:59I 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:21great and amazing job! thanx for sharing! ;-))

Richcommented at 23 December 2009 at 16:44Your script and the results achieved are amazing! Congrats on this fantastic work and I hope you continue developing it!

-Rich

Silicon Soulcommented at 10 January 2010 at 04:58Spectacular!

Stevecommented at 20 January 2010 at 18:58I'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 Wolfecommented at 28 January 2010 at 19:41Hi 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!!!

Tomcommented at 28 January 2010 at 22:22Steve: 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.

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

clementcommented at 21 February 2010 at 10:39Simply 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-berlincommented at 5 March 2010 at 13:37man, this is awesome! keep up the good work and continue creating miracles.

greets,

the whole amazed e-berlin team

tienda de scalextriccommented at 13 April 2010 at 21:55Really amazing! congratulations

Alexcommented at 20 April 2010 at 22:00Hi, 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

oppenheimercommented at 7 May 2010 at 18:54hi 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 Towecommented at 12 May 2010 at 16:40That'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 Bultercommented at 18 May 2010 at 05:25It's Amazing. Another great work of art. Thanks for sharing!

Jarrodcommented at 29 May 2010 at 16:27Awesome 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.

kimyacommented at 4 June 2010 at 23:59Really amazing. Congrats on this fantastic work and I hope you continue developing it!

Essaycommented at 22 June 2010 at 13:24Its incredible. A fine work of art. The 3d looks amazing. It has a fine details. I love it.

socboocommented at 26 July 2010 at 02:41That'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 autcommented at 28 July 2010 at 03:38Hi there!

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

Joe Artcommented at 29 July 2010 at 05:41Amazing pieces of art! Thanks for sharing

harveycommented at 2 August 2010 at 11:53Wow, 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.

Übersetzungencommented at 21 September 2010 at 18:49I 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 Vetcommented at 12 November 2010 at 03:49I am just starting to really explore your site. You have combined mathematics and artist ability to a wonderful flower for the eye.

Holländisch Übersetzercommented at 1 January 2011 at 14:53Hi 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.

zhuluicommented at 31 May 2011 at 08:49Hi 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!!!