From 1881b01d3fe1805d371589969b4a75b9cccd8d26 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Sat, 12 Nov 2022 01:38:09 +0100 Subject: Per application color saturation support (#21) * Initial implementation without fullscreen support * Limit saturation to 2 * Fixed saturation not working for fullscreen applications like CSGO * Fixed saturation ignoring border radius * Updated README and sway.5 man page * Rebased from Master * Added command to README * Fixed nitpicks --- sway/desktop/shaders/tex_rgba.frag | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sway/desktop/shaders/tex_rgba.frag') diff --git a/sway/desktop/shaders/tex_rgba.frag b/sway/desktop/shaders/tex_rgba.frag index 95f58987..2a9dbccb 100644 --- a/sway/desktop/shaders/tex_rgba.frag +++ b/sway/desktop/shaders/tex_rgba.frag @@ -7,9 +7,20 @@ uniform vec2 size; uniform vec2 position; uniform float radius; uniform bool has_titlebar; +uniform float saturation; +const vec3 saturation_weight = vec3(0.2125, 0.7154, 0.0721); void main() { - gl_FragColor = texture2D(tex, v_texcoord) * alpha; + // Saturation + if (saturation != 1.0) { + vec4 pixColor = texture2D(tex, v_texcoord); + vec3 irgb = pixColor.rgb; + vec3 target = vec3(dot(irgb, saturation_weight)); + gl_FragColor = vec4(mix(target, irgb, saturation), pixColor.a) * alpha; + } else { + gl_FragColor = texture2D(tex, v_texcoord) * alpha; + } + if (!has_titlebar || gl_FragCoord.y - position.y > radius) { vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy); if (max(corner_distance.x, corner_distance.y) < radius) { -- cgit v1.2.3