Gridea

Physically Based Rendering

2022-03-02 · 3 min read

Blinn-Phong shading model:

L=CdiffNL+Cspec(NH)mL=C_{diff} N \cdot L + C_{spec} (N \cdot H)^m

CdiffC_{diff}: Diffuse color
CspecC_{spec}: Specular color
NN: Normal vector
LL: Light direction vector
HH: Half-angle vector (sight direction vector & light direction vector)
Which is also Normalized(L+V)Normalized(L + V)

BRDF:

L=fBRDFcosθlL=f_{BRDF} \cos \theta_{l}

fBRDF=kdiffCdiffπ+kspecVDFf_{BRDF} = k_{diff} \frac{C_{diff}}{\pi} + k_{spec}VDF

DTR=Roughness2π(cos2θh(Roughness21)+1)2D_{TR} = \frac{Roughness^2}{\pi (\cos^2\theta_h(Roughness^2 - 1) + 1)^2}

F=F0+(1F0)(1cosθh)5F = F_0 + (1 - F_0)(1 - \cos \theta_h)^5

F0=Metalic×Albedo+(1Metalic)×[0.04,0.04,0.04]F_0 = Metalic \times Albedo + (1 - Metalic) \times [0.04, 0.04, 0.04]

V=GSGGX(θl)GSGGX(θv)4cosθlcosθvV = \frac{G_{S-GGX}(\theta_l)G_{S-GGX}(\theta_v)}{4 \cos \theta_l \cos \theta_v}

GSGGX(θ)=cosθk+(1k)cosθG_{S-GGX}(\theta) = \frac{\cos \theta}{k + (1 - k) \cos \theta}

k=(Roughness+1)28k = \frac{(Roughness + 1)^2}{8}

kspec=F0k_{spec} = F_0

kdiff=(1F0)(1Metalic)k_{diff} = (1 - F_0)(1 - Metalic)

For Roughness:

L=fBRDFNLL=f_{BRDF} N \cdot L

L=(kdiffCdiffπ+kspecVDF)NLL = (k_{diff} \frac{C_{diff}}{\pi} + k_{spec}VDF) N \cdot L

L=(kdiffCdiffπ+kspec(GSGGX(θl)GSGGX(θv)4cosθlcosθv)(Roughness2π(cos2θh(Roughness21)+1)2)F)NLL = (k_{diff} \frac{C_{diff}}{\pi} + k_{spec} (\frac{G_{S-GGX}(\theta_l)G_{S-GGX}(\theta_v)}{4 \cos \theta_l \cos \theta_v}) (\frac{Roughness^2}{\pi (\cos^2\theta_h(Roughness^2 - 1) + 1)^2})F) N \cdot L