top of page

Hair Rendering and Simulation using Mass-Spring Sytems and Dynamic Follow-The-Leader (DFTL)

Hair rendering and simulation is a complex problem, where great breakthroughs have allowed realistic feel and looks. 
In this project, I take on both problems with hair rendering techniques using famous lighting equations, such as Kajiya & Kay, and Marschner. Use hair interpolation (tessellation) methods, and simulation techniques like Mass-Spring models for hair simulation and Dynamic Follow-The-Leader. For accomplishing this purpose, I implemented the full DirectX11 pipeline. Some other screen effects used are SSAO and the usage of MSAA antialiasing.

Currently Implemented

  • Hair rendering using Marschner and Kajiya-Kay equations.

  • Single strand interpolation.

  • Multi-strand interpolation.

  • Hair tessellation using Bezier curves.

  • Screen-Space Ambient Occlusion (SSAO).

  • Antialiasing through MSAA.

  • Support of per-strand hair color.

  • Support of density map to control hair creation.

  • Simulation through Mass Spring Systems (straight and curly hair).

  • Simulation through Dynamic Follow-The-Leader (DFTL, straight hair only).

  • External forces to affect simulation behavior.

Final Results (using DFTL)

Role

Graphics & Engine Programmer

Engine

Custom C++ Engine

Tools and Languages

C++, HLSL, DirectX11, Visual Studio, RenderDoc, Nvidia Nsight.

Development Time

9 Months (In progress)

Illumination

The hair is represented using line segments, that get expanded to quads in the Geometry Shader. Using the Hull and Domain shader, new virtual hair is created based on guide strands. And then rendered using either Marschner's or Kajiya-Kay lighting equations

Marschner and Kajiya-Kay lighting equations

Marschner's light equations are composed of multiple smaller equations, but in can be computed as the resulting color of the light, depending on how it bounces (azimuthal or N values), and their corresponding coefficients (Longitudinal or M values).

Calculating Light Scattering with Marschner Equation

Some rendering parameters, such as Specular and Diffuse Coefficients, Hair Width, Longitudinal Width can be changed in real time for a better look. 

Changing lighting parameters at runtime

Hair Interpolation

Since rendering hair takes, quite literally, hundreds of thousands of hairs in order to make it look realistic. Creating so much hair on CPU can be expensive and slow. The usage of the interpolated (virtual hair) can make a significant difference, and can also be configured at runtime.  The interpolated hair is created using DirectX11 tessellation engine.

There are two interpolation techniques: Single Strand and Multi-Strand Interpolation
Single Strand Interpolation creates more hair in the same plane as a single hair, in a determined radius or in a plane. 

The following code handles interpolating a hair vertex position for each new virtual hair, the default being creating hair in a radius. An offset is created then added to the original hair position.

Creating Virtual Hair with Single Strand Interpolation

Visualizing Single Strand Interpolation

Multi-Strand Interpolation takes multiple hair by using multiple hair (3 in this instance) and interpolating between the hair using weights. 

Visualizing Multi-Strand Interpolation

Anti-Aliasing

Rendered hair is quite thin, falling in a range of 1/1500 to 1/500 of an inch in diameter (17 and 180 micrometers). For this reason, it is often thinner than a pixel. When rendering, these may result in jagged lines (aliasing). Implementing MSAA antialiasing can substantially help with this problem:

Effects of MSAA (Anti-Aliasing)

Dyed Appearance

As in real life, hair can come in many different shapes and colors. By using a color map, one can decide the color for each individual hair strand. These can still be influenced by a general model color, if a tint is desired.

ColorMap.png

Color Map

Different Colored Strands

Simulation

The simulation is done by implementing Mass Spring Systems and Dynamic Follow-The-Leader, simulated at real time, using Compute Shaders.  Hair-hair interaction is simulated using a background grid. This gives the feeling of friction between hairs.
 

Mass Spring System Straight Hair

Mass Spring System Curly Hair

Dynamic Follow-The-Leader

Where to go Next?

Some features that could be implemented next include: ​

  • Custom hair culling.

  • Introduce shadow maps to the lighting equations.

  • Finer control of external forces.

  • Robust inter-hair collision system, a good option could be using Bounding Volume Hierarchy (BVH).

  • Hair sorting and transparency.

  • Usage of 3D models. 

bottom of page