Skip to content

Commit 4ac5b8f

Browse files
committed
Fix text_fg_override_threshold not working with multi-pass rendering
This has the side-effect of also applying the same luminance based gamma adjustment for multipass rendering as we do for single pass rendering. This *may* make things look worse with very low background_opacity values, since in such cases the actual background color can be quite different from the background color we are adjusting against.
1 parent b7fd46d commit 4ac5b8f

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

kitty/cell_fragment.glsl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
#pragma kitty_include_shader <linear2srgb.glsl>
33
#pragma kitty_include_shader <cell_defines.glsl>
44

5-
#ifdef NEEDS_BACKROUND
65
in vec3 background;
76
in float draw_bg;
87
#ifdef NEEDS_BG_ALPHA
98
in float bg_alpha;
109
#endif
11-
#endif
1210

1311
#ifdef NEEDS_FOREGROUND
1412
uniform sampler2DArray sprites;
@@ -199,6 +197,7 @@ void main() {
199197

200198
#if (PHASE == PHASE_FOREGROUND)
201199
vec4 text_fg = load_text_foreground_color();
200+
text_fg = adjust_foreground_contrast_with_background(text_fg, background);
202201
vec4 text_fg_premul = calculate_premul_foreground_from_sprites(text_fg);
203202
final_color = text_fg_premul;
204203
#ifdef TRANSPARENT

kitty/cell_vertex.glsl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ const uvec2 cell_pos_map[] = uvec2[4](
3434
// }}}
3535

3636

37-
#ifdef NEEDS_BACKROUND
3837
out vec3 background;
3938
out float draw_bg;
4039
#ifdef NEEDS_BG_ALPHA
4140
out float bg_alpha;
4241
#endif
43-
#endif
4442

4543
#ifdef NEEDS_FOREGROUND
4644
uniform float inactive_text_alpha;
@@ -198,7 +196,6 @@ void main() {
198196
// }}}
199197

200198
// Background {{{
201-
#ifdef NEEDS_BACKROUND
202199
float cell_has_non_default_bg = step(1, float(abs(bg_as_uint - default_colors[1])));
203200
draw_bg = 1;
204201

@@ -235,7 +232,6 @@ void main() {
235232
#endif
236233
#endif
237234

238-
#endif
239235
// }}}
240236

241237
}

kitty/options/definition.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@
276276
foreground and background is below this threshold, the foreground color will be set
277277
to white if the background is dark or black if the background is light. The default
278278
value is :code:`0`, which means no overriding is performed. Useful when working with applications
279-
that use colors that do not contrast well with your preferred color scheme. Note that this
280-
will not work in situations where kitty has to render in multiple passes, for example,
281-
when rendering with images under text or with non-opaque background and images.
279+
that use colors that do not contrast well with your preferred color scheme.
282280
''')
283281

284282
egr() # }}}
@@ -1352,21 +1350,24 @@
13521350
option_type='unit_float', ctype='float',
13531351
long_text='''
13541352
The opacity of the background. A number between zero and one, where one is
1355-
opaque and zero is fully transparent. This will only work if supported by the OS
1356-
(for instance, when using a compositor under X11). Note that it only sets the
1357-
background color's opacity in cells that have the same background color as the
1358-
default terminal background, so that things like the status bar in vim,
1353+
opaque and zero is fully transparent. This will only work if supported by the
1354+
OS (for instance, when using a compositor under X11). Note that it only sets
1355+
the background color's opacity in cells that have the same background color as
1356+
the default terminal background, so that things like the status bar in vim,
13591357
powerline prompts, etc. still look good. But it means that if you use a color
13601358
theme with a background color in your editor, it will not be rendered as
13611359
transparent. Instead you should change the default background color in your
13621360
kitty config and not use a background color in the editor color scheme. Or use
1363-
the escape codes to set the terminals default colors in a shell script to launch
1364-
your editor. Be aware that using a value less than 1.0 is a (possibly
1365-
significant) performance hit. If you want to dynamically change transparency of
1366-
windows, set :opt:`dynamic_background_opacity` to :code:`yes` (this is off by
1367-
default as it has a performance cost). Changing this option when reloading the
1368-
config will only work if :opt:`dynamic_background_opacity` was enabled in the
1369-
original config.
1361+
the escape codes to set the terminals default colors in a shell script to
1362+
launch your editor. Be aware that using a value less than 1.0 is a (possibly
1363+
significant) performance hit. When using a low value for this setting, it is
1364+
desirable that you set the :opt:`background` color to a color the matches the
1365+
general color of the desktop background, for best text rendering. If you want
1366+
to dynamically change transparency of windows, set
1367+
:opt:`dynamic_background_opacity` to :code:`yes` (this is off by default as it
1368+
has a performance cost). Changing this option when reloading the config will
1369+
only work if :opt:`dynamic_background_opacity` was enabled in the original
1370+
config.
13701371
'''
13711372
)
13721373

0 commit comments

Comments
 (0)