diff options
Diffstat (limited to 'sway/desktop/shaders')
-rw-r--r-- | sway/desktop/shaders/tex_external.frag | 9 | ||||
-rw-r--r-- | sway/desktop/shaders/tex_rgba.frag | 9 | ||||
-rw-r--r-- | sway/desktop/shaders/tex_rgbx.frag | 9 |
3 files changed, 18 insertions, 9 deletions
diff --git a/sway/desktop/shaders/tex_external.frag b/sway/desktop/shaders/tex_external.frag index d31cc990..9976eb51 100644 --- a/sway/desktop/shaders/tex_external.frag +++ b/sway/desktop/shaders/tex_external.frag @@ -4,6 +4,8 @@ precision mediump float; varying vec2 v_texcoord; uniform samplerExternalOES texture0; uniform float alpha; +uniform float dim; +uniform vec4 dim_color; uniform vec2 size; uniform vec2 position; @@ -13,15 +15,16 @@ uniform float saturation; const vec3 saturation_weight = vec3(0.2125, 0.7154, 0.0721); void main() { + vec4 color = texture2D(texture0, v_texcoord); // 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; + color = vec4(mix(target, irgb, saturation), pixColor.a); } + // Dimming + gl_FragColor = mix(color, dim_color, dim) * alpha; if (!has_titlebar || gl_FragCoord.y - position.y > radius) { vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy); diff --git a/sway/desktop/shaders/tex_rgba.frag b/sway/desktop/shaders/tex_rgba.frag index 2a9dbccb..b46885b2 100644 --- a/sway/desktop/shaders/tex_rgba.frag +++ b/sway/desktop/shaders/tex_rgba.frag @@ -2,6 +2,8 @@ precision mediump float; varying vec2 v_texcoord; uniform sampler2D tex; uniform float alpha; +uniform float dim; +uniform vec4 dim_color; uniform vec2 size; uniform vec2 position; @@ -11,15 +13,16 @@ uniform float saturation; const vec3 saturation_weight = vec3(0.2125, 0.7154, 0.0721); void main() { + vec4 color = texture2D(tex, v_texcoord); // 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; + color = vec4(mix(target, irgb, saturation), pixColor.a); } + // Dimming + gl_FragColor = mix(color, dim_color, dim) * alpha; if (!has_titlebar || gl_FragCoord.y - position.y > radius) { vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy); diff --git a/sway/desktop/shaders/tex_rgbx.frag b/sway/desktop/shaders/tex_rgbx.frag index b31c1bfd..283963f2 100644 --- a/sway/desktop/shaders/tex_rgbx.frag +++ b/sway/desktop/shaders/tex_rgbx.frag @@ -2,6 +2,8 @@ precision mediump float; varying vec2 v_texcoord; uniform sampler2D tex; uniform float alpha; +uniform float dim; +uniform vec4 dim_color; uniform vec2 size; uniform vec2 position; @@ -11,14 +13,15 @@ uniform float saturation; const vec3 saturation_weight = vec3(0.2125, 0.7154, 0.0721); void main() { + vec4 color = vec4(texture2D(tex, v_texcoord).rgb, 1.0); // 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; + color = vec4(mix(target, irgb, saturation), 1.0); } + // Dimming + gl_FragColor = mix(color, dim_color, dim) * alpha; if (!has_titlebar || gl_FragCoord.y - position.y > radius) { vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy); |