Hair Component
The Hair Simulation Component is used to simulate hairstyles with realistic lighting and physics.
In this guide we'll cover:
- The Hair Component
- Hair Viewing Modes
- Strand Shape and Simulations
- Physics Simulation
- Collision, Self Collision and Wind
- Hair Materials
- Hair Splines
- Importing hair spline fbx into Lens Studio
- Creating hair splines with Maya and 3D MAX
You can try playing with a lot of different hair styles in the Hair Simulation Template
The Hair Component
It's recommended to use the Hair Template as a starting point when working with Hair Simulation as there are many inter-connecting pieces such as Blur layer, bald ML and head collider in order for the Hair Simulation to work correctly.
We'll go over some of the examples in the Hair Template
to dive deeper into the Hair Component
.
Under the Back Orthographic Camera
in the Hair Template, we have the Hair
Camera
. Under this camera we have everything related to simulating hair. To check out different hairstyles, try toggling objects under Head Binding > Hair Components
Each hairstyle has the Hair Component
attached to it. The Hair Component
handles everything about hair simulation. For example, let’s check out the Curly Hair Mint Blue
hairstyle under Hairstyles > Long Hairs.
Hair Viewing Mode
The first section on the Hair Component
has the hair material as well as several modes for viewing and understanding the hair simulation.
Turning on the Fallback mode
will disable physics for hair simulation. Fallback mode
will be turned on on some low end devices for optimization reasons. (check out the Hair Simulation Optimization
section below for a more detailed description!)
Turning on Loaded strands
will show the raw shape of imported hair splines. Turning on Sim. strands
will visualize optimized / recalculated shape of imported hair splines. This is especially useful when visualizing the effects of the Hair Resolution
value.
If Debug mode
is checked, we’ll see our hair now has 3 distinct RGB colors. Color Green represents the original hair strand. Color Blue represents strands generated with single strand interpolation method, aka each original strand generates another similar strand nearby. Color Red represents strands generated with multi strand interpolation method, aka strands are generated between 2 to 3 original strands. This mode is useful to see how different strands are generated based on different settings under Strand Shape
and Strand Generation
.
Strand Generation
The Strand Generation
section handles everything related to generating strands.
Hair data
is where the hair strand object is linked. Try right clicking on Hair data and select to highlight the strand object and swap it with another strand provided in the template to see how hairstyle changes based on the strand shape!
Neighbor radius
is the threshold for generating simulated strands based on distance between strand neighbors. Cos threshold
is the cosine angular threshold for generating simulated strands. Length threshold
is threshold for strand length to generate simulated strands.
It’s best to turn onDebug mode
while adjusting these 3 parameters to see how they affect the hair simulation!
Hair Resolution
changes the resolution of hair strands. To get a precise idea on how Hair Resolution
affects strand shapes, we can clear out the Primary Material
and turn on Loaded Strands
and Sim. Strands
in the section above.
The deep blue color represents the original strands of the hair, light blue represents simulated strands which will be changed by changing Hair Resolution
. The green strand represents a smoothed result of the light blue strands.
Having Hair Resolution
to 1 or 0 means using original resolution of the hair strand object.
Strand Shape
The Strand Shape
section has parameters that affect the shape of each hair strand. Changing Width
will change how wide each strand is and Taper
will affect the tip size of each strand.
The Clump
section defines how ‘messy’ the hair looks. Increasing Clump radius
will affect the distance of each strand between each other. Clump density
affects how much more strands are generated to increase the volume of the hair. Clump tip scale
determines the amount of separation between hair tips.
The Density
variable changes hair density of simulated strands, which can be represented by the red colored strands if Debug mode
is enabled. Increasing Density
will increase the amount of simulated strands. Increasing Density
noise
will amplify the shapes of simulated strands.
Physics Simulation
The Simulation
section sets up properties related to hair’s physics simulation. Stiffness
will determine how stiff hair is. Damp
will determine how ‘sticky / flowy’ hair seems. Friction
will determine the amount of friction between each hair strand.
Gravity
adds an external force to hair simulation.
Collision, Self Collision and Wind
The properties under the Collision
panel affects how the hair object collides with external colliders, and properties under the Self Collision
panel affect how hair collides with each other. Colliders can be added with the Add collider
button. In this case the collider is set to be the Head Collider
object under Head Binding > Head. Turn on the Show Collider
check on this object to see the shape of the collider!
Stiffness
determines how stiff the collision would be. Offset
determines the amount of movement offset caused by the collision, and Friction
determines the amount of friction retained during collision.
The Wind
property if checked will add external wind force to the hair object.
Hair Materials
We can see each hair material by right click to Highlight
the Primary Material
at the top of the Hair Component
.
All hairs use a special material with special settings for hair. You can also create this material from scratch by going to Resources > + > Hairstyle Materials
Each hair material has its main Hair Texture
where texture of the hair is applied.
Alpha Test Threshold
determines the amount of cutoff from the transparency of the Hair Texture.
Blur Multiplier
multiplies the amount of blur post effects on the hair.
Texture Scale
is used to tile the hair texture along its Y axis. Make sure your texture is seamless in order for Texture Scale
to work appropriately. Texture Offset
offsets the texture map on hair strands.
Hair Growth
works like the Cut
variable on the Hair Component
that it changes the length of the hair.
The Lit Lookup
map
uses a texture’s RGB value to adjust the brightness and shininess of the hairstyle. Feel free to swap current texture with any of the presets to see how it affects the hair differently.
Turning on Direction Map Support
would allow the hair material to use the Direction map
. The Direction map
uses a texture’s RGB value to determine flow direction of the hairstyle.
Setting Intensity Levels
to Map
will enable the Intensity map
, which uses a texture’s RGB value combined with adjustable parameters to determine the diffuse and specular of the hairstyle. Red channel controls diffuse and green channel controls specular, both can be multiplied by the according slider.
The Hair Roots Color
and Hair Tips Color
determines the main color tone of the hair. You can adjust how they mix in with each other by adjusting the Mix Edge
and Mix Size
parameters.
The Diffuse Light Color
multiplies another color into the Hair Roots Color
and Hair Tips Color
. And the Specular Light Color
multiplies another color into the highlight of the hair color.
Adjusting the Lit offset
and Lit rotation
would change the direction and position of how the Lit map
affects the hair object. It will therefore change position and rotation of the reflection of the hairstyle.
Hair Splines
Each hair style is generated based on a spline object that can be found from the object linked in the Hair Data
slot.
We have provided a handful of hair strands in the Hair Data
folder. But we also encourage creators to create their own hair spline objects to bring more dynamically designed hairstyles to Lens Studio!
Currently Lens Studio only supports splines created with Maya and 3DMax because of their way of fbx spline data formatting.
Importing Splines to Lens Studio
Import your fbx exported from Maya or 3DMax to Lens Studio by dragging it into the Scene Hierarchy
panel the same way as importing any other fbx.
Then duplicate an existing hair component, and click on the Hair data slot, a window will pop up. If your fbx is a spline object, it will show up on the pop-up window, just select your fbx then the hair component will be using your custom style.
Creating Splines in Maya
First let’s open the head template in Maya so we have a head shape as reference when we create our splines.
Switch to front view, then go to the Curves/Surfaces section, and select the spline object.
After having spline selected, draw out a curve from the top center of the head object to bottom (or whichever direction that would fit your hair)
Press W
to exit edit mode.
Then press D
to shift the anchor to the root of the spline object.
Then select the head object and make it a live object.
Then select the spline, and duplicate the spline object along the head line.
Rotate and scale while duplicating the spline objects to create half a head of hairs.
You may also smooth some splines at the bottom part so they stand out less.
Then we’ll select all spline objects and press cmd/ctrl + G
to group them.
Duplicate the group, then change its scaleX
to -1 so it shows up at the other side of the head.
Select both groups and press cmd/ctrl + G
again to put them all under one group.
Then select Modify > Freeze Transform
And after that select Modify > Reset Transform
With the final group selected, click on File > Export Selection
.
Creating Splines with 3DMAX
First create Guides using Either Splines
or NURBS
curves
If you are using splines, make sure to convert them to NURBS
using right click menu.
Once you have one half done, select all curves and enable pivot editing mode
Then type in 0 for absolute X Y Z coordinates here
Once you have pivots at 0,0,0 and all NURBS curves selected, turn off pivot editing and use Mirror Tool with “copy” option
Select all curves, ALT + Right Click
and select Freeze Transforms
and chose Yes
, then ALT + Right Click
and Freeze Rotations
.
With all curves selected, use Reset Xform
tool.
After resetting XForm, collapse modifier stack on all curves by converting them to NURBS.
Add all curves to a group so it’s easier to manage them in Lens Studio
Once hair guides are grouped repeat step 2 so that group pivot is also at 0,0,0. Now you’re ready to export to FBX !