From 73ff9934d074658a83882d819da410713cc45ee2 Mon Sep 17 00:00:00 2001 From: Joey de Vries Date: Wed, 30 Dec 2020 09:55:55 +0100 Subject: [PATCH] Update PBR lighting chapter to support large DGGX values as 0-clamp was too high. --- src/6.pbr/1.1.lighting/1.1.pbr.fs | 2 +- src/6.pbr/1.1.lighting/lighting.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/6.pbr/1.1.lighting/1.1.pbr.fs b/src/6.pbr/1.1.lighting/1.1.pbr.fs index b5242e5..dce7c32 100644 --- a/src/6.pbr/1.1.lighting/1.1.pbr.fs +++ b/src/6.pbr/1.1.lighting/1.1.pbr.fs @@ -29,7 +29,7 @@ float DistributionGGX(vec3 N, vec3 H, float roughness) float denom = (NdotH2 * (a2 - 1.0) + 1.0); denom = PI * denom * denom; - return nom / max(denom, 0.001); // prevent divide by zero for roughness=0.0 and NdotH=1.0 + return nom / max(denom, 0.0000001); // prevent divide by zero for roughness=0.0 and NdotH=1.0 } // ---------------------------------------------------------------------------- float GeometrySchlickGGX(float NdotV, float roughness) diff --git a/src/6.pbr/1.1.lighting/lighting.cpp b/src/6.pbr/1.1.lighting/lighting.cpp index 4825c3b..11e334b 100644 --- a/src/6.pbr/1.1.lighting/lighting.cpp +++ b/src/6.pbr/1.1.lighting/lighting.cpp @@ -140,7 +140,7 @@ int main() shader.setFloat("metallic", (float)row / (float)nrRows); for (int col = 0; col < nrColumns; ++col) { - // we clamp the roughness to 0.025 - 1.0 as perfectly smooth surfaces (roughness of 0.0) tend to look a bit off + // we clamp the roughness to 0.05 - 1.0 as perfectly smooth surfaces (roughness of 0.0) tend to look a bit off // on direct lighting. shader.setFloat("roughness", glm::clamp((float)col / (float)nrColumns, 0.05f, 1.0f));