summaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorJoe Wilm <jwilm@users.noreply.github.com>2017-10-21 15:26:42 -0700
committerGitHub <noreply@github.com>2017-10-21 15:26:42 -0700
commitb79574ee823900c21759628f92cf036271847afc (patch)
tree0147c31cde54febf034749b095513d3b5b376130 /res
parent7a5eebd0941169396557b80084c0c8f354c6840f (diff)
Fix solid background color opacity (#847)
Since landing the patch adding transparency support to Alacritty, there's been an issue where othewise solid background cells were also being rendered partially transparent. Now, all filled background cells are rendered fully opaque. Some logic was added to support discarding filled backgrounds which had the same color as the default background. This means that, if the default background is #000 and a cell has that background, it will never be rendered opaque. This may not be correct. Note that many truecolor vim color schemes print spaces for default colored background cells. Performance can be dramatically improved by using ctermbg=NONE guibg=NONE to skip rendering those cells.
Diffstat (limited to 'res')
-rw-r--r--res/text.f.glsl7
-rw-r--r--res/text.v.glsl7
2 files changed, 8 insertions, 6 deletions
diff --git a/res/text.f.glsl b/res/text.f.glsl
index dd60333c..5915960f 100644
--- a/res/text.f.glsl
+++ b/res/text.f.glsl
@@ -14,7 +14,7 @@
#version 330 core
in vec2 TexCoords;
in vec3 fg;
-in vec3 bg;
+in vec4 bg;
flat in float vb;
flat in int background;
@@ -27,8 +27,11 @@ uniform sampler2D mask;
void main()
{
if (background != 0) {
+ if (bg.a == 0.0)
+ discard;
+
alphaMask = vec4(1.0);
- color = vec4(bg + vb, 1.0) * bgOpacity;
+ color = vec4(bg.rgb + vb, 1.0);
} else {
vec3 textColor = texture(mask, TexCoords).rgb;
alphaMask = vec4(textColor, textColor.r);
diff --git a/res/text.v.glsl b/res/text.v.glsl
index 081ca6b9..9580c71f 100644
--- a/res/text.v.glsl
+++ b/res/text.v.glsl
@@ -26,11 +26,11 @@ layout (location = 3) in vec4 uv;
// text fg color
layout (location = 4) in vec3 textColor;
// Background color
-layout (location = 5) in vec3 backgroundColor;
+layout (location = 5) in vec4 backgroundColor;
out vec2 TexCoords;
out vec3 fg;
-out vec3 bg;
+out vec4 bg;
// Terminal properties
uniform vec2 termDim;
@@ -63,7 +63,6 @@ void main()
gl_Position = projection * vec4(finalPosition.xy, 0.0, 1.0);
TexCoords = vec2(0, 0);
} else {
-
// Glyphs are offset within their cell; account for y-flip
vec2 cellOffset = vec2(glyphOffset.x, glyphOffset.y - glyphSize.y);
@@ -76,6 +75,6 @@ void main()
vb = visualBell;
background = backgroundPass;
- bg = backgroundColor / vec3(255.0, 255.0, 255.0);
+ bg = vec4(backgroundColor.rgb / 255.0, backgroundColor.a);
fg = textColor / vec3(255.0, 255.0, 255.0);
}