summaryrefslogtreecommitdiff
path: root/raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/effects/derivative.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/effects/derivative.glsl')
-rw-r--r--raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/effects/derivative.glsl57
1 files changed, 31 insertions, 26 deletions
diff --git a/raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/effects/derivative.glsl b/raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/effects/derivative.glsl
index 64c1682..b497b69 100644
--- a/raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/effects/derivative.glsl
+++ b/raveos-gnome-theme/theme-data/extensions/installed/blur-my-shell@aunetx/effects/derivative.glsl
@@ -2,21 +2,22 @@ uniform sampler2D tex;
uniform int operation;
uniform float width;
uniform float height;
+uniform float opacity_factor;
#define CORRECTION 2.25
-#define SIZE_ADDITION 3
+#define SIZE_ADDITION 3.0
vec4 get_texture_at_position(vec2 position) {
vec2 raw_position = position + vec2(CORRECTION, CORRECTION);
- vec2 raw_uv = raw_position / vec2(width + SIZE_ADDITION, height + SIZE_ADDITION);
+ vec2 raw_uv = raw_position / vec2(max(1.0, width + SIZE_ADDITION), max(1.0, height + SIZE_ADDITION));
return texture2D(tex, raw_uv);
}
vec4 try_get_texture_at_position(vec2 position, inout int count) {
if (any(greaterThanEqual(position, vec2(width, height))) ||
- any(lessThan(position, vec2(0, 0)))) {
- return vec4(0);
+ any(lessThan(position, vec2(0.0, 0.0)))) {
+ return vec4(0.0);
} else {
count++;
return get_texture_at_position(position);
@@ -31,41 +32,45 @@ ivec2 get_corrected_position() {
void main() {
ivec2 corrected_position = get_corrected_position();
+ vec4 source_color = get_texture_at_position(vec2(corrected_position));
+ vec4 effect_color = source_color;
// 1-step derivative
if (operation == 0) {
- vec4 color = vec4(0);
+ vec4 color = vec4(0.0);
int c = 0;
- color += try_get_texture_at_position(corrected_position + vec2(0, 1), c);
- color -= try_get_texture_at_position(corrected_position + vec2(0, 0), c);
- color += try_get_texture_at_position(corrected_position + vec2(1, 0), c);
- color -= try_get_texture_at_position(corrected_position + vec2(0, 0), c);
+ color += try_get_texture_at_position(vec2(corrected_position) + vec2(0.0, 1.0), c);
+ color -= try_get_texture_at_position(vec2(corrected_position) + vec2(0.0, 0.0), c);
+ color += try_get_texture_at_position(vec2(corrected_position) + vec2(1.0, 0.0), c);
+ color -= try_get_texture_at_position(vec2(corrected_position) + vec2(0.0, 0.0), c);
if (c < 4) {
- color = vec4(0);
+ color = vec4(0.0);
}
- cogl_color_out = vec4(color.xyz, 1);
+ effect_color = vec4(color.xyz, source_color.a);
} else
// 2-step derivative
if (operation == 1) {
- vec4 color = vec4(0);
+ vec4 color = vec4(0.0);
int c = 0;
- color += try_get_texture_at_position(corrected_position + vec2(0, 1), c);
- color -= try_get_texture_at_position(corrected_position + vec2(0, -1), c);
- color += try_get_texture_at_position(corrected_position + vec2(1, 0), c);
- color -= try_get_texture_at_position(corrected_position + vec2(-1, 0), c);
+ color += try_get_texture_at_position(vec2(corrected_position) + vec2(0.0, 1.0), c);
+ color -= try_get_texture_at_position(vec2(corrected_position) + vec2(0.0, -1.0), c);
+ color += try_get_texture_at_position(vec2(corrected_position) + vec2(1.0, 0.0), c);
+ color -= try_get_texture_at_position(vec2(corrected_position) + vec2(-1.0, 0.0), c);
if (c < 4) {
- color = vec4(0);
+ color = vec4(0.0);
}
- cogl_color_out = vec4(color.xyz / 2, 1);
+ effect_color = vec4(color.xyz / 2.0, source_color.a);
} else
// laplacian
if (operation == 2) {
- vec4 color = vec4(0);
- color = -4 * get_texture_at_position(corrected_position);
- color += get_texture_at_position(corrected_position + vec2(0, 1));
- color += get_texture_at_position(corrected_position + vec2(0, -1));
- color += get_texture_at_position(corrected_position + vec2(1, 0));
- color += get_texture_at_position(corrected_position + vec2(-1, 0));
- cogl_color_out = vec4(color.xyz, 1);
+ vec4 color = vec4(0.0);
+ color = -4.0 * get_texture_at_position(vec2(corrected_position));
+ color += get_texture_at_position(vec2(corrected_position) + vec2(0.0, 1.0));
+ color += get_texture_at_position(vec2(corrected_position) + vec2(0.0, -1.0));
+ color += get_texture_at_position(vec2(corrected_position) + vec2(1.0, 0.0));
+ color += get_texture_at_position(vec2(corrected_position) + vec2(-1.0, 0.0));
+ effect_color = vec4(color.xyz, source_color.a);
}
-} \ No newline at end of file
+
+ cogl_color_out = mix(source_color, effect_color, opacity_factor);
+}