diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2022-03-14 08:52:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-14 08:52:53 +0300 |
commit | 589c1e9c6b8830625162af14a9a7aee32c7aade0 (patch) | |
tree | 03c4bd5ccf4ad259bda3a2c7d99788fe4a9d5011 | |
parent | 7312f33f6711cccd04c3e34d25b9b11514cbb90e (diff) | |
download | alacritty-589c1e9c6b8830625162af14a9a7aee32c7aade0.tar.gz alacritty-589c1e9c6b8830625162af14a9a7aee32c7aade0.zip |
Use center of the pixel when aligning undercurl
Since `x` position in rect shader represents left side of the pixel we
should use the center of it when dealing with contiguous functions.
-rw-r--r-- | alacritty/res/rect.f.glsl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/alacritty/res/rect.f.glsl b/alacritty/res/rect.f.glsl index 4fbbd874..4e8fdd01 100644 --- a/alacritty/res/rect.f.glsl +++ b/alacritty/res/rect.f.glsl @@ -37,11 +37,14 @@ uniform float_t undercurlPosition; color_t draw_undercurl(float_t x, float_t y) { // We use `undercurlPosition` as an amplitude, since it's half of the descent // value. - float_t undercurl = undercurlPosition / 2. * cos(x * 2. * PI / cellWidth) - + undercurlPosition - 1.; - - float_t undercurlTop = undercurl + max((underlineThickness - 1.), 0.); - float_t undercurlBottom = undercurl - max((underlineThickness - 1.), 0.); + // + // The `x` represents the left bound of pixel we should add `1/2` to it, so + // we compute the undercurl position for the center of the pixel. + float_t undercurl = undercurlPosition / 2. * cos((x + 0.5) * 2. + * PI / cellWidth) + undercurlPosition - 1.; + + float_t undercurlTop = undercurl + max((underlineThickness - 1.), 0.) / 2.; + float_t undercurlBottom = undercurl - max((underlineThickness - 1.), 0.) / 2.; // Compute resulted alpha based on distance from `gl_FragCoord.y` to the // cosine curve. |