From 69c70dd319532f7860f211f4a527a902b0386e49 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sat, 8 May 2021 20:18:29 +0200 Subject: [PATCH] Fix swapped vertex colors on GLES2 --- client/shaders/default_shader/opengl_vertex.glsl | 4 ++++ client/shaders/minimap_shader/opengl_vertex.glsl | 4 ++++ client/shaders/nodes_shader/opengl_vertex.glsl | 10 +++++++--- client/shaders/object_shader/opengl_vertex.glsl | 4 ++++ client/shaders/selection_shader/opengl_vertex.glsl | 4 ++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/client/shaders/default_shader/opengl_vertex.glsl b/client/shaders/default_shader/opengl_vertex.glsl index d95a3c2d3..a908ac953 100644 --- a/client/shaders/default_shader/opengl_vertex.glsl +++ b/client/shaders/default_shader/opengl_vertex.glsl @@ -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 } diff --git a/client/shaders/minimap_shader/opengl_vertex.glsl b/client/shaders/minimap_shader/opengl_vertex.glsl index 1a9491805..b23d27181 100644 --- a/client/shaders/minimap_shader/opengl_vertex.glsl +++ b/client/shaders/minimap_shader/opengl_vertex.glsl @@ -7,5 +7,9 @@ void main(void) { varTexCoord = inTexCoord0.st; gl_Position = mWorldViewProj * inVertexPosition; +#ifdef GL_ES + varColor = inVertexColor.bgra; +#else varColor = inVertexColor; +#endif } diff --git a/client/shaders/nodes_shader/opengl_vertex.glsl b/client/shaders/nodes_shader/opengl_vertex.glsl index c68df4a8e..1a4840d35 100644 --- a/client/shaders/nodes_shader/opengl_vertex.glsl +++ b/client/shaders/nodes_shader/opengl_vertex.glsl @@ -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; diff --git a/client/shaders/object_shader/opengl_vertex.glsl b/client/shaders/object_shader/opengl_vertex.glsl index b4a4d0aaa..f26224e82 100644 --- a/client/shaders/object_shader/opengl_vertex.glsl +++ b/client/shaders/object_shader/opengl_vertex.glsl @@ -49,5 +49,9 @@ void main(void) : directional_ambient(normalize(inVertexNormal)); #endif +#ifdef GL_ES + varColor = inVertexColor.bgra; +#else varColor = inVertexColor; +#endif } diff --git a/client/shaders/selection_shader/opengl_vertex.glsl b/client/shaders/selection_shader/opengl_vertex.glsl index 9ca87a9cf..39dde3056 100644 --- a/client/shaders/selection_shader/opengl_vertex.glsl +++ b/client/shaders/selection_shader/opengl_vertex.glsl @@ -6,5 +6,9 @@ void main(void) varTexCoord = inTexCoord0.st; gl_Position = mWorldViewProj * inVertexPosition; +#ifdef GL_ES + varColor = inVertexColor.bgra; +#else varColor = inVertexColor; +#endif }