Skip to content

Commit fe3e69e

Browse files
authoredJun 9, 2020
Fix broken coloring of wielditems (#9969)
Fixes a regression that appeared in 5.3.0-dev.
1 parent 7148834 commit fe3e69e

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed
 

‎client/shaders/object_shader/opengl_fragment.glsl

+3-1
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ void main(void)
145145

146146
vec4 col = vec4(color.rgb, base.a);
147147

148+
col.rgb *= gl_Color.rgb;
149+
148150
col.rgb *= emissiveColor.rgb * vIDiff;
149-
151+
150152
#ifdef ENABLE_TONE_MAPPING
151153
col = applyToneMapping(col);
152154
#endif

‎client/shaders/object_shader/opengl_vertex.glsl

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ void main(void)
3838

3939
lightVec = sunPosition - worldPosition;
4040
eyeVec = -(gl_ModelViewMatrix * gl_Vertex).xyz;
41-
vIDiff = directional_ambient(normalize(gl_Normal));
41+
42+
// This is intentional comparison with zero without any margin.
43+
// If normal is not equal to zero exactly, then we assume it's a valid, just not normalized vector
44+
vIDiff = length(gl_Normal) == 0.0
45+
? 1.0
46+
: directional_ambient(normalize(gl_Normal));
4247

4348
gl_FrontColor = gl_BackColor = gl_Color;
4449
}

‎src/client/wieldmesh.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,11 @@ void WieldMeshSceneNode::setColor(video::SColor c)
467467
bc.getGreen() * green / 255,
468468
bc.getBlue() * blue / 255);
469469
scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
470-
colorizeMeshBuffer(buf, &buffercolor);
470+
471+
if (m_enable_shaders)
472+
setMeshBufferColor(buf, buffercolor);
473+
else
474+
colorizeMeshBuffer(buf, &buffercolor);
471475
}
472476
}
473477

@@ -481,9 +485,9 @@ void WieldMeshSceneNode::setNodeLightColor(video::SColor color)
481485
video::SMaterial &material = m_meshnode->getMaterial(i);
482486
material.EmissiveColor = color;
483487
}
484-
} else {
485-
setColor(color);
486488
}
489+
490+
setColor(color);
487491
}
488492

489493
void WieldMeshSceneNode::render()

0 commit comments

Comments
 (0)
Please sign in to comment.