From d3c022779a9d5848a20180c1fa5f184aa9703862 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 19 Oct 2017 19:01:33 +0200 Subject: video: fix alpha handling Regression since ec6e8a31e092a1d. Removal of the explicit else case always applies the conversion to premultiplied alpha in the else branch. We want to scale with multiplied alpha, but we don't want to multiply with alpha again on top of it. Fixes #4983, hopefully. --- video/out/gpu/video.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'video') diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index 2ec5e91207..9191f062b6 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -2777,13 +2777,15 @@ static void pass_draw_to_screen(struct gl_video *p, struct ra_fbo fbo) GLSLF("// transparency checkerboard\n"); GLSL(bvec2 tile = lessThan(fract(gl_FragCoord.xy * 1.0/32.0), vec2(0.5));) GLSL(vec3 background = vec3(tile.x == tile.y ? 0.93 : 0.87);) - GLSL(color.rgb = mix(background, color.rgb, color.a);) + GLSL(color.rgb += background.rgb * (1.0 - color.a);) + GLSL(color.a = 1.0;) } else if (p->opts.alpha_mode == ALPHA_BLEND) { // Blend into background color (usually black) struct m_color c = p->opts.background; GLSLF("vec4 background = vec4(%f, %f, %f, %f);\n", c.r / 255.0, c.g / 255.0, c.b / 255.0, c.a / 255.0); - GLSL(color = mix(background, vec4(color.rgb, 1.0), color.a);) + GLSL(color.rgb += background.rgb * (1.0 - color.a);) + GLSL(color.a = background.a;) } } -- cgit v1.2.3