1
0
Fork 0

HDR: Prevent materials with roughness=0 from blowing out the lighting

This commit is contained in:
Fernando García Liñán 2021-08-22 18:01:30 +02:00
parent 164112a8c0
commit b79d09d45f

View file

@ -333,7 +333,8 @@ vec3 evaluateLight(
vec3 c_diff = mix(baseColor * (1.0 - DIELECTRIC_SPECULAR), vec3(0.0), metallic);
float a = roughness * roughness;
// Avoid blown out lighting by capping the roughness to a non-zero value
float a = max(roughness * roughness, 0.001);
float a2 = a * a;
vec3 F = F_Schlick(VdotH, f0);
@ -345,7 +346,7 @@ vec3 evaluateLight(
vec3 diffuse = (vec3(1.0) - F) * Fd_Lambert(c_diff);
// Specular term
// Cook-Torrance specular microfacet model
vec3 specular = (F * D * G) / (4.0 * NdotV * NdotL);
vec3 specular = ((D * G) * F) / (4.0 * NdotV * NdotL);
vec3 material = diffuse + specular;