From a1ef8550d36ba46be929e0078557b01c300e78f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 24 Aug 2018 16:58:34 +0200 Subject: [PATCH] Shaders: don't multiply Phong diffuse alpha with light intensity. That messes up with alpha mask (basically, areas that receive less than 50% light get clipped away). --- src/Magnum/Shaders/Phong.frag | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Shaders/Phong.frag b/src/Magnum/Shaders/Phong.frag index fbae0d82c..8ac7e9d84 100644 --- a/src/Magnum/Shaders/Phong.frag +++ b/src/Magnum/Shaders/Phong.frag @@ -151,13 +151,13 @@ void main() { /* Add diffuse color */ lowp float intensity = max(0.0, dot(normalizedTransformedNormal, normalizedLightDirection)); - color += finalDiffuseColor*lightColor*intensity; + color += vec4(finalDiffuseColor.rgb*lightColor.rgb*intensity, lightColor.a*finalDiffuseColor.a); /* Add specular color, if needed */ if(intensity > 0.001) { highp vec3 reflection = reflect(-normalizedLightDirection, normalizedTransformedNormal); mediump float specularity = pow(max(0.0, dot(normalize(cameraDirection), reflection)), shininess); - color += finalSpecularColor*specularity; + color += vec4(finalSpecularColor.rgb*specularity, finalSpecularColor.a); } #ifdef ALPHA_MASK