Update PBR lighting chapter to support large DGGX values as 0-clamp was too high.

This commit is contained in:
Joey de Vries
2020-12-30 09:55:55 +01:00
parent 9a46ecf526
commit 73ff9934d0
2 changed files with 2 additions and 2 deletions

View File

@@ -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)

View File

@@ -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));