• 1/3

Waterfall using fluids and nParticles

Posted by Duncan Brinsmead, 21 June 2010 8:00 pm

Here is an example scene file showing how one can use particle emission into a fluid for a natural looking waterfall effect.

fluidParticleFalls.zip

In this case the particles simply fall under gravity and collide and bounce with objects. They emit into a fluid which has high density dissipation. The self shadowing of the fluid is important for the look of the render, and this scene also uses ambient diffusion to help provide detail in the shadowed regions. For efficiency auto resize was also enabled for the fluid. The particle system rendering was disabled by turn on "intermediate object" on the particle shape. This way the fluid handles all the water shading, and as a result it also needs to be fairly high resolution to get good detail in the flow.

Here are some general rough steps to set this up:

1. Create an nParticle emitter. Use the "balls" preset and make the emitter a volume cube shape.  Scale the emitter to fit the top of the water fall and edit the emitter speed to push the particles over the edge.

2. Select any geometry you wish to collide with the particles and do "nMesh: create passive collider".

3. Create a 3d fluid container. Turn on auto resize on the fluid, as well as self shadowing. Because this is an auto resize fluid the resolution is a result of the scale of the fluid relative to the particle system, so one can get higher resolution by simply scaling down the fluid.

4. Select the fluid and the particle system and do fluid:emitFromObject. Make the fluid emitter type "omni" (this does not affect emission with particle emitters, but it ungreys the maxDistance attribute) then set the maxDistance attribute to your desired particle size. (this will be better if it is larger than the size of a voxel in your fluid) 

5. On the emitter enable motion streak and make the speed method "replace" . Make "inherit velocity" around 1 or 2. This causes the particles to also push on the fluid as they fall through it.

6. On the fluid make density dissipation around 1.0. The dissipation is pretty critical to the overall effect. You may also wish to have the density buoyancy negative. Turning on high detail solve will help to preserve detail in the flow.

7.  Make the fluid auto resize threshold 0.0. You can later experiment with raising it slightly to keep the fluid bounds tighter, but be careful because if it is higher than the particle density emission per step it can cause artifacts in the flow.

8. For good shading make the transparency of the fluid very low and adjust ambient brightness to taste (note that ambient diffusion requires mental ray, it is not supported in the maya software renderer) Also ambient diffusion did not render properly with auto resize in the 2011 gold release( check for future hot fixes that may fix this issue ).

Note that care should be taken to limit the range of the particles to avoid making the fluid grow too large. One can either kill stray particles, limit their lifespan or bound them with collisions.

 

 

42 Comments

sacslacker

Posted 23 June 2010 1:22 am

Thanks for this Duncan! After seeing the example I had hoped you'd detail how this was done. Very nice example. I love the improvements to nParticles and fluids!

belgant

Posted 23 June 2010 2:48 am

wow thank again, for usefull scene...
hai duncan, we are interesting for script making explotion that u made....i dont know, u can share us or no!!...
and i can see that u make some explotion for particlebomber scene...
hoply u can share us for that script....thank.s ..

Max Balboa

Posted 23 June 2010 6:15 am

Looking under the hood, that's wow.. amazing. Great technique.

Although I was convinced that it looked like a waterfall in the the image. But when I watched the video, I have to be honest, the beginning looked more like a big pile sand, dust, gravel and debris falling altogether. Although the latter parts of the video looked like a waterfall eventually. I think this will for both.

RROCHS

Posted 23 June 2010 1:39 pm

I have been amazed by the things I have been able to pull off thanks to NParticles and NCloth. I am alway grateful for the experiments and discoveries. Thanks you...

SantiDarkG

Posted 23 June 2010 6:07 pm

this is great Duncan. You are my "guru" using particles in Maya.

palesdream

Posted 5 July 2010 11:28 am

brilliant

Duncan Brinsmead

Posted 20 July 2010 9:49 pm

If you simply want to recreate your exact molecular motion as animation in Maya I would suggest converting your data to the Maya particle nCache format (this is an iff format that we publish). I would only use the curves if you had simple flow data and wanted to add more particles. Instead of curves you could also potentially set the velocity grid on a fluid node(which would only have a static velocity grid) then use it as a force on particles( with conserve = 0 on the particles to exactly follow the fluid flow).

CBKR

Posted 21 July 2010 12:59 am

Thanks for responding. I would like to try what your suggesting. Unfortunately I am somewhat of a novice with MAYAs more complicated procedures...

How would I go about converting my data into iFF format? IS there a pluggin or script of somesort? And can this then be directly attached to a particle?


Duncan Brinsmead

Posted 21 July 2010 1:15 am

Unfortunately I don't know of any scripts you could tweek to do what you want. You would need to read up on our cache format( use the nCache, not the old style particle cache) and then write some code to convert your data into a cache file. (this is the hard part) Then you would simply load the cache to a particle system in Maya.

Another way might be to create a bunch of ascii files with your particle positions in them... then create an expression (not a particle one) that each frame reads the file for the current frame then sets the positions of your particles(looping over all the particles). If this was slow, you could then create a particle cache and use that instead of doing the MEL read.

CBKR

Posted 22 July 2010 2:31 pm

Thank you, I will follow up with your suggestions.

sacslacker

Posted 27 July 2010 6:25 am

Hi Duncan - I know this probably isn't the best place to post this so forgive the intrusion. I watched a video of your Mandelbrot presentation and it was fantastic. So much so that it inspired me to try my hand at it. I seem to be doing ok but when I venture into attempting fluid versions, I fail miserably. Do you plan on sharing that code or is that a personal research project? I'm particularly interested in the Mandelbox/Mandelbulb stuff but I'm totally lost on how to get this represented in a fluid sim. You're examples were extremely inspiring!

Duncan Brinsmead

Posted 27 July 2010 5:03 pm

The fluid rendered mandelbox was done by internally changing the fluid texturing code and recompiling Maya. Users can't do it unfortunately. I toyed with the idea of putting it into Maya but it would add a lot of attribute clutter than would rarely be useful to anyone. A better thing would be to provide api for overriding the fluid internal texture, but this is also a bit problematic because it would also have to have a mental ray component.

I would suggest you explore this site:
http://www.fractalforums.com/

You will find lots of discussion about the Mandelbox including code and posts by the fellow who created it. As well there is info on what software to use and how to use it.

If you really want to use Maya I think it would involve writing a volume rendering shader in Mental Ray, which would be a chore. (although perhaps there is something available for mental ray already out there) Maya of course would provide more flexibility with things like animation and light setup than specialized fractal programs.

Duncan Brinsmead

Posted 27 July 2010 5:31 pm

Your post made me look around and I found this:

http://www.ms.mff.cuni.cz/~kadlj3am/big/boxplorer/

Jan Kadlec has graciously made this realtime GPU Mandelbox program available to all, source code included!

sacslacker

Posted 29 July 2010 9:54 pm

Thanks Duncan! I really appreciate your responses. I've been hanging out in the fractalforums and it's very interesting. Even though I can't do this inside of Maya Fluids (yet), you've really inspired me to look into this more. Much appreciated.

I would definitely like to use Maya for this because there so much opportunity for unique FX based on this technique. Great stuff!

dyei nightmare

Posted 12 August 2010 7:23 am

hi duncan this is great stuff, and could be great if you explain, or you give some hints on how to do this kind of
stuff maya 2011 special features:

vimeo.com/12466787

it looks really amazing... mainly those cubic structures with random patterns.... fractals and such... i didnt know that maya was able to do things like that... how did you that???

Duncan Brinsmead

Posted 12 August 2010 7:27 pm

I intend to create a blog post on the 2D stuff I showed, which used a mel expression to create a mandelbrot texture. The 3d stuff was done by coding a custom texture for a Maya fluid node, which is not possible for users. However there is an excellent program for exploring the 3D mandelbox interactively here(source included):
www.ms.mff.cuni.cz/~kadlj3am/big/boxplorer/

Also www.fractalforums.com has lots of info on generating these structures.

Duncan Brinsmead

Posted 8 September 2010 4:19 pm

I'm not sure what you are asking... one can set fluid voxel values directly in a plugin, expression or script, so the technique in this post could be implemented that way( if you don't have maya 2011 ), however you might find it to be a bit of coding to do the smooth particle emission into a fluid with radius and motion streaks.

Duncan Brinsmead

Posted 8 September 2010 4:40 pm

Jalo... I just entered bug 367628 for the issue you describe (pond as field no longer works). If you just want to mesh the pond you could do convert:fluid to poly(with history on). That could also be used as a softbody target if you still need to use soft bodies.

Duncan Brinsmead

Posted 10 September 2010 6:48 pm

I studied as a french horn player but I don't play horn anymore. Instead I like to read classical scores on the piano for fun. I have a pretty large collection of piano music( most of the classical repertoire ), however just last night I downloaded an iPad app that has preloaded pretty much everything written for piano( before about 1920), including concertos and such... something like 3000 scores. Amazing! The app was 10 dollars, but if you bought that much music in books it would be over 60,000 dollars. The visual quality is no as nice as a printed score and the ipad screen is a bit small( complex stuff by Scriabin can be an eye strain ), but it is compact and nicely indexed. Interesting times we live in.

Duncan Brinsmead

Posted 13 September 2010 9:44 pm

Here is some more info on that app:
http://dailyator.com/new-ipad-app-is-perfect-for-piano-enthusiasts/52810/

1) some favorite of piano work composers?
It is really hard to single out favorites, because I'm constantly becoming enthralled with different composers and works( the piano has such a wonderful repertoire ). A lot of the best stuff I get over exposed to, so I like to play things I'm less familiar with.

Bach (although he didn't compose for the piano exactly). I would rank him as the greatest composer of all time if I had to, but it is apples and oranges, really. He is the one composer that I never tire of. The Well Tempered Clavier is great, the Goldberg Variations. I really enjoy listening to the grand organ works he did, and I have some transcriptions for piano, but while fun to play don't really have the same effect as on a large organ.

I've been playing some Handel lately, and really enjoying it. I think one of his suites was inspiration for the Goldberg variations, and I find the simplicity of Handel helps me better understands the musical forms that Bach was building upon. His music is not as complex or deep as Bach's but is fun and easy to play.

Beethovens Sonatas are magnificent... surely the finest written. Being an orchestral player I especially like to play transcriptions of Symphonies and concertos. Liszt transcribed( in his style ) all the Beethoven symphonies, and these are fun and challenging to play. I also have some other transcriptions of the 3d, 5th and 9th that are simpler that I sometimes enjoy playing. That iPad app has all his string quartets transcribed for piano, which is the first time I've seen this. It is like discovering a bunch of new Sonatas.

Brahms is also one of my favorites. I have a transcription of his Symphonies I really like to play. As well his more intimate works as well as his sonatas are some of my favorites. I also love his two piano concertos.

Rachmaninoff wrote a lot of great stuff for piano. I find his work not all up to a high standard but his best works are brilliant. I prefer much of his earlier work, and my favorite is likely his 2nd concerto.

I especially love the later symphonies and piano concertos of Mozart.

I suppose I need to cut this list short, as otherwise I will go on for pages and pages.

2) and to return a little bit on 3D stuff, days ago I have the question, if possible share a one mesh solver(convert:nParticles_to_Polygons) for two diferent nParticles, in order to mix it and be independent, but if they approach close the same mesh solver work like metaballs and integrate the two nParticles. (kinda makes RealFlow, particles of different emitters using a single solver mesh.)

There is no direct way to do this, however there are workarounds. The simplest is to simulate within a single particles system, and use per particle attributes and multiple emitters to differentiate the particles. (you can assign as many emitters to a single particles system as desired using the dynamic relationship editor). Another potential workaround is to combine two systems into a single one(there would be 3 particles systems in the scene). One could use emission to combine the systems, although it might be fussy setting everything up efficiently.

Duncan Brinsmead

Posted 21 September 2010 5:15 pm

Try typing "ls -sl" to confirm you have two sets of 5 edges selected. Perhaps you have overlapping geometry resulting in too many edges.

Duncan Brinsmead

Posted 21 September 2010 7:25 pm

It is Mel script. Type it into the script editor. It will list the items currently selected.

Skorpius

Posted 21 September 2010 7:56 pm

thanks, I'm not too sure what I was exactly looking for, but it did work, I just don't know what I did....
thank you for you help...

sarosh

Posted 16 October 2010 9:52 am

thanks . i searched or waterfall technique your note help me to make my project so good . i want your valuable advises for all my new projects . i think you be . i trust you .

klf_lupo

Posted 14 November 2010 12:31 am

hy anybody know haw to bild a 3d fractal in mel?

Duncan Brinsmead

Posted 20 December 2010 10:13 pm

I'm sorry, but I can't understand your question. Perhaps you could simplify it.

Duncan Brinsmead

Posted 21 December 2010 7:08 pm

OK, I'm still not sure of your exact problem. However I recommend the following setup for a tornado:
Animate nParticles by making conserve = 0 and using a curve field. Set up the radius and directions on the curve field for the correction rotation of the particles. Emit from the particles into a fluid in a manner similar to this waterfall and render the fluid, setting intermediateObject ON for the particle shape so it doesn't render.
The particles can emit both density and speed (with inherit motion) into the fluid. You need to use Maya2011 for the emission from particles into the fluid. Also enable motion streak on the emitter. Also look at:
particleVortexFanHR5.ma
which can be found here:
http://area.autodesk.com/blogs/duncan/scene_files_for_fun_stuff_in_maya2011

giftbaby

Posted 24 December 2010 2:21 am


Greeting my dear
I'm gift Koneh

anyway i came across your profile on

www.the-area.com and i love it so much.Here is my

email address (gift_1000@yahoo.in)

you can email me with the above id then

i will send you my picture and also tell

you more about my self

hope to hear from you soon
have a nice day
thanks

Duncan Brinsmead

Posted 18 March 2011 5:42 pm

No mandelbulbs in 2012, sorry.

Satyajit Ramesh

Posted 9 April 2011 6:50 pm



Great Work Duncan........ Thanks for the Tutorial

Duncan Brinsmead

Posted 2 May 2011 9:10 pm

If it looks like balls moving then I would suggest a few things...
1. Make sure the particle motion is roughly correct without any fluid(you can look for other particle tutorials if this is a problem)
2. If the fluid simply looks like hard balls, not streaks, then your density dissipation may be too high on the fluid. As well you may not have enabled motion streak on the fluid emitter. Another possible issue could be having too large an emission radius (maxDistance on the fluid emitter). It should not be too much more than the size of a voxel.
3. Perhaps your fluid is stationary. You want some solving in general. Turn on draw of the velocity vectors so you can see what is going on. One can use both density buoyancy and inheritVelocity on the particle fluid emitter as a means of applying force to the fluid. (external fields could also be used but shouldn't be needed)

If you download the scene file you should be able to compare your setup with the settings of the various nodes.

Duncan Brinsmead

Posted 4 May 2011 5:32 pm

I was referring to some 3d mandebrot set renderings I had done. Currently the fluid uses a built in texture for speed and users have no way of creating a custom or plugin texture for this this internal one currently (you are stuck with the various noise methods and attributes on the fluid)
It is possible to use shading network textures with a fluid(textures mapped to things like transparency or color ramp indices on the fluid), but by default they will evaluate at the outer bounds of the fluid. To evaluate such textures( which must be 3d or projected textures) within the fluid you need to enable volumeSamplesOverride on the fluid shape and increase the volumeSamples. For a detailed texture the volumeSamples would need to be very high, which could make the render significantly slower.


Also note that if you want to convert the fluid to poly then shading network textures are not evaluated properly.

Duncan Brinsmead

Posted 5 May 2011 2:56 am

Actually if you are using a fluidTexture3d (or 2d) then you don't need to use the volume samples override if you are mapping an attribute. Just map any attribute that affects shading( not simulation ) and it should work. The fluid node also has an outCoordinate attribute that can be used if you are using the coordinateGrid method (under the texture section of the fluid). This attribute could be mapped to the uv of a texture for example to push it around.

Duncan Brinsmead

Posted 11 May 2011 11:53 pm

You can't make a connection that would override the internal fluid texturing. The kind of connection you were making would just change the internal texture type used based on the intensity of your fractal. Instead you want to map the texture to a fluid attribute like "transparency" or perhaps an opacity or color ramp indice, or even one of the ramp input bias values. For example you could connect your fractal's output to the first opacity indice:
fluidTexture2DShape1.opacity[0].opacity_FloatValue
If you wanted to smear your texture around based on the motion of the fluid you could make the fluid coord method =grid and the coord speed 1.0 then connect the fluid texture outUV to your fractal uvCoords.

JimBean

Posted 17 May 2011 3:47 pm

Hi Duncan,

Love your work. It's been too long since we've seen any of it, what have you been busy doing? Maybe that would make a nice post.

Regards

Duncan Brinsmead

Posted 17 May 2011 8:54 pm

I've actually got a backlog of 30 or so blog posts (with scene files and such) but I've been kinda busy with work and haven't found time to make them. I've been neglecting this blog lately, but hopefully in the near future I'll start posting again.

JimBean

Posted 18 May 2011 5:44 pm

Gracias!

Thanks for the update.

jbturof

Posted 31 August 2011 6:39 am

Hi Duncan.
Don't know why I have so many problems finding these things....
Where can I find the Inherit Velocity attribute and motion streak? I've looked through the emitter, nParticle Shape and nucleus tabs and don't see it anywhere. Also...after assigning the fluid to my particles, they are rendering very large now. Thoughts

Duncan Brinsmead

Posted 31 August 2011 10:13 am

Those attributes are on the fluid emitter, not the particle emitter.
The main direction of flow should be determined by the particle emitter unless the dissipation is not high enough on the fluid.

jbturof

Posted 31 August 2011 12:07 pm

Great! Thanks Duncan---and thanks for the quick reply!

Duncan Brinsmead

Posted 26 September 2011 5:39 pm

On the fluid turn off realLights OR create a light with raytrace shadows ON. (in the maya renderer it forces raytrace shadows on for the lights that render the fluid if self shadow is on)

faveric

Posted 26 July 2012 4:28 am

thanks for duncan!I would like to ask a few questions?
1.Does it use the SPH algorithm to realize the liquid simulation between the two nparticles from different transmitters?
2.How to achieve the self collision of the nparticles? What is its internal algorithm?

Add Your Comment

You must be logged in to post a comment.

Please only report comments that are spam or abusive.