summaryrefslogtreecommitdiff
path: root/sway/desktop/fx_renderer/shaders/tex.frag
diff options
context:
space:
mode:
authorReza Jelveh <[email protected]>2024-04-15 13:39:41 +0800
committerGitHub <[email protected]>2024-04-15 01:39:41 -0400
commitfb86ed6b0588dfdebfb66ce875bc63cfa0a897f6 (patch)
tree29857a1769107adc58696f08d379f608aa4e29a2 /sway/desktop/fx_renderer/shaders/tex.frag
parenta5e79676c4bd22fc5902182acf0667907202a465 (diff)
feat: 1.9 merge (#277)
Co-authored-by: William McKinnon <[email protected]> Co-authored-by: Erik Reider <[email protected]>
Diffstat (limited to 'sway/desktop/fx_renderer/shaders/tex.frag')
-rw-r--r--sway/desktop/fx_renderer/shaders/tex.frag67
1 files changed, 0 insertions, 67 deletions
diff --git a/sway/desktop/fx_renderer/shaders/tex.frag b/sway/desktop/fx_renderer/shaders/tex.frag
deleted file mode 100644
index 77501887..00000000
--- a/sway/desktop/fx_renderer/shaders/tex.frag
+++ /dev/null
@@ -1,67 +0,0 @@
-#define SOURCE_TEXTURE_RGBA 1
-#define SOURCE_TEXTURE_RGBX 2
-#define SOURCE_TEXTURE_EXTERNAL 3
-
-#if !defined(SOURCE)
-#error "Missing shader preamble"
-#endif
-
-#if SOURCE == SOURCE_TEXTURE_EXTERNAL
-#extension GL_OES_EGL_image_external : require
-#endif
-
-precision mediump float;
-
-varying vec2 v_texcoord;
-
-#if SOURCE == SOURCE_TEXTURE_EXTERNAL
-uniform samplerExternalOES tex;
-#elif SOURCE == SOURCE_TEXTURE_RGBA || SOURCE == SOURCE_TEXTURE_RGBX
-uniform sampler2D tex;
-#endif
-
-uniform float alpha;
-uniform float dim;
-uniform vec4 dim_color;
-uniform vec2 size;
-uniform vec2 position;
-uniform float radius;
-uniform float saturation;
-uniform bool has_titlebar;
-uniform bool discard_transparent;
-
-const vec3 saturation_weight = vec3(0.2125, 0.7154, 0.0721);
-
-vec4 sample_texture() {
-#if SOURCE == SOURCE_TEXTURE_RGBA || SOURCE == SOURCE_TEXTURE_EXTERNAL
- return texture2D(tex, v_texcoord);
-#elif SOURCE == SOURCE_TEXTURE_RGBX
- return vec4(texture2D(tex, v_texcoord).rgb, 1.0);
-#endif
-}
-
-void main() {
- vec4 color = sample_texture();
- // Saturation
- if (saturation != 1.0) {
- vec4 pixColor = texture2D(tex, v_texcoord);
- vec3 irgb = pixColor.rgb;
- vec3 target = vec3(dot(irgb, saturation_weight));
- 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);
- if (max(corner_distance.x, corner_distance.y) < radius) {
- float d = radius - distance(corner_distance, vec2(radius));
- float smooth = smoothstep(-1.0, 0.5, d);
- gl_FragColor = mix(vec4(0), gl_FragColor, smooth);
- }
- }
-
- if (discard_transparent && gl_FragColor.a == 0.0) {
- discard;
- }
-}