Fix blue channel ignored in fg_override contrast check #9820
1 commit 1 file changed
+1 -1 Apr 7, 2026, 01:26 AM
View on GitHub
In cell_vertex.glsl, the HSLuv-based fg override (algo 2) checks if fg and bg are nearly identical before applying contrast correction. The check sums the per-channel color difference, but uses diff.g twice instead of diff.g + diff.b:
// before
step(diff.r + diff.g + diff.g, 0.001f)
// after
step(diff.r + diff.g + diff.b, 0.001f)
This causes the override to skip contrast adjustment for color pairs that differ primarily in blue.
kitty/cell_vertex.glsl +1 -1
| ··· | @@ -284,7 +284,7 @@ vec3 fg_override(float under_luminance, float over_luminance, vec3 under, vec3 o | ||
| 284 | 284 | float result_a_ratio = contrast_ratio(under_luminance, dot(result_a, Y)); | |
| 285 | 285 | float result_b_ratio = contrast_ratio(under_luminance, dot(result_b, Y)); | |
| 286 | 286 | vec3 result = mix(result_a, result_b, step(result_a_ratio, result_b_ratio)); | |
| 287 | - | return mix(result, over, max(step(diff.r + diff.g + diff.g, 0.001f), step(min_contrast_ratio, ratio))); | |
| 287 | + | return mix(result, over, max(step(diff.r + diff.g + diff.b, 0.001f), step(min_contrast_ratio, ratio))); | |
| 288 | 288 | } | |
| 289 | 289 | #endif | |
| 290 | 290 | ||