According to their most simplistic definition, fluids consist of any substance that continually deforms. Autodesk Maya has two tools available for working with fluids: Maya Fluids and Bifrost.
Maya Fluids consist of containers and emitters, which are designed to simulate gaseous effects such as clouds, smoke, flames, explosions, galactic nebulae, and so on. Maya Fluids also include dynamic geometry deformers and shaders, which can be used to simulate rolling ocean waves, ripples in ponds, and wakes created by boats.
Bifrost, Maya’s newest fluid solver, is capable of water and smoke effects. Bifrost uses real-world values, making it easier to understand than fluids, and also provides realistic results. Since Bifrost is in its early stages of development, being first introduced in Maya 2015, its functionality is not yet as robust as Maya Fluids.
In this chapter, you will learn to
Fluid containers can be thought of as mini-scenes within a Maya scene. They are best used for gaseous and plasma effects such as clouds, flames, and explosions. The effect itself can exist only within the container. You can generate fluids inside the container by using an emitter or by painting the fluid inside the container. Dynamic forces then act on the fluid within the container to create the effect.
There are two types of containers: 2D and 3D. They work the same way. Two-dimensional containers are flat planes that generally calculate faster than 3D containers, which are cubical volumes. If you do not need an object to fly through a fluid effect or if the camera angle does not change in relation to the fluid, you might want to try a 2D container instead of a 3D container. Using a 2D container can save a lot of calculation and render time. Two-dimensional containers are also a great way to generate an image sequence that can be used as a texture on a surface.
In this first exercise, you’ll work with fluid basics to create a simple but interesting effect using 2D containers. When you set up a container, you can choose to add an emitter that generates the fluid within the container, or you can place the fluid inside the container using the Artisan Brush interface. You’ll start your experimentation using the latter method.
The properties that govern how the fluid exists within the container and how it behaves are controlled using the settings on the fluidShape1 node. When you painted in the container using the Paint Fluids Tool, you painted the density of the fluid. By creating areas of density, you position the fluid in an otherwise empty container.
You can paint various attributes in a container using the Artisan Brush. Some attributes can be painted simultaneously, like Density And Color or Density And Fuel. Other attributes, like Velocity and Temperature, are painted singularly. As you work through the exercises in this chapter, you’ll learn how these attributes affect your fluid simulations.
Another way to generate a fluid within a fluid container is to use a fluid emitter. Fluid emitters are similar to particle emitters in that they consist of a point or area in 3D space that generates fluids at a rate you can control. The main difference between fluids and particles is that the fluids created by an emitter can exist only within the confines of the fluid container.
Fluid emitter types include omni, volume, surface, and curve:
Maya fluid emission maps can control the emission of a fluid’s density, heat, and fuel using a texture.
This opens up a lot of possibilities for creating interesting effects. In this exercise, you’ll map a file texture to the fluid’s density attribute:
jollyRoger.tif
file in the chapter15sourceimages
folder at the book’s web page (www.sybex.com/go/masteringmaya2016
).jollyRoger_v01.ma
.To see a version of the scene, open the jollyRoger_v01.ma
scene from the chapter15scenes
folder at the book’s web page. Create a playblast of the animation to see how the image acts as an emitter for the fluid.
Fluid containers are subdivided into a grid. Each subdivision is known as a voxel. When Maya calculates fluids, it looks at each voxel and how the fluid particles in one voxel affect the particles in the next voxel. As you increase the resolution of a fluid container, you increase the number of voxels and the number of calculations Maya has to perform in the simulation.
The Base Resolution slider is a single control that you can use to adjust the resolution of the fluid container along both the x- and y-axes as long as the Keep Voxels Square option is selected. If you decide that you want to create rectangular voxels, you can deselect this option and then set the X and Y resolution independently. This can result in a stretched appearance for the fluid voxels. Generally speaking, square voxels will result in a better appearance for your fluid simulations.
The nice thing about 2D containers is that you can use a fairly high-resolution setting (such as 120) and get decent playback results. Three-dimensional containers take much longer to calculate because of the added dimension, so higher settings can result in really slow playback. When using 2D or 3D containers, it’s a good idea to start with the default Base Resolution setting and then move the resolution upward incrementally as you work on refining the effect.
Fluids can be controlled using dynamic fields such as Turbulence, Volume Axis, Drag, and Vortex. In this section, you’ll distort the image of the Jolly Roger using a Volume Axis field.
As demonstrated in the previous section, when you play the Jolly Roger scene, the image forms and then starts to rise to the top of the container like a gas that is lighter than air. In this exercise, you want the image to remain motionless until a dynamic field is applied to the fluid. To do this, you’ll need to change the Buoyancy property of the fluid and then set the initial state of the fluid container so that the image of the skull and crossbones is present when the animation starts.
jollyRoger_v01.ma
scene from the chapter15scenes
folder at the book’s web page.Rewind and play the animation.
You should see the image of the skull and crossbones clearly at the start of the animation, and it should remain motionless as the animation plays.
Select fluid1, and choose Fields/Solvers ➣ Volume Axis. By selecting fluid1 before creating a field, you ensure that the field and the fluid are automatically connected.
In this exercise, imagine that the field is a cannonball moving through the ghostly image of the skull and crossbones.
jollyRoger_v02.ma
.To see a version of the scene up to this point, open the jollyRoger_v02.ma
scene from the chapter15scenes
folder at the book’s web page. You will need to create a new cache for this scene in order to see the effect.
If you decide to try rendering this scene, make sure that the Primary Visibility setting of the NURBS plane is turned off in Render Stats of the plane’s Attribute Editor; otherwise, the plane will be visible in the render.
Now that you have had a little practice working with containers, the next section explores some of the settings more deeply as you create an effect using 3D fluid containers and emitters.
Three-dimensional fluid containers work just like 2D containers, except they have depth as well as width and height. Therefore, they are computationally much more expensive. If you double the resolution in X and Y for a 2D container, the number of voxels increases by a factor of 4 (2 × 2); if you double the resolution of a 3D container, the number of voxels increases by a factor of 8 (2 × 2 × 2). A good practice for working with 3D containers is to start at a low resolution, such as 20 × 20 × 20, and increase the resolution gradually as you develop the effect.
Choose Fluids ➣ 3D Container.
You’ll see the 3D container appear in the scene. You’ll see a small grid on the bottom of the container. The size of the squares in the grid indicates the resolution (in X and Z) of the container.
At the top of the Container Properties rollout for the fluidShape1 node, you’ll see that the Keep Square Voxels option is selected. As long as this option is on, you can change the resolution of the 3D grid for all three axes using the Base Resolution slider. If Keep Voxels Square is off, you can use the Resolution fields to set the resolution along each axis independently.
You’ll also see three fields that can be used to determine the size of the 3D grid. You can use the Scale tool to resize the fluid container, but it’s a better idea to use the Size setting in the fluid’s shape node. This Size setting affects how dynamic properties (such as Mass and Gravity) are calculated within the fluid. Using the Scale tool does not affect these calculations, so increasing the scale of the fluid using the Scale tool may not give you the results you want. It depends on what you’re trying to accomplish, of course. If you look at the Blast.ma
example in the Visor, you’ll see that the explosion effect is actually created by animating the Scale X, Y, and Z channels of the fluid container.
There’s no better way to gain an understanding of how fluids work than by designing an effect directly. In this section, you’ll learn how emitters and fluid settings work together to create flame and smoke. You can simulate a reaction within the 3D container as if it were a miniature chemistry lab.
In the first part of this section, you’ll use a polygon plane to emit fuel into a container. A second surface, a polygon sphere, is also introduced and used to emit heat into the same container as the fuel.
Play the simulation. The results at frame 40 are shown in Figure 15.9.
This creates the potential for an explosive situation. To complete the effect, drop a dynamically driven sphere emitting temperature onto the plane.
Scale Z: 0.25
gasolineFire_v01.ma
.To see a version of the scene up to this point, open the gasolineFire_v01.ma
scene from the chapter15scenes
folder at the book’s web page.
To get the density to take on the look of flames, you need to add heat. By emitting temperature into the container, you can use it to drive the incandescence of the fluid. The next steps take you through the process:
gasolineFire_v01.ma
scene from the chapter15scenes
folder at the book’s web page.Under the Opacity rollout, change Opacity Input to Temperature.
You can edit the Opacity ramp by adding points to the curve. Just like the Incandescence ramp, the left side of the curve controls opacity based on lower temperatures, whereas the right side controls the opacity of higher temperatures. You can experiment with this ramp to shape the way the flames look.
Scroll up toward Contents Details, and open the Velocity rollout. Change Swirl to 5 and Noise to 0.343. This makes the flame waver and flicker.
Velocity pushes fluids around within a container. You can add velocity as a constant force to push fluids in a particular direction, or you can use an emitter. The Swirl setting adds rolling and swirling motion to the contents of a container. In the current example, the flames are already rising to the top of the container because of the Buoyancy setting, so you’ll use Velocity to add swirl.
gasolineFire_v02.ma
.To see a version of the scene up to this point, open the gasolineFire_v02.ma
scene from the chapter15scenes
folder at the book’s web page.
Reactions can cause several things to happen. In this example, you want the fuel to appear as if it has caught on fire. This is achieved by using the ignited fuel to add heat and color to the fluid.
gasolineFire_v02.ma
scene from the chapter15scenes
folder at the book’s web page.Expand the Contents Details ➣ Fuel rollout. Use the values from Figure 15.14 for the Fuel settings.
Press the 6 key to switch to Shaded mode. Play the simulation. Shortly after the ball hits the ground plane, the fuel is ignited (see Figure 15.15).
You can think of the fuel emitter as a gas leak inside the container. As the temperature and the fuel come within close proximity to each other, a reaction takes place. The fuel burns until the fuel is exhausted or the temperature is lowered. Since the fuel is being emitted from the plane into the container, the flame keeps burning.
You can alter how the fuel ignites and burns by adjusting the fuel attributes. Here is an explanation of some of the parameters:
Reaction Speed Determines how fast the reaction takes place once the heat ignites the fuel. Higher values produce faster reactions.
Air/Fuel Ratio Fire needs air to burn. This setting increases the amount of air in the container, causing the fuel to burn in a different manner. Gasoline requires 15 times more air than fuel. To simulate a gas fire, use a value of 15.
Ignition Temperature This option sets the minimum temperature required to ignite the fuel. If you want to create a reaction that occurs regardless of temperature, set this value to a negative number such as –0.1.
Heat Released This option causes the reaction to add more temperature to the fluid container.
Light Released This option adds a value to the current Incandescent value of the fluid, which causes the fluid to glow brightly when rendered.
Light Color This option specifies the color of the light to be released. You can easily add a blue tinge to the flame by changing the light color.
Try experimenting with the various parameters to see their effects on the simulation.
You’ll notice that, as the simulation plays, the flame and smoke appear trapped within the walls of the 3D container. This is because, by default, containers have boundaries on all sides. You can remove these boundaries to let the contents escape. Be aware that, as the contents leave the container, they will disappear since fluid simulations cannot exist outside the fluid container (2D or 3D).
gasolineFire_v03.ma
.To see a version of the scene up to this point, open the gasolineFire_v03.ma
scene from the chapter15scenes
folder at the book’s web page.
Fluids can interact directly with polygon and NURBS surfaces in several ways. In the “Emitting Fluids from a Surface” section earlier, a plane was used to emit fluid. You can also use a surface to give a fluid its initial shape. In the next example, you will fill a polygon model in the shape of ice cream to create a melting ice cream effect. To enhance the effect further, a modeled ice cream cone will be used as a collision object for the melting ice cream.
iceCreamCone_v01.ma
scene from the chapter15scenes
folder at the book’s web page. You are presented with two separate models—the ice cream and the cone—each on its own layer (see Figure 15.16).The surface now emits the fluid when you play the simulation; however, the goal is to have the fluid take on the shape of the ice cream. To make this happen, select the emitter and select Fill Object under the Basic Emitter Attributes rollout (see Figure 15.18).
Turn off the visibility of the ICE_CREAM layer; then click the Play button to see the fluid take the shape of the geometry. Figure 15.19 shows the results.
Save the scene as iceCreamCone_v02.ma
.
To see a version of the scene up to this point, open the iceCreamCone_v02.ma
scene from the chapter15scenes
folder at the book’s web page.
iceCreamCone_v02.ma
scene from the chapter15scenes
folder at the book’s web page.iceCreamCone_v03.ma
.To see a version of the scene up to this point, open the iceCreamCone_v03.ma
scene from the chapter15scenes
folder at the book’s web page.
Fluid simulations can be rendered using Maya Software or mental ray®, with identical results for the most part. Because fluids have an incandescent value, they can be used as light-emitting objects when rendering with Final Gathering. If you want the fluid to appear in reflections and refractions, you need to turn on the Visible In Reflections and Visible In Refractions options in the Render Stats section of the fluid’s shape node.
This section demonstrates some ways in which the detail and the shading of fluids can be improved when rendered.
Fluids can react to lighting in the scene, and you can apply self-shadowing to increase the realism. As an example of how to light fluids, a scene with simple clouds has been created for you to experiment with:
simpleCloud_v01.ma
scene from the chapter15scenes
folder at the book’s web page.Play the animation to frame 100. A simple cloud appears in the center of the scene.
The scene contains a fluid container, an emitter, a plane, and a light. The scene is already set to render using mental ray at production quality.
Select the fluid1 node, and open the Attribute Editor to the fluidShape1 tab. Scroll down to the Lighting section at the bottom of the editor.
The Lighting section contains two main settings: Self Shadow and Real Lights. When Real Lights is off, the fluids are lit from a built-in light. Maya has three Light Type options when using an internal light: Directional, Point, and Diagonal. Using an internal light will make rendering faster than using a real light.
When using a Directional internal light type, you can use the three fields labeled Directional Light to aim the light. The Diagonal internal light is the simplest option; it creates lighting that moves diagonally through the x- and y-axes of the fluid. The Point internal light is similar to using an actual point light; it even lets you specify the position of the light and has options for light decay just like a regular point light. These options are No Decay, Linear, Quadratic, and Cubic. For more information on light decay, consult Chapter 7, “Lighting with mental ray.”
You can use the options for Light Color, Brightness, and Ambient Brightness to modify the look of the light. Ambient Diffusion will affect the look of the cloud, regardless of whether you use internal or real lights. Ambient Diffusion controls how the light spreads through the fluid and can add detail to shadowed areas.
Create a test render, and store the render in the Render View window (see Figure 15.25, middle image).
Shadow Diffusion controls the softness of self-shadowing, simulating light scattering. Unfortunately, it can be seen only in the viewport. This effect will not appear when rendering with software (Maya Software or mental ray). The documentation recommends that, if you’d like to use Shadow Diffusion, you render a playblast and then composite the results with the rest of your rendered images using your compositing program.
simpleCloud_v02.ma
.When you render using Real Lights, the fluid casts shadows onto other objects as well as itself. When rendering using real shadow-casting lights, make sure that Self Shadow is disabled to avoid calculating the shadows twice. You can see that rendering with Real Lights does take significantly longer than using the built-in lighting and shadowing. Take this into consideration when rendering fluid simulations.
To see a version of the final scene, open the simpleCloud_v02.ma
scene from the chapter15scenes
folder at the book’s web page.
Fluids and nParticles can work together in combination to create a near-limitless number of interesting effects. You can use nParticles as fluid emitters, and you can also use a fluid to affect the movement of nParticles as if it were a field. Next we’ll cover two quick examples that show you how to make the systems work together.
In this section, you’ll see how you can emit fluids into a 3D container using nParticles, and you’ll learn about the Auto Resize feature that can help you optimize calculations for fluids.
Open the rockWall_v01.ma
scene from the chapter15scenes
folder at the book’s web page. Rewind and play the scene.
In this scene, nParticles are emitted from a volume emitter. A rock wall has been modeled and turned into a collision object. If you watch the animation from camera1, you’ll see that the scene resembles the wall of a volcanic mountain during an eruption.
Rewind and play the simulation.
Auto Resize causes the fluid container to change its shape automatically to accommodate the fluid (see Figure 15.28). The Max Resolution slider sets a limit to the resolution. When you use Auto Resize, be mindful of the maximum size of the entire simulation; think about what will be within the rendered frame and what will be outside of it. You don’t want to waste resources calculating fluid dynamics that will never be seen in the final render.
The problem with this setup is that as the nParticles fall off the bottom edge of the rockWall collision object, the fluid container stretches downward to accommodate their position. Also, as the fluid rises, the container stretches upward to contain the fluid. There are a couple of strategies that you can use so that the Auto Resize feature does not stretch the container too far. These strategies are discussed in the following steps.
Set Buoyancy to 0.25 and Dissipation to 1.
These settings will keep the fluid from rising indefinitely, which will limit stretching of the fluid in the upward direction. They also help to keep the smoke trails left by the bouncing nParticles a little more defined.
To keep the fluid1 container from stretching downward forever, you can kill the nParticles as they fall off the bottom edge of the rockWall collision object. One way to do this is to lower the life span; however, this strategy can backfire because some of the nParticles that take longer to bounce down the wall may disappear within the camera view, which can ruin the effect. A better solution is to write an expression that kills the nParticles when they fall below a certain point on the y-axis.
In the Expression field, type lifespanPP=8;
.
This creation expression creates an overall lifespanPP so that each nParticle that is born will have a maximum life span of 8 seconds. This should be enough time so that slower-moving nParticles don’t die before leaving the frame.
Type the following into the Expression field:
vector $pPos = position;
float $yPos = $pPos.y;
if($yPos<-4)
{
lifespanPP=0;
}
This expression says that if the Y position of the nParticle is less than –4, then the nParticle’s life span is 0 and the nParticle dies. You need to jump through a few small hoops to get this to work properly. First, you need to access the Y position of the nParticle—which, because of the expression syntax in Maya, cannot be done directly. In other words, you can’t just say if(position.y<-4)
. Instead, you have to set up some variables to get to the Y position. That’s just a quirk of the expression syntax. Thus the first line of the expression creates a vector variable called $pPos
that holds the position of the nParticle. The second line creates a float variable called $yPos
that retrieves the Y value of the $pPos
vector variable. Now you can use $yPos
in the if
statement as a way to access the Y position of each nParticle. In Figure 15.29, you can see the setup of two different expressions applied to the same attribute. The expression on the left is applied at the particle’s creation while the expression on the right is applied at runtime before dynamics. For more information on nParticle expressions, consult Chapter 12.
rockWall_v02.ma
.To see a version of the scene up to this point, open rockWall_v02.ma
from the chapter15scenes
folder at the book’s web page.
To finish the look, you can edit the fluid settings so that the trails left by the nParticles look like flames.
rockWall_v02.ma
scene from the chapter15scenes
folder at the book’s web page.Heat Released: 1
Since Ignition Temperature is at –1, a reaction should occur regardless of how much temperature is released.
In the Shading section, set Transparency to a dark gray, and set Glow Intensity to 0.1.
When rendering a sequence using a glow, you should always deselect the Auto Exposure setting in the shaderGlow1 node to eliminate flickering that may occur when the animation is rendered.
Rewind and play the animation. You should see flaming trails left behind each nParticle (see Figure 15.30).
You can improve the look by experimenting with the settings, as well as by increasing the Base Resolution and Max Resolution settings in the Auto Resize section.
rockWall_v03.ma
.To see a version of the scene up to this point, open the rockWall_v03.ma
scene from the chapter15scenes
folder at the book’s web page.
Creating believable water or liquid effects in the past required a mixture of particle and fluid simulations. This was a difficult process that fell short on functionality and realism. To solve this problem, Maya 2015 introduced Bifrost, a procedural engine specifically designed for liquid effects. Bifrost’s predecessor was Exotic Matter’s Naiad. Autodesk acquired the Naiad fluid-simulation software in 2012.
The Bifrost engine differs from Maya Fluids and particle simulations by using a FLIP solver. A FLIP solver is a hybrid of sorts, using features from both particle systems and fluid simulations. As a result, water volume and splashing effects are handled with the same solver. The resulting liquid simulation is stable and highly accurate.
There are several components to a Bifrost liquid. Here is an explanation of the nodes and attributes required for a simulation:
Bifrost The bifrost node is the root of the simulation. It controls the display of the liquid in the viewport and is the conduit for all of the other nodes and attributes. The bifrost node is represented by a bounding box based on the overall size of your liquid (see Figure 15.31). As the dimensions of your liquid change, so does the size of the bifrost node.
bifrostLiquid This is the actual container for the liquid. Each container has its own solver settings allowing for independent control over start frame and gravity. The bifrostLiquid node is where you control the resolution or voxel size of the liquid. Figure 15.32 shows the bifrostLiquid icon.
bifrostMesh The bifrostMesh node exists so that the liquid can be converted to polygon geometry. Rendering the liquid as a mesh allows for advanced shading features not available in its particle or voxel form. You can turn the mesh on or off at any point during the simulation from within the bifrost node (see Figure 15.33).
Bifrost Emitter A liquid simulation cannot be created without an emitter. Any polygon geometry can be an emitter. When a mesh is used as an emitter, a new Bifrost rollout is added to its shape node. Figure 15.34 shows the additional attributes.
Liquid simulation with Bifrost requires very little effort since the solver handles all of the intricacies of the liquid’s motion. Furthermore, Bifrost is multithreaded and can take full advantage of your computer’s hardware. The following exercise takes you through the process of creating a Bifrost liquid simulation:
pool_v01.ma
scene from the chapter15scenes
folder at the book’s web page. The scene contains a diving platform, a container, a ball, and a pool. The pool is on a layer with its visibility turned off. The ball is a rigid-body simulation and designed to drop into the pool.Select bifrostliquid1. Notice the green bar at frame 1 in the timeline. Click Play. Two things happen. First, the animation plays based on the values in the Time slider. A yellow bar fills the timeline as the animation progresses. This bar signifies the uncached frames of the liquid simulation. The second thing is that the liquid begins to cache. The cached frames are represented by a green bar in the timeline that overlaps the yellow bar. If playback is set to Continuous, every loop of the animation will show more and more of the finished simulation. At any point, you can click the Stop button in the lower-right corner of the interface. The progress of the simulation is also displayed here (see Figure 15.36).
Liquid simulations are saved to a scratch cache. This allows you to watch the simulation at a decent frame rate. When you make a change to one of the bifrost nodes, the scratch cache is removed. Playing the simulation will generate a new scratch cache. Making changes to a secondary object, like a collider, does not cause the scratch to be removed. You can manually remove the scratch cache by choosing Bifrost ➣ Flush Scratch Cache.
During the simulation, the liquids spill onto the ground object and flow into empty space. Figure 15.37 shows the liquids at frame 210.
Liquid falling into the open air unnecessarily complicates the simulation. To prevent the liquid from traveling too far or off camera, you can introduce a kill plane. Select bifrost1 and choose Bifrost ➣ Killplane from the Add section.
pool_v02.ma
.To see a version of the scene up to this point, open the pool_v02.ma
scene from the chapter15scenes
folder.
You can render the liquid simulation in two ways. Voxel rendering is the default method. This is similar to how Maya Fluids render. As with Maya Fluids, you can also convert the simulation data into a polygon mesh. Mesh nodes are created along with the liquid; therefore, a separate conversion is not necessary. You can enable the mesh for a liquid at any point.
The Bifrost liquid is automatically assigned a shader. Enabling the mesh option for the liquid allows you to take full advantage of the shader’s features and different rendering techniques. The following example takes you through the steps to render a realistic-looking liquid:
pool_v02.ma
scene from the chapter15scenes
folder at the book’s web page.Select liquid1 from under the bifrostLiquid1 hierarchy. In the Channel Box, set Meshing Enable to On. A polygon mesh is created, matching the particle volume.
With the mesh turned on, your simulation will run slower. However, the liquid is already cached. This means that you can skip frames to see the results of the mesh.
Most of the default values of the liquid material are already set for a convincing water look. Look at the Reflection rollout. Reflection Color is pure white and Reflection Weight is set to 1.0. These are good settings; however, the scene does not have an environment to reflect.
Select the Perspective camera and open its Attribute Editor. Choose the perspShape tab and expand the Environment rollout. Change Background Color to a sky blue. Render a test frame to see the water reflect the blue sky (see Figure 15.42).
pool_v03.ma
.To see a version of the scene, open the pool_v03.ma
scene from the chapter15scenes
folder at the book’s web page. You can also watch the rendered version of the simulation from the chapter15movies
folder.
You can control the shape of a liquid simulation by using guide geometry. The guide geometry can be static, animated, or even deformed. To optimize your scene, you can even use Alembic cached geometry. When a Bifrost liquid is being driven by guide geometry, only the liquid at the top of the guide is simulated. You can control the depth at which the liquid is simulated through a minimum simulation depth. Through guides, you can shape your liquid into virtually anything. The following example takes you through the steps of converting a motion-captured driven character into a liquid entity:
fight3.ma
into the Maya viewport.The ocean fluid effect uses a surface and a special Ocean shader to create a realistic ocean surface that can behave dynamically. The Ocean shader uses an animated displacement map to create the water surface. Ocean surfaces can take a while to render, so you should consider this when planning your scene.
You can find all of the controls needed to create the ocean on the oceanShader node. This node is created and applied automatically when you create an ocean. In this example, you’ll create the effect of a space capsule floating on the surface of the ocean:
capsule_v01.ma
scene from the chapter15scenes
folder at the book’s web page. This scene has the simple space capsule model used in Chapter 12.In the Outliner, select the transform1 node and open the Attribute Editor. Switch to the oceanShader1 tab.
You’ll find all of the controls you need to change the way the ocean looks and behaves in the Ocean shader controls. Each control is described in the Maya documentation, but many of the controls are self-explanatory.
To make the ocean waves seem larger, increase Wave Length Max to 6. The wavelength units are measured in meters.
To make the ocean seem a little rougher, you can adjust the Wave Height edit curve. The Wave Height edit curve changes the wave height relative to the wavelength. If you edit the curve so that it slopes up to the right, the waves with longer wavelengths will be proportionally taller than the waves with shorter wavelengths. A value of 1 means that the wave is half as tall as it is long. When you edit this curve, you can see the results in the preview plane.
Wave Turbulence works the same way, so by making the curve slope up to the right, longer waves will have a higher turbulence frequency.
Wave Peaking creates crests on top of areas that have more turbulence. Turbulence must be a nonzero value for wave peaking to have an effect.
capsule_v02.ma
.To see a finished version of the scene, open the capsule_v02.ma
scene from the chapter15scenes
folder at the book’s web page.
This is a good start to creating a realistic ocean. Take a look at some of the ocean examples in the Visor to see more advanced effects.
Use fluid containers. Fluid containers are used to create self-contained fluid effects. Fluid simulations use a special type of particle that is generated in the small subunits (called voxels) of a fluid container. Fluid containers can be 2D or 3D. Two-dimensional containers take less time to calculate and can be used in many cases to generate realistic fluid effects.
Master It Create a logo animation that dissolves like ink in water.
Create a reaction. A reaction can be simulated in a 3D container by combining temperature with fuel. Surfaces can be used as emitters within a fluid container.
Master It Create a chain reaction of explosions using the Paint Fluids Tool.
Render fluid containers. Fluid containers can be rendered using Maya Software or mental ray. The fluids can react to lighting, cast shadows, and self-shadow.
Master It Render the
TurbulentFlame.ma
example in the Visor so that it emits light onto nearby surfaces.
Use fluids with nParticles. Fluid simulations can interact with nParticles to create a large array of interesting effects.
Master It nCloth objects use nParticles and springs to simulate the behavior of cloth. If fluids can affect nParticles, it stands to reason that they can also affect nCloth objects. Test this by creating a simulation where a fluid emitter pushes around an nCloth object.
Create water effects. Ocean effects are created and edited using the Ocean shader. Objects can float in the ocean using locators.
Master It Create an ocean effect that resembles stormy seas. Add the capsule geometry as a floating object.