Skip to content

Commit

Permalink
Fix swapped vertex colors on GLES2
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed May 11, 2021
1 parent 2443f1e commit 69c70dd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions client/shaders/default_shader/opengl_vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ varying lowp vec4 varColor;
void main(void)
{
gl_Position = mWorldViewProj * inVertexPosition;
#ifdef GL_ES
varColor = inVertexColor.bgra;
#else
varColor = inVertexColor;
#endif
}
4 changes: 4 additions & 0 deletions client/shaders/minimap_shader/opengl_vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ void main(void)
{
varTexCoord = inTexCoord0.st;
gl_Position = mWorldViewProj * inVertexPosition;
#ifdef GL_ES
varColor = inVertexColor.bgra;
#else
varColor = inVertexColor;
#endif
}
10 changes: 7 additions & 3 deletions client/shaders/nodes_shader/opengl_vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,14 @@ void main(void)
// the brightness, so now we have to multiply these
// colors with the color of the incoming light.
// The pre-baked colors are halved to prevent overflow.
vec4 color;
#ifdef GL_ES
vec4 color = inVertexColor.bgra;
#else
vec4 color = inVertexColor;
#endif
// The alpha gives the ratio of sunlight in the incoming light.
float nightRatio = 1.0 - inVertexColor.a;
color.rgb = inVertexColor.rgb * (inVertexColor.a * dayLight.rgb +
float nightRatio = 1.0 - color.a;
color.rgb = color.rgb * (color.a * dayLight.rgb +
nightRatio * artificialLight.rgb) * 2.0;
color.a = 1.0;

Expand Down
4 changes: 4 additions & 0 deletions client/shaders/object_shader/opengl_vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ void main(void)
: directional_ambient(normalize(inVertexNormal));
#endif

#ifdef GL_ES
varColor = inVertexColor.bgra;
#else
varColor = inVertexColor;
#endif
}
4 changes: 4 additions & 0 deletions client/shaders/selection_shader/opengl_vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ void main(void)
varTexCoord = inTexCoord0.st;
gl_Position = mWorldViewProj * inVertexPosition;

#ifdef GL_ES
varColor = inVertexColor.bgra;
#else
varColor = inVertexColor;
#endif
}

0 comments on commit 69c70dd

Please sign in to comment.