FX Particles and Dynamics in Maya
Learn how to set up FX and particle systems in Maya with industry pro Mike Zugschwert, in this sample chapter of our popular eBook…
To start creating an animation of water I need some geometry to simulate my water against. I am going to model a glass and a bottle to pour water from. It is important to keep scale in mind when you model. In my preferences under the settings category, I make sure my working units are in centimeters and then I model everything roughly to real-world scale (Fig.01).
Now I can add some particles to the scene, but first I can take advantage of an nParticle preset. Under the menu nParticles > Create nParticles, there are five options for default particle settings (Fig. 02).
I select Water and then in the same menu, use Create Emitter. This will create an omni emitter and an nParticle object in the scene. By default, omni emitters have their Max Distance set to 0, which means all of the particles will spawn in the exact same place. This will be problematic for my water simulation because the forces that drive the simulation will cause the particles to shoot away from each other very quickly. So in the emitter's Attribute Editor, under the Distance/Direction Attributes I set Max Distance to 2 for now and I can adjust this later. I also set my emitter rate to 500 and place the emitter inside the bottle (Fig.03).
Another thing to change right away is the Substeps count for the nucleus solver. The default is 4, which can lead to unstable simulations. I turn it up to 12, and if during my simulations I see particles exploding or moving through collision objects I can turn it up more. Also I enable the Use Plane option under the Ground Plane options. This will keep any particles that miss the glass from falling into infinity. If I didn't create my geometry at the origin, I could create a plane in my scene to use as a collider (Fig.04).
Finally, I need to add the geometry as collision objects for the particles. With my geometryselected I go to nMesh > Create Passive Collider. This will create new nRigid objects in my scene for each object in my selection. In the Attribute Editor for the nRigidShape I can adjust the collision attributes like thickness, bounce, and friction. The default values should work just fine.
Now I can playback my scene to watch my simulation. The default values for the water preset work pretty well, but there are some improvements I could make.
Tip: If you don't use the water preset, the most important thing to do is enable Liquid Simulations and turn off Self Collisions. With liquid simulations enabled there are attraction and repulsion forces that act on the particles to create the behavior of water that must allow the particles to interpenetrate. If Self Collide was turned on, it would interfere with the fluid simulation and you would not get fluid behavior.
In the nParticleShape tab in the Attribute Editor, I start by changing the particle radius. The larger the particle, the less I need to fill the glass but the less detail I will get in my simulation. A radius of .15 should work well for a scene of this scale. Also, I change the Radius Scale Input from none to Randomized ID and increase the Radius Scale Randomize to .1. What this does is randomizes the radius of the particles. This will help prevent the particles from stacking along surfaces, as shown in Fig. 05.
I also want the particles to interpenetrate with the glass a little so I can choke my mesh without leaving a gap between the mesh and the glass. To do this, I set my Collide Width Scale to .7.
Under Liquid Simulation there is an attribute called Liquid Radius Scale. This will influence how much the particles will interpenetrate with each other. To get a smooth surface when meshing I will want them to overlap a lot. The default value is 1, which is way too high. I drop it down to .5, but keep in mind that the more I allow them to overlap, the more particles it will take to fill the glass.
The viscosity will change the behavior of the liquid quite a bit. Thicker liquids like honey or syrup have a high viscosity, while water has a low viscosity. I also key my emitter rate to cut off after 140 frames so it doesn't continue to pour forever. I may need to adjust the timing after seeing the first simulation. My final settings can be seen in Fig.06.
For faster playback, I can cache my simulation. In the nCache menu, with my nParticles selected, I pick the option box for Create New Cache. Here I set my directory as well as other options. I prefer to use one file per frame so that in the event of a crash, I can pick up from where it stopped instead of risking the whole cache becoming corrupted. Also, after I cache, there is a cache description info panel at the bottom of the Cache tab in the Attribute Editor. Here I can see what all of my attributes were when I created the cache, which can help me keep track of which cache had
This simulation took 17 minutes to do 300 frames. The final particle count was 34,750.
That looks pretty good for a first simulation, although I would like to add some animation to the bottle so it doesn't pour into the same spot the entire time. I would also like the glass to fill up a bit more. I would guess around 150,000 particles, which will mean a rate of around 25,000 particles per second for 140 frames. I also raise the Liquid Radius Scale to .7 and run another sim to see how it looks.
This one I let run for 380 frames and it takes 3 hours and 5 minutes to run the simulation (this will depend on the power of your system). The total particle count is 144,791.
Now that I have a good simulation I can create the mesh. I click Modify > Convert > nParticles to Polygons. This will create a mesh in my scene and turn off the display of the particles to speed up the viewport.
The first time I do this I may not see anything on my screen or just a few blobs (Fig.07).
This isbecause the triangle size is too high. The value will depend on my scene scale. For my scene I end up with the values seen in Fig.08.
Threshold and Blobby Radius Scale will influence how the mesh blends between particles. Threshold chokes back the mesh based on the particle density.
Mesh Triangle Size will influence the size of the polygons that generate the mesh. Max Triangle Resolution will automatically change my Mesh Triangle Size if the voxel grid that generates my mesh gets larger than the resolution value. Basically, if I set it to 100, and it takes more than 100 polygons to make the full width of my mesh along one axis, it will change the triangle size. Most of the time changing the triangle size throughout the simulation will cause the mesh to pop between frames, so I set it pretty high to avoid that.
Motion Streak will stretch out the shape of the particles in the direction they are traveling, helping with motion blur. Mesh Smoothing iterations will also help to smooth out the mesh.
I prefer using Quad Mesh for the Mesh Method because it allows me to work with a lower poly mesh and then smooth the mesh using the 3 key. Also I make sure Velocity Per Vertex is checked because I plan on rendering with motion blur.
Then I throw some shaders onto my geometry, add some lights and a floor plane, and start rendering it out (Fig.09 – 10).