Lesson 3: Create the water surface
 
 
 

Lesson setup

To ensure the lesson works as described, do these steps before beginning:

  1. Open the scene file named Liquid_Simulation_3.mb.

    This file can be found in the GettingStarted directory that you set as your Maya project:

    GettingStarted/nParticles/Liquid_Simulation_3.mb

    This scene includes textured models that have been created for you. The desk, water pitcher, and water glass provided are all polygon meshes. The water pitcher mesh is animated so that it lifts off the desk, tips as to pour into the glass, and then sets back down to the desktop.

Convert your nParticles to a polygon mesh

You can convert an nParticle object to a polygonal mesh, which you can then treat like any other polygon. For example, you can improve the quality and overall look of your liquid simulation by performing a polygon smooth operation on the nParticle output mesh. Polygon smoothing will increase the number of polygons in your output mesh to give it a smoother overall appearance.

Throughout this tutorial, when played back each simulation, you notice that the nParticles take some time to settle down before the pitcher animation starts. This occurs because, at frame 1, the Nucleus solver begins after the nParticles arrive at equilibrium by setting the initial state for the simulated nParticles. From frame 1 to 30, the nParticles react to this force, arriving at a state of equilibrium during the first 30 frames of the simulation. Be aware that any force exerted on the nParticles, such as the pitcher lifting off the desk, disrupts the equilibrium between the nParticles and the force of gravity.

You can specify that your simulation begins after the nParticles arrive at equilibrium by setting the simulation’s initial state.

To set the initial state of the nParticles

  1. Play the simulation and stop the playback at or around frame 30.
  2. In the Outliner, -select nParticle_Water.
  3. Select nSolver > Initial State and then select Set From Current.

  4. Rewind the simulation to the start frame.

To convert your nParticle object to a polygon mesh

  1. In the Outliner, select nParticle_Water.
  2. Select Modify > Convert > nParticle to Polygons.

    The PolySurface1 object appears in the Outliner, and a new polySurfaceShape node appears in the Attribute Editor.

  3. Rename the new polygon object, in the Outliner, double-click PolySurface1, and type Water_Mesh.

  4. In the Attribute Editor, select the nParticle_WaterShape tab.
  5. In the Output Mesh section, set Blobby Radius Scale to 3.5.

    In the scene view, the nParticle output mesh superimposes on your nParticle object.

  6. In the Output Mesh section, select Quads from the Mesh Method list.

    Selecting Quads will convert your nParticles to a quad-based polygon mesh. The Tetrahedra, Cubes, and AcuteTetrahedra coverts nParticle objects to triangulated meshes.Quad-based polygon meshes respond better to polygon smoothing than triangle-based meshes.

  7. Experiment with the following Threshold values. Dolly and tumble the scene so that you can closely observe any problem areas.
    • Set Threshold to 0.2.

      At this value, the nParticle output mesh is extending beyond the nParticle object’s collision width and penetrates the inner wall of the pitcher’s mesh.

    • Set Threshold to 1.0.

      At this value, the nParticle output mesh is cutting into the nParticle object, and is no longer surrounding the nParticles.

    • Set Threshold back to its default value of 0.6 and continue with the tutorial.

  8. To apply smoothing to the corners of the mesh’s quad, set Mesh Smoothing Iterations to 2.

Cache your nParticle simulation

You will notice that since you converted the nParticle to an output mesh, the playback of the simulation has slow down considerably. This is due to the additional calculations required for nParticle and its associated output mesh. However, you can use Maya's nCache feature to cache the simulation and play the scene at full speed.

To cache your nParticle simulation

  1. Before caching the simulation, hide Water_Mesh object, by selecting it in the Outliner, and selecting Display > Hide > Hide Selection.
  2. In the Outliner, select nParticle_Water.
  3. Select nCache > Create New Cache> .

  4. The Create nCache Options window appears.
  5. Set the Cache directory to the folder to which you want your caches saved. Set the Cache name to LiquidSimulationCache. Click Create. Maya will begin to play the scene automatically and store the frames in the directory you specified. When it is finished, click the Play button in the animation controls. You will notice that the scene now plays back faster. However, if you change any of the nParticle attribute settings you will need to create a new cache to view your changes.

In the next section of this lesson, you use the cached simulation to help optimize specific areas of the simulation.

Finishing your nParticle Liquid Simulation

To finish the liquid simulation, you set the Motion Streak attribute to optimize the motion of the nParticles during the pouring sequence of the animation. You also add an ocean shader, which gives the water surface transparency and the reflective properties of water.

To set Motion Streak

  1. In the Timeline, go to frame 119, and the dolly and tumble the scene so that you have a close-up view of the water nParticles pouring into the glass.
  2. Show the Water_Mesh object, by selecting it in the Outliner, and selecting Display > Show > Show Selection.

    At this frame, you notice that the droplet mesh pouring into the glass look too spherical, almost like globs. The does not resemble the continuous flowing behavior of water when it is poured into a glass.

  3. To make the mesh a continuous flowing object, set the Motion Streak attribute.
  4. In the Attribute Editor, click the nParticle_WaterShape tab.
  5. In the Output Mesh section, set Motion Streak to 0.150.

    Maya updates the output mesh with the new setting.

    The mesh looks more like water. In the last step of this lesson, you apply an ocean shader to the nParticle output mesh so that it has the transparency and the reflective properties of water.

To apply an ocean shader to the mesh

  1. In the scene view, select the Water_Mesh object.
  2. Open the Hypershade window by selecting Windows > Rendering Editors > Hypershade.

    The Hypershade window opens.

  3. In the Surface list, select Ocean Shader.
  4. In the Work Area tab, Right-Click oceanShader and from the marker menu, select Assign Material to Selection.

    Your nParticle output mesh now appears white. To see the effects of the ocean shader, you need to render a frame of your simulation.

  5. In the Render menu set, select Render > Render Current Frame> .

    The current frame appears as a rendered image in the Render View.

Beyond the lesson

In this lesson you learned how to: