@@ -176,7 +176,9 @@ void main()
appendDecalColors(decal, fragPos, diffCol, roughness);
}
- float a2 = pow(roughness, 2.0);
+ // Don't allow zero a2 because we may end up with division with zero
+ float a2 = roughness * 0.9 + 0.1;
+ a2 *= a2;
// Ambient and emissive color
vec3 outC = diffCol * emission;
@@ -47,7 +47,6 @@ vec3 computeSpecularColorBrdf(vec3 v, // view dir
float noh = dot(n, h);
float D = noh * noh * (a2 - 1.0) + 1.0;
D = a2 / (PI * D * D);
- D = clamp(D, EPSILON, 100.0); // Limit that because it may grow
// G(l,v,h)/(4*dot(n,h)*dot(n,v)) aka Visibility term: Geometric shadowing divided by BRDF denominator
#if 0
@@ -137,7 +137,7 @@ void readGBuffer(in sampler2D rt0, in sampler2D rt1, in sampler2D rt2, in vec2 u
comp = textureLod(rt1, uv, lod);
g.specular = comp.xyz;
- g.roughness = max(EPSILON, comp.w);
+ g.roughness = comp.w;
comp = textureLod(rt2, uv, lod);
g.normal = comp.xyz * 2.0 - 1.0;