From ea250ff5c57301b6ea3e529c811484c743c1fde1 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 10 Sep 2021 21:59:29 +0200 Subject: Fix GLES2 discard behaviour (texture transparency) --- client/shaders/object_shader/opengl_fragment.glsl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'client/shaders/object_shader/opengl_fragment.glsl') diff --git a/client/shaders/object_shader/opengl_fragment.glsl b/client/shaders/object_shader/opengl_fragment.glsl index 8d6f57a44..9a0b90f15 100644 --- a/client/shaders/object_shader/opengl_fragment.glsl +++ b/client/shaders/object_shader/opengl_fragment.glsl @@ -328,13 +328,16 @@ void main(void) vec2 uv = varTexCoord.st; vec4 base = texture2D(baseTexture, uv).rgba; -#ifdef USE_DISCARD // If alpha is zero, we can just discard the pixel. This fixes transparency // on GPUs like GC7000L, where GL_ALPHA_TEST is not implemented in mesa, // and also on GLES 2, where GL_ALPHA_TEST is missing entirely. - if (base.a == 0.0) { +#ifdef USE_DISCARD + if (base.a == 0.0) + discard; +#endif +#ifdef USE_DISCARD_REF + if (base.a < 0.5) discard; - } #endif color = base.rgb; -- cgit v1.2.3