From 5009566ea5c46a85fa243b18ce4b7fe8e0b89b62 Mon Sep 17 00:00:00 2001 From: Gabriel Martinez Date: Sun, 20 Aug 2017 09:55:45 -0700 Subject: Add background_opacity option to set terminal transparency (#331) The option is an Alpha struct that ensures that the contained float is between 0.0 and 1.0. Background colors are multiplied by the opacity to properly alpha blend them. --- res/text.f.glsl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'res') diff --git a/res/text.f.glsl b/res/text.f.glsl index 70d50b38..dd60333c 100644 --- a/res/text.f.glsl +++ b/res/text.f.glsl @@ -21,15 +21,17 @@ flat in int background; layout(location = 0, index = 0) out vec4 color; layout(location = 0, index = 1) out vec4 alphaMask; +uniform float bgOpacity; uniform sampler2D mask; void main() { if (background != 0) { - alphaMask = vec4(1.0, 1.0, 1.0, 1.0); - color = vec4(bg + vb, 1.0); + alphaMask = vec4(1.0); + color = vec4(bg + vb, 1.0) * bgOpacity; } else { - alphaMask = vec4(texture(mask, TexCoords).rgb, 1.0); + vec3 textColor = texture(mask, TexCoords).rgb; + alphaMask = vec4(textColor, textColor.r); color = vec4(fg, 1.0); } } -- cgit v1.2.3-54-g00ecf