Skip to content

Commit

Permalink
Fix broken coloring of wielditems (#9969)
Browse files Browse the repository at this point in the history
Fixes a regression that appeared in 5.3.0-dev.
  • Loading branch information
FunkyDck committed Jun 9, 2020
1 parent 7148834 commit fe3e69e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion client/shaders/object_shader/opengl_fragment.glsl
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion client/shaders/object_shader/opengl_vertex.glsl
Expand Up @@ -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;
}
10 changes: 7 additions & 3 deletions src/client/wieldmesh.cpp
Expand Up @@ -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);
}
}

Expand All @@ -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()
Expand Down

0 comments on commit fe3e69e

Please sign in to comment.