• 1/1

Mandel-Maya Madness!

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.

 

 

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

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)
 

27 Comments

landr

Posted 5 August 2011 9:41 pm

wow this is beautiful, is there a chance general public will have access to the ability to do this in 3d any time soon.

landr

Duncan Brinsmead

Posted 5 August 2011 10:12 pm

Adding a mandelbulb/box texture to maya fluids along with attributes would add complexity and would not be of much general use. Having the ability to plug-in to the fluid internal texturing through the api would be much better, and a more likely route for inclusion of this in Maya, but is somewhat problematic, so I don't expect it to happen anytime soon.

yogeshsherman

Posted 6 August 2011 2:21 am

Benoît Mandelbrot must be smiling after watching it

Duncan Brinsmead

Posted 6 August 2011 3:56 am

I once did a short animation for Siggraph (about 25 years ago) and got a letter from Mandelbrot himself asking for a copy.... it was thrilling for me to get a letter from him. (even though he probably did it for everything that had fractal in the title)

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

Your the man Duncan. Very cool!

effectzero

Posted 6 August 2011 9:02 pm

Duncan, I agree that just having access to the mandelbulb and box within maya would be very limiting and really you would need access to plug in other variations. Unless I'm mistaken, SoftImage has a way of rendering arbitrary functions within their voxel system? Is there something in their voxel foundation that makes this less complicated than in Maya's fluids? For what its worth I would imagine that having this functionality would have a lot of benefits down the road as more and more cool and interesting algorithms are discovered not to mention there are a few projects today that I could use this awesome visual complexity and motion for!!

Zeeshan Anjum

Posted 6 August 2011 10:28 pm

no comments ! Mr.Duncan. its awesome !

cole McCartney

Posted 8 August 2011 9:17 am

Exciting !

vizije

Posted 8 August 2011 3:11 pm

Duncan, You surely are man from the future. Even blog date is from future!

Michel_Men

Posted 12 August 2011 3:28 pm

Faszinating Things, i have never seen this in 3D, amazing.


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

this is great! its so wonderful that ya share the scene files and knowledge.. and its exciting to know that we may be getting a new fluid shader for maya!!! been waiting tooo long for new fluid shader! maybe we will get this shader withthe maya2012 subscription advantage pack!?!?

RedCobra

Posted 19 August 2011 11:41 pm

wow....im speechles!!!

LoveFest

Posted 21 August 2011 7:18 am

wow, wow, wow! I want to do this!

ntashev

Posted 26 August 2011 4:24 pm

Quite interseting stuff Duncan... I was just thinking - you can manipulate a lot of attributes for fluids with SOuP (http://www.soup-dev.com/index.html), I already have a set up which injects color and density based on the voxel position. The only problem is that my math skills are far from enough so I can't integrate the fractal equations into the system...
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

You could set the voxel values for color and density, but really this might be too blurry to look very interesting and would require fluid resolutions in the 300 range, which currently bump up against memory limits. The technique I used implements the function as a texture... the fluid didn't use any grids but was simply a volume rendering tool. You can find math for this stuff on fractalforums.com.

Omegaroth

Posted 1 September 2011 12:33 pm

P.S. I would really like to begin learning how to script nParticles and fluids. I know the basics of Mel, but after a certain point I figured one must be taught to script rather than rely on self teaching. If you know of any books or tutorials on this subject matter I would love to know where I can buy them. Thank you!

v12

Posted 20 January 2012 5:56 am

Hello, good morning!
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

Hi Duncan - I just installed Maya 2013 and I really wanted to thank you for including the fluid texture in this build. It's little things like this that I feel sets Maya apart.

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

Hey Duncan,

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

Hate to be a complete (maya) newb, but I am wondering can the 3D fluid versions be animated as well as the 2D?

gmckneally

Posted 26 February 2013 9:56 pm

Hi Duncan - thank you so much for all your amazing contributions and especially for this one. i'm very excited about the possibilities of where this could go....

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

You can override any fluid texturing or shading attributes per particle. To do so create particle attributes userScalar1PP, userScalar2PP,etc (or userVector1,2..) then set these in a particle expression. You can then plug the corresponding attribute on the particleSamplerInfo node into the desired fluid attribute, for example:
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

wow! quite a few ideas to explore there! thanks so much for your feedback. i *think* i understand what you are talking about, but it might take me a little while to work it out inside maya, frankly.
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

Just to clarify.. applying the radius to scale was the first suggestion, the first paragraph explains how to pass any particle attributes to the shader, radiusPP being one of those attributes. You create one of those generically named user attributes and set them inside an expression, then use the matching attribute on the particleSamplerInfo.

ptunstall1988

Posted 2 May 2013 2:41 pm

Hey! Quick question on how the 3d Mandelbulb textures works in Maya 2013/2014. Is there a way to keyframe the "phase" of the texture over time? We are hoping to get a more animated look.

doctorspook

Posted 16 March 2014 7:44 pm

hi Duncan,

now that Maya 2013/2014 support the 3D Mandelbulb... could you graciously upload your 3d Scene files?

---re " (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)"

many thanks! ps LOVE Fractal Fantasy!!! I started making psychedelic 3D graphics back in 1992 and know the intense labor it took to explore virtual worlds.

Boxplorer is tons of fun btw... am interested in recording some as animated clips... (recording HDMI is one way but I think there are a few screen recorders and even maybe that game recording option built into some graphics cards.

Add Your Comment

You must be logged in to post a comment.

Please only report comments that are spam or abusive.