Posted by Duncan Brinsmead, 6 August 2011 12:00 pm
3D Julia set with pickover stalks rendered with a custom Maya fluid render
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.
I also implemented a 3d form of the Mandebrot set called a mandelbulb.

As well I implemented a very different form dubbed the mandelbox.
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).
.jpg)
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= zu2+zv2
I use:
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:



I found that a modified Pickover stalks method could create interesting effects with Julia sets, creating twisty, almost 3D rope effects.



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.
http://en.wikipedia.org/wiki/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.
The Pickover stalks method also creates interesting, hairy effects with 3d Julia sets.
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):
And the following has 5 lobes:

The MandelBox
The mandelbox uses a system of folding space that results in a complex 3D shape with very interesting structure that looks manmade, as opposed to the more organic looking mandelbulb.

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.

So I isolated this part into a separate 2d Mandelbrot which I call it the mandelfold. It has symmetry with 9 main sets where 5 are 1 lobed and 4 are 3 lobed.

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.
DOWNLOADS
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.
userdata/fckdata/200/file/mandel1.zip
userdata/fckdata/200/file/mandel2.zip
userdata/fckdata/200/file/mandel3.zip
userdata/fckdata/200/file/mandel4.zip
userdata/fckdata/200/file/mandel5.zip
userdata/fckdata/200/file/mandel6.zip
userdata/fckdata/200/file/mandel7.zip
Download Scenes
userdata/fckdata/200/file/scenes.zip
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.
26 Comments
landr
Posted 5 August 2011 9:41 pm
landr
Duncan Brinsmead
Posted 5 August 2011 10:12 pm
yogeshsherman
Posted 6 August 2011 2:21 am
Duncan Brinsmead
Posted 6 August 2011 3:56 am
Naqoyqatsi
Posted 6 August 2011 8:47 am
mandelbulb looks very nice, i hope for a integration in maya.
phoppes
Posted 6 August 2011 11:50 am
effectzero
Posted 6 August 2011 9:02 pm
Zeeshan Anjum
Posted 6 August 2011 10:28 pm
cole McCartney
Posted 8 August 2011 9:17 am
vizije
Posted 8 August 2011 3:11 pm
Michel_Men
Posted 12 August 2011 3:28 pm
Duncan, i have missed you so much the last year in your Blog. Thoughts your leaving AD and more...
Good to see you back.
Im a great Fan (+ Vids) from Germany, since you start witch the Fluids in Maya 4.5....
3dtrialpractice
Posted 17 August 2011 9:38 pm
RedCobra
Posted 19 August 2011 11:41 pm
LoveFest
Posted 21 August 2011 7:18 am
ntashev
Posted 26 August 2011 4:24 pm
The only thing left is the maths for calclulating density and color based on voxel position, which can be integrated really fast into the set up.
I can share the scene if someone is interested to give it a go... or be very thankful if can give some example for the maths.
Duncan Brinsmead
Posted 26 August 2011 6:37 pm
Omegaroth
Posted 1 September 2011 12:33 pm
v12
Posted 20 January 2012 5:56 am
My name is Alex Aurelio and I wrote on the blog today.
3 months ago maya met, I was fascinated to want sensational learning program is to develop projects in maya is generally in the area of civil engineering, but no school where I live so I can learn maya. I am writing for the blog with ituito to get help. If you know me and want to send handouts or links where you can find tutorials or book so I can study the Maya I thank you. My email is: lecao.porto @ gmail.com
Thank you.
sacslacker
Posted 13 April 2012 12:15 pm
When I originally saw this post, I immediately wanted to do this with a fluid render. There are certainly some cool fractal programs out there but they aren't Maya. Mandelbrot fluid texture was the first feature I wanted to try when 2013 was announced. Sometimes you just need something to tinker with for inspiration and this definitely fits the bill for me.
max1020
Posted 24 April 2012 2:41 pm
Many, many thanks for this. I've been playing with the mandelbrot in Maya 2013 and I cannot tell how amazing it is. I have been waiting for something like this for years.
Ciao,
mak knighton
skeewhiff
Posted 23 June 2012 7:41 am
gmckneally
Posted 26 February 2013 9:56 pm
i've been playing around with this for a while and i've managed to get some good results (albeit a bit like a borg cube about to explode...) the animateable parameters are fantastic - like bridges building across fractal impossibilities. i love it, and i'm interested pushing this whole idea further.
- specifically i'm trying to map the mandelbox detail and structure onto non-cube geometry. do you think this is possible in the current implementation?
ideally one could use nParticles/nDynamics to define (and control) a volume of particles which we could then shade using a mandelbox-like fluid shader. hopefully this would consider the volume and take into account the edges of the non-cube shape, providing mandelbox-like edge detail at the borders of the surface.
at the moment my tests are ending up with loads of little mini-mandelboxes (one for each particle). which is cool, but not exactly what i'm aiming for.
maybe this is all a couple years away, but i reckon there must be a way through, and i would be very interested in seeing what you think.
all the best. and thanks again for your continued invention and inspiration!
g
ps. i'm also excited about getting this whole mandelbrot thing working in mental ray. i'm suspect master zap could be convinced now that he is on board at AD? what do you reckon?
Duncan Brinsmead
Posted 26 February 2013 11:03 pm
connectAttr particleSamplerInfo1.userVector1PP npThickCloudFluid.textureRotate;
You might apply the particle radius to the texture Scale and the particle start position to the texture offset such that the particles initially form one large continuous mandelbox... they can then move around, rotate change size, etc and carry the texture with them. As well you could have per particle attributes that control things like box radius.
Note that when you setup a fluid shader per particle by starting with a thickCloud particle preset the color transparency and incandescence are all connected from the sampler info. It might work best to start with this then set the fluid's mandelbrot texture attributes by hand(rather than clicking on a preset) as other elements of the preset like fluid size and shading quality will not be overridden.
Another possibility is to use a mandelbrot texture map( which has the same mandelbox code as the fluid ) applied to color+displacement+alpha etc of the object shader.
Another trick is to use a fluidShape as a surface shader on on your meshes. Unfortunately the setup for this is a little harder than before... you need to manually connect your fluid outColor the the surfaceMaterial attribute of your shading group. (the UI now treats the fluid shader as strictly a volume material) When applied as a surface material it does a little raytrace into the fluid starting at the ray hit point at the surface and continuing in the same direction a fixed distance. The fluid attribute surfaceShaderDepth, which you can find in the channel box at the bottom., controls the depth the ray continues into the fluid. This is pretty hacky, in that one would ideally wish this distance be the distance to the next surface intersection with the ray instead of constant. However you could map the surfaceShaderDepth or set with utility nodes like facing ratio. A separate problem is that the shadow feelers are not clipped by the object shape but travel through the entire fluid, so the outside of the mesh may cut through a region that is fully inside the density an in shadow. Still you might find it a useful technique.
Mental Ray would definitely be nice, but it might take a lot of user demand to make it happen. (The Mandelbrot feature is a bit marginal in terms of our primary markets) Still if folks like you use it for cool animations, then interest in having it in MR will grow.
gmckneally
Posted 27 February 2013 1:14 am
it seems to me that your second suggestion of applying the particle radius to the texture Scale and the particle start position to the texture offset is a good way to begin.
i've got a couple of days off before my next job, so i'll let you know how i get on with trying to implement these suggestions. its possible that i'll have a few questions along the way that might be a bit less interesting for blog readers so maybe email is best? (although maybe not?.. we could also keep this whole discussion live, which is also cool with me.)
whatever you reckon, my email is gmckneally@gmail.com
thanks again,
g
Duncan Brinsmead
Posted 27 February 2013 1:53 am
ptunstall1988
Posted 2 May 2013 2:41 pm
Add Your Comment
You must be logged in to post a comment. Login or Register here