summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filamented.cginc27
-rw-r--r--yum_brdf.cginc5
2 files changed, 30 insertions, 2 deletions
diff --git a/filamented.cginc b/filamented.cginc
index 1b53e2b..dda261d 100644
--- a/filamented.cginc
+++ b/filamented.cginc
@@ -877,6 +877,33 @@ float F_Schlick(float f0, float VoH) {
return f0 + (1.0 - f0) * pow5(1.0 - VoH);
}
+float F_Schlick(float f0, float f90, float VoH) {
+ // Schlick 1994, "An Inexpensive BRDF Model for Physically-Based Rendering"
+ return f0 + (f90 - f0) * pow5(1.0 - VoH);
+}
+
+float3 F_Schlick(const float3 f0, float VoH) {
+ float f = pow5(1.0 - VoH);
+ return f + f0 * (1.0 - f);
+}
+
+float3 F_Schlick(const float3 f0, float f90, float VoH) {
+ // Schlick 1994, "An Inexpensive BRDF Model for Physically-Based Rendering"
+ return f0 + (f90 - f0) * pow5(1.0 - VoH);
+}
+
+float Fd_Lambert() {
+ return 1.0 / PI;
+}
+
+float Fd_Burley(float roughness, float NoV, float NoL, float LoH) {
+ // Burley 2012, "Physically-Based Shading at Disney"
+ float f90 = 0.5 + 2.0 * roughness * LoH * LoH;
+ float lightScatter = F_Schlick(1.0, f90, NoL);
+ float viewScatter = F_Schlick(1.0, f90, NoV);
+ return lightScatter * viewScatter * (1.0 / PI);
+}
+
float V_SmithGGXCorrelated(float roughness, float NoV, float NoL) {
// Heitz 2014, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs"
float a2 = roughness * roughness;
diff --git a/yum_brdf.cginc b/yum_brdf.cginc
index cd97865..170451d 100644
--- a/yum_brdf.cginc
+++ b/yum_brdf.cginc
@@ -35,7 +35,8 @@ float3 specularLobe(YumPbr pbr, float f0,
return (D * V) * F;
#else
// Fresnel
- const float3 F = F_Schlick(f0, LoH);
+ float f90 = 0.5 + 2.0 * pbr.roughness * LoH * LoH;
+ const float3 F = F_Schlick(f0, f90, LoH);
// Normal distribution function
float D = D_GGX(pbr.roughness, NoH, h);
// Geometric shadowing
@@ -115,7 +116,7 @@ float4 YumBRDF(v2f i, const YumLighting light, YumPbr pbr) {
const float3 E = specularDFG(dfg, f0);
const float3 energy_compensation = energyCompensation(dfg, f0);
- float3 Fd = pbr.albedo / PI;
+ float3 Fd = pbr.albedo * Fd_Burley(pbr.roughness, NoV, NoL, LoH);
Fd *= (1.0 - pbr.metallic) * light.attenuation * pbr.ao;
float3 Fr = specularLobe(pbr, f0, h, LoH, NoH, NoV, NoL_wrapped_s) * pbr.ao * PI * light.attenuation;