Actual post date: 12/03/2023

Last modified: 12/03/2023

Note: Code will be public at https://github.com/xrr-233/URP-Pass-Shader after solving copyright problem.

A project that captures the figure of real person and creates the digital 3D avatar with specific rendering techniques. Developed by Unity URP+ShaderLab+HLSL. Based on in-depth understanding of Unity PBR-BRDF rendering scheme and popular hair rendering methods (Kajiya-Kay, Marschner, Scheuermann).

Fig. 1 The workflow of the project. The person here is my teammate GZY, who is responsible for finding 3D avatar reconstruction methods. Tribute to him!

During the process of the project, we have solved/alleviated the problem of aliasing effect due to alpha test, double-sided rendering, transparency, blending and rendering order issues.

Fig. 2 General Hair Rendering Scheme.

Some Formulas

  • PBR Reflectance Equation
\[L_{o}(p, \omega_{o})=\int_{\Omega}f_{BRDF}(p,\omega_{i},\omega_{o})L_{i}(p,\omega_{i})(\omega_{i}\cdot n)d\omega_{i},\]
  • Definition of BRDF (Bidirectional Reflectance Distribution Function)

\(f_{BRDF}=k_{d}f_{lambert}+k_{s}f_{cook-torrace},\) \(f_{lambert}=\frac{c}{\pi}\) \(f_{cook-torrace}=\frac{DGF}{4(\omega_{i}\cdot N)(\omega_{o}\cdot N)}\)

  • Commonly used Normal Distribution, Geometry, and Fresnel Term

\(D_{Trowbridge-Reitz GGX}=\frac{\alpha^{2}}{\pi((N\cdot H)^{2}(\alpha^{2}-1)+1)^2},\) \(G_{Smith GGX}=\frac{1}{((N\cdot L)(1-k)+k)((N\cdot V)(1-k)+k)},\) \(F_{Schlick}=F_{0}+(1-F_{0})(1-(H\cdot V))^{5},\)

  • Unity-optimized G·F approximation
\[(G\cdot F)_{approx}=\frac{1}{(L\cdot H)^2(\alpha+0.5)} [23].\]
  • Unity-optimized Cook-Torrace Specular Formula
\[f_{unity}=\frac{\alpha^{2}}{\pi((N\cdot H)^{2}(\alpha^{2}-1)+1)^2(L\cdot H)^2(4\alpha+2)}.\]

Potential Improvement Directions

More automated hair generation algorithms (mapping hair strands into facets/generating opacity maps/…), integrate animation and rigging with FACS, more advanced skin/hair shading models (d’Eon/Double Cylinder/…)

References

- PBR Theoretic Background

- Hair Transparency / Depth Issues

- Hair Rendering

- Code Reference