Join Aaron F. Ross for an in-depth discussion in this video Filling a container using a volume emitter, part of Maya: Liquid Simulation (2013).
The Fill Object command is convenient, but it's destructive. That means that after you fill the object full of particles, you cannot change the number of particles later. And it's very important that you have the ability to change the number of particles. That's because the number and size of the particles will determine how the surface will eventually render. I found that it's a better practice in fact, to use a volume emitter instead of the Fill Object command.
Let's do it that way. So we're going to go into the nDynamics menu set, and we'll go into nParticles > Create nParticles, and make sure that the water preset is chosen. And we're going to do Create Emitter. And it's created at the origin. Let's tap the spacebar. What we want to do is just move that up and position it so that it's inside the gin bottle. So I'll get the move tool in the front view and just position that inside the bottle. And then I'll need to move it in the top view, as well.
Move that forward and Z. Make sure that it's square inside the bottom. Now, that's an omni emitter currently. Let's go back to our camera view and open the attribute getter /g, Ctrl+A. And we play this, you'll see we get particles shooting out. Well, we don't want an omni emitter, we want a volume emitter. So the basic emitter attributes for that emitter should be set to Volume. And now you'll see we get a cube. The particles are built inside that cube. Let's scale it up with the Scale tool.
Needs to be taller. And it needs to be just larger in general, so that it basically fills the volume of the bottle. And we want to check that in the various view ports here to make sure that it's good. We don't want it to be larger than the bottle, we want it to be a little bit smaller than the bottle, so that no particles are born outside the bottle. Play that back. Very good. We don't want them to fly outward, we just want them to start with a velocity of 0 and then just drop with gravity. Scrolling down, we want to set the volume speed attributes all to 0, so away from center, I want to set that to 0, press play, and you'll see okay, now they're just falling.
Now, of course we want the proxy object here to be a collision object. So I want to select that. Go into nMash > Create Passive Collider. Press play again, see what we get. And our particles fall and collide with the inside of the bottle. We don't want those particles to sort of appear and respond like that. We want them to all be present on the first frame of the animation. And there's a trick to this. What we'll do, is we'll set the emission rate to a very, very high number, like a million.
But then we'll limit the number of particles in the particle shape node. So let's go into the outliner and selectings. We want to first select the emitter node. Here it is, emitter one. And we want to increase the rate up to a very, very high number, like a million. And press Enter. Now be careful, because if you press the play button now, then you may crash your system, because you're creating way too many particles all at once. But then, we'll go into the shape node, and limit the number of total particles. And that'll be found in the emission attributes section. Max count.
We can set that to a value of let's say 1,000. What this'll do, is it will create 1,000 particles on frame one of the animation. Because we've said we want to create a million particles per second, but we want to limit it to 1,000. So rewind and play that back, and you'll see all those particles are built on one frame. So we got our particles built, now we want to adjust those particle attributes. Scrolling back up to the top of the particle shape node, we're going to need to increase the radius here. So I don't know exactly how much I need this to be, but the reason that I'm doing it with this work flow is because I can go back and change the radius and the number of particles after the fact non-destructively.
So with a radius of 0.5, this is the result that I'm getting. So scrolling down a bit in the liquid simulation section once again, we've got incompressibility, rest density and liquid radius scale. I'm going to increase the incompressibility to about ten, rest density I'll leave at two, but I'll set the radius scale down to about 0.5, which will create more overlap among those particles. And then additionally, there's the viscosity setting. We can turn that actually down to almost nothing, because water is not very viscous.
And there's also a very useful attribute here called Surface Tension. And what that does, is it's sort of a self-attraction attribute that causes the particles to kind of stick together. And we need that because if the particles fly apart from one another, then when we try to render them with blobbies, they wont render if they're seperate. So they need to kind of stay together. I'll turn the surface tension up all the way. Rewind and play back. So you can see, with 1,000 particles with the liquid radius scale of 0.5, basically they're all landing at the bottom here.
So basically, I think I can increase the radius a bit. So set that overall radius to 0.7, rewind and play back. And now we're getting a better volume of particles. In your own scenes, you're going to need to adjust all of these variables. And you'll need to fin- tune all of these attributes for your particular scene. And it's important that you get a decent playback rate. Because it's no good to have teeny tiny particles with millions and zillions of them, because the simulation playback will be so slow in your view port that you will not be able to work. So you have to try to find a happy medium between quality and performance, and we do that by setting the overall number of particles, their radius, and their amount of overlap in the liquid simulation settings here. I think I need more particles, so I'll go back to the emission attributes, and set the max count up to let's say, 2,000 instead of 1,000. Rewind and play that back.
Now sometimes, you'll see that your particles are a bit overactive, and they may actually even explode out of the container, even if you've set everything else the way that it sort of should be. There's one little trick that you can do here that will prevent those particles from flying out. And that is to keyframe the damping factor on the first few frames of the animation. Damping is a sort of chill out factor that reduces the intensity of the simulation. What we'll do, is I'll rewind back to frame one, and in my nParticle shape node up at the top, we're looking in the dynamic properties area here, and you'll see Damp. And what we'll do, is we'll just set it to a damp value of ten, which is the maximum here, on frame one, and then key it.
Right-click and set Key. And then a few frames later, we'll go forward, let's say, about frame ten, set the damp value down to zero, and then right click and Set Key again. And if we play this back now, what's happening is that they sort of settle down more gracefully. And if your particles are exploding out of their container, then use this technique. One more thing you might want to do with this damp factor, is to make it constant throughout the first few frames of the animation and then drop off suddenly.
And to do that, you'll want to set the keyframes to step tangents. Go ahead and select the particle shape node, and go into the graph editor, Window > Animation Editors > Graph Editor. And you can see, here's the damp curve. We just want to select those keyframes and set them to step tangents. And that'll make the damp factor constant for the first ten frames, and then drop off to nothing. Rewind and play back the simulation. And again, this is a method to try to prevent those particles from becoming overactive on the first few frames of the simulation.
- Creating dynamic foam and bubbles with nParticles
- Rendering particles with the Fluid shader
- Colliding particles and fluids with polygons
- Storing simulations with disk caches
- Emitting particles from a texture
- Pouring liquid with nParticles
- Converting particles and fluids to smoothed polygons
- Simulating volumetric liquid with a 3D fluid container
- Controlling key simulation parameters
- Texturing a 3D fluid