From 9a269d55c7d04334b1c4891c42914423517dfad6 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Thu, 27 Aug 2020 18:21:50 +0300 Subject: [PATCH] Do smarter blending of visual bell flash Blend highlight color with pegtop's softlight mode over both background and half as much over foreground. This should help with flash visibility in light themed and inverted colors contexts. --- kitty/cell_vertex.glsl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kitty/cell_vertex.glsl b/kitty/cell_vertex.glsl index f146f7ebd..3531588b3 100644 --- a/kitty/cell_vertex.glsl +++ b/kitty/cell_vertex.glsl @@ -134,6 +134,10 @@ float is_cursor(uint xi, uint y) { float x_equal = step(0.5, x1_equal + x2_equal); return step(2.0, x_equal + y_equal); } + +vec3 blend_softlight(vec3 base, vec3 blend) { + return (1.0 - 2.0 * blend) * base * base + 2.0 * blend * base; +} // }}} @@ -191,6 +195,10 @@ void main() { // Selection vec3 selection_color = color_to_vec(highlight_fg); foreground = choose_color(float(is_selected & ONE), selection_color, foreground); + foreground = choose_color(visual_bell_intensity * 0.5, + blend_softlight(color_to_vec(highlight_bg), foreground), + foreground + ); decoration_fg = choose_color(float(is_selected & ONE), selection_color, decoration_fg); #endif // Underline and strike through (rendered via sprites) @@ -236,9 +244,12 @@ void main() { #if defined(SPECIAL) || defined(SIMPLE) // Selection and cursor - bg = max(bg, choose_color(visual_bell_intensity, color_to_vec(highlight_bg), bg)); bg = choose_color(float(is_selected & ONE), color_to_vec(highlight_bg), bg); - background = choose_color(cell_has_block_cursor, color_to_vec(cursor_color), bg); + bg = choose_color(cell_has_block_cursor, color_to_vec(cursor_color), bg); + background = choose_color(visual_bell_intensity, + blend_softlight(color_to_vec(highlight_bg), bg), + bg + ); #if !defined(TRANSPARENT) && defined(SPECIAL) float is_special_cell = cell_has_block_cursor + float(is_selected & ONE); bg_alpha = step(0.5, is_special_cell);