diff options
| -rw-r--r-- | brdf.cginc | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -6,17 +6,15 @@ #include "lysenko.cginc" #include "math.cginc" -float fresnel(float LoH) { - // Schlick's approximation - float n1 = 1.0; - float n2 = 1.33; - float r0 = (n1 - n2) / (n1 + n2); - r0 = r0 * r0; - - float term = 1.0 - LoH; +// Schlick "An Inexpensive BRDF Model for Physically-based Rendering". +// Equation 24. +// f0: Reflectance at normal incidence. Typically around 0.04. +// f90: Reflectance at grazing incidence. Typically around 1.0. +float F_Schlick(float LoH, float f0, float f90) { + float term = 1.0f - LoH; float term2 = term * term; float term5 = term2 * term2 * term; - return r0 + (1.0 - r0) * term5; + return f0 + (f90 - f0) * term5; } float4 brdf(Pbr pbr, LightData data) { @@ -25,7 +23,7 @@ float4 brdf(Pbr pbr, LightData data) { // Direct if (true) { - float F = fresnel(data.direct.LoH); + float F = F_Schlick(data.direct.LoH, 0.04f, 1.0f); float D = D_GGX(pbr.roughness, data.direct.NoH, data.direct.H); float V = V_SmithGGXCorrelated_Fast(pbr.roughness, data.common.NoV, data.direct.NoL); @@ -41,11 +39,11 @@ float4 brdf(Pbr pbr, LightData data) { // Indirect if (true) { - float F = fresnel(data.indirect.LoH); + float F = F_Schlick(data.indirect.LoH, 0.04f, 1.0f); specular += F * data.indirect.specular; - float Fd = 1.0 / PI; + float Fd = 1.0f; // Lambertian divide is baked into SH float3 remainder = (1.0f - F); diffuse += Fd * remainder * pbr.albedo.xyz * data.indirect.diffuse; remainder *= (1.0f - Fd * pbr.albedo); |
