Understanding Fluid Containers in Maya - Creating Believable Fluid Simulations

The many different dynamic effects in Maya allow you to create just about any simulation imaginable, whether it's an ocean, a nuclear explosion or water being poured into a glass. As you begin to work with fluid effects inside of Maya you'll begin to realize you need to contain your simulations so you have more control over where they travel to and where they're located. This is where fluid containers come into play. Fluid containers allow you to contain your simulations in a box so that the simulation doesn't travel outside this area. There are two different fluid containers that we'll look at with this article as well as some of the key properties you need to keep in mind when working with fluid containers inside of Maya. A fluid container is a 2D or 3D bounding box which basically defines the space where your fluid simulation exists. It's important to remember that your simulations can't exist outside either container. A fluid container is the key component for most fluid effects. Once a 2D or 3D container is created there still needs to be an emitter inside the container in order for the particles to be simulated. There are many different properties that can be adjusted for this emitter that allows you to create things like smoke, fire, explosions, etc.

The Difference Between 2D and 3D Containers

Container Now, the difference between 2D and 3D containers is probably pretty self explanatory, but it's important to keep in mind that a 2D container is essentially still a 3D container with only a depth of one voxel. The size of this voxel is determined by the Z size of the container. A voxel (volume pixel) can basically be thought of the same way as pixels in a program like Photoshop, the more pixels you have, the higher the resolution, the same goes for voxels. A fluid container is made up of these individual voxels that define the resolution of fluids, the more voxels you have within your container means the higher resolution your simulation will be. It also means that the more voxels you have the slower the simulation time is going to be. For this reason, it's important you find a good balance between the two. Voxels A 3D fluid container is a container with at least two or more voxels making up the depth. You can very easily see the difference between the two containers by creating both a 2D and 3D container and looking at them side by side in Maya. A 2D container is great for simulating something like cigarette smoke or when the camera angle is going to be at a position where the viewer can't really tell the difference if the fluid is a flat object or not. The rendering time for a 2D container is less than a 3D container so if you can get away with using a 2D container you'll have the added benefit of faster simulation times.

Creating a 2D Container to Understand Voxels

In order to create a 2D container in Maya you'll want to make sure you're under the Dynamics menu set. 2D_1 Once there navigate to the Fluid Effects drop down and select Create 2D Container with Emitter. This basically does two tasks at once by including the emitter inside the 2D container. The other option is to create a 2D container and then go to Fluid Effects>Add/Edit Contents>Emitter. Both options have the same result; just the first one is a little faster. 2D_2 If you play back your simulation in the viewport you'll probably get similar results to the image below, it looks like particles being generated from the emitter. 2D_3 That's just because Maya is displaying the wireframe mode. All you need to do is press six on your keyboard to see the shaded mode, which should give you results closer to smoke. 2D_4 Now with your emitter selected open up your attribute editor and navigate to the fluidShape node. This is where you can adjust the base resolution, so you can better understand how voxels work. 2D_5 So let's dial down the base resolution to around 10. The first thing you should notice is that the smoke is much blockier, and very faint. That's because there are now only 100 voxels making up the entire container. Voxel resolution It's important to remember that 10 base resolution doesn't mean a total of 10 voxels, it means there are 10 voxels across the X axis and 10 voxels making up the Y axis of the 2D container. So there are actually 100 voxels making up the resolution of the fluid. 2D_6v2 Now, if you raise the base resolution to around 100 and play back the simulation you should quickly see the difference. The smoke is much more prominent and appears to be a lot smoother and it takes on a whole new shape because there is much more resolution to work with. 2D_7v2 It's important to keep in mind as you raise the base resolution and increase the number of voxels in the container you'll start to notice a slow down in simulation time, so just keep that in mind if you're finding that the simulation is running much too slow. You may be wondering why when you increase or decrease the voxel resolution there is no visible change on the actual container. That's because the container is set to only display the outline by default. If you go back into your fluidShape node and under Display change the boundary draw to full. You'll see just how dense the container is when the base resolution is set to 100. 2D_8

Creating a Liquid Simulation with a 3D Container

In order to create a 3D container go to Fluid Effects>Create 3D Container with Emitter. This will drop both the 3D container and the emitter directly in your viewport. 3D_1 The first thing you should notice as you play back the simulation is the smoke is now being rendered with depth, instead of a flat 2D plane like you would get with the 2D container. 3D_2 Select the 3D container and navigate to the fluidShape node in the attribute editor. 3D_3 Scroll down until you find the Content Details properties and open it up. Select Density and change the Density Scale to 1, and the Buoyancy to -1. This will now allow the fluid effects to fall to the floor instead of fly into the air. 3D_3v2 Now scroll down until you find the Shading attribute and dial down the transparency to black, making it completely opaque. 3D_5 Once you've done that go back up to the Surface attribute and check the Surface Render and Soft Surface options. You'll also need to dial up the Surface Threshold to 0.024 and the Surface Tolerance to 0.2. Your settings should look the same as the image below. 3D_6v2 Now you can see that the fluid effects have been changed to an actual surface, and if you scroll down to the Output Mesh properties and bump up the Mesh Resolution to 4 and the Mesh Smoothing Iterations to 2 you'll see your fluid effect is much smoother. 3D_7v2 Fluid containers are a great way to create some really nice fluid effects that give you a lot of control over where your fluid effects travel to and how they look. Try messing around with the different attributes inside your fluidShape node to see the different effects you can create. If you want to learn more check out Introduction to Fluid Containers in Maya.