This Cyber Monday Tuts+ courses will be reduced to just $3 (usually $15). Don't miss out.
Maya fluids gives you the tools to simulate any kind of smoke, fire, water, explosions, wind effects etc. and is a very powerful tool for every FX artist. The fluid simulations and shading can be as different as night and day, but they rely on the same attributes which you'll better understand after completing this tutorial.
You'll learn to animate and shade fluids, understand all of the major attributes, learn how adding fields will allow you to gain better control over your simulation, and how to light and render the final animation.
To begin choose Dynamics as a menu set for this project, since almost all of the things we are using are related to Maya Fluid FX.
Because we are going to use Mental ray nodes, make sure Mental ray is loaded in Maya by going to Window>Settings/Preferences>Plug-in manager and checking both the Loaded and Auto load check boxes for Mayatomr.mll.
Choose Window>Settings/Preferences>Preferences and in the Time Slider tab, change the Playback speed to Play every frame and the Max Playback Speed to Real-time. This ensures that you will see every frame of your animation and if the animation is computing very fast, you'll still be able to watch it in real time and not exceed the 24fps limit (so it wont look like fast forwarded.)
Now create the 3D container that will contain the fluid for the explosion animation. Choose Fluid Effects>Create 3D Container with Emitter.
Now you have a box with a little sphere inside of it. The box is the actual container where you can make your animation and the little sphere is the emitter that emits the fluids (in this particular case the smoke animation).
Since the explosion will spread mostly on the Y axis (because the smoke will rise up quickly.) You need to make the container bigger, especially in the Y axis. Choose the container and in the Attribute Editor, in the fluidShape tab. Set the Size to 45.0 for the X and Z axis and 60.0 for Y.
Choose the Emitter and move it to the bottom of the Container, but beware not to go below it. Next in the Attribute Editor under the fluidEmitter tab, change the Emitter Type to Volume, and the Volume Shape to Sphere.
Now it's time for the first animation test. Give your animation an interval of about five or six seconds. I choose to go with a 140 frame animation, which is almost six seconds. Type 140 in the box below the right part of the Timeline. This will set your Timeline to 140 frames long. Hit the play button at the right side of the timeline. You can see almost nothing is happening, so let's start shaping the explosion animation.
There is almost nothing happening, because there is a very little amount of fluid emitting, and the grid (at the bottom of the container) is not detailed enough to catch the small amounts of fluid.
Select the container and check Keep Voxels Square and set the Base Resolution to 30. Increasing the Resolution improves the depth of the details, much like in image resolution.
Choose -Y Side for Boundary Y, so the container does not let the fluid escape from the bottom of the container, acting as a ground for the explosion.
Set the all Contents Methods option to Dynamic Grid, this makes your simulation relevant to all factors such as Temperature, Fuel etc. and calculates them based on the Dynamic Grid, whose resolution you set above.
Choose the fluidEmitter tab in the Attribute editor and set the Fluid Attributes as follows: Density/Voxel/Sec to 80, Heat/Voxel/Sec to 60, Fuel/Voxel/Sec to 90. This is the amount of emitted voxels per one second for the Density, Heat and Fuel. For Fluid Dropoff, set it to 0.
Now test the simulation again by rewinding and pressing Play. Now you can see that there is much more fluid emitted in the container.
Now all of the Fluid Attributes are continuously emitted at the Rate specified in Step 10.
That's not what you want since the Fuel and Heat, in an explosion are taking place only at the beginning. And the Density of the fluid emitted, is decreasing with the passing time.
To make the emitted amounts decrease in time, you must first Set Key for the first frame.
Hit the Rewind button, and make sure you are at frame 1. Choose the Emitter and in the Fluid Attributes, right click on Density/Voxel/Sec and choose Set Key. Repeat for Heat/Voxel/Sec and Fuel/Voxel/Sec. The values will turn Pink which means that they are animated.
Now move to frame 3 and set Density/Voxel/Sec to 50, and right click and choose Set Key. Then change Fuel/Voxel/Sec to 0, right click and choose Set Key. This way you decrease the amount of emitted density voxels and make sure that there is no Fuel emitting after frame 3.
Move to frame 6 and change the Heat/Voxel/Sec to 5 and right click and choose Set Key.
Next move to frame 15 and change Density/Voxel/Sec to 0 and again right click and choose Set Key.
To check if you have entered the exact values at the exact frame, you can open the Graph Editor by choosing Window>Animation Editors>Graph Editor. Select your Fluid Emitter, and check if your animation Graphs are the same as the ones shown in the picture.
Now if you test your simulation (as in Step 11), you can see that there is a very big difference, there isn't a constant emission of all the attributes. Most of the emission is taking part in the beginning of the simulation, which is closer to the explosion look. There is another problem that you can clearly see now. The simulation is too slow for an explosion.
To make the simulation faster, select the Container and in the Attribute Editor under the fluidShape tab, scroll down to Dynamic Simulation and set the Simulation Rate Scale to 3.5.
Test the simulation again. You can see now it's much faster, but the smoke is still moving a little bit slow, and it looks too heavy. To make it lighter (in order for it to move faster through the air), scroll down to Contents Details and for Density, set the Buoyancy to 3.
Now your simulation is getting closer and closer, but it's still just moving upwards after the emission due to the buoyancy of the fluid. To make it more interesting and believable you need to add some turbulence and swirl.
Change the Swirl to 18 under the Velocity tab. Later you'll add more turbulence with a turbulence field, as it gives a better result than the built in turbulence for the fluid container.
Now rewind and play the animation again to see the difference. You can see now your smoke isn't just going directly upwards, and the result is much more pleasing.
Now it's time to set the values for the Temperature and Fuel.
Set these values in the Temperature and Fuel sections (as shown below). Simply make the temperature more turbulent and more buoyant, because the hot air is raising quicker. Then set the Fuel attributes in order to get a nice reaction (as shown below.)
In order to get a better look at the reaction occurring via the ignition of the fuel, you must make some adjustments in the Shading section.
Scroll down to the Shading section and in the Color section, choose Density for the Color Input. And the color of the fluid will be controlled by the density The more dense the fluid is, the more color is used from the left side of the gradient and the opposite for the right side (the less dense it is).
Now click and drag to the right on the gradient above, so that the second color you add is at the furthermost right position. Click on Selected Color for the right color and set the Value to 0.450.
Now choose the left color and set its Value to 0.140. Check again to make sure that your gradient is darker at the left side (where the fluid is more dense) and lighter at the right.
Below the Color Input there's a Input Bias field, change its value to 0.2, to make it a little bit more lighter (you can later adjust this setting to get the fluid as you like it).
If you rewind and play the animation, you can clearly see that the heat is igniting the fuel, thus making the fluid brighter.
The problem is that the fluid is too transparent, and is gradually mixing with the air around it, there is no distinct border between the air and the smoke generated from the explosion.
To fix this, access the Opacity section (again in the Shading section) and by clicking and dragging, add more control points and move them until you get a similar curve. Change the Input Bias to 0.6 to increase the emitted fluid's opacity.
Make sure that the last control point on the left side is at the bottom (Selected Value = 0.00), otherwise the whole container will be full of smoke.
To make the explosion brighter, there is a section above the Opacity section, called Incandescence. Where you can set the values for the explosion incandescence via a gradient.
First make sure that Incandescence Input is set to Temperature, so your fluid is getting self illuminated in areas where the temperature is very high.
Choose the yellow swatch on the right side of the gradient and click at the Selected Color, change the Value (V) to 3.
Add another swatch just next to the one that you just edited (Selected Position = 0.960) and change it's Value to 2.5.
Move the red swatch in the middle of the gradient to Selected Position 0.900, and then add another swatch between the red and the black swatches at Selected Position 0.760, and set it's Value to 0.4.
Finally set the Input Bias to 0.15
Scroll down a bit to Shading Quality and set it to 3. This increases the quality of the render, but be careful because it increases the render time as well. Decreasing the Contrast Tolerance also increases the render time.
Scroll down again and you should see the Lighting section. Turn on the Self Shadow checkbox and set the Shadow Opacity to 1. This makes the fluid able to cast a shadow on itself (also make sure that Real Lights is turned on). Later when we add lights in the scene, you'll see that the fluid is casting a shadow both on the ground and on itself.
Now lets refine the animation!
In the Dynamic Simulation tab of the container attributes, change the Viscosity to 0.200, and the Damp to 0.050. This will make the fluid simulation extra realistic.
Go to the first frame and right click on Simulation Rate Scale and choose Set Key, to set a key at the beginning for the animation speed. Because explosions happen fast in the beginning and then slow down with fire and smoke, the Simulation Rate Scale should drop in time. Go to frame 10 and set the Simulation Rate Scale to 1.75 then again right click and choose Set Key.
Since you are finished dealing with the basic animation and shading, you can now up-res the container and make the simulation more detailed by first setting the Base Resolution to 60 (for the final animation you'll increase it even more) and in the Dynamic Simulation tab, set the High Detail Solve to All Grids Except Velocity and the Solver Quality to 40.
Now to gain extra control on the simulation, let's add some fields to control the movement of the fluid.
First make sure the container is selected (it's important, because this makes the field automatically connected to the container), then in the Dynamics menu set, choose Fields>Volume Axis.
Volume Axis fields are great, because they have a couple of different volume types and a lot of different attributes.
Select the Volume Axis field and make sure that the fluid container is turning purple. This means that the field is affecting the fluid. If not, select both and choose Fields>Affect Selected Object(s).
In the Attribute editor, choose Cylinder for the Volume Shape in the Volume Control Attributes tab. Use the Scale and Move tools to scale and position the Volume Axis Field as shown in the picture (make it wide and short and put it at the bottom of the container).
In the Volume Speed Attributes, change the following values: Along Axis to -0.500 and Turbulence to 0.800.
Go to frame 1 and change the Away From Axis to 15, right click on it and choose Set Key. Next go to frame 10 and dial it down to 3, then Set Key again.
With these settings, you make the Volume Axis Field push the fluid away from the center and a little bit down. This way you get a shockwave effect on the ground.
Create a second Volume Axis field, as shown in Step 28, make it tall and thin and position it as pictured below. Set the Attenuation to 0.500, Along Axis to10 and the Turbulence to 0.8.
This field will push up the fluid in the center to simulate a little bit of a mushroom type explosion effect.
Now as I said before, lets add more turbulence to the explosion. Choose the container and from the Dynamics menu set, choose Fields>Turbulence, which will add a turbulence field attached to the container.
Adjust the turbulence field settings as shown: Magnitude to 200, Attenuation to 0 and Frequency to 12. Magnitude is controlling how strong the turbulence will be and frequency is self explanatory.
With non-animated values for Phase X, Phase Y and Phase Z the turbulence field is generating turbulence constantly in the same manner, so the force of the turbulence is building up at the same spots and it looks awkward. So lets make an expression for these values, so they are always changing.
To do so, select the turbulence field and right click on Phase X value and choose Create New Expression...
In the Expression Editor that will appear, enter the following expression:
turbulenceField1.phaseX = time;
turbulenceField1.phaseY = time;
turbulenceField1.phaseZ = time;
Make sure that the name of your turbulence field is turbulanceField1. If it isn't, either rename it or change the expression so that it's matching the name of your turbulence field.
When the animation is being played each different frame will have a unique value for PhaseX, PhaseY and PhaseZ, so the turbulence will be more believable and pleasing.
With the turbulence field, everything for the simulation part is completed. All that's left is to add some lights and render the entire simulation. You can use whatever lighting setup you like, but I will show you what I used. I used a simple 3 point lighting setup.
Create three Point lights by choosing Create>Lights>Point Light, and position two of them in front of the fluid container (one to the left and one to the right) and the last light behind the container (as shown.)
These are the settings I used for the three lights. Change the colors of all the lights to a warm or cool tone (just a bit), so that the render has a little more life and not just gray shades. Change the Intensity values of all the lights in the attribute editor, so that the first light has an Intensity of 1.2, the second 0.2 and the third 1.0. Turn ON the Use Ray Trace Shadows option for all the lights in the scene !
The simple lighting is ready so it's time to render the final simulation. To get a detailed simulation you need to up-res the container. For the preview video of this tutorial I used a Base Resolution set to 140, but you can use even higher values. With the Base Resolution set to 140, my quad core processor calculates each frame for about 6-7seconds (simulation not the render). I don't recommend you use values higher then 250, unless you are very patient or have a very powerful CPU.
It's not necessary, but I recommend you make a cache of your simulation, because if your rendering process is interrupted, or you want to do a render from a different camera, you must have the animation of your fluid saved. If you don't cache it, every time you hit the play button the simulation will be different. To cache the simulation, simply choose the container and then Fluid nCache>Create new Cache and choose the box next to it.
These are the settings for the Fluid cache: .File distribution: One file per frame, Cache time range: Time slider (should be 0 to 140.) For Evaluate every and Save every, set the values to 1. You can Uncheck the checkboxes for color, texture coordinates and falloff since you are not using them in the simulation anyway.
When you hit the Create button, Maya will start to evaluate every frame of the simulation. When each frame is calculated it's saved to the hard drive so you can repeat the animation or go to a specific frame any time you want without changing the simulation.
Open the Render Settings window and choose mental ray to be used as rendering engine. In the Common tab to be able to render an animation choose name.#.ext for Frame/Animation ext: this means that the name will be followed by a dot (.) then the frame number and at last the file extension.
For file format I chose PNG, but you can use let's say TGA or TIFF as well. Be sure to set the Frame padding to 3, since the whole animation has 140 frames you need 3 digits, so the numbering will begin from 001 to 140. Set the Start frame to 1 and End frame to whatever frame you want to end your animation.
You didn't have to use all of the 140 frames, so you can set it to 80, but with the animation being cached you can always render frames from 80 to 140 later. Choose the width and height of your images, as well as a renderable camera and your Common tab settings are ready.
The render doesn't require very sharp edges, so you don't need very high settings for anti-aliasing. In the Quality tab of the Render Settings, choose Adaptive Sampling and set the Max Sample Level to 1. Set the Filter to Gauss. These settings will be good enough to get a nicely rendered explosion.
Position your renderable camera so that the container is filling the frame. To render your animation simply choose the Rendering menu set, then Render>Batch Render and select the box next to it.
In the Batch Render Options, you can set Auto Render Threads to be On (and the render will use all of your CPU cores.) Set the Memory Limit, according to your PC or leave it to Auto Memory Limit. Finally click on Batch render and close and you just have to wait for your PC to render the animation.
After all of your frames are rendered, you can see them in your project Images folder and load them as a Sequence in your favorite compositing software. And that's it, you have finished your Maya fluids explosion simulation.
- Release Your Inner Chemist With Maya
- How to Create an Awesome Fire Effect Using Maya Fluids
- Introduction to Smoke Simulation in Blender 2.5
- Creating A Nuclear Explosion In 3ds Max And After Effects
- Taking Advantage of Blender 2.5
- Quick Tip: the Secret to Making Convincing Explosions with FumeFX