Write foreground output only at end of shader

This commit is contained in:
Kovid Goyal
2025-08-26 12:09:30 +05:30
parent da641982e2
commit f8dac2c136
2 changed files with 10 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ in vec3 underline_pos;
in vec3 cursor_pos; in vec3 cursor_pos;
in vec3 strike_pos; in vec3 strike_pos;
flat in uint underline_exclusion_pos; flat in uint underline_exclusion_pos;
in vec3 foreground; in vec3 cell_foreground;
in vec4 cursor_color_premult; in vec4 cursor_color_premult;
in vec3 decoration_fg; in vec3 decoration_fg;
in float colored_sprite; in float colored_sprite;
@@ -62,7 +62,7 @@ vec4 load_text_foreground_color() {
// For colored sprites use the color from the sprite rather than the text foreground // For colored sprites use the color from the sprite rather than the text foreground
// Return non-premultiplied foreground color // Return non-premultiplied foreground color
vec4 text_fg = texture(sprites, sprite_pos); vec4 text_fg = texture(sprites, sprite_pos);
return vec4(mix(foreground, text_fg.rgb, colored_sprite), text_fg.a); return vec4(mix(cell_foreground, text_fg.rgb, colored_sprite), text_fg.a);
} }
vec4 calculate_premul_foreground_from_sprites(vec4 text_fg) { vec4 calculate_premul_foreground_from_sprites(vec4 text_fg) {

View File

@@ -47,16 +47,16 @@ const uint cursor_shape_map[] = uint[5]( // maps cursor shape to foreground spr
out vec3 background; out vec3 background;
out vec4 effective_background_premul; out vec4 effective_background_premul;
#ifndef ONLY_BACKGROUND #ifndef ONLY_BACKGROUND
out float effective_text_alpha;
out vec3 sprite_pos; out vec3 sprite_pos;
out vec3 underline_pos; out vec3 underline_pos;
out vec3 cursor_pos; out vec3 cursor_pos;
out vec4 cursor_color_premult;
out vec3 strike_pos; out vec3 strike_pos;
flat out uint underline_exclusion_pos; flat out uint underline_exclusion_pos;
out vec3 foreground; out vec3 cell_foreground;
out vec4 cursor_color_premult;
out vec3 decoration_fg; out vec3 decoration_fg;
out float colored_sprite; out float colored_sprite;
out float effective_text_alpha;
#endif #endif
@@ -261,7 +261,7 @@ void main() {
// Foreground {{{ // Foreground {{{
#ifndef ONLY_BACKGROUND // background does not depend on foreground #ifndef ONLY_BACKGROUND // background does not depend on foreground
fg_as_uint = has_mark * color_table[NUM_COLORS + MARK_MASK + mark] + (ONE - has_mark) * fg_as_uint; fg_as_uint = has_mark * color_table[NUM_COLORS + MARK_MASK + mark] + (ONE - has_mark) * fg_as_uint;
foreground = color_to_vec(fg_as_uint); vec3 foreground = color_to_vec(fg_as_uint);
float has_dim = float((text_attrs >> DIM_SHIFT) & ONE), has_blink = float((text_attrs >> BLINK_SHIFT) & ONE); float has_dim = float((text_attrs >> DIM_SHIFT) & ONE), has_blink = float((text_attrs >> BLINK_SHIFT) & ONE);
effective_text_alpha = inactive_text_alpha * if_one_then(has_dim, dim_opacity, 1.0) * if_one_then( effective_text_alpha = inactive_text_alpha * if_one_then(has_dim, dim_opacity, 1.0) * if_one_then(
has_blink, blink_opacity, 1.0); has_blink, blink_opacity, 1.0);
@@ -320,4 +320,8 @@ void main() {
bgpremul *= draw_bg; bgpremul *= draw_bg;
effective_background_premul = bgpremul; effective_background_premul = bgpremul;
#endif #endif
#ifndef ONLY_BACKGROUND
cell_foreground = foreground;
#endif
} }