Username
Password
Auto-login
Show my name in the online users list
Not a member?
Please register.
Forgot your password?
(1) October 2008
(2) May 2008
(1) January 2008
(1) November 2007
(2) September 2007
(7) August 2007
(2) July 2007
(1) June 2007
(3) May 2007
(4) April 2007
(8) March 2007
(9) February 2007
Water using nCloth (part 1 of 2)
Posted: Mar 05, 2007 - 06:33 AM
Category: nCloth
It is possible to use nCloth for water, taking advantage of its ability to accurately self collide thick vertices (spheres), in addition with the ability to collide with geometry and other cloth objects( including rigid cloth). Note that one problem with this method currently is that the water can be too damped (a bit like slush or pea soup), however it may work fine in many contexts. A hidden nCloth attribute "selfCollisionSoftness" can be used to help keep it from getting too viscous, and I will discuss the use of this later in the tutorial. Please keep in mind, however, that nCloth was designed for cloth and this tutorial is somewhat of a hack. In future nucleus will hopefully support a proper particle based water solution.



Prepackaged Water
If you want the simple and easy way of doing things, just import the following file into your scene:
nClothWater.ma (scroll to the bottom to download related material)

This creates a block of nCloth particles that you can simulate, cache and render. Open the particle shape node in the attribute editor and you will see info on how to use this (inside the notes section), as well as added attributes ( under "extra attributes") for controlling the look and resolution of the simulation.
If you scale the block along just one axis the resolution automatically adjusts to maintain a uniform particle density. It is best to render this is Mental ray with motion blur, but make sure to cache first if you want to see the motion blur. (the maya blobby render not only does not support motion blur on particles, but it also has some problems with the blobby threshold rendering) Note that to cache you need to select the nCloth shape node, not its transform, because there is no output mesh in this scene. If you wish to create constraints you can still do so by displaying the input mesh and selecting it for constraint uses.

Here is a simple workflow for a pouring glass filled with liquid that shows how one can use this cloth water file.

1. Load the water preset file nClothWater.ma.
You may need to playback and rewind once to see the correct particles as there is an initialization problem on load.
image1.jpg
On the node "waterNClothShape" in the attribute editor there are several extra attributes for controlling the water as well as descriptions of them in the notes section. Set the resolution to detemine how detailed a solution you want.
image2.jpg
Note that you can change the resolution(or number of particles) at any time, but if you have an initial state set then you will need to reset it. The particle density controls the amount the particles overlap. A value of 1.0 will have them just touching at the start frame. For water sometimes a value like 1.1 will keep the water from losing volume as it simulates, while values much larger will tend to result in the overall water volume increasing. Values less than 1 might be useful when simulating droplets like rain

2. Create a cylinder and scale it to the desired size of your glass. Select and delete the top face to make it open.
image3.jpg
3. Select the cylinder and do MENU "nCloth: Create Passive"
On the nRigid node that was created turn OFF "Trapped Check" because that attribute pushes out based on the surface normal, and we are colliding with the inside of the glass, not only the outside. If you only wanted to collide with the inside then instead you could reverse normals on the glass and leave "trapped check" on. Note also that the pushout attribute looks at the normal, so it is important that you reverse the normals if you want to use that.
image4.jpg
4. Scale the block of water to fit inside the glass. Also scale it up in y more to pour more water into the glass. Notice the way extra particles are added as you increase the y scale. When we playback the water should fall into the the glass.
image5.jpg
5. Increase the collide thickness on the glass (nRigid1) so that the expanded blobby surface does no penetrate the glass. To do this first lets enable the attribute "blobbyScaleDisplay" (under waterNClothShape extra attributes).
image6.jpg
This shows the maximum potential extent of the water, although it may be less depending on how many particles overlap and the blobby threshold setting. I also added a simple blinn water shader to the glass and increased the transparency to help better see the water during playback.
image7.jpg
You can set the glass solver display to "collision thickness" then playback editing the thickness value to just push the water inward enough... about 0.07.Note that one could model and collide with a glass that has thickness, however one can model the thickness with this thickness attribute and insert a more realistic glass just for rendering, simulating on the simpler one.
image8.jpg
5. Set the initial state of the cloth in order to have the glass start filled with water. In order to do this we temporarily need to first select the output cloth mesh and make it visible (other operations like creating a constraint will require this as well).
image9.jpg
Do MENU "nCloth: Relax Initial State" setting the number of steps in the option box to about 50.
image10.jpg
The water should drop down into the glass. If it doesn't make it the full way then repeat until it does. Optionally one could instead simply playback and then stop on a good frame and do "nCloth: Set Initial State". When done make the output cloth mesh invisible again because we don't want this to render.

6. Keyframe the motion of the glass. One can also play around with the simulation by doing MENU "nCloth: interactive playback" and transforming the glass object during playback ( set your slider frame range to a large value so the simulation does not stop too soon ).
image11.jpg
7. Select waterNClothShape and do MENU "nCloth: nCache: Create New Cache" and then render the animation. Make sure you have specified your desired cache frame range. Also you must directly select the shape node "waterNClothShape" and not its parent transform. (or one could select the clothOutputMesh and make it temporarily visible again). It is generally best to cache the simulation first before rendering, especially if rendering with motion blur or on a render farm. Note that one must render with Mental Ray in order to get motion blur on particles. The mental ray blobby rendering is also generally better than with the Maya renderer.
image12.jpg
You can edit the blobby attributes under the extra attributes of the waterNClothShape node. Here is an example of smoothing accomplished by increasing the blobby scale and threshold. Careful adjusting of the threshold can determine the size of lone droplets. Note that when the threshold is greater than 1 there will be only be water where particles overlap.
image13.jpg
The file waterPlayground.ma shown at the top of this tutorial used a file similar to nClothWater.ma, although I've made a few modifications since then. Note how the various nCloth elements... the door flap, two floating objects and a suspended piece of cloth... interact with the cloth water. If the object has a greater mass than the water it will sink( the object at the top ), while lower mass objects float( the ball at the bottom ). Note that if you want to cache the simulation for this scene you need to select all the nCloth meshes in the scene, and the water cloth requires that the nCloth shape node be directly selected. Rendering was done in Mental Ray so that the particles had motion blur.

Warning: If you find that a file with nCloth no longer loads try removing the particle startup cache in you project/particles folder. Currently there is a bug where particle startup caches are saved for nCloth and nRigid nodes(on file save). The cache folders will have a name like nClothWater_startup, or nRigid1_startup and can be safely deleted as they are not used or needed. Also the 8.5 release has a bug where large nCloth or nRigid nodes leak memory and crash. Keeping these objects less than about 150 units in size will avoid this problem.

Part two of this tutorial will cover how the nClothWater file is setup and go in to more detailed examples.
The basic technique is to disable all edge and face relationships on the nCloth node, so that all that remains is point to point collision, then pipe the output of the nCloth into a particle system. We connect this output of the cloth into the particle system softbody mesh and goal mesh inputs. The particle system is used solely for its blobby particle rendering.
In order to post any comments, you must be logged in!
  Posted by Greg M  on  14 May, 2008  at  09:02 AM

Thank you! This is very useful! I’m using this method for a liquid simulation, but to make the splash a little more believable I’m trying to figure out a way to randomize the size of the ncloth particles. Do you know of a way to accomplish this?

[edit] No sooner do I post the question, than I figure out a way! For the benefit of others, I’ll post what I did here.

Make sure blobby display is turned on, as mentioned above. You also may want to turn off the Solver Display on the waterNclothShape node. I couldn’t figure out a way to randomize that, so for now I hid it and tried to pick a collision size that would accommodate all particle sizes. Then add a raidusPP attribute and add this line as a creation expression (which uses copied lines from the expression that’s already there):

float $sx = waterNCloth.scaleX;
int $xres = (waterNClothShape.resolution+1)/2;
float $size = 0.25 * waterNClothShape.particleDensity * $sx/(float)$xres;
clothOutputParticleShape.radiusPP = rand(.01,.1) * $size * waterNClothShape.blobbyScale;

And that’ll give you random particle sizes. It’ll mess up the Blobby Scale attribute, but if you’re using this for airborne liquid, that might be okay. I’m still learning, so any thoughts would be welcome!

  Posted by learningmaya  on  22 Mar, 2008  at  11:17 AM

Thanks for your great tutorials Duncan! They are very helpful!

It states that this tutorial is Part 1 of 2.  Does anyone know where Part 2 can be found?

Thank you!

  Posted by Quillet  on  07 Nov, 2007  at  04:22 AM

hi !
thx u for your tutorial, but how i convert the Ncloth objet to Particles Blobby for to have a water effect
thx u for response smile
see u later

  Posted by tikalmat  on  18 Oct, 2007  at  07:50 AM

if i wanna start not from a cube shape but from a sphere shape? is this what talk about the part 2 of the tutorial?
however very good job Duncan, you are the great!

  Posted by mahesh80  on  01 Oct, 2007  at  06:30 AM

Duncan, you are a rock star!!

  Posted by 4dfx  on  10 Apr, 2007  at  05:00 PM

This is nice, but I would like to see if ncloth allows an artist to add a fire effect to it. For example, in the movie Stealth, one female pilot ejected from the plane and was parachuting down. However, later her parachute got on fire and it quickly burned away the chute. How would one go about to create such an awesome and realistic effect for ncloth?

Or is there a way to add a text to the ncloth (lets say, the word “Maya”, and have the fire burn only on that text or along that text from the first to the last letter?)

What about to improve on the tear in ncloth to allow an artist to in a perfect straight line, like using the cut faces tool. This way, the cut doesn’t look like a stair step effect. It’s like using Wolverine’s super sharp claw to cut through a banana.

Check out some of the effects done by professor Ron Fedkiw and his students
http://graphics.stanford.edu/~fedkiw/

 
Page 1 of 1 pages