From d397b8ca22e7640d4e42cb0154446322afb282e0 Mon Sep 17 00:00:00 2001 From: nightuser <1827576+nightuser@users.noreply.github.com> Date: Sun, 26 May 2019 22:49:03 +0300 Subject: [PATCH] Change blending options for transparent background --- kitty/cell_fragment.glsl | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/kitty/cell_fragment.glsl b/kitty/cell_fragment.glsl index 3cfa5fd0a8a..dae7810fa50 100644 --- a/kitty/cell_fragment.glsl +++ b/kitty/cell_fragment.glsl @@ -53,14 +53,6 @@ vec4 alpha_blend_premul(vec3 over, float over_alpha, vec3 under, float under_alp float alpha = mix(under_alpha, 1.0f, over_alpha); return vec4(premul_blend(over, over_alpha, under), alpha); } - -float max3(vec3 v) { - return max(max(v.r, v.g), v.b); -} - -float rgb_to_grayscale(vec3 color) { - return dot(vec3(0.3, 0.59, 0.11), color); -} // }}} #ifdef NEEDS_FOREGROUND @@ -71,7 +63,7 @@ vec4 calculate_foreground() { #ifdef TRANSPARENT // According to https://stackoverflow.com/questions/33507617/blending-text-rendered-by-freetype-in-color-and-alpha // it's impossible to precisely blend it if we use RGBA. Hence, the following hack is used. - float alpha = rgb_to_grayscale(text_fg.rgb); // Grayscale looks much nicer than max3 + float alpha = text_fg.g; // TODO: Cairo uses green channel when converts FreeType's subpixel to ARGB vec3 scaled_mask = mix(vec3(1.0), text_fg.rgb / alpha, bvec3(alpha > 0)); // TODO: May get not normalized values? vec3 blended_fg = mix(background * bg_alpha * bg_alpha, foreground, scaled_mask); // TODO: Check whether we should multiply by bg_alpha float text_alpha = mix(text_fg.a, alpha, subpixel);