Project 6e: nParticles and Fluids

Goal We are going to learn how to create dynamic effects using particles and fluids. The end result will be a fully composited and rendered animation of a burning log complete with roaring flames and sparking embers.

This project will be broken into three phases:


Before starting, check if Maya is set up to use Legacy Render Layers. Go to the Channel Box and look under the window. You should at least see two tabs labeled "Display" and "Anim". If a third tab labeled "Render" exists, you can continue on with the assignment. Otherwise, go to Windows > Settings/Preferences > Preferences > Rendering. Then, select "Legacy Render Layers" from the drop-down menu next to "Preferred Renders Setup System". Close out and reopen Maya to load the Legacy Render Layers.


Phase I: Particles

Particles represent tiny objects such as snow, dust, or sparks. Since there can be sometimes hundreds or thousands of these particles, it is infeasible to animate them by hand. Similar to what we did with nCloth and BiFrost, we can dictate the basic rules and behaviors we want our particles to have, and the particles will animate themselves according to these constraints. This phase will walk you through setting up a simple particle system that simulates sparks. You will want to be in the FX Menu Set for this assignment.

  1. The first step in setting up a particle system is to create a particle emitter. In the FX menu set go to nParticles → Create Emitter (Options). We will need to adjust several of the emitter's attributes. This can be done before creation or afterward through the Attribute Editor.

    Call the new emitter sparksEmitter. Since we want our sparks to come from a log, set the Emitter type to Volume and the Volume shape to Cylinder. Rotate and scale the new volume emitter until it resembles a log. If you hit Play, you should see particles being emitted downwards - this is due to the gravity attribute in the nucleus You can turn this off by going into the Dynamic Properties tab under the nParticleShape1 attributes and checking 'Ignore Solver Gravity'.

    Increase the frames in your Time Slider to 300. Going back to frame 0 will reset the particle simulation back to its initial state.

    By default Maya will try to play your effect in real-time. If it can not keep up with the computation required to simulate your effect, then it will cut some corners to make up time. This generally not what you want and can be especially problematic with fluids. To make sure Maya calculates every frame right click the timeline and go to Playback Speed → Play every frame, Max Real-time.

  2. Select the emitter and go to the Attribute Editor. Under Basic Emitter Attributes, change the Rate to 25. Under Basic Emission Speed Attributes, change Speed Random to 3.

  3. In the attributes of the nParticleShape, under Lifespan Attributes, change Lifespan Mode to Random range, Lifespan to 2, and Lifespan Random to 1. This means that every particle will last for anywhere from 1.5 to 2.5 sec.

  4. At the moment, the particles are emitted in all directions and travel in a straight line. We can affect the trajectory of a particle after it has been emitted by creating fields that are linked to the particles. Fields act as forces that affect the particles in a certain way, such as being pulled down by gravity..

    Fields can be linked to particles when they are created by selecting the particles before creating the field. With the particles selected (you can select the particles by clicking on the nParticle1 object in the Outliner) create an Air and a Turbulence field from the Fields/Solvers menu and make sure they are linked to the particles. The default settings for the Air field should be sufficient, but change the Magnitude of the Turbulence field to 25.

  5. You may have noticed that the particles currently render as white dots. While Maya does have a default particle shading system to control the particle color and shape, the Arnold renderer does not support rendering it.

    Navigate to the Arnold dropdown menu under the nParticleShape tab in the Attribute Editor. Uncheck the 'Opaque' box. Set the 'Min. Particle Radius' to a value around 0.01. In the field next to "Export Attributes", enter 'age'. We can use this 'age' value to drive the color and opacity of the particle based on the lifespan of the particle.

  6. To change the appearance of the nParticles, we will assign a new aiStandardSurface material. Give the material a descriptive name and pull up the shader in the Hypershade. To make the particles more easy to see, we can turn up the emission weight of the shader.

    Create a ramp node and connect the 'Out Color' to the "Base Color' and 'Emission Color' of the aiStandardSurface node. This ramp node will control how the color changes as the particle ages. Change the 'Type' under Ramp Attributes to 'U Ramp'. Change the colors on the ramp so that it is similar to the image below. Also, delete the place2dTexture node attached to the ramp.



    Create a 'Particle Sampler Info' node and aiUserDataFloat node. The 'Particle Sampler Info' node will allow the shader to access information from the particles it is attached to. Connect the 'Age' attribute from the 'Particle Sampler Info' node to the 'Default' attribute of aiUserDataFloat node. To do this, drag the output from the 'Particle Sampler Info' node to the white dot on the left side of the aiUserDataFloat node, click 'Other...', then select 'default'. Select the aiUserDataFloat node and set the 'Attribute' field to 'age'.



    Connect the 'Out VCoord' of the 'Particle Sampler Info' node to the V Coord of the ramp node under the 'Uv Coord' inputs. The 'Particle Sampler Info' 'Out VCoord' can be found by selecting the outputs on the right side of the 'Particle Sampler Info' node and navigating to 'Out Uv Coord' > 'Out VCoord'. Below is an image showing where more input and outputs can be found on a Maya node if the desired inputs or outputs do not show up when the node is expanded.



    While we could connect the aiUserDataFloat 'Out Value" output into the UCoord of the Ramp node, this would cause the colors of the ramp node to "wrap" when the particle life is longer than average. Instead, create a MultiplyDivide node. Set the 'Operation' to 'Divide', and connect the aiUserDataFloat 'Out Value' to the 'Input 1X' input in the MultiplyDivide node. In the MultiplyDivide node's 'Input 2X' field (leftmost field), enter the maximum particle age (Lifespan + (Lifespan Random)/2). In this case, plug in 2.500. Plug the MultiplyDivide node's 'Output X' output to the 'U Coord' of the Ramp node.



    Afterwards, your shading network should look something like this.

  7. For now, the particles have a constant emission weight and opacity over their lifespan. We can use another ramp node to control the emission weight and opacity of the particle so that the sparks appear to die off. Add a ramp shader and adjust the color to go from white to black so that the particles will be the most opaque when emitted. Change the type to 'U Ramp'. Connect the 'Out Color' of this ramp to the 'Opacity' of your sparks shader, and connect 'Out Color R' of this ramp to the 'Emission' of the sparks shader. As before, connect the 'Multiply Divide Node' 'Output X' to the 'U Coord' and 'Particle Sampler Info' 'Out VCoord' to the 'V Coord', respectively, of this ramp.

    Overall, the shading network should look something like this.


  8. If you render your particles, they should look like those in the image below. If your particles look too small, you can always increase the minimum particle size in nParticleShape's Arnold tab: Min Particle Radius.

    As a finishing step, you will need to do a little Outliner cleanup. Group your fields and name the group "fields". Group your particle nodes (particles, nucleus, emitter) and name the group "particles". Group those groups together and name it "sparkFX".

  9. Save your file as [lastname]_[firstname]_effects_p1.ma

Phase II: Fluids

When you think of the word fluids, you probably imagine an effect that creates the splashing of water. In Maya Fluids refers to fluid dynamics, which deals with the interaction of fluids of similar density such as fire and air, smoke and air, or ink and water. Fluids can create very convincing effects, but as always, there is a performance tradeoff. Fluids are expensive to set up and expensive to render. In this phase we will walk you through creating a simple fire.

A large battle during a production, especially with effects, is finding ways to reduce your build time. We are going to use a little shortcut that will allow us to create a fire effect that would likely take several hours to build from scratch.

  1. In the same file from Phase I, using the Dynamics menu set, go to Fluids → Get Example → Fluid.... This will load the Maya Visor where we can select from a range of premade effects. These examples work well as a starting point to achieve some fairly complex effects. Choose Fire, select the TurbulentFlame.ma icon, Middle mouse click and drag the icon to your viewport.
  2. Unlike particles, fluids are contained in boxes (containers) which they cannot escape. The insides of these containers are divided into a set of "voxels" - points in space at which the various properties of the fluid are calculated. Increasing the resolution results in a higher fidelity image, but also takes longer to calculate and consumes more memory.

    The first step will create a fluid container (Flame) with a fluidEmitter attached to a nurbs torus. Don't worry about all this junk, we only want the emitter settings and the fluid container. This is where some trickery comes into the mix. We want to 'steal' the emitter settings from fluidEmitter and apply them to a new one we are about to create. In your Outliner, underneath the nurbsTorus, select the fluidEmitter and open the attribute editor. Select Presets → Save fluidEmitter preset.... Name it something like flame_preset.

  3. Now that we have our preset made, we can delete everything EXCEPT the fluid container (Flame) and your SparkFX group. Move and scale the fluid container so it fits the sparksEmitter. Scaling up the container will result in a more realistic fire.
  4. Create a polygon cylinder and name it log. Rotate, move, and scale your log so it fits inside your sparksEmitter. Shape it like in the image below.

  5. Now we are going to create our own fire emitter. First select your log, THEN shift+select the fluid container. In the Dynamics menu set, go to Fluids → Add/Edit Contents → Emit from object (options). Name the emitter logFlame_emitter and make sure the emitter type is set to surface. Click Apply and close. Select the emitter, and then in the attribute editor apply your created preset.

  6. At this point go ahead and hit 6, rewind and play the timeline. You should see Maya's attempt to preview what your fire is looking like. Find a spot that you like and take a quick render to see how we are doing. If all goes well you should have something that looks like the image below.

  7. You should now change the initial state of your sparks and your fire to make your fire is going strong from the beginning. For the fire go to Fields/Solvers → Initial State → Set Initial State.  For the sparks go to Fields/Solvers → Initial State → Set for All Dynamic.
  8. Apply a bark shader to your log. You can use this bark texture or find/create another one.

     

  9. Save your file as [lastname]_[firstname]_effects_p2.ma You are now ready to render and composite your fire! You'll be doing this in the next tutorial.
Turn In You will be graded on the following: Turn the following into Collect-It on Catalyst: