Thursday, August 27, 2015

Creating Maya nHair Using ZBrush FiberMesh

In this post, I will go through how you can export FiberMesh from ZBrush to Maya to render. I will focus on the procedural steps, not the artistic aspect.
Hair rendered in Maya using Mental Ray
To manage expectation, let me point out that the post only covers the creation of the nHair system. At the end of it, you do not get the render above yet. To get that render, you will need to go through this post as well as the rendering post.

 1. Creating FiberMesh Hair in ZBrush

There are tutorials out there that show you how you can create hair using FiberMesh. I recommend going through this video tutorial: "Fibermesh : Zbrush to Maya, Efficient Workflow Pt1 /// ZBRUSH" (it is 15 minute long).
In addition, I got excellent tips from Charlie Kim.
Figure 1. Brush menu.
  • Go to Brush menu; expand FiberMesh section (see Figure 1).
    • Set "Preserve Length" to 100.
      • This means whatever we do to the Fibers using the active brush, the Fibers will remain the same length.
      • I find this is the key setting that makes working with FiberMesh (relatively) easy.
    • The "Front Collision Tolerance" enables a collision detection between the Fibers and the head mesh. On the other hand, the collision detection causes the Fibers to look "jittery".
  • Further down Brush menu, expand Auto Masking section (see Figure 1).
    • "Mask By Polygroups" enables you to affect only the polygroup you start your stroke on. I turn this on and off depending on what I am doing.
    • "FiberMesh Mask Curve" determines how much your stroke affects the Fiber along the Fiber strand.
      • By default, the mask is maximum at the root. This is why it is impossible to move the root of Fibers. This is also why the tip moves the easiest.
      • Change the shape of the curve based on what you are working on.

Here is how my FiberMesh looks.
Figure 2. Left: screenshot of ZBrush viewport. Right: BPR render.

2. Exporting FiberMesh to Maya

  1. Go to Tool menu.
  2. Make sure you select the SubTool that contains your FiberMesh (see Figure 3).
  3. Scroll further down to FiberMesh section, "Export Curves."
  4. Click "Export Curves" button.
  5. Make sure you save as "Maya Ascii Format (*.ma)" (see Figure 4).
Figure 3. Tool menu.
Figure 4. "Export FiberMesh Curves" dialog.
Now we are ready to open the curves in Maya.

3. Creating Hair in Maya using nHair

Before importing the curves, let us create an nHair system first.
  1. Create a plane.
    • This plane is just a temporary dummy to create nHair system; we will delete it later.
  2. Make sure you select "nDynamics" menu set (see Figure 5).
  3. Click "nHair" > "Create Hair" (see Figure 5).
  4. Figure 5. Creating nHair system.
  5. Open Outliner.
  6. Figure 6. The Outliner after we created nHair.
    • Notice that Maya created 4 objects (see Figure 6): hairSystem1, hairSystem1Follicles, pfxHair1, and nucleus1.
    • hairSystem1 is where we set parameters to control the look of the hair a well as its dynamic behavior in simulations.
    • pfxHair1 is the paint effect that gets rendered.
    • nucleus1 is the Nucleus simulation solver.
    • In this method, we do not need hairSystem1Follicles.
  7. Delete hairSystem1Follicles.
Now we are ready to import the curves.
  1. Click "File" > "Import".
  2. Select the file with hair curves and click "Import".
Depending on the Fiber count you had in ZBrush, Maya viewport may slow down drastically. In this case, you may want to hide the curves.
Next, we will add the imported curves to the nHair system we created earlier.
  1. Select the curves.
  2. Click "nHair" > "Assign Hair System" > "hairSystemShape1" (see Figure 7).
    • Maya may take a while if your curve count is high.

Figure 7. Adding curves to nHair system.
If we open the Outliner, we can see that Maya created a new group hairSystem1OutputCurves. This is what the nHair system needs to generate hair. The generated hair is in pfxHair1.
Figure 8. The result of adding curves to nHair system.
Let us take a close look at the generated hair.
Figure 9. Left: Each curve (green lines) has multiple hairs (brown lines). Right: "Hairs Per Clump" parameter.
Each imported curve actually has multiple hairs (see Figure 9 left). This reason is the default setting of hair system. Here is how you can make sure there is 1 hair for each curve:
  1. Select the shape node of the hair system. In my case, it is called "hairSystemShape1".
  2. Open Attribute Editor.
  3. Expand "Clump and Hair Shape" section.
  4. Set "Hairs Per Clump" to 1.
    • By default, this value is 10 (see Figure 8 right). This is why each curve has multiple hairs and therefore overall the hair looks thicker.
This opens up a new possibility: we can set a low Fiber count in ZBrush. This way, we export fewer curves; which means importing and hair generation in Maya will be faster. Then, to compensate, we set "Hair Per Clump" parameter to a value greater than 1.

Back to our hair, here is how it looks in the viewport and Maya software render.
Figure 10. Left: viewport render; right: Maya software render.

And that is it! You can now render the hair using your favourite renderer. In the next post, I will cover how to render the hair system using Mental Ray (and how I got this render below).
Figure 11. The same hair system rendered using Mental Ray.

No comments:

Post a Comment