Tải bản đầy đủ (.pdf) (105 trang)

Mastering Autodesk Maya 2011 phần 8 docx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (3.08 MB, 105 trang )

706
|
CHAPTER 13 IntroduCIng nPartICles
4. Switch to a side view, and turn on wireframe mode.
5. 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 attri-
bute 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).
6. Play the animation back several times; notice the behavior when
A. Enable Liquid Behavior is off.
B. Self Collide is on (set Self Collide Width Scale to 0.7).
C. Both Liquid Behavior and Self Collide are enabled.
7. Turn Liquid Behavior back on, and turn Self Collide off.
8. Open the Particle Size rollout panel, 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.
9. Play the animation for about 140 frames until all the nParticles settle.
10. With the moltenMetal shape selected, choose nSolvers  Initial State  Set From Current.
11. Rewind and play the animation; the particles start out as settled in the well of the tub
(see Figure 13.27).
12. Select moltenMetal. At the top of the Attribute Editor, deselect Enable to temporarily
disable the nParticle simulation so you can easily animate the tub.
13. Select the tub1 group in the Outliner, and switch to the side view.
14. 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.28).
15. Set the timeline to frame 20.
16. In the Channel Box, select the Rotate X channel for the tub1 group node, right-click, and
set a keyframe.
17. Set the timeline to frame 100.


18. Set the value of tub1’s Rotate X channel to 85, and set another key.
Figure 13.27
Setting Initial
State makes the
nParticles start out
from their settled
position.
usIng nPartICles to sIMulate lIquIds
|
707
19. Move the timeline to frame 250, and set another keyframe.
20. Set the timeline to 330, set Rotate X to 0, and set a fourth key.
21. Select moltenMetal, and in the Attribute Editor, select the Enable check box.
22. Rewind the animation, and play it. The nParticles pour out of the tub like water (see
Figure 13.29).
Figure 13.28
Align the pivot
point for the tub
group with the
handles from the
side view.
Figure 13.29
When you animate
the tub, the nParticles
pour out of it like
water.
708
|
CHAPTER 13 IntroduCIng nPartICles
23. Switch to the perspective view. When you play the animation, the water goes through the

bucket and the floor.
24. Select the bucket, and choose nMesh  Create Passive Collider.
25. Switch to the nucleus1 tab, and turn on Use Plane.
26. Set the PlaneOrigin’s Translate Y to -4.11 to match the position of the floor. Now when
you play the animation, the nParticles land in the bucket and on the floor.
Set the Collision Flag to Edge
You can improve the performance speed of the playback by selecting the nRigid node connected to
the bucket and setting Collision Flag to Edge instead of Face.
27. 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 resis-
tance to flow. Sticky, gooey, or oily substances have a higher viscosity.
Viscosity and Solver Substeps
Increasing the number of substeps on the Nucleus solver will magnify viscosity.
28. 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.
You can use the other settings in the Liquid Simulation rollout panel 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 1 to a setting of 5.
At 1 fewer nParticles overlap, and they flow out of the tub more easily than when Rest
Density is set to 5.
Surface Tension The Liquid Simulation settings now have a Surface Tension slider in
Maya 2011. Surface tension simulates the attractive force within fluids that tends to hold
them together. Think of how a drop of water forms a surface as it rests on wax paper or

how beads of water form when condensing on a cold pipe.
usIng nPartICles to sIMulate lIquIds
|
709
29. To complete the behavior of molten metal, set Rest Density to 2, and set Incompressibility
to 0.5.
30. In the Collisions rollout panel, set Friction to 0.5 and Stickiness to 0.25.
31. Expand the Dynamic Properties rollout panel, 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.30).
32. Save the scene as forge_v03.ma.
To see a version of the scene to this point, open forge_v03.ma from the chapter13\scenes
folder.
Viscosity Scale and Surface Tension Ramp
In Maya 2011, you can now fine-tune the behavior of your liquid simulations using Viscosity Scale
and Surface Tension ramps.
You can use the viscosity scale to modify the viscosity over time. To do this, set Viscosity Scale Input
to Age, and adjust the ramp. You can also use other inputs such as Randomized ID and Radius to
determine how viscosity is applied to the liquid.
The Surface Tension Scale Ramp setting allows you to scale the surface tension value based on an
input such as the age of the particle, a randomized ID, the radius, and more using settings similar
to the other ramps.
Converting nParticles to Polygons
You can convert nParticles into a polygon mesh. The mesh updates with the particle motion
to create a smooth blob or liquid-like appearance, which is perfect for rendering fluids. In this
Figure 13.30
Adjusting the
settings under
Liquid Simulation,
Collisions, and

Dynamic Proper-
ties makes the
nParticles behave
like a heavy, slow-
moving liquid.
710
|
CHAPTER 13 IntroduCIng nPartICles
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 chapter13\scenes folder on the DVD.
2. Play the animation to about frame 230.
3. Select the moltenMetal object in the Outliner, and choose Modify  Convert  nParticle
To Polygons.
The nParticles have disappeared, and a polygon mesh has been added to the scene. You’ll
notice that the mesh is a lot smaller than the original nParticle simulation; this can be
changed after converting the nParticle to a mesh. You can adjust the quality of this mesh
in the Attribute Editor of the nParticle object used to generate the mesh.
4. Select the new polySurface1 object in the Outliner, and open the Attribute Editor to the
moltenMetalShape tab.
5. Expand the Output Mesh section. Set Threshold to 0.8 and Blobby Radius Scale to 2.1.
Fine-Tuning the Mesh
The settings in step 5 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.
6. Set Motion Streak to 0.5. This stretches the moving areas of the mesh in the direction of
the motion to create a more fluid-like behavior.

7. 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.31. 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 reason-
able pace.
Figure 13.31
Adjust the quality
of the mesh in
the Output Mesh
section of the
nParticle’s shape
node attributes.
usIng nPartICles to sIMulate lIquIds
|
711
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 Max Triangle Size Numerically
Be careful when using the slider for Mesh Triangle Size. It’s easy to move the slider to a low value by
accident, and then you’ll have to wait for Maya to update, which can be frustrating. Use numeric
input for this attribute, and reduce the value by 0.05 at a time until you’re happy with the look of
the mesh.
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 Quad Mesh. 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

greater than 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 the metalMesh object in the viewport. Use the pop-up menu to assign a ramp
material. Choose Assign New Material. A pop-up window will appear; choose Ramp
Shader from the list (see Figure 13.32).
Figure 13.32
Assign a Ramp
shader to the
metalMesh object.
712
|
CHAPTER 13 IntroduCIng nPartICles
3. Open the Attribute Editor for the new Ramp shader. In the Common Materials Attributes
section, set Color Input to Facing Angle.
4. Click the color swatch, and use the Color Chooser to pick a bright orange color.
5. Click 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.
Ramp Shader Color Input Settings
Each of the color channels that uses a ramp will use the same Color Input setting as the Color rollout
panel. So, in the case of this ramp, Incandescence will also use Facing Angle as the input.
7. Set Specularity to 0.24 and the specular color to a bright yellow.
8. Increase the Glow intensity in the Special Effects rollout panel to 0.15.
9. 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 on the Quality tab to Production.
10. Save the scene as forge_v04.ma.
To see a version of the finished scene, open forge_v04.ma from the chapter13\scenes folder
on the DVD (see Figure 13.33).

Emit nParticles Using a Texture
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,
Figure 13.33
Render the
molten metal
in mental ray.
eMIt nPartICles usIng a texture
|
713
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, since 2009, Maya 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 cap-
sule 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 chapter13\scenes 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.34).
Creating an Emitter Surface from a Model
The capsule emitter geometry was created by selecting the faces on the base of the capsule and
duplicating them (Edit Mesh  Duplicate Face). A slight offset was added to the duplicate face
operation to move it away from the capsule surface. The idea is to have the nParticles generated by
the bottom of the capsule. By creating an object separate from the bottom of the model, you can
make the process much easier and faster.
Figure 13.34

The capsule group
consists of two
polygon meshes.
The base of the cap-
sule has been dupli-
cated to serve as an
emitter surface.
714
|
CHAPTER 13 IntroduCIng nPartICles
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, do the following:
a. Open the Expression Editor (Window  Animation Editors  Expression Editor).
b. Choose Select Filter  By Expression Name.
c. Select expression1, expression2, or expression3.
You’ll see the expression in the box at the bottom of the editor (see Figure 13.35).
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.
5. Switch to the nDynamics menu set, and choose nParticles  Create nParticles  Points to
set the nParticle style to Points.
6. Select the capsuleEmitter, and choose nParticles  Create nParticles  Emit From Object 
Options.
7. In the options, choose Edit  Reset to clear any settings that remain from previous Maya
sessions.
8. Set Emitter Name to flameGenerator. Set Emitter Type to Surface and Rate (particles/sec)
to 150. Leave the rest of the settings at the default, and click the Apply button to create the
emitter.
9. 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.
Figure 13.35
Create the vibra-
tion of the capsule
using random
function expres-
sions applied to
each of the transla-
tion channels of
the capsule.
eMIt nPartICles usIng a texture
|
715
To randomize the generation of the nParticles, you can use a texture. To help visualize how
the texture creates the particles, you can apply the texture to the surface emitter:
1. Select the capsuleEmitter, and open the UV Texture Editor (Window  UV Texture
Editor). The base already has UVs projected on the surface.
2. Select the capsuleEmitter, right-click the surface in the viewport, and use the pop-up
menu to create a new Lambert texture for the capsuleEmitter surface. Name the shader
flameGenShader.
3. Open the Attribute Editor for flameGenShader, and click the checkered box to the right of
the Color channel to create a new render node for color.
4. In the Create Render Node window, click Ramp to create a ramp texture.
5. In 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).
6. Set the ramp’s Type to Circular Ramp, and set Interpolation to None.
7. Remove the blue color from the top of the ramp by clicking the blue box at the right side
at the top of the ramp. Click the color swatch, and use the Color Chooser to change the

green color to white and then the red color to black.
8. Set Noise to 0.5 and Noise Freq to 0.3 to add some variation to the pattern (see
Figure 13.36).
9. In the Outliner, select the nParticle node and hide it (hot key = Ctrl+h) so you can ani-
mate the ramp without having the nParticle simulation slow down the playback. Set the
renderer to High Quality display.
Figure 13.36
Apply the ramp
to the shader
on the base
capsuleEmitter
object.
716
|
CHAPTER 13 IntroduCIng nPartICles
10. Select the flameRamp node, and open it in the Attribute Editor (select the node by choos-
ing it from the Textures area of the Hypershade).
11. Rewind the animation, and drag the white color marker on the ramp down toward the
bottom. Its Selected Position should be at .05.
12. Right-click Selected Position, and choose Set Key (see Figure 13.37).
13. Set the timeline to frame 100, move the white color marker to the top of the ramp, and
set another key for the Selected Position.
14. Play the animation; you’ll see the dark areas on the ramp grow over the course of
100 frames.
15. Open the Graph Editor (Window  Animation Editors  Graph Editor). Click the Select
button at the bottom of the ramp’s Attribute Editor to select the node; you’ll see the ani-
mation curve appear in the Graph Editor.
16. Select the curve, switch to the Insert Keys tool, and add some keyframes to the curve.
17. Use the Move tool to reposition the keys to create an erratic motion to the ramp’s anima-
tion (see Figure 13.38).

Figure 13.37
Position the white
color marker at the
bottom of the ramp
and keyframe it.
Figure 13.38
Add keyframes to
the ramp’s anima-
tion on the Graph
Editor to make
a more erratic
motion.
eMIt nPartICles usIng a texture
|
717
Animate U Wave and V Wave with Expressions
To add some variation to the ramp’s animation, you can animate the U and V Wave values or cre-
ate an expression. In the U Wave field, type =0.5+(0.5*noise(time));, as shown here. The
noise(time) part of the expression creates a random set of values between -1 and 1 over time.
Noise creates a smooth curve of randomness values as opposed to the rand function, which cre-
ates a discontinuous string of random values (as seen in the vibration of the capsule). By dividing
the result in half and then adding 0.5, the range of values is kept between 0 and 1. To speed up the
rate of the noise, multiply time by 5 so the expression is =0.5+(0.5*noise(time*5));. You can
use an expression to make the V Wave the same as the U Wave; just type =flameRamp.uWave in
the field for the V Wave attribute. When you play the animation, you’ll see a more varied growth
of the color over the course of the animation.
18. In the Outliner, select the capsuleEmitter node, and expand it.
19. Select the flameGenerator emitter node, and open its Attribute Editor.
20. Scroll to the bottom of the editor, and expand Texture Emission Attributes.
21. Open the Hypershade to the Textures tab.

22. MMB-drag flameRamp from the Textures area onto the color swatch for Texture Rate to
connect the ramp to the emitter (see Figure 13.39).
23. Select Enable Texture Rate and Emit From Dark.
24. 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.
25. Select the capsuleEmitter node, 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 chapter13\
scenes folder on the DVD.
Figure 13.39
Drag the ramp
texture with the
middle mouse
button from the
Hypershade onto
the Texture Rate
color swatch to
make a connection.
718
|
CHAPTER 13 IntroduCIng nPartICles
Inherit Color and Opacity
You can make the particles inherit the color of the texture or use the color to control opacity. To do
this, first switch to the particle’s shape node attributes, expand the Add Dynamic Attributes rollout
panel in the particle’s shape tab, and click Opacity or Color. Then choose Add Per Particle from the
pop-up window. Switch to the emitter’s attributes, place the texture in the Particle Color swatch
in the Texture Emission Attributes, and then enable Inherit Color or Inherit Opacity or both.
Using Wind
The Nucleus solver contains settings to create wind and turbulence. You can use these settings
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 par-
ticles 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 nDy-
namic nodes (nCloth, nRigid, nParticles) connected to the solver. For this section, you’ll use the
Nucleus solver. Fields will be discussed later in this chapter.
1. Continue with the scene from the previous section, or open the capsule_v02.ma file from
the chapter13\scenes directory. Set Renderer to Default Render Quality in the view-
port’s menu bar 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 in the Outliner. Rename it flames.
3. Open the Attribute Editor, and choose the nucleus1 tab.
4. Set Gravity to 0, and play the animation. The particles emerge from the base of the cap-
sule 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.
5. Switch to the flamesShape tab, expand the Dynamic Properties rollout panel, and set
Drag to 0. Play the animation, and the nParticles emerge and continue to travel at a
steady rate.
6. Switch back to the nucleus1 tab:
a. Set the Wind Direction fields to 0, 1, 0 so the wind is blowing straight up along the
y-axis.
b. Set Wind Speed to 5 (see Figure 13.40).
c. Play the animation.
There’s no change; the nParticles don’t seem affected by the wind.
usIng WInd
|
719
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.
7. Switch to the tab for the flamesShape, set the Drag value to 0.01, and play the animation.
The particles now emerge and then move upward through the capsule.
8. 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 consider is the particle’s mass.
Since these are flames, presumably the mass will be very low.
9. Set Air Density to 1. Play the animation. The particles start out slowly but gain speed as
the wind pushes them along.
10. Set the Mass attribute in the Dynamic Properties section to 0.01. The particles are again
moving quickly through the capsule (see Figure 13.41).
Figure 13.40
The settings for
the wind on the
nucleus tab
Figure 13.41
Set the Mass and
Drag attributes
to a low value,
enabling the
nParticle flames
to be pushed by
the wind on the

Nucleus solver.
720
|
CHAPTER 13 IntroduCIng nPartICles
11. 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.
Solver Substeps
The Substeps setting on the Nucleus tab sets the number of times, per frame, the nDynamics are
calculated. Increasing this value increases the accuracy of the simulation but also slows down per-
formance. It can also change how some aspects of nDynamics behave. If you change the Substeps
setting, you may need to adjust Wind Speed, Noise, Mass, and other settings.
12. To make the nParticles collide with the capsule, select the capsule node, and choose
nMesh  Create Passive Collider. The nParticles now move around the capsule.
13. Select the nRigid1 node in the Outliner, and name it flameCollide.
14. 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.42).
15. Save the scene as capsule_v03.ma.
To see a version of the scene to this point, open capsule_v03.ma from the chapter13\scenes
folder on the DVD.
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 subma-
rine, 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 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 direc-
tion 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.
Figure 13.42
The Wind Field
Generation
settings on the
flameCollide-
Shape node
shadIng nPartICles and usIng hardWare renderIng to Create FlaMe eFFeCts
|
721
Shading nParticles and Using Hardware Rendering
to Create Flame Effects
Once you have created your nParticle simulation, you’ll have to decide how to render the
nParticles in order to best achieve the effect you want. The first decision you’ll have to make is
how to shade the nParticles—meaning, how they will be colored and what rendering style will
best suit your needs. Maya makes this process fairly easy, because there are several rendering
styles to choose from, including Point, MultiPoint, Blobby Surface, Streak, MultiStreak, and
Cloud. Any one of these styles will change the appearance of the individual nParticles and thus
influence the way the nParticle effect looks in the final rendered image.
To make coloring the nParticles easy, Maya provides you with a number of colored ramps
that control the nParticles’ color, opacity, and incandescence over time. You can choose differ-
ent attributes, such as Age, Acceleration, Randomized ID, and so on, to control the way the color
ramps are applied to the nParticles. You can find all of these attributes in the Shading section of

the nParticle’s Attribute Editor.
Most of the time, you’ll want to render nParticles as a separate pass from the rest of the scene
and then composite the rendered nParticle image sequence together with the rest of the rendered
scene in your compositing program. This is so that you can easily isolate the nParticles and apply
effects such as blurring, glows, and color correction separately from the other elements of the
scene. You have a choice how you can render the nParticles. This can be done using mental ray,
Maya Software, Maya Hardware, or the Hardware Render Buffer. This section demonstrates how
to render using the Hardware Render Buffer. Later in the chapter you’ll learn how to render
nParticles using mental ray.
Shading nParticles to Simulate Flames
Shading nParticles has been made much easier since Maya version 2009. Many of the color and
opacity attributes that required manual connections are now automatically set up and can eas-
ily be edited using the ramp in the nParticle’s Attribute Editor. In this section, you’ll use these
ramps to make the nParticles look more like flames.
1. Continue with the same scene from the previous section, or open capsule_v03.ma from
the chapter13\scenes 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 panel, and set Lifespan to
Random Range. Set Lifespan to 3 and Lifespan Random to 3.
This setting makes the average life span for each nParticle three 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 panel, 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.43).
5. In the Opacity Scale section, set Opacity Scale Input to Age. Click 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.44).
722

|
CHAPTER 13 IntroduCIng nPartICles
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.
Flashing nParticle Colors
If the opacity of your nParticles seems to be behaving strangely or the nParticles are flashing differ-
ent colors, make sure that the renderer in the viewport is not set to High Quality Rendering. Setting
it to Default Quality Rendering should fix the problem.
Figure 13.43
Change Particle
Render Type to
MultiStreak to
better simulate
flames.
Figure 13.44
The opacity and
color ramps in the
nParticle’s attri-
bute replace the
need to connect
ramps manually.
shadIng nPartICles and usIng hardWare renderIng to Create FlaMe eFFeCts
|
723
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 sec-
onds to become transparent, so the nParticles are visible for a longer period of time.
Input Max Value

If the Input Max value is larger than the particle’s life span, it will die before it reaches zero opacity,
making it disappear rather than fade out. This is fine for flame effects, but you should be aware of
this behavior when creating an effect. If Opacity Scale Input is set to Normalized Age, then Input
Max has no effect.
7. To randomize the opacity scale for the opacity, set Opacity Scale Randomize to 0.5.
8. Expand the Color rollout panel. Set Color Input to Age. Click the ramp just to the right of
the color marker to add a new color to the ramp. Click 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. See Figure 13.44.
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 chapter13\scenes
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 chapter13\scenes folder on the DVD.
2. Set the timeline to 200 frames.
3. In the Outliner, expand the capsuleEmitter section, and select the flameGenerator emit-
ter. 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  Create New Cache  Options. In the options, you can choose a name for the
cache or use the default, which is the name of the selected node (flameShape in this
example). You can also specify the directory for the cache, which is usually the project’s
data directory. Leave File Distribution set to One File Per Frame and Cache Time Range
to Time Slider. Click Create to make the cache (see Figure 13.45).

724
|
CHAPTER 13 IntroduCIng nPartICles
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.
5. Open the Attribute Editor for the flameShape tab, and turn off the Enable button so that
the nParticle is disabled. This prevents Maya from calculating the nParticle dynamics
while using an nCache at the same time.
6. Play the animation, and you’ll see the nParticles play back even though they have been
disabled.
The playback is much faster now since the dynamics do not have to be calculated.
If you make any changes to the dynamics of the nParticles, you’ll have to delete or disable the
existing cache before you’ll see the changes take effect.
By default, only the position and velocity attributes of the nParticle are stored when you cre-
ate an nCache. If you have a more complex simulation in which other attributes change over
time (such as mass, stickiness, rotation, and so on), then open the Caching rollout panel in the
nParticle’s Attribute Editor, set Cacheable Attributes to All, and then create a new nCache (see
Figure 13.46). It is a fairly common mistake to forget to do this, and if this is not set properly,
you’ll notice that the nParticles do not behave as expected when you play back from the nCache
or when you render the animation. The nCache file will be much larger when you change the
Cacheable Attributes setting.
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.
Figure 13.45
The options for
creating an nCache
Figure 13.46
Set the Cacheable
Attributes menu to

All when you want
to cache attributes
other than just
Position and
Velocit y.
shadIng nPartICles and usIng hardWare renderIng to Create FlaMe eFFeCts
|
725
Particle Disk Cache
nParticles do not use the Particle Disk Cache settings in the Dynamics menu set. A normal Particle
Disk Cache works only for standard particles. Create an nCache for nParticles and any other
nDynamic system.
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 Hardware Render Buffer vs. Maya Hardware
There are two ways to hardware render in Maya: you can use the Hardware Render Buffer, which
takes a screenshot of each rendered frame directly from the interface, or you can batch render with
Maya Hardware. Maya Hardware is chosen in the Render Settings window. The Hardware Render
Buffer uses its own interface. There can be some differences in the way the final render looks depend-
ing on which hardware rendering method you choose. Depending on the effect you want to achieve,
you may want to test each method to see which one produces the best results.
The Blobby Surface, Cloud, and Tube nParticle render styles can only be rendered using soft-
ware (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.
Network Rendering with Hardware

If you are rendering using a farm, the render nodes on the farm may not have graphics cards, so
using either the Hardware Render Buffer or Maya Hardware won’t actually work. You’ll have to
render the scene locally.
1. To render using the Hardware Render Buffer, choose Window  Rendering Editors 
Hardware Render Buffer. A new window opens showing a wireframe display of the
scene. Use the Cameras menu in the buffer to switch to the renderCam.
2. To set the render attributes in the Hardware Render Buffer, choose Render  Attributes.
The settings for the buffer appear in the Attribute Editor.
726
|
CHAPTER 13 IntroduCIng nPartICles
The render buffer renders each frame of the sequence and then takes a screenshot 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.
4. Set Start Frame to 1 and End Frame to 200. Keep By Frame set to 1.
Keep Image Format set to Maya IFF. This file format is compatible with compositing pro-
grams such as 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 panel.
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.47).
9. Play the animation to about frame 45.
10. In the Hardware Render Buffer, click the clapboard icon to see a preview of how the ren-
der will look (see Figure 13.48).
Figure 13.47
The settings for the
Hardware Render
Buffer
nPartICles and FIelds
|
727
11. If you’re happy with the look, choose Render  Render Sequence to render the 200-frame
sequence. It should take 5 to 10 minutes depending on your machine. You’ll see the buffer
render each frame.
12. When the sequence is finished, choose Flipbooks  capsuleFlameRender1-200 to see the
sequence play in FCheck.
13. 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 chapter13\
scenes directory on the DVD.
To finalize the look of flames, you can apply additional effects such as glow and blur in your
compositing program. Take a look at the capsuleReentry movie in the chapter13 folder of the
DVD to see a finished movie made using the techniques described in this section.
nParticles and Fields
The behavior of nParticles is most often controlled by using fields. There are three ways to gen-
erate a field for an nParticles system. First, 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. Second, 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. Finally, 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.
Figure 13.48
When Geometry
Mask is enabled,
the Hardware
Render Buffer
renders only the
nParticles.
728
|
CHAPTER 13 IntroduCIng 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 chapter13\scenes 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  Create nParticles  Cloud to
set the nParticle style to Cloud.
3. Choose nParticles  Create nParticles  Create Emitter  Options.
4. In the options, set Emitter Name to energyGenerator. Leave Solver set to Create New
Solver. Set Emitter Type to Volume and Rate (particles/sec) to 200.
5. In the Volume Emitter Attributes rollout panel, set Volume Shape to Sphere. You can leave
the rest of the settings at the defaults. Click Create to make the emitter (see Figure 13.49).
Figure 13.49
The settings for the
volume emitter
nPartICles and FIelds

|
729
6. 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 cham-
ber. You may want to scale it up to about 1.25 (Figure 13.50).
7. 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 check box is enabled.
8. 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 dupli-
cating 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.
9. Select nParticle1 in the Outliner, and rename it energy.
10. Select energy, and choose Window  Relationship Editors  Dynamic Relationships. A
window opens showing the objects in the scene; energy is selected on the left side.
11. On the right side, click the Emitters radio button to switch to a list of the emitters in the
scene. EnergyGenerator1 is highlighted, indicating that the energy nParticle is connected
to it.
12. Select energyGenerator2 so both emitters are highlighted (see Figure 13.51).
Figure 13.50
Place the volume
emitter over one of
the balls inside the
generator device.
730
|
CHAPTER 13 IntroduCIng nPartICles

13. Close the Dynamic Relationships Editor, and rewind and play the animation. You’ll see
both emitters now generate nParticles—the same nParticle object actually.
14. Select the energy object, and open the Attribute Editor. Switch to the nucleus tab, and set
Gravity to 1.
15. In the energyShape tab, expand the Dynamic Properties rollout panel, and turn off Ignore
Solver Gravity so the energy nParticles slowly fall after they are emitted from the two
generator poles (see Figure 13.52).
Figure 13.51
Use the Dynamic
Relationships
Editor to connect
the energy
nParticle to
both emitters.
Figure 13.52
The energy
nParticles are
emitted from
both emitters.
Gravity is set to a
low value, causing
the nParticles to
slowly fall.

×