Hair

Next we will add some hair to Harry's head. You can continue the tutorial from the previous section by loading the sample file 'tutorprojects/harry/body_and_uvskin.r3d'.

We start hair modeling by drawing a single hair element: a NURBS curve.

So, go to the NURBS tab of the toolbar. Activate the Curve tool and draw a single hair into the view window.

If you want to create long hair, use a sufficient amount of points so that hair bending, curly hair etc. details can be represented by the geometry. In this example, we will make relatively short hair, so, 5 or 6 points are quite enough. You can place the points at regular intervals. Position of the curve does not matter. Its shape should be quite a straight line - hairs will be bent and made curly later. After the last point, select Accept or hit the Enter key to finish the curve tool. Then rename the curve as Hair.

Each hair will be positioned to the skin using the pivot point - the center point of red, green and blue object handles. To ensure that hair will properly stick into the skin surface, not float above it, we have to move the pivot point along the hair.

You can do this by carefully clicking the center point of the object handles, and then a second time, say, 10% towards the opposite end of the hair. The pivot point can be moved also by activating the move tool ('m' hotkey) and selecting Target=Handles from the tool control bar.

[Note] Note
The hair will be added using the Paste tool. The tool rotates the pasted objects so that their blue object space axis matches the surface normal. Therefore, make sure that the hair object you created has a correct object space orientation. The points should approximately follow the blue move handle line. A new NURBS curve has the correct orientation after its creation, but the orientation can change if you point edit the curve heavily or apply tools, which change the orientation, such as the Normalize Object Space tool.

To ensure quick drawing of a large number of hair objects, open the property window and go to the Wire tab. Check the Hide Geometry option and set Show Control Polygon=Always. Control polygon is the simplest way to draw the curve geometry. It is not totally accurate but good enough for our purposes. Clear the Draw Knots option.

While the curve is still selected, switch to the Spec tab of the property window. Set both Head and Tail radius to a suitable value - you may try 1 mm first. It's quite thick, but we can adjust it later. Now the hair will have a constant radius, just like human hair. Using a lower tail radius to get a tapered shape is naturally possible. Because of antialiasing related reasons, infinitely thin zero tail radius is not recommended for animated hair. It is wiser to use 'almost zero' radius such as 10 % of the Head radius value. Decrease the Quality from the default value 24 (suitable for scanline) to the minimal value 2. That is most likely sufficient and renders much quicker. Then switch to the leftmost Gen tab and clear the option Invisible in photo realistic rendering.

Next we scatter some hundreds of hair copies on top of Harry's head. We do not have to add every single hair, but only a number, which is enough to define the hairy area, hair growth direction and other such variations. The rest will be generated by interpolating the sample hairs.

Make sure that the curve object - the sample hair - is still selected. Then take a top view over the head. Go to the Lattice mapping tab and activate the Paste tool. Select the Airbrush option, set Count = 1, Project=Surface and Rotate=Normal.

Move the mouse pointer over the view window. The brush size is shown as a circle. Adjust the diameter to approximately one quarter of the diameter of Harry's head (with the scroll wheel of the mouse or from the tool bar). Too large radius will scatter copies too distantly, making interpolation hard. Too small radius just means lot of pasting work to cover the head top.

Press LMB down to start pasting and move the mouse around at a constant speed to add hair. For an optimal result, try to fill the surface by pasting hair bands back and forth across the head. Make sure that these hair bands overlap enough; otherwise you may see visible gaps between them.

While pasting, you can release the LMB, change the view direction and continue again. If possible, continue new pasting from where you ended the previous brush strokes. You can also adjust the brush radius any time. Try to avoid brushing hair to the horns and other undesired places. However, misplaced copies do not matter much because we can relatively easily delete them later.

When a proper area of the head is covered by hair samples, click Accept to finish the tool. If you are not happy with the result, apply Undo and hit 'a' hotkey to start pasting again with the same options.

When hair pasting is done, the select window lists a large number of new objects. Curve duplicates are automatically selected and you can see their count in the top area of the select window. For a simple character like Harry, 500-1000 hair samples can be enough. A high number of hairs will unnecessarily slow down further editing and especially animation actions. Therefore, it is wise to aim at a minimal sample count.

While the new hair copies are still active, select Drop to a level from the popup menu of the select window. Delete the original hair sample. Drag and drop the level containing the hairs from the root level into the level called 'harry' - hairs belong to the hierarchy of the character.

Open the hierarchy level that contains the hair curves on the select window (just click the little box at the left side of the level icon). After opening the level hierarchy, you can select individual hair objects again.

You can trim a symmetric hairline, and the same time, remove unwanted hairs as follows. Select any hair on the select window and hit Ctrl+a (or apply the pull down menu Edit/Select All). Then take a side view, zoom and pan so that you see the hairy area.

Press Ctrl key down to activate AND selection. Then press also '4' key down to activate lasso selection. Both keys held down, draw a loop that encloses the hairs you want to keep. Only the hairs inside the lasso remain selected.

Select Edit/Invert selection from the pull down menu (or use Ctrl+i) and hit the Del key. Undesired hairs are removed. If there are still some unwanted hairs left, for example around the horn and skull joining area, just zoom in heavily and click the hairs one by one and delete them by pressing the Del key.

Trimming the hairy area with the lasso selector

Let's experiment how to adjust hair direction and shape. Now all hairs are pointing perpendicularly away from the head. Select again all hairs like we just did above (use Ctrl+a). Take a side view, activate the rotate tool ('r' hotkey), set the About Pivot option from the toolbar, click in the middle of the head and then somewhere at the outer edge of hair. Move the mouse and observe how each hair rotates around its root. Rotate hairs so that they turn backwards and Harry gets a bit more aerodynamic haircut.

Each sample hair still has an identical shape, which is unnatural. To randomize the curves, make sure that all hair objects are still selected. Hit spacebar to put them into the point edit mode. Open the property window, go to the Spec tab, activate the Selected point field, type in 0 and hit Enter key. This selects the root point of every hair. Actually we do not want to dislocate the root point from the skin - it is the only point that must not move. So, apply the pull down menu Edit/Invert selection or press Ctrl+i. Now we have selected a suitable point set for geometry randomization.

Randomization can be applied using the Noise transform tool. Zoom in heavily to see part of hairs in detail. Go to the Transformation tab of the toolbar and activate the Noise tool. Click once in the view window; position does not matter because noise fills the whole space.

The second click position, however, is important. If you click close to the first point, the noise field will be dense and every single point moves quite randomly. If you leave more distance between the clicks - say a length of a hair or more - noise deforms hairs into recognizable turbulence patterns. After the second click, moving the mouse away from the click position increases deformation. The third click finishes the tool. Experiment freely with various distances - just hit Esc to cancel the tool and try again, or use Undo afterwards.

Randomizing hair points with the Noise transformation

So far, we have not defined any color for hair. We will now assign a unique color to each hair using a material. Hit spacebar to turn off the edit mode and select the parent level of the hairs. Go to the second (materials) tab of the select window. Select New/VSL material from the popup menu. A new material is added at the bottom of the list. Open the property window. Rename the new material as 'Haircolor' using the Name field. Select the 'Color' wizard and hit the Add button. A new Color field appears to the property window. Click the color square and pick a base color for the hair from the palette, for example a light brown (R=0.8 G=0.6 B=0.4). Then check the Advanced option. Click Surface properties in the shader tree to select it, open the popup menu and select the item New/Random. Set Density value of the created Random VSL object to 1.0 (to randomize everywhere), Minimum value to 0 and Amplitude to 0.2. Check also the 1D option if you just wish to change the darkness of hairs. 3D randomization will make hairs slightly colorful. Finally, in the General tab, change Operation from '=' to '+'. In other words, the material will make each hair a random amount lighter.

The material is now ready and you can close the property window. Make sure that the new Haircolor material is still selected. Select Map/Parallel from the select window and draw a parallel map box into the view window with 2 clicks. Map size and position do not matter, because the material simply picks a random value in each point.

[Note] Note
By using a Noise object instead of a Random object, you can assign hair colors that change less rapidly. With a suitable material, you can define color stripes or other patterns.

Switch back to the leftmost tab of the select window. Select the first hair object and then Edit/Select All to activate every hair object and the newly inserted parallel mapping, which is the last object in the level.

[Note] Note
If Select All for some reason does not highlight all hair curve names, then you have left the point edit mode on, and the first curve has all points selected. If this happens, scroll down to the end of object name list and Ctrl-click the last name to range select all objects.

Go to the Materials tab of the toolbar. Activate the Map2Obj tool. Set Target=Object, Source=Color and Destination=Color. These settings will copy material defined color into object colors. Then hit Accept. Now you can find, select and delete the parallel map object from the select window. We do not need it any more because colors are now stored to hair objects.

Time to save the project! Then find a suitable view angle to hair and hit the zero hotkey '0' to render the view window. The hair looks OK but is far too sparse. We will now add the already mentioned interpolation system, which produces more copies. Once again, select all hair curves. Go to the Creation tab of the toolbar, activate the Interpolator tool and click Accept.

With the new interpolator object selected, open the property window and go to the Spec tab. The default interpolation count 10 is quite OK - it will multiply hair count by 10. Set Min distance to a small value such as 0.001. That ensures there will not be 10 overlapping hairs within one-millimeter distance. Set max distance to a value, which is about 10%-20% of the diameter of the head. A value 0.1 prevents interpolation across distances higher than 0.1 meters. The idea is to interpolate curves that are 'relatively' close to each other. Interpolating a curve on the back of the head to another one on the forehead is useless because interpolated copies would be placed inside the skull. Another example: you would not want to interpolate cat's tail hair towards a hair in its ear because interpolated copies would float in the air.

We can also add some geometry randomization here: set the random value for example to 0.01. This makes each interpolated copy unique. Do not set too high random value because hair can get dislocated from the skin. Do you remember when we positioned the pivot point of the first hair? The random value should not exceed the distance of the pivot and the first point of the curve.

Now interpolator is ready. Render a test image ('0' key) and adjust its parameters if necessary. Bilinear interpolation often gives a better result, especially if the number of used samples is low.

Save the project with a new file name, such as 'hairy_harry', to backup your work.