Hair Shader (Pre-3.6)

Hair Shader

The hair shader is a dedicated rendering technique for rendering hair and fur. Hair rendering is a relatively hard task to achieve in real-time with high quality results due to the very fine geometry and specific lighting behavior.

The most recent implementation of hair shading strongly implies the use of alpha test in conjunction with soft alpha test enabled so the use of opacity is strongly discouraged since its visual result is prone to issues especially when sorting multiple polygons using opacity.

Shader Params

Shader Params

Description

Shader Gen Option

Alpha test softening

Sets amount of alpha test softening to apply.

Soft alpha test

Ambient spec multiplier

Controls over specular intensity.

Default

Bump scale

Sets hair bumpiness.

Default

Detail tilling

Sets detail tilling scale.

Default

Diffuse wrap

Sets diffuse wrapping.

Default

Hair color

Sets hair color.

Default

Indirect bounce color

See Illum Shader for more information.

Default

Primary spec color

Sets primary spec color.

Default

Primary spec glossiness

Sets primary specular glossiness.

Default

Primary spec shift

Sets primary specular shift.

Default

Rim multiplier

Sets rim strength.

Default

Secondary spec color

Sets hair secondary spec color.

Default

Secondary spec glossiness

Sets secondary specular glossiness.

Default

Secondary spec shift

Sets secondary specular specular shift.

Default

Self-shadow softening

Sets geometry self-shadowing multiplier.

Default

Wind frequency

Sets the speed at which the verts are deformed.

Wind bending

Wind phase

Sets hair animation phase and randomizes the deformation.

Wind bending

Wind wave0 amp

Sets the amount or amplitude at which the verts are deformed.

Wind bending

Wind wave2 amp

Sets the amount or amplitude at which the verts are deformed on a different curve.

Wind bending

Shader Generation Params

Param

Description

Vertex Colors

See Illum Shader for more information.

Soft alpha test

Enable for alpha test to have soft edges and for more stable rendering.

Wind bending

Simulate wind effects.

Guidelines for Modeling Hair

Due to limitations in hardware regarding alpha blending sorting, we cannot at this point have per-pixel sorting which would save a lot of work, so we need to use a very cheap sorting approximation which works something like this:

Render hair opaque areas (this is where your alpha channel is 1 (white)). Then render hair backfaces, and finally render hair frontfaces.

This works for many cases but it has a lot of limitations, regarding modeling for it to work:

  • Start by making an initial hair cap (imagine a hair helmet), this will give missing shading (anisotropic, etc.) details from base head while making sure each hair patch should be modeled as single sided.
  • Use vertical UV patches so that they follow the hair strands vertically. This adheres to the anisotropic shape.
  • Then add all of the little details by adding hair patches.
Additional Note

When "Soft alpha test" is enabled, the hair will be rendered using the usual opaque rendering pipeline. In a post process we apply alpha test smoothing. You can also enable double sided option at will.

Hair Texturing Guidelines

  • Regarding hair texture, the trick for having very thin hair is to make texture as pixel perfect and with as little distortions/rotations (else filtering will kick in more and look blurrier). One way of achieving this is in Photoshop making a uniform noise, then using strong Motion Blur.
  • Then add little details to hair texture, colored noisy, alpha blended areas, etc.
  • Important note regarding alpha blended areas, we are trying to avoid them as much as possible, so try to make alpha blended areas only at the bottom tip of the hair.
  • For better "thinner" results enable Anisotropic texture filtering in diffuse texture filter options.

Diffuse texture

Diffuse texture alpha channel