Be a Match, Save a Life

3D Mandelbulb Ray Tracer

Mandelbulbs are a new class of 3D Mandelbrot fractals. Unlike many other 3D fractals the Mandelbulb continues to reveal finer details the closer you look.

This implementation was written as a Pixel Bender filter then ported over to QuartzComposer as a GLSL patch to enable animation. The scripts run on the GPU which makes real-time interactive exploration possible. For more information behind the discovery of the Mandelbulb see the accompanying blog post.

Power 8 Mandelbulb

inverse6 The Crown Juliaberry Juliaberry detail Fuzz2 spikey passage

More images in the gallery and on Flickr.

Animation

Animations can be created in Adobe After Effects using the .pbk files, but it will be very slow to render as the calculations have to be performed on the CPU rather than the GPU. The following videos were created using the QuartzComposer patch and took 15-20 minutes to render at 720x576 for about 720 frames. If only After Effects would support GPU rendering too...

Download and installation

Download the 3D Mandelbulb Ray Tracer

Note: there are two versions of each filter, the quick and and the normal. The quick version might run about twice as fast but doesn't handle negative powers or phase options.

For Pixel Bender open the Mandelbulb.pbk file with the Adobe Pixel Bender Toolkit or copy it into the Pixel Bender Files folder in your Photoshop CS4 installation directory (you will need to have installed the PB plugin for Photoshop first).

After Effects CS4 users should copy the filter into a Pixel Bender folder within the Plug-ins/Effects directory.

The Quartz Composer patch was created with Quartz Composer 4 (QC4), which is part of XCode. It will also work with QC3 as the patch is just a GLSL shader. It runs at about 15fps @ 640x480 on my iMac that has an NVIDIA GeForce 8800GS graphics card.

How to use

There are quite a few controls to play around with that will need some explaining:

Defining the fractal

Power 16 Mandelbulbpower: the power n used in the fractal equation. The default is 8 as it gives an aesthetically pleasing result.
maxIterations: higher values will reveal more detail when close to the fractal surface but increases calculation time.
bailout: the 'escape' threshold for the fractal iteration. A lower value tends to give rounder simplified surfaces.
bounding: the radius of a bounding sphere around the fractal that is used to speed up the ray tracing. This should be increased for negative powers.
epsilon scale: increases the number of steps in the ray tracing process and will help bring out fine details, especially when using the radiolaria option.
Radiolariaphase: change the θ and φ phases. Doesn't work when using the 'quick formula' option.
radiolaria: when enabled this option constrains the y component of the triplex number resulting in interesting spiky structures. It often works best with a low maxIteration value and might require fine tuning of the bailout and epsilon scale parameters.
step limit: is the maximum number of steps a ray can take before aborting. Increase this value to see far side details of hollow structures like the Julia variations.
Julia: activates the Julia-set equivalent where the value is c is user defined and fixed throughout the entire calculation, rather than depending on position in space.

Navigation

camera position: defines the x, y, z co-ordinates of the eye in 3D space. The fine tune parameters let you easily refine the position especially when close to the fractal surface. Tweak the y component to zoom in by default.
camera rotation: change the rotation of the camera on each axis.
camera zoom: magnifies the current view. Note, to reveal more details on the surface the camera position has to be moved, you can't just zoom in.
rotation: rotate the fractal itself. This in combination with the camera.y component is the most used parameter when exploring the Mandelbulb.

Shading and output

Shading modessize: the output image size. Set this low when exploring the fractal for responsive rendering and then only increase for high resolution output.
antialiasing: enables 4x or 9x super sampling per pixel (the aa value squared). Only enable after the final output size is set.
phong: enables phong shading with specular highlights.
ambient occlusion: simulates the darkening of the more occluded areas of the surface. The minimum distance from the origin of the triplex number during the calculation is recorded and used to proportionally darken the surface.
ambient occlusion emphasis: darkens the surface proportionally to the number of steps taken to reach the fractal intersection. It can help emphasise surface details to make the object look more physically real.
colors: are defined by three controls for red, green and blue components.
color spread: shifts the colour based on the normal.
light: sets the x, y and z co-ordinates of the light in the scene.
rim light: enables specular shading for the areas pointing away from the light source. It simulates a rim light effect.
shadows: when set greater than 0.0 a ray is fired from the fractal intersection point towards the light source to determine whether the point is in shadow.
specular exponent: higher values give a high-gloss effect whereas low values give a satin like sheen.
specularity: the amount of highlight. Set to 0.0 for a matt surface.