diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-12-03 07:50:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-03 07:50:37 +0100 |
commit | 65e6efaa3bb51b69f5b62b5ae67d480ba22aa39d (patch) | |
tree | e78d488bf4d2bb886ba2429d2cbbd52c6a06d18c /drivers/gles3/shaders/scene.glsl | |
parent | 055d7ace544e8dccf1bcee15c4a8704614ebb900 (diff) | |
parent | 334d41d7cc04f7c745f9f56124b9bdca84c907f3 (diff) |
Merge pull request #33836 from clayjohn/blinn-fix
Fix Specular Blinn function
Diffstat (limited to 'drivers/gles3/shaders/scene.glsl')
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 088fa12592..b4ceb7dcfd 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -213,12 +213,10 @@ void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float roughness, in //normalized blinn always unless disabled vec3 H = normalize(V + L); float cNdotH = max(dot(N, H), 0.0); - float cVdotH = max(dot(V, H), 0.0); - float cLdotH = max(dot(L, H), 0.0); float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25; - float blinn = pow(cNdotH, shininess); + float blinn = pow(cNdotH, shininess) * cNdotL; blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI)); - specular_brdf_NL = (blinn) / max(4.0 * cNdotV * cNdotL, 0.75); + specular_brdf_NL = blinn; #endif specular += specular_brdf_NL * light_color * (1.0 / M_PI); @@ -1094,9 +1092,9 @@ LIGHT_SHADER_CODE //normalized blinn float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25; - float blinn = pow(cNdotH, shininess); + float blinn = pow(cNdotH, shininess) * cNdotL; blinn *= (shininess + 8.0) * (1.0 / (8.0 * M_PI)); - float intensity = (blinn) / max(4.0 * cNdotV * cNdotL, 0.75); + float intensity = blinn; specular_light += light_color * intensity * specular_blob_intensity * attenuation; |