Marschner Shader Part II
In my last post I mentioned two functions that are needed to represent the hair model as depicted in Marschner’s paper.
S = SR + STT + STRT,
Sp = Mp (q i , q r ) x Np (q d , f d ) for P = R, TT, TRT.
And the M components are as follows:
- MR (q h ) = g( Beta R , q h – Alpha R).
- MTT (q h ) = g( Beta TT , q h – Alpha TT).
- MTRT (q h ) = g( Beta TRT , q h – Alpha TRT).
The N component is actually a bit tricky to compute. Here are all the main steps:
- Convert to Miller-Bravais index.
This is done in order to change the index of refraction to 2D physics, so that the optics of a 3D cylindrical fiber may be reduced to the 2D analysis of the optics of its cross-section.
After looking into Snell’s Law we define the indexes of refraction as:
- Solve a cubic equation
Remember this picture:
We need to find out who the incident angles are, and we can approximate the solution for this equation as:
- Solve Fresnel equation
Fresnel equation is used in order to simulate the reflection model from within the attenuation
- Find out the absorption factor
This is actually quite straightforward, just:
- The attenuation factor
This is obtain combining both the reflection and the absorption factor, hence the “Attenuation by absorption and reflection” model from Marschner’s paper.
where the first derivative is
- The N component (finally)
and the N are
- NR (q d , f d ) = NP (0, q d , f d ).
- NTT (q d , f d ) = NP (1, q d , f d ).
- NTRT (q d , f d ) = NP (2, q d , f d ).
For the last component Marschner proposes a more complex model in order to avoid singularities, but for my implementation I couldn’t tell any improvement so I stuck with the simpler version of NTRT.
The whole model
As a sum up this is the whole Marschner hair model in just an equation:
Hope I managed to keep everything simple and explicit alike.