Sunday, November 29, 2020

Preparing Mesh Hair

Tonight I ran into some trouble when I was trying to convert the hair below to particles, and added some tools to deal with it.

At the top of the Hair section we now find the Print Statitistics button. This tool already existed in the Low-poly section, but it is convenient to duplicate it here because we want to keep track of how heavy the hair is before converting.  This beauty is a real heavy-weight with over half a million vertices.

  Verts: 566945, Edges: 419810, Faces: 139156

We don't want to convert such a heavy mesh to particles, both because conversion times grows fast with the number of particles (at least quadratically), and the resulting particle hair would be very unwieldy. To deal with that problem, there is a new tool called Select Strands By Size, which groups strands according to the number of faces and selects the groups that we want.

When we press the button a dialog appears where we can select the sizes. It takes some time before the dialog appears, because the mesh must first be analyzed and the faces grouped by size. In this case there are four groups, with 0, 40, 44 and 1156 vertices. Select that latter, which is not a strand but the hair cap.
Separate the selected vertices to a new object which we rename to Scalp. We also changed the viewport color of the hair cap material so we can distinguish it from the hair.
Invoke Select Strands By Size once again, and select the groups with 40 and 44 faces. We want to delete the strands with size 0, but for some reason nothing is selected when we select that group. Therefore we select the other two groups and then invert the selection.
Here is the inverted selection which consists of stray verts only, and the hair after the stray verts have been deleted. We can check the size again with the Print Statistics tool:

   Verts: 282860, Edges: 417430, Faces: 138000

Half of the vertices have disappeared, but the number of edges and faces has only decreased a little, probably because the scalp mesh was separated.

The hair mesh is still huge with 138,000 faces, and will take a very long time to convert. A reasonable size is 30,000 faces or less. To reach that number, we now Select Random Strands with a fraction = 0.8. This will select 80% of the remaining faces at random. Note that the semantics of this tool has changed; previously we specified the fraction of vertices that were not selected.

Delete the selected vertices and toggle out of edit mode. Again we check the size of the mesh with the Print Statistics tool:

Verts: 57342, Edges: 84623, Faces: 27976

The mesh now weighs in at almost 28,000 faces, which can be converted in a reasonable time, ca five minutes on my computer. It is a good idea to check the hair from different angles to ensure that there are no large bald spots.

Now the mesh is prepared for conversion to particle hair.

Select the hair and the scalp mesh, and press Make Hair. The meshes must be selected in the right order, with the hair active. For convenience the two meshes are listed below the button, so we can easily tell if they have been selected in the wrong order.

If we use the default options, the result is an unpleasant surprise.

The reason for this behavior is that the strands are oriented bottom-up in UV space. The UV coordinates are used as coordinates along the strands. The default assumption is that the strands are oriented vertically in UV space, with the roots at the top and the tips at the bottom. This has been the case in almost every hair that I have encountered so far, e.g. the Toulouse hair that comes with DAZ Studio. However, in this case the strands are oriented bottom-up, so the roots are close to the bottom of the UV.

To fix this, there is a new option in the pop-up dialog, Strand Orientation, which can take on four different values, depending on the orientation of the strands in UV space.

  • Top-Down: Vertically in UV space, with roots at the top (default).
  • Bottom-Up: Vertically in UV space, with roots at the bottom.
  • Left-Right: Horizontally in UV space, with roots to the left.
  • Right-Left: Horizontally in UV space, with roots to the right.

We select Sheet in the Create section and set Strand Orientation to Bottom-Up. We also resize the hair to a hair length of 40.

And here is the particle hair, in the viewport and rendered.