gles2: pre-multiply alpha and fix blending function

This commit is contained in:
Ilia Bozhinov 2018-05-18 20:05:49 +03:00
parent 98088e78df
commit 47ffd0e184
2 changed files with 4 additions and 7 deletions

View file

@ -42,7 +42,7 @@ static void gles2_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
// enable transparency // enable transparency
glEnable(GL_BLEND); 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 // XXX: maybe we should save output projection and remove some of the need
// for users to sling matricies themselves // for users to sling matricies themselves

View file

@ -63,8 +63,7 @@ const GLchar tex_fragment_src_rgba[] =
"uniform float alpha;\n" "uniform float alpha;\n"
"\n" "\n"
"void main() {\n" "void main() {\n"
" gl_FragColor.rgb = texture2D(tex, v_texcoord).rgb;\n" " gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n"
" gl_FragColor.a = alpha * texture2D(tex, v_texcoord).a;\n"
"}\n"; "}\n";
const GLchar tex_fragment_src_rgbx[] = const GLchar tex_fragment_src_rgbx[] =
@ -74,8 +73,7 @@ const GLchar tex_fragment_src_rgbx[] =
"uniform float alpha;\n" "uniform float alpha;\n"
"\n" "\n"
"void main() {\n" "void main() {\n"
" gl_FragColor.rgb = texture2D(tex, v_texcoord).rgb;\n" " gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n"
" gl_FragColor.a = alpha;\n"
"}\n"; "}\n";
const GLchar tex_fragment_src_external[] = const GLchar tex_fragment_src_external[] =
@ -86,6 +84,5 @@ const GLchar tex_fragment_src_external[] =
"uniform float alpha;\n" "uniform float alpha;\n"
"\n" "\n"
"void main() {\n" "void main() {\n"
" vec4 col = texture2D(texture0, v_texcoord);\n" " gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n"
" gl_FragColor = vec4(col.rgb, col.a * alpha);\n"
"}\n"; "}\n";