From de3081042e93cf806ad8a28b71c98576ea2de80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 7 Oct 2018 19:39:19 +0200 Subject: [PATCH] Shaders: avoid overflowing alpha with multiple lights. Still not sure what the proper semantics of light alpha should be. --- src/Magnum/Shaders/Phong.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magnum/Shaders/Phong.frag b/src/Magnum/Shaders/Phong.frag index e9c6afc89..a7a37debb 100644 --- a/src/Magnum/Shaders/Phong.frag +++ b/src/Magnum/Shaders/Phong.frag @@ -155,7 +155,7 @@ void main() { for(int i = 0; i < LIGHT_COUNT; ++i) { highp vec3 normalizedLightDirection = normalize(lightDirections[i]); lowp float intensity = max(0.0, dot(normalizedTransformedNormal, normalizedLightDirection)); - color += vec4(finalDiffuseColor.rgb*lightColors[i].rgb*intensity, lightColors[i].a*finalDiffuseColor.a); + color += vec4(finalDiffuseColor.rgb*lightColors[i].rgb*intensity, lightColors[i].a*finalDiffuseColor.a/float(LIGHT_COUNT)); /* Add specular color, if needed */ if(intensity > 0.001) {