Examples of using the Particle Sampler Info node

 
 
 

To help you use the Particle Sampler Info node: we’ve included the following examples to help you learn how to use the Particle Sampler Info node to achieve some commonly used effects. Refer to Set Particle Sampler Info node attributes for complete information on Particle Sampler Info node attributes.

Use the Particle Sampler Info node to drive a texture placement node

Here is an example of the first strategy—using the Particle Sampler Info node to drive a texture placement node, which textures the shader color. In this example, we’ll use the particles’ age to color the particles.

Example: Using particle age to color particles

  1. Make a cone emitter emitting upwards with a speed of 8, set the particles’ Lifespan Mode to Constant with a Lifespan of 2, and set their Render Type to cloud.

    To do this, you can copy the following MEL commands from the Maya Help and paste them into the Script Editor:

    emitter -pos 0 0 0 -type volume -r 100 -vsh cone -alx 8; particle; connectDynamic -em emitter1 particle1; setAttr particleShape1.lifespanMode 1; setAttr particleShape1.lifespan 2.0; setAttr particleShape1.particleRenderType 8;
    
  2. Select the particle shape and display the Attribute Editor.
  3. Select the particleCloud tab, and press the button next to Life Incandescence to display the Create Render Node window.
    Tip

    Incandescence is the same as color but is self illuminating so you don’t need to add a light.

  4. In the right panel, click .

    This creates a new ramp, a texture placement node, and a Particle Sampler Info node. Life Color isn’t actually an attribute at all—it’s just a control in the Attribute Editor that tells Maya to set up these connections to color for you.

  5. Play the scene back and render.

    You’ll see the particle color textured by the ramp as the particles age.

    Now we’ll change some of the controls in the Particle Sampler Info node.

  6. Select the particle shape and display the Attribute Editor. Click the particleSamplerInfo1 tab.
  7. Turn on Inverse Out Uv and re-render.

    The colors are reversed—instead of the particles changing from red to green to blue, they change from blue to green to red.

    Now we’ll change a control on the texture node.

  8. In the particle shape Attribute Editor, click the particleCloud tab.
  9. Click the Input Connection button next to Life Incandescence.
  10. Click place2DTexture1.
  11. Set Noise UV to 1.0 and 1.0 and re-render.

    Noise is applied to the placement of the ramp creating randomness in the red, green, and blue particles.

  12. Change Noise UV back to 0.0 and 0.0.
  13. Click Load Attributes and display the particle shape Attribute Editor.
  14. Change Lifespan Mode to Live forever.
  15. Select the tab for the Particle Sampler Info node.
  16. Change the Out Uv Type to Absolute Age and set a normalization value of 1.
  17. Rewind, play about 100 frames, and render.

    Notice that the particles cycle through the ramp more than once as they age.

Use the Particle Sampler Info node with per-particle attributes

Here is an example of the second general strategy—driving shader color directly with rgbPP. Use this strategy when you want to use expressions or ramps driven by something other than age.

Example: Using the Particle Sampler Info node with rgbPP

  1. Make a cone emitter emitting upwards with a speed of 8, set the particles’ Lifespan Mode to Constant with a Lifespan of 2, and set their Render Type to cloud.

    To do this, you can copy the following MEL commands from the Maya Help and paste them into the Script Editor:

    emitter -pos 0 0 0 -type volume -r 100 -vsh cone -alx 8; particle; connectDynamic -em emitter1 particle1; setAttr particleShape1.lifespanMode 1; setAttr particleShape1.lifespan 2.0; setAttr particleShape1.particleRenderType 8;
    
  2. Select the particle shape and select Fields > Gravity.
  3. With the particle shape selected, display the Attribute Editor.
  4. Under Add Dynamic Attributes, click Color.

    The Particle Color window is displayed.

  5. Click Add Per Particle Attribute and click Add Attribute.
  6. In the Attribute Editor, click the particleCloud1 tab.
  7. Next to the Color attribute, press the map button to display the Create Render Node window.
  8. In the Create Render Node window, under Maya, click Utilities.
  9. In right panel, click .

    This automatically creates a new Particle Sampler Info node and connects its color output to the color attribute. (If you had already created a Particle Sampler Info node, you could use that and connect it directly, in the connection editor.)

  10. Select the particle shape tab in the Attribute Editor. Under Per Particle (Array) Attributes, right-click rgbPP and select Runtime Expression (before or after dynamics calculation).
  11. In the Expression Editor, enter the following expression:
    particleShape1.rgbPP = << mag(particleShape1.velocity) /
    	10, 0.0, 1 -mag(particleShape1.velocity)/10 >>;
    

    This tells Maya to change the particle color from blue to red as the velocity increases.

    Tip

    We used an expression in this example to achieve a specific effect. However, you don’t have to use expressions with the Particle Sampler Info node. You can also use a ramp, which will give you a different effect.

  12. Add a light to the scene. We recommend a directional light.
  13. Play about 75 frames and render.

    Notice that the Particle Sampler Info node outIncandescence output automatically uses rgbPP if that attribute is present. If there is no rgbPP, it uses colorRed/colorGreen/colorBlue, if they are present.

    The advantage of using rgbPP is that you can set or animate its value in any of the ways available for per-particle attributes, and see the results in software. You will also then be using the same color attribute in both hardware and software rendering.

    However, rgbPP can be animated only with expressions and ramps (or the component editor). The advantage of using Life Color is that you get a texture placement node and can make use of its additional controls. In particular, you can use any texture, not just a ramp, since you get both u and v control. You can connect any compatible Particle Sampler Info node attribute you want.

Set transparency with the Particle Sampler Info node

As with color, Life Transparency is still available. It uses the outUvCoord attribute of a Particle Sampler Info node in conjunction with a texture placement node, instead of a particle transparency mapper and age mapper.

As with color, you can use per-particle attributes such as opacityPP directly. You use the outTransparency attribute of the Particle Sampler Info node.

Example: Creating fading particle

  1. Make a volume emitter with the shape of a flat cylindrical disk, with Speed Away From Axis equal to 1 and other speeds zero.

    To do this, you can copy the following MEL commands from the Maya Help and paste them into the Script Editor:

    emitter -pos 0 0 0 -type volume -r 100 -sro 0 -spd 1 -vsh cylinder -afx 1; scale -r 5 0.5 5 ; particle; connectDynamic -em emitter1 particle1;
    
  2. Reduce Rate (Particles/Sec) to 50.
  3. Set the particle’s render type to cloud. Click Add Attributes for Current Render Type and set the Radius to 1.5.
  4. In the Attribute Editor, under Add Dynamic Attributes, click Opacity. Turn on Add Per Particle Attribute and click Add Attribute.
  5. Under Per Particle Attributes, right-click opacityPP and select Runtime Expression (before or after dynamics calculation).
  6. In the Expression Editor, enter the following expression and click Create:
    opacityPP = 1 / (0.01 + mag( position ));
    

    (We added 0.01 in the denominator to avoid dividing by zero when particle is at the origin.)

  7. Select the particleCloud shader tab and click the map button for Transparency (not Life Transparency).

    The Create Render Node window appears.

  8. In the Create Render Node window, under Maya, click Utilities.
  9. In right panel, click .

    This create a new Particle Sampler Info node and connects its outTransparency to the shader transparency. As with color and incandescence, the outTransparency output automatically uses opacityPP, if that attribute is present, otherwise it uses opacity.

    Opacity and transparency have an inverse relationship: the more opaque something is, the less transparent it is. If you connect the outTransparency output of the Particle Sampler Info node, then the node automatically converts opacity to transparency so that you get the right result.

  10. Add a light, play the scene about 50 frames, and render. A camera view from the top, looking down the y-axis, is best. The particles will appear more transparent the further they are from the origin.

Control noise on a per-particle basis

You can connect any per-particle attribute to the attribute in the shader that you want to control. You can then put an expression on the per-particle attribute to control it exactly the way you want.

Example: Creating smoke

  1. Make a simple curve emitter emitting particles vertically upward.

    To do this, you can copy the following MEL commands from the Maya Help and paste them into the Script Editor:

    curve -d 3 -p -6.861087 0 7.36723 -p -2.43128 0 2.685247 -p 2.685247 0 -2.43128 	-p 6.968851 0 -6.714884 -k 0 -k 0 -k 0 -k 1 -k 1 -k 1 ; emitter -type curve -r 100 -sro 0 -nuv 0 -cye none -cyi 5 -spd 6 -srn 0 -nsp 0 	-tsp 0 -mxd 0 -mnd 0 -dx 0 -dy 1 -dz 0 -sp 0 ; particle;
    connectDynamic -em emitter1 particle1;
    
  2. Set the particles’ lifespan mode to random range. Set lifespan to 2 and lifespanRandom to 2.
  3. Set the particle rendering type to cloud. Click Add Attributes for Current Render Type, and set Radius to 1.5.
  4. Select the particleCloud tab, and set the color to a light gray color, or any other color you like.

    Now we’ll use any per-particle attribute you aren’t using. For example, we have no need of parentU and parentV here, so we’ll use that.

    Note

    For simplicity, we used parentU and parentV in this example because they are easily added and weren’t being used. However, you can use any dynamic attribute—even those you define yourself.

  5. Select Attributes > Add Attributes. Click the Particle tab in the Add attribute window.
  6. Select parentU and click Add. Select parentV and click Add. Click OK.
  7. Right-click either parentU or parentV, select Runtime Expression (before or after dynamics calculation), and add the following expression:
    parentU = 0.7 + 2*(age/finalLifespanPP); parentV = age /(1.5*finalLifespanPP);
    

    We want the particles to get less dense and more noisy as they age, the way smoke would.

    Tip

    We used an expression in this example to achieve a specific effect. However, you don’t have to use expressions with the Particle Sampler Info node. You can also use a ramp, which will give you a different effect.

  8. In the particleCloud Attribute Editor, click the map button next to noise.

    The Create Render Node window appears.

  9. In the Create Render Node window, under Maya, click Utilities.
  10. In right panel, click .

    The Connection Editor appears.

  11. Connect the Particle Sampler Info node’s parentU to Noise, and connect parentV to Density.
  12. Add a light. Play the scene to about frame 60 and render.