Chapter 13. Introducing nParticles

This chapter introduces Maya's new nParticle dynamics and shows you how they can be used creatively to create a wide variety of visual effects. The example scenes demonstrate the fundamentals of working with and rendering particles. The subsequent chapters on Maya dynamics build on these techniques.

nParticles are new to Maya 2009. These nParticles are connected to the Nucleus solver system, a difference from traditional Maya particles. Nucleus is a unified dynamic system first introduced in Maya 8.5 as part of nCloth. The Nucleus solver is the brain behind the nDynamic systems in Maya.

In this chapter you will learn to:

  • Create nParticles

  • Make nParticles collide

  • Create liquid simulations

  • Emit nParticles from a texture

  • Move nParticles with nucleus wind

  • Use the Hardware Render Buffer

  • Use force fields

  • Render nParticles with mental ray

Creating nParticles

nParticles can do just about everything that traditional Maya particles can do plus a lot more. Furthermore, they can create much more sophisticated simulations without relying on complex expressions. For this reason, the exercises in this book focus on nParticles and the nDynamic systems. The traditional particle and rigid body systems have not changed since older versions of Maya and aren't as powerful as the Nucleus systems. If you're familiar with traditional Maya particles, you'll see some similarities when using nParticles.

When you create an nParticle object or an nCloth object, or both, in a scene, a Nucleus solver is created. The same solver is used to calculate the dynamics and interactions within the nParticle system and the nCloth system. A scene can have more than one Nucleus solver, but nDynamic systems using two different solvers can't directly interact. However, two separate nParticle objects using the same Nucleus solver can interact.

In this chapter, several exercises demonstrate the possibilities of nParticle systems. Other Nucleus systems are covered in Chapters 14 and 15.

There are a number of ways to create nParticles in a scene. You can draw them on the grid, use an emitter to spawn them into a scene, use a surface as an emitter, or fill a volume with nParticles. When you create an nParticle object, you also need to specify the nParticle's style.

Choosing a style activates one of a number of preset settings for the nParticle's attributes, all of which can be altered after you add the nParticle object to the scene. The nParticle styles include balls, points, cloud, thick cloud, and water. The following exercises take you through the process of using the different nParticle creation methods and introduce you to working with the Nucleus solver.

Drawing nParticles Using the nParticle Tool

The simplest way to create nParticles is to draw them on the grid using the nParticle tool.

  1. Create a new scene in Maya. Switch to the nDynamics menu set.

  2. Choose nParticles

    Drawing nParticles Using the nParticle Tool
  3. Choose Create nParticles

    Drawing nParticles Using the nParticle Tool
  4. Press the Enter key on the numeric keypad to create the particles.

    You'll see several circles on the grid. The ball-type nParticle style automatically creates blobby surface particles. Blobby surfaces are spheres rendered using Maya Software or mental ray. Blobby surfaces use standard Maya shaders when rendered and can be blended together to form a gooey surface.

    Use the nParticle menu to specify the nParticle style.

    Figure 13.1. Use the nParticle menu to specify the nParticle style.

  5. Set the length of the timeline to 600. Rewind and play the animation. The particles will fall in space.

  6. Open the Attribute Editor for the nParticle1 object, and switch to the nucleus1 tab. The settings on this tab control the Nucleus solver, which sets the overall dynamic attributes of the connected nDynamic systems (see Figure 13.2).

  7. By default a Nucleus solver has Gravity enabled. Enable Use Plane in the Ground Plane settings (Figure 13.3). This creates an invisible floor that the nParticles can rest on. Set the Plane Origin's Translate Y to −1.

    The settings on the nucleus1 tab define the behavior of the environment for all connected nDynamic nodes.

    Figure 13.2. The settings on the nucleus1 tab define the behavior of the environment for all connected nDynamic nodes.

    The ground plane creates an invisible floor that keeps the nParticles from falling.

    Figure 13.3. The ground plane creates an invisible floor that keeps the nParticles from falling.

  8. The Nucleus solver also has wind settings. Set Wind Speed to 3 and Wind Noise to 4. By default Wind Direction is set to 1, 0, 0 (Figure 13.4). The fields correspond to the X, Y, and Z axes, so this means that the nParticles will be blown along the positive X axis. Rewind and play the animation. Now the nParticles are moving along with the wind, and a small amount of turbulence is applied.

    The settings for Air Density, Wind Speed, Wind Direction, and Wind Noise are found under the Nucleus solver's attributes.

    Figure 13.4. The settings for Air Density, Wind Speed, Wind Direction, and Wind Noise are found under the Nucleus solver's attributes.

By increasing the Air Density value, you adjust the atmosphere of the environment. A very high setting is a good way to simulate an underwater environment. Using wind in combination with a high air density pushes the nParticles with more force; this makes sense since the air is denser.

The Solver Attributes section sets the quality of the solver. The Substeps setting specifies how many times per frame the solver calculates nDynamics. Higher settings are more accurate but can slow down performance. Increasing the Substeps value may alter some of the ways in which nDynamics behave, such as how they collide with each other and other objects, so when you increase this value, be aware that you may need to adjust other settings on your nDynamic nodes.

The Scale Attributes section has sliders for adjusting both Time Scale and the Space Scale. Use Time Scale to speed up or slow down the solver. Values below 1 slow down the simulation; higher values speed it up. If you increase Time Scale, you should increase the number of substeps in the Solver Attributes section to ensure that the simulation is still accurate. Time Scale can be keyframed to create the "bullet time" effect made famous in The Matrix movies.

Space Scale scales the environment of the simulation. By default nDynamics are calculated in meters even if the Maya scene unit is set to centimeters. You should set this to 0.1 if you need your nDynamics simulation to behave appropriately when the Maya scene units are set to centimeters. This is more noticeable when working with large simulations. You can also use this setting creatively to exaggerate effects or when using more than one Nucleus solver in a scene. For the following examples, leave Space Scale set to 1.

Spawning nParticles from an Emitter

An emitter shoots nParticles into the scene, like a sprinkler shooting water onto a lawn. When a particle is emitted into a scene it is "born" at that moment, and all calculations based on its age begin from the moment it is born.

  1. Continue with the scene from the previous section. Add an emitter to the scene by choosing nParticles

    Spawning nParticles from an Emitter
  2. Open the Attribute Editor for the emitter1 object, and set Rate to 10. Set Emitter Type to Omni.

  3. Rewind and play the scene. The omni emitter spawns particles from a point at the center of the grid. Note that after the particles are born, they collide with the ground plane and are pushed by the nucleus wind in the same direction as the other particles (see Figure 13.5).

    The new nParticles are connected to the same Nucleus solver. If you open the Attribute Editor for the nParticle2 object, you'll see the tabs for nucleus1 and nParticle2, as well as the tab for nParticle1. If you change the settings on the nucleus1 tab, both nParticle1 and nParticle2 are affected.

    A second nParticle system is spawned from an emitter. These nParticles also collide with the ground plane and are pushed by the wind.

    Figure 13.5. A second nParticle system is spawned from an emitter. These nParticles also collide with the ground plane and are pushed by the wind.

  4. Select nParticle2 and choose nSolver

    nParticle Tabs in the Attribute Editor
  5. Open the Outliner and, in the Outliner's Display menu, turn off DAG Objects Only. This allows you to see all the nodes in the scene. If you scroll down, you'll see nucleus1 and nucleus2 nodes (see Figure 13.6).

  6. Select nParticle2 and choose nSolver

    nParticle Tabs in the Attribute Editor
    The nucleus nodes are visible in the Outliner.

    Figure 13.6. The nucleus nodes are visible in the Outliner.

  7. Select emitter1 and set Emitter Type to Volume. In the emitter's Attribute Editor, set Volume Shape in the Volume Emitter Attributes section to Sphere. Use the Move tool to position the emitter above the ground plane. The emitter is now a volume, which you can scale up in size using the Scale tool (hot key = r). nParticles are born from random locations within the sphere (see Figure 13.7).

    The directional emitter type is similar to the omni and volume emitters in that it shoots nParticles into a scene. The directional emitter emits the nParticles in a straight line. The range of the directional emitter can be altered using the Spread slider, causing it to behave more like a sprinkler or fountain.

    Volume emitters spawn nParticles from random locations within the volume.

    Figure 13.7. Volume emitters spawn nParticles from random locations within the volume.

  8. Open the Attribute Editor to the nParticleShape1 tab. This is where you'll find the attributes that control particle behavior, and there are a lot of them. As an experiment, expand the Force Field Generation rollout and set Point Force Field to Worldspace.

  9. Rewind and play the animation. As the emitter spawns particles in the scene, a few nParticles from nParticle2 are attracted to nParticle1. NParticle1 is emitting a force field that attracts individual nParticles from nParticle2 like a magnet. You can also make the nParticles attract themselves by increasing the Self Attract slider (see Figure 13.8).

This is an example of how the Nucleus solver allows particles from two different particle objects to interact. The Force Field settings will be further explored in the section "Working with Force Fields" later in this chapter. If you switch nParticle2 to the nucleus2 solver, you will lose this behavior; only nParticles that share a solver can be attracted to each other. Be careful when using force fields on large numbers of nParticles (more than 10,000), as this will slow the performance of Maya significantly.

The Force Field settings cause one nParticle object to attract other nDynamic systems like a magnet.

Figure 13.8. The Force Field settings cause one nParticle object to attract other nDynamic systems like a magnet.

Emitting nParticles from a Surface

Polygon and NURBS surfaces can be used to generate nParticles as well.

  1. Create a new Maya scene. Create a polygon plane (Create

    Emitting nParticles from a Surface
  2. Scale the plane 25 units in X and Z.

  3. Switch to the nDynamics menu set. Set the nParticle style to Balls (nParticles

    Emitting nParticles from a Surface
  4. Choose nParticles

    Emitting nParticles from a Surface
    The options for creating a surface emitter

    Figure 13.9. The options for creating a surface emitter

  5. Set the timeline to 600.

  6. Open the Attribute Editor to the nucleus1 tab, and set Gravity to 0.

  7. Rewind and play the animation. Particles appear randomly on the surface.

  8. Open the Attribute Editor to the nParticle Shape tab. Expand the Particle Size rollout. Set Radius to 1.

  9. Click on the right side of the Radius Scale ramp to add a point. Adjust the position of the point on the left side of the ramp edit curve for Radius Scale so that it's at 0 on the left side and moves up to 1 on the right side (see Figure 13.10).

    The Radius Scale ramp curve adjusts the radius of the nParticles.

    Figure 13.10. The Radius Scale ramp curve adjusts the radius of the nParticles.

  10. Rewind and play the animation. The particles now scale up as they are born (by default Radius Scale Input is set to Age). Notice that adjacent particles push each other as they grow. The ball-style particle has Self Collision on by default, so the particles will bump into each other (see Figure 13.11).

  11. Set Radius Scale Randomize to 0.5. The balls each have a random size. By increasing this slider, you increase the random range for the maximum radius size of each nParticle.

  12. Set Input Max to 3. This sets the maximum range along the X axis of the Radius Scale ramp. Since Radius Scale Input is set to Time, this means each nParticle takes 3 seconds to achieve its maximum radius, so they slowly grow in size.

    The balls scale up as they are born and push each other as they grow.

    Figure 13.11. The balls scale up as they are born and push each other as they grow.

Filling an Object with nParticles

An object can be instantly filled with particles. Any modeled polygon mesh can hold the nParticles as long as it has some kind of depression in it. A flat plane, on the other hand, can't be used.

  1. Open the forge_v01.ma scene from the chapter13scenes folder on the DVD. You'll see a very simple scene consisting of a tub on a stand. A bucket is in front of the tub. The tub will be used to pour molten metal into the bucket.

  2. Set the nParticle style to Water by choosing nParticles

    Filling an Object with nParticles
  3. Select the tub object and choose Create nParticles

    Filling an Object with nParticles
    Select the tub object is selected, and it will be filled with nParticles.

    Figure 13.12. Select the tub object is selected, and it will be filled with nParticles.

  4. Set the display to Wireframe. You'll see a few particles stuck in the rim of the tub. If you play the scene, the particles fall through space.

    There are two problems. The first problem is that the object has been built with a thick wall, so Maya is trying to fill the inside of the surface with particles rather than the well in the tub. The second problem is that the tub is not set as a collision surface (see Figure 13.13).

  5. Select the nParticle1 object in the Outliner and delete it. Note that this does not delete the nucleus1 solver created with the particle, and that's okay; the next nParticle object you create will be automatically connected to this same solver.

    There are a couple solutions to this problem. When you create the nParticle object, you can choose Double Walled in the Fill Object options, which in many cases solves the problem for objects that have a simple shape, such as a glass. For more convoluted shapes the nParticles may try to fill different parts of the object. For instance, in the case of the tub, as long as the Resolution setting in the options is at 10 or below, the tub will fill with nParticles just fine (increasing Resolution increases the number of nParticles that will fill the volume). However, if you create a higher-resolution nParticle, you'll find that nParticles are placed in the well of the tub and on the handles where the tub is held by the frame.

    The nParticles lodge within the thick walls of the tub.

    Figure 13.13. The nParticles lodge within the thick walls of the tub.

    Another solution is to split the polygons that make up the object so that only the parts of the tub that actually collide with the nParticles are used to calculate how the nParticles fill the object.

  6. Switch to shaded view. Select the tub object, and move the view so you can see the bottom of its interior.

  7. Chose the Paint Selection tool, right-click on the tub, and choose Face to switch to face selection. Use the Paint Selection tool to select the faces at the very bottom of the tub (see Figure 13.14).

    Select the faces at the bottom of the tub with the Paint Selection tool.

    Figure 13.14. Select the faces at the bottom of the tub with the Paint Selection tool.

    Expand the selection to include all the faces up to the rim of the tub.

    Figure 13.15. Expand the selection to include all the faces up to the rim of the tub.

  8. Hold the Shift key and press the > key on the keyboard to expand the selection. Keep pressing the > key until all the interior polygons are selected up to the edge of the tub's rim (see Figure 13.5).

  9. Switch to wireframe mode, and make sure none of the polygons on the outside of the tub have been selected by accident. Hold the Ctrl key and select any unwanted polygons to deselect them.

  10. Switch to the Polygon menu set and choose Mesh

    Expand the selection to include all the faces up to the rim of the tub.
  11. Select the polysurface1 and polysurface2 nodes, and choose Edit

    Expand the selection to include all the faces up to the rim of the tub.
  12. Name the interior mesh insideTub and the exterior mesh outsideTub.

  13. Switch to the nDynamics menu set. Select the insideTub mesh, and choose nParticles

    Expand the selection to include all the faces up to the rim of the tub.
  14. In the options, set Solver to nucleus1, and set Resolution to 15.

    The Fill Bounds settings determine the minimum and maximum boundaries within the volume that will be filled. In other words, if you want to fill a glass from the middle of the glass to the top, leaving the bottom half of the glass empty, set the minimum in Y to 0.5 and the maximum to 1 (the nParticles would still drop to the bottom of the glass if Gravity were enabled, but for a split second you would confuse both optimists and pessimists).

    Split the tub into two separate mesh objects using the Extract command.

    Figure 13.16. Split the tub into two separate mesh objects using the Extract command.

  15. Leave all the Fill Bounds settings at the default. Turn off Double Walled and Close Packing. Click Particle Fill to apply it. After a couple seconds you'll see the tub filled with little blue spheres (see Figure 13.17).

  16. Rewind and play the animation. The spheres drop through the bottom of the tub. To make them stay within the tub, you'll need to create a collision surface.

    The inside of the tub is filled with nParticles.

    Figure 13.17. The inside of the tub is filled with nParticles.

nParticle Collisions

nParticles collide with nCloth objects, passive collision surfaces, and other nParticle objects. They can also be made to self-collide; in fact, when the ball-style nParticle is chosen, Self Collision is on by default. To make an nParticle collide with an ordinary rigid object, you need to convert the collision surface into a passive collider. The passive collider can be animated as well.

Passive Collision Objects

Passive collision objects, also known as nRigids, are automatically connected to the current Nucleus solver when they are created.

  1. Rewind the animation and select the insideTub mesh. Choose nMesh

    Passive Collision Objects
  2. Play the animation. You'll see the nParticles drop down and collide with the bottom of the tub. They'll slosh around for awhile and eventually settle.

    When creating a collision between an nParticle and a passive collision surface, there are two sets of controls you can tune to adjust the way the collision happens. Collision settings on the nParticle shape control how the nParticle reacts when colliding with surfaces, and collision settings on the passive object control how objects react when they collide with it.

    For example, if you dumped a bunch of basketballs and Ping-Pong balls on a granite table and a sofa, you would see that the table and the sofa have their own collision behavior based on their physical properties, and the Ping-Pong balls and basketballs also have their own collision behavior based on their physical properties. When a collision event occurs between a Ping-Pong ball and the sofa, the physical properties of both objects are factored together to determine the behavior of the Ping-Pong ball at the moment of collision. Likewise a basketball has its own physical properties that are factored in with the same sofa properties when a collision occurs between the sofa and a basketball.

    The nDynamics systems have a variety of ways to calculate collisions as well as ways to visualize and control the collisions between elements in the system.

  3. Select the nRigid node in the Outliner, and switch to the nRigidShape1 tab in the Attribute Editor. Expand the Collisions rollout.

    The Collide option turns collisions on or off for the surface. It's sometimes useful to temporarily disable collisions when working on animating objects in a scene using nDynamics. Likewise the Enable option above the Collisions rollout disables all nDynamics for the surface when it is unchecked.

  4. Set the Solver Display option to Collision Thickness. Turning this option on creates an interactive display so you can see how the collisions for this surface are calculated (see Figure 13.18).

  5. Switch to wireframe view (hot key = 4). Move the Thickness slider back and forth, and the envelope grows and shrinks, indicating how thick the surface will seem when the dynamics are calculated.

    You can display the collision surface thickness using the controls in the nRigid body shape node.

    Figure 13.18. You can display the collision surface thickness using the controls in the nRigid body shape node.

    The thickness will not change its appearance when rendered, only how the nParticles will collide with the object. A very high Thickness value makes it seem as though there is an invisible force field around the object.

  6. Switch back to smooth shaded view (hot key = 5). Collision Flag is set to Face by default, meaning that collisions are calculated based on the faces of the collision object. This is the most accurate but slowest way to calculate collisions.

  7. Set Collision Flag to Vertex. Rewind and play the animation. You'll see the thickness envelope drawn around each vertex of the collision surface.

    The nParticles fall through the bottom of the surface, and some may collide with the envelopes around the vertices on their way through the bottom. The calculation of the dynamics is faster, though. This setting may work well for dense meshes, and it will calculate much faster than the Face method.

  8. Set Collision Flag to Edge; rewind and play the animation. The envelope is now drawn around each edge of the collision surface, creating a wireframe network (see Figure 13.19).

    The calculation is much faster than when Collision Flag is set to Face, but the nParticles stay within the tub. You may notice some bumping as the nParticles collide with the wireframe. Many times this may not be noticeable at all, which makes the Edge method useful for calculating collisions.

    When Collision Flag is set to Vertex, the nParticles collide with each vertex of the collision surface, allowing some to fall through the bottom. When the flag is set to Edge, the nParticles collide with the edges and the calculation speed improves.

    Figure 13.19. When Collision Flag is set to Vertex, the nParticles collide with each vertex of the collision surface, allowing some to fall through the bottom. When the flag is set to Edge, the nParticles collide with the edges and the calculation speed improves.

    The other settings in the Collisions section include:

    Bounce

    Controls how high the nParticles bounce off the surface. Think of the Ping-Pong balls hitting the granite table and the sofa. The sofa would have a much lower Bounce setting than the granite table.

    Friction

    A smooth surface has a much lower Friction setting than a rough one. nParticles will slide off a smooth surface more easily. If the sofa was made of suede, the friction would be higher than for the smooth granite table.

    Stickiness

    Pretty self explanatory—if the granite table were covered in honey, the Ping-Pong balls would stick to it more than to the sofa, even if the friction is lower on the granite table. The behavior of the nParticles sticking to the surface may be different if Collision Flag is set to Face than if it is set to Edge or Vertex.

  9. Make sure that Collision Flag is set to Edge and that Bounce, Friction, and Stickiness are set to 0. Set Collision Thickness to 0.05.

  10. Select the nParticle1 object, and open the Attribute Editor to the nParticleShape1 tab. Expand the Collisions rollout for the nParticle1 object. These control how the nParticles collide with collision objects in the scene.

  11. Click on the Display Color swatch to open the Color Chooser, and pick a red color. Set Solver Display to Collision Thickness. Now the nParticles each have a red envelope around them. Changing the color of the display makes it easier to distinguish from the nRigid collision surface display.

  12. Set Collide Width Scale to 0.25. The envelope becomes a dot inside each nParticle. The nParticles have not changed size, but if you play the animation, you'll see that they fall through the space between the edges of the collision surface (see Figure 13.20).

    Reducing the Collide Width Scale value of the nParticles causes them to fall through the spaces between the edges of the nRigid object.

    Figure 13.20. Reducing the Collide Width Scale value of the nParticles causes them to fall through the spaces between the edges of the nRigid object.

  13. Scroll down to the Liquid Simulation tab and uncheck Enable Liquid Simulation. This makes it easier to see how the nParticles behave when self-collision is on. The Liquid Simulation settings alter the behavior of nParticles; this is covered later in the chapter.

  14. Turn on Self Collide and set Solver Display to Self Collision Thickness.

  15. Set Collide Width Scale to 1 and Self Collide Width Scale to 0.1. Turn on wireframe view (hot key = 4) and play the animation; watch it from a side view.

    The nParticles have separate Collision Thickness settings for collision surfaces and self-collisions. Self Collide Width Scale is relative to Collide Width Scale. Increasing Collide Width Scale also increases Self Collide Width Scale (see Figure 13.21).

    Reducing the Self Collide Width Scale value causes the nParticles to overlap as they collide.

    Figure 13.21. Reducing the Self Collide Width Scale value causes the nParticles to overlap as they collide.

  16. Scroll up to the Particle Size settings and adjust the Radius; set it to 0.8. Both Collide Width Scale and Self Collide Width Scale are relative to the radius of the nParticles. Increasing the radius can cause the nParticles to pop out of the top of the tub.

  17. Set Radius to 0.4 and Collide Width Scale to 1, and turn off Self Collide. Turn Enable Liquid Simulation back on.

    The nParticles also have their own Bounce, Friction, and Stickiness settings. The Max Self Collide Iterations slider sets a limit on the number of calculated self-collisions per substep when Self Collide is on. This keeps the nParticles from locking up or the system from slowing down too much. If you have a lot of self-colliding nParticles in a simulation, lowering this value can increase performance.

    The Collision Layer setting sets a priority for collision events. If two nDynamic objects using the same Nucleus solver are set to the same Collision Layer value, they will collide normally. If they have different layer settings, those with lower values will receive higher priority. In other words, they will be calculated first in a chain of collision events. Both nCloth and passive objects will collide with nParticles in the same or higher collision layers. So if the passive collision object has a Collision Layer setting of 10, an nParticle with a Collision Layer setting of 3 will pass right through it, but an nParticle with a Collision Layer value of 12 won't.

  18. Save the scene as forge_v02.ma. To see a version of the scene so far, open forge_v02.ma from the chapter13scenes folder on the DVD.

Liquid Simulation

You can make nParticles simulate the behavior of fluids by enabling the Liquid Simulation attribute in the particle's shape node or by creating the nParticle as a water object. In this exercise you'll use a tub filled with nParticles. The tub will be animated to pour out the nParticles, and their behavior will be modified to resemble hot molten metal.

Creating Liquid Behavior

Liquid simulations have unique properties that differ from other styles of nParticle behavior. This behavior is actually amazingly easy to set up and control.

  1. Continue with the scene from the last section or open the forge_v02.ma scene from the chapter13scenes folder on the DVD. In this scene the tub has already been filled with particles, and collisions have been enabled.

  2. Select nParticle1 in the Outliner and name it moltenMetal. Open its Attribute Editor to the moltenMetalShape tab. Expand the Liquid Simulation rollout (Figure 13.22).

    Turning on Enable Liquid Simulation causes the nParticles to behave like water.

    Figure 13.22. Turning on Enable Liquid Simulation causes the nParticles to behave like water.

    Liquid simulation has already been enabled because the nParticle style was set to Water when the nParticles were created. If you need to remove the liquid behavior from the nParticle, you can uncheck the Enable Liquid Simulation checkbox; for the moment, leave the box checked.

  3. Switch to a side view and turn on wireframe mode. Play the animation and observe the behavior of the nParticles.

    If you look at the Collisions settings for moltenMetal, you'll see that the Self Collide attribute is off, but the nParticles are clearly colliding with each other. This type of collision is part of the liquid behavior defined by the Incompressibility attribute (this is discussed a little later in the chapter).

  4. Play the animation back several times; notice the behavior when:

    • Enable Liquid Behavior is off.

    • Self Collide is on (set Self Collide Width Scale to 0.7).

    • Both Liquid Behavior and Self Collide are enabled.

  5. Turn Liquid Behavior back on and turn Self Collide off. Open the Particle Size rollout, and set Radius to 0.25; play the animation. There seems to be much less fluid for the same number of particles when the radius size is lowered.

  6. Play the animation for about 140 frames until all the nParticles settle. With the moltenMetal shape selected, choose nSolvers

    Turning on Enable Liquid Simulation causes the nParticles to behave like water.
  7. Select moltenMetal. At the top of the Attribute Editor, uncheck Enable to temporarily disable the nParticle simulation so you can easily animate the tub.

  8. Select tub1 in the Outliner and switch to the side view. Select the Move tool (hot key = w). Hold the d key on the keyboard, and move the pivot for tub1 so it's aligned with the center of the handles that hold it in the frame (see Figure 13.24).

    Setting Initial State makes the nParticles start out from their settled position.

    Figure 13.23. Setting Initial State makes the nParticles start out from their settled position.

    Align the pivot point for the tub group with the handles from the side view.

    Figure 13.24. Align the pivot point for the tub group with the handles from the side view.

  9. Set the timeline to frame 20. In the Channel Box, select the Rotate X channel for the tub1 group node, right-click, and set a keyframe.

  10. Set the timeline to frame 100. Set the value of tub1's Rotate X channel to 85, and set another key. Move the timeline to frame 180, and set another keyframe.

  11. Set the timeline to 250, set Rotate X to 0, and set a fourth key.

  12. Select moltenMetal, and in the Attribute Editor, check the Enable checkbox. Rewind the animation and play it. The nParticles pour out of the tub like water (see Figure 13.25).

    When you animate the tub, the nParticles pour out of it like water.

    Figure 13.25. When you animate the tub, the nParticles pour out of it like water.

  13. Switch to the perspective view. When you play the animation, the water goes through the bucket and the floor. Select the bucket and Choose nMesh

    When you animate the tub, the nParticles pour out of it like water.
  14. By default the liquid simulation settings approximate the behavior of water. To create a more molten metal–like quality, increase Viscosity to 10. Viscosity sets the liquid's resistance to flow. Sticky, gooey, or oily substances have a higher viscosity.

  15. Set Liquid Radius Scale to 0.5. This sets the amount of overlap between nParticles when Liquid Simulation is enabled. Lower values create more overlap. By lowering this setting, the fluid looks more like a cohesive surface.

    The other settings in the Liquid Simulation rollout can be used to alter the behavior of the liquid:

    Incompressibility

    This setting determines the degree to which the nParticles resist compression. Most fluids use a low value (between 0.1 and 0.5). If you set this value to 0, all the nParticles will lie at the bottom of the tub in the same area, much like a nonliquid nParticle with Self Collide turned off.

    Rest Density

    This sets the overlapping arrangement of the nParticles when they are at rest. It can affect how "chunky" the nParticles look when the simulation is running. The default value of 2 works well for most liquids, but compare a setting of 0.5 to a setting of 5. At 0.5 fewer nParticles overlap, and they flow out of the tub more easily than when Rest Density is set to 5.

  16. To complete the behavior of molten metal, set Rest Density back to 2, and set Incompressibility to 0.5. In the Collisions rollout, set Friction to 0.5 and Stickiness to 0.25. Expand the Dynamic Properties rollout and increase Mass to 6. Note that you may want to reset the initial state after changing the settings because the nParticles will now collapse into a smaller area (see Figure 13.26).

  17. Save the scene as forge_v03.ma. To see a version of the scene to this point, open forge_v03.ma from the chapter13scenes folder.

    Adjusting the settings under Liquid Simulation, Collisions, and Dynamic Properties makes the nParticles behave like a heavy, slowmoving liquid.

    Figure 13.26. Adjusting the settings under Liquid Simulation, Collisions, and Dynamic Properties makes the nParticles behave like a heavy, slowmoving liquid.

Converting nParticles to Polygons

Maya 2009 introduces a way to convert nParticles into a polygon mesh. The mesh updates with the particle motion to create a smooth blob or liquidlike appearance, which is perfect for rendering fluids. In this section, you'll convert the liquid nParticles created in the previous section into a mesh to make a more convincing molten metal effect.

  1. Continue with the scene from the previous section or open the forge_v03.ma scene from the chapter13scenes folder on the DVD.

  2. Play the animation to about frame 160.

  3. Select the moltenMetal object in the Outliner, and choose Modify

    Converting nParticles to Polygons

    If you look at the particles, you'll see they are still there but a polygon mesh has been added to the scene. You can adjust the quality of this mesh in the Attribute Editor of the nParticle object used to generate the mesh.

  4. Select the moltenMetal object in the Outliner, and open the Attribute Editor to the moltenMetalShape tab. Expand the Shading rollout and set Opacity to 0.

    Converting an nParticle into a polygon creates a polygon mesh around the nParticle object.

    Figure 13.27. Converting an nParticle into a polygon creates a polygon mesh around the nParticle object.

    Lowering the opacity of the nParticles makes it easier to see the mesh. If you hide the nParticles or disable nParticles in the View menu of the viewport, the polygon mesh will not animate with the nParticles. The simulation has to be visible, so the easiest workaround is to make the nParticles completely transparent.

  5. In the Render Stats section of the Attribute Editor, turn off all the checkboxes. This ensures that the nParticles are not seen in the render.

  6. Expand the Output Mesh section. Set Threshold to 0.8 and Blobby Radius Scale to 1.8.

    These settings smooth the converted mesh. Higher Threshold settings create a smoother but thinner mesh; increasing Blobby Radius Scale does not affect the radius of the original nParticles. Rather it uses this value as a multiple to determine the size of the enveloping mesh around each nParticle. Using the Threshold and Blobby Radius Scale settings together you can fine-tune the look of the converted mesh.

  7. Set Motion Streak to 0.5. This stretches the mesh in areas where there is motion in the direction of the motion to create a more fluid-like behavior.

  8. Mesh Triangle Size determines the resolution of the mesh. Lowering this value increases the smoothness of the mesh but also slows down the simulation. Set this value to 0.3 for now, as shown in Figure 13.28. Once you're happy with the overall look of the animation, you can set it to a lower value. This way the animation continues to update at a reasonable pace.

Max Triangle Resolution sets a limit on the number of triangles used in the nParticle Mesh. If the number is exceeded during the simulation, Max Triangle Size is raised automatically to compensate.

Adjust the quality of the mesh in the Output Mesh section of the nParticle's shape node attributes.

Figure 13.28. Adjust the quality of the mesh in the Output Mesh section of the nParticle's shape node attributes.

Use Gradient Normals smoothes the normals of the mesh.

Mesh Method determines the shape of the polygons that make up the surface of the mesh. The choices are Cubes, Tetrahedra, Acute Tetrahedra, and Quads. After setting the Mesh Method option, you can create a smoother mesh around the nParticles by increasing the Max Smoothing Iterations slider. For example, if you want to create a smoother mesh that uses four-sided polygons, set Mesh Method to Quads and increase the Max Smoothing Iterations slider. By default, the slider goes up to 10. If a value of 10 is not high enough, you can type values above 10 into the field.

Shading the nParticle Mesh

To create the look of molten metal you can use a simple Ramp shader as a starting point.

  1. Select the polySurface1 node in the Outliner. Rename it metalMesh.

  2. Right-click on the metalMesh object in the viewport. Use the pop-up menu to assign a ramp material. Choose Assign New Material

    Shading the nParticle Mesh
    Assign a Ramp shader to the metalMesh object.

    Figure 13.29. Assign a Ramp shader to the metalMesh object.

  3. In the Common Materials Attributes section, set the Color Input to Facing Angle.

  4. Click on the color swatch, and use the Color Chooser to pick a bright orange color.

  5. Click on the right side of the ramp to add a second color. Make it a reddish orange.

  6. Create a similar but darker ramp for the Incandescence channel.

  7. Set Specularity to 0.24 and the specular color to a bright yellow. Raise the Glow intensity in the Special Effects rollout to 0.15.

  8. Back in the moltenMetal particle Attribute Editor, decrease the Mesh Triangle Size to 0.1 (it will take a couple minutes to update), and render a test frame using mental ray. Set the Quality preset in the Quality tab to Production.

  9. Save the scene as forge_v04.ma. To see a version of the finished scene, open forge_v04.ma from the chapter13scenes folder on the DVD (see Figure 13.30).

    Render the molten metal in mental ray.

    Figure 13.30. Render the molten metal in mental ray.

Texture Emission Attributes

The behavior of nParticles is often determined by their many dynamic properties. These control how the nParticles react to the settings in the Nucleus solver as well as fields, collision objects, and other nParticle systems. In the following section, you'll get more practice working with these settings.

If you have used standard particle systems in previous versions of Maya, you'll be pleased to see how Maya 2009 has streamlined the workflow for creating particle effects. Many of the attributes that required custom connections, expressions, and ramps are now automated.

Surface Emission

In this exercise you'll use nParticles to create the effect of flames licking the base of a space capsule as it reenters the atmosphere. You'll start by emitting nParticles from the base of the capsule and use a texture to randomize the generation of the nParticles on the surface.

  1. Open the capsule_v01.ma scene from the chapter13scenes directory on the DVD. You'll see a simple polygon capsule model. The capsule is contained in a group named spaceCapsule. In the group there is another surface named capsule emitter. This will serve as the surface emitter for the flames (see Figure 13.31).

    The capsule group consists of two polygon meshes. The base of the capsule has been duplicated to serve as an emitter surface.

    Figure 13.31. The capsule group consists of two polygon meshes. The base of the capsule has been duplicated to serve as an emitter surface.

  2. Play the animation. The capsule has expressions that randomize the movement of the capsule to make it vibrate. The expressions are applied to the Translate channels of the group node. To see the Expressions, open the Expression Editor (Window

    Creating an Emitter Surface from a Model
    Create the vibration of the capsule using random function expressions applied to each of the translation channels of the capsule.

    Figure 13.32. Create the vibration of the capsule using random function expressions applied to each of the translation channels of the capsule.

  3. In the viewport, choose to look through the renderCam. The camera has been set up so the capsule looks as though it's entering the atmosphere at an angle.

  4. In the Outliner, expand the spaceCapsule and choose the capsuleEmitter object. Switch to the nDynamics menu set and choose nParticles

    Create the vibration of the capsule using random function expressions applied to each of the translation channels of the capsule.
  5. Select the capsuleEmitter and choose nParticles

    Create the vibration of the capsule using random function expressions applied to each of the translation channels of the capsule.
  6. Rewind and play the animation. The nParticles are born on the emitter and then start falling through the air. This is because the Nucleus solver has Gravity activated by default. For now this is fine; leave the settings on the Nucleus solver where they are.

    To randomize the generation of the nParticles, you can use a texture. To help visualize how the texture creates the particles, you can apply it to the surface emitter.

  7. Select the capsuleEmitter and open the UV Texture Editor. The base already has UVs projected on the surface.

  8. Select the capsuleEmitter, right-click on the surface in the viewport, and use the pop-up menu to create a new Lambert texture (Assign New Material

    Create the vibration of the capsule using random function expressions applied to each of the translation channels of the capsule.
  9. Open the Attribute Editor for flameGenShader, and click on the checkered box to the right of the Color channel to create a new render node for color. In the Create Render Node window, click Ramp to create a ramp texture.

  10. Open the Attribute Editor for the ramp (it should open automatically when you create the ramp). Name the ramp flameRamp. Make sure texture view is on in the viewport so you can see the ramp on the capsuleEmitter surface (hot key = 6).

  11. Set the ramp's Type to Circular Ramp, and set Interpolation to None. Remove the blue color from the top of the ramp by clicking on the blue box at the right side at the top of the ramp. Click on the color swatch and use the Color Chooser to change the green color to white and then the red color to black.

  12. Set Noise to 0.5 and Noise Freq to 0.3 to add some variation to the pattern (see Figure 13.33).

  13. In the Outliner, select the nParticle node and hide it (hot key = Ctrl+h) so you can animate the ramp without having the nParticle simulation slow down the playback. Set the renderer to High Quality display.

    Apply the ramp to the shader on the base capsuleEmitter object.

    Figure 13.33. Apply the ramp to the shader on the base capsuleEmitter object.

  14. Select the flameRamp node and open it in the Attribute Editor (select the node by choosing it from the Textures area of the Hypershade). Rewind the animation and drag the white color marker on the ramp down toward the bottom. Its Selected Position should be at .05.

  15. Right-click Selected Position and choose Set Key (see Figure 13.34).

    Position the white color marker at the bottom of the ramp and keyframe it.

    Figure 13.34. Position the white color marker at the bottom of the ramp and keyframe it.

  16. Set the timeline to frame 100, move the white color marker to the top of the ramp, and set another key.

  17. Play the animation; you'll see the dark areas on the ramp grow over the course of 100 frames.

  18. Open the Graph Editor (Window

    Position the white color marker at the bottom of the ramp and keyframe it.
    Add keyframes to the ramp's animation on the Graph Editor to make a more erratic motion.

    Figure 13.35. Add keyframes to the ramp's animation on the Graph Editor to make a more erratic motion.

  19. In the Outliner, select the capsuleEmitter node and expand it. Select the flameGenerator emitter node and open its Attribute Editor. Scroll to the bottom of the editor and expand Texture Emission Attributes.

  20. Open the Hypershade to the Textures tab. MMB-drag flameRamp from the Textures area onto the color swatch for Texture Rate to connect the ramp to the emitter (see Figure 13.36). Select Enable Texture Rate and Emit From Dark.

  21. Increase Rate to 2400, unhide the nParticle1 node, and play the animation. You'll see that the nParticles are now emitted from the dark part of the ramp.

    Drag the ramp texture with the middle mouse button from the Hypershade onto the Texture Rate color swatch to make a connection.

    Figure 13.36. Drag the ramp texture with the middle mouse button from the Hypershade onto the Texture Rate color swatch to make a connection.

  22. Select the capsuleEmitter shape and hide it. Save the scene as capsule_v02.ma. To see a version of the scene to this point, open capsule_v02.ma from the chapter13scenes folder on the DVD.

  23. Disable High Quality Renderer in the viewport to improve playback speed—make sure nParticles is enabled in the viewport's Show menu.

Using Wind

The Nucleus solver contains settings to create wind and turbulence. These can be used with nParticles to create snow blowing in the air, bubbles rising in water, or flames flying from a careening spacecraft.

The Wind Settings

Now that you have the basic settings for the particle emission, the next task is to make the particles flow upward rather than fall. You can do this using either an air field or the Wind settings on the Nucleus solver. Using the Wind settings on the Nucleus solver applies wind to all nDynamic nodes (nCloth, nRigid, nParticles) connected to the solver. For this section you'll use the Nucleus solver. We'll discuss fields later in this chapter.

  1. Continue with the scene from the previous section or open the capsule_v02.ma file from the chapter13scenes directory. Make sure High-Quality Rendering is disabled in the viewport in order to improve playback speed (nParticles should be enabled in the viewport's Show menu as well). Select the capsule emitter and hide it; this also improves performance.

  2. Select the nParticle1 object. Rename it flames. Open the Attribute Editor and choose the nucleus1 tab.

  3. Set Gravity to 0 and play the animation. The particles emerge from the base of the capsule and stop after a short distance. This is because by default the nParticles have a Drag value of 0.01 set in their Dynamic Properties settings.

  4. Switch to the flamesShape tab, expand the Dynamic Properties rollout, and set Drag to 0. Play the animation, and the nParticles emerge and continue to travel at a steady rate.

  5. Switch back to the nucleus1 tab. Set the Wind Direction fields to 0, 1, 0 so the wind is blowing straight up along the Y axis. Set Wind Speed to 5 (see Figure 13.37). Play the animation—there's no change; the nParticles don't seem affected by the wind.

    The settings for the wind on the nucleus tab

    Figure 13.37. The settings for the wind on the nucleus tab

    For the Wind settings in the Nucleus solver to work, the nParticle needs to have a Drag value, even a small one. This is why all the nParticle styles except Water have drag applied by default. If you create a Water-style particle and add a Wind setting, it won't affect the water until you set the Drag field above 0. Think of drag as a friction setting for the wind. In fact, the higher the Drag setting, the more the wind can grab the particle and push it along, so it actually has a stronger pull on the nParticle.

  6. Set the Drag value to 0.01 and play the animation. The particles now emerge and then move upward through the capsule.

  7. Switch to the nucleus1 tab; set Air Density to 5 and Wind Speed to 25. The Air Density setting also controls, among other things, how much influence the wind has on the particles.

    A very high air density acts like a liquid, and a high wind speed acts like a current in the water. It depends on what you're trying to achieve in your particular effect, but you can use drag or air density or a combination to set how much influence the Wind settings have on the nParticle. And of course another attribute to take into consideration is the particle's mass. Since these are flames, presumably the mass will be very low.

  8. Set Air Density back to 1. Play the animation. The particles start out slowly but gain speed as the wind pushes them along. Set the Mass attribute in the Dynamic Properties section to 0.01. The particles are again moving quickly through the capsule (see Figure 13.38).

  9. Switch to the nucleus1 tab and set Wind Noise to 10. Because the particles are moving fast, Wind Noise needs to be set to a high value before there's any noticeable difference in the movement. Wind noise adds turbulence to the movement of the particles as they are pushed by the wind.

    Set the Mass and Drag attributes to a low value, enabling the nParticle flames to be pushed by the wind on the Nucleus solver.

    Figure 13.38. Set the Mass and Drag attributes to a low value, enabling the nParticle flames to be pushed by the wind on the Nucleus solver.

  10. To make the nParticles collide with the capsule, select the capsule node and choose nMesh

    Solver Substeps
  11. Select the nRigid1 node in the Outliner, and name it flameCollide.

  12. Expand the Wind Field Generation settings in the flameCollideShape node. Set Air Push Distance to 0.5 and Air Push Vorticity to 1.5 (see Figure 13.39).

    A passive object can generate wind as it moves through particles or nCloth objects to create the effect of air displacement. In this case, the capsule is just bouncing around, so the Air Push Distance setting helps jostle the particles once they have been created. If you were creating the look of a submarine moving through murky waters with particulate matter, the Air Push Distance setting could help create the look of the particles being pushed away by the submarine, and the Air Push Vorticity setting could create a swirling motion in the particles that have been pushed aside. In the case of the capsule animation, it adds more turbulence to the nParticle flames.

    The Wind Field Generation settings on the flame-CollideShape node

    Figure 13.39. The Wind Field Generation settings on the flame-CollideShape node

    The Wind Shadow Distance and Diffusion settings block the effect of the Nucleus solver's Wind setting on nParticles or nCloth objects on the side of the passive object opposite the direction of the wind. The Wind Shadow Diffusion attribute sets the amount at which the wind curls around the passive object.

    Air Push Distance is more processor intensive than Wind Shadow Distance, and the Maya documentation recommends that you do not combine Air Push Distance and Wind Shadow Distance.

    nParticles have these settings as well. You can make an nParticle system influence an nCloth object using the Air Push Distance setting.

  13. Save the scene as capsule_v03.ma. To see a version of the scene to this point, open capsule_v03.ma from the chapter13scenes folder on the DVD.

Shading and Hardware Rendering nParticles

Shading and rendering nParticles has been made much easier in Maya 2009. Many of the color and opacity attributes that required manual connections are now automatically set up and can easily be edited using the ramp in the nParticle's Attribute Editor.

  1. Continue with the same scene from the previous section or open capsule_v03.ma from the chapter13scenes folder on the DVD.

  2. Select the flames nParticle node in the Outliner, and open the Attribute Editor to the flamesShape node. Expand the Lifespan Attributes rollout, and set Lifespan to Random Range. Set Lifespan to 3 and Lifespan Random to 3.

    This setting makes the average lifespan for each nParticle 3 seconds with a variation of half the Lifespan Random setting in either direction. In this case the nParticles will live anywhere between 0.5 and 4.5 seconds.

  3. Scroll down to the Shading rollout and expand it; set Particle Render Type to MultiStreak. This makes each nParticle a group of streaks and activates attributes specific to this render type.

  4. Set Multi Count to 5, Multi Radius to 0.8, and Tail Size to 0.5 (see Figure 13.40).

    Change Particle Render Type to MultiStreak to better simulate flames.

    Figure 13.40. Change Particle Render Type to MultiStreak to better simulate flames.

  5. In the Opacity Scale section, set Opacity Scale Input to Age. Click on the right side of the Opacity Scale ramp curve to add an edit point. Drag this point down. This creates a ramp where the nParticle fades out over the course of its life (see Figure 13.41).

    If you've used standard particles in older versions of Maya, you know that you normally have to create a per-particle Opacity attribute and connect it to a ramp. If you scroll down to the Per Particle Array Attributes section, you'll see that Maya has automatically added the Opacity attribute and connected it to the ramp curve.

    The opacity and color ramps in the nParticle's attribute replace the need to connect ramps manually.

    Figure 13.41. The opacity and color ramps in the nParticle's attribute replace the need to connect ramps manually.

  6. Set Input Max to 1.5. This sets the maximum range along the X axis of the Opacity Scale ramp. Since Opacity Scale Input is set to Age, this means that each nParticle takes 1.5 seconds to become transparent, so the nParticles are visible for a longer period of time.

  7. To randomize the opacity scale for the opacity, set Opacity Scale Randomize to 0.5.

  8. Expand the Color rollout. Set Color Input to Age. Click on the ramp just to the right of the color marker to add a new color to the ramp. Click on the color swatch and change the color to yellow.

  9. Add a third color marker to the right end of the ramp, and set its color to orange.

  10. Set Input Max to 2 and Color Randomize to 0.8.

  11. In the Shading section, enable Color Accum. This creates an additive color effect, where denser areas of overlapping particles appear brighter.

  12. Save the scene as capsule_v04.ma. To see a version of the scene to this point, open capsule_v04.ma from the chapter13scenes folder on the DVD.

Creating an nCache

Before rendering it's always a good idea to create a cache to ensure that the scene renders correctly.

  1. Continue with the scene from the previous section or open the capsule_v04.ma file from the chapter13scenes folder on the DVD.

  2. Set the timeline to 200 frames.

  3. In the Outliner, expand the capsuleEmitter section, and select the flameGenerator emitter. Increase Rate (Particle/Sec) to 25,000. This will create a much more believable flame effect.

  4. Select the flames node in the Outliner. Switch to the nDynamics menu set, and choose nCache

    Creating an nCache
    The options for creating an nCache

    Figure 13.42. The options for creating an nCache

  5. The scene will play through, and the cache file will be written to disk. It will take a fair amount of time to create the cache, anywhere from 5 to 10 minutes depending on the speed of your machine.

  6. You can use the options in the nCache menu to attach an existing cache file to an nParticle or to delete, append, merge, or replace caches.

Using the Hardware Render Buffer

One of the fastest and easiest ways to render flames in Maya is to use the Hardware Render Buffer. The results may need a little extra tweaking in a compositing program, but overall it does a very decent job of rendering convincing flames. The performance of the Hardware Render Buffer depends on the type of graphics card installed in your machine. If you're using an Autodesk-approved graphics card, you should be in good shape.

The Blobby Surface, Cloud, and Tube nParticle render styles can only be rendered using software (Maya Software or mental ray). All nParticle types can be rendered in mental ray, although the results may be different than those rendered using the Hardware Render Buffer or Maya Hardware.

  1. To render using the Hardware Render Buffer choose Window

    Network Rendering with Hardware
  2. To set the render attributes in the Buffer, choose Render

    Network Rendering with Hardware

    The render buffer renders each frame of the sequence and then takes a screengrab of the screen. It's important to deactivate screen savers and keep other interface or application windows from overlapping the render buffer.

  3. Set Filename to capsuleFlameRender and Extension to name.0001.ext. Set Start Frame to 1 and End Frame to 200. Keep By Frame set to 1.

  4. Keep Image Format set to Maya IFF. This file format is compatible with compositing programs like Adobe After Effects.

  5. To change the resolution, you can manually replace the numbers in the Resolution field or click the Select button to choose a preset. Click this button and choose the 640 × 480 preset.

  6. In the viewport window, you may want to turn off the display of the resolution or film gate. The view in the Hardware Render Buffer updates automatically.

  7. Under Render Modes, turn on Full Image Resolution and Geometry Mask. Geometry Mask renders all the geometry as a solid black mask so only the nParticles will render. You can composite the rendered particles over a separate pass of the software-rendered version of the geometry.

  8. To create the soft look of the frames, expand the Multi-Pass Render Options rollout. Enable Multi-Pass Rendering and set Render Passes to 36. This means the buffer will take 36 snapshots of the frame and slightly jitter the position of the nParticles in each pass. The passes will then be blended together to create the look of the flame. For flame effects, this actually works better than the buffer's Motion Blur option. Leave Motion Blur at 0 (see Figure 13.43).

    The settings for the Hardware Render Buffer

    Figure 13.43. The settings for the Hardware Render Buffer

  9. Play the animation to about frame 45. In the Hardware Render Buffer, click the clapboard icon to see a preview of how the render will look (see Figure 13.44). If you're happy with the look, choose Render

    The settings for the Hardware Render Buffer
  10. When the sequence is finished, choose Flipbooks

    The settings for the Hardware Render Buffer
  11. Save the scene as capsule_v05.ma. To see a version of the scene to this point, open the capsule_v05.ma scene from the chapter13scenes directory on the DVD.

    When Geometry Mask is enabled, the Hardware Render Buffer renders only the nParticles.

    Figure 13.44. When Geometry Mask is enabled, the Hardware Render Buffer renders only the nParticles.

nParticles and Fields

The behavior of nParticles is most often controlled by using fields. There are three ways to generate a field for an nParticles system. You can connect one or more of the many fields listed in the Fields menu. These include Air, Gravity, Newton, Turbulence, Vortex, and Volume Axis Curve. You can use the fields built into the Nucleus solver—these are the Gravity and Wind forces that are applied to all nDynamic systems connected to the solver. And you can use the Force field and the Air Push fields that are built into nDynamic objects. In this section you'll experiment using all of these types of fields to control nParticles.

Using Multiple Emitters

When you create the emitter, an nParticle object is added and connected to the emitter. An nParticle can actually be connected to more than one emitter.

  1. Open the generator_v01.ma scene in the chapter13scenes folder on the DVD. You'll see a device built out of polygons. This will act as your experimental lab as you learn how to control nParticles with fields.

  2. Switch to the nDynamics menu set, and choose nParticles

    Using Multiple Emitters
  3. Choose nParticles

    Using Multiple Emitters
    The settings for the volume emitter

    Figure 13.45. The settings for the volume emitter

  4. In the Volume Emitter Attributes rollout, set Volume Shape to Sphere. You can leave the rest of the settings at the default. Click Create to make the emitter.

  5. Select the energyGenerator1 emitter in the Outliner. Use the Move tool (hot key = w) to position the emitter around one of the balls at the end of the generators in the glass chamber. You may want to scale it up to about 1.25 (Figure 13.46).

    Place the volume emitter over one of the balls inside the generator device.

    Figure 13.46. Place the volume emitter over one of the balls inside the generator device.

  6. Set the timeline to 800, and play the animation. The nParticles are born and fly out of the emitter.

    Notice that the nParticles do not fall even though Gravity is enabled in the Nucleus solver and the nParticle has a mass of 1. This is because in the Dynamic properties for the Cloud style of nParticle, the Ignore Solver Gravity checkbox is enabled.

  7. Select the energyGenerator1 emitter and duplicate it (hot key = Ctrl+d). Use the Move tool to position this second emitter over the ball on the opposite generator.

    If you play the animation, the second emitter creates no nParticles. This is because duplicating the emitter did not create a second nParticle object, but that's okay; you're going to connect the same nParticle object to both emitters.

  8. Select nParticle1 and rename it energy. Select energy and choose Window

    Place the volume emitter over one of the balls inside the generator device.
    Use the Dynamic Relationships Editor to connect the energy nParticle to both emitters.

    Figure 13.47. Use the Dynamic Relationships Editor to connect the energy nParticle to both emitters.

  9. Close the Dynamic Relationships Editor, and rewind and play the animation. You'll see both emitters now generate nParticles—the same nParticle object actually.

  10. Select the energy object and open the Attribute Editor. Switch to the nucleus tab and set Gravity to 1.

  11. In the energyShape tab, expand the Dynamic Properties rollout and turn off Ignore Solver Gravity, so the energy nParticles slowly fall after they are emitted from the two generator poles (see Figure 13.48).

    The energy nParticles are emitted from both emitters. Gravity is set to a low value, causing the nParticles to slowly fall.

    Figure 13.48. The energy nParticles are emitted from both emitters. Gravity is set to a low value, causing the nParticles to slowly fall.

Volume Axis Curve

The volume axis curve is a new type of dynamic field that has been added to Maya 2009. You can use this field with any of the dynamic systems (traditional and nDynamic) in Maya. In this section you'll perform some tricks using the field inside a model of an experimental vacuum chamber.

  1. Select the energy nParticle node in the Outliner. In the Attribute Editor, open the Lifespan rollout, and set the Lifespan mode to Random Range. Set Lifespan to 6 and Lifespan Random to 4. The nParticles will now live between 4 and 8 seconds each.

  2. With the energy nParticle selected, choose Fields

    Volume Axis Curve
  3. Select curve1 in the Outliner, and use the Move tool to position it between the generators. The field consists of a curve surrounded by a tubular field.

  4. Use the Show menu to disable the display of polygons so the glass case is not in the way. Select curve1 in the Outliner and right-click on the curve; choose CVs to edit the curve's control vertices. Use the Move tool to position the CVs at the end of the curve inside each generator ball. Use the Move tool to add some bends to the curve (see Figure 13.49).

  5. Rewind and play the animation. A few of the nParticles will be pushed along the curve. So far, it's not very exciting.

    Position the CVs of the Volume Axis curve to add bends to the curve. The field surrounds the curve, forming a tube.

    Figure 13.49. Position the CVs of the Volume Axis curve to add bends to the curve. The field surrounds the curve, forming a tube.

  6. Select the volumeAxisField1 node in the Outliner, and open its Attribute Editor. Use the following settings:

    • The default Magnitude and Attenuation settings (5 and 0) are fine for the moment.

    • Leave Use Max Distance off.

    • In the Volume Control Attributes rollout, set Section Radius to 3.

    • Set Trap Inside to 0.8. This keeps most of the nParticles inside the area defined by the volume radius (the Trap Inside attribute is available for other types of fields such as the Radial field).

    • Leave Trap Radius set to 2. This defines the radius around the field within which the nParticles are trapped.

    • Edit the Axial Magnitude ramp so each end is at about 0.5 and the middle is at 1, as in Figure 13.50. Set the Interpolation of each point to Spline. This means that the area at the center of the curve has a stronger influence on the nParticles than the areas at either end of the curve.

    • Edit the Curve Radius ramp, add some points to the curve, and drag them up and down in a random jagged pattern. You'll see the display of the field update; this creates an interesting shape for the curve.

    • In the Volume Speed Attributes rollout, set Away From Axis and Along Axis to 0, and set Around Axis to 4. This means that the nParticles are pushed in a circular motion around the curve rather than along or away from it. If you zoom into the field, you'll see an arrow icon at the end of the field indicating its direction. Positive numbers make the field go clockwise; negative numbers make it go counterclockwise.

    • Set Turbulence to 3 and leave Turbulence Speed at 0.2. This adds noise to the field, causing some nParticles to fly off (see Figure 13.50).

  7. Play the animation. You'll see the nParticles move around within the field. Faster-moving particles fly out of the field.

    The settings for the Volume Axis Curve field

    Figure 13.50. The settings for the Volume Axis Curve field

    This is interesting, but it can be improved to create a more dynamic look.

  8. In the Attribute Editor for the Volume Axis Curve field, remove the edit points from the Curve Radius ramp. Edit the curve so it has three points. The points at either end should have a value of 1; the point at the center should have a value of 0.1.

  9. Select the edit point at the center, and in the Selected Position field type =0.5+(0.5*(noise(time*4)));. This is similar to the expression that was applied to the ramp in the "Surface Emission" section of this chapter. In this case, it moves the center point back and forth along the curve, creating a moving shape for the field (see Figure 13.51).

  10. Save the scene as generator_v02.ma. To see a version of the scene to this point, open the generator_v02.ma scene from the chapter13scenes folder on the DVD.

Create an expression to control the Selected Position attribute of the Curve Radius ramp's center point. The numeric field is not large enough to display the entire expression.

Figure 13.51. Create an expression to control the Selected Position attribute of the Curve Radius ramp's center point. The numeric field is not large enough to display the entire expression.

Working with Force Fields

nParticles, nCloth, and passive collision objects (also known as nRigids) can all emit force fields that affect themselves and other nDynamic systems attached to the same nucleus node. In this example, the surface of the glass that contains the particle emitters will create a field that controls the nParticle's behavior.

  1. Continue with the scene from the previous section or open the generator_v02.ma scene from the chapter13scenes folder on the DVD.

  2. Expand the Housing group in the Outliner. Select the dome object and choose nMesh

    Working with Force Fields
  3. To keep the particles from escaping the chamber, you'll also need to convert the seal and base objects to passive collision objects. Select the seal object and choose nMesh

    Working with Force Fields
    Parts of the generator device are converted to collision objects, trapping the nParticles inside.

    Figure 13.52. Parts of the generator device are converted to collision objects, trapping the nParticles inside.

  4. Play the animation. As some of the nParticles are thrown from the Volume Axis field, they are now contained within the glass chamber (see Figure 13.52).

  5. Open the settings for the energyShape node in the Attribute Editor. Set Radius Scale Input to Age. Edit the Radius Scale ramp so it slopes up from 0 on the left to 1 in the middle and back down to 0 on the left. Set Input Max to 3 and Radius Scale Randomize to 0.5 (see Figure 13.53).

  6. Select the domeCollide node, and open the Attribute Editor to the domeCollideShape tab. Expand the Force Field Generation settings, and set Force Field to Single Sided. This generates a force field based on the positive normal direction of the collision surface.

    Edit the Radius Scale settings to create a more randomized radius for the nParticles.

    Figure 13.53. Edit the Radius Scale settings to create a more randomized radius for the nParticles.

    Along Normal generates the field along the surface normals of the collision object. In this case the difference between Along Normal and Single Sided is not noticeable. Double Sided generates the field based on both sides of the collision surface.

  7. The normals for the dome shape are actually pointing outward. You can see this if you choose Display

    Edit the Radius Scale settings to create a more randomized radius for the nParticles.
  8. Set Field Magnitude to 100 and Field Distance to 4, and play the animation. The particles are repelled from the sides of the dome when they are within four field units of the collision surface. A lower field magnitude will repel the particles with a weaker force, allowing them to collide with the dome before being pushed back to the center. If you set Magnitude to 1000, the nParticles never reach the collision surface.

  9. Set Field Magnitude to −100. The nParticles are now pulled to the sides of the dome when they are within four field units of the collision surface, much like a magnet. Setting a negative value of −1000 causes them to stick to the sides.

  10. The Field Scale Edit ramp controls the strength of the field within the distance set by the Field Distance value. The right side of the ramp is the leading edge of the field—in this case four field units in from the surface of the dome. The left side represents the scale of the force field on the actual collision surface.

    Reverse the normals for the dome surface so they point inward.

    Figure 13.54. Reverse the normals for the dome surface so they point inward.

    You can create some interesting effects by editing this curve. If Field Magnitude is at a value of −100 and you reverse the curve, the nParticles are sucked to the dome quickly when they are within four units of the surface. However, they do not stick very strongly to the side, so they bounce around a little within the four-unit area. Experiment creating different shapes for the curve, and see how it affects the behavior of the nParticles. By adding variation to the center of the curve, you get more of a wobble as the nParticle is attracted to the surface.

  11. Save the scene as generator_v03.ma. To see a version of the scene to this point, open the generator_v03.ma scene from the chapter13scenes folder on the DVD.

Painting Field Maps

The strength of the force field can be controlled by a texture. The texture itself can be painted onto the collision surface.

  1. Continue with the scene from the previous section or open the generator_v03.ma scene from the chapter13scenes folder on the DVD.

  2. In the Attribute Editor for domeCollide, set the Field Scale ramp so it's a straight line across the top of the curve editor. Set Field Magnitude to 1.

  3. Select the dome object and choose nMesh

    Painting Field Maps
  4. Open the tools options for the Artisan Brush. The color should be set to black, and Paint Operation should be set to Paint. Use the brush to paint a pattern on the surface of the dome. Make large, solid lines on the surface; avoid blurring the edges so the end result is clear (see Figure 13.55).

    Use the Artisan Brush tool to paint a pattern for the field magnitude on the collision surface.

    Figure 13.55. Use the Artisan Brush tool to paint a pattern for the field magnitude on the collision surface.

  5. When you've finished, click the Select tool in the toolbox to close the Artisan Brush options. Open the Hypershade. In the Textures tab, you'll see the texture map you just created. You can also use file textures or even animated sequences for the map source.

  6. Select the dome in the scene. In the Work Area of the Hypershade, right-click and choose Graph

    Use the Artisan Brush tool to paint a pattern for the field magnitude on the collision surface.
    Connect the newly painted texture to the color of the dome shader.

    Figure 13.56. Connect the newly painted texture to the color of the dome shader.

  7. If you play the animation, you won't see much of a result. The reason is that the values of the map are too weak and the movement of the nParticles is too fast to be affected by the field.

  8. In the Hypershade, select the file1 texture and open its Attribute Editor. The outAlpha of the texture is connected to the field magnitude of the collision surface. You can see this when you graph the network in the Hypershade. To increase the strength of the map, expand the Color Balance section. Set Alpha Gain to 1000 and Alpha Offset to −500. Chapter 2 has a detailed explanation of how the Alpha Gain and Alpha Offset attributes work. Essentially this means that the light areas of the texture cause the force field magnitude to be at a value of 500, and the dark areas cause it to be at −500.

  9. Play the animation. You'll see that most of the nParticles stay in the center of the dome, but occasionally one or two nParticles will fly out and stick to the side. They stick to the areas where the texture is dark (see Figure 13.57).

    The painted force field texture causes most of the nParticles to remain hovering around the center, but a few manage to stick to the dark areas.

    Figure 13.57. The painted force field texture causes most of the nParticles to remain hovering around the center, but a few manage to stick to the dark areas.

    Vertex maps assign values to the vertices of the surface using the colors painted by the brush; texture maps use a file texture. One may work better than the other depending on the situation. You can paint vertex maps by choosing nMesh

    The painted force field texture causes most of the nParticles to remain hovering around the center, but a few manage to stick to the dark areas.

    When using a texture or vertex map for the force field, the Force Field Magnitude setting acts as a multiplier for the strength of the map.

  10. Back in the domeCollide node, set Field Magnitude to 10 and play the animation. You'll see more nParticles stick to the surface where the texture has been painted.

  11. To smooth their motion, you can adjust the Field Scale ramp.

  12. Save the scene as generator_v04.ma. To see a version of the scene to this point, open generator_v04.ma from the chapter13scenes folder on the DVD.

Using Dynamic Fields

The traditional set of dynamic fields is found in the Fields menu. They have been included as part of Maya since version 1.

Fields such as Air and Gravity are similar to the wind and gravity forces that are part of the Nucleus system. But that is not to say you can't use them in combination with the Nucleus forces to create a specific effect.

Drag is similar to the Drag attribute of nParticles; it applies a force that in some cases slows an nParticle down; in other cases it actually pulls the nParticle in a direction determined by the force. You can use the Inherit Transform slider on the Drag field to create wakelike effects in a cloud of particles, similar to the wind field generation on nDynamic objects.

Radial fields are similar to force fields emitted by nRigids and nParticles; they push or pull particles, depending on their Magnitude settings.

A Uniform force is similar to Gravity because it pushes a particle in a particular direction. The Volume Axis field is similar to the Volume Axis curve used earlier in the chapter. It has a built-in turbulence and affects particles within a given volume shape (by default).

The Turbulence field creates a noise pattern, and the Vortex field creates a swirling motion. Newton fields create a Newtonian attraction to dynamic objects.

  1. Open the generator_v04 scene from the chapter13scenes folder on the DVD.

  2. Select the energy nParticle object and choose Fields

    Attenuation and Max Distance in Dynamic Fields
  3. In the Attribute Editor for the Turbulence field, set Magnitude to 100, Attenuation to 0, and Frequency to 0.5.

  4. Attach a Vortex field to the energy nParticle. By default the vortex travels around the Y axis, which works well for this scene. Set the Magnitude of the vortex to 25 and the Attenuation to 0.5.

  5. To see the particles behave properly, you'll probably want to create a playblast. Set the timeline to 300, and choose Window

    Attenuation and Max Distance in Dynamic Fields
  6. Save the scene as generator_v05.ma. To see a version of the scene to this point, open generator_v05.ma from the chapter13scenes folder on the DVD.

Rendering Particles with mental ray

All particle types can be rendered using mental ray software rendering, and particles will appear in reflections and refractions. In this section you'll see how easy it is to render different nParticle types using mental ray.

Setting nParticle Shading Attributes

In this exercise you'll render the nParticles created in the generator scene.

  1. Open the generator_v05.ma scene from the chapter13scenes folder on the DVD.

  2. Select the energy nParticle node in the Outliner, and open its Attribute Editor to the energyShape1 tab.

  3. Expand the Shading attributes in the bottom of the editor. Set Opacity to 0.8.

  4. Set Color Input to Age. Make the left side of the ramp bright green and the right side a slightly dimmer green.

  5. Set Incandescence Input to Age. Edit the ramp so the far-left side is white followed closely by bright green. Make the center a dimmer green and the right side completely black (see Figure 13.58).

  6. Select each of the emitter nodes, and raise the Rate value to 1000.

  7. Select the domeShader node in the Hypershade, and break the connection between the color and the file texture (don't delete the file texture—it still controls the force field magnitude). Set the color of the domeShader to a dark gray.

  8. Play the animation for about 80 frames. Open the render settings, and set the renderer to mental ray. In the Quality tab, set the Quality preset to Production.

    The shading attributes for the energy nParticle

    Figure 13.58. The shading attributes for the energy nParticle

  9. Select the energy nParticle, and in the Render Stats section of the energyShape tab, check the boxes for Visible in Reflections and Refractions.

  10. Create a test render of the scene. You can see in the glass of the chamber and the metal base that the nParticles are reflected. Open the Hypershade and select the metal shader. Increase Reflectivity in the Attribute Editor to 0.8. The nParticles are more visible in the reflection on the base (see Figure 13.59).

  11. Select the dome shader, and in its Attribute Editor under Raytrace Options, activate Refractions and set the Refractive Index to 1.2. Under the Specular Shading rollout, increase Reflectivity to 0.8. Create another test render. You can see the effect refraction has on the nParticles.

    You can render the point, multipoint, streak, and multiStreak render types using mental ray. They will appear in reflections and refractions as well; however, you'll notice that in the Render Stats section for these nParticle types, the options for Reflections and Refractions are unavailable.

  12. In the Hypershade select the npCloudVolume shader. This shader is created with the nParticle. Graph the network in the Hypershade Work Area (see Figure 13.60).

    The nParticles are visible in reflections on the surfaces.

    Figure 13.59. The nParticles are visible in reflections on the surfaces.

    Shaders are automatically created for the nParticles. The particleSamplerInfo node connects the attributes of the nParticle to the shader.

    Figure 13.60. Shaders are automatically created for the nParticles. The particleSamplerInfo node connects the attributes of the nParticle to the shader.

    You can see that a particleSampler node is automatically connected to the volume shader. This node transfers the settings you create in the nParticle's Attribute Editor for color, opacity, and transparency to the shader. An npCloudBlinn shader is also created. This shader is applied when you switch the Particle Type to Points. You can further refine the look of the nParticles by adjusting the settings in the npCloudVolume shaders Attribute Editor.

    You can add a shader glow to the particles by increasing Glow Intensity in the npCloudVolume shader; however, the glow does not appear behind refractive surfaces with standard Maya shaders.

  13. When you are happy with the look of the render, you can create an nCache for the energy nParticle and render the sequence using mental ray.

  14. Save the scene as generator_v06.ma. To see a finished version of the scene, open the generator_v06.ma file from the chapter13scenes directory.

The Bottom Line

Create nParticles

nParticles can be added to a scene in a number of ways. They can be drawn using the tool or spawned from an emitter, or they can fill an object.

Master it

Create a spiral shape using nParticles.

Make nParticles collide

NParticles can collide with themselves, other nParticles, and polygon surfaces.

Master it

Make nParticles pop out of the top of an animated volume.

Create liquid simulations

Enabling Liquid Simulations changes the behavior of nParticles so they act like water or other fluids.

Master it

Create a flowing stream of nParticles that ends in a waterfall.

Emit nParticles from a texture

The emission rate of an nParticle can be controlled using a texture.

Master it

Create your own name in nParticles.

Move nParticles with nucleus wind

The wind force on the nucleus node can be used to push nParticles.

Master it

Create the effect of bubbles pushed back and forth under water.

Use the Hardware Render Buffer

The Hardware Render Buffer is a quick way to render nParticles using your machine's graphics card. It works well for creating flame effects.

Master it

Render a small fire using the Hardware Render Buffer.

Use force fields

Force fields can be emitted by nParticles and collision objects, creating interesting types of behavior in your scenes.

Master it

Add a second nParticle object emitted from the base of the generator. Enable its force field so that it attracts some of the original energy nParticle.

Render nParticles with mental ray

mental ray can be used to render all nParticle styles using raytraced features such as reflections and refractions.

Master it

Create and render a snowglobe effect.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset