aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-05-19 09:21:35 +0100
committerGitHub <noreply@github.com>2018-05-19 09:21:35 +0100
commitb5472796251f8d7ef9d9da7f20db0aaa11ace127 (patch)
treee732e4062bd86e0e3122a72b433bcd70eabbaac5
parent98088e78df054553ec846043ee913d0dcf39de16 (diff)
parent47ffd0e184dd3886f9e810b9ec89e2a9942014a0 (diff)
Merge pull request #986 from ammen99/master
gles2: pre-multiply alpha and fix blending function
-rw-r--r--render/gles2/renderer.c2
-rw-r--r--render/gles2/shaders.c9
2 files changed, 4 insertions, 7 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index c10493c4..8360c5fb 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -42,7 +42,7 @@ static void gles2_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
// enable transparency
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
// XXX: maybe we should save output projection and remove some of the need
// for users to sling matricies themselves
diff --git a/render/gles2/shaders.c b/render/gles2/shaders.c
index b940ee53..01410d87 100644
--- a/render/gles2/shaders.c
+++ b/render/gles2/shaders.c
@@ -63,8 +63,7 @@ const GLchar tex_fragment_src_rgba[] =
"uniform float alpha;\n"
"\n"
"void main() {\n"
-" gl_FragColor.rgb = texture2D(tex, v_texcoord).rgb;\n"
-" gl_FragColor.a = alpha * texture2D(tex, v_texcoord).a;\n"
+" gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n"
"}\n";
const GLchar tex_fragment_src_rgbx[] =
@@ -74,8 +73,7 @@ const GLchar tex_fragment_src_rgbx[] =
"uniform float alpha;\n"
"\n"
"void main() {\n"
-" gl_FragColor.rgb = texture2D(tex, v_texcoord).rgb;\n"
-" gl_FragColor.a = alpha;\n"
+" gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n"
"}\n";
const GLchar tex_fragment_src_external[] =
@@ -86,6 +84,5 @@ const GLchar tex_fragment_src_external[] =
"uniform float alpha;\n"
"\n"
"void main() {\n"
-" vec4 col = texture2D(texture0, v_texcoord);\n"
-" gl_FragColor = vec4(col.rgb, col.a * alpha);\n"
+" gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n"
"}\n";