]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix broken coloring of wielditems (#9969)
authorDanila Shutov <dcbrwn2@gmail.com>
Tue, 9 Jun 2020 19:38:09 +0000 (22:38 +0300)
committerGitHub <noreply@github.com>
Tue, 9 Jun 2020 19:38:09 +0000 (21:38 +0200)
Fixes a regression that appeared in 5.3.0-dev.

client/shaders/object_shader/opengl_fragment.glsl
client/shaders/object_shader/opengl_vertex.glsl
src/client/wieldmesh.cpp

index 32f3e974e3074a532a298ceca66eb359f42bf02c..0534dc049ca7a4f0cf79af52c3797ce6d7c0c29d 100644 (file)
@@ -145,8 +145,10 @@ void main(void)
 
        vec4 col = vec4(color.rgb, base.a);
 
+       col.rgb *= gl_Color.rgb;
+
        col.rgb *= emissiveColor.rgb * vIDiff;
-               
+
 #ifdef ENABLE_TONE_MAPPING
        col = applyToneMapping(col);
 #endif
index 4880893922bc659df4274e0988b3c1add738cfe3..59171145f51c82b10a5221256c6cb78000280ea2 100644 (file)
@@ -38,7 +38,12 @@ void main(void)
 
        lightVec = sunPosition - worldPosition;
        eyeVec = -(gl_ModelViewMatrix * gl_Vertex).xyz;
-       vIDiff = directional_ambient(normalize(gl_Normal));
+
+       // This is intentional comparison with zero without any margin.
+       // If normal is not equal to zero exactly, then we assume it's a valid, just not normalized vector
+       vIDiff = length(gl_Normal) == 0.0
+               ? 1.0
+               : directional_ambient(normalize(gl_Normal));
 
        gl_FrontColor = gl_BackColor = gl_Color;
 }
index 997eb1b5b66d30b4c1e177dd4a1eb591f6c9fae3..8cd3e29a9a8da24adfe3f97478670e1793cea39b 100644 (file)
@@ -467,7 +467,11 @@ void WieldMeshSceneNode::setColor(video::SColor c)
                        bc.getGreen() * green / 255,
                        bc.getBlue() * blue / 255);
                scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
-               colorizeMeshBuffer(buf, &buffercolor);
+
+               if (m_enable_shaders)
+                       setMeshBufferColor(buf, buffercolor);
+               else
+                       colorizeMeshBuffer(buf, &buffercolor);
        }
 }
 
@@ -481,9 +485,9 @@ void WieldMeshSceneNode::setNodeLightColor(video::SColor color)
                        video::SMaterial &material = m_meshnode->getMaterial(i);
                        material.EmissiveColor = color;
                }
-       } else {
-               setColor(color);
        }
+
+       setColor(color);
 }
 
 void WieldMeshSceneNode::render()