In the previous movie, we used a top-down method
to generate an nHair system based on our XGen guides,
then cached the XGen guides driven by that nHair system to animate the XGen primitives.
In this movie, we'll use a bottom-up approach to give us finer control over the nHair simulation
in a more complex animation scenario.
Make sure you set your project folder to the provided scene folder,
then open the file "01-XGen_hair_part5_start.mb".
This file contains an animated version of the bust we started with in part 3.
As we established in the previous movie, animating this hair using a top-down approach
would limit our ability to customize the XGen primitives during simulation.
Instead, let's approach the nHair generation process using an Anim Wire modifier.
This modifier adds dynamic curves, at locations you specify, to the XGen description.
Maya then assigns each XGen primitive to use one of these curves as a basis for simulation.
Before we do that though, there's a collision issue we have to deal with.
Notice how a lot of the hair primitives are penetrating the bust.
To better view this, go to the Preview/Output tab and change the Primitive Color value.
In the previous movie, we tried to deal with this problem in the nHair simulation
by using the bust as a passive collider nRigid object.
However, that only allowed the nHair curves, and by extension the XGen guides,
to collide with the mesh.
The XGen primitives themselves had no idea where the collision mesh was
since they simply interpolate between the guides.
This time, we’ll add a Collision modifier.
This gives the primitives themselves the ability to detect and resolve collisions with the mesh.
To do so, this modifier requires an Alembic cache interpretation of the collision mesh.
You'll recall we created one of these Alembic caches in the previous movie.
First, turn off the XGen Preview since we’re only focusing on the geometry at this point.
Select the bust, then go to Pipeline Cache > Alembic Cache > Export Selection to Alembic.
Save the cache in the cache directory and make sure the time range is set to the full Time Slider.
Once Maya caches the bust animation,
set the Collision modifier’s Mesh File to reference this new cache.
Update the XGen preview.
Notice this time the hairs collide with the mesh.
This is already a nice improvement over our previous method, although not quite perfect.
While there are a few hairs still penetrating the geometry,
these will mostly be cleaned up after we animate the guides.
Remember that if you ever make changes to your bust animation,
you'll need to regenerate the Alembic Cache.
Now you're ready to add an Anim Wire modifier.
Scroll down to the Control Map section.
We’ll create a new map to determine which dynamic curves
each primitive will look to for simulation.
Maya gives us the option of using the existing Region or Clumping map,
or creating a new map from scratch.
Select Clumping. While we could’ve used a customized point mapping for the wires,
generating them based on our clump points lends greater predictability to our eventual result.
Turn off the XGen preview and click the Create Maps button.
You’ll notice points are automatically generated at the same spots as our "Clumping1" map
(at each of the guides), and that the point directory references its directory.
While we could add or remove points by clicking or Ctrl + clicking the scalp respectively,
we’ll leave the current configuration as is for the aforementioned reasons.
Next, we need to adjust the control map, which references an existing Ptex file
(either region or clumping) to determine which primitive follows which follicle
via the Anim Wire modifier.
In this case, we'd prefer the control map also reference the “Clumping1” map
rather than the default “Clumping2” map.
However, the reason for this isn’t simply to match the point directory.
To really understand why, select “Clumping2” in the Modifiers list
and turn on the Color Preview option.
Update the XGen preview.
This shows you the various regions of influence of the map over the hair.
Notice that the regions shown here are relatively small.
This would mean that only small pockets of XGen primitives would be affected by nearby anim wires.
Conversely, if you do the same for “Clumping1”, you’ll see the regions are much larger
and thus will achieve a much more uniform looking simulation of the XGen primitives.
Click the Preview Wires button to get a sense of how your dynamic curves will appear.
Remember, these are not the actual XGen primitives.
Click Create Hair System.
The Make Curves Dynamics Options window appears.
As we did in the previous movie, we'll output NURBS curves to drive our anim wires.
Maya generates a hair system node simulated by a nucleus solver,
as well as a set of curves and corresponding follicles at each point location of our control map.
Before we simulate this new hair system,
we’ll need to set the nucleus node's Space Scale to 0.01
to account for unit difference in the context of this simulation.
In the Solver Attributes section,
we’ll set Substeps to 8 and Max Collision Iterations to 10 to ensure solving accuracy.
We'll also use the same hairSystem configuration as in the previous movie.
Set Stretch and Compression Resistance to 100, and Mass to 0.05.
Finally, we need to use the bust in the simulation as a passive collider nRigid object.
This is for the benefit of the nucleus solver, which ultimately impacts the XGen guides.
The Collision modifier we added earlier only affects the XGen primitives.
Speaking of the Collision modifier,
we need to move it above the anim wire modifier in the modifier list
to ensure it calculates collisions based on the anim wires and not on the original guides.
Now select all the output curves and display the anim wire modifier in the XGen window.
Click the Attach Hair System button to set the primitives to follow the anim wires.
Note that when using this method you must attach the hair system
at the frame denoted by the Ref Wires Frame attribute here,
as the modifiers require a point of reference for the initial hairstyle.
Before you play the simulation,
recall that we set the playback speed to “Play every frame”
to ensure the solver performs accurately...
...and that we also enabled the Update Preview Automatically option.
If you play the simulation, notice the hair flops over the model's face.
You’ll recall that this is due to our initial hairsystem settings.
Also notice how the primitives are once again breaking the surface of the mesh.
Instead of fixing the issue by keyframing the hairsystem’s Start Curve Attract
and Damp attributes as we did in the previous movie,
let's try using the increased granular control of the primitives afforded to us
by our bottom-up approach.
Rewind the simulation.
Let's adjust the Magnitude Scale ramp to control the primitives’ shape blending.
Reduce the point at the root to 0.
This means that each primitive will retain their guide’s shape at the root,
then gradually interpolate to their respective nHair curve’s shape at the tip.
Although Maya recommends an interpolation value of 0.5 here, we’re going to set it to 1.
This will eliminate the collision issues we saw earlier,
which were due to the hairs interpolating between anim wires.
Finally, moreso than the other regions of the hair,
the bangs should retain their shape during animation.
To accomplish this, we're going to mask the primitives out
from being affected by the anim wires.
Turn off the Update Preview Automatically option for now.
Create a new map for the Mask attribute...
...and name it "bangs_animation_mask". Set Map Resolution to 10.
Open the 3D Paint Tool Settings window.
We'll paint a mask around the most prominent front bangs using a very dark grey color value.
Don't use black or else the bangs will remain completely still.
A little bit of motion while retaining their overall shape is important.
For the area around these side bangs, we'll use a medium-toned grey color value
to get a halfway point between simulation and holding shape.
And finally, we'll use the blur tool around the edges of these regions
to create a gradient between them and the white areas,
to get a nice falloff to the rest of the hair which will be fully affected by the simulation.
Save the mask.
You can modify or add additional mask regions if you find some of the hair reacting too much
or too little to the anim wires.
Because of all the modifiers combined with the nHair simulation,
you may notice at this point that the simulation is slowing down.
To reduce some of the load, let’s add a Groom Bake Manager modifier.
The Groom Bake Manager caches sets of modifiers to an external XPD file.
Other modifiers can then reference the information from that file,
rather than having to calculate them each time.
Because the Groom Bake Manager doesn’t cache per frame,
it won’t have any effect on the anim wire or collision modifiers,
so let’s move it down below them.
Turn it on and click the Bake Xpd Groom button to generate the XPD file.
Once it’s done, Maya will automatically set XGen to reference it.
Now the simulation playback is much faster.
Once you have the hair simulating the way you want,
you can select all the dynamic curves and create an Alembic cache just like in the previous movie.
In this case though, we’ll have to turn off the AnimWire modifier’s Live Mode,
as well as apply the Alembic cache here.
Once cached, you can disable the nucleus solver.
You should now have ample ability to animate your characters’ XGen hair.
In the next movie, we’ll show you some techniques for rendering it.