diff options
author | lbonn <lbonn@users.noreply.github.com> | 2020-05-12 15:23:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-12 16:23:35 +0300 |
commit | 77f2d6e853f1ad54e6dc844a811b78daeb463e76 (patch) | |
tree | 2bdda495a8825f1dbb3ff3743f76c9dafd40dbe1 /res | |
parent | 2c2104a51776ac826dde35f54423657f2d5150fb (diff) | |
download | alacritty-77f2d6e853f1ad54e6dc844a811b78daeb463e76.tar.gz alacritty-77f2d6e853f1ad54e6dc844a811b78daeb463e76.zip |
Fix emojis being blended with background
Fixes #1864.
Diffstat (limited to 'res')
-rw-r--r-- | res/text.f.glsl | 21 | ||||
-rw-r--r-- | res/text.v.glsl | 15 |
2 files changed, 28 insertions, 8 deletions
diff --git a/res/text.f.glsl b/res/text.f.glsl index 70ad3d19..cf477eb0 100644 --- a/res/text.f.glsl +++ b/res/text.f.glsl @@ -15,6 +15,7 @@ in vec2 TexCoords; flat in vec3 fg; flat in vec4 bg; +flat in int colored; uniform int backgroundPass; layout(location = 0, index = 0) out vec4 color; @@ -31,8 +32,22 @@ void main() alphaMask = vec4(1.0); color = vec4(bg.rgb, 1.0); } else { - vec3 textColor = texture(mask, TexCoords).rgb; - alphaMask = vec4(textColor, textColor.r); - color = vec4(fg, 1.0); + if (colored != 0) { + // Color glyphs, like emojis. + vec4 glyphColor = texture(mask, TexCoords); + alphaMask = vec4(glyphColor.a); + + // Revert alpha premultiplication. + if (glyphColor.a != 0) { + glyphColor.rgb = vec3(glyphColor.rgb / glyphColor.a); + } + + color = vec4(glyphColor.rgb, 1.0); + } else { + // Regular text glyphs. + vec3 textColor = texture(mask, TexCoords).rgb; + alphaMask = vec4(textColor, textColor.r); + color = vec4(fg, 1.0); + } } } diff --git a/res/text.v.glsl b/res/text.v.glsl index 5189980f..8978c111 100644 --- a/res/text.v.glsl +++ b/res/text.v.glsl @@ -12,24 +12,28 @@ // See the License for the specific language governing permissions and // limitations under the License. #version 330 core -// Cell properties +// Cell properties. layout (location = 0) in vec2 gridCoords; -// glyph properties +// Glyph properties. layout (location = 1) in vec4 glyph; -// uv mapping +// uv mapping. layout (location = 2) in vec4 uv; -// text fg color +// Text fg color. layout (location = 3) in vec3 textColor; -// Background color +// Background color. layout (location = 4) in vec4 backgroundColor; +// Set to 1 if the glyph colors should be kept. +layout (location = 5) in int coloredGlyph; + out vec2 TexCoords; flat out vec3 fg; flat out vec4 bg; +flat out int colored; // Terminal properties uniform vec2 cellDim; @@ -71,4 +75,5 @@ void main() bg = vec4(backgroundColor.rgb / 255.0, backgroundColor.a); fg = textColor / vec3(255.0, 255.0, 255.0); + colored = coloredGlyph; } |