Notes

Physically-based Rendering

  • notations:
    • p\mathbf p is the shading point.
    • ωo\omega_o is the outgoing view direction (shading point to eye)
    • ωi\omega_i is the outgoing lighting direction (shading point to light)
    • n\mathbf n is the normal vector
    • t=2(n⋅ωo)n−ωo\mathbf t = 2(\mathbf n \cdot \omega_o) \mathbf n - \omega_o is the reflective direction
    • h=wi+wo∣∣wi+wo∣∣\mathbf h=\frac {w_i + w_o} {||w_i + w_o||} is the halfway vector (different from n\mathbf n !)
    • mm is the metalness
    • ρ\rho is the roughness
    • a\mathbf a is the ambient color (base color)
    • s(ωi)s(\omega_i) is the occlusion probability from the shading point to light.
  • rendering Equation:
c(ωo)=∫ΩL(ωi)f(ωi,ωo)(ωi⋅n)dωi\mathbf c(\mathbf \omega_o) = \int_\Omega L(\omega_i)f(\omega_i, \omega_o)(\omega_i \cdot \mathbf n)d \omega_i
  • micro-facet BRDF (Cook-Torrance 1982):

    f(ωi,ωo)=(1−m)aπ+DFG4(ωi⋅n)(ωo⋅n)f(\omega_i, \omega_o) = (1 - m) \frac {\mathbf a} {\pi} + \frac {DFG} {4(\omega_i \cdot \mathbf n)(\omega_o \cdot \mathbf n)}

    The BRDF can be divided into diffuse + specular terms, where the specular term includes:

    • F = Fresnel term
    F0=m∗a+(1−m)∗0.04F=F0+(1−F0)(1−(h⋅ωo))5F_0 = m * \mathbf a + (1 - m) * 0.04 \\ F = F_0 + (1 - F_0)(1-(\mathbf h \cdot \omega_o))^5
    • G = Geometry term (Schlick-GGX)

      k=ρ4/2g(v)=n⋅vk+(1−k)n⋅vG=g(ωo)g(ωi)k = \rho^4 / 2 \\ g(\mathbf v) = \frac {\mathbf n \cdot \mathbf v} {k + (1 - k)\mathbf n \cdot \mathbf v}\\ G = g(\omega_o) g(\omega_i)
    • D = Normal Distribution (Trowbridge-Reitz GGX)

      α=ρ2D=α2π((n⋅h)(α2−1)+1)2\alpha = \rho^2 \\ D = \frac {\alpha^2} {\pi((\mathbf n \cdot \mathbf h)(\alpha^2 - 1) + 1)^2}
  • split-sum approximation (Karis and Games 2013)

    ∫ΩL(ωi)DFG4(ωi⋅n)(ωo⋅n)(ωi⋅n)dωi=∫ΩL(ωi)Ddωi∫ΩDFG4(ωo⋅n)dωi\int_\Omega L(\omega_i)\frac {DFG} {4(\omega_i \cdot \mathbf n)(\omega_o \cdot \mathbf n)} (\omega_i \cdot \mathbf n)d \omega_i \\ = \int_\Omega L(\omega_i)Dd\omega_i \int_\Omega \frac {DFG} {4(\omega_o \cdot \mathbf n)} d \omega_i \\
  • lighting representation

    L(ωi)=(1−s(ωi))gdirect(ωi)+s(ωi)gindirect(ωi,p)s(ωi)=gocc(ωi,p)L(\omega_i) = (1 - s(\omega_i)) g_\text{direct}(\omega_i) + s(\omega_i) g_\text{indirect}(\omega_i, \mathbf p) \\ s(\omega_i) = g_\text{occ}(\omega_i, \mathbf p)
    • direct term (from light): only dependent on the outgoing light direction.
    • indirect term (from other reflective surfaces): also dependent on the current shading point.

Metallic/Roughness v.s. Specular/Glossiness

Except for the common metallic-roughness model, there is also specular-glossiness model for PBR (e.g., Unity).

Both models can be converted between: https://kcoley.github.io/glTF/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows/

glossiness=1−roughnessdiffuse=(1−metallic)∗basecolorspecular=metallic∗basecolorglossiness = 1 - roughness \\ diffuse = (1 - metallic) * basecolor \\ specular = metallic * basecolor \\

A detailed documentation can be found: https://kcoley.github.io/glTF/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/

Type to search.