diff options
Diffstat (limited to 'sway/desktop/shaders')
-rw-r--r-- | sway/desktop/shaders/tex_external.frag | 13 | ||||
-rw-r--r-- | sway/desktop/shaders/tex_rgba.frag | 13 | ||||
-rw-r--r-- | sway/desktop/shaders/tex_rgbx.frag | 12 |
3 files changed, 35 insertions, 3 deletions
diff --git a/sway/desktop/shaders/tex_external.frag b/sway/desktop/shaders/tex_external.frag index 0703a05f..d31cc990 100644 --- a/sway/desktop/shaders/tex_external.frag +++ b/sway/desktop/shaders/tex_external.frag @@ -9,9 +9,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(texture0, v_texcoord) * alpha; + // Saturation + if (saturation != 1.0) { + vec4 pixColor = texture2D(texture0, 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(texture0, 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) { 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) { diff --git a/sway/desktop/shaders/tex_rgbx.frag b/sway/desktop/shaders/tex_rgbx.frag index 4a8b3756..b31c1bfd 100644 --- a/sway/desktop/shaders/tex_rgbx.frag +++ b/sway/desktop/shaders/tex_rgbx.frag @@ -7,9 +7,19 @@ 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 = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha; + // Saturation + if (saturation != 1.0) { + vec3 irgb = texture2D(tex, v_texcoord).rgb; + vec3 target = vec3(dot(irgb, saturation_weight)); + gl_FragColor = vec4(mix(target, irgb, saturation), 1.0) * alpha; + } else { + gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * 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) { |