From 54889fc4ff117f59efb392955a18b414fee570c7 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 24 Nov 2023 23:57:43 +0400 Subject: [PATCH] Make AA stronger for undercurl This improves undercurl rendering preserving its original thickness. This also makes it look not out-of place when places next to other lines. --- alacritty/res/rect.f.glsl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/alacritty/res/rect.f.glsl b/alacritty/res/rect.f.glsl index 65701da3..9951861f 100644 --- a/alacritty/res/rect.f.glsl +++ b/alacritty/res/rect.f.glsl @@ -45,7 +45,11 @@ color_t draw_undercurl(float_t x, float_t y) { // cosine curve. float_t alpha = 1.; if (y > undercurlTop || y < undercurlBottom) { - alpha = 1. - min(abs(undercurlTop - y), abs(undercurlBottom - y)); + // Doing proper SDF is complicated for this shader, so just make AA + // stronger by 1/x^2, which renders preserving underline thickness and + // being bold enough. + float_t dst = min(abs(undercurlTop - y), abs(undercurlBottom - y)); + alpha -= dst * dst; } // The result is an alpha mask on a rect, which leaves only curve opaque.