BlueGit

timfa kwin-marble

Per-window state in the single uProgress animation (no extra animations): uProgress = tintIndex*4096 + morph-normalised progress; shader decodes tint and morph progress, so concurrent windows no longer share tint/uCrumpleEnd. Random colour derived from window.internalId + per-window counter, reused on restore

timfa Tim Falken · pushed by timfa

Authored 2026-11-02 · 2 weeks ago

Hash
4a2b092a90caf67728932d6f839c0b263b9bcaea
Parent
698e0d60
6 files changed +76 −20
kwin6_effect_marble/contents/code/main.js +17 −6
@@ -100,12 +100,23 @@ class BurnMyWindowsMarbleEffect {
100 100
101 101 // Mix target colour. tintMode 11 = random; with reuse, a random colour picked for this
102 102 // window (e.g. at minimize) is used again (e.g. at unminimize) and then forgotten.
103 // uProgress value for this window: tint base + morph-normalised progress m (capped, see shader)
104 prog(window, m) { return (window.bmwBase || 0) + Math.min(4000, Math.max(0, m)); }
105
106 crumpleEnd() { return Math.max(1e-4, this.duration / Math.max(1, this.duration + this.pause + this.fallDuration)); }
107
103 108 applyTint(window, reuse) {
104 109 const C = [[0.0000,0.0000,0.0000],[0.0000,0.0000,0.6667],[0.6667,0.0000,0.0000],[0.0000,0.6667,0.0000],[0.4000,0.0000,0.6667],[0.6667,0.6667,0.0000],[0.6667,0.3333,0.0000],[0.0000,0.6667,0.6667],[0.6667,0.0000,0.4000],[0.3333,0.3333,0.3333],[0.3333,0.2000,0.0000]];
105 110 let c;
106 if (this.tintMode < C.length) c = C[this.tintMode];
111 if (this.tintMode < C.length) { c = C[this.tintMode]; if (window) window.bmwTint = null; }
107 112 else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }
108 else { c = C[Math.floor(Math.random() * C.length)]; if (window) window.bmwTint = c; }
113 else if (window) { // random: derived from the window id + a per-window counter (new colour per close/minimize)
114 let h = 0; const id = String(window.internalId) + '#' + (window.bmwN = (window.bmwN || 0) + 1);
115 for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) | 0;
116 c = C[Math.abs(h) % C.length]; window.bmwTint = c;
117 }
118 else c = C[0];
119 if (window) window.bmwBase = 4096 * Math.max(0, C.findIndex(x => x[0] == c[0] && x[1] == c[1] && x[2] == c[2])); // per-window tint, carried in uProgress
109 120 effect.setUniform(this.shader, 'uTintR', c[0]);
110 121 effect.setUniform(this.shader, 'uTintG', c[1]);
111 122 effect.setUniform(this.shader, 'uTintB', c[2]);
@@ -202,8 +213,8 @@ class BurnMyWindowsMarbleEffect {
202 213 type: Effect.ShaderUniform,
203 214 fragmentShader: this.shader,
204 215 uniform: 'uProgress',
205 from: 0.0,
206 to: 1.0
216 from: this.prog(window, 0.0),
217 to: this.prog(window, 1.0 / this.crumpleEnd())
207 218 }]
208 219 });
209 220 }
@@ -242,8 +253,8 @@ class BurnMyWindowsMarbleEffect {
242 253 type: Effect.ShaderUniform,
243 254 fragmentShader: this.shader,
244 255 uniform: 'uProgress',
245 from: 0.0,
246 to: 1.0
256 from: this.prog(window, 0.0),
257 to: this.prog(window, 1.0 / this.crumpleEnd())
247 258 }]
248 259 });
249 260 // 2) marker animation that ends exactly when the marble is done; the fall is
@@ -100,12 +100,23 @@ class BurnMyWindowsMarbleEffect {
100
100
101 // Mix target colour. tintMode 11 = random; with reuse, a random colour picked for this
101 // Mix target colour. tintMode 11 = random; with reuse, a random colour picked for this
102 // window (e.g. at minimize) is used again (e.g. at unminimize) and then forgotten.
102 // window (e.g. at minimize) is used again (e.g. at unminimize) and then forgotten.
103 // uProgress value for this window: tint base + morph-normalised progress m (capped, see shader)
104 prog(window, m) { return (window.bmwBase || 0) + Math.min(4000, Math.max(0, m)); }
105
106 crumpleEnd() { return Math.max(1e-4, this.duration / Math.max(1, this.duration + this.pause + this.fallDuration)); }
107
103 applyTint(window, reuse) {
108 applyTint(window, reuse) {
104 const C = [[0.0000,0.0000,0.0000],[0.0000,0.0000,0.6667],[0.6667,0.0000,0.0000],[0.0000,0.6667,0.0000],[0.4000,0.0000,0.6667],[0.6667,0.6667,0.0000],[0.6667,0.3333,0.0000],[0.0000,0.6667,0.6667],[0.6667,0.0000,0.4000],[0.3333,0.3333,0.3333],[0.3333,0.2000,0.0000]];
109 const C = [[0.0000,0.0000,0.0000],[0.0000,0.0000,0.6667],[0.6667,0.0000,0.0000],[0.0000,0.6667,0.0000],[0.4000,0.0000,0.6667],[0.6667,0.6667,0.0000],[0.6667,0.3333,0.0000],[0.0000,0.6667,0.6667],[0.6667,0.0000,0.4000],[0.3333,0.3333,0.3333],[0.3333,0.2000,0.0000]];
105 let c;
110 let c;
106 if (this.tintMode < C.length) c = C[this.tintMode];
111 if (this.tintMode < C.length) { c = C[this.tintMode]; if (window) window.bmwTint = null; }
107 else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }
112 else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }
108 else { c = C[Math.floor(Math.random() * C.length)]; if (window) window.bmwTint = c; }
113 else if (window) { // random: derived from the window id + a per-window counter (new colour per close/minimize)
114 let h = 0; const id = String(window.internalId) + '#' + (window.bmwN = (window.bmwN || 0) + 1);
115 for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) | 0;
116 c = C[Math.abs(h) % C.length]; window.bmwTint = c;
117 }
118 else c = C[0];
119 if (window) window.bmwBase = 4096 * Math.max(0, C.findIndex(x => x[0] == c[0] && x[1] == c[1] && x[2] == c[2])); // per-window tint, carried in uProgress
109 effect.setUniform(this.shader, 'uTintR', c[0]);
120 effect.setUniform(this.shader, 'uTintR', c[0]);
110 effect.setUniform(this.shader, 'uTintG', c[1]);
121 effect.setUniform(this.shader, 'uTintG', c[1]);
111 effect.setUniform(this.shader, 'uTintB', c[2]);
122 effect.setUniform(this.shader, 'uTintB', c[2]);
@@ -202,8 +213,8 @@ class BurnMyWindowsMarbleEffect {
202 type: Effect.ShaderUniform,
213 type: Effect.ShaderUniform,
203 fragmentShader: this.shader,
214 fragmentShader: this.shader,
204 uniform: 'uProgress',
215 uniform: 'uProgress',
205 from: 0.0,
216 from: this.prog(window, 0.0),
206 to: 1.0
217 to: this.prog(window, 1.0 / this.crumpleEnd())
207 }]
218 }]
208 });
219 });
209 }
220 }
@@ -242,8 +253,8 @@ class BurnMyWindowsMarbleEffect {
242 type: Effect.ShaderUniform,
253 type: Effect.ShaderUniform,
243 fragmentShader: this.shader,
254 fragmentShader: this.shader,
244 uniform: 'uProgress',
255 uniform: 'uProgress',
245 from: 0.0,
256 from: this.prog(window, 0.0),
246 to: 1.0
257 to: this.prog(window, 1.0 / this.crumpleEnd())
247 }]
258 }]
248 });
259 });
249 // 2) marker animation that ends exactly when the marble is done; the fall is
260 // 2) marker animation that ends exactly when the marble is done; the fall is
kwin6_effect_marble/contents/shaders/marble.frag +11 −2
@@ -751,7 +751,16 @@ uniform float uMarbleSize; // marble diameter in px
751 751 uniform float uMixCenter; // 0..1 black mix, centre/top zone
752 752
753 753 void main() {
754 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
754 // per-window state lives in uProgress (setUniform is global for all windows):
755 // uProgress = tintIndex * 4096 + m, with m = 1 when the morph is complete
756 float tk = floor(uProgress / 4096.0);
757 float c = clamp(uProgress - tk * 4096.0, 0.0, 1.0);
758 if (uCrumpleEnd < -1.0) c = 0.0; // keep uCrumpleEnd alive (still set by the script)
759 vec3 tint = tk < 0.5 ? vec3(0.0) : tk < 1.5 ? vec3(0.0, 0.0, 0.6667) : tk < 2.5 ? vec3(0.6667, 0.0, 0.0)
760 : tk < 3.5 ? vec3(0.0, 0.6667, 0.0) : tk < 4.5 ? vec3(0.4, 0.0, 0.6667) : tk < 5.5 ? vec3(0.6667, 0.6667, 0.0)
761 : tk < 6.5 ? vec3(0.6667, 0.3333, 0.0) : tk < 7.5 ? vec3(0.0, 0.6667, 0.6667) : tk < 8.5 ? vec3(0.6667, 0.0, 0.4)
762 : tk < 9.5 ? vec3(0.3333) : vec3(0.3333, 0.2, 0.0);
763 if (uTintR < -1.0 || uTintG < -1.0 || uTintB < -1.0) tint = vec3(0.0); // keep uniforms alive
755 764 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
756 765 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
757 766
@@ -784,7 +793,7 @@ void main() {
784 793 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
785 794 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
786 795 float outer = smoothstep(0.2, 0.85, length(bz));
787 col.rgb = mix(col.rgb, vec3(uTintR, uTintG, uTintB), e * mix(uMixCenter, uMixOuter, outer));
796 col.rgb = mix(col.rgb, tint, e * mix(uMixCenter, uMixOuter, outer));
788 797 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
789 798 vec2 sv = q - vec2(-0.40, -0.47);
790 799 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
@@ -751,7 +751,16 @@ uniform float uMarbleSize; // marble diameter in px
751uniform float uMixCenter; // 0..1 black mix, centre/top zone
751uniform float uMixCenter; // 0..1 black mix, centre/top zone
752
752
753void main() {
753void main() {
754 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
754 // per-window state lives in uProgress (setUniform is global for all windows):
755 // uProgress = tintIndex * 4096 + m, with m = 1 when the morph is complete
756 float tk = floor(uProgress / 4096.0);
757 float c = clamp(uProgress - tk * 4096.0, 0.0, 1.0);
758 if (uCrumpleEnd < -1.0) c = 0.0; // keep uCrumpleEnd alive (still set by the script)
759 vec3 tint = tk < 0.5 ? vec3(0.0) : tk < 1.5 ? vec3(0.0, 0.0, 0.6667) : tk < 2.5 ? vec3(0.6667, 0.0, 0.0)
760 : tk < 3.5 ? vec3(0.0, 0.6667, 0.0) : tk < 4.5 ? vec3(0.4, 0.0, 0.6667) : tk < 5.5 ? vec3(0.6667, 0.6667, 0.0)
761 : tk < 6.5 ? vec3(0.6667, 0.3333, 0.0) : tk < 7.5 ? vec3(0.0, 0.6667, 0.6667) : tk < 8.5 ? vec3(0.6667, 0.0, 0.4)
762 : tk < 9.5 ? vec3(0.3333) : vec3(0.3333, 0.2, 0.0);
763 if (uTintR < -1.0 || uTintG < -1.0 || uTintB < -1.0) tint = vec3(0.0); // keep uniforms alive
755 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
764 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
756 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
765 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
757
766
@@ -784,7 +793,7 @@ void main() {
784 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
793 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
785 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
794 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
786 float outer = smoothstep(0.2, 0.85, length(bz));
795 float outer = smoothstep(0.2, 0.85, length(bz));
787 col.rgb = mix(col.rgb, vec3(uTintR, uTintG, uTintB), e * mix(uMixCenter, uMixOuter, outer));
796 col.rgb = mix(col.rgb, tint, e * mix(uMixCenter, uMixOuter, outer));
788 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
797 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
789 vec2 sv = q - vec2(-0.40, -0.47);
798 vec2 sv = q - vec2(-0.40, -0.47);
790 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
799 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
kwin6_effect_marble/contents/shaders/marble_core.frag +11 −2
@@ -752,7 +752,16 @@ uniform float uMarbleSize; // marble diameter in px
752 752 uniform float uMixCenter; // 0..1 black mix, centre/top zone
753 753
754 754 void main() {
755 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
755 // per-window state lives in uProgress (setUniform is global for all windows):
756 // uProgress = tintIndex * 4096 + m, with m = 1 when the morph is complete
757 float tk = floor(uProgress / 4096.0);
758 float c = clamp(uProgress - tk * 4096.0, 0.0, 1.0);
759 if (uCrumpleEnd < -1.0) c = 0.0; // keep uCrumpleEnd alive (still set by the script)
760 vec3 tint = tk < 0.5 ? vec3(0.0) : tk < 1.5 ? vec3(0.0, 0.0, 0.6667) : tk < 2.5 ? vec3(0.6667, 0.0, 0.0)
761 : tk < 3.5 ? vec3(0.0, 0.6667, 0.0) : tk < 4.5 ? vec3(0.4, 0.0, 0.6667) : tk < 5.5 ? vec3(0.6667, 0.6667, 0.0)
762 : tk < 6.5 ? vec3(0.6667, 0.3333, 0.0) : tk < 7.5 ? vec3(0.0, 0.6667, 0.6667) : tk < 8.5 ? vec3(0.6667, 0.0, 0.4)
763 : tk < 9.5 ? vec3(0.3333) : vec3(0.3333, 0.2, 0.0);
764 if (uTintR < -1.0 || uTintG < -1.0 || uTintB < -1.0) tint = vec3(0.0); // keep uniforms alive
756 765 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
757 766 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
758 767
@@ -785,7 +794,7 @@ void main() {
785 794 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
786 795 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
787 796 float outer = smoothstep(0.2, 0.85, length(bz));
788 col.rgb = mix(col.rgb, vec3(uTintR, uTintG, uTintB), e * mix(uMixCenter, uMixOuter, outer));
797 col.rgb = mix(col.rgb, tint, e * mix(uMixCenter, uMixOuter, outer));
789 798 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
790 799 vec2 sv = q - vec2(-0.40, -0.47);
791 800 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
@@ -752,7 +752,16 @@ uniform float uMarbleSize; // marble diameter in px
752uniform float uMixCenter; // 0..1 black mix, centre/top zone
752uniform float uMixCenter; // 0..1 black mix, centre/top zone
753
753
754void main() {
754void main() {
755 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
755 // per-window state lives in uProgress (setUniform is global for all windows):
756 // uProgress = tintIndex * 4096 + m, with m = 1 when the morph is complete
757 float tk = floor(uProgress / 4096.0);
758 float c = clamp(uProgress - tk * 4096.0, 0.0, 1.0);
759 if (uCrumpleEnd < -1.0) c = 0.0; // keep uCrumpleEnd alive (still set by the script)
760 vec3 tint = tk < 0.5 ? vec3(0.0) : tk < 1.5 ? vec3(0.0, 0.0, 0.6667) : tk < 2.5 ? vec3(0.6667, 0.0, 0.0)
761 : tk < 3.5 ? vec3(0.0, 0.6667, 0.0) : tk < 4.5 ? vec3(0.4, 0.0, 0.6667) : tk < 5.5 ? vec3(0.6667, 0.6667, 0.0)
762 : tk < 6.5 ? vec3(0.6667, 0.3333, 0.0) : tk < 7.5 ? vec3(0.0, 0.6667, 0.6667) : tk < 8.5 ? vec3(0.6667, 0.0, 0.4)
763 : tk < 9.5 ? vec3(0.3333) : vec3(0.3333, 0.2, 0.0);
764 if (uTintR < -1.0 || uTintG < -1.0 || uTintB < -1.0) tint = vec3(0.0); // keep uniforms alive
756 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
765 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
757 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
766 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
758
767
@@ -785,7 +794,7 @@ void main() {
785 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
794 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
786 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
795 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
787 float outer = smoothstep(0.2, 0.85, length(bz));
796 float outer = smoothstep(0.2, 0.85, length(bz));
788 col.rgb = mix(col.rgb, vec3(uTintR, uTintG, uTintB), e * mix(uMixCenter, uMixOuter, outer));
797 col.rgb = mix(col.rgb, tint, e * mix(uMixCenter, uMixOuter, outer));
789 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
798 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
790 vec2 sv = q - vec2(-0.40, -0.47);
799 vec2 sv = q - vec2(-0.40, -0.47);
791 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
800 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
kwin6_effect_marble_minimize/contents/code/main.js +15 −6
@@ -106,12 +106,21 @@ class BurnMyWindowsMarbleMinimizeEffect {
106 106
107 107 // Mix target colour. tintMode 11 = random; with reuse, a random colour picked for this
108 108 // window (e.g. at minimize) is used again (e.g. at unminimize) and then forgotten.
109 // uProgress value for this window: tint base + morph-normalised progress m (capped, see shader)
110 prog(window, m) { return (window.bmwBase || 0) + Math.min(4000, Math.max(0, m)); }
111
109 112 applyTint(window, reuse) {
110 113 const C = [[0.0000,0.0000,0.0000],[0.0000,0.0000,0.6667],[0.6667,0.0000,0.0000],[0.0000,0.6667,0.0000],[0.4000,0.0000,0.6667],[0.6667,0.6667,0.0000],[0.6667,0.3333,0.0000],[0.0000,0.6667,0.6667],[0.6667,0.0000,0.4000],[0.3333,0.3333,0.3333],[0.3333,0.2000,0.0000]];
111 114 let c;
112 if (this.tintMode < C.length) c = C[this.tintMode];
115 if (this.tintMode < C.length) { c = C[this.tintMode]; if (window) window.bmwTint = null; }
113 116 else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }
114 else { c = C[Math.floor(Math.random() * C.length)]; if (window) window.bmwTint = c; }
117 else if (window) { // random: derived from the window id + a per-window counter (new colour per close/minimize)
118 let h = 0; const id = String(window.internalId) + '#' + (window.bmwN = (window.bmwN || 0) + 1);
119 for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) | 0;
120 c = C[Math.abs(h) % C.length]; window.bmwTint = c;
121 }
122 else c = C[0];
123 if (window) window.bmwBase = 4096 * Math.max(0, C.findIndex(x => x[0] == c[0] && x[1] == c[1] && x[2] == c[2])); // per-window tint, carried in uProgress
115 124 effect.setUniform(this.shader, 'uTintR', c[0]);
116 125 effect.setUniform(this.shader, 'uTintG', c[1]);
117 126 effect.setUniform(this.shader, 'uTintB', c[2]);
@@ -207,8 +216,8 @@ class BurnMyWindowsMarbleMinimizeEffect {
207 216 type: Effect.ShaderUniform,
208 217 fragmentShader: this.shader,
209 218 uniform: 'uProgress',
210 from: 0.0,
211 to: 1.0
219 from: this.prog(window, 0.0),
220 to: this.prog(window, 1.0 / Math.max(1e-4, this.duration / Math.max(1, this.duration + this.pause + this.fallDuration)))
212 221 }]
213 222 });
214 223 }
@@ -274,7 +283,7 @@ class BurnMyWindowsMarbleMinimizeEffect {
274 283 // one shader animation, deliberately longer; cancelled after the invisible tail (flash fix)
275 284 window.bmwMinAnimation = animate({
276 285 window: window, curve: QEasingCurve.Linear, duration: total + 3000,
277 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: (total + 3000) / Math.max(1, total) },
286 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: this.prog(window, 0.0), to: this.prog(window, (total + 3000) / Math.max(1, this.duration)) },
278 287 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
279 288 });
280 289 window.bmwMarbleDone = animate({
@@ -299,7 +308,7 @@ class BurnMyWindowsMarbleMinimizeEffect {
299 308 effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));
300 309 window.bmwUnminAnimation = animate({
301 310 window: window, curve: QEasingCurve.Linear, duration: total,
302 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 1.0, to: 0.0 }]
311 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: this.prog(window, total / Math.max(1, this.duration)), to: this.prog(window, 0.0) }]
303 312 });
304 313 this.fallAnims(window, f, -1);
305 314 window.bmwFadeInAnimation = animate({ window: window, curve: QEasingCurve.InExpo, duration: 80,
@@ -106,12 +106,21 @@ class BurnMyWindowsMarbleMinimizeEffect {
106
106
107 // Mix target colour. tintMode 11 = random; with reuse, a random colour picked for this
107 // Mix target colour. tintMode 11 = random; with reuse, a random colour picked for this
108 // window (e.g. at minimize) is used again (e.g. at unminimize) and then forgotten.
108 // window (e.g. at minimize) is used again (e.g. at unminimize) and then forgotten.
109 // uProgress value for this window: tint base + morph-normalised progress m (capped, see shader)
110 prog(window, m) { return (window.bmwBase || 0) + Math.min(4000, Math.max(0, m)); }
111
109 applyTint(window, reuse) {
112 applyTint(window, reuse) {
110 const C = [[0.0000,0.0000,0.0000],[0.0000,0.0000,0.6667],[0.6667,0.0000,0.0000],[0.0000,0.6667,0.0000],[0.4000,0.0000,0.6667],[0.6667,0.6667,0.0000],[0.6667,0.3333,0.0000],[0.0000,0.6667,0.6667],[0.6667,0.0000,0.4000],[0.3333,0.3333,0.3333],[0.3333,0.2000,0.0000]];
113 const C = [[0.0000,0.0000,0.0000],[0.0000,0.0000,0.6667],[0.6667,0.0000,0.0000],[0.0000,0.6667,0.0000],[0.4000,0.0000,0.6667],[0.6667,0.6667,0.0000],[0.6667,0.3333,0.0000],[0.0000,0.6667,0.6667],[0.6667,0.0000,0.4000],[0.3333,0.3333,0.3333],[0.3333,0.2000,0.0000]];
111 let c;
114 let c;
112 if (this.tintMode < C.length) c = C[this.tintMode];
115 if (this.tintMode < C.length) { c = C[this.tintMode]; if (window) window.bmwTint = null; }
113 else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }
116 else if (window && reuse && window.bmwTint) { c = window.bmwTint; window.bmwTint = null; }
114 else { c = C[Math.floor(Math.random() * C.length)]; if (window) window.bmwTint = c; }
117 else if (window) { // random: derived from the window id + a per-window counter (new colour per close/minimize)
118 let h = 0; const id = String(window.internalId) + '#' + (window.bmwN = (window.bmwN || 0) + 1);
119 for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) | 0;
120 c = C[Math.abs(h) % C.length]; window.bmwTint = c;
121 }
122 else c = C[0];
123 if (window) window.bmwBase = 4096 * Math.max(0, C.findIndex(x => x[0] == c[0] && x[1] == c[1] && x[2] == c[2])); // per-window tint, carried in uProgress
115 effect.setUniform(this.shader, 'uTintR', c[0]);
124 effect.setUniform(this.shader, 'uTintR', c[0]);
116 effect.setUniform(this.shader, 'uTintG', c[1]);
125 effect.setUniform(this.shader, 'uTintG', c[1]);
117 effect.setUniform(this.shader, 'uTintB', c[2]);
126 effect.setUniform(this.shader, 'uTintB', c[2]);
@@ -207,8 +216,8 @@ class BurnMyWindowsMarbleMinimizeEffect {
207 type: Effect.ShaderUniform,
216 type: Effect.ShaderUniform,
208 fragmentShader: this.shader,
217 fragmentShader: this.shader,
209 uniform: 'uProgress',
218 uniform: 'uProgress',
210 from: 0.0,
219 from: this.prog(window, 0.0),
211 to: 1.0
220 to: this.prog(window, 1.0 / Math.max(1e-4, this.duration / Math.max(1, this.duration + this.pause + this.fallDuration)))
212 }]
221 }]
213 });
222 });
214 }
223 }
@@ -274,7 +283,7 @@ class BurnMyWindowsMarbleMinimizeEffect {
274 // one shader animation, deliberately longer; cancelled after the invisible tail (flash fix)
283 // one shader animation, deliberately longer; cancelled after the invisible tail (flash fix)
275 window.bmwMinAnimation = animate({
284 window.bmwMinAnimation = animate({
276 window: window, curve: QEasingCurve.Linear, duration: total + 3000,
285 window: window, curve: QEasingCurve.Linear, duration: total + 3000,
277 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: (total + 3000) / Math.max(1, total) },
286 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: this.prog(window, 0.0), to: this.prog(window, (total + 3000) / Math.max(1, this.duration)) },
278 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
287 { type: Effect.Opacity, from: 1.0, to: 1.0 }]
279 });
288 });
280 window.bmwMarbleDone = animate({
289 window.bmwMarbleDone = animate({
@@ -299,7 +308,7 @@ class BurnMyWindowsMarbleMinimizeEffect {
299 effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));
308 effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));
300 window.bmwUnminAnimation = animate({
309 window.bmwUnminAnimation = animate({
301 window: window, curve: QEasingCurve.Linear, duration: total,
310 window: window, curve: QEasingCurve.Linear, duration: total,
302 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 1.0, to: 0.0 }]
311 animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: this.prog(window, total / Math.max(1, this.duration)), to: this.prog(window, 0.0) }]
303 });
312 });
304 this.fallAnims(window, f, -1);
313 this.fallAnims(window, f, -1);
305 window.bmwFadeInAnimation = animate({ window: window, curve: QEasingCurve.InExpo, duration: 80,
314 window.bmwFadeInAnimation = animate({ window: window, curve: QEasingCurve.InExpo, duration: 80,
kwin6_effect_marble_minimize/contents/shaders/marble.frag +11 −2
@@ -751,7 +751,16 @@ uniform float uMarbleSize; // marble diameter in px
751 751 uniform float uMixCenter; // 0..1 black mix, centre/top zone
752 752
753 753 void main() {
754 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
754 // per-window state lives in uProgress (setUniform is global for all windows):
755 // uProgress = tintIndex * 4096 + m, with m = 1 when the morph is complete
756 float tk = floor(uProgress / 4096.0);
757 float c = clamp(uProgress - tk * 4096.0, 0.0, 1.0);
758 if (uCrumpleEnd < -1.0) c = 0.0; // keep uCrumpleEnd alive (still set by the script)
759 vec3 tint = tk < 0.5 ? vec3(0.0) : tk < 1.5 ? vec3(0.0, 0.0, 0.6667) : tk < 2.5 ? vec3(0.6667, 0.0, 0.0)
760 : tk < 3.5 ? vec3(0.0, 0.6667, 0.0) : tk < 4.5 ? vec3(0.4, 0.0, 0.6667) : tk < 5.5 ? vec3(0.6667, 0.6667, 0.0)
761 : tk < 6.5 ? vec3(0.6667, 0.3333, 0.0) : tk < 7.5 ? vec3(0.0, 0.6667, 0.6667) : tk < 8.5 ? vec3(0.6667, 0.0, 0.4)
762 : tk < 9.5 ? vec3(0.3333) : vec3(0.3333, 0.2, 0.0);
763 if (uTintR < -1.0 || uTintG < -1.0 || uTintB < -1.0) tint = vec3(0.0); // keep uniforms alive
755 764 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
756 765 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
757 766
@@ -784,7 +793,7 @@ void main() {
784 793 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
785 794 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
786 795 float outer = smoothstep(0.2, 0.85, length(bz));
787 col.rgb = mix(col.rgb, vec3(uTintR, uTintG, uTintB), e * mix(uMixCenter, uMixOuter, outer));
796 col.rgb = mix(col.rgb, tint, e * mix(uMixCenter, uMixOuter, outer));
788 797 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
789 798 vec2 sv = q - vec2(-0.40, -0.47);
790 799 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
@@ -751,7 +751,16 @@ uniform float uMarbleSize; // marble diameter in px
751uniform float uMixCenter; // 0..1 black mix, centre/top zone
751uniform float uMixCenter; // 0..1 black mix, centre/top zone
752
752
753void main() {
753void main() {
754 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
754 // per-window state lives in uProgress (setUniform is global for all windows):
755 // uProgress = tintIndex * 4096 + m, with m = 1 when the morph is complete
756 float tk = floor(uProgress / 4096.0);
757 float c = clamp(uProgress - tk * 4096.0, 0.0, 1.0);
758 if (uCrumpleEnd < -1.0) c = 0.0; // keep uCrumpleEnd alive (still set by the script)
759 vec3 tint = tk < 0.5 ? vec3(0.0) : tk < 1.5 ? vec3(0.0, 0.0, 0.6667) : tk < 2.5 ? vec3(0.6667, 0.0, 0.0)
760 : tk < 3.5 ? vec3(0.0, 0.6667, 0.0) : tk < 4.5 ? vec3(0.4, 0.0, 0.6667) : tk < 5.5 ? vec3(0.6667, 0.6667, 0.0)
761 : tk < 6.5 ? vec3(0.6667, 0.3333, 0.0) : tk < 7.5 ? vec3(0.0, 0.6667, 0.6667) : tk < 8.5 ? vec3(0.6667, 0.0, 0.4)
762 : tk < 9.5 ? vec3(0.3333) : vec3(0.3333, 0.2, 0.0);
763 if (uTintR < -1.0 || uTintG < -1.0 || uTintB < -1.0) tint = vec3(0.0); // keep uniforms alive
755 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
764 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
756 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
765 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
757
766
@@ -784,7 +793,7 @@ void main() {
784 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
793 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
785 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
794 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
786 float outer = smoothstep(0.2, 0.85, length(bz));
795 float outer = smoothstep(0.2, 0.85, length(bz));
787 col.rgb = mix(col.rgb, vec3(uTintR, uTintG, uTintB), e * mix(uMixCenter, uMixOuter, outer));
796 col.rgb = mix(col.rgb, tint, e * mix(uMixCenter, uMixOuter, outer));
788 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
797 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
789 vec2 sv = q - vec2(-0.40, -0.47);
798 vec2 sv = q - vec2(-0.40, -0.47);
790 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
799 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
kwin6_effect_marble_minimize/contents/shaders/marble_core.frag +11 −2
@@ -752,7 +752,16 @@ uniform float uMarbleSize; // marble diameter in px
752 752 uniform float uMixCenter; // 0..1 black mix, centre/top zone
753 753
754 754 void main() {
755 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
755 // per-window state lives in uProgress (setUniform is global for all windows):
756 // uProgress = tintIndex * 4096 + m, with m = 1 when the morph is complete
757 float tk = floor(uProgress / 4096.0);
758 float c = clamp(uProgress - tk * 4096.0, 0.0, 1.0);
759 if (uCrumpleEnd < -1.0) c = 0.0; // keep uCrumpleEnd alive (still set by the script)
760 vec3 tint = tk < 0.5 ? vec3(0.0) : tk < 1.5 ? vec3(0.0, 0.0, 0.6667) : tk < 2.5 ? vec3(0.6667, 0.0, 0.0)
761 : tk < 3.5 ? vec3(0.0, 0.6667, 0.0) : tk < 4.5 ? vec3(0.4, 0.0, 0.6667) : tk < 5.5 ? vec3(0.6667, 0.6667, 0.0)
762 : tk < 6.5 ? vec3(0.6667, 0.3333, 0.0) : tk < 7.5 ? vec3(0.0, 0.6667, 0.6667) : tk < 8.5 ? vec3(0.6667, 0.0, 0.4)
763 : tk < 9.5 ? vec3(0.3333) : vec3(0.3333, 0.2, 0.0);
764 if (uTintR < -1.0 || uTintG < -1.0 || uTintB < -1.0) tint = vec3(0.0); // keep uniforms alive
756 765 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
757 766 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
758 767
@@ -785,7 +794,7 @@ void main() {
785 794 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
786 795 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
787 796 float outer = smoothstep(0.2, 0.85, length(bz));
788 col.rgb = mix(col.rgb, vec3(uTintR, uTintG, uTintB), e * mix(uMixCenter, uMixOuter, outer));
797 col.rgb = mix(col.rgb, tint, e * mix(uMixCenter, uMixOuter, outer));
789 798 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
790 799 vec2 sv = q - vec2(-0.40, -0.47);
791 800 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
@@ -752,7 +752,16 @@ uniform float uMarbleSize; // marble diameter in px
752uniform float uMixCenter; // 0..1 black mix, centre/top zone
752uniform float uMixCenter; // 0..1 black mix, centre/top zone
753
753
754void main() {
754void main() {
755 float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
755 // per-window state lives in uProgress (setUniform is global for all windows):
756 // uProgress = tintIndex * 4096 + m, with m = 1 when the morph is complete
757 float tk = floor(uProgress / 4096.0);
758 float c = clamp(uProgress - tk * 4096.0, 0.0, 1.0);
759 if (uCrumpleEnd < -1.0) c = 0.0; // keep uCrumpleEnd alive (still set by the script)
760 vec3 tint = tk < 0.5 ? vec3(0.0) : tk < 1.5 ? vec3(0.0, 0.0, 0.6667) : tk < 2.5 ? vec3(0.6667, 0.0, 0.0)
761 : tk < 3.5 ? vec3(0.0, 0.6667, 0.0) : tk < 4.5 ? vec3(0.4, 0.0, 0.6667) : tk < 5.5 ? vec3(0.6667, 0.6667, 0.0)
762 : tk < 6.5 ? vec3(0.6667, 0.3333, 0.0) : tk < 7.5 ? vec3(0.0, 0.6667, 0.6667) : tk < 8.5 ? vec3(0.6667, 0.0, 0.4)
763 : tk < 9.5 ? vec3(0.3333) : vec3(0.3333, 0.2, 0.0);
764 if (uTintR < -1.0 || uTintG < -1.0 || uTintB < -1.0) tint = vec3(0.0); // keep uniforms alive
756 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
765 if (uDuration < -1.0) c = 0.0; // keep uDuration alive
757 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
766 float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
758
767
@@ -785,7 +794,7 @@ void main() {
785 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
794 // outer/bottom (red zone) strongly; soft elliptic gradient around a point above centre
786 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
795 vec2 bz = (q - vec2(0.05, -0.22)) * vec2(1.0, 1.45);
787 float outer = smoothstep(0.2, 0.85, length(bz));
796 float outer = smoothstep(0.2, 0.85, length(bz));
788 col.rgb = mix(col.rgb, vec3(uTintR, uTintG, uTintB), e * mix(uMixCenter, uMixOuter, outer));
797 col.rgb = mix(col.rgb, tint, e * mix(uMixCenter, uMixOuter, outer));
789 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
798 // bent rounded-square shine top-left (superellipse in a rotated, curved frame), sharp edge
790 vec2 sv = q - vec2(-0.40, -0.47);
799 vec2 sv = q - vec2(-0.40, -0.47);
791 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg
800 vec2 sr = vec2(0.766 * sv.x - 0.643 * sv.y, 0.643 * sv.x + 0.766 * sv.y); // rotate -40deg