@@ -151,7 +151,8 @@ void main() {
151151 // set cell color indices {{{
152152 uvec2 default_colors = uvec2 (default_fg, default_bg);
153153 uint text_attrs = sprite_coords[3 ];
154- uint is_inverted = ((text_attrs >> REVERSE_SHIFT) & ONE) + inverted;
154+ uint is_reversed = ((text_attrs >> REVERSE_SHIFT) & ONE);
155+ uint is_inverted = is_reversed + inverted;
155156 int fg_index = fg_index_map[is_inverted];
156157 int bg_index = 1 - fg_index;
157158 float cell_has_cursor = is_cursor(c, r);
@@ -200,22 +201,25 @@ void main() {
200201 background = bg;
201202#endif
202203
203- #if defined(TRANSPARENT) && ! defined(SPECIAL)
204- // If the background color is default, set its opacity to background_opacity, otherwise it should be opaque
205- bg_alpha = step (0.5 , float (colors[bg_index] & BYTE_MASK));
206- // Cursor must not be affected by background_opacity
207- bg_alpha = mix (bg_alpha, 1.0 , cell_has_block_cursor);
204+ #if defined(TRANSPARENT)
205+ // Set bg_alpha to background_opacity on cells that have the default background color
206+ // Which means they must not have a block cursor or a selection or reverse video
207+ // On other cells it should be 1. For the SPECIAL program it should be 1 on cells with
208+ // selections/block cursor and 0 everywhere else.
209+ float is_special_cell = cell_has_block_cursor + float (is_selected & ONE);
210+ #ifndef SPECIAL
211+ is_special_cell += float (colors[bg_index] & BYTE_MASK) + float (is_reversed);
212+ #endif
213+ bg_alpha = step (0.5 , is_special_cell);
214+ #ifndef SPECIAL
208215 bg_alpha = bg_alpha + (1 .0f - bg_alpha) * background_opacity;
209216#endif
217+ #endif
210218
211219#if defined(SPECIAL) || defined(SIMPLE)
212220 // Selection and cursor
213221 bg = choose_color(float (is_selected & ONE), color_to_vec(highlight_bg), bg);
214222 background = choose_color(cell_has_block_cursor, color_to_vec(cursor_color), bg);
215- #ifdef SPECIAL
216- // bg_alpha should be 1 if cursor/selection otherwise 0
217- bg_alpha = mix (0.0 , 1.0 , step (0.5 , float (is_selected & ONE) + cell_has_block_cursor));
218- #endif
219223#endif
220224
221225#endif
0 commit comments