forked from alacritty/alacritty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes alacritty#1628.
- Loading branch information
Showing
11 changed files
with
195 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,53 @@ | ||
#version 330 core | ||
|
||
// We're using `origin_upper_left`, since we only known about padding from left | ||
// and top. If we use default `origin_bottom_left` we won't be able to offset | ||
// `gl_FragCoord` properly to align with the terminal grid. | ||
layout(origin_upper_left) in vec4 gl_FragCoord; | ||
|
||
flat in vec4 color; | ||
|
||
out vec4 FragColor; | ||
|
||
uniform int isUndercurl; | ||
|
||
uniform float cellWidth; | ||
uniform float cellHeight; | ||
uniform float paddingY; | ||
uniform float paddingX; | ||
|
||
uniform float undercurlThickness; | ||
uniform float undercurlPosition; | ||
|
||
#define PI 3.1415926538 | ||
|
||
void main() | ||
{ | ||
FragColor = color; | ||
if (isUndercurl == 0) { | ||
FragColor = color; | ||
return; | ||
} | ||
|
||
int x = int(gl_FragCoord.x - paddingX) % int(cellWidth); | ||
int y = int(gl_FragCoord.y - paddingY) % int(cellHeight); | ||
|
||
// We use `undercurlPosition` as amplitude, since it's half of the descent | ||
// value. | ||
float undercurl = -1. * undercurlPosition / 2. | ||
* cos(float(x) * 2 * PI / float(cellWidth)) | ||
+ cellHeight - undercurlPosition; | ||
|
||
float undercurl_top = undercurl + undercurlThickness / 2.; | ||
float undercurl_bottom = undercurl - undercurlThickness / 2.; | ||
|
||
|
||
// Compute resulted alpha based on distance from `gl_FragCoord.y` to the | ||
// cosine curve. | ||
float alpha = 1.; | ||
if (y > undercurl_top || y < undercurl_bottom) { | ||
alpha = 1. - min(abs(undercurl_top - y), abs(undercurl_bottom - y)); | ||
} | ||
|
||
// The result is an alpha mask on a rect, which leaves only curve opaque. | ||
FragColor = vec4(color.xyz, alpha); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.