|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Ref: Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs, p. 19, 29. |
|
|
|
float G_MaskingSmithGGX(float NdotV, float VdotH, float roughness) |
|
|
|
float G_MaskingSmithGGX(float NdotV, float roughness) |
|
|
|
{ |
|
|
|
// G1(V, H) = HeavisideStep(VdotH) / (1 + Λ(V)). |
|
|
|
// Λ(V) = -0.5 + 0.5 * sqrt(1 + 1 / a²). |
|
|
|
|
|
|
// Assume that (VdotH > 0), e.i. (acos(LdotV) < Pi). |
|
|
|
float hs = VdotH > 0.0 ? 1.0 : 0.0; |
|
|
|
return hs / (0.5 + 0.5 * sqrt(1.0 + a2 * (1.0 / z2 - 1.0))); |
|
|
|
return 1 / (0.5 + 0.5 * sqrt(1.0 + a2 * (1.0 / z2 - 1.0))); |
|
|
|
float D_GGX_Visible(float NdotH, float NdotV, float VdotH, float roughness) |
|
|
|
float D_GGX_Visible(float NdotH, float NdotV, float roughness) |
|
|
|
// Note that we pass 1.0 instead of 'VdotH' since the multiplication will already clamp. |
|
|
|
return D_GGX(NdotH, roughness) * G_MaskingSmithGGX(NdotV, 1.0, roughness) * VdotH / NdotV; |
|
|
|
return D_GGX(NdotH, roughness) * G_MaskingSmithGGX(NdotV, roughness) * VdotH / NdotV; |
|
|
|
} |
|
|
|
|
|
|
|
// Ref: http://jcgt.org/published/0003/02/03/paper.pdf |
|
|
|