mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Update PBR lighting chapter to support large DGGX values as 0-clamp was too high.
This commit is contained in:
@@ -29,7 +29,7 @@ float DistributionGGX(vec3 N, vec3 H, float roughness)
|
|||||||
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
|
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
|
||||||
denom = PI * denom * denom;
|
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)
|
float GeometrySchlickGGX(float NdotV, float roughness)
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ int main()
|
|||||||
shader.setFloat("metallic", (float)row / (float)nrRows);
|
shader.setFloat("metallic", (float)row / (float)nrRows);
|
||||||
for (int col = 0; col < nrColumns; ++col)
|
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.
|
// on direct lighting.
|
||||||
shader.setFloat("roughness", glm::clamp((float)col / (float)nrColumns, 0.05f, 1.0f));
|
shader.setFloat("roughness", glm::clamp((float)col / (float)nrColumns, 0.05f, 1.0f));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user