Posted by Duncan Brinsmead, 6 August 2011 12:00 pm
3D Julia set with pickover stalks rendered with a custom Maya fluid render
***Note that everything shown here is now in Maya(as of 2013). For the 3D effects create a 3d fluid container, then on the fluid shape set the texture type to Mandelbrot to see all the available attributes. A good starting point would be to use a preset (in the attribute editor for the fluid) such as "mandelboxColor". Also there are now 2d and 3d mandelbrot textures in Maya that also have mandelbox attributes and controls for things like stalks.
Emergence is a fascinating phenomenon where complexity can emerge through iteration of simple rules or processes. One of the most dramatic illustrations of emergence is the Mandelbrot set where seemingly endless structure and detail arise when iterating on a very simple equation:
zn+1 = zn2 + c
I had a little fun and implemented a Mandelbrot texture totally inside a MEL expression. This allows one to easily play with it and potentially render it in a variety of fashions. The speed is much slower than if it were instead a plugin texture written in C, but for my purposes it was fast enough.
These could not be done as simple MEL scripts, however. I created an alternate internal texture on the fluid node for these, as they are best done as volume renders. Unfortunately this code is in my own build of Maya so for the mandelbulb and box I can only share pictures. However the following software is great for exploring the mandelbox: www.ms.mff.cuni.cz/~kadlj3am/big/boxplorer/
Also check out www.fractalforums.com which is full of great info on generating these structures.
2D Mandelbrot sets using a Mel expression
To see the basic Mandelbrot script in action load the scene mandelbrotDemo.ma (download scenes at bottom of this post).
One can track and zoom the camera to look at different parts of the fractal and do a full render when you have a view you like. To edit the colors look at the texture ramp1. The Mandelbrot expression is used to set the vCoordinate on the ramp texture( more accurately… on its placement node, which lets one repeat the ramp by increasing the vRepeat). To see the script first open the expression editor:
“Window: Animation Editors: Expression Editor”
And do “Select Filter: By Expression Name”.
Expression1 implements the Mandelbrot texture and expression2 resizes and moves the plane to fit the camera view. The Mandelbrot expression uses u and vCoord from a sampler info node to get the uv of the current point being rendered. It then scales this based on the current zoom and offset. The expression then sets the vCoord of the ramp’s place2dtexture node.
Note that texturing with a MEL expression will only work with the Maya sw renderer (and hardware ), but not Mental Ray, as Mental Ray does not evaluate MEL expressions( per frame expressions are evaluated before data is passed to mental ray, which can’t be done in the case of per pixel ones). If needed one could bake the texture to a high resolution file texture, which could then be rendered in any renderer.
To have a little fun try uncommenting the commented out lines in expression1 (remove all the “//”) then remove the line:
float $val = $i/10.0;
Then hit the “edit” button. The fractal will now show in a different form that is based on the minimum radius with the iterations. Unlike the standard form which colors based on the total number of iterations and is stepped, this method is continuous and yields nice gradations, as well as interesting almost 3d looking shapes. This technique uses the minimum radius or minZ to shade with.
I’ve included scene files for each of the images generated here (outside of the 3D ones). You can load them and check out expression1 to see the math used for each case.
An interesting variation I stumbled upon creates a leaf-like effect. Instead of using the standard escape radius:
R = abs( zu2-zv2 )
A Mandelbrot set consists of all possible Julia sets. The Julia set has 2 variables that control its shape. With the Mandelbrot set one is basically setting these variables to the uv position in the plane. If one instead sets constant values for these two variables then one can render the Julia sets. The minimum radius technique creates interesting effects with Julia sets.
Pickover stalks is another interesting technique where one uses the closest distance of the escape path to the x and y axis:
Instead of looking at the distance to the xy axis we can look at the distance to a circle which yields the following effect:
Particle system Buddhabrot
A different method of visualizing this set is the so called buddhabrot.
Open the scene buddhaBrot.ma and do a playback. The expression now generates particles instead of being used as a texture.
Escape Paths as Maya Curves
The Mandelbrot function starts with a point in the complex plane and iterates on it until it either goes beyond a certain radius( where it then goes off to infinity ), or it exceeds a max iteration count. One can track the trajectory of these points and turn them into lines. To see these load the scene MandelbrotEscapePaths.ma. Expression1 was used to generate the curves shown in this scene and is commented out to avoid regenerating curves on top of curves. (It would make more sense for this to be a script that one calls rather than an expression) You can select the individual curves to see the shape of particular escape paths. This is like the buddhabrot, but the points are connected into lines rather than being drawn as dots… I’m sure someone else has done this but I’ve not seen the escape paths represented this way before. It is reminiscent of particles trapped in a magnetic field (like particle accelerator collisions).
Mandelbulb rendered with Maya Fluids
The mandelbulb use a technique for creating the set in a polar coordinate form. This allows one to easily vary the power of the Mandelbrot function. Higher powers create more lobes and in 3D the higher power versions of the set tend to look more interesting.
Note once again that these mandelbulb renders are with my own custom maya cut(currently not available to users).
One can also do a Julia set version of the mandelbulb, which is somewhat simpler and less cluttered.
I used the same polar form to create higher power 2d versions of the set which I find are quite interesting.
Here are some images in a 3 lobed form (the standard power 2 set has 1 lobe):
Mixing the Mandelbox with the Mandelbrot set
For fun I tried combining it with the Mandelbrot set. The result in 3d was not that interesting but I noticed an intriguing 2d pattern in the cross-section.
One can vary a couple of parameters that basically affect the interaction of these different sets, which can be used to create a wide range of images.
Here is an animation created by varying the parameters.
You can find additional images at full resolution, along with all images in this entry (also in full resolution), in the zipped files below. These zips are not part of a giant zipped file, you can unpack them individually. Scene files are also available for download.
Scenefiles are included for all the 2D renders. One can look at the expressions in each scene to play with the math used or further explore those examples. (The 3D versions are not currently available because those used a custom build of Maya where the mandelbox and mandelbulb were implemented as internal fluid shader textures)
Please only report comments that are spam or abusive.