From c92f3b5574197a3a904c729263ae2f751ff15d80 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 27 May 2022 20:16:09 +0200
Subject: [PATCH 01/71] :tada: Add some initial kwin files
---
kwin/README.md | 0
kwin/build.sh | 42 +++++
kwin/kwin4_effect_tv/contents/config/main.xml | 15 ++
kwin/kwin4_effect_tv/contents/ui/config.ui | 80 ++++++++
kwin/main.js.in | 172 ++++++++++++++++++
kwin/metadata.desktop.in | 21 +++
6 files changed, 330 insertions(+)
create mode 100644 kwin/README.md
create mode 100755 kwin/build.sh
create mode 100755 kwin/kwin4_effect_tv/contents/config/main.xml
create mode 100755 kwin/kwin4_effect_tv/contents/ui/config.ui
create mode 100755 kwin/main.js.in
create mode 100755 kwin/metadata.desktop.in
diff --git a/kwin/README.md b/kwin/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/kwin/build.sh b/kwin/build.sh
new file mode 100755
index 0000000..15c0fde
--- /dev/null
+++ b/kwin/build.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------------------- #
+# ) ( #
+# ( /( ( ( ) ( ( ( ( )\ ) ( ( #
+# )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( #
+# ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ #
+# | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) #
+# | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< #
+# |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ #
+# |__/ #
+# Copyright (c) 2021 Simon Schneegans #
+# Released under the GPLv3 or later. See LICENSE file for details. #
+# -------------------------------------------------------------------------------------- #
+
+# Exit the script when one command fails.
+set -e
+
+# Go to the script's directory.
+cd "$( cd "$( dirname "$0" )" && pwd )" || \
+ { echo "ERROR: Could not find kwin directory."; exit 1; }
+
+BUILD_DIR="_build"
+
+mkdir -p "${BUILD_DIR}"
+
+generate() {
+ cp -r "kwin4_effect_$1" "${BUILD_DIR}"
+
+ mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/shaders"
+ mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/code"
+
+ sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
+ metadata.desktop.in > "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
+
+ sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
+ main.js.in > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
+
+}
+
+generate "tv" "TV" "Make windows close like turning off a TV"
+# generate "fire" "Fire" "Make windows burn"
\ No newline at end of file
diff --git a/kwin/kwin4_effect_tv/contents/config/main.xml b/kwin/kwin4_effect_tv/contents/config/main.xml
new file mode 100755
index 0000000..c0f6524
--- /dev/null
+++ b/kwin/kwin4_effect_tv/contents/config/main.xml
@@ -0,0 +1,15 @@
+
+
Date: Fri, 27 May 2022 20:16:24 +0200
Subject: [PATCH 02/71] :wrench: Ignore kwin build directory
---
.gitignore | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 11da693..6f382cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@
/locale
/schemas/gschemas.compiled
/resources/burn-my-windows.gresource
-/resources/burn-my-windows.gresource.xml
\ No newline at end of file
+/resources/burn-my-windows.gresource.xml
+kwin/_build
\ No newline at end of file
From 18c46f58c253a2debb39ab7828d3c138bb1cc07f Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 27 May 2022 21:06:44 +0200
Subject: [PATCH 03/71] :memo: Add some comments
---
kwin/build.sh | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 15c0fde..92e861c 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -24,9 +24,13 @@ BUILD_DIR="_build"
mkdir -p "${BUILD_DIR}"
+# $1: The nick of the effect (e.g. "tv")
+# $2: The name of the effect (e.g. "TV Effect")
+# $3: A short description of the effect
generate() {
cp -r "kwin4_effect_$1" "${BUILD_DIR}"
+ # Create resource directories.
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/shaders"
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/code"
@@ -36,7 +40,9 @@ generate() {
sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
main.js.in > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
+ SHADER="${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1.glsl"
+ cp "../resources/shaders/$1.glsl" $SHADER
}
-generate "tv" "TV" "Make windows close like turning off a TV"
+generate "tv" "TV Effect" "Make windows close like turning off a TV"
# generate "fire" "Fire" "Make windows burn"
\ No newline at end of file
From c635336a7e331f2e99068781afbf22b00948a4c7 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 28 May 2022 05:52:25 +0200
Subject: [PATCH 04/71] :wrench: Append common.glsl to kwin shaders
---
kwin/build.sh | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 92e861c..4f1926b 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -40,8 +40,14 @@ generate() {
sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
main.js.in > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
- SHADER="${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1.glsl"
- cp "../resources/shaders/$1.glsl" $SHADER
+ SHADER="${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1.frag"
+ echo "#version 140" > $SHADER
+ echo "#define KWIN" >> $SHADER
+ echo "" >> $SHADER
+ echo "// This file is automatically generated during the build process." >> $SHADER
+ echo "" >> $SHADER
+ cat "../resources/shaders/common.glsl" >> $SHADER
+ cat "../resources/shaders/$1.frag" >> $SHADER
}
generate "tv" "TV Effect" "Make windows close like turning off a TV"
From 74bd7cdef85fe8a2f01d00c43fc625b0baf44f97 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 28 May 2022 05:56:04 +0200
Subject: [PATCH 05/71] :wrench: Use generic i/o names
---
docs/how-to-create-new-effects.md | 14 +++++-----
resources/shaders/apparition.frag | 10 +++----
resources/shaders/broken-glass.frag | 10 +++----
resources/shaders/common.glsl | 28 +++++++++++++++++--
resources/shaders/energize-a.frag | 22 +++++++--------
resources/shaders/energize-b.frag | 42 ++++++++++++++---------------
resources/shaders/fire.frag | 20 +++++++-------
resources/shaders/hexagon.frag | 24 ++++++++---------
resources/shaders/matrix.frag | 28 +++++++++----------
resources/shaders/snap.frag | 14 +++++-----
resources/shaders/trex.frag | 24 ++++++++---------
resources/shaders/tv.frag | 21 +++++++--------
resources/shaders/wisps.frag | 22 +++++++--------
13 files changed, 152 insertions(+), 127 deletions(-)
diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md
index 28e1a50..9bc7544 100644
--- a/docs/how-to-create-new-effects.md
+++ b/docs/how-to-create-new-effects.md
@@ -86,7 +86,9 @@ Please study this code carefully, all of it is explained with inline comments.
```glsl
// The content from common.glsl is automatically prepended to each shader effect. This
-// provides some standard uniforms which will be updated during the animation.
+// provides the standard input "vec2 iTexCoord", the standard output "vec4 oColor" as well
+// as some standard uniforms which will be updated during the animation:
+
// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
// sampler2D uTexture: Contains the texture of the window.
// float uProgress: A value which transitions from 0 to 1 during the entire animation.
@@ -99,15 +101,15 @@ uniform float uFadeWidth;
void main() {
// Get the color from the window texture.
- cogl_color_out = texture2D(uTexture, cogl_tex_coord_in[0].st);
+ oColor = texture2D(uTexture, iTexCoord.st);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (cogl_color_out.a > 0) {
- cogl_color_out.rgb /= cogl_color_out.a;
+ if (oColor.a > 0) {
+ oColor.rgb /= oColor.a;
}
// Radial distance from window edge to the window's center.
- float dist = length(cogl_tex_coord_in[0].st - 0.5) * 2.0 / sqrt(2.0);
+ float dist = length(iTexCoord.st - 0.5) * 2.0 / sqrt(2.0);
// This gradually dissolves from [1..0] from the outside to the center. We
// switch the direction for opening and closing.
@@ -118,7 +120,7 @@ void main() {
mask = smoothstep(0, 1, mask);
// Apply the mask to the output.
- cogl_color_out.a *= mask;
+ oColor.a *= mask;
}
```
diff --git a/resources/shaders/apparition.frag b/resources/shaders/apparition.frag
index 0134c04..7e4372a 100644
--- a/resources/shaders/apparition.frag
+++ b/resources/shaders/apparition.frag
@@ -30,7 +30,7 @@ void main() {
// Choose a random suction center.
vec2 center = uSeed * uRandomness + 0.5 * (1.0 - uRandomness);
- vec2 coords = cogl_tex_coord_in[0].st * ACTOR_SCALE - PADDING - center;
+ vec2 coords = iTexCoord.st * ACTOR_SCALE - PADDING - center;
// Add some shaking.
coords.x +=
@@ -49,11 +49,11 @@ void main() {
coords = vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- cogl_color_out = texture2D(uTexture, coords + center);
- if (cogl_color_out.a > 0) {
- cogl_color_out.rgb /= cogl_color_out.a;
+ oColor = texture2D(uTexture, coords + center);
+ if (oColor.a > 0) {
+ oColor.rgb /= oColor.a;
}
// Fade out the window texture.
- cogl_color_out.a *= 1.0 - progress;
+ oColor.a *= 1.0 - progress;
}
\ No newline at end of file
diff --git a/resources/shaders/broken-glass.frag b/resources/shaders/broken-glass.frag
index b8326ca..fd1a508 100644
--- a/resources/shaders/broken-glass.frag
+++ b/resources/shaders/broken-glass.frag
@@ -25,7 +25,7 @@ const float ACTOR_SCALE = 2.0;
const float PADDING = ACTOR_SCALE / 2.0 - 0.5;
void main() {
- cogl_color_out = vec4(0, 0, 0, 0);
+ oColor = vec4(0, 0, 0, 0);
float progress = uForOpening ? 1.0 - uProgress : uProgress;
@@ -35,7 +35,7 @@ void main() {
// To enable drawing shards outside of the window bounds, the actor was scaled
// by ACTOR_SCALE. Here we scale and move the texture coordinates so that the
// window gets drawn at the correct position again.
- vec2 coords = cogl_tex_coord_in[0].st * ACTOR_SCALE - PADDING;
+ vec2 coords = iTexCoord.st * ACTOR_SCALE - PADDING;
// Scale and rotate around our epicenter.
coords -= uEpicenter;
@@ -66,12 +66,12 @@ void main() {
float shardGroup = floor(shardMap.g * SHARD_LAYERS * 0.999);
if (shardGroup == i && (shardMap.x - pow(progress + 0.1, 2)) > 0) {
- cogl_color_out = texture2D(uTexture, coords);
+ oColor = texture2D(uTexture, coords);
}
}
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (cogl_color_out.a > 0) {
- cogl_color_out.rgb /= cogl_color_out.a;
+ if (oColor.a > 0) {
+ oColor.rgb /= oColor.a;
}
}
\ No newline at end of file
diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl
index e8356fb..46e6d5c 100644
--- a/resources/shaders/common.glsl
+++ b/resources/shaders/common.glsl
@@ -23,6 +23,25 @@
// uTime: A steadily increasing value in seconds.
// uSize: The size of uTexture in pixels.
// uPadding: The empty area around the actual window (e.g. where the shadow is drawn).
+
+#ifdef KWIN
+
+uniform bool uForOpening;
+uniform sampler2D uTexture;
+uniform float animationProgress;
+// uniform float uTime;
+// uniform vec2 uSize;
+// uniform float uPadding;
+
+in vec2 texcoord0;
+out vec4 fragColor;
+
+#define uProgress animationProgress
+#define iTexCoord texcoord0
+#define oColor fragColor
+
+#else
+
uniform bool uForOpening;
uniform sampler2D uTexture;
uniform float uProgress;
@@ -30,6 +49,11 @@ uniform float uTime;
uniform vec2 uSize;
uniform float uPadding;
+#define iTexCoord cogl_tex_coord_in[0]
+#define oColor cogl_color_out
+
+#endif
+
// ----------------------------------------------------------------- compositing operators
// The Shell.GLSLEffect uses straight alpha blending. This helper method allows
@@ -71,7 +95,7 @@ float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {
// (offset = 1).
float getAbsoluteEdgeMask(float fadePixels, float offset) {
float padding = max(0, uPadding - fadePixels * offset);
- vec2 uv = cogl_tex_coord_in[0].st * uSize - padding;
+ vec2 uv = iTexCoord.st * uSize - padding;
return getEdgeMask(uv, uSize - 2.0 * padding, fadePixels);
}
@@ -79,7 +103,7 @@ float getAbsoluteEdgeMask(float fadePixels, float offset) {
// the fade zone is given relative to the actor size. This neither uses uSize and
// uPadding.
float getRelativeEdgeMask(float fadeAmount) {
- vec2 uv = cogl_tex_coord_in[0].st;
+ vec2 uv = iTexCoord.st;
return getEdgeMask(uv, vec2(1.0), fadeAmount);
}
diff --git a/resources/shaders/energize-a.frag b/resources/shaders/energize-a.frag
index 77ab3fb..a1d1264 100644
--- a/resources/shaders/energize-a.frag
+++ b/resources/shaders/energize-a.frag
@@ -31,7 +31,7 @@ vec2 getMasks(float progress) {
clamp((progress - (1.0 - HEART_FADE_TIME)) / HEART_FADE_TIME, 0, 1);
// Compute mask for the "atom" particles.
- float dist = length(cogl_tex_coord_in[0].st - 0.5) * 4.0;
+ float dist = length(iTexCoord.st - 0.5) * 4.0;
float atomMask = smoothstep(0.0, 1.0, (fadeInProgress * 2.0 - dist + 1.0));
atomMask *= fadeInProgress;
atomMask *= smoothstep(1.0, 0.0, fadeOutProgress);
@@ -60,7 +60,7 @@ void main() {
float progress = easeOutQuad(uProgress);
vec2 masks = getMasks(progress);
- vec4 windowColor = texture2D(uTexture, cogl_tex_coord_in[0].st);
+ vec4 windowColor = texture2D(uTexture, iTexCoord.st);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (windowColor.a > 0) {
@@ -68,10 +68,10 @@ void main() {
}
// Dissolve window to effect color / transparency.
- cogl_color_out.rgb = mix(uColor, windowColor.rgb, 0.2 * masks.y + 0.8);
- cogl_color_out.a = windowColor.a * masks.y;
+ oColor.rgb = mix(uColor, windowColor.rgb, 0.2 * masks.y + 0.8);
+ oColor.a = windowColor.a * masks.y;
- vec2 scaledUV = (cogl_tex_coord_in[0].st - 0.5) * (1.0 + 0.1 * progress);
+ vec2 scaledUV = (iTexCoord.st - 0.5) * (1.0 + 0.1 * progress);
scaledUV /= uScale;
// Add molecule particles.
@@ -86,12 +86,12 @@ void main() {
particles += 0.5 * pow(0.2 * (1.0 / (1.0 - atoms) - 1.0), 2);
}
- cogl_color_out.rgb += uColor * particles * masks.x;
- cogl_color_out.a += particles * masks.x;
+ oColor.rgb += uColor * particles * masks.x;
+ oColor.a += particles * masks.x;
// These are pretty useful for understanding how this works.
- // cogl_color_out = vec4(masks, 0.0, 1.0);
- // cogl_color_out = vec4(vec3(masks.x), 1.0);
- // cogl_color_out = vec4(vec3(masks.y), 1.0);
- // cogl_color_out = vec4(vec3(particles), 1.0);
+ // oColor = vec4(masks, 0.0, 1.0);
+ // oColor = vec4(vec3(masks.x), 1.0);
+ // oColor = vec4(vec3(masks.y), 1.0);
+ // oColor = vec4(vec3(particles), 1.0);
}
\ No newline at end of file
diff --git a/resources/shaders/energize-b.frag b/resources/shaders/energize-b.frag
index 4ac4faf..68856b9 100644
--- a/resources/shaders/energize-b.frag
+++ b/resources/shaders/energize-b.frag
@@ -32,7 +32,7 @@ vec4 getMasks(float progress) {
float fadeProgress = clamp((progress - SHOWER_TIME) / (1.0 - SHOWER_TIME), 0, 1);
// Gradient from top to bottom.
- float t = cogl_tex_coord_in[0].t;
+ float t = iTexCoord.t;
// A smooth gradient which moves to the bottom within the showerProgress.
float showerMask =
@@ -77,7 +77,7 @@ void main() {
float progress = easeOutQuad(uProgress);
vec4 masks = getMasks(progress);
- vec4 windowColor = texture2D(uTexture, cogl_tex_coord_in[0].st);
+ vec4 windowColor = texture2D(uTexture, iTexCoord.st);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
if (windowColor.a > 0) {
@@ -85,37 +85,37 @@ void main() {
}
// Dissolve window to effect color / transparency.
- cogl_color_out.rgb = mix(uColor, windowColor.rgb, 0.5 * masks.w + 0.5);
- cogl_color_out.a = windowColor.a * masks.w;
+ oColor.rgb = mix(uColor, windowColor.rgb, 0.5 * masks.w + 0.5);
+ oColor.a = windowColor.a * masks.w;
// Add leading shower particles.
- vec2 showerUV = cogl_tex_coord_in[0].st + vec2(0, -0.7 * progress / SHOWER_TIME);
+ vec2 showerUV = iTexCoord.st + vec2(0, -0.7 * progress / SHOWER_TIME);
showerUV *= 0.02 * uSize / uScale;
float shower = pow(simplex2D(showerUV), 10.0);
- cogl_color_out.rgb += uColor * shower * masks.x;
- cogl_color_out.a += shower * masks.x;
+ oColor.rgb += uColor * shower * masks.x;
+ oColor.a += shower * masks.x;
// Add trailing streak lines.
- vec2 streakUV = cogl_tex_coord_in[0].st + vec2(0, -progress / SHOWER_TIME);
+ vec2 streakUV = iTexCoord.st + vec2(0, -progress / SHOWER_TIME);
streakUV *= vec2(0.05 * uSize.x, 0.001 * uSize.y) / uScale;
float streaks = simplex2DFractal(streakUV) * 0.5;
- cogl_color_out.rgb += uColor * streaks * masks.y;
- cogl_color_out.a += streaks * masks.y;
+ oColor.rgb += uColor * streaks * masks.y;
+ oColor.a += streaks * masks.y;
// Add glimmering atoms.
- vec2 atomUV = cogl_tex_coord_in[0].st + vec2(0, -0.025 * progress / SHOWER_TIME);
+ vec2 atomUV = iTexCoord.st + vec2(0, -0.025 * progress / SHOWER_TIME);
atomUV *= 0.2 * uSize / uScale;
float atoms = pow((simplex3D(vec3(atomUV, uTime))), 5.0);
- cogl_color_out.rgb += uColor * atoms * masks.z;
- cogl_color_out.a += atoms * masks.z;
+ oColor.rgb += uColor * atoms * masks.z;
+ oColor.a += atoms * masks.z;
// These are pretty useful for understanding how this works.
- // cogl_color_out = vec4(masks.rgb, 1.0);
- // cogl_color_out = vec4(vec3(masks.x), 1.0);
- // cogl_color_out = vec4(vec3(masks.y), 1.0);
- // cogl_color_out = vec4(vec3(masks.z), 1.0);
- // cogl_color_out = vec4(vec3(masks.w), 1.0);
- // cogl_color_out = vec4(vec3(shower), 1.0);
- // cogl_color_out = vec4(vec3(streaks), 1.0);
- // cogl_color_out = vec4(vec3(atoms), 1.0);
+ // oColor = vec4(masks.rgb, 1.0);
+ // oColor = vec4(vec3(masks.x), 1.0);
+ // oColor = vec4(vec3(masks.y), 1.0);
+ // oColor = vec4(vec3(masks.z), 1.0);
+ // oColor = vec4(vec3(masks.w), 1.0);
+ // oColor = vec4(vec3(shower), 1.0);
+ // oColor = vec4(vec3(streaks), 1.0);
+ // oColor = vec4(vec3(atoms), 1.0);
}
\ No newline at end of file
diff --git a/resources/shaders/fire.frag b/resources/shaders/fire.frag
index b4d5ded..f1cf381 100644
--- a/resources/shaders/fire.frag
+++ b/resources/shaders/fire.frag
@@ -63,7 +63,7 @@ vec2 effectMask(float hideTime, float fadeWidth, float edgeFadeWidth) {
float afterBurnProgress = clamp((progress - hideTime) / (1 - hideTime), 0, 1);
// Gradient from top to bottom.
- float t = cogl_tex_coord_in[0].t * (1 - fadeWidth);
+ float t = iTexCoord.t * (1 - fadeWidth);
// Visible part of the window. Gradually dissolves towards the bottom.
float windowMask = 1 - clamp((burnProgress - t) / fadeWidth, 0, 1);
@@ -89,7 +89,7 @@ vec2 effectMask(float hideTime, float fadeWidth, float edgeFadeWidth) {
void main() {
// Get a noise value which moves vertically in time.
- vec2 uv = cogl_tex_coord_in[0].st * uSize / vec2(400, 600) / uScale;
+ vec2 uv = iTexCoord.st * uSize / vec2(400, 600) / uScale;
uv.y += uTime * uMovementSpeed;
float noise = u3DNoise ? simplex3DFractal(vec3(uv * 4.0, uTime * uMovementSpeed * 1.5))
@@ -103,21 +103,21 @@ void main() {
vec4 fire = getFireColor(noise);
// Get the window texture.
- cogl_color_out = texture2D(uTexture, cogl_tex_coord_in[0].st);
+ oColor = texture2D(uTexture, iTexCoord.st);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (cogl_color_out.a > 0) {
- cogl_color_out.rgb /= cogl_color_out.a;
+ if (oColor.a > 0) {
+ oColor.rgb /= oColor.a;
}
// Fade the window according to the effect mask.
- cogl_color_out.a *= effectMask.x;
+ oColor.a *= effectMask.x;
// Add the fire to the window.
- cogl_color_out = alphaOver(cogl_color_out, fire);
+ oColor = alphaOver(oColor, fire);
// These are pretty useful for understanding how this works.
- // cogl_color_out = vec4(vec3(noise), 1);
- // cogl_color_out = vec4(vec3(effectMask.x), 1);
- // cogl_color_out = vec4(vec3(effectMask.y), 1);
+ // oColor = vec4(vec3(noise), 1);
+ // oColor = vec4(vec3(effectMask.x), 1);
+ // oColor = vec4(vec3(effectMask.y), 1);
}
\ No newline at end of file
diff --git a/resources/shaders/hexagon.frag b/resources/shaders/hexagon.frag
index 752d886..14f8a8a 100644
--- a/resources/shaders/hexagon.frag
+++ b/resources/shaders/hexagon.frag
@@ -68,7 +68,7 @@ void main() {
// Add some smooth noise to the progress so that not every tile behaves the
// same.
- float noise = simplex2D(cogl_tex_coord_in[0].st + uSeed);
+ float noise = simplex2D(iTexCoord.st + uSeed);
progress = clamp(mix(noise - 1.0, noise + 1.0, progress), 0.0, 1.0);
// glowProgress fades in in the first half of the animation, tileProgress fades
@@ -77,23 +77,23 @@ void main() {
float tileProgress = smoothstep(0, 1, clamp((progress - 0.5) / 0.5, 0, 1));
vec2 texScale = 0.1 * uSize / uScale;
- vec4 hex = getHexagons(cogl_tex_coord_in[0].st * texScale);
+ vec4 hex = getHexagons(iTexCoord.st * texScale);
if (tileProgress > hex.z) {
// Crop outer parts of the shrinking tiles.
- cogl_color_out.a = 0.0;
+ oColor.a = 0.0;
} else {
// Make the tiles shrink by offsetting the texture lookup towards the edge
// of the cell.
vec2 lookupOffset = tileProgress * hex.xy / texScale / (1.0 - tileProgress);
- cogl_color_out = texture2D(uTexture, cogl_tex_coord_in[0].st + lookupOffset);
+ oColor = texture2D(uTexture, iTexCoord.st + lookupOffset);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (cogl_color_out.a > 0) {
- cogl_color_out.rgb /= cogl_color_out.a;
+ if (oColor.a > 0) {
+ oColor.rgb /= oColor.a;
}
vec4 glow = uGlowColor;
@@ -111,15 +111,15 @@ void main() {
line.a *= glowProgress;
// Do not add the hexagon lines onto transparent parts of the window.
- glow *= cogl_color_out.a;
- line *= cogl_color_out.a;
+ glow *= oColor.a;
+ line *= oColor.a;
if (uAdditiveBlending) {
- cogl_color_out.rgb += glow.rgb * glow.a;
- cogl_color_out.rgb += line.rgb * line.a;
+ oColor.rgb += glow.rgb * glow.a;
+ oColor.rgb += line.rgb * line.a;
} else {
- cogl_color_out.rgb = mix(cogl_color_out.rgb, glow.rgb, glow.a);
- cogl_color_out.rgb = mix(cogl_color_out.rgb, line.rgb, line.a);
+ oColor.rgb = mix(oColor.rgb, glow.rgb, glow.a);
+ oColor.rgb = mix(oColor.rgb, line.rgb, line.a);
}
}
}
\ No newline at end of file
diff --git a/resources/shaders/matrix.frag b/resources/shaders/matrix.frag
index 3afefb2..ad1db69 100644
--- a/resources/shaders/matrix.frag
+++ b/resources/shaders/matrix.frag
@@ -47,13 +47,13 @@ float getText(vec2 fragCoord) {
// to one below each drop and to zero above it. This second value is used for fading
// the window texture.
vec2 getRain(vec2 fragCoord) {
- float column = cogl_tex_coord_in[0].x * uSize.x;
+ float column = iTexCoord.x * uSize.x;
column -= mod(column, uLetterSize);
float delay = fract(sin(column) * 78.233) * mix(0.0, 1.0, uRandomness);
float speed = fract(cos(column) * 12.989) * mix(0.0, 0.3, uRandomness) + 1.5;
- float distToDrop = (uProgress * 2 - delay) * speed - cogl_tex_coord_in[0].y;
+ float distToDrop = (uProgress * 2 - delay) * speed - iTexCoord.y;
float rainAlpha = distToDrop >= 0 ? exp(-distToDrop / TRAIL_LENGTH) : 0;
float windowAlpha = 1 - clamp(uSize.y * distToDrop, 0, FADE_WIDTH) / FADE_WIDTH;
@@ -64,8 +64,8 @@ vec2 getRain(vec2 fragCoord) {
// Add some variation to the drop start and end position.
float shorten =
fract(sin(column + 42.0) * 33.423) * mix(0.0, uOverShoot * 0.25, uRandomness);
- rainAlpha *= smoothstep(0, 1, clamp(cogl_tex_coord_in[0].y / shorten, 0, 1));
- rainAlpha *= smoothstep(0, 1, clamp((1.0 - cogl_tex_coord_in[0].y) / shorten, 0, 1));
+ rainAlpha *= smoothstep(0, 1, clamp(iTexCoord.y / shorten, 0, 1));
+ rainAlpha *= smoothstep(0, 1, clamp((1.0 - iTexCoord.y) / shorten, 0, 1));
if (uForOpening) {
windowAlpha = 1.0 - windowAlpha;
@@ -75,7 +75,7 @@ vec2 getRain(vec2 fragCoord) {
}
void main() {
- vec2 coords = cogl_tex_coord_in[0].st;
+ vec2 coords = iTexCoord.st;
coords.y = coords.y * (uOverShoot + 1.0) - uOverShoot * 0.5;
// Get a cool matrix effect. See comments for those methods above.
@@ -83,15 +83,15 @@ void main() {
float textMask = getText(coords);
// Get the window texture.
- cogl_color_out = texture2D(uTexture, coords);
+ oColor = texture2D(uTexture, coords);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (cogl_color_out.a > 0) {
- cogl_color_out.rgb /= cogl_color_out.a;
+ if (oColor.a > 0) {
+ oColor.rgb /= oColor.a;
}
// Fade the window according to the effect mask.
- cogl_color_out.a *= rainMask.y;
+ oColor.a *= rainMask.y;
// This is used to fade out the remaining trails in the end.
float finalFade =
@@ -99,12 +99,12 @@ void main() {
float rainAlpha = finalFade * rainMask.x;
// Add the matrix effect to the window.
- vec4 text = vec4(mix(uTrailColor, uTipColor, min(1, pow(rainAlpha + 0.1, 4))),
+ vec4 text = vec4(mix(uTrailColor, uTipColor, min(1, pow(rainAlpha + 0.1, 4))),
rainAlpha * textMask);
- cogl_color_out = alphaOver(cogl_color_out, text);
+ oColor = alphaOver(oColor, text);
// These are pretty useful for understanding how this works.
- // cogl_color_out = vec4(vec3(textMask), 1);
- // cogl_color_out = vec4(vec3(rainMask.x), 1);
- // cogl_color_out = vec4(vec3(rainMask.y), 1);
+ // oColor = vec4(vec3(textMask), 1);
+ // oColor = vec4(vec3(rainMask.x), 1);
+ // oColor = vec4(vec3(rainMask.y), 1);
}
\ No newline at end of file
diff --git a/resources/shaders/snap.frag b/resources/shaders/snap.frag
index 2432cb0..952b95a 100644
--- a/resources/shaders/snap.frag
+++ b/resources/shaders/snap.frag
@@ -29,16 +29,16 @@ void main() {
// We simply inverse the progress for opening windows.
float progress = uForOpening ? uProgress : 1.0 - uProgress;
- float gradient = cogl_tex_coord_in[0].t * ACTOR_SCALE - PADDING;
+ float gradient = iTexCoord.t * ACTOR_SCALE - PADDING;
progress = 2.0 - gradient - 2.0 * progress;
- progress = progress + 0.25 - 0.5 * simplex2D((cogl_tex_coord_in[0].st + uSeed) * 2.0);
- progress = pow(max(0, progress), 2.0);
+ progress = progress + 0.25 - 0.5 * simplex2D((iTexCoord.st + uSeed) * 2.0);
+ progress = pow(max(0, progress), 2.0);
// This may help you to understand how this effect works.
- // cogl_color_out = vec4(progress, 0, 0, 0);
+ // oColor = vec4(progress, 0, 0, 0);
// return;
- cogl_color_out = vec4(0, 0, 0, 0);
+ oColor = vec4(0, 0, 0, 0);
for (float i = 0; i < DUST_LAYERS; ++i) {
@@ -49,7 +49,7 @@ void main() {
direction = rotate(direction, angle);
// Flip direction for one side of the window.
- vec2 coords = cogl_tex_coord_in[0].st * ACTOR_SCALE - PADDING - 0.5;
+ vec2 coords = iTexCoord.st * ACTOR_SCALE - PADDING - 0.5;
if (getWinding(direction, coords) > 0) {
direction *= -1;
}
@@ -93,7 +93,7 @@ void main() {
// Dissolve and blend the layers.
if (dustMap.x - progress > 0) {
- cogl_color_out = windowColor;
+ oColor = windowColor;
}
}
}
diff --git a/resources/shaders/trex.frag b/resources/shaders/trex.frag
index 20dbb3b..a59b699 100644
--- a/resources/shaders/trex.frag
+++ b/resources/shaders/trex.frag
@@ -68,10 +68,10 @@ void main() {
float progress = uForOpening ? 1.0 - easeOutQuad(uProgress) : easeOutQuad(uProgress);
// Warp the texture coordinates to create a blow-up effect.
- vec2 coords = cogl_tex_coord_in[0].st * 2.0 - 1.0;
+ vec2 coords = iTexCoord.st * 2.0 - 1.0;
float dist = length(coords);
coords = (coords / dist * pow(dist, 1.0 + uWarpIntensity)) * 0.5 + 0.5;
- coords = mix(cogl_tex_coord_in[0].st, coords, progress);
+ coords = mix(iTexCoord.st, coords, progress);
// Scale down the window according to the warp.
float scale = 0.5 * uWarpIntensity * (1.0 - progress);
@@ -89,12 +89,12 @@ void main() {
// Get the window texture. We shift the texture lookup by the local derivative of
// the claw texture in order to mimic some folding distortion.
- vec2 offset = vec2(dFdx(scratchMap), dFdy(scratchMap)) * progress * 0.5;
- cogl_color_out = texture2D(uTexture, coords + offset);
+ vec2 offset = vec2(dFdx(scratchMap), dFdy(scratchMap)) * progress * 0.5;
+ oColor = texture2D(uTexture, coords + offset);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (cogl_color_out.a > 0) {
- cogl_color_out.rgb /= cogl_color_out.a;
+ if (oColor.a > 0) {
+ oColor.rgb /= oColor.a;
}
// Add colorful flashes.
@@ -105,19 +105,19 @@ void main() {
// Hide flashes where there is now window.
vec4 flash = uFlashColor;
- flash.a *= flashIntensity * cogl_color_out.a * (1.0 - progress);
+ flash.a *= flashIntensity * oColor.a * (1.0 - progress);
// Hide scratched out parts.
- cogl_color_out.a *= (scratchMap > progress ? 1 : 0);
+ oColor.a *= (scratchMap > progress ? 1 : 0);
// Add flash color.
- cogl_color_out = alphaOver(cogl_color_out, flash);
+ oColor = alphaOver(oColor, flash);
// Fade out the remaining shards.
float fadeProgress = smoothstep(0, 1, (progress - 1.0 + FF_TIME) / FF_TIME);
- cogl_color_out.a *= sqrt(1 - fadeProgress * fadeProgress);
+ oColor.a *= sqrt(1 - fadeProgress * fadeProgress);
// These are pretty useful for understanding how this works.
- // cogl_color_out = vec4(vec3(flashIntensity), 1);
- // cogl_color_out = vec4(vec3(scratchMap), 1);
+ // oColor = vec4(vec3(flashIntensity), 1);
+ // oColor = vec4(vec3(scratchMap), 1);
}
\ No newline at end of file
diff --git a/resources/shaders/tv.frag b/resources/shaders/tv.frag
index df54666..2d84dde 100644
--- a/resources/shaders/tv.frag
+++ b/resources/shaders/tv.frag
@@ -27,7 +27,7 @@ void main() {
// Scale down the window vertically.
float scale = 1.0 / mix(1.0, SCALING, progress) - 1.0;
- vec2 coords = cogl_tex_coord_in[0].st;
+ vec2 coords = iTexCoord.st;
coords.y = coords.y * (scale + 1.0) - scale * 0.5;
// All of these are in [0..1] during the different stages of the animation.
@@ -54,20 +54,19 @@ void main() {
// Assemble the final alpha value.
float mask = tbMask * lrMask * ffMask;
- cogl_color_out = texture2D(uTexture, coords);
+ oColor = texture2D(uTexture, coords);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (cogl_color_out.a > 0) {
- cogl_color_out.rgb /= cogl_color_out.a;
+ if (oColor.a > 0) {
+ oColor.rgb /= oColor.a;
}
- cogl_color_out.rgb =
- mix(cogl_color_out.rgb, uColor * cogl_color_out.a, smoothstep(0, 1, progress));
- cogl_color_out.a *= mask;
+ oColor.rgb = mix(oColor.rgb, uColor * oColor.a, smoothstep(0, 1, progress));
+ oColor.a *= mask;
// These are pretty useful for understanding how this works.
- // cogl_color_out = vec4(vec3(tbMask), 1);
- // cogl_color_out = vec4(vec3(lrMask), 1);
- // cogl_color_out = vec4(vec3(ffMask), 1);
- // cogl_color_out = vec4(vec3(mask), 1);
+ // oColor = vec4(vec3(tbMask), 1);
+ // oColor = vec4(vec3(lrMask), 1);
+ // oColor = vec4(vec3(ffMask), 1);
+ // oColor = vec4(vec3(mask), 1);
}
\ No newline at end of file
diff --git a/resources/shaders/wisps.frag b/resources/shaders/wisps.frag
index a19617f..de7e6e6 100644
--- a/resources/shaders/wisps.frag
+++ b/resources/shaders/wisps.frag
@@ -68,18 +68,18 @@ void main() {
// Scale down the window slightly.
float scale = 1.0 / mix(1.0, SCALING, progress) - 1.0;
- vec2 coords = cogl_tex_coord_in[0].st * (scale + 1.0) - scale * 0.5;
+ vec2 coords = iTexCoord.st * (scale + 1.0) - scale * 0.5;
// Get the color of the window.
- cogl_color_out = texture2D(uTexture, coords);
+ oColor = texture2D(uTexture, coords);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (cogl_color_out.a > 0) {
- cogl_color_out.rgb /= cogl_color_out.a;
+ if (oColor.a > 0) {
+ oColor.rgb /= oColor.a;
}
// Compute several layers of moving wisps.
- vec2 uv = (cogl_tex_coord_in[0].st - 0.5) / mix(1.0, 0.5, progress) + 0.5;
+ vec2 uv = (iTexCoord.st - 0.5) / mix(1.0, 0.5, progress) + 0.5;
uv /= uScale;
float wisps = 0;
for (int i = 0; i < WISPS_LAYERS; ++i) {
@@ -99,15 +99,15 @@ void main() {
float noise = smoothstep(1.0, 0.0, abs(2.0 * simplex2DFractal(uv * uSize / 250) - 1.0));
float windowMask = 1.0 - (windowOut < 0.5 ? mix(0.0, noise, windowOut * 2.0)
: mix(noise, 1.0, windowOut * 2.0 - 1.0));
- cogl_color_out.a *= windowMask * mask;
+ oColor.a *= windowMask * mask;
// Add the wisps.
vec4 wispColor = wisps * vec4(uColor, min(wispsIn, 1.0 - wispsOut) * mask);
- cogl_color_out = alphaOver(cogl_color_out, wispColor);
+ oColor = alphaOver(oColor, wispColor);
// These are pretty useful for understanding how this works.
- // cogl_color_out = vec4(vec3(windowMask), 1.0);
- // cogl_color_out = vec4(vec3(wisps), 1.0);
- // cogl_color_out = vec4(vec3(noise), 1.0);
- // cogl_color_out = vec4(vec3(mask*min(wispsIn, 1.0 - wispsOut)), 1.0);
+ // oColor = vec4(vec3(windowMask), 1.0);
+ // oColor = vec4(vec3(wisps), 1.0);
+ // oColor = vec4(vec3(noise), 1.0);
+ // oColor = vec4(vec3(mask*min(wispsIn, 1.0 - wispsOut)), 1.0);
}
\ No newline at end of file
From bf0feae117b3811d447e5136ffdc2fa3b4b6bd60 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 28 May 2022 05:57:41 +0200
Subject: [PATCH 06/71] :wrench: Make ShellCheck happy
---
kwin/build.sh | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 4f1926b..14fce0b 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -41,13 +41,13 @@ generate() {
main.js.in > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
SHADER="${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1.frag"
- echo "#version 140" > $SHADER
- echo "#define KWIN" >> $SHADER
- echo "" >> $SHADER
- echo "// This file is automatically generated during the build process." >> $SHADER
- echo "" >> $SHADER
- cat "../resources/shaders/common.glsl" >> $SHADER
- cat "../resources/shaders/$1.frag" >> $SHADER
+ echo "#version 140" > "$SHADER"
+ echo "#define KWIN" >> "$SHADER"
+ echo "" >> "$SHADER"
+ echo "// This file is automatically generated during the build process." >> "$SHADER"
+ echo "" >> "$SHADER"
+ cat "../resources/shaders/common.glsl" >> "$SHADER"
+ cat "../resources/shaders/$1.frag" >> "$SHADER"
}
generate "tv" "TV Effect" "Make windows close like turning off a TV"
From 9a68af1676072a68dada48868002a71017bdce5f Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sat, 28 May 2022 06:01:01 +0200
Subject: [PATCH 07/71] :wrench: Make ShellCheck happy
---
kwin/build.sh | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 14fce0b..190c0dd 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -40,14 +40,15 @@ generate() {
sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
main.js.in > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
- SHADER="${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1.frag"
- echo "#version 140" > "$SHADER"
- echo "#define KWIN" >> "$SHADER"
- echo "" >> "$SHADER"
- echo "// This file is automatically generated during the build process." >> "$SHADER"
- echo "" >> "$SHADER"
- cat "../resources/shaders/common.glsl" >> "$SHADER"
- cat "../resources/shaders/$1.frag" >> "$SHADER"
+ {
+ echo "#version 140"
+ echo "#define KWIN"
+ echo ""
+ echo "// This file is automatically generated during the build process."
+ echo ""
+ cat "../resources/shaders/common.glsl"
+ cat "../resources/shaders/$1.frag"
+ } > "${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1.frag"
}
generate "tv" "TV Effect" "Make windows close like turning off a TV"
From e96b42a3f7e88b64cd3a303fdc2a068260a5598a Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 9 Jun 2022 07:47:12 +0200
Subject: [PATCH 08/71] :wrench: Support different profiles for kwin
---
kwin/build.sh | 10 ++++++
kwin/main.js.in | 11 +++----
kwin/metadata.desktop.in | 2 +-
resources/shaders/common.glsl | 58 ++++++++++++++++++++++++++---------
4 files changed, 60 insertions(+), 21 deletions(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 190c0dd..95550c2 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -48,6 +48,16 @@ generate() {
echo ""
cat "../resources/shaders/common.glsl"
cat "../resources/shaders/$1.frag"
+ } > "${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1_core.frag"
+
+ {
+ echo "#version 100"
+ echo "#define KWIN_LEGACY"
+ echo ""
+ echo "// This file is automatically generated during the build process."
+ echo ""
+ cat "../resources/shaders/common.glsl"
+ cat "../resources/shaders/$1.frag"
} > "${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1.frag"
}
diff --git a/kwin/main.js.in b/kwin/main.js.in
index a0d96c6..426def2 100755
--- a/kwin/main.js.in
+++ b/kwin/main.js.in
@@ -1,8 +1,7 @@
/*
- KWin - the KDE window manager
- This file is part of the KDE project.
+ This file is part of the Burn-My-Windows project.
- SPDX-FileCopyrightText: 2018, 2021, 2022 Vlad Zahorodnii
SPDX-License-Identifier: GPL-3.0-or-later
*/
@@ -26,7 +25,7 @@ class Effect {
effects.windowClosed.connect(this.slotWindowClosed.bind(this));
effects.windowDataChanged.connect(this.slotWindowDataChanged.bind(this));
- this.shader = effect.addShader(Effect.MapTexture, "%NICK%.frag");
+ this.shader = effect.addFragmentShader(Effect.MapTexture, "%NICK%.frag");
this.loadConfig();
}
@@ -109,7 +108,7 @@ class Effect {
animations: [
{
type: Effect.ShaderUniform,
- shader: this.shader,
+ fragmentShader: this.shader,
uniform: "uForOpening",
from: 1.0,
to: 1.0
@@ -143,7 +142,7 @@ class Effect {
animations: [
{
type: Effect.ShaderUniform,
- shader: this.shader,
+ fragmentShader: this.shader,
uniform: "uForOpening",
from: 0.0,
to: 0.0
diff --git a/kwin/metadata.desktop.in b/kwin/metadata.desktop.in
index c975bed..25dc34c 100755
--- a/kwin/metadata.desktop.in
+++ b/kwin/metadata.desktop.in
@@ -6,7 +6,7 @@ Comment=%DESCRIPTION%
Type=Service
X-KDE-ServiceTypes=KWin/Effect,KCModule
X-KDE-PluginInfo-Author=Vlad Zahorodnii, Martin Flöser, Simon Schneegans
-X-KDE-PluginInfo-Email=vlad.zahorodnii@kde.org, mgraesslin@kde.org
+X-KDE-PluginInfo-Email=vlad.zahorodnii@kde.org, mgraesslin@kde.org, code@simonschneegans.de
X-KDE-PluginInfo-Name=kwin4_effect_%NICK%
X-KDE-PluginInfo-Version=1
X-KDE-PluginInfo-Category=Window Open/Close Animation
diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl
index 46e6d5c..6a2dc8f 100644
--- a/resources/shaders/common.glsl
+++ b/resources/shaders/common.glsl
@@ -17,31 +17,60 @@
// --------------------------------------------------------------------- standard uniforms
-// uForOpening: True if a window-open animation is ongoing, false otherwise.
-// uTexture: Contains the texture of the window.
-// uProgress: A value which transitions from 0 to 1 during the entire animation.
-// uTime: A steadily increasing value in seconds.
-// uSize: The size of uTexture in pixels.
-// uPadding: The empty area around the actual window (e.g. where the shadow is drawn).
+// Each shader can access these standard uniforms:
-#ifdef KWIN
+// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
+// sampler2D uTexture: Contains the texture of the window.
+// float uProgress: A value which transitions from 0 to 1 during the animation.
+// float uTime: A steadily increasing value in seconds.
+// vec2 uSize: The size of uTexture in pixels.
+// float uPadding: The empty area around the actual window (e.g. where the shadow
+// is drawn). For now, this will only be set on GNOME.
-uniform bool uForOpening;
-uniform sampler2D uTexture;
+// Furthermore, there is the global input "vec2 iTexCoord" and the output "vec4 oColor".
+
+#ifdef KWIN // --------------------------------------------------------------------------
+
+uniform float forOpening;
+uniform sampler2D sampler;
+uniform float textureWidth;
+uniform float textureHeight;
uniform float animationProgress;
-// uniform float uTime;
-// uniform vec2 uSize;
-// uniform float uPadding;
+
+vec2 uSize = vec2(textureWidth, textureHeight);
+bool uForOpening = forOpening == 1.0;
in vec2 texcoord0;
out vec4 fragColor;
+#define uTexture sampler;
#define uProgress animationProgress
+#define uPadding 0.0
#define iTexCoord texcoord0
#define oColor fragColor
-#else
+#elif KWIN_LEGACY // --------------------------------------------------------------------
+uniform float forOpening;
+uniform sampler2D sampler;
+uniform float textureWidth;
+uniform float textureHeight;
+uniform float animationProgress;
+
+vec2 uSize = vec2(textureWidth, textureHeight);
+bool uForOpening = forOpening == 1.0;
+
+varying vec2 texcoord0;
+
+#define uTexture sampler;
+#define uProgress animationProgress
+#define uPadding 0.0
+#define iTexCoord texcoord0
+#define oColor gl_fragColor
+
+#else // GNOME --------------------------------------------------------------------------
+
+// On GNOME, the uniforms are just normal uniforms.
uniform bool uForOpening;
uniform sampler2D uTexture;
uniform float uProgress;
@@ -49,10 +78,11 @@ uniform float uTime;
uniform vec2 uSize;
uniform float uPadding;
+// On GNOME, we set iTexCoord and oColor to be aliases for the cogl variables.
#define iTexCoord cogl_tex_coord_in[0]
#define oColor cogl_color_out
-#endif
+#endif // -------------------------------------------------------------------------------
// ----------------------------------------------------------------- compositing operators
From 67d6df0a70d0ed87b54ca3aa5a649968ac557d8b Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 9 Jun 2022 08:06:43 +0200
Subject: [PATCH 09/71] :wrench: Fix incompatibilites with OpenGL 1.0
---
kwin/build.sh | 1 -
resources/shaders/common.glsl | 22 +++++++++++-----------
resources/shaders/tv.frag | 28 ++++++++++++++--------------
3 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 95550c2..447d8dd 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -51,7 +51,6 @@ generate() {
} > "${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1_core.frag"
{
- echo "#version 100"
echo "#define KWIN_LEGACY"
echo ""
echo "// This file is automatically generated during the build process."
diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl
index 6a2dc8f..947420d 100644
--- a/resources/shaders/common.glsl
+++ b/resources/shaders/common.glsl
@@ -29,7 +29,7 @@
// Furthermore, there is the global input "vec2 iTexCoord" and the output "vec4 oColor".
-#ifdef KWIN // --------------------------------------------------------------------------
+#if defined(KWIN) // --------------------------------------------------------------------
uniform float forOpening;
uniform sampler2D sampler;
@@ -43,13 +43,13 @@ bool uForOpening = forOpening == 1.0;
in vec2 texcoord0;
out vec4 fragColor;
-#define uTexture sampler;
+#define uTexture sampler
#define uProgress animationProgress
#define uPadding 0.0
#define iTexCoord texcoord0
#define oColor fragColor
-#elif KWIN_LEGACY // --------------------------------------------------------------------
+#elif defined(KWIN_LEGACY) // -----------------------------------------------------------
uniform float forOpening;
uniform sampler2D sampler;
@@ -62,11 +62,11 @@ bool uForOpening = forOpening == 1.0;
varying vec2 texcoord0;
-#define uTexture sampler;
+#define uTexture sampler
#define uProgress animationProgress
#define uPadding 0.0
#define iTexCoord texcoord0
-#define oColor gl_fragColor
+#define oColor gl_FragColor
#else // GNOME --------------------------------------------------------------------------
@@ -99,7 +99,7 @@ vec4 alphaOver(vec4 under, vec4 over) {
// Taken from here:
// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/clutter/clutter/clutter-easing.c
-float easeOutQuad(float x) { return -1.0 * x * (x - 2); }
+float easeOutQuad(float x) { return -1.0 * x * (x - 2.0); }
// --------------------------------------------------------------------- edge mask helpers
@@ -108,10 +108,10 @@ float easeOutQuad(float x) { return -1.0 * x * (x - 2); }
// pixels and one which takes this as a percentage.
float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {
float mask = 1.0;
- mask *= smoothstep(0, 1, clamp(uv.x / fadeWidth, 0, 1));
- mask *= smoothstep(0, 1, clamp(uv.y / fadeWidth, 0, 1));
- mask *= smoothstep(0, 1, clamp((maxUV.x - uv.x) / fadeWidth, 0, 1));
- mask *= smoothstep(0, 1, clamp((maxUV.y - uv.y) / fadeWidth, 0, 1));
+ mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));
+ mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
+ mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));
+ mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));
return mask;
}
@@ -124,7 +124,7 @@ float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {
// (offset = 0), ontop the window borders (offset = 0.5) or outside the window borders
// (offset = 1).
float getAbsoluteEdgeMask(float fadePixels, float offset) {
- float padding = max(0, uPadding - fadePixels * offset);
+ float padding = max(0.0, uPadding - fadePixels * offset);
vec2 uv = iTexCoord.st * uSize - padding;
return getEdgeMask(uv, uSize - 2.0 * padding, fadePixels);
}
diff --git a/resources/shaders/tv.frag b/resources/shaders/tv.frag
index 2d84dde..f6c3ccc 100644
--- a/resources/shaders/tv.frag
+++ b/resources/shaders/tv.frag
@@ -23,10 +23,10 @@ const float FF_TIME = 0.1; // Relative time for the final fade to transpare
const float SCALING = 0.5; // Additional vertical scaling of the window.
void main() {
- float progress = uForOpening ? 1.0 - easeOutQuad(uProgress) : easeOutQuad(uProgress);
+ float prog = uForOpening ? 1.0 - easeOutQuad(uProgress) : easeOutQuad(uProgress);
// Scale down the window vertically.
- float scale = 1.0 / mix(1.0, SCALING, progress) - 1.0;
+ float scale = 1.0 / mix(1.0, SCALING, prog) - 1.0;
vec2 coords = iTexCoord.st;
coords.y = coords.y * (scale + 1.0) - scale * 0.5;
@@ -34,22 +34,22 @@ void main() {
// tb refers to the top-bottom animation.
// lr refers to the left-right animation.
// ff refers to the final fade animation.
- float tbProgress = smoothstep(0, 1, clamp(progress / TB_TIME, 0, 1));
- float lrProgress = smoothstep(0, 1, clamp((progress - LR_DELAY) / LR_TIME, 0, 1));
- float ffProgress = smoothstep(0, 1, clamp((progress - 1.0 + FF_TIME) / FF_TIME, 0, 1));
+ float tbProg = smoothstep(0.0, 1.0, clamp(prog / TB_TIME, 0.0, 1.0));
+ float lrProg = smoothstep(0.0, 1.0, clamp((prog - LR_DELAY) / LR_TIME, 0.0, 1.0));
+ float ffProg = smoothstep(0.0, 1.0, clamp((prog - 1.0 + FF_TIME) / FF_TIME, 0.0, 1.0));
// This is a top-center-bottom gradient in [0..1..0]
- float tb = coords.y * 2;
- tb = tb < 1 ? tb : 2 - tb;
+ float tb = coords.y * 2.0;
+ tb = tb < 1.0 ? tb : 2.0 - tb;
// This is a left-center-right gradient in [0..1..0]
- float lr = coords.x * 2;
- lr = lr < 1 ? lr : 2 - lr;
+ float lr = coords.x * 2.0;
+ lr = lr < 1.0 ? lr : 2.0 - lr;
// Combine the progress values with the gradients to create the alpha masks.
- float tbMask = 1 - smoothstep(0, 1, clamp((tbProgress - tb) / BLUR_WIDTH, 0, 1));
- float lrMask = 1 - smoothstep(0, 1, clamp((lrProgress - lr) / BLUR_WIDTH, 0, 1));
- float ffMask = 1 - smoothstep(0, 1, ffProgress);
+ float tbMask = 1.0 - smoothstep(0.0, 1.0, clamp((tbProg - tb) / BLUR_WIDTH, 0.0, 1.0));
+ float lrMask = 1.0 - smoothstep(0.0, 1.0, clamp((lrProg - lr) / BLUR_WIDTH, 0.0, 1.0));
+ float ffMask = 1.0 - smoothstep(0.0, 1.0, ffProg);
// Assemble the final alpha value.
float mask = tbMask * lrMask * ffMask;
@@ -57,11 +57,11 @@ void main() {
oColor = texture2D(uTexture, coords);
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (oColor.a > 0) {
+ if (oColor.a > 0.0) {
oColor.rgb /= oColor.a;
}
- oColor.rgb = mix(oColor.rgb, uColor * oColor.a, smoothstep(0, 1, progress));
+ oColor.rgb = mix(oColor.rgb, uColor * oColor.a, smoothstep(0.0, 1.0, prog));
oColor.a *= mask;
// These are pretty useful for understanding how this works.
From 3360b45c189e635ef618a6a74b7461d139214d3c Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 9 Jun 2022 08:28:48 +0200
Subject: [PATCH 10/71] :wrench: Use vec4 for color
---
resources/shaders/tv.frag | 4 ++--
src/TVEffect.js | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/resources/shaders/tv.frag b/resources/shaders/tv.frag
index f6c3ccc..79b35fb 100644
--- a/resources/shaders/tv.frag
+++ b/resources/shaders/tv.frag
@@ -13,7 +13,7 @@
// The content from common.glsl is automatically prepended to each shader effect.
-uniform vec3 uColor;
+uniform vec4 uColor;
const float BLUR_WIDTH = 0.01; // Width of the gradients.
const float TB_TIME = 0.7; // Relative time for the top/bottom animation.
@@ -61,7 +61,7 @@ void main() {
oColor.rgb /= oColor.a;
}
- oColor.rgb = mix(oColor.rgb, uColor * oColor.a, smoothstep(0.0, 1.0, prog));
+ oColor.rgb = mix(oColor.rgb, uColor.rgb * oColor.a, smoothstep(0.0, 1.0, prog));
oColor.a *= mask;
// These are pretty useful for understanding how this works.
diff --git a/src/TVEffect.js b/src/TVEffect.js
index f1cfe5f..b02d8bd 100644
--- a/src/TVEffect.js
+++ b/src/TVEffect.js
@@ -50,8 +50,8 @@ var TVEffect = class {
// Write all uniform values at the start of each animation.
shader.connect('begin-animation', (shader, settings) => {
const c = Clutter.Color.from_string(settings.get_string('tv-effect-color'))[1];
- shader.set_uniform_float(shader._uColor, 3,
- [c.red / 255, c.green / 255, c.blue / 255]);
+ shader.set_uniform_float(shader._uColor, 4,
+ [c.red / 255, c.green / 255, c.blue / 255, 1.0]);
});
});
}
From 03a6d9263a3e229918acdc21d3fdf130f1480f0a Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 9 Jun 2022 08:29:04 +0200
Subject: [PATCH 11/71] :wrench: Make class name unique
---
kwin/main.js.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kwin/main.js.in b/kwin/main.js.in
index 426def2..6854d4e 100755
--- a/kwin/main.js.in
+++ b/kwin/main.js.in
@@ -17,7 +17,7 @@ const blacklist = [
"ksplashqml ksplashqml"
];
-class Effect {
+class %NICK%Effect {
constructor() {
effect.configChanged.connect(this.loadConfig.bind(this));
effect.animationEnded.connect(this.cleanupForcedRoles.bind(this));
@@ -121,7 +121,7 @@ class Effect {
if (effects.hasActiveFullScreenEffect) {
return;
}
- if (!Effect.isScaleWindow(window)) {
+ if (!%NICK%Effect.isScaleWindow(window)) {
return;
}
if (!window.visible || window.skipsCloseAnimation) {
@@ -168,4 +168,4 @@ class Effect {
}
}
-new Effect();
+new %NICK%Effect();
From bbd7d6ea647fc3f851c45cada731cf0c0e194704 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 9 Jun 2022 10:46:45 +0200
Subject: [PATCH 12/71] :wrench: Use consistent class names
---
kwin/kwin4_effect_tv/contents/config/main.xml | 26 ++-
kwin/kwin4_effect_tv/contents/ui/config.ui | 156 +++++++++---------
kwin/main.js.in | 8 +-
3 files changed, 94 insertions(+), 96 deletions(-)
diff --git a/kwin/kwin4_effect_tv/contents/config/main.xml b/kwin/kwin4_effect_tv/contents/config/main.xml
index c0f6524..4d89142 100755
--- a/kwin/kwin4_effect_tv/contents/config/main.xml
+++ b/kwin/kwin4_effect_tv/contents/config/main.xml
@@ -1,15 +1,13 @@
-
Date: Thu, 9 Jun 2022 10:59:03 +0200
Subject: [PATCH 13/71] :wrench: Fix function call
---
kwin/main.js.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kwin/main.js.in b/kwin/main.js.in
index 4b3d530..5e755be 100755
--- a/kwin/main.js.in
+++ b/kwin/main.js.in
@@ -91,7 +91,7 @@ class BMW%NICK%Effect {
if (effects.hasActiveFullScreenEffect) {
return;
}
- if (!Effect.isScaleWindow(window)) {
+ if (!BMW%NICK%Effect.isScaleWindow(window)) {
return;
}
if (!window.visible) {
From bf3aa0af9355f8a9d634a391c972f8b8fe45505b Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 9 Jun 2022 11:34:18 +0200
Subject: [PATCH 14/71] :wrench: Use methods shader I/O
---
kwin/main.js.in | 4 +--
resources/shaders/common.glsl | 68 +++++++++++++++++++++++++++--------
resources/shaders/tv.frag | 12 +++----
3 files changed, 60 insertions(+), 24 deletions(-)
diff --git a/kwin/main.js.in b/kwin/main.js.in
index 5e755be..0e9ebe2 100755
--- a/kwin/main.js.in
+++ b/kwin/main.js.in
@@ -109,7 +109,7 @@ class BMW%NICK%Effect {
{
type: Effect.ShaderUniform,
fragmentShader: this.shader,
- uniform: "uForOpening",
+ uniform: "forOpening",
from: 1.0,
to: 1.0
}
@@ -143,7 +143,7 @@ class BMW%NICK%Effect {
{
type: Effect.ShaderUniform,
fragmentShader: this.shader,
- uniform: "uForOpening",
+ uniform: "forOpening",
from: 0.0,
to: 0.0
}
diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl
index 947420d..04c1085 100644
--- a/resources/shaders/common.glsl
+++ b/resources/shaders/common.glsl
@@ -17,17 +17,21 @@
// --------------------------------------------------------------------- standard uniforms
-// Each shader can access these standard uniforms:
+// Each shader can access these standard input values:
-// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
-// sampler2D uTexture: Contains the texture of the window.
-// float uProgress: A value which transitions from 0 to 1 during the animation.
-// float uTime: A steadily increasing value in seconds.
-// vec2 uSize: The size of uTexture in pixels.
-// float uPadding: The empty area around the actual window (e.g. where the shadow
-// is drawn). For now, this will only be set on GNOME.
+// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
+// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
+// float uProgress: A value which transitions from 0 to 1 during the animation.
+// float uTime: A steadily increasing value in seconds.
+// vec2 uSize: The size of uTexture in pixels.
+// float uPadding: The empty area around the actual window (e.g. where the shadow
+// is drawn). For now, this will only be set on GNOME.
-// Furthermore, there is the global input "vec2 iTexCoord" and the output "vec4 oColor".
+// Furthermore, there are two global methods for reading the window input color and
+// setting the shader output color. Both methods assume straight alpha:
+
+// vec4 getInputColor(vec2 coords)
+// void setOutputColor(vec4 outColor)
#if defined(KWIN) // --------------------------------------------------------------------
@@ -43,11 +47,23 @@ bool uForOpening = forOpening == 1.0;
in vec2 texcoord0;
out vec4 fragColor;
-#define uTexture sampler
#define uProgress animationProgress
#define uPadding 0.0
#define iTexCoord texcoord0
-#define oColor fragColor
+
+vec4 getInputColor(vec2 coords) {
+ vec4 color = texture2D(sampler, coords);
+
+ if (color.a > 0.0) {
+ color.rgb /= color.a;
+ }
+
+ return color;
+}
+
+void setOutputColor(vec4 outColor) {
+ fragColor = vec4(outColor.rgb * outColor.a, outColor.a);
+}
#elif defined(KWIN_LEGACY) // -----------------------------------------------------------
@@ -62,11 +78,23 @@ bool uForOpening = forOpening == 1.0;
varying vec2 texcoord0;
-#define uTexture sampler
#define uProgress animationProgress
#define uPadding 0.0
#define iTexCoord texcoord0
-#define oColor gl_FragColor
+
+vec4 getInputColor(vec2 coords) {
+ vec4 color = texture2D(sampler, coords);
+
+ if (color.a > 0.0) {
+ color.rgb /= color.a;
+ }
+
+ return color;
+}
+
+void setOutputColor(vec4 outColor) {
+ gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a);
+}
#else // GNOME --------------------------------------------------------------------------
@@ -80,7 +108,19 @@ uniform float uPadding;
// On GNOME, we set iTexCoord and oColor to be aliases for the cogl variables.
#define iTexCoord cogl_tex_coord_in[0]
-#define oColor cogl_color_out
+
+// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
+vec4 getInputColor(vec2 coords) {
+ vec4 color = texture2D(uTexture, coords);
+
+ if (color.a > 0.0) {
+ color.rgb /= color.a;
+ }
+
+ return color;
+}
+
+void setOutputColor(vec4 outColor) { cogl_color_out = outColor; }
#endif // -------------------------------------------------------------------------------
diff --git a/resources/shaders/tv.frag b/resources/shaders/tv.frag
index 79b35fb..ea53b4c 100644
--- a/resources/shaders/tv.frag
+++ b/resources/shaders/tv.frag
@@ -54,14 +54,8 @@ void main() {
// Assemble the final alpha value.
float mask = tbMask * lrMask * ffMask;
- oColor = texture2D(uTexture, coords);
-
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (oColor.a > 0.0) {
- oColor.rgb /= oColor.a;
- }
-
- oColor.rgb = mix(oColor.rgb, uColor.rgb * oColor.a, smoothstep(0.0, 1.0, prog));
+ vec4 oColor = getInputColor(coords);
+ oColor.rgb = mix(oColor.rgb, uColor.rgb * oColor.a, smoothstep(0.0, 1.0, prog));
oColor.a *= mask;
// These are pretty useful for understanding how this works.
@@ -69,4 +63,6 @@ void main() {
// oColor = vec4(vec3(lrMask), 1);
// oColor = vec4(vec3(ffMask), 1);
// oColor = vec4(vec3(mask), 1);
+
+ setOutputColor(oColor);
}
\ No newline at end of file
From ba9f1c91f54750a35247073d59793aab48ed71d8 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 9 Jun 2022 14:03:00 +0200
Subject: [PATCH 15/71] :wrench: Generate JS code for kwin
---
kwin/build.sh | 19 +++++++++++++------
.../{contents/ui => }/config.ui | 0
kwin/kwin4_effect_tv/loadConfig.js | 7 +++++++
.../{contents/config => }/main.xml | 2 +-
kwin/main.js.in | 8 +-------
5 files changed, 22 insertions(+), 14 deletions(-)
rename kwin/kwin4_effect_tv/{contents/ui => }/config.ui (100%)
create mode 100644 kwin/kwin4_effect_tv/loadConfig.js
rename kwin/kwin4_effect_tv/{contents/config => }/main.xml (91%)
diff --git a/kwin/build.sh b/kwin/build.sh
index 447d8dd..78854d4 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -26,19 +26,26 @@ mkdir -p "${BUILD_DIR}"
# $1: The nick of the effect (e.g. "tv")
# $2: The name of the effect (e.g. "TV Effect")
-# $3: A short description of the effect
+# $3: A short description of the effect (e.g. "Make windows close like turning off a TV")
generate() {
- cp -r "kwin4_effect_$1" "${BUILD_DIR}"
# Create resource directories.
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/shaders"
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/code"
+ mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/config"
+ mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/ui"
- sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
- metadata.desktop.in > "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
+ cp "kwin4_effect_$1/main.xml" "${BUILD_DIR}/kwin4_effect_$1/contents/config"
+ cp "kwin4_effect_$1/config.ui" "${BUILD_DIR}/kwin4_effect_$1/contents/ui"
- sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
- main.js.in > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
+ perl -pe "s/%LOAD_CONFIG%/`cat kwin4_effect_$1/loadConfig.js | tr '/' '\f' `/g;" \
+ main.js.in | tr '\f' '/' > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
+
+ perl -pi -e "s/%NICK%/$1/g;" "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
+
+ perl -pe "s/%NICK%/$1/g;" metadata.desktop.in > "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
+ perl -pi -e "s/%NAME%/$2/g;" "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
+ perl -pi -e "s/%DESCRIPTION%/$3/g;" "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
{
echo "#version 140"
diff --git a/kwin/kwin4_effect_tv/contents/ui/config.ui b/kwin/kwin4_effect_tv/config.ui
similarity index 100%
rename from kwin/kwin4_effect_tv/contents/ui/config.ui
rename to kwin/kwin4_effect_tv/config.ui
diff --git a/kwin/kwin4_effect_tv/loadConfig.js b/kwin/kwin4_effect_tv/loadConfig.js
new file mode 100644
index 0000000..e281b8e
--- /dev/null
+++ b/kwin/kwin4_effect_tv/loadConfig.js
@@ -0,0 +1,7 @@
+loadConfig() {
+ const defaultDuration = 400;
+ const duration = effect.readConfig('Duration', defaultDuration) || defaultDuration;
+ this.duration = animationTime(duration);
+
+ effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
+}
\ No newline at end of file
diff --git a/kwin/kwin4_effect_tv/contents/config/main.xml b/kwin/kwin4_effect_tv/main.xml
similarity index 91%
rename from kwin/kwin4_effect_tv/contents/config/main.xml
rename to kwin/kwin4_effect_tv/main.xml
index 4d89142..0a6d131 100755
--- a/kwin/kwin4_effect_tv/contents/config/main.xml
+++ b/kwin/kwin4_effect_tv/main.xml
@@ -7,7 +7,7 @@
Date: Thu, 9 Jun 2022 14:09:50 +0200
Subject: [PATCH 16/71] :wrench: Fix shellcheck issues
---
kwin/build.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 78854d4..2e2d520 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -38,7 +38,7 @@ generate() {
cp "kwin4_effect_$1/main.xml" "${BUILD_DIR}/kwin4_effect_$1/contents/config"
cp "kwin4_effect_$1/config.ui" "${BUILD_DIR}/kwin4_effect_$1/contents/ui"
- perl -pe "s/%LOAD_CONFIG%/`cat kwin4_effect_$1/loadConfig.js | tr '/' '\f' `/g;" \
+ perl -pe "s/%LOAD_CONFIG%/$(tr '/' '\f' < "kwin4_effect_$1/loadConfig.js")/g;" \
main.js.in | tr '\f' '/' > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
perl -pi -e "s/%NICK%/$1/g;" "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
From af9cdb6459bc715e3b7920d4e036b079e35b3db8 Mon Sep 17 00:00:00 2001
From: Ulices
Date: Fri, 10 Jun 2022 07:20:02 +0200
Subject: [PATCH 18/71] :memo: Update tutorial
---
docs/how-to-create-new-effects.md | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md
index 9bc7544..fc9a3fb 100644
--- a/docs/how-to-create-new-effects.md
+++ b/docs/how-to-create-new-effects.md
@@ -86,27 +86,28 @@ Please study this code carefully, all of it is explained with inline comments.
```glsl
// The content from common.glsl is automatically prepended to each shader effect. This
-// provides the standard input "vec2 iTexCoord", the standard output "vec4 oColor" as well
-// as some standard uniforms which will be updated during the animation:
+// provides the standard input:
-// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
-// sampler2D uTexture: Contains the texture of the window.
-// float uProgress: A value which transitions from 0 to 1 during the entire animation.
-// float uTime: A steadily increasing value in seconds.
-// vec2 uSize: The size of uTexture in pixels.
-// float uPadding: The empty area around the actual window (e.g. where the shadow is drawn).
+// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
+// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
+// float uProgress: A value which transitions from 0 to 1 during the animation.
+// float uTime: A steadily increasing value in seconds.
+// vec2 uSize: The size of uTexture in pixels.
+// float uPadding: The empty area around the actual window (e.g. where the shadow
+// is drawn). For now, this will only be set on GNOME.
+
+// Furthermore, there are two global methods for reading the window input color and
+// setting the shader output color. Both methods assume straight alpha:
+
+// vec4 getInputColor(vec2 coords)
+// void setOutputColor(vec4 outColor)
// The width of the fading effect is loaded from the settings.
uniform float uFadeWidth;
void main() {
// Get the color from the window texture.
- oColor = texture2D(uTexture, iTexCoord.st);
-
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (oColor.a > 0) {
- oColor.rgb /= oColor.a;
- }
+ vec4 oColor = getInputColor(iTexCoord.st);
// Radial distance from window edge to the window's center.
float dist = length(iTexCoord.st - 0.5) * 2.0 / sqrt(2.0);
@@ -121,6 +122,8 @@ void main() {
// Apply the mask to the output.
oColor.a *= mask;
+
+ setOutputColor(oColor);
}
```
From 0bd0fb27b9a1d6d989a437e6d04b0a36d2c1bdd9 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 07:20:21 +0200
Subject: [PATCH 19/71] :wrench: Use new global methods for shader I/O
---
resources/shaders/apparition.frag | 8 ++------
resources/shaders/broken-glass.frag | 9 +++------
resources/shaders/common.glsl | 2 +-
resources/shaders/energize-a.frag | 15 ++++++---------
resources/shaders/energize-b.frag | 15 ++++++---------
resources/shaders/fire.frag | 9 +++------
resources/shaders/hexagon.frag | 17 ++++++-----------
resources/shaders/matrix.frag | 9 +++------
resources/shaders/snap.frag | 18 +++++++-----------
resources/shaders/trex.frag | 9 +++------
resources/shaders/wisps.frag | 9 +++------
11 files changed, 43 insertions(+), 77 deletions(-)
diff --git a/resources/shaders/apparition.frag b/resources/shaders/apparition.frag
index 7e4372a..5f1d8db 100644
--- a/resources/shaders/apparition.frag
+++ b/resources/shaders/apparition.frag
@@ -48,12 +48,8 @@ void main() {
float c = cos(angle);
coords = vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- oColor = texture2D(uTexture, coords + center);
- if (oColor.a > 0) {
- oColor.rgb /= oColor.a;
- }
-
// Fade out the window texture.
+ vec4 oColor = getInputColor(coords + center);
oColor.a *= 1.0 - progress;
+ setOutputColor(oColor);
}
\ No newline at end of file
diff --git a/resources/shaders/broken-glass.frag b/resources/shaders/broken-glass.frag
index fd1a508..da5477c 100644
--- a/resources/shaders/broken-glass.frag
+++ b/resources/shaders/broken-glass.frag
@@ -25,7 +25,7 @@ const float ACTOR_SCALE = 2.0;
const float PADDING = ACTOR_SCALE / 2.0 - 0.5;
void main() {
- oColor = vec4(0, 0, 0, 0);
+ vec4 oColor = vec4(0, 0, 0, 0);
float progress = uForOpening ? 1.0 - uProgress : uProgress;
@@ -66,12 +66,9 @@ void main() {
float shardGroup = floor(shardMap.g * SHARD_LAYERS * 0.999);
if (shardGroup == i && (shardMap.x - pow(progress + 0.1, 2)) > 0) {
- oColor = texture2D(uTexture, coords);
+ oColor = getInputColor(coords);
}
}
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (oColor.a > 0) {
- oColor.rgb /= oColor.a;
- }
+ setOutputColor(oColor);
}
\ No newline at end of file
diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl
index 04c1085..798ff43 100644
--- a/resources/shaders/common.glsl
+++ b/resources/shaders/common.glsl
@@ -106,7 +106,7 @@ uniform float uTime;
uniform vec2 uSize;
uniform float uPadding;
-// On GNOME, we set iTexCoord and oColor to be aliases for the cogl variables.
+// On GNOME, we set iTexCoord to be an alias for the cogl variables.
#define iTexCoord cogl_tex_coord_in[0]
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
diff --git a/resources/shaders/energize-a.frag b/resources/shaders/energize-a.frag
index a1d1264..e8ccd43 100644
--- a/resources/shaders/energize-a.frag
+++ b/resources/shaders/energize-a.frag
@@ -59,17 +59,12 @@ vec2 getMasks(float progress) {
void main() {
float progress = easeOutQuad(uProgress);
- vec2 masks = getMasks(progress);
- vec4 windowColor = texture2D(uTexture, iTexCoord.st);
-
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (windowColor.a > 0) {
- windowColor.rgb /= windowColor.a;
- }
+ vec2 masks = getMasks(progress);
+ vec4 oColor = getInputColor(iTexCoord.st);
// Dissolve window to effect color / transparency.
- oColor.rgb = mix(uColor, windowColor.rgb, 0.2 * masks.y + 0.8);
- oColor.a = windowColor.a * masks.y;
+ oColor.rgb = mix(uColor, oColor.rgb, 0.2 * masks.y + 0.8);
+ oColor.a = oColor.a * masks.y;
vec2 scaledUV = (iTexCoord.st - 0.5) * (1.0 + 0.1 * progress);
scaledUV /= uScale;
@@ -94,4 +89,6 @@ void main() {
// oColor = vec4(vec3(masks.x), 1.0);
// oColor = vec4(vec3(masks.y), 1.0);
// oColor = vec4(vec3(particles), 1.0);
+
+ setOutputColor(oColor);
}
\ No newline at end of file
diff --git a/resources/shaders/energize-b.frag b/resources/shaders/energize-b.frag
index 68856b9..32dad1f 100644
--- a/resources/shaders/energize-b.frag
+++ b/resources/shaders/energize-b.frag
@@ -76,17 +76,12 @@ vec4 getMasks(float progress) {
void main() {
float progress = easeOutQuad(uProgress);
- vec4 masks = getMasks(progress);
- vec4 windowColor = texture2D(uTexture, iTexCoord.st);
-
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (windowColor.a > 0) {
- windowColor.rgb /= windowColor.a;
- }
+ vec4 masks = getMasks(progress);
+ vec4 oColor = getInputColor(iTexCoord.st);
// Dissolve window to effect color / transparency.
- oColor.rgb = mix(uColor, windowColor.rgb, 0.5 * masks.w + 0.5);
- oColor.a = windowColor.a * masks.w;
+ oColor.rgb = mix(uColor, oColor.rgb, 0.5 * masks.w + 0.5);
+ oColor.a = oColor.a * masks.w;
// Add leading shower particles.
vec2 showerUV = iTexCoord.st + vec2(0, -0.7 * progress / SHOWER_TIME);
@@ -118,4 +113,6 @@ void main() {
// oColor = vec4(vec3(shower), 1.0);
// oColor = vec4(vec3(streaks), 1.0);
// oColor = vec4(vec3(atoms), 1.0);
+
+ setOutputColor(oColor);
}
\ No newline at end of file
diff --git a/resources/shaders/fire.frag b/resources/shaders/fire.frag
index f1cf381..44b0d65 100644
--- a/resources/shaders/fire.frag
+++ b/resources/shaders/fire.frag
@@ -103,12 +103,7 @@ void main() {
vec4 fire = getFireColor(noise);
// Get the window texture.
- oColor = texture2D(uTexture, iTexCoord.st);
-
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (oColor.a > 0) {
- oColor.rgb /= oColor.a;
- }
+ vec4 oColor = getInputColor(iTexCoord.st);
// Fade the window according to the effect mask.
oColor.a *= effectMask.x;
@@ -120,4 +115,6 @@ void main() {
// oColor = vec4(vec3(noise), 1);
// oColor = vec4(vec3(effectMask.x), 1);
// oColor = vec4(vec3(effectMask.y), 1);
+
+ setOutputColor(oColor);
}
\ No newline at end of file
diff --git a/resources/shaders/hexagon.frag b/resources/shaders/hexagon.frag
index 14f8a8a..2900a2a 100644
--- a/resources/shaders/hexagon.frag
+++ b/resources/shaders/hexagon.frag
@@ -79,22 +79,15 @@ void main() {
vec2 texScale = 0.1 * uSize / uScale;
vec4 hex = getHexagons(iTexCoord.st * texScale);
- if (tileProgress > hex.z) {
+ vec4 oColor = vec4(0.0);
- // Crop outer parts of the shrinking tiles.
- oColor.a = 0.0;
-
- } else {
+ // Crop outer parts of the shrinking tiles.
+ if (tileProgress < hex.z) {
// Make the tiles shrink by offsetting the texture lookup towards the edge
// of the cell.
vec2 lookupOffset = tileProgress * hex.xy / texScale / (1.0 - tileProgress);
- oColor = texture2D(uTexture, iTexCoord.st + lookupOffset);
-
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (oColor.a > 0) {
- oColor.rgb /= oColor.a;
- }
+ oColor = getInputColor(iTexCoord.st + lookupOffset);
vec4 glow = uGlowColor;
vec4 line = uLineColor;
@@ -122,4 +115,6 @@ void main() {
oColor.rgb = mix(oColor.rgb, line.rgb, line.a);
}
}
+
+ setOutputColor(oColor);
}
\ No newline at end of file
diff --git a/resources/shaders/matrix.frag b/resources/shaders/matrix.frag
index ad1db69..4547474 100644
--- a/resources/shaders/matrix.frag
+++ b/resources/shaders/matrix.frag
@@ -83,12 +83,7 @@ void main() {
float textMask = getText(coords);
// Get the window texture.
- oColor = texture2D(uTexture, coords);
-
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (oColor.a > 0) {
- oColor.rgb /= oColor.a;
- }
+ vec4 oColor = getInputColor(coords);
// Fade the window according to the effect mask.
oColor.a *= rainMask.y;
@@ -107,4 +102,6 @@ void main() {
// oColor = vec4(vec3(textMask), 1);
// oColor = vec4(vec3(rainMask.x), 1);
// oColor = vec4(vec3(rainMask.y), 1);
+
+ setOutputColor(oColor);
}
\ No newline at end of file
diff --git a/resources/shaders/snap.frag b/resources/shaders/snap.frag
index 952b95a..25a69bf 100644
--- a/resources/shaders/snap.frag
+++ b/resources/shaders/snap.frag
@@ -34,11 +34,7 @@ void main() {
progress = progress + 0.25 - 0.5 * simplex2D((iTexCoord.st + uSeed) * 2.0);
progress = pow(max(0, progress), 2.0);
- // This may help you to understand how this effect works.
- // oColor = vec4(progress, 0, 0, 0);
- // return;
-
- oColor = vec4(0, 0, 0, 0);
+ vec4 oColor = vec4(0.0);
for (float i = 0; i < DUST_LAYERS; ++i) {
@@ -80,12 +76,7 @@ void main() {
if (dustGroup == i) {
// Get the window color.
- vec4 windowColor = texture2D(uTexture, coords + 0.5);
-
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (windowColor.a > 0) {
- windowColor.rgb /= windowColor.a;
- }
+ vec4 windowColor = getInputColor(coords + 0.5);
// Fade the window color to uDustColor.
vec3 dustColor = mix(windowColor.rgb, uDustColor.rgb, uDustColor.a);
@@ -97,4 +88,9 @@ void main() {
}
}
}
+
+ // This may help you to understand how this effect works.
+ // oColor = vec4(progress, 0, 0, 0);
+
+ setOutputColor(oColor);
}
\ No newline at end of file
diff --git a/resources/shaders/trex.frag b/resources/shaders/trex.frag
index a59b699..ecb74f4 100644
--- a/resources/shaders/trex.frag
+++ b/resources/shaders/trex.frag
@@ -90,12 +90,7 @@ void main() {
// Get the window texture. We shift the texture lookup by the local derivative of
// the claw texture in order to mimic some folding distortion.
vec2 offset = vec2(dFdx(scratchMap), dFdy(scratchMap)) * progress * 0.5;
- oColor = texture2D(uTexture, coords + offset);
-
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (oColor.a > 0) {
- oColor.rgb /= oColor.a;
- }
+ vec4 oColor = getInputColor(coords + offset);
// Add colorful flashes.
float flashIntensity = 1.0 / FLASH_INTENSITY * (scratchMap - progress) + 1;
@@ -120,4 +115,6 @@ void main() {
// These are pretty useful for understanding how this works.
// oColor = vec4(vec3(flashIntensity), 1);
// oColor = vec4(vec3(scratchMap), 1);
+
+ setOutputColor(oColor);
}
\ No newline at end of file
diff --git a/resources/shaders/wisps.frag b/resources/shaders/wisps.frag
index de7e6e6..90d36de 100644
--- a/resources/shaders/wisps.frag
+++ b/resources/shaders/wisps.frag
@@ -71,12 +71,7 @@ void main() {
vec2 coords = iTexCoord.st * (scale + 1.0) - scale * 0.5;
// Get the color of the window.
- oColor = texture2D(uTexture, coords);
-
- // Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
- if (oColor.a > 0) {
- oColor.rgb /= oColor.a;
- }
+ vec4 oColor = getInputColor(coords);
// Compute several layers of moving wisps.
vec2 uv = (iTexCoord.st - 0.5) / mix(1.0, 0.5, progress) + 0.5;
@@ -110,4 +105,6 @@ void main() {
// oColor = vec4(vec3(wisps), 1.0);
// oColor = vec4(vec3(noise), 1.0);
// oColor = vec4(vec3(mask*min(wispsIn, 1.0 - wispsOut)), 1.0);
+
+ setOutputColor(oColor);
}
\ No newline at end of file
From 46a1729e548e1bde77a76a825ebfb806cb17ed08 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 07:30:44 +0200
Subject: [PATCH 20/71] :wrench: Use uDuration instead of uTime
---
docs/how-to-create-new-effects.md | 2 +-
extension.js | 6 +++---
resources/shaders/common.glsl | 6 ++++--
resources/shaders/energize-a.frag | 6 +++---
resources/shaders/energize-b.frag | 2 +-
resources/shaders/fire.frag | 8 +++++---
resources/shaders/matrix.frag | 2 +-
resources/shaders/wisps.frag | 3 ++-
src/Shader.js | 21 ++++++++++-----------
9 files changed, 30 insertions(+), 26 deletions(-)
diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md
index fc9a3fb..db82aca 100644
--- a/docs/how-to-create-new-effects.md
+++ b/docs/how-to-create-new-effects.md
@@ -91,7 +91,7 @@ Please study this code carefully, all of it is explained with inline comments.
// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
// float uProgress: A value which transitions from 0 to 1 during the animation.
-// float uTime: A steadily increasing value in seconds.
+// float uDuration: The duration of the current animation in seconds.
// vec2 uSize: The size of uTexture in pixels.
// float uPadding: The empty area around the actual window (e.g. where the shadow
// is drawn). For now, this will only be set on GNOME.
diff --git a/extension.js b/extension.js
index 26cca45..f11aba8 100644
--- a/extension.js
+++ b/extension.js
@@ -502,14 +502,14 @@ class Extension {
actor.add_effect_with_name('burn-my-windows-effect', shader);
// Set one-time uniforms.
- shader.beginAnimation(this._settings, forOpening, actor);
+ shader.beginAnimation(this._settings, forOpening, duration * 0.001, actor);
// Set other uniforms each frame.
transition.connect('new-frame', (t) => {
if (testMode) {
- shader.updateAnimation(0.5, 0.001 * duration * 0.5);
+ shader.updateAnimation(0.5);
} else {
- shader.updateAnimation(t.get_progress(), 0.001 * t.get_elapsed_time());
+ shader.updateAnimation(t.get_progress());
}
});
diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl
index 798ff43..a1026c0 100644
--- a/resources/shaders/common.glsl
+++ b/resources/shaders/common.glsl
@@ -22,7 +22,7 @@
// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
// float uProgress: A value which transitions from 0 to 1 during the animation.
-// float uTime: A steadily increasing value in seconds.
+// float uDuration: The duration of the current animation in seconds.
// vec2 uSize: The size of uTexture in pixels.
// float uPadding: The empty area around the actual window (e.g. where the shadow
// is drawn). For now, this will only be set on GNOME.
@@ -37,6 +37,7 @@
uniform float forOpening;
uniform sampler2D sampler;
+uniform float uDuration;
uniform float textureWidth;
uniform float textureHeight;
uniform float animationProgress;
@@ -69,6 +70,7 @@ void setOutputColor(vec4 outColor) {
uniform float forOpening;
uniform sampler2D sampler;
+uniform float uDuration;
uniform float textureWidth;
uniform float textureHeight;
uniform float animationProgress;
@@ -102,7 +104,7 @@ void setOutputColor(vec4 outColor) {
uniform bool uForOpening;
uniform sampler2D uTexture;
uniform float uProgress;
-uniform float uTime;
+uniform float uDuration;
uniform vec2 uSize;
uniform float uPadding;
diff --git a/resources/shaders/energize-a.frag b/resources/shaders/energize-a.frag
index e8ccd43..f94ba5e 100644
--- a/resources/shaders/energize-a.frag
+++ b/resources/shaders/energize-a.frag
@@ -70,14 +70,14 @@ void main() {
scaledUV /= uScale;
// Add molecule particles.
- vec2 uv = scaledUV + vec2(0, 0.1 * uTime);
+ vec2 uv = scaledUV + vec2(0, 0.1 * uProgress * uDuration);
uv *= 0.010598 * vec2(0.5 * uSize.x, uSize.y);
- float particles = 0.2 * pow((simplex3D(vec3(uv, 0.0 * uTime))), 3.0);
+ float particles = 0.2 * pow((simplex3D(vec3(uv, 0.0 * uProgress * uDuration))), 3.0);
// Add more molecule particles.
for (int i = 1; i <= 3; ++i) {
vec2 uv = scaledUV * 0.12154 / pow(1.5, i) * uSize;
- float atoms = simplex3D(vec3(uv, 2.0 * uTime / i));
+ float atoms = simplex3D(vec3(uv, 2.0 * uProgress * uDuration / i));
particles += 0.5 * pow(0.2 * (1.0 / (1.0 - atoms) - 1.0), 2);
}
diff --git a/resources/shaders/energize-b.frag b/resources/shaders/energize-b.frag
index 32dad1f..703c5e3 100644
--- a/resources/shaders/energize-b.frag
+++ b/resources/shaders/energize-b.frag
@@ -100,7 +100,7 @@ void main() {
// Add glimmering atoms.
vec2 atomUV = iTexCoord.st + vec2(0, -0.025 * progress / SHOWER_TIME);
atomUV *= 0.2 * uSize / uScale;
- float atoms = pow((simplex3D(vec3(atomUV, uTime))), 5.0);
+ float atoms = pow((simplex3D(vec3(atomUV, uProgress * uDuration))), 5.0);
oColor.rgb += uColor * atoms * masks.z;
oColor.a += atoms * masks.z;
diff --git a/resources/shaders/fire.frag b/resources/shaders/fire.frag
index 44b0d65..0ebce5c 100644
--- a/resources/shaders/fire.frag
+++ b/resources/shaders/fire.frag
@@ -90,10 +90,12 @@ vec2 effectMask(float hideTime, float fadeWidth, float edgeFadeWidth) {
void main() {
// Get a noise value which moves vertically in time.
vec2 uv = iTexCoord.st * uSize / vec2(400, 600) / uScale;
- uv.y += uTime * uMovementSpeed;
+ uv.y += uProgress * uDuration * uMovementSpeed;
- float noise = u3DNoise ? simplex3DFractal(vec3(uv * 4.0, uTime * uMovementSpeed * 1.5))
- : simplex2DFractal(uv * 4.0);
+ float noise =
+ u3DNoise
+ ? simplex3DFractal(vec3(uv * 4.0, uProgress * uDuration * uMovementSpeed * 1.5))
+ : simplex2DFractal(uv * 4.0);
// Modulate noise by effect mask.
vec2 effectMask = effectMask(HIDE_TIME, FADE_WIDTH, EDGE_FADE);
diff --git a/resources/shaders/matrix.frag b/resources/shaders/matrix.frag
index 4547474..5191238 100644
--- a/resources/shaders/matrix.frag
+++ b/resources/shaders/matrix.frag
@@ -36,7 +36,7 @@ float getText(vec2 fragCoord) {
// Choose random letter.
uv += floor(hash22(floor(hash22(block) * vec2(12.9898, 78.233) +
- LETTER_FLICKER_SPEED * uTime + 42.254)) *
+ LETTER_FLICKER_SPEED * uProgress * uDuration + 42.254)) *
LETTER_TILES);
return texture2D(uFontTexture, uv / LETTER_TILES).r;
diff --git a/resources/shaders/wisps.frag b/resources/shaders/wisps.frag
index 90d36de..e6e57d9 100644
--- a/resources/shaders/wisps.frag
+++ b/resources/shaders/wisps.frag
@@ -47,7 +47,8 @@ float getWisps(vec2 texCoords, float gridSize, vec2 seed) {
float radius = mix(0.5, 1.0, hash12(cellID * seed * 19.1249)) * WISPS_RADIUS;
float roundness = mix(-1.0, 1.0, hash12(cellID * seed * 7.51949));
- vec2 offset = vec2(sin(speed * (uTime + 1)) * roundness, cos(speed * (uTime + 1)));
+ vec2 offset = vec2(sin(speed * (uProgress * uDuration + 1)) * roundness,
+ cos(speed * (uProgress * uDuration + 1)));
offset *= 0.5 - 0.5 * radius / gridSize;
offset = vec2(offset.x * cos(rotation) - offset.y * sin(rotation),
offset.x * sin(rotation) + offset.y * cos(rotation));
diff --git a/src/Shader.js b/src/Shader.js
index 718179f..2ae1ad0 100644
--- a/src/Shader.js
+++ b/src/Shader.js
@@ -48,7 +48,7 @@ var Shader = GObject.registerClass(
Signals: {
'begin-animation':
{param_types: [Gio.Settings.$gtype, GObject.TYPE_BOOLEAN, Clutter.Actor.$gtype]},
- 'update-animation': {param_types: [GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE]}
+ 'update-animation': {param_types: [GObject.TYPE_DOUBLE]}
}
},
class Shader extends Shell.GLSLEffect { // --------------------------------------------
@@ -68,17 +68,16 @@ var Shader = GObject.registerClass(
// Store standard uniform locations.
this._uForOpening = this.get_uniform_location('uForOpening');
this._uProgress = this.get_uniform_location('uProgress');
- this._uTime = this.get_uniform_location('uTime');
+ this._uDuration = this.get_uniform_location('uDuration');
this._uSize = this.get_uniform_location('uSize');
this._uPadding = this.get_uniform_location('uPadding');
}
// This is called once each time the shader is used.
- beginAnimation(settings, forOpening, actor) {
+ beginAnimation(settings, forOpening, duration, actor) {
- // Reset progress values.
+ // Reset progress value.
this._progress = 0;
- this._time = 0;
// This is not necessarily symmetric, but I haven't figured out a way to
// get the actual values...
@@ -86,17 +85,18 @@ var Shader = GObject.registerClass(
this.set_uniform_float(this._uPadding, 1, [padding]);
this.set_uniform_float(this._uForOpening, 1, [forOpening]);
+ this.set_uniform_float(this._uDuration, 1, [duration]);
this.set_uniform_float(this._uSize, 2, [actor.width, actor.height]);
this.emit('begin-animation', settings, forOpening, actor);
}
// This is called at each frame during the animation.
- updateAnimation(progress, time) {
- // Store the current time and progress values. The corresponding signal is emitted
- // each frame in vfunc_paint_target.
+ updateAnimation(progress) {
+ // Store the current progress value. The corresponding signal is emitted each frame
+ // in vfunc_paint_target. We do not emit it here, as the pipeline which may be used
+ // by handlers must not have been created yet.
this._progress = progress;
- this._time = time;
}
// This is called by the constructor. This means, it's only called when the
@@ -121,9 +121,8 @@ var Shader = GObject.registerClass(
// We use this vfunc to trigger the update as it allows calling this.get_pipeline() in
// the handler. This could still be null if called from the updateAnimation() above.
vfunc_paint_target(...params) {
- this.emit('update-animation', this._progress, this._time);
+ this.emit('update-animation', this._progress);
this.set_uniform_float(this._uProgress, 1, [this._progress]);
- this.set_uniform_float(this._uTime, 1, [this._time]);
super.vfunc_paint_target(...params);
}
From a182f247cb89620f47a16eab68b4e3e70d1e4b1e Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 07:33:06 +0200
Subject: [PATCH 21/71] :wrench: Pass duration to kwin shaders
---
kwin/main.js.in | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/kwin/main.js.in b/kwin/main.js.in
index 67e6fb5..1e90177 100755
--- a/kwin/main.js.in
+++ b/kwin/main.js.in
@@ -106,6 +106,13 @@ class BMW%NICK%Effect {
uniform: "forOpening",
from: 1.0,
to: 1.0
+ },
+ {
+ type: Effect.ShaderUniform,
+ fragmentShader: this.shader,
+ uniform: "uDuration",
+ from: this.duration,
+ to: this.duration
}
]
});
@@ -140,6 +147,13 @@ class BMW%NICK%Effect {
uniform: "forOpening",
from: 0.0,
to: 0.0
+ },
+ {
+ type: Effect.ShaderUniform,
+ fragmentShader: this.shader,
+ uniform: "uDuration",
+ from: this.duration,
+ to: this.duration
}
]
});
From 3cbbd636291aa4296c540194747b84c510ff59d2 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 07:34:14 +0200
Subject: [PATCH 22/71] :memo: Fix typo
---
resources/shaders/hexagon.frag | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/shaders/hexagon.frag b/resources/shaders/hexagon.frag
index 2900a2a..d550728 100644
--- a/resources/shaders/hexagon.frag
+++ b/resources/shaders/hexagon.frag
@@ -20,7 +20,7 @@ uniform float uLineWidth;
uniform vec4 uGlowColor;
uniform vec4 uLineColor;
-// This methods generates a procedural hexagonal pattern. It returns four values:
+// This method generates a procedural hexagonal pattern. It returns four values:
// result.xy: This contains cell-relative coordinates for the given point.
// [0, 0] is in the center of a cell, [0, 1] at the upper edge,
// [sqrt(4.0 / 3.0), 0] at the right tip and so on.
From f44d0ae5b630983f5584a414db3542af3b5fd840 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 08:13:35 +0200
Subject: [PATCH 23/71] :wrench: Add new kwin effect
---
kwin/build.sh | 47 ++++++++-----
kwin/kwin4_effect_energize_a/config.ui | 80 ++++++++++++++++++++++
kwin/kwin4_effect_energize_a/loadConfig.js | 8 +++
kwin/kwin4_effect_energize_a/main.xml | 16 +++++
kwin/main.js.in | 10 +--
kwin/metadata.desktop.in | 6 +-
6 files changed, 141 insertions(+), 26 deletions(-)
create mode 100755 kwin/kwin4_effect_energize_a/config.ui
create mode 100644 kwin/kwin4_effect_energize_a/loadConfig.js
create mode 100755 kwin/kwin4_effect_energize_a/main.xml
diff --git a/kwin/build.sh b/kwin/build.sh
index 2e2d520..6fa2c74 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -22,30 +22,40 @@ cd "$( cd "$( dirname "$0" )" && pwd )" || \
BUILD_DIR="_build"
-mkdir -p "${BUILD_DIR}"
+mkdir -p "$BUILD_DIR"
-# $1: The nick of the effect (e.g. "tv")
-# $2: The name of the effect (e.g. "TV Effect")
-# $3: A short description of the effect (e.g. "Make windows close like turning off a TV")
+# $1: The nick of the effect (e.g. "energize-a")
+# $2: The name of the effect (e.g. "Energize A")
+# $3: A short description of the effect (e.g. "Beam your windows away")
generate() {
+ # Use the nick for the effect's directory name by replacing dashes by underscoares.
+ DIR_NAME="kwin4_effect_$(echo $1 | tr '-' '_')"
+
+ # Use the name of the effect for the JavaScript class name by removing all spaces.
+ EFFECT_CLASS="BurnMyWindows$(echo $2 | tr -d ' ')"
+
# Create resource directories.
- mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/shaders"
- mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/code"
- mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/config"
- mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/ui"
+ mkdir -p "$BUILD_DIR/$DIR_NAME/contents/shaders"
+ mkdir -p "$BUILD_DIR/$DIR_NAME/contents/code"
+ mkdir -p "$BUILD_DIR/$DIR_NAME/contents/config"
+ mkdir -p "$BUILD_DIR/$DIR_NAME/contents/ui"
- cp "kwin4_effect_$1/main.xml" "${BUILD_DIR}/kwin4_effect_$1/contents/config"
- cp "kwin4_effect_$1/config.ui" "${BUILD_DIR}/kwin4_effect_$1/contents/ui"
+ # Copy the config and ui files.
+ cp "$DIR_NAME/main.xml" "$BUILD_DIR/$DIR_NAME/contents/config"
+ cp "$DIR_NAME/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui"
- perl -pe "s/%LOAD_CONFIG%/$(tr '/' '\f' < "kwin4_effect_$1/loadConfig.js")/g;" \
- main.js.in | tr '\f' '/' > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
+ perl -pe "s/%LOAD_CONFIG%/$(tr '/' '\f' < "$DIR_NAME/loadConfig.js")/g;" \
+ main.js.in | tr '\f' '/' > "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
- perl -pi -e "s/%NICK%/$1/g;" "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
+ perl -pi -e "s/%EFFECT_CLASS%/$EFFECT_CLASS/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
+ perl -pi -e "s/%SHADER_NAME%/$1/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
- perl -pe "s/%NICK%/$1/g;" metadata.desktop.in > "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
- perl -pi -e "s/%NAME%/$2/g;" "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
- perl -pi -e "s/%DESCRIPTION%/$3/g;" "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
+ cp metadata.desktop.in "$BUILD_DIR/$DIR_NAME/metadata.desktop"
+ perl -pi -e "s/%ICON%/$1/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
+ perl -pi -e "s/%NAME%/$2/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
+ perl -pi -e "s/%DESCRIPTION%/$3/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
+ perl -pi -e "s/%DIR_NAME%/$DIR_NAME/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
{
echo "#version 140"
@@ -55,7 +65,7 @@ generate() {
echo ""
cat "../resources/shaders/common.glsl"
cat "../resources/shaders/$1.frag"
- } > "${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1_core.frag"
+ } > "$BUILD_DIR/$DIR_NAME/contents/shaders/$1_core.frag"
{
echo "#define KWIN_LEGACY"
@@ -64,8 +74,9 @@ generate() {
echo ""
cat "../resources/shaders/common.glsl"
cat "../resources/shaders/$1.frag"
- } > "${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1.frag"
+ } > "$BUILD_DIR/$DIR_NAME/contents/shaders/$1.frag"
}
generate "tv" "TV Effect" "Make windows close like turning off a TV"
+generate "energize-a" "Energize A" "Beam your windows away"
# generate "fire" "Fire" "Make windows burn"
\ No newline at end of file
diff --git a/kwin/kwin4_effect_energize_a/config.ui b/kwin/kwin4_effect_energize_a/config.ui
new file mode 100755
index 0000000..1a8d43e
--- /dev/null
+++ b/kwin/kwin4_effect_energize_a/config.ui
@@ -0,0 +1,80 @@
+
+
Date: Fri, 10 Jun 2022 08:24:42 +0200
Subject: [PATCH 24/71] :wrench: Reduce number of implicit calls
---
resources/shaders/apparition.frag | 2 +-
resources/shaders/broken-glass.frag | 8 ++++----
resources/shaders/energize-a.frag | 14 +++++++-------
resources/shaders/energize-b.frag | 16 ++++++++--------
resources/shaders/fire.frag | 16 ++++++++--------
resources/shaders/hexagon.frag | 4 ++--
resources/shaders/matrix.frag | 17 +++++++++--------
resources/shaders/snap.frag | 16 ++++++++--------
resources/shaders/trex.frag | 18 +++++++++---------
resources/shaders/wisps.frag | 14 +++++++-------
10 files changed, 63 insertions(+), 62 deletions(-)
diff --git a/resources/shaders/apparition.frag b/resources/shaders/apparition.frag
index 5f1d8db..1cd17df 100644
--- a/resources/shaders/apparition.frag
+++ b/resources/shaders/apparition.frag
@@ -39,7 +39,7 @@ void main() {
progress * 0.05 * uShake * cos((progress + uSeed.y) * (1.0 + uSeed.y) * uShake);
// "Suck" the texture into the center.
- float dist = length(coords) / sqrt(2);
+ float dist = length(coords) / sqrt(2.0);
coords += progress * coords / dist * 0.5 * uSuction;
// Apply some whirling.
diff --git a/resources/shaders/broken-glass.frag b/resources/shaders/broken-glass.frag
index da5477c..1733575 100644
--- a/resources/shaders/broken-glass.frag
+++ b/resources/shaders/broken-glass.frag
@@ -20,12 +20,12 @@ uniform float uShardScale;
uniform float uBlowForce;
uniform float uGravity;
-const float SHARD_LAYERS = 5;
+const float SHARD_LAYERS = 5.0;
const float ACTOR_SCALE = 2.0;
const float PADDING = ACTOR_SCALE / 2.0 - 0.5;
void main() {
- vec4 oColor = vec4(0, 0, 0, 0);
+ vec4 oColor = vec4(0.0);
float progress = uForOpening ? 1.0 - uProgress : uProgress;
@@ -41,7 +41,7 @@ void main() {
coords -= uEpicenter;
// Scale each layer a bit differently.
- coords /= mix(1.0, 1.0 + uBlowForce * (i + 2) / SHARD_LAYERS, progress);
+ coords /= mix(1.0, 1.0 + uBlowForce * (i + 2.0) / SHARD_LAYERS, progress);
// Rotate each layer a bit differently.
float rotation = (mod(i, 2.0) - 0.5) * 0.2 * progress;
@@ -65,7 +65,7 @@ void main() {
// the bin of the current shard.
float shardGroup = floor(shardMap.g * SHARD_LAYERS * 0.999);
- if (shardGroup == i && (shardMap.x - pow(progress + 0.1, 2)) > 0) {
+ if (shardGroup == i && (shardMap.x - pow(progress + 0.1, 2)) > 0.0) {
oColor = getInputColor(coords);
}
}
diff --git a/resources/shaders/energize-a.frag b/resources/shaders/energize-a.frag
index f94ba5e..775c6c6 100644
--- a/resources/shaders/energize-a.frag
+++ b/resources/shaders/energize-a.frag
@@ -25,10 +25,10 @@ const float EDGE_FADE_WIDTH = 50;
// result.x: A mask for the particles.
// result.y: The opacity of the fading window.
vec2 getMasks(float progress) {
- float fadeInProgress = clamp(progress / FADE_IN_TIME, 0, 1);
- float fadeOutProgress = clamp((progress - FADE_IN_TIME) / FADE_OUT_TIME, 0, 1);
+ float fadeInProgress = clamp(progress / FADE_IN_TIME, 0.0, 1.0);
+ float fadeOutProgress = clamp((progress - FADE_IN_TIME) / FADE_OUT_TIME, 0.0, 1.0);
float heartProgress =
- clamp((progress - (1.0 - HEART_FADE_TIME)) / HEART_FADE_TIME, 0, 1);
+ clamp((progress - (1.0 - HEART_FADE_TIME)) / HEART_FADE_TIME, 0.0, 1.0);
// Compute mask for the "atom" particles.
float dist = length(iTexCoord.st - 0.5) * 4.0;
@@ -41,10 +41,10 @@ vec2 getMasks(float progress) {
atomMask *= edgeFade;
float heartMask = getRelativeEdgeMask(0.5);
- heartMask = 3.0 * pow(heartMask, 5);
+ heartMask = 3.0 * pow(heartMask, 5.0);
heartMask *= fadeOutProgress;
heartMask *= 1.0 - heartProgress;
- atomMask = clamp(heartMask + atomMask, 0, 1);
+ atomMask = clamp(heartMask + atomMask, 0.0, 1.0);
// Compute fading window opacity.
float windowMask = pow(1.0 - fadeOutProgress, 2.0);
@@ -70,7 +70,7 @@ void main() {
scaledUV /= uScale;
// Add molecule particles.
- vec2 uv = scaledUV + vec2(0, 0.1 * uProgress * uDuration);
+ vec2 uv = scaledUV + vec2(0.0, 0.1 * uProgress * uDuration);
uv *= 0.010598 * vec2(0.5 * uSize.x, uSize.y);
float particles = 0.2 * pow((simplex3D(vec3(uv, 0.0 * uProgress * uDuration))), 3.0);
@@ -78,7 +78,7 @@ void main() {
for (int i = 1; i <= 3; ++i) {
vec2 uv = scaledUV * 0.12154 / pow(1.5, i) * uSize;
float atoms = simplex3D(vec3(uv, 2.0 * uProgress * uDuration / i));
- particles += 0.5 * pow(0.2 * (1.0 / (1.0 - atoms) - 1.0), 2);
+ particles += 0.5 * pow(0.2 * (1.0 / (1.0 - atoms) - 1.0), 2.0);
}
oColor.rgb += uColor * particles * masks.x;
diff --git a/resources/shaders/energize-b.frag b/resources/shaders/energize-b.frag
index 703c5e3..2834ae9 100644
--- a/resources/shaders/energize-b.frag
+++ b/resources/shaders/energize-b.frag
@@ -28,22 +28,22 @@ const float EDGE_FADE = 50;
// result.w: The opacity of the fading window.
vec4 getMasks(float progress) {
float showerProgress = progress / SHOWER_TIME;
- float streakProgress = clamp((progress - SHOWER_TIME) / STREAK_TIME, 0, 1);
- float fadeProgress = clamp((progress - SHOWER_TIME) / (1.0 - SHOWER_TIME), 0, 1);
+ float streakProgress = clamp((progress - SHOWER_TIME) / STREAK_TIME, 0.0, 1.0);
+ float fadeProgress = clamp((progress - SHOWER_TIME) / (1.0 - SHOWER_TIME), 0.0, 1.0);
// Gradient from top to bottom.
float t = iTexCoord.t;
// A smooth gradient which moves to the bottom within the showerProgress.
float showerMask =
- smoothstep(1, 0, abs(showerProgress - t - SHOWER_WIDTH) / SHOWER_WIDTH);
+ smoothstep(1.0, 0.0, abs(showerProgress - t - SHOWER_WIDTH) / SHOWER_WIDTH);
// This is 1 above the streak mask.
- float streakMask = (showerProgress - t - SHOWER_WIDTH) > 0 ? 1 : 0;
+ float streakMask = (showerProgress - t - SHOWER_WIDTH) > 0.0 ? 1.0 : 0.0;
// Compute mask for the "atom" particles.
float atomMask = getRelativeEdgeMask(0.2);
- atomMask = max(0, atomMask - showerMask);
+ atomMask = max(0.0, atomMask - showerMask);
atomMask *= streakMask;
atomMask *= sqrt(1 - fadeProgress * fadeProgress);
@@ -84,21 +84,21 @@ void main() {
oColor.a = oColor.a * masks.w;
// Add leading shower particles.
- vec2 showerUV = iTexCoord.st + vec2(0, -0.7 * progress / SHOWER_TIME);
+ vec2 showerUV = iTexCoord.st + vec2(0.0, -0.7 * progress / SHOWER_TIME);
showerUV *= 0.02 * uSize / uScale;
float shower = pow(simplex2D(showerUV), 10.0);
oColor.rgb += uColor * shower * masks.x;
oColor.a += shower * masks.x;
// Add trailing streak lines.
- vec2 streakUV = iTexCoord.st + vec2(0, -progress / SHOWER_TIME);
+ vec2 streakUV = iTexCoord.st + vec2(0.0, -progress / SHOWER_TIME);
streakUV *= vec2(0.05 * uSize.x, 0.001 * uSize.y) / uScale;
float streaks = simplex2DFractal(streakUV) * 0.5;
oColor.rgb += uColor * streaks * masks.y;
oColor.a += streaks * masks.y;
// Add glimmering atoms.
- vec2 atomUV = iTexCoord.st + vec2(0, -0.025 * progress / SHOWER_TIME);
+ vec2 atomUV = iTexCoord.st + vec2(0.0, -0.025 * progress / SHOWER_TIME);
atomUV *= 0.2 * uSize / uScale;
float atoms = pow((simplex3D(vec3(atomUV, uProgress * uDuration))), 5.0);
oColor.rgb += uColor * atoms * masks.z;
diff --git a/resources/shaders/fire.frag b/resources/shaders/fire.frag
index 0ebce5c..099dcc2 100644
--- a/resources/shaders/fire.frag
+++ b/resources/shaders/fire.frag
@@ -23,7 +23,7 @@ uniform vec4 uGradient4;
uniform vec4 uGradient5;
// These may be configurable in the future.
-const float EDGE_FADE = 70;
+const float EDGE_FADE = 70.0;
const float FADE_WIDTH = 0.1;
const float HIDE_TIME = 0.4;
@@ -59,22 +59,22 @@ vec4 getFireColor(float v) {
vec2 effectMask(float hideTime, float fadeWidth, float edgeFadeWidth) {
float progress = easeOutQuad(uProgress);
- float burnProgress = clamp(progress / hideTime, 0, 1);
- float afterBurnProgress = clamp((progress - hideTime) / (1 - hideTime), 0, 1);
+ float burnProgress = clamp(progress / hideTime, 0.0, 1.0);
+ float afterBurnProgress = clamp((progress - hideTime) / (1.0 - hideTime), 0.0, 1.0);
// Gradient from top to bottom.
- float t = iTexCoord.t * (1 - fadeWidth);
+ float t = iTexCoord.t * (1.0 - fadeWidth);
// Visible part of the window. Gradually dissolves towards the bottom.
- float windowMask = 1 - clamp((burnProgress - t) / fadeWidth, 0, 1);
+ float windowMask = 1.0 - clamp((burnProgress - t) / fadeWidth, 0.0, 1.0);
// Gradient from top burning window.
- float effectMask = clamp(t * (1 - windowMask) / burnProgress, 0, 1);
+ float effectMask = clamp(t * (1.0 - windowMask) / burnProgress, 0.0, 1.0);
// Fade-out when the window burned down.
if (progress > hideTime) {
- float fade = sqrt(1 - afterBurnProgress * afterBurnProgress);
- effectMask *= mix(1, 1 - t, afterBurnProgress) * fade;
+ float fade = sqrt(1.0 - afterBurnProgress * afterBurnProgress);
+ effectMask *= mix(1.0, 1.0 - t, afterBurnProgress) * fade;
}
// Fade at window borders.
diff --git a/resources/shaders/hexagon.frag b/resources/shaders/hexagon.frag
index d550728..3319ef3 100644
--- a/resources/shaders/hexagon.frag
+++ b/resources/shaders/hexagon.frag
@@ -73,8 +73,8 @@ void main() {
// glowProgress fades in in the first half of the animation, tileProgress fades
// in in the second half.
- float glowProgress = smoothstep(0, 1, clamp(progress / 0.5, 0, 1));
- float tileProgress = smoothstep(0, 1, clamp((progress - 0.5) / 0.5, 0, 1));
+ float glowProgress = smoothstep(0.0, 1.0, clamp(progress / 0.5, 0.0, 1.0));
+ float tileProgress = smoothstep(0.0, 1.0, clamp((progress - 0.5) / 0.5, 0.0, 1.0));
vec2 texScale = 0.1 * uSize / uScale;
vec4 hex = getHexagons(iTexCoord.st * texScale);
diff --git a/resources/shaders/matrix.frag b/resources/shaders/matrix.frag
index 5191238..119cb07 100644
--- a/resources/shaders/matrix.frag
+++ b/resources/shaders/matrix.frag
@@ -21,8 +21,8 @@ uniform float uRandomness;
uniform float uOverShoot;
// These may be configurable in the future.
-const float EDGE_FADE = 30;
-const float FADE_WIDTH = 150;
+const float EDGE_FADE = 30.0;
+const float FADE_WIDTH = 150.0;
const float TRAIL_LENGTH = 0.2;
const float FINAL_FADE_START_TIME = 0.8;
const float LETTER_TILES = 16.0;
@@ -55,8 +55,8 @@ vec2 getRain(vec2 fragCoord) {
float distToDrop = (uProgress * 2 - delay) * speed - iTexCoord.y;
- float rainAlpha = distToDrop >= 0 ? exp(-distToDrop / TRAIL_LENGTH) : 0;
- float windowAlpha = 1 - clamp(uSize.y * distToDrop, 0, FADE_WIDTH) / FADE_WIDTH;
+ float rainAlpha = distToDrop >= 0.0 ? exp(-distToDrop / TRAIL_LENGTH) : 0.0;
+ float windowAlpha = 1.0 - clamp(uSize.y * distToDrop, 0.0, FADE_WIDTH) / FADE_WIDTH;
// Fade at window borders.
rainAlpha *= getAbsoluteEdgeMask(EDGE_FADE, 0.5);
@@ -64,8 +64,8 @@ vec2 getRain(vec2 fragCoord) {
// Add some variation to the drop start and end position.
float shorten =
fract(sin(column + 42.0) * 33.423) * mix(0.0, uOverShoot * 0.25, uRandomness);
- rainAlpha *= smoothstep(0, 1, clamp(iTexCoord.y / shorten, 0, 1));
- rainAlpha *= smoothstep(0, 1, clamp((1.0 - iTexCoord.y) / shorten, 0, 1));
+ rainAlpha *= smoothstep(0.0, 1.0, clamp(iTexCoord.y / shorten, 0.0, 1.0));
+ rainAlpha *= smoothstep(0.0, 1.0, clamp((1.0 - iTexCoord.y) / shorten, 0.0, 1.0));
if (uForOpening) {
windowAlpha = 1.0 - windowAlpha;
@@ -90,11 +90,12 @@ void main() {
// This is used to fade out the remaining trails in the end.
float finalFade =
- 1 - clamp((uProgress - FINAL_FADE_START_TIME) / (1 - FINAL_FADE_START_TIME), 0, 1);
+ 1 -
+ clamp((uProgress - FINAL_FADE_START_TIME) / (1.0 - FINAL_FADE_START_TIME), 0.0, 1.0);
float rainAlpha = finalFade * rainMask.x;
// Add the matrix effect to the window.
- vec4 text = vec4(mix(uTrailColor, uTipColor, min(1, pow(rainAlpha + 0.1, 4))),
+ vec4 text = vec4(mix(uTrailColor, uTipColor, min(1.0, pow(rainAlpha + 0.1, 4.0))),
rainAlpha * textMask);
oColor = alphaOver(oColor, text);
diff --git a/resources/shaders/snap.frag b/resources/shaders/snap.frag
index 25a69bf..530ab04 100644
--- a/resources/shaders/snap.frag
+++ b/resources/shaders/snap.frag
@@ -18,7 +18,7 @@ uniform vec4 uDustColor;
uniform vec2 uSeed;
uniform float uDustScale;
-const float DUST_LAYERS = 4;
+const float DUST_LAYERS = 4.0;
const float GROW_INTENSITY = 0.05;
const float SHRINK_INTENSITY = 0.05;
const float WIND_INTENSITY = 0.05;
@@ -32,35 +32,35 @@ void main() {
float gradient = iTexCoord.t * ACTOR_SCALE - PADDING;
progress = 2.0 - gradient - 2.0 * progress;
progress = progress + 0.25 - 0.5 * simplex2D((iTexCoord.st + uSeed) * 2.0);
- progress = pow(max(0, progress), 2.0);
+ progress = pow(max(0.0, progress), 2.0);
vec4 oColor = vec4(0.0);
for (float i = 0; i < DUST_LAYERS; ++i) {
// Create a random direction.
- float factor = DUST_LAYERS == 1 ? 0 : i / (DUST_LAYERS - 1);
+ float factor = DUST_LAYERS == 1.0 ? 0.0 : i / (DUST_LAYERS - 1.0);
float angle = 123.123 * (uSeed.x + factor);
vec2 direction = vec2(1.0, 0.0);
direction = rotate(direction, angle);
// Flip direction for one side of the window.
vec2 coords = iTexCoord.st * ACTOR_SCALE - PADDING - 0.5;
- if (getWinding(direction, coords) > 0) {
- direction *= -1;
+ if (getWinding(direction, coords) > 0.0) {
+ direction *= -1.0;
}
// Flip direction for half the layers.
if (factor > 0.5) {
- direction *= -1;
+ direction *= -1.0;
}
// We grow the layer along the random direction, shrink it orthogonally to it
// and scale it up slightly.
float dist = distToLine(vec2(0.0), direction, coords);
- vec2 grow = direction * dist * mix(0, GROW_INTENSITY, progress);
+ vec2 grow = direction * dist * mix(0.0, GROW_INTENSITY, progress);
vec2 shrink =
- vec2(direction.y, -direction.x) * dist * mix(0, SHRINK_INTENSITY, progress);
+ vec2(direction.y, -direction.x) * dist * mix(0.0, SHRINK_INTENSITY, progress);
float scale = mix(1.0, 1.05, factor * progress);
coords = (coords + grow + shrink) / scale;
diff --git a/resources/shaders/trex.frag b/resources/shaders/trex.frag
index ecb74f4..b208004 100644
--- a/resources/shaders/trex.frag
+++ b/resources/shaders/trex.frag
@@ -41,7 +41,7 @@ vec2 getClawUV(vec2 texCoords, float gridScale, vec2 seed) {
coords *= gridScale;
// Get grid cell coordinates in [0..1].
- vec2 cellUV = mod(coords, vec2(1));
+ vec2 cellUV = mod(coords, vec2(1.0));
// This is unique for each cell.
vec2 cellID = coords - cellUV + vec2(362.456);
@@ -61,7 +61,7 @@ vec2 getClawUV(vec2 texCoords, float gridScale, vec2 seed) {
cellUV += 0.5;
// Clamp resulting coordinates.
- return clamp(cellUV, vec2(0), vec2(1));
+ return clamp(cellUV, vec2(0.0), vec2(1.0));
}
void main() {
@@ -84,7 +84,7 @@ void main() {
for (int i = 0; i < uNumClaws; ++i) {
vec2 uv = getClawUV(coords, 1.0 / uClawSize, uSeed * (i + 1));
float delay = i / uNumClaws * MAX_SPAWN_TIME;
- scratchMap = min(scratchMap, clamp(texture2D(uClawTexture, uv).r + delay, 0, 1));
+ scratchMap = min(scratchMap, clamp(texture2D(uClawTexture, uv).r + delay, 0.0, 1.0));
}
// Get the window texture. We shift the texture lookup by the local derivative of
@@ -93,9 +93,9 @@ void main() {
vec4 oColor = getInputColor(coords + offset);
// Add colorful flashes.
- float flashIntensity = 1.0 / FLASH_INTENSITY * (scratchMap - progress) + 1;
- if (flashIntensity < 0 || flashIntensity >= 1) {
- flashIntensity = 0;
+ float flashIntensity = 1.0 / FLASH_INTENSITY * (scratchMap - progress) + 1.0;
+ if (flashIntensity < 0.0 || flashIntensity >= 1.0) {
+ flashIntensity = 0.0;
}
// Hide flashes where there is now window.
@@ -103,14 +103,14 @@ void main() {
flash.a *= flashIntensity * oColor.a * (1.0 - progress);
// Hide scratched out parts.
- oColor.a *= (scratchMap > progress ? 1 : 0);
+ oColor.a *= (scratchMap > progress ? 1.0 : 0.0);
// Add flash color.
oColor = alphaOver(oColor, flash);
// Fade out the remaining shards.
- float fadeProgress = smoothstep(0, 1, (progress - 1.0 + FF_TIME) / FF_TIME);
- oColor.a *= sqrt(1 - fadeProgress * fadeProgress);
+ float fadeProgress = smoothstep(0.0, 1.0, (progress - 1.0 + FF_TIME) / FF_TIME);
+ oColor.a *= sqrt(1.0 - fadeProgress * fadeProgress);
// These are pretty useful for understanding how this works.
// oColor = vec4(vec3(flashIntensity), 1);
diff --git a/resources/shaders/wisps.frag b/resources/shaders/wisps.frag
index e6e57d9..08a3c05 100644
--- a/resources/shaders/wisps.frag
+++ b/resources/shaders/wisps.frag
@@ -19,7 +19,7 @@ uniform float uScale;
const float WISPS_RADIUS = 20.0;
const float WISPS_SPEED = 10.0;
-const float WISPS_SPACING = 40 + WISPS_RADIUS;
+const float WISPS_SPACING = 40.0 + WISPS_RADIUS;
const int WISPS_LAYERS = 8;
const float WISPS_IN_TIME = 0.5;
const float WINDOW_OUT_TIME = 1.0;
@@ -36,7 +36,7 @@ float getWisps(vec2 texCoords, float gridSize, vec2 seed) {
coords /= gridSize;
// Get grid cell coordinates in [0..1].
- vec2 cellUV = mod(coords, vec2(1));
+ vec2 cellUV = mod(coords, vec2(1.0));
// This is unique for each cell.
vec2 cellID = coords - cellUV + vec2(362.456);
@@ -77,7 +77,7 @@ void main() {
// Compute several layers of moving wisps.
vec2 uv = (iTexCoord.st - 0.5) / mix(1.0, 0.5, progress) + 0.5;
uv /= uScale;
- float wisps = 0;
+ float wisps = 0.0;
for (int i = 0; i < WISPS_LAYERS; ++i) {
wisps += getWisps(uv * 0.3, WISPS_SPACING, uSeed * (i + 1));
}
@@ -86,10 +86,10 @@ void main() {
float mask = getRelativeEdgeMask(mix(0.01, 0.5, progress));
// Compute three different progress values.
- float wispsIn = smoothstep(0, 1, clamp(progress / WISPS_IN_TIME, 0, 1));
- float wispsOut =
- smoothstep(0, 1, clamp((progress - WISPS_IN_TIME) / (1.0 - WISPS_IN_TIME), 0, 1));
- float windowOut = smoothstep(0, 1, clamp(progress / WINDOW_OUT_TIME, 0, 1));
+ float wispsIn = smoothstep(0.0, 1.0, clamp(progress / WISPS_IN_TIME, 0.0, 1.0));
+ float wispsOut = smoothstep(
+ 0.0, 1.0, clamp((progress - WISPS_IN_TIME) / (1.0 - WISPS_IN_TIME), 0.0, 1.0));
+ float windowOut = smoothstep(0.0, 1.0, clamp(progress / WINDOW_OUT_TIME, 0.0, 1.0));
// Use a noise function to dissolve the window.
float noise = smoothstep(1.0, 0.0, abs(2.0 * simplex2DFractal(uv * uSize / 250) - 1.0));
From 4e5084bdbad91d95d34dd7e57cd6e563a59ea0fc Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 10:29:12 +0200
Subject: [PATCH 25/71] :wrench: Use correct duration
---
kwin/main.js.in | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kwin/main.js.in b/kwin/main.js.in
index f954693..13452bc 100755
--- a/kwin/main.js.in
+++ b/kwin/main.js.in
@@ -111,8 +111,8 @@ class %EFFECT_CLASS% {
type: Effect.ShaderUniform,
fragmentShader: this.shader,
uniform: "uDuration",
- from: this.duration,
- to: this.duration
+ from: this.duration * 0.001,
+ to: this.duration * 0.001
}
]
});
@@ -152,8 +152,8 @@ class %EFFECT_CLASS% {
type: Effect.ShaderUniform,
fragmentShader: this.shader,
uniform: "uDuration",
- from: this.duration,
- to: this.duration
+ from: this.duration * 0.001,
+ to: this.duration * 0.001
}
]
});
From 9f8258b9f870bd3b716e16c7d0e575ea81fe41ef Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 10:29:29 +0200
Subject: [PATCH 26/71] :wrench: Fix setting of window size
---
resources/shaders/common.glsl | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl
index a1026c0..3ec9fb9 100644
--- a/resources/shaders/common.glsl
+++ b/resources/shaders/common.glsl
@@ -38,8 +38,8 @@
uniform float forOpening;
uniform sampler2D sampler;
uniform float uDuration;
-uniform float textureWidth;
-uniform float textureHeight;
+uniform int textureWidth;
+uniform int textureHeight;
uniform float animationProgress;
vec2 uSize = vec2(textureWidth, textureHeight);
@@ -71,8 +71,8 @@ void setOutputColor(vec4 outColor) {
uniform float forOpening;
uniform sampler2D sampler;
uniform float uDuration;
-uniform float textureWidth;
-uniform float textureHeight;
+uniform int textureWidth;
+uniform int textureHeight;
uniform float animationProgress;
vec2 uSize = vec2(textureWidth, textureHeight);
From bfc3467e332d9079de0dd9e7694cf9864ec08275 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 10:29:47 +0200
Subject: [PATCH 27/71] :wrench: Fixes for kwin
---
resources/shaders/energize-a.frag | 10 +++++-----
resources/shaders/energize-b.frag | 12 ++++++------
src/EnergizeA.js | 2 +-
src/EnergizeB.js | 2 +-
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/resources/shaders/energize-a.frag b/resources/shaders/energize-a.frag
index 775c6c6..6869dd7 100644
--- a/resources/shaders/energize-a.frag
+++ b/resources/shaders/energize-a.frag
@@ -13,13 +13,13 @@
// The content from common.glsl is automatically prepended to each shader effect.
-uniform vec3 uColor;
+uniform vec4 uColor;
uniform float uScale;
const float FADE_IN_TIME = 0.3;
const float FADE_OUT_TIME = 0.6;
const float HEART_FADE_TIME = 0.3;
-const float EDGE_FADE_WIDTH = 50;
+const float EDGE_FADE_WIDTH = 50.0;
// This method returns two values:
// result.x: A mask for the particles.
@@ -63,7 +63,7 @@ void main() {
vec4 oColor = getInputColor(iTexCoord.st);
// Dissolve window to effect color / transparency.
- oColor.rgb = mix(uColor, oColor.rgb, 0.2 * masks.y + 0.8);
+ oColor.rgb = mix(uColor.rgb, oColor.rgb, 0.2 * masks.y + 0.8);
oColor.a = oColor.a * masks.y;
vec2 scaledUV = (iTexCoord.st - 0.5) * (1.0 + 0.1 * progress);
@@ -75,13 +75,13 @@ void main() {
float particles = 0.2 * pow((simplex3D(vec3(uv, 0.0 * uProgress * uDuration))), 3.0);
// Add more molecule particles.
- for (int i = 1; i <= 3; ++i) {
+ for (float i = 1.0; i <= 3.0; ++i) {
vec2 uv = scaledUV * 0.12154 / pow(1.5, i) * uSize;
float atoms = simplex3D(vec3(uv, 2.0 * uProgress * uDuration / i));
particles += 0.5 * pow(0.2 * (1.0 / (1.0 - atoms) - 1.0), 2.0);
}
- oColor.rgb += uColor * particles * masks.x;
+ oColor.rgb += uColor.rgb * particles * masks.x;
oColor.a += particles * masks.x;
// These are pretty useful for understanding how this works.
diff --git a/resources/shaders/energize-b.frag b/resources/shaders/energize-b.frag
index 2834ae9..df40402 100644
--- a/resources/shaders/energize-b.frag
+++ b/resources/shaders/energize-b.frag
@@ -13,13 +13,13 @@
// The content from common.glsl is automatically prepended to each shader effect.
-uniform vec3 uColor;
+uniform vec4 uColor;
uniform float uScale;
const float SHOWER_TIME = 0.3;
const float SHOWER_WIDTH = 0.3;
const float STREAK_TIME = 0.6;
-const float EDGE_FADE = 50;
+const float EDGE_FADE = 50.0;
// This method returns four values:
// result.x: A mask for the particles which lead the shower.
@@ -80,28 +80,28 @@ void main() {
vec4 oColor = getInputColor(iTexCoord.st);
// Dissolve window to effect color / transparency.
- oColor.rgb = mix(uColor, oColor.rgb, 0.5 * masks.w + 0.5);
+ oColor.rgb = mix(uColor.rgb, oColor.rgb, 0.5 * masks.w + 0.5);
oColor.a = oColor.a * masks.w;
// Add leading shower particles.
vec2 showerUV = iTexCoord.st + vec2(0.0, -0.7 * progress / SHOWER_TIME);
showerUV *= 0.02 * uSize / uScale;
float shower = pow(simplex2D(showerUV), 10.0);
- oColor.rgb += uColor * shower * masks.x;
+ oColor.rgb += uColor.rgb * shower * masks.x;
oColor.a += shower * masks.x;
// Add trailing streak lines.
vec2 streakUV = iTexCoord.st + vec2(0.0, -progress / SHOWER_TIME);
streakUV *= vec2(0.05 * uSize.x, 0.001 * uSize.y) / uScale;
float streaks = simplex2DFractal(streakUV) * 0.5;
- oColor.rgb += uColor * streaks * masks.y;
+ oColor.rgb += uColor.rgb * streaks * masks.y;
oColor.a += streaks * masks.y;
// Add glimmering atoms.
vec2 atomUV = iTexCoord.st + vec2(0.0, -0.025 * progress / SHOWER_TIME);
atomUV *= 0.2 * uSize / uScale;
float atoms = pow((simplex3D(vec3(atomUV, uProgress * uDuration))), 5.0);
- oColor.rgb += uColor * atoms * masks.z;
+ oColor.rgb += uColor.rgb * atoms * masks.z;
oColor.a += atoms * masks.z;
// These are pretty useful for understanding how this works.
diff --git a/src/EnergizeA.js b/src/EnergizeA.js
index 1064c7e..4d76cc6 100644
--- a/src/EnergizeA.js
+++ b/src/EnergizeA.js
@@ -51,7 +51,7 @@ var EnergizeA = class {
const c = Clutter.Color.from_string(settings.get_string('energize-a-color'))[1];
// clang-format off
- shader.set_uniform_float(shader._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
+ shader.set_uniform_float(shader._uColor, 4, [c.red / 255, c.green / 255, c.blue / 255, 1.0]);
shader.set_uniform_float(shader._uScale, 1, [settings.get_double('energize-a-scale')]);
// clang-format on
});
diff --git a/src/EnergizeB.js b/src/EnergizeB.js
index 0123857..9640f83 100644
--- a/src/EnergizeB.js
+++ b/src/EnergizeB.js
@@ -51,7 +51,7 @@ var EnergizeB = class {
const c = Clutter.Color.from_string(settings.get_string('energize-b-color'))[1];
// clang-format off
- shader.set_uniform_float(shader._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
+ shader.set_uniform_float(shader._uColor, 4, [c.red / 255, c.green / 255, c.blue / 255, 1.0]);
shader.set_uniform_float(shader._uScale, 1, [settings.get_double('energize-b-scale')]);
// clang-format on
});
From 2056130e98895d13979a2c6176735bdbad9265b2 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 10:42:04 +0200
Subject: [PATCH 28/71] :wrench: Fixes for kwin
---
kwin/kwin4_effect_energize_a/config.ui | 4 ++--
kwin/kwin4_effect_tv/config.ui | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kwin/kwin4_effect_energize_a/config.ui b/kwin/kwin4_effect_energize_a/config.ui
index 1a8d43e..1bbe11b 100755
--- a/kwin/kwin4_effect_energize_a/config.ui
+++ b/kwin/kwin4_effect_energize_a/config.ui
@@ -1,7 +1,7 @@
Date: Fri, 10 Jun 2022 10:42:59 +0200
Subject: [PATCH 29/71] :wrench: Fix shellcheck issues
---
kwin/build.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 6fa2c74..359277d 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -30,10 +30,10 @@ mkdir -p "$BUILD_DIR"
generate() {
# Use the nick for the effect's directory name by replacing dashes by underscoares.
- DIR_NAME="kwin4_effect_$(echo $1 | tr '-' '_')"
+ DIR_NAME="kwin4_effect_$(echo "$1" | tr '-' '_')"
# Use the name of the effect for the JavaScript class name by removing all spaces.
- EFFECT_CLASS="BurnMyWindows$(echo $2 | tr -d ' ')"
+ EFFECT_CLASS="BurnMyWindows$(echo "$2" | tr -d ' ')"
# Create resource directories.
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/shaders"
From d7859145c362ebf2db5305dc73e7d7a701b22dde Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 11:04:03 +0200
Subject: [PATCH 30/71] :wrench: Update kwin settings ui
---
kwin/kwin4_effect_energize_a/config.ui | 171 ++++++++++++++-----------
kwin/kwin4_effect_tv/config.ui | 148 ++++++++++-----------
2 files changed, 165 insertions(+), 154 deletions(-)
diff --git a/kwin/kwin4_effect_energize_a/config.ui b/kwin/kwin4_effect_energize_a/config.ui
index 1bbe11b..56ad8db 100755
--- a/kwin/kwin4_effect_energize_a/config.ui
+++ b/kwin/kwin4_effect_energize_a/config.ui
@@ -1,80 +1,97 @@
Date: Fri, 10 Jun 2022 11:07:41 +0200
Subject: [PATCH 31/71] :wrench: Load defaults from settings
---
kwin/kwin4_effect_energize_a/loadConfig.js | 5 +----
kwin/kwin4_effect_energize_a/main.xml | 2 +-
kwin/kwin4_effect_tv/loadConfig.js | 5 +----
kwin/kwin4_effect_tv/main.xml | 2 +-
4 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/kwin/kwin4_effect_energize_a/loadConfig.js b/kwin/kwin4_effect_energize_a/loadConfig.js
index 80eb995..bda8a0b 100644
--- a/kwin/kwin4_effect_energize_a/loadConfig.js
+++ b/kwin/kwin4_effect_energize_a/loadConfig.js
@@ -1,8 +1,5 @@
loadConfig() {
- const defaultDuration = 2000;
- const duration = effect.readConfig('Duration', defaultDuration) || defaultDuration;
- this.duration = animationTime(duration);
-
+ this.duration = animationTime(effect.readConfig('Duration', 1000));
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
}
\ No newline at end of file
diff --git a/kwin/kwin4_effect_energize_a/main.xml b/kwin/kwin4_effect_energize_a/main.xml
index 0e767f5..13897a3 100755
--- a/kwin/kwin4_effect_energize_a/main.xml
+++ b/kwin/kwin4_effect_energize_a/main.xml
@@ -4,7 +4,7 @@
Date: Fri, 10 Jun 2022 11:07:56 +0200
Subject: [PATCH 32/71] :tada: Add new kwin effect
---
kwin/build.sh | 1 +
kwin/kwin4_effect_energize_b/config.ui | 97 ++++++++++++++++++++++
kwin/kwin4_effect_energize_b/loadConfig.js | 5 ++
kwin/kwin4_effect_energize_b/main.xml | 16 ++++
4 files changed, 119 insertions(+)
create mode 100755 kwin/kwin4_effect_energize_b/config.ui
create mode 100644 kwin/kwin4_effect_energize_b/loadConfig.js
create mode 100755 kwin/kwin4_effect_energize_b/main.xml
diff --git a/kwin/build.sh b/kwin/build.sh
index 359277d..fdc7463 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -79,4 +79,5 @@ generate() {
generate "tv" "TV Effect" "Make windows close like turning off a TV"
generate "energize-a" "Energize A" "Beam your windows away"
+generate "energize-b" "Energize B" "sing different transporter technology results in an alternative visual effect"
# generate "fire" "Fire" "Make windows burn"
\ No newline at end of file
diff --git a/kwin/kwin4_effect_energize_b/config.ui b/kwin/kwin4_effect_energize_b/config.ui
new file mode 100755
index 0000000..56ad8db
--- /dev/null
+++ b/kwin/kwin4_effect_energize_b/config.ui
@@ -0,0 +1,97 @@
+
+
Date: Fri, 10 Jun 2022 11:10:10 +0200
Subject: [PATCH 33/71] :wrench: Fix typo
---
kwin/build.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index fdc7463..dfe2268 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -79,5 +79,5 @@ generate() {
generate "tv" "TV Effect" "Make windows close like turning off a TV"
generate "energize-a" "Energize A" "Beam your windows away"
-generate "energize-b" "Energize B" "sing different transporter technology results in an alternative visual effect"
+generate "energize-b" "Energize B" "Using different transporter technology results in an alternative visual effect"
# generate "fire" "Fire" "Make windows burn"
\ No newline at end of file
From 4d77635e78e8a17289c9e21e9427976e5a5ec5ce Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 11:45:59 +0200
Subject: [PATCH 34/71] :wrench: Fix implicit conversion
---
resources/shaders/energize-b.frag | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/shaders/energize-b.frag b/resources/shaders/energize-b.frag
index df40402..e61e26b 100644
--- a/resources/shaders/energize-b.frag
+++ b/resources/shaders/energize-b.frag
@@ -45,7 +45,7 @@ vec4 getMasks(float progress) {
float atomMask = getRelativeEdgeMask(0.2);
atomMask = max(0.0, atomMask - showerMask);
atomMask *= streakMask;
- atomMask *= sqrt(1 - fadeProgress * fadeProgress);
+ atomMask *= sqrt(1.0 - fadeProgress * fadeProgress);
// Make some particles visible in the streaks.
showerMask += 0.05 * streakMask;
From 192719739ce88b283ff7b25d89369e6cabbb737d Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 11:48:31 +0200
Subject: [PATCH 35/71] :wrench: Flip texture coordinates for kwin
---
resources/shaders/common.glsl | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl
index 3ec9fb9..fbced17 100644
--- a/resources/shaders/common.glsl
+++ b/resources/shaders/common.glsl
@@ -42,18 +42,17 @@ uniform int textureWidth;
uniform int textureHeight;
uniform float animationProgress;
-vec2 uSize = vec2(textureWidth, textureHeight);
-bool uForOpening = forOpening == 1.0;
-
in vec2 texcoord0;
out vec4 fragColor;
-#define uProgress animationProgress
-#define uPadding 0.0
-#define iTexCoord texcoord0
+vec2 uSize = vec2(textureWidth, textureHeight);
+bool uForOpening = forOpening == 1.0;
+vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
+float uProgress = animationProgress;
+float uPadding = 0.0;
vec4 getInputColor(vec2 coords) {
- vec4 color = texture2D(sampler, coords);
+ vec4 color = texture2D(sampler, vec2(coords.x, 1.0 - coords.y));
if (color.a > 0.0) {
color.rgb /= color.a;
@@ -75,17 +74,16 @@ uniform int textureWidth;
uniform int textureHeight;
uniform float animationProgress;
-vec2 uSize = vec2(textureWidth, textureHeight);
-bool uForOpening = forOpening == 1.0;
-
varying vec2 texcoord0;
-#define uProgress animationProgress
-#define uPadding 0.0
-#define iTexCoord texcoord0
+vec2 uSize = vec2(textureWidth, textureHeight);
+bool uForOpening = forOpening == 1.0;
+vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
+float uProgress = animationProgress;
+float uPadding = 0.0;
vec4 getInputColor(vec2 coords) {
- vec4 color = texture2D(sampler, coords);
+ vec4 color = texture2D(sampler, vec2(coords.x, 1.0 - coords.y));
if (color.a > 0.0) {
color.rgb /= color.a;
From d08c318b7da04ac3893df7c0d4a0e62a228e2d2e Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 13:57:21 +0200
Subject: [PATCH 36/71] :wrench: Tweak kwin build process
---
kwin/build.sh | 38 ++++++++++++++----
kwin/kwin4_effect_energize_a/loadConfig.js | 5 ---
.../onSettingsChanged.js | 6 +++
kwin/kwin4_effect_energize_b/loadConfig.js | 5 ---
.../onSettingsChanged.js | 6 +++
kwin/kwin4_effect_tv/loadConfig.js | 4 --
kwin/kwin4_effect_tv/onSettingsChanged.js | 5 +++
kwin/main.js.in | 39 ++++++++++---------
resources/shaders/common.glsl | 29 +++++---------
9 files changed, 77 insertions(+), 60 deletions(-)
delete mode 100644 kwin/kwin4_effect_energize_a/loadConfig.js
create mode 100644 kwin/kwin4_effect_energize_a/onSettingsChanged.js
delete mode 100644 kwin/kwin4_effect_energize_b/loadConfig.js
create mode 100644 kwin/kwin4_effect_energize_b/onSettingsChanged.js
delete mode 100644 kwin/kwin4_effect_tv/loadConfig.js
create mode 100644 kwin/kwin4_effect_tv/onSettingsChanged.js
diff --git a/kwin/build.sh b/kwin/build.sh
index dfe2268..2811fed 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -41,15 +41,34 @@ generate() {
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/config"
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/ui"
- # Copy the config and ui files.
- cp "$DIR_NAME/main.xml" "$BUILD_DIR/$DIR_NAME/contents/config"
- cp "$DIR_NAME/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui"
+ # Copy the config file if it exists.
+ if [ -f "$DIR_NAME/main.xml" ]; then
+ cp "$DIR_NAME/main.xml" "$BUILD_DIR/$DIR_NAME/contents/config"
+ fi
- perl -pe "s/%LOAD_CONFIG%/$(tr '/' '\f' < "$DIR_NAME/loadConfig.js")/g;" \
- main.js.in | tr '\f' '/' > "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
+ # Copy the ui file if it exists.
+ if [ -f "$DIR_NAME/config.ui" ]; then
+ cp "$DIR_NAME/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui"
+ fi
- perl -pi -e "s/%EFFECT_CLASS%/$EFFECT_CLASS/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
- perl -pi -e "s/%SHADER_NAME%/$1/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
+
+ ON_SETTINGS_CHANGE=""
+ ON_ANIMATION_BEGIN=""
+
+ if [ -f "$DIR_NAME/onSettingsChanged.js" ]; then
+ ON_SETTINGS_CHANGE=$(tr '/' '\f' < "$DIR_NAME/onSettingsChanged.js")
+ fi
+
+ if [ -f "$DIR_NAME/onAnimationBegin.js" ]; then
+ ON_ANIMATION_BEGIN=$(tr '/' '\f' < "$DIR_NAME/onAnimationBegin.js")
+ fi
+
+ cp main.js.in "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
+ perl -pi -e "s/%ON_SETTINGS_CHANGE%/$ON_SETTINGS_CHANGE/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
+ perl -pi -e "s/%ON_ANIMATION_BEGIN%/$ON_ANIMATION_BEGIN/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
+ perl -pi -e "s/%EFFECT_CLASS%/$EFFECT_CLASS/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
+ perl -pi -e "s/%SHADER_NAME%/$1/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
+ perl -pi -e "s/\f/\//g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
cp metadata.desktop.in "$BUILD_DIR/$DIR_NAME/metadata.desktop"
perl -pi -e "s/%ICON%/$1/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
@@ -75,9 +94,12 @@ generate() {
cat "../resources/shaders/common.glsl"
cat "../resources/shaders/$1.frag"
} > "$BUILD_DIR/$DIR_NAME/contents/shaders/$1.frag"
+
+ # If clang-format is installed, try to beauty the code a bit.
}
-generate "tv" "TV Effect" "Make windows close like turning off a TV"
generate "energize-a" "Energize A" "Beam your windows away"
generate "energize-b" "Energize B" "Using different transporter technology results in an alternative visual effect"
+generate "hexagon" "Hexagon" "With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi"
+generate "tv" "TV Effect" "Make windows close like turning off a TV"
# generate "fire" "Fire" "Make windows burn"
\ No newline at end of file
diff --git a/kwin/kwin4_effect_energize_a/loadConfig.js b/kwin/kwin4_effect_energize_a/loadConfig.js
deleted file mode 100644
index bda8a0b..0000000
--- a/kwin/kwin4_effect_energize_a/loadConfig.js
+++ /dev/null
@@ -1,5 +0,0 @@
-loadConfig() {
- this.duration = animationTime(effect.readConfig('Duration', 1000));
- effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
- effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
-}
\ No newline at end of file
diff --git a/kwin/kwin4_effect_energize_a/onSettingsChanged.js b/kwin/kwin4_effect_energize_a/onSettingsChanged.js
new file mode 100644
index 0000000..5becc52
--- /dev/null
+++ b/kwin/kwin4_effect_energize_a/onSettingsChanged.js
@@ -0,0 +1,6 @@
+// This part is automatically included in the effect's source during the build process.
+// The code below is called whenever the user changes something in the configuration of
+// the effect.
+
+effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
+effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
\ No newline at end of file
diff --git a/kwin/kwin4_effect_energize_b/loadConfig.js b/kwin/kwin4_effect_energize_b/loadConfig.js
deleted file mode 100644
index bda8a0b..0000000
--- a/kwin/kwin4_effect_energize_b/loadConfig.js
+++ /dev/null
@@ -1,5 +0,0 @@
-loadConfig() {
- this.duration = animationTime(effect.readConfig('Duration', 1000));
- effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
- effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
-}
\ No newline at end of file
diff --git a/kwin/kwin4_effect_energize_b/onSettingsChanged.js b/kwin/kwin4_effect_energize_b/onSettingsChanged.js
new file mode 100644
index 0000000..5a5dce5
--- /dev/null
+++ b/kwin/kwin4_effect_energize_b/onSettingsChanged.js
@@ -0,0 +1,6 @@
+// This part is automatically included in the effect's source during the build process.
+// The code below is called whenever the user changes something in the configuration of
+// the effect.
+
+effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
+effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
diff --git a/kwin/kwin4_effect_tv/loadConfig.js b/kwin/kwin4_effect_tv/loadConfig.js
deleted file mode 100644
index 9330cf9..0000000
--- a/kwin/kwin4_effect_tv/loadConfig.js
+++ /dev/null
@@ -1,4 +0,0 @@
-loadConfig() {
- this.duration = animationTime(effect.readConfig('Duration', 1000));
- effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
-}
\ No newline at end of file
diff --git a/kwin/kwin4_effect_tv/onSettingsChanged.js b/kwin/kwin4_effect_tv/onSettingsChanged.js
new file mode 100644
index 0000000..e656b03
--- /dev/null
+++ b/kwin/kwin4_effect_tv/onSettingsChanged.js
@@ -0,0 +1,5 @@
+// This part is automatically included in the effect's source during the build process.
+// The code below is called whenever the user changes something in the configuration of
+// the effect.
+
+effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
\ No newline at end of file
diff --git a/kwin/main.js.in b/kwin/main.js.in
index 13452bc..89a82a3 100755
--- a/kwin/main.js.in
+++ b/kwin/main.js.in
@@ -30,7 +30,12 @@ class %EFFECT_CLASS% {
this.loadConfig();
}
- %LOAD_CONFIG%
+ loadConfig() {
+ this.duration = animationTime(effect.readConfig('Duration', 1000));
+ effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
+
+ %ON_SETTINGS_CHANGE%
+ }
static isScaleWindow(window) {
// We don't want to animate most of plasmashell's windows, yet, some
@@ -95,6 +100,11 @@ class %EFFECT_CLASS% {
return;
}
this.setupForcedRoles(window);
+
+ effect.setUniform(this.shader, 'uForOpening', 1.0);
+
+ %ON_ANIMATION_BEGIN%
+
window.scaleInAnimation = animate({
window: window,
curve: QEasingCurve.Linear,
@@ -103,16 +113,9 @@ class %EFFECT_CLASS% {
{
type: Effect.ShaderUniform,
fragmentShader: this.shader,
- uniform: "forOpening",
- from: 1.0,
+ uniform: "uProgress",
+ from: 0.0,
to: 1.0
- },
- {
- type: Effect.ShaderUniform,
- fragmentShader: this.shader,
- uniform: "uDuration",
- from: this.duration * 0.001,
- to: this.duration * 0.001
}
]
});
@@ -136,6 +139,11 @@ class %EFFECT_CLASS% {
delete window.scaleInAnimation;
}
this.setupForcedRoles(window);
+
+ effect.setUniform(this.shader, 'uForOpening', 0.0);
+
+ %ON_ANIMATION_BEGIN%
+
window.scaleOutAnimation = animate({
window: window,
curve: QEasingCurve.Linear,
@@ -144,16 +152,9 @@ class %EFFECT_CLASS% {
{
type: Effect.ShaderUniform,
fragmentShader: this.shader,
- uniform: "forOpening",
+ uniform: "uProgress",
from: 0.0,
- to: 0.0
- },
- {
- type: Effect.ShaderUniform,
- fragmentShader: this.shader,
- uniform: "uDuration",
- from: this.duration * 0.001,
- to: this.duration * 0.001
+ to: 1.0
}
]
});
diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl
index fbced17..80894b7 100644
--- a/resources/shaders/common.glsl
+++ b/resources/shaders/common.glsl
@@ -33,23 +33,22 @@
// vec4 getInputColor(vec2 coords)
// void setOutputColor(vec4 outColor)
+uniform bool uForOpening;
+uniform float uProgress;
+uniform float uDuration;
+
#if defined(KWIN) // --------------------------------------------------------------------
-uniform float forOpening;
uniform sampler2D sampler;
-uniform float uDuration;
uniform int textureWidth;
uniform int textureHeight;
-uniform float animationProgress;
in vec2 texcoord0;
out vec4 fragColor;
-vec2 uSize = vec2(textureWidth, textureHeight);
-bool uForOpening = forOpening == 1.0;
-vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
-float uProgress = animationProgress;
-float uPadding = 0.0;
+vec2 uSize = vec2(textureWidth, textureHeight);
+vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
+float uPadding = 0.0;
vec4 getInputColor(vec2 coords) {
vec4 color = texture2D(sampler, vec2(coords.x, 1.0 - coords.y));
@@ -67,20 +66,15 @@ void setOutputColor(vec4 outColor) {
#elif defined(KWIN_LEGACY) // -----------------------------------------------------------
-uniform float forOpening;
uniform sampler2D sampler;
-uniform float uDuration;
uniform int textureWidth;
uniform int textureHeight;
-uniform float animationProgress;
varying vec2 texcoord0;
-vec2 uSize = vec2(textureWidth, textureHeight);
-bool uForOpening = forOpening == 1.0;
-vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
-float uProgress = animationProgress;
-float uPadding = 0.0;
+vec2 uSize = vec2(textureWidth, textureHeight);
+vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
+float uPadding = 0.0;
vec4 getInputColor(vec2 coords) {
vec4 color = texture2D(sampler, vec2(coords.x, 1.0 - coords.y));
@@ -99,10 +93,7 @@ void setOutputColor(vec4 outColor) {
#else // GNOME --------------------------------------------------------------------------
// On GNOME, the uniforms are just normal uniforms.
-uniform bool uForOpening;
uniform sampler2D uTexture;
-uniform float uProgress;
-uniform float uDuration;
uniform vec2 uSize;
uniform float uPadding;
From cc86b16817323b1f21374ea57a0942b443b8f261 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 14:07:20 +0200
Subject: [PATCH 37/71] :tada: Add kwin hexagon effect
---
kwin/kwin4_effect_hexagon/config.ui | 97 +++++++++++++++++++
kwin/kwin4_effect_hexagon/main.xml | 25 +++++
kwin/kwin4_effect_hexagon/onAnimationBegin.js | 4 +
.../kwin4_effect_hexagon/onSettingsChanged.js | 10 ++
4 files changed, 136 insertions(+)
create mode 100755 kwin/kwin4_effect_hexagon/config.ui
create mode 100755 kwin/kwin4_effect_hexagon/main.xml
create mode 100644 kwin/kwin4_effect_hexagon/onAnimationBegin.js
create mode 100644 kwin/kwin4_effect_hexagon/onSettingsChanged.js
diff --git a/kwin/kwin4_effect_hexagon/config.ui b/kwin/kwin4_effect_hexagon/config.ui
new file mode 100755
index 0000000..56ad8db
--- /dev/null
+++ b/kwin/kwin4_effect_hexagon/config.ui
@@ -0,0 +1,97 @@
+
+
Date: Fri, 10 Jun 2022 14:13:29 +0200
Subject: [PATCH 38/71] :wrench: Only set duration if required
---
kwin/kwin4_effect_energize_a/onSettingsChanged.js | 1 +
kwin/kwin4_effect_energize_b/onSettingsChanged.js | 1 +
kwin/kwin4_effect_hexagon/onSettingsChanged.js | 1 +
kwin/main.js.in | 1 -
4 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/kwin/kwin4_effect_energize_a/onSettingsChanged.js b/kwin/kwin4_effect_energize_a/onSettingsChanged.js
index 5becc52..e6b23f2 100644
--- a/kwin/kwin4_effect_energize_a/onSettingsChanged.js
+++ b/kwin/kwin4_effect_energize_a/onSettingsChanged.js
@@ -2,5 +2,6 @@
// The code below is called whenever the user changes something in the configuration of
// the effect.
+effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
\ No newline at end of file
diff --git a/kwin/kwin4_effect_energize_b/onSettingsChanged.js b/kwin/kwin4_effect_energize_b/onSettingsChanged.js
index 5a5dce5..8797f46 100644
--- a/kwin/kwin4_effect_energize_b/onSettingsChanged.js
+++ b/kwin/kwin4_effect_energize_b/onSettingsChanged.js
@@ -2,5 +2,6 @@
// The code below is called whenever the user changes something in the configuration of
// the effect.
+effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
diff --git a/kwin/kwin4_effect_hexagon/onSettingsChanged.js b/kwin/kwin4_effect_hexagon/onSettingsChanged.js
index 2def1ec..f0740d7 100644
--- a/kwin/kwin4_effect_hexagon/onSettingsChanged.js
+++ b/kwin/kwin4_effect_hexagon/onSettingsChanged.js
@@ -2,6 +2,7 @@
// The code below is called whenever the user changes something in the configuration of
// the effect.
+effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
effect.setUniform(this.shader, 'uAdditiveBlending',
effect.readConfig('AdditiveBlending', true));
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
diff --git a/kwin/main.js.in b/kwin/main.js.in
index 89a82a3..eec52cf 100755
--- a/kwin/main.js.in
+++ b/kwin/main.js.in
@@ -32,7 +32,6 @@ class %EFFECT_CLASS% {
loadConfig() {
this.duration = animationTime(effect.readConfig('Duration', 1000));
- effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
%ON_SETTINGS_CHANGE%
}
From d4165b4b62cccd2b43fc8615aa80fb4027285bd1 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 14:38:14 +0200
Subject: [PATCH 39/71] :wrench: Fix GLSL compiler issue
---
resources/shaders/hexagon.frag | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/resources/shaders/hexagon.frag b/resources/shaders/hexagon.frag
index 3319ef3..ff5ad85 100644
--- a/resources/shaders/hexagon.frag
+++ b/resources/shaders/hexagon.frag
@@ -31,10 +31,10 @@ uniform vec4 uLineColor;
vec4 getHexagons(vec2 p) {
// Length of a cell's edge.
- const float edgeLength = sqrt(4.0 / 3.0);
+ float edgeLength = sqrt(4.0 / 3.0);
// The hexgrid repeats after this distance.
- const vec2 scale = vec2(3.0 * edgeLength, 2.0);
+ vec2 scale = vec2(3.0 * edgeLength, 2.0);
// This is a repeating grid of scale-sized cells. Y-values are in the
// interval [-1...1], X-value in [-1.5*edgeLength...1.5*edgeLength].
From 2bd67c0d379a56e19cd60ef2d8f06a8ca0186e1f Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 14:38:34 +0200
Subject: [PATCH 40/71] :wrench: Tweak kwin config GUI
---
kwin/kwin4_effect_energize_a/config.ui | 15 +--
kwin/kwin4_effect_energize_b/config.ui | 15 +--
kwin/kwin4_effect_hexagon/config.ui | 115 ++++++++++++------
.../kwin4_effect_hexagon/onSettingsChanged.js | 3 +-
kwin/kwin4_effect_tv/config.ui | 15 +--
5 files changed, 94 insertions(+), 69 deletions(-)
diff --git a/kwin/kwin4_effect_energize_a/config.ui b/kwin/kwin4_effect_energize_a/config.ui
index 56ad8db..f5a89ed 100755
--- a/kwin/kwin4_effect_energize_a/config.ui
+++ b/kwin/kwin4_effect_energize_a/config.ui
@@ -35,12 +35,9 @@
Date: Fri, 10 Jun 2022 14:50:38 +0200
Subject: [PATCH 41/71] :wrench: Update kwin default colors
---
kwin/kwin4_effect_energize_a/main.xml | 2 +-
kwin/kwin4_effect_energize_b/main.xml | 2 +-
kwin/kwin4_effect_hexagon/main.xml | 4 ++--
kwin/kwin4_effect_tv/main.xml | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/kwin/kwin4_effect_energize_a/main.xml b/kwin/kwin4_effect_energize_a/main.xml
index 13897a3..dda1b6b 100755
--- a/kwin/kwin4_effect_energize_a/main.xml
+++ b/kwin/kwin4_effect_energize_a/main.xml
@@ -10,7 +10,7 @@
Date: Fri, 10 Jun 2022 14:53:38 +0200
Subject: [PATCH 42/71] :wrench: Fix kwin default colors
---
kwin/kwin4_effect_hexagon/main.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kwin/kwin4_effect_hexagon/main.xml b/kwin/kwin4_effect_hexagon/main.xml
index cd6ceb4..e2515e5 100755
--- a/kwin/kwin4_effect_hexagon/main.xml
+++ b/kwin/kwin4_effect_hexagon/main.xml
@@ -13,10 +13,10 @@
Date: Fri, 10 Jun 2022 15:13:49 +0200
Subject: [PATCH 43/71] :wrench: Build archives for effects
---
.gitignore | 3 ++-
kwin/build.sh | 25 ++++++++++++-------
.../config.ui | 0
.../main.xml | 0
.../onSettingsChanged.js | 0
.../config.ui | 0
.../main.xml | 0
.../onSettingsChanged.js | 0
.../config.ui | 0
.../main.xml | 0
.../onAnimationBegin.js | 0
.../onSettingsChanged.js | 0
kwin/{kwin4_effect_tv => tv}/config.ui | 0
kwin/{kwin4_effect_tv => tv}/main.xml | 0
.../onSettingsChanged.js | 0
15 files changed, 18 insertions(+), 10 deletions(-)
rename kwin/{kwin4_effect_energize_a => energize-a}/config.ui (100%)
rename kwin/{kwin4_effect_energize_a => energize-a}/main.xml (100%)
rename kwin/{kwin4_effect_energize_a => energize-a}/onSettingsChanged.js (100%)
rename kwin/{kwin4_effect_energize_b => energize-b}/config.ui (100%)
rename kwin/{kwin4_effect_energize_b => energize-b}/main.xml (100%)
rename kwin/{kwin4_effect_energize_b => energize-b}/onSettingsChanged.js (100%)
rename kwin/{kwin4_effect_hexagon => hexagon}/config.ui (100%)
rename kwin/{kwin4_effect_hexagon => hexagon}/main.xml (100%)
rename kwin/{kwin4_effect_hexagon => hexagon}/onAnimationBegin.js (100%)
rename kwin/{kwin4_effect_hexagon => hexagon}/onSettingsChanged.js (100%)
rename kwin/{kwin4_effect_tv => tv}/config.ui (100%)
rename kwin/{kwin4_effect_tv => tv}/main.xml (100%)
rename kwin/{kwin4_effect_tv => tv}/onSettingsChanged.js (100%)
diff --git a/.gitignore b/.gitignore
index 6f382cf..0bf9a1c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,5 @@
/schemas/gschemas.compiled
/resources/burn-my-windows.gresource
/resources/burn-my-windows.gresource.xml
-kwin/_build
\ No newline at end of file
+kwin/_build
+kwin/*.tar.gz
\ No newline at end of file
diff --git a/kwin/build.sh b/kwin/build.sh
index 2811fed..a7a8c0d 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -33,7 +33,7 @@ generate() {
DIR_NAME="kwin4_effect_$(echo "$1" | tr '-' '_')"
# Use the name of the effect for the JavaScript class name by removing all spaces.
- EFFECT_CLASS="BurnMyWindows$(echo "$2" | tr -d ' ')"
+ EFFECT_CLASS="BurnMyWindows$(echo "$2" | tr -d ' ')Effect"
# Create resource directories.
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/shaders"
@@ -42,25 +42,25 @@ generate() {
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/ui"
# Copy the config file if it exists.
- if [ -f "$DIR_NAME/main.xml" ]; then
- cp "$DIR_NAME/main.xml" "$BUILD_DIR/$DIR_NAME/contents/config"
+ if [ -f "$1/main.xml" ]; then
+ cp "$1/main.xml" "$BUILD_DIR/$DIR_NAME/contents/config"
fi
# Copy the ui file if it exists.
- if [ -f "$DIR_NAME/config.ui" ]; then
- cp "$DIR_NAME/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui"
+ if [ -f "$1/config.ui" ]; then
+ cp "$1/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui"
fi
ON_SETTINGS_CHANGE=""
ON_ANIMATION_BEGIN=""
- if [ -f "$DIR_NAME/onSettingsChanged.js" ]; then
- ON_SETTINGS_CHANGE=$(tr '/' '\f' < "$DIR_NAME/onSettingsChanged.js")
+ if [ -f "$1/onSettingsChanged.js" ]; then
+ ON_SETTINGS_CHANGE=$(tr '/' '\f' < "$1/onSettingsChanged.js")
fi
- if [ -f "$DIR_NAME/onAnimationBegin.js" ]; then
- ON_ANIMATION_BEGIN=$(tr '/' '\f' < "$DIR_NAME/onAnimationBegin.js")
+ if [ -f "$1/onAnimationBegin.js" ]; then
+ ON_ANIMATION_BEGIN=$(tr '/' '\f' < "$1/onAnimationBegin.js")
fi
cp main.js.in "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
@@ -96,6 +96,13 @@ generate() {
} > "$BUILD_DIR/$DIR_NAME/contents/shaders/$1.frag"
# If clang-format is installed, try to beauty the code a bit.
+ if command -v clang-format &> /dev/null
+ then
+ clang-format -i "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
+ fi
+
+ # Create an archive for the effect.
+ tar -C "$BUILD_DIR" -czf $DIR_NAME.tar.gz "$DIR_NAME"
}
generate "energize-a" "Energize A" "Beam your windows away"
diff --git a/kwin/kwin4_effect_energize_a/config.ui b/kwin/energize-a/config.ui
similarity index 100%
rename from kwin/kwin4_effect_energize_a/config.ui
rename to kwin/energize-a/config.ui
diff --git a/kwin/kwin4_effect_energize_a/main.xml b/kwin/energize-a/main.xml
similarity index 100%
rename from kwin/kwin4_effect_energize_a/main.xml
rename to kwin/energize-a/main.xml
diff --git a/kwin/kwin4_effect_energize_a/onSettingsChanged.js b/kwin/energize-a/onSettingsChanged.js
similarity index 100%
rename from kwin/kwin4_effect_energize_a/onSettingsChanged.js
rename to kwin/energize-a/onSettingsChanged.js
diff --git a/kwin/kwin4_effect_energize_b/config.ui b/kwin/energize-b/config.ui
similarity index 100%
rename from kwin/kwin4_effect_energize_b/config.ui
rename to kwin/energize-b/config.ui
diff --git a/kwin/kwin4_effect_energize_b/main.xml b/kwin/energize-b/main.xml
similarity index 100%
rename from kwin/kwin4_effect_energize_b/main.xml
rename to kwin/energize-b/main.xml
diff --git a/kwin/kwin4_effect_energize_b/onSettingsChanged.js b/kwin/energize-b/onSettingsChanged.js
similarity index 100%
rename from kwin/kwin4_effect_energize_b/onSettingsChanged.js
rename to kwin/energize-b/onSettingsChanged.js
diff --git a/kwin/kwin4_effect_hexagon/config.ui b/kwin/hexagon/config.ui
similarity index 100%
rename from kwin/kwin4_effect_hexagon/config.ui
rename to kwin/hexagon/config.ui
diff --git a/kwin/kwin4_effect_hexagon/main.xml b/kwin/hexagon/main.xml
similarity index 100%
rename from kwin/kwin4_effect_hexagon/main.xml
rename to kwin/hexagon/main.xml
diff --git a/kwin/kwin4_effect_hexagon/onAnimationBegin.js b/kwin/hexagon/onAnimationBegin.js
similarity index 100%
rename from kwin/kwin4_effect_hexagon/onAnimationBegin.js
rename to kwin/hexagon/onAnimationBegin.js
diff --git a/kwin/kwin4_effect_hexagon/onSettingsChanged.js b/kwin/hexagon/onSettingsChanged.js
similarity index 100%
rename from kwin/kwin4_effect_hexagon/onSettingsChanged.js
rename to kwin/hexagon/onSettingsChanged.js
diff --git a/kwin/kwin4_effect_tv/config.ui b/kwin/tv/config.ui
similarity index 100%
rename from kwin/kwin4_effect_tv/config.ui
rename to kwin/tv/config.ui
diff --git a/kwin/kwin4_effect_tv/main.xml b/kwin/tv/main.xml
similarity index 100%
rename from kwin/kwin4_effect_tv/main.xml
rename to kwin/tv/main.xml
diff --git a/kwin/kwin4_effect_tv/onSettingsChanged.js b/kwin/tv/onSettingsChanged.js
similarity index 100%
rename from kwin/kwin4_effect_tv/onSettingsChanged.js
rename to kwin/tv/onSettingsChanged.js
From 79fe1feb5c58369f696c4c5e08d14c3913163c0a Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 15:15:38 +0200
Subject: [PATCH 44/71] :wrench: Fix shellcheck issues
---
kwin/build.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index a7a8c0d..20aa12b 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -102,7 +102,7 @@ generate() {
fi
# Create an archive for the effect.
- tar -C "$BUILD_DIR" -czf $DIR_NAME.tar.gz "$DIR_NAME"
+ tar -C "$BUILD_DIR" -czf "$DIR_NAME.tar.gz" "$DIR_NAME"
}
generate "energize-a" "Energize A" "Beam your windows away"
From 97a422689854190248dc4ffa290ba92c99a444cf Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 15:24:54 +0200
Subject: [PATCH 45/71] :tada: Add wisps kwin effect
---
kwin/build.sh | 1 +
kwin/wisps/config.ui | 84 +++++++++++++++++++++++++++++++++
kwin/wisps/main.xml | 16 +++++++
kwin/wisps/onAnimationBegin.js | 4 ++
kwin/wisps/onSettingsChanged.js | 6 +++
resources/shaders/wisps.frag | 4 +-
src/Wisps.js | 2 +-
7 files changed, 114 insertions(+), 3 deletions(-)
create mode 100755 kwin/wisps/config.ui
create mode 100755 kwin/wisps/main.xml
create mode 100644 kwin/wisps/onAnimationBegin.js
create mode 100644 kwin/wisps/onSettingsChanged.js
diff --git a/kwin/build.sh b/kwin/build.sh
index 20aa12b..805394b 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -109,4 +109,5 @@ generate "energize-a" "Energize A" "Beam your windows away"
generate "energize-b" "Energize B" "Using different transporter technology results in an alternative visual effect"
generate "hexagon" "Hexagon" "With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi"
generate "tv" "TV Effect" "Make windows close like turning off a TV"
+generate "wisps" "Wisps" "Let your windows be carried away to the realm of dreams by these little fairies"
# generate "fire" "Fire" "Make windows burn"
\ No newline at end of file
diff --git a/kwin/wisps/config.ui b/kwin/wisps/config.ui
new file mode 100755
index 0000000..c0670e0
--- /dev/null
+++ b/kwin/wisps/config.ui
@@ -0,0 +1,84 @@
+
+
Date: Fri, 10 Jun 2022 15:28:42 +0200
Subject: [PATCH 46/71] :tada: Add apparition kwin effect
---
kwin/apparition/config.ui | 132 +++++++++++++++++++++++++++
kwin/apparition/main.xml | 22 +++++
kwin/apparition/onAnimationBegin.js | 4 +
kwin/apparition/onSettingsChanged.js | 8 ++
kwin/build.sh | 1 +
5 files changed, 167 insertions(+)
create mode 100755 kwin/apparition/config.ui
create mode 100755 kwin/apparition/main.xml
create mode 100644 kwin/apparition/onAnimationBegin.js
create mode 100644 kwin/apparition/onSettingsChanged.js
diff --git a/kwin/apparition/config.ui b/kwin/apparition/config.ui
new file mode 100755
index 0000000..3fa647c
--- /dev/null
+++ b/kwin/apparition/config.ui
@@ -0,0 +1,132 @@
+
+
Date: Fri, 10 Jun 2022 15:42:46 +0200
Subject: [PATCH 47/71] :wrench: Remove implicit conversions
---
resources/shaders/wisps.frag | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/resources/shaders/wisps.frag b/resources/shaders/wisps.frag
index 927f35a..5171f2b 100644
--- a/resources/shaders/wisps.frag
+++ b/resources/shaders/wisps.frag
@@ -47,8 +47,8 @@ float getWisps(vec2 texCoords, float gridSize, vec2 seed) {
float radius = mix(0.5, 1.0, hash12(cellID * seed * 19.1249)) * WISPS_RADIUS;
float roundness = mix(-1.0, 1.0, hash12(cellID * seed * 7.51949));
- vec2 offset = vec2(sin(speed * (uProgress * uDuration + 1)) * roundness,
- cos(speed * (uProgress * uDuration + 1)));
+ vec2 offset = vec2(sin(speed * (uProgress * uDuration + 1.0)) * roundness,
+ cos(speed * (uProgress * uDuration + 1.0)));
offset *= 0.5 - 0.5 * radius / gridSize;
offset = vec2(offset.x * cos(rotation) - offset.y * sin(rotation),
offset.x * sin(rotation) + offset.y * cos(rotation));
@@ -58,7 +58,7 @@ float getWisps(vec2 texCoords, float gridSize, vec2 seed) {
// Use distance to center of shifted / rotated UV coordinates to draw a glaring point.
float dist = length(cellUV - 0.5) * gridSize / radius;
if (dist < 1.0) {
- return min(5, 0.01 / pow(dist, 2.0));
+ return min(5.0, 0.01 / pow(dist, 2.0));
}
return 0.0;
@@ -78,7 +78,7 @@ void main() {
vec2 uv = (iTexCoord.st - 0.5) / mix(1.0, 0.5, progress) + 0.5;
uv /= uScale;
float wisps = 0.0;
- for (int i = 0; i < WISPS_LAYERS; ++i) {
+ for (float i = 0; i < WISPS_LAYERS; ++i) {
wisps += getWisps(uv * 0.3, WISPS_SPACING, uSeed * (i + 1));
}
From a2fdf05431502c0eb78752e161f8b65e0ff9b95e Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 15:42:58 +0200
Subject: [PATCH 48/71] :wrench: Tweak UI
---
kwin/apparition/config.ui | 101 +++++++++++++++++---------------------
kwin/apparition/main.xml | 8 +--
2 files changed, 49 insertions(+), 60 deletions(-)
diff --git a/kwin/apparition/config.ui b/kwin/apparition/config.ui
index 3fa647c..c611e6f 100755
--- a/kwin/apparition/config.ui
+++ b/kwin/apparition/config.ui
@@ -11,34 +11,14 @@
Date: Fri, 10 Jun 2022 15:43:11 +0200
Subject: [PATCH 49/71] :wrench: Add BMW to effect names
---
kwin/build.sh | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index cf15643..dd163c5 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -32,8 +32,8 @@ generate() {
# Use the nick for the effect's directory name by replacing dashes by underscoares.
DIR_NAME="kwin4_effect_$(echo "$1" | tr '-' '_')"
- # Use the name of the effect for the JavaScript class name by removing all spaces.
- EFFECT_CLASS="BurnMyWindows$(echo "$2" | tr -d ' ')Effect"
+ # Transform to CamelCase for the JavaScript class.
+ EFFECT_CLASS="BurnMyWindows$(sed -r 's/(^|-)(\w)/\U\2/g' <<<"$1")Effect"
# Create resource directories.
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/shaders"
@@ -105,10 +105,10 @@ generate() {
tar -C "$BUILD_DIR" -czf "$DIR_NAME.tar.gz" "$DIR_NAME"
}
-generate "apparition" "Apparition" "This effect hides your windows by violently sucking them into the void of magic"
-generate "energize-a" "Energize A" "Beam your windows away"
-generate "energize-b" "Energize B" "Using different transporter technology results in an alternative visual effect"
-generate "hexagon" "Hexagon" "With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi"
-generate "tv" "TV Effect" "Make windows close like turning off a TV"
-generate "wisps" "Wisps" "Let your windows be carried away to the realm of dreams by these little fairies"
+generate "apparition" "Apparition [BMW]" "This effect hides your windows by violently sucking them into the void of magic"
+generate "energize-a" "Energize A [BMW]" "Beam your windows away"
+generate "energize-b" "Energize B [BMW]" "Using different transporter technology results in an alternative visual effect"
+generate "hexagon" "Hexagon [BMW]" "With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi"
+generate "tv" "TV Effect [BMW]" "Make windows close like turning off a TV"
+generate "wisps" "Wisps [BMW]" "Let your windows be carried away to the realm of dreams by these little fairies"
# generate "fire" "Fire" "Make windows burn"
\ No newline at end of file
From ef746c20e66bf4582768e7fcc27dd5bc9c37c5c5 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 15:58:10 +0200
Subject: [PATCH 50/71] :wrench: Remove implicit conversions
---
resources/shaders/wisps.frag | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/resources/shaders/wisps.frag b/resources/shaders/wisps.frag
index 5171f2b..11daf9a 100644
--- a/resources/shaders/wisps.frag
+++ b/resources/shaders/wisps.frag
@@ -20,7 +20,7 @@ uniform float uScale;
const float WISPS_RADIUS = 20.0;
const float WISPS_SPEED = 10.0;
const float WISPS_SPACING = 40.0 + WISPS_RADIUS;
-const int WISPS_LAYERS = 8;
+const float WISPS_LAYERS = 8.0;
const float WISPS_IN_TIME = 0.5;
const float WINDOW_OUT_TIME = 1.0;
const float SCALING = 0.9;
@@ -78,8 +78,8 @@ void main() {
vec2 uv = (iTexCoord.st - 0.5) / mix(1.0, 0.5, progress) + 0.5;
uv /= uScale;
float wisps = 0.0;
- for (float i = 0; i < WISPS_LAYERS; ++i) {
- wisps += getWisps(uv * 0.3, WISPS_SPACING, uSeed * (i + 1));
+ for (float i = 0.0; i < WISPS_LAYERS; ++i) {
+ wisps += getWisps(uv * 0.3, WISPS_SPACING, uSeed * (i + 1.0));
}
// Compute shrinking edge mask.
@@ -92,7 +92,8 @@ void main() {
float windowOut = smoothstep(0.0, 1.0, clamp(progress / WINDOW_OUT_TIME, 0.0, 1.0));
// Use a noise function to dissolve the window.
- float noise = smoothstep(1.0, 0.0, abs(2.0 * simplex2DFractal(uv * uSize / 250) - 1.0));
+ float noise =
+ smoothstep(1.0, 0.0, abs(2.0 * simplex2DFractal(uv * uSize / 250.0) - 1.0));
float windowMask = 1.0 - (windowOut < 0.5 ? mix(0.0, noise, windowOut * 2.0)
: mix(noise, 1.0, windowOut * 2.0 - 1.0));
oColor.a *= windowMask * mask;
From 5c58ccf2cf900b4c937c87ed7e9de3ec41e923cc Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 16:08:05 +0200
Subject: [PATCH 51/71] :tada: Add fire kwin effect
---
kwin/build.sh | 14 ++--
kwin/fire/config.ui | 132 +++++++++++++++++++++++++++++++++
kwin/fire/main.xml | 34 +++++++++
kwin/fire/onSettingsChanged.js | 13 ++++
4 files changed, 186 insertions(+), 7 deletions(-)
create mode 100755 kwin/fire/config.ui
create mode 100755 kwin/fire/main.xml
create mode 100644 kwin/fire/onSettingsChanged.js
diff --git a/kwin/build.sh b/kwin/build.sh
index dd163c5..8b87d49 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -105,10 +105,10 @@ generate() {
tar -C "$BUILD_DIR" -czf "$DIR_NAME.tar.gz" "$DIR_NAME"
}
-generate "apparition" "Apparition [BMW]" "This effect hides your windows by violently sucking them into the void of magic"
-generate "energize-a" "Energize A [BMW]" "Beam your windows away"
-generate "energize-b" "Energize B [BMW]" "Using different transporter technology results in an alternative visual effect"
-generate "hexagon" "Hexagon [BMW]" "With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi"
-generate "tv" "TV Effect [BMW]" "Make windows close like turning off a TV"
-generate "wisps" "Wisps [BMW]" "Let your windows be carried away to the realm of dreams by these little fairies"
-# generate "fire" "Fire" "Make windows burn"
\ No newline at end of file
+generate "apparition" "[BMW] Apparition" "This effect hides your windows by violently sucking them into the void of magic"
+generate "energize-a" "[BMW] Energize A" "Beam your windows away"
+generate "energize-b" "[BMW] Energize B" "Using different transporter technology results in an alternative visual effect"
+generate "fire" "[BMW] Fire" "The classic effect inspired by Compiz"
+generate "hexagon" "[BMW] Hexagon" "With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi"
+generate "tv" "[BMW] TV Effect" "Make windows close like turning off a TV"
+generate "wisps" "[BMW] Wisps" "Let your windows be carried away to the realm of dreams by these little fairies"
\ No newline at end of file
diff --git a/kwin/fire/config.ui b/kwin/fire/config.ui
new file mode 100755
index 0000000..3fa647c
--- /dev/null
+++ b/kwin/fire/config.ui
@@ -0,0 +1,132 @@
+
+
Date: Fri, 10 Jun 2022 16:19:30 +0200
Subject: [PATCH 52/71] :wrench: Fix kwin fire
---
kwin/fire/main.xml | 8 ++++----
resources/shaders/fire.frag | 15 +++++++++++++--
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/kwin/fire/main.xml b/kwin/fire/main.xml
index 78b042b..cb44028 100755
--- a/kwin/fire/main.xml
+++ b/kwin/fire/main.xml
@@ -13,16 +13,16 @@
Date: Fri, 10 Jun 2022 17:09:22 +0200
Subject: [PATCH 53/71] :wrench: Set duration uniforms
---
kwin/fire/onSettingsChanged.js | 1 +
kwin/wisps/onSettingsChanged.js | 1 +
2 files changed, 2 insertions(+)
diff --git a/kwin/fire/onSettingsChanged.js b/kwin/fire/onSettingsChanged.js
index 3b20add..d6ef48d 100644
--- a/kwin/fire/onSettingsChanged.js
+++ b/kwin/fire/onSettingsChanged.js
@@ -2,6 +2,7 @@
// The code below is called whenever the user changes something in the configuration of
// the effect.
+effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
effect.setUniform(this.shader, 'u3DNoise',
effect.readConfig('3DNoise', true) ? 1.0 : 0.0);
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
diff --git a/kwin/wisps/onSettingsChanged.js b/kwin/wisps/onSettingsChanged.js
index 6a8173e..6928ce8 100644
--- a/kwin/wisps/onSettingsChanged.js
+++ b/kwin/wisps/onSettingsChanged.js
@@ -2,5 +2,6 @@
// The code below is called whenever the user changes something in the configuration of
// the effect.
+effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
From c7696773287f57887b6e9b53a15f2df2c6fb7856 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Fri, 10 Jun 2022 17:21:41 +0200
Subject: [PATCH 54/71] :memo: Add some comments
---
kwin/build.sh | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 8b87d49..33a02dd 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -13,6 +13,10 @@
# Released under the GPLv3 or later. See LICENSE file for details. #
# -------------------------------------------------------------------------------------- #
+
+# This scripts takes the shaders of Burn-My-Windows as well as some other input files from
+# the directories next to this script and creates effect for KDE's Kwin.
+
# Exit the script when one command fails.
set -e
@@ -20,22 +24,25 @@ set -e
cd "$( cd "$( dirname "$0" )" && pwd )" || \
{ echo "ERROR: Could not find kwin directory."; exit 1; }
+# We will store the effect directories in this directory.
BUILD_DIR="_build"
+# Create it if it's not there yet.
mkdir -p "$BUILD_DIR"
+# This method is called one for each effect. The parameters are as follows:
# $1: The nick of the effect (e.g. "energize-a")
# $2: The name of the effect (e.g. "Energize A")
# $3: A short description of the effect (e.g. "Beam your windows away")
generate() {
- # Use the nick for the effect's directory name by replacing dashes by underscoares.
+ # We use the nick for the effect's directory name by replacing dashes with underscoares.
DIR_NAME="kwin4_effect_$(echo "$1" | tr '-' '_')"
- # Transform to CamelCase for the JavaScript class.
+ # We transform the nick to CamelCase for the JavaScript class name.
EFFECT_CLASS="BurnMyWindows$(sed -r 's/(^|-)(\w)/\U\2/g' <<<"$1")Effect"
- # Create resource directories.
+ # Now create all required resource directories.
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/shaders"
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/code"
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/config"
@@ -51,14 +58,19 @@ generate() {
cp "$1/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui"
fi
-
+ # Now we create the effect's JavaScript source file. This is done by taking main.js.in
+ # and replacing some placeholders with effect-specific files and values.
ON_SETTINGS_CHANGE=""
ON_ANIMATION_BEGIN=""
+ # If the effect's directory contains a onSettingsChanged.js, we replace the
+ # corresponding placeholder with it's content. We replace all occurences of / temporily
+ # so that the REGEX works.
if [ -f "$1/onSettingsChanged.js" ]; then
ON_SETTINGS_CHANGE=$(tr '/' '\f' < "$1/onSettingsChanged.js")
fi
+ # Similarily, we will inject the contents of onAnimationBegin.js.
if [ -f "$1/onAnimationBegin.js" ]; then
ON_ANIMATION_BEGIN=$(tr '/' '\f' < "$1/onAnimationBegin.js")
fi
@@ -70,12 +82,16 @@ generate() {
perl -pi -e "s/%SHADER_NAME%/$1/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
perl -pi -e "s/\f/\//g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
+ # Now create the metadata.desktop file. Again, we replace some placeholders.
cp metadata.desktop.in "$BUILD_DIR/$DIR_NAME/metadata.desktop"
perl -pi -e "s/%ICON%/$1/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
perl -pi -e "s/%NAME%/$2/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
perl -pi -e "s/%DESCRIPTION%/$3/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
perl -pi -e "s/%DIR_NAME%/$DIR_NAME/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
+ # Now create the two required shader files. We prepend the common.glsl to each shader.
+ # We also define KWIN and KWIN_LEGACY. The code in common.glsl takes some different
+ # paths based on these defines.
{
echo "#version 140"
echo "#define KWIN"
@@ -101,14 +117,15 @@ generate() {
clang-format -i "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
fi
- # Create an archive for the effect.
+ # Finally, create an archive for the effect.
tar -C "$BUILD_DIR" -czf "$DIR_NAME.tar.gz" "$DIR_NAME"
}
+# Now run the above method for all supported effects.
generate "apparition" "[BMW] Apparition" "This effect hides your windows by violently sucking them into the void of magic"
generate "energize-a" "[BMW] Energize A" "Beam your windows away"
generate "energize-b" "[BMW] Energize B" "Using different transporter technology results in an alternative visual effect"
generate "fire" "[BMW] Fire" "The classic effect inspired by Compiz"
generate "hexagon" "[BMW] Hexagon" "With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi"
generate "tv" "[BMW] TV Effect" "Make windows close like turning off a TV"
-generate "wisps" "[BMW] Wisps" "Let your windows be carried away to the realm of dreams by these little fairies"
\ No newline at end of file
+generate "wisps" "[BMW] Wisps" "Let your windows be carried away to the realm of dreams by these little fairies"
From 7e91b9c1f7028ef155fad431c5e703b06043886b Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Sun, 12 Jun 2022 18:13:49 +0200
Subject: [PATCH 55/71] :memo: Update README
---
README.md | 90 ++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 80 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index 814c181..fd8177d 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
(and KWin as well)
-When I released the [Desktop Cube Extension](https://github.com/Schneegans/Desktop-Cube/), many people requested to revive one of the most useless features of Linux desktop history: Setting windows on fire! +When I released the [Desktop Cube Extension](https://github.com/Schneegans/Desktop-Cube/) for GNOME, many people requested to revive one of the most useless features of Linux desktop history: Setting windows on fire! This extension is not only more useless than the cube, but it is also much more hacky. So I expect some bug! [Let's incinerate them all](https://github.com/Schneegans/Burn-My-Windows/issues)! -For a list of things changed in previous releases, you can have a look at the [changelog](docs/changelog.md)! - +Burn-My-Windows is not only available for **GNOME** but also includes some basic support for **KDE Plasma's KWin**. +Further down in this file you'll find installation instructions for both. Effect | Preview -----|-------- -**Apparition**
-**Broken Glass**
+**Apparition**
+**Broken Glass**
**Energize A**
**Energize B**
**Fire**
**Hexagon**
-**Matrix**
-**Snap of Disintegration**
-**T-Rex Attack**
+**Matrix**
+**Snap of Disintegration**
+**T-Rex Attack**
**TV-Effect**
**Wisps**
**Your Effect!** | + | GNOME | +KWin | +||||
| 3.36 | 3.38 | 40 | 41 | 42 | 5.25 | |
| Apparition | ✅ | ✅ | ✅ | ✅ | ||
| Broken Glass | ✅ | ✅ | ✅ | |||
| Energize A | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Energize B | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Fire | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Hexagon | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Matrix | ✅ | ✅ | ✅ | |||
| Snap of Disintegration | ✅ | ✅ | ✅ | |||
| T-Rex Attack | ✅ | ✅ | ✅ | |||
| TV-Effect | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Wisps | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Date: Mon, 13 Jun 2022 06:15:20 +0200
Subject: [PATCH 56/71] :wrench: Add helpers to read color settings
---
kwin/main.js.in | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/kwin/main.js.in b/kwin/main.js.in
index eec52cf..ba29b8a 100755
--- a/kwin/main.js.in
+++ b/kwin/main.js.in
@@ -30,6 +30,29 @@ class %EFFECT_CLASS% {
this.loadConfig();
}
+ // A small helper which can be used to read a hex color string (e.g. #ff3244) from the
+ // settings. This method will return an array of four floating point values
+ // [r, g, b, a]. If the settings key only refers to an rgb value, the alpha component
+ // will be set to 1.0.
+ readRGBAConfig(key) {
+ const color = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?([a-f\d]{2})?$/i
+ .exec(effect.readConfig(key, '#ffffff'))
+ .slice(1)
+ .filter(x => x !== undefined)
+ .map(x => parseInt(x, 16) / 255);
+ return color.length == 3 ? [color[0], color[1], color[2], 1.0] :
+ [color[1], color[2], color[3], color[0]];
+ }
+
+ // A small helper which can be used to read a hex color string (e.g. #ff3244) from the
+ // settings. This method will return an array of three floating point values [r, g, b]
+ // regardless of whether the settings key actually refers to an argb hex string.
+ readRGBConfig(key) {
+ const color = readRGBAConfig(key);
+ color.pop();
+ return color;
+ }
+
loadConfig() {
this.duration = animationTime(effect.readConfig('Duration', 1000));
From ad76fff3081a8af3b4a69dc230ba8fe287aaf377 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Mon, 13 Jun 2022 06:16:59 +0200
Subject: [PATCH 57/71] :wrench: Use RGB for energize a color
---
kwin/energize-a/onSettingsChanged.js | 2 +-
resources/shaders/energize-a.frag | 6 +++---
src/EnergizeA.js | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/kwin/energize-a/onSettingsChanged.js b/kwin/energize-a/onSettingsChanged.js
index e6b23f2..9d2b8fa 100644
--- a/kwin/energize-a/onSettingsChanged.js
+++ b/kwin/energize-a/onSettingsChanged.js
@@ -3,5 +3,5 @@
// the effect.
effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
-effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
+effect.setUniform(this.shader, 'uColor', this.readRGBConfig('Color'));
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
\ No newline at end of file
diff --git a/resources/shaders/energize-a.frag b/resources/shaders/energize-a.frag
index 6869dd7..8124fe5 100644
--- a/resources/shaders/energize-a.frag
+++ b/resources/shaders/energize-a.frag
@@ -13,7 +13,7 @@
// The content from common.glsl is automatically prepended to each shader effect.
-uniform vec4 uColor;
+uniform vec3 uColor;
uniform float uScale;
const float FADE_IN_TIME = 0.3;
@@ -63,7 +63,7 @@ void main() {
vec4 oColor = getInputColor(iTexCoord.st);
// Dissolve window to effect color / transparency.
- oColor.rgb = mix(uColor.rgb, oColor.rgb, 0.2 * masks.y + 0.8);
+ oColor.rgb = mix(uColor, oColor.rgb, 0.2 * masks.y + 0.8);
oColor.a = oColor.a * masks.y;
vec2 scaledUV = (iTexCoord.st - 0.5) * (1.0 + 0.1 * progress);
@@ -81,7 +81,7 @@ void main() {
particles += 0.5 * pow(0.2 * (1.0 / (1.0 - atoms) - 1.0), 2.0);
}
- oColor.rgb += uColor.rgb * particles * masks.x;
+ oColor.rgb += uColor * particles * masks.x;
oColor.a += particles * masks.x;
// These are pretty useful for understanding how this works.
diff --git a/src/EnergizeA.js b/src/EnergizeA.js
index 4d76cc6..1064c7e 100644
--- a/src/EnergizeA.js
+++ b/src/EnergizeA.js
@@ -51,7 +51,7 @@ var EnergizeA = class {
const c = Clutter.Color.from_string(settings.get_string('energize-a-color'))[1];
// clang-format off
- shader.set_uniform_float(shader._uColor, 4, [c.red / 255, c.green / 255, c.blue / 255, 1.0]);
+ shader.set_uniform_float(shader._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
shader.set_uniform_float(shader._uScale, 1, [settings.get_double('energize-a-scale')]);
// clang-format on
});
From 87209db9bd5d34c4d8b36362a92b2192e5f519b2 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Mon, 13 Jun 2022 06:18:28 +0200
Subject: [PATCH 58/71] :wrench: Fix typo
---
kwin/main.js.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kwin/main.js.in b/kwin/main.js.in
index ba29b8a..c067e65 100755
--- a/kwin/main.js.in
+++ b/kwin/main.js.in
@@ -48,7 +48,7 @@ class %EFFECT_CLASS% {
// settings. This method will return an array of three floating point values [r, g, b]
// regardless of whether the settings key actually refers to an argb hex string.
readRGBConfig(key) {
- const color = readRGBAConfig(key);
+ const color = this.readRGBAConfig(key);
color.pop();
return color;
}
From 8d6b844defb8d74dda0d00f0372fab90621975f2 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Mon, 13 Jun 2022 06:20:17 +0200
Subject: [PATCH 59/71] :wrench: Use RGB for energize b color
---
kwin/energize-b/onSettingsChanged.js | 2 +-
resources/shaders/energize-b.frag | 10 +++++-----
src/EnergizeB.js | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/kwin/energize-b/onSettingsChanged.js b/kwin/energize-b/onSettingsChanged.js
index 8797f46..46bff9e 100644
--- a/kwin/energize-b/onSettingsChanged.js
+++ b/kwin/energize-b/onSettingsChanged.js
@@ -3,5 +3,5 @@
// the effect.
effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
-effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
+effect.setUniform(this.shader, 'uColor', this.readRGBConfig('Color'));
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
diff --git a/resources/shaders/energize-b.frag b/resources/shaders/energize-b.frag
index e61e26b..200efb9 100644
--- a/resources/shaders/energize-b.frag
+++ b/resources/shaders/energize-b.frag
@@ -13,7 +13,7 @@
// The content from common.glsl is automatically prepended to each shader effect.
-uniform vec4 uColor;
+uniform vec3 uColor;
uniform float uScale;
const float SHOWER_TIME = 0.3;
@@ -80,28 +80,28 @@ void main() {
vec4 oColor = getInputColor(iTexCoord.st);
// Dissolve window to effect color / transparency.
- oColor.rgb = mix(uColor.rgb, oColor.rgb, 0.5 * masks.w + 0.5);
+ oColor.rgb = mix(uColor, oColor.rgb, 0.5 * masks.w + 0.5);
oColor.a = oColor.a * masks.w;
// Add leading shower particles.
vec2 showerUV = iTexCoord.st + vec2(0.0, -0.7 * progress / SHOWER_TIME);
showerUV *= 0.02 * uSize / uScale;
float shower = pow(simplex2D(showerUV), 10.0);
- oColor.rgb += uColor.rgb * shower * masks.x;
+ oColor.rgb += uColor * shower * masks.x;
oColor.a += shower * masks.x;
// Add trailing streak lines.
vec2 streakUV = iTexCoord.st + vec2(0.0, -progress / SHOWER_TIME);
streakUV *= vec2(0.05 * uSize.x, 0.001 * uSize.y) / uScale;
float streaks = simplex2DFractal(streakUV) * 0.5;
- oColor.rgb += uColor.rgb * streaks * masks.y;
+ oColor.rgb += uColor * streaks * masks.y;
oColor.a += streaks * masks.y;
// Add glimmering atoms.
vec2 atomUV = iTexCoord.st + vec2(0.0, -0.025 * progress / SHOWER_TIME);
atomUV *= 0.2 * uSize / uScale;
float atoms = pow((simplex3D(vec3(atomUV, uProgress * uDuration))), 5.0);
- oColor.rgb += uColor.rgb * atoms * masks.z;
+ oColor.rgb += uColor * atoms * masks.z;
oColor.a += atoms * masks.z;
// These are pretty useful for understanding how this works.
diff --git a/src/EnergizeB.js b/src/EnergizeB.js
index 9640f83..0123857 100644
--- a/src/EnergizeB.js
+++ b/src/EnergizeB.js
@@ -51,7 +51,7 @@ var EnergizeB = class {
const c = Clutter.Color.from_string(settings.get_string('energize-b-color'))[1];
// clang-format off
- shader.set_uniform_float(shader._uColor, 4, [c.red / 255, c.green / 255, c.blue / 255, 1.0]);
+ shader.set_uniform_float(shader._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
shader.set_uniform_float(shader._uScale, 1, [settings.get_double('energize-b-scale')]);
// clang-format on
});
From fda91e69bb7ed3729046673ac9c4e6cf1448c94b Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Mon, 13 Jun 2022 06:22:27 +0200
Subject: [PATCH 60/71] :wrench: Use RGB for TV color
---
kwin/tv/onSettingsChanged.js | 2 +-
resources/shaders/tv.frag | 4 ++--
src/TVEffect.js | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/kwin/tv/onSettingsChanged.js b/kwin/tv/onSettingsChanged.js
index e656b03..c739437 100644
--- a/kwin/tv/onSettingsChanged.js
+++ b/kwin/tv/onSettingsChanged.js
@@ -2,4 +2,4 @@
// The code below is called whenever the user changes something in the configuration of
// the effect.
-effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
\ No newline at end of file
+effect.setUniform(this.shader, 'uColor', this.readRGBConfig('Color'));
\ No newline at end of file
diff --git a/resources/shaders/tv.frag b/resources/shaders/tv.frag
index ea53b4c..c3da0b8 100644
--- a/resources/shaders/tv.frag
+++ b/resources/shaders/tv.frag
@@ -13,7 +13,7 @@
// The content from common.glsl is automatically prepended to each shader effect.
-uniform vec4 uColor;
+uniform vec3 uColor;
const float BLUR_WIDTH = 0.01; // Width of the gradients.
const float TB_TIME = 0.7; // Relative time for the top/bottom animation.
@@ -55,7 +55,7 @@ void main() {
float mask = tbMask * lrMask * ffMask;
vec4 oColor = getInputColor(coords);
- oColor.rgb = mix(oColor.rgb, uColor.rgb * oColor.a, smoothstep(0.0, 1.0, prog));
+ oColor.rgb = mix(oColor.rgb, uColor * oColor.a, smoothstep(0.0, 1.0, prog));
oColor.a *= mask;
// These are pretty useful for understanding how this works.
diff --git a/src/TVEffect.js b/src/TVEffect.js
index b02d8bd..f1cfe5f 100644
--- a/src/TVEffect.js
+++ b/src/TVEffect.js
@@ -50,8 +50,8 @@ var TVEffect = class {
// Write all uniform values at the start of each animation.
shader.connect('begin-animation', (shader, settings) => {
const c = Clutter.Color.from_string(settings.get_string('tv-effect-color'))[1];
- shader.set_uniform_float(shader._uColor, 4,
- [c.red / 255, c.green / 255, c.blue / 255, 1.0]);
+ shader.set_uniform_float(shader._uColor, 3,
+ [c.red / 255, c.green / 255, c.blue / 255]);
});
});
}
From d76aea4fc8f5d8541a878a0c0208ac0f8b83f3ce Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Mon, 13 Jun 2022 06:24:38 +0200
Subject: [PATCH 61/71] :wrench: Use rgba color config readers
---
kwin/fire/onSettingsChanged.js | 10 +++++-----
kwin/hexagon/onSettingsChanged.js | 4 ++--
kwin/wisps/onSettingsChanged.js | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/kwin/fire/onSettingsChanged.js b/kwin/fire/onSettingsChanged.js
index d6ef48d..82fe9a4 100644
--- a/kwin/fire/onSettingsChanged.js
+++ b/kwin/fire/onSettingsChanged.js
@@ -7,8 +7,8 @@ effect.setUniform(this.shader, 'u3DNoise',
effect.readConfig('3DNoise', true) ? 1.0 : 0.0);
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
effect.setUniform(this.shader, 'uMovementSpeed', effect.readConfig('MovementSpeed', 1.0));
-effect.setUniform(this.shader, 'uGradient1', effect.readConfig('Gradient1', 'white'));
-effect.setUniform(this.shader, 'uGradient2', effect.readConfig('Gradient2', 'white'));
-effect.setUniform(this.shader, 'uGradient3', effect.readConfig('Gradient3', 'white'));
-effect.setUniform(this.shader, 'uGradient4', effect.readConfig('Gradient4', 'white'));
-effect.setUniform(this.shader, 'uGradient5', effect.readConfig('Gradient5', 'white'));
+effect.setUniform(this.shader, 'uGradient1', this.readRGBAConfig('Gradient1'));
+effect.setUniform(this.shader, 'uGradient2', this.readRGBAConfig('Gradient2'));
+effect.setUniform(this.shader, 'uGradient3', this.readRGBAConfig('Gradient3'));
+effect.setUniform(this.shader, 'uGradient4', this.readRGBAConfig('Gradient4'));
+effect.setUniform(this.shader, 'uGradient5', this.readRGBAConfig('Gradient5'));
diff --git a/kwin/hexagon/onSettingsChanged.js b/kwin/hexagon/onSettingsChanged.js
index b7a8b20..c64a254 100644
--- a/kwin/hexagon/onSettingsChanged.js
+++ b/kwin/hexagon/onSettingsChanged.js
@@ -6,5 +6,5 @@ effect.setUniform(this.shader, 'uAdditiveBlending',
effect.readConfig('AdditiveBlending', true) ? 1.0 : 0.0);
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
effect.setUniform(this.shader, 'uLineWidth', effect.readConfig('LineWidth', 1.0));
-effect.setUniform(this.shader, 'uGlowColor', effect.readConfig('GlowColor', 'white'));
-effect.setUniform(this.shader, 'uLineColor', effect.readConfig('LineColor', 'white'));
+effect.setUniform(this.shader, 'uGlowColor', this.readRGBAConfig('GlowColor'));
+effect.setUniform(this.shader, 'uLineColor', this.readRGBAConfig('LineColor'));
diff --git a/kwin/wisps/onSettingsChanged.js b/kwin/wisps/onSettingsChanged.js
index 6928ce8..a7845fc 100644
--- a/kwin/wisps/onSettingsChanged.js
+++ b/kwin/wisps/onSettingsChanged.js
@@ -4,4 +4,4 @@
effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
-effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
+effect.setUniform(this.shader, 'uColor', this.readRGBAConfig('Color'));
From ca4484727f2031c1e6d8789f3adb7f2b9d4c512a Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Mon, 13 Jun 2022 06:27:10 +0200
Subject: [PATCH 62/71] :wrench: Use RGB for wisps color
---
kwin/wisps/onSettingsChanged.js | 2 +-
resources/shaders/wisps.frag | 4 ++--
src/Wisps.js | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kwin/wisps/onSettingsChanged.js b/kwin/wisps/onSettingsChanged.js
index a7845fc..6d55e65 100644
--- a/kwin/wisps/onSettingsChanged.js
+++ b/kwin/wisps/onSettingsChanged.js
@@ -4,4 +4,4 @@
effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
-effect.setUniform(this.shader, 'uColor', this.readRGBAConfig('Color'));
+effect.setUniform(this.shader, 'uColor', this.readRGBConfig('Color'));
diff --git a/resources/shaders/wisps.frag b/resources/shaders/wisps.frag
index 11daf9a..4550715 100644
--- a/resources/shaders/wisps.frag
+++ b/resources/shaders/wisps.frag
@@ -14,7 +14,7 @@
// The content from common.glsl is automatically prepended to each shader effect.
uniform vec2 uSeed;
-uniform vec4 uColor;
+uniform vec3 uColor;
uniform float uScale;
const float WISPS_RADIUS = 20.0;
@@ -99,7 +99,7 @@ void main() {
oColor.a *= windowMask * mask;
// Add the wisps.
- vec4 wispColor = wisps * vec4(uColor.rgb, min(wispsIn, 1.0 - wispsOut) * mask);
+ vec4 wispColor = wisps * vec4(uColor, min(wispsIn, 1.0 - wispsOut) * mask);
oColor = alphaOver(oColor, wispColor);
// These are pretty useful for understanding how this works.
diff --git a/src/Wisps.js b/src/Wisps.js
index 69f09e6..bb6919e 100644
--- a/src/Wisps.js
+++ b/src/Wisps.js
@@ -58,7 +58,7 @@ var Wisps = class {
// clang-format off
shader.set_uniform_float(shader._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
- shader.set_uniform_float(shader._uColor, 4, [c.red / 255, c.green / 255, c.blue / 255, 1.0]);
+ shader.set_uniform_float(shader._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
shader.set_uniform_float(shader._uScale, 1, [settings.get_double('wisps-scale')]);
// clang-format on
});
From b3568d9be56ff1e9e968e600b62210245c347a33 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Tue, 14 Jun 2022 05:53:32 +0200
Subject: [PATCH 63/71] :memo: Add disclaimer to tutorial
---
docs/how-to-create-new-effects.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/docs/how-to-create-new-effects.md b/docs/how-to-create-new-effects.md
index db82aca..72e2a26 100644
--- a/docs/how-to-create-new-effects.md
+++ b/docs/how-to-create-new-effects.md
@@ -3,6 +3,8 @@
The extension is very modular and with a bit of creativity and GLSL knowledge, you can easily create your own effects.
If you are happy with your results, please open a pull request so that we can include your effect in the next version of Burn-My-Windows!
+_:warning: For now, this guide is only for GNOME Shell (and not for KWin). As soon as the API for KWin is more stable, this guide will be updated._
+
### Before you Start
First you should [fork the repository](https://github.com/Schneegans/Burn-My-Windows/fork) and clone it to your PC.
From b31a166b2231acbdddc1f685bbdad08114d83764 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Tue, 14 Jun 2022 06:11:08 +0200
Subject: [PATCH 64/71] :memo: Update kwin instructions
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fd8177d..9acb000 100644
--- a/README.md
+++ b/README.md
@@ -172,7 +172,7 @@ Install it by executing the following commands.
```bash
mkdir -p ~/.local/share/kwin/effects
-unzip burn_my_windows_kwin4.zip -d ~/.local/share/kwin/effects
+tar -xf burn_my_windows_kwin4.tar.gz -C ~/.local/share/kwin/effects
```
Then select the desired effects in the system settings under "Desktop Effects".
From 9057f8cceb98dfb0f278fb98e05b7ee9d545767a Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Tue, 14 Jun 2022 06:13:05 +0200
Subject: [PATCH 65/71] :wrench: Put all effects into one archive
---
kwin/build.sh | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 33a02dd..6931aa8 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -116,9 +116,6 @@ generate() {
then
clang-format -i "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
fi
-
- # Finally, create an archive for the effect.
- tar -C "$BUILD_DIR" -czf "$DIR_NAME.tar.gz" "$DIR_NAME"
}
# Now run the above method for all supported effects.
@@ -129,3 +126,7 @@ generate "fire" "[BMW] Fire" "The classic effect inspired by Compiz"
generate "hexagon" "[BMW] Hexagon" "With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi"
generate "tv" "[BMW] TV Effect" "Make windows close like turning off a TV"
generate "wisps" "[BMW] Wisps" "Let your windows be carried away to the realm of dreams by these little fairies"
+
+# Finally, create an archive for the effects.
+# shellcheck disable=SC2046
+tar -cjf "burn_my_windows_kwin4.tar.gz" -C "$BUILD_DIR" $(ls "$BUILD_DIR")
\ No newline at end of file
From 4ab87d1257d8919ec10e7857cef03123d433aa8b Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Tue, 14 Jun 2022 06:17:06 +0200
Subject: [PATCH 66/71] :wrench: Create kwin package on tags
---
.github/workflows/deploy.yml | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 044375b..289951f 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -6,8 +6,8 @@ on:
- '**'
jobs:
- extension_bundle:
- name: Extension Bundle
+ gnome_bundle:
+ name: Bundle GNOME Shell Extension
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
@@ -26,3 +26,24 @@ jobs:
file: burn-my-windows@schneegans.github.com.zip
tag: ${{ github.ref }}
overwrite: true
+
+ kwin_bundle:
+ name: Bundle Kwin Effect
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v2
+ - name: Install Dependencies
+ run: |
+ sudo apt-get update -q
+ sudo apt-get install clang-format
+ - name: Create Release
+ run: |
+ ./kwin/build.sh
+ - name: Upload Release
+ uses: svenstaro/upload-release-action@2.2.1
+ with:
+ repo_token: ${{ secrets.GITHUB_TOKEN }}
+ file: kwin/burn_my_windows_kwin4.tar.gz
+ tag: ${{ github.ref }}
+ overwrite: true
From fdad5f6c897e7cd8dce48e305de729332b2ee097 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Tue, 14 Jun 2022 06:20:42 +0200
Subject: [PATCH 67/71] :wrench: Fix job name
---
.github/workflows/deploy.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 289951f..d5059f6 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -28,7 +28,7 @@ jobs:
overwrite: true
kwin_bundle:
- name: Bundle Kwin Effect
+ name: Bundle KWin Effect
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
From caec83a391df1b5914b3952e5e9912a29b514228 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Tue, 14 Jun 2022 06:20:49 +0200
Subject: [PATCH 68/71] :memo: Fix archive name
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 9acb000..acea9fc 100644
--- a/README.md
+++ b/README.md
@@ -165,7 +165,7 @@ You can either download a stable version from GitHub (a) or clone the latest ver
Execute this command to download the latest stable release:
```bash
-wget https://github.com/Schneegans/Burn-My-Windows/releases/latest/download/burn_my_windows_kwin4.zip
+wget https://github.com/Schneegans/Burn-My-Windows/releases/latest/download/burn_my_windows_kwin4.tar.gz
```
Install it by executing the following commands.
From 4e5ddfdcc652f96b653a7968216fa2b305192260 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 16 Jun 2022 05:19:55 +0200
Subject: [PATCH 69/71] :wrench: Do not build the apparition effect for KWin
for now
---
kwin/build.sh | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kwin/build.sh b/kwin/build.sh
index 6931aa8..316e54e 100755
--- a/kwin/build.sh
+++ b/kwin/build.sh
@@ -119,7 +119,11 @@ generate() {
}
# Now run the above method for all supported effects.
-generate "apparition" "[BMW] Apparition" "This effect hides your windows by violently sucking them into the void of magic"
+
+# The apparition effect is disabled for now. I have not yet found a way to upscale the
+# window canvas during the animation.
+#generate "apparition" "[BMW] Apparition" "This effect hides your windows by violently sucking them into the void of magic"
+
generate "energize-a" "[BMW] Energize A" "Beam your windows away"
generate "energize-b" "[BMW] Energize B" "Using different transporter technology results in an alternative visual effect"
generate "fire" "[BMW] Fire" "The classic effect inspired by Compiz"
From 3afbf6d93b790ea8d3e8193a06a3cc9e28542893 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 16 Jun 2022 05:25:54 +0200
Subject: [PATCH 70/71] :memo: Add changelog entry
---
docs/changelog.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/changelog.md b/docs/changelog.md
index f20cba8..fba0b60 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -6,6 +6,7 @@
#### New Features
+* **Initial KDE Support.** Thanks to the [awesome work](https://invent.kde.org/plasma/kwin/-/merge_requests/2227) of Martin Flöser, it has become possible to port some of its effects to KDE Plasma! For now, only the most simple effects can be ported, but hopefully this list can be improved in the future.
* An option has been added which allows to automatically disable all effects if running on battery power.
#### Enhancements
From bb44d4bd811e5ed1421281661777f49f7c33b243 Mon Sep 17 00:00:00 2001
From: Simon Schneegans
Date: Thu, 16 Jun 2022 05:29:25 +0200
Subject: [PATCH 71/71] :fire: Remove empty file
---
kwin/README.md | 0
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 kwin/README.md
diff --git a/kwin/README.md b/kwin/README.md
deleted file mode 100644
index e69de29..0000000