Add Marble Magic Lamp minimize effect; remove debug logs
@@ -1,4 +1,4 @@
1
# Marble – KWin close effect (Burn-My-Windows variant)
1
# Marble – KWin close & minimize effects (Burn-My-Windows variant)
2
2
3
3
**NL** – KWin 6 (Plasma 6) sluit-animatie: het venster vormt zich soepel om tot een kleine,
4
4
glanzende knikker (inhoud blijft zichtbaar), blijft even stil liggen en valt daarna met echte
@@ -10,10 +10,20 @@ acceleration from rest) for 1.5 screen heights.
10
10
11
11

12
12
13
## Marble Magic Lamp (minimize)
14
15
**NL** – `kwin6_effect_marble_minimize`: bij minimaliseren vormt het venster zich net zo om tot
16
een knikker, pauzeert, en valt dan in een rechte lijn met zwaartekracht (vanuit stilstand) naar
17
zijn taakbalkknop. Herstellen is een korte fade-in. Zelfde instellingen en defaults.
18
19
**EN** – `kwin6_effect_marble_minimize`: on minimize the window becomes the same marble, pauses,
20
then falls in a straight line under gravity (from rest) to its taskbar entry. Restore is a short
21
fade-in. Same settings and defaults. It replaces the active minimize animation (e.g. Magic Lamp).
22
13
23
## Installatie / Installation
14
24
15
25
```sh
16
cp -r kwin6_effect_marble ~/.local/share/kwin/effects/
26
cp -r kwin6_effect_marble kwin6_effect_marble_minimize ~/.local/share/kwin/effects/
17
27
```
18
28
19
29
Then enable **Marble [Burn-My-Windows variant]** in System Settings → Window Management →
@@ -26,7 +36,7 @@ it does not show up.
26
36
|------------|---------|-----------------------------------------------------------------|
27
37
| `Duration` | 300 ms | Morph into the marble |
28
38
| `Pause` | 600 ms | Marble rests before falling |
29
| `Gravity` | 4000 px/s² | Fall acceleration; fall time = sqrt(2·1.5·screen height / g) |
39
| `Gravity` | 4000 px/s² | Fall acceleration; fall time = sqrt(2·distance / g) (close: 1.5 screen heights; minimize: distance to taskbar entry) |
30
40
31
41
All durations are scaled by Plasma's global animation speed.
32
42
@@ -1,4 +1,4 @@1
# Marble – KWin close effect (Burn-My-Windows variant)1
# Marble – KWin close & minimize effects (Burn-My-Windows variant)2
2
3
**NL** – KWin 6 (Plasma 6) sluit-animatie: het venster vormt zich soepel om tot een kleine,3
**NL** – KWin 6 (Plasma 6) sluit-animatie: het venster vormt zich soepel om tot een kleine,4
glanzende knikker (inhoud blijft zichtbaar), blijft even stil liggen en valt daarna met echte4
glanzende knikker (inhoud blijft zichtbaar), blijft even stil liggen en valt daarna met echte@@ -10,10 +10,20 @@ acceleration from rest) for 1.5 screen heights.10
10
11
11
12
12
13
## Marble Magic Lamp (minimize)14
15
**NL** – `kwin6_effect_marble_minimize`: bij minimaliseren vormt het venster zich net zo om tot16
een knikker, pauzeert, en valt dan in een rechte lijn met zwaartekracht (vanuit stilstand) naar17
zijn taakbalkknop. Herstellen is een korte fade-in. Zelfde instellingen en defaults.18
19
**EN** – `kwin6_effect_marble_minimize`: on minimize the window becomes the same marble, pauses,20
then falls in a straight line under gravity (from rest) to its taskbar entry. Restore is a short21
fade-in. Same settings and defaults. It replaces the active minimize animation (e.g. Magic Lamp).22
13
## Installatie / Installation23
## Installatie / Installation14
24
15
```sh25
```sh16
cp -r kwin6_effect_marble ~/.local/share/kwin/effects/26
cp -r kwin6_effect_marble kwin6_effect_marble_minimize ~/.local/share/kwin/effects/17
```27
```18
28
19
Then enable **Marble [Burn-My-Windows variant]** in System Settings → Window Management →29
Then enable **Marble [Burn-My-Windows variant]** in System Settings → Window Management →@@ -26,7 +36,7 @@ it does not show up.26
|------------|---------|-----------------------------------------------------------------|36
|------------|---------|-----------------------------------------------------------------|27
| `Duration` | 300 ms | Morph into the marble |37
| `Duration` | 300 ms | Morph into the marble |28
| `Pause` | 600 ms | Marble rests before falling |38
| `Pause` | 600 ms | Marble rests before falling |29
| `Gravity` | 4000 px/s² | Fall acceleration; fall time = sqrt(2·1.5·screen height / g) |39
| `Gravity` | 4000 px/s² | Fall acceleration; fall time = sqrt(2·distance / g) (close: 1.5 screen heights; minimize: distance to taskbar entry) |30
40
31
All durations are scaled by Plasma's global animation speed.41
All durations are scaled by Plasma's global animation speed.32
42
@@ -211,7 +211,6 @@ class BurnMyWindowsMarbleEffect {
211
211
212
212
213
213
// 1) marble morph (shader); runs the whole time so the marble stays drawn while falling
214
console.info('marble: start ' + Date.now() + ' crumple ' + this.duration + ' fall ' + this.fallDuration);
215
214
window.bmwOutAnimation = animate({
216
215
window: window,
217
216
curve: QEasingCurve.Linear,
@@ -236,7 +235,6 @@ class BurnMyWindowsMarbleEffect {
236
235
}
237
236
238
237
slotAnimationEnded(window, id) {
239
console.info('marble: ended ' + id + ' ' + Date.now());
240
238
if (!window || !window.bmwFallPending) return; // first end = marble marker (ids arrive as 0)
241
239
window.bmwFallPending = false;
242
240
// free fall from rest: InQuad = t^2 = constant acceleration, d = 0.5 g t^2
@@ -247,7 +245,6 @@ class BurnMyWindowsMarbleEffect {
247
245
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0},
248
246
to: {value1: 0.0, value2: this.fallDistance} }]
249
247
});
250
console.info('marble: fall start ' + Date.now());
251
248
}
252
249
253
250
slotWindowDataChanged(window, role) {
@@ -211,7 +211,6 @@ class BurnMyWindowsMarbleEffect {211
211
212
212
213
// 1) marble morph (shader); runs the whole time so the marble stays drawn while falling213
// 1) marble morph (shader); runs the whole time so the marble stays drawn while falling214
console.info('marble: start ' + Date.now() + ' crumple ' + this.duration + ' fall ' + this.fallDuration);215
window.bmwOutAnimation = animate({214
window.bmwOutAnimation = animate({216
window: window,215
window: window,217
curve: QEasingCurve.Linear,216
curve: QEasingCurve.Linear,@@ -236,7 +235,6 @@ class BurnMyWindowsMarbleEffect {236
}235
}237
236
238
slotAnimationEnded(window, id) {237
slotAnimationEnded(window, id) {239
console.info('marble: ended ' + id + ' ' + Date.now());240
if (!window || !window.bmwFallPending) return; // first end = marble marker (ids arrive as 0)238
if (!window || !window.bmwFallPending) return; // first end = marble marker (ids arrive as 0)241
window.bmwFallPending = false;239
window.bmwFallPending = false;242
// free fall from rest: InQuad = t^2 = constant acceleration, d = 0.5 g t^2240
// free fall from rest: InQuad = t^2 = constant acceleration, d = 0.5 g t^2@@ -247,7 +245,6 @@ class BurnMyWindowsMarbleEffect {247
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0},245
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0},248
to: {value1: 0.0, value2: this.fallDistance} }]246
to: {value1: 0.0, value2: this.fallDistance} }]249
});247
});250
console.info('marble: fall start ' + Date.now());251
}248
}252
249
253
slotWindowDataChanged(window, role) {250
slotWindowDataChanged(window, role) {@@ -0,0 +1,268 @@
1
// SPDX-FileCopyrightText: Vlad Zahorodnii <vlad.zahorodnii@kde.org>, Martin Flöser
2
// <mgraesslin@kde.org>, Simon Schneegans <code@simonschneegans.de>
3
// SPDX-License-Identifier: GPL-3.0-or-later
4
5
'use strict';
6
7
const classBlacklist = [
8
// The logout screen has to be animated only by the logout effect.
9
'ksmserver ksmserver', 'ksmserver-logout-greeter ksmserver-logout-greeter',
10
11
// KDE Plasma splash screen has to be animated only by the login effect.
12
'ksplashqml ksplashqml',
13
14
// All the tooltips of IntelliJ IDEs use the same window class as their main window.
15
// This results in many awkward animations, so we have to blacklist them all.
16
// See https://github.com/Schneegans/Burn-My-Windows/issues/284 for details.
17
'jetbrains-studio jetbrains-studio', 'jetbrains-aqua jetbrains-aqua',
18
'jetbrains-clion jetbrains-clion', 'jetbrains-datagrip jetbrains-datagrip',
19
'jetbrains-dataspell jetbrains-dataspell', 'jetbrains-goland jetbrains-goland',
20
'jetbrains-idea jetbrains-idea', 'jetbrains-idea-ce jetbrains-idea-ce',
21
'jetbrains-phpstorm jetbrains-phpstorm', 'jetbrains-pycharm jetbrains-pycharm',
22
'jetbrains-pycharm-ce jetbrains-pycharm-ce', 'jetbrains-rider jetbrains-rider',
23
'jetbrains-rubymine jetbrains-rubymine', 'jetbrains-webstorm jetbrains-webstorm',
24
25
// Spectacle (KDE screenshot tool) should not be animated.
26
'spectacle org.kde.spectacle'
27
];
28
29
const nameBlacklist = [
30
// Kando uses a normal window, but it should look like a popup menu. We do not
31
// blacklist it by class as this would also affect the settings window.
32
'Kando Menu'
33
];
34
35
class BurnMyWindowsMarbleMinimizeEffect {
36
constructor() {
37
effect.configChanged.connect(this.loadConfig.bind(this));
38
effect.animationEnded.connect(this.cleanupForcedRoles.bind(this));
39
effect.animationEnded.connect(this.slotAnimationEnded.bind(this));
40
//effects.windowAdded.connect(this.slotWindowAdded.bind(this));
41
const hook = (w) => {
42
w.minimizedChanged.connect(() => {
43
if (w.minimized) this.slotWindowMinimized(w); else this.slotWindowUnminimized(w);
44
});
45
};
46
effects.windowAdded.connect(hook);
47
for (const w of effects.stackingOrder) hook(w);
48
effects.windowDataChanged.connect(this.slotWindowDataChanged.bind(this));
49
50
this.shader = effect.addFragmentShader(Effect.MapTexture, 'marble.frag');
51
52
this.loadConfig();
53
}
54
55
// A small helper which can be used to read a hex color string (e.g. #ff3244) from the
56
// settings. This method will return an array of four floating point values
57
// [r, g, b, a]. If the settings key only refers to an rgb value, the alpha component
58
// will be set to 1.0.
59
readRGBAConfig(key) {
60
const raw = String(effect.readConfig(key, '#ffffff'));
61
const parts = raw.split(',').map(x => parseFloat(x.trim()));
62
if (parts.length >= 3 && parts.every(x => !isNaN(x))) {
63
const c = parts.map(x => x / 255);
64
return [c[0], c[1], c[2], c.length > 3 ? c[3] : 1.0];
65
}
66
const color = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?([a-f\d]{2})?$/i
67
.exec(effect.readConfig(key, '#ffffff'))
68
.slice(1)
69
.filter(x => x !== undefined)
70
.map(x => parseInt(x, 16) / 255);
71
return color.length == 3 ? [color[0], color[1], color[2], 1.0] :
72
[color[1], color[2], color[3], color[0]];
73
}
74
75
// A small helper which can be used to read a hex color string (e.g. #ff3244) from the
76
// settings. This method will return an array of three floating point values [r, g, b]
77
// regardless of whether the settings key actually refers to an argb hex string.
78
readRGBConfig(key) {
79
const color = this.readRGBAConfig(key);
80
color.pop();
81
return color;
82
}
83
84
// This is called when the effect is loaded and whenever the settings of the effect
85
// are changed by the user.
86
loadConfig() {
87
this.duration = animationTime(effect.readConfig("Duration", 300));
88
this.pause = animationTime(Number(effect.readConfig("Pause", 600)));
89
this.gravity = Math.max(100, Number(effect.readConfig('Gravity', 4000))); // px/s^2
90
let sh = 1080;
91
try { sh = effects.virtualScreenGeometry.height || sh; } catch (e) {}
92
this.fallDistance = 1.5 * sh;
93
// free fall from rest: d = 0.5 g t^2 -> t = sqrt(2d/g); scaled by the global speed factor
94
this.fallDuration = animationTime(Math.round(1000 * Math.sqrt(2 * this.fallDistance / this.gravity)));
95
effect.setUniform(this.shader, 'uDuration', (this.duration + this.pause + this.fallDuration) * 0.001);
96
effect.setUniform(this.shader, 'uCrumpleEnd', this.duration / Math.max(1, this.duration + this.pause + this.fallDuration));
97
}
98
99
static shouldAnimateWindow(window) {
100
101
// We don't want to animate most of plasmashell's windows, yet, some
102
// of them we want to, for example, Task Manager Settings window.
103
// The problem is that all those window share single window class.
104
// So, the only way to decide whether a window should be animated is
105
// to use a heuristic: if a window has decoration, then it's most
106
// likely a dialog or a settings window so we have to animate it.
107
if (window.windowClass == 'plasmashell plasmashell' ||
108
window.windowClass == 'plasmashell org.kde.plasmashell') {
109
return window.hasDecoration;
110
}
111
112
// This is primarily to avoid animating the AltTab popup.
113
// See https://github.com/Schneegans/Burn-My-Windows/issues/384 for details.
114
if (!window.hasDecoration && window.onAllDesktops) {
115
return false
116
}
117
118
if (classBlacklist.indexOf(window.windowClass) != -1) {
119
return false;
120
}
121
122
if (nameBlacklist.indexOf(window.caption) != -1) {
123
return false;
124
}
125
126
if (window.hasDecoration) {
127
return true;
128
}
129
130
// Don't animate combobox popups, tooltips, popup menus, etc.
131
if (window.popupWindow) {
132
return false;
133
}
134
135
// Dont't animate the outline and the screenlocker as it looks bad.
136
if (window.lockScreen || window.outline) {
137
return false;
138
}
139
140
// Override-redirect windows are usually used for user interface
141
// concepts that are not expected to be animated by this effect.
142
if (!window.managed) {
143
return false;
144
}
145
146
return window.normalWindow || window.dialog;
147
}
148
149
setupForcedRoles(window) {
150
// marble: no forced blur/contrast (blurred window-sized rect + cost)
151
// window.setData(Effect.WindowForceBackgroundContrastRole, true);
152
// marble: no forced blur/contrast (blurred window-sized rect + cost)
153
// window.setData(Effect.WindowForceBlurRole, true);
154
}
155
156
cleanupForcedRoles(window) {
157
window.setData(Effect.WindowForceBackgroundContrastRole, null);
158
window.setData(Effect.WindowForceBlurRole, null);
159
}
160
161
slotWindowAdded(window) {
162
if (effects.hasActiveFullScreenEffect) {
163
return;
164
}
165
if (!BurnMyWindowsMarbleMinimizeEffect.shouldAnimateWindow(window)) {
166
return;
167
}
168
if (!window.visible) {
169
return;
170
}
171
if (effect.isGrabbed(window, Effect.WindowAddedGrabRole)) {
172
return;
173
}
174
this.setupForcedRoles(window);
175
176
effect.setUniform(this.shader, 'uForOpening', 1.0);
177
effect.setUniform(this.shader, 'uIsFullscreen', window.fullScreen ? 1.0 : 0.0);
178
179
180
181
window.bmwInAnimation = animate({
182
window: window,
183
curve: QEasingCurve.Linear,
184
duration: this.duration,
185
animations: [{
186
type: Effect.ShaderUniform,
187
fragmentShader: this.shader,
188
uniform: 'uProgress',
189
from: 0.0,
190
to: 1.0
191
}]
192
});
193
}
194
195
slotWindowMinimized(window) {
196
if (effects.hasActiveFullScreenEffect) return;
197
const ir = window.iconGeometry;
198
if (!ir || ir.width == 0 || ir.height == 0) return; // no taskbar entry
199
this.stopAll(window);
200
const wr = window.geometry;
201
const dx = (ir.x + ir.width / 2) - (wr.x + wr.width / 2);
202
const dy = (ir.y + ir.height / 2) - (wr.y + wr.height / 2);
203
const dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
204
// straight-line free fall from rest: d = 0.5 g t^2 -> t = sqrt(2d/g)
205
const fall = animationTime(Math.round(1000 * Math.sqrt(2 * dist / this.gravity)));
206
const total = this.duration + this.pause + fall;
207
effect.setUniform(this.shader, "uForOpening", 0.0);
208
effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);
209
effect.setUniform(this.shader, "uDuration", total * 0.001);
210
effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));
211
window.bmwMinAnimation = animate({
212
window: window, curve: QEasingCurve.Linear, duration: total,
213
animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: 1.0 },
214
{ type: Effect.Opacity, from: 1.0, to: 1.0 }]
215
});
216
window.bmwMarbleDone = animate({
217
window: window, curve: QEasingCurve.Linear, duration: this.duration + this.pause,
218
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]
219
});
220
window.bmwFall = {dx: dx, dy: dy, duration: fall};
221
window.bmwFallPending = true;
222
}
223
224
slotWindowUnminimized(window) {
225
if (effects.hasActiveFullScreenEffect) return;
226
this.stopAll(window);
227
window.bmwUnminAnimation = animate({
228
window: window, curve: QEasingCurve.OutQuad, duration: animationTime(200),
229
animations: [{ type: Effect.Opacity, from: 0.0, to: 1.0 }]
230
});
231
}
232
233
stopAll(window) {
234
window.bmwFallPending = false;
235
for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwFallAnimation", "bmwUnminAnimation"]) {
236
if (window[k]) { cancel(window[k]); delete window[k]; }
237
}
238
}
239
240
slotAnimationEnded(window, id) {
241
if (!window || !window.bmwFallPending) return; // first end = marble marker
242
window.bmwFallPending = false;
243
const f = window.bmwFall;
244
window.bmwFallAnimation = animate({
245
window: window, curve: QEasingCurve.InQuad, duration: f.duration, keepAtTarget: true,
246
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: f.dx, value2: f.dy} },
247
{ type: Effect.Opacity, from: 1.0, to: 1.0 }]
248
});
249
}
250
251
slotWindowDataChanged(window, role) {
252
if (role == Effect.WindowAddedGrabRole) {
253
if (window.bmwInAnimation && effect.isGrabbed(window, role)) {
254
cancel(window.bmwInAnimation);
255
delete window.bmwInAnimation;
256
this.cleanupForcedRoles(window);
257
}
258
} else if (role == Effect.WindowClosedGrabRole) {
259
if (window.bmwOutAnimation && effect.isGrabbed(window, role)) {
260
cancel(window.bmwOutAnimation);
261
delete window.bmwOutAnimation;
262
this.cleanupForcedRoles(window);
263
}
264
}
265
}
266
}
267
268
new BurnMyWindowsMarbleMinimizeEffect();
@@ -0,0 +1,268 @@1
// SPDX-FileCopyrightText: Vlad Zahorodnii <vlad.zahorodnii@kde.org>, Martin Flöser2
// <mgraesslin@kde.org>, Simon Schneegans <code@simonschneegans.de>3
// SPDX-License-Identifier: GPL-3.0-or-later4
5
'use strict';6
7
const classBlacklist = [8
// The logout screen has to be animated only by the logout effect.9
'ksmserver ksmserver', 'ksmserver-logout-greeter ksmserver-logout-greeter',10
11
// KDE Plasma splash screen has to be animated only by the login effect.12
'ksplashqml ksplashqml',13
14
// All the tooltips of IntelliJ IDEs use the same window class as their main window.15
// This results in many awkward animations, so we have to blacklist them all.16
// See https://github.com/Schneegans/Burn-My-Windows/issues/284 for details.17
'jetbrains-studio jetbrains-studio', 'jetbrains-aqua jetbrains-aqua',18
'jetbrains-clion jetbrains-clion', 'jetbrains-datagrip jetbrains-datagrip',19
'jetbrains-dataspell jetbrains-dataspell', 'jetbrains-goland jetbrains-goland',20
'jetbrains-idea jetbrains-idea', 'jetbrains-idea-ce jetbrains-idea-ce',21
'jetbrains-phpstorm jetbrains-phpstorm', 'jetbrains-pycharm jetbrains-pycharm',22
'jetbrains-pycharm-ce jetbrains-pycharm-ce', 'jetbrains-rider jetbrains-rider',23
'jetbrains-rubymine jetbrains-rubymine', 'jetbrains-webstorm jetbrains-webstorm',24
25
// Spectacle (KDE screenshot tool) should not be animated.26
'spectacle org.kde.spectacle'27
];28
29
const nameBlacklist = [30
// Kando uses a normal window, but it should look like a popup menu. We do not31
// blacklist it by class as this would also affect the settings window.32
'Kando Menu'33
];34
35
class BurnMyWindowsMarbleMinimizeEffect {36
constructor() {37
effect.configChanged.connect(this.loadConfig.bind(this));38
effect.animationEnded.connect(this.cleanupForcedRoles.bind(this));39
effect.animationEnded.connect(this.slotAnimationEnded.bind(this));40
//effects.windowAdded.connect(this.slotWindowAdded.bind(this));41
const hook = (w) => {42
w.minimizedChanged.connect(() => {43
if (w.minimized) this.slotWindowMinimized(w); else this.slotWindowUnminimized(w);44
});45
};46
effects.windowAdded.connect(hook);47
for (const w of effects.stackingOrder) hook(w);48
effects.windowDataChanged.connect(this.slotWindowDataChanged.bind(this));49
50
this.shader = effect.addFragmentShader(Effect.MapTexture, 'marble.frag');51
52
this.loadConfig();53
}54
55
// A small helper which can be used to read a hex color string (e.g. #ff3244) from the56
// settings. This method will return an array of four floating point values57
// [r, g, b, a]. If the settings key only refers to an rgb value, the alpha component58
// will be set to 1.0.59
readRGBAConfig(key) {60
const raw = String(effect.readConfig(key, '#ffffff'));61
const parts = raw.split(',').map(x => parseFloat(x.trim()));62
if (parts.length >= 3 && parts.every(x => !isNaN(x))) {63
const c = parts.map(x => x / 255);64
return [c[0], c[1], c[2], c.length > 3 ? c[3] : 1.0];65
}66
const color = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?([a-f\d]{2})?$/i67
.exec(effect.readConfig(key, '#ffffff'))68
.slice(1)69
.filter(x => x !== undefined)70
.map(x => parseInt(x, 16) / 255);71
return color.length == 3 ? [color[0], color[1], color[2], 1.0] :72
[color[1], color[2], color[3], color[0]];73
}74
75
// A small helper which can be used to read a hex color string (e.g. #ff3244) from the76
// settings. This method will return an array of three floating point values [r, g, b]77
// regardless of whether the settings key actually refers to an argb hex string.78
readRGBConfig(key) {79
const color = this.readRGBAConfig(key);80
color.pop();81
return color;82
}83
84
// This is called when the effect is loaded and whenever the settings of the effect85
// are changed by the user.86
loadConfig() {87
this.duration = animationTime(effect.readConfig("Duration", 300));88
this.pause = animationTime(Number(effect.readConfig("Pause", 600)));89
this.gravity = Math.max(100, Number(effect.readConfig('Gravity', 4000))); // px/s^290
let sh = 1080;91
try { sh = effects.virtualScreenGeometry.height || sh; } catch (e) {}92
this.fallDistance = 1.5 * sh;93
// free fall from rest: d = 0.5 g t^2 -> t = sqrt(2d/g); scaled by the global speed factor94
this.fallDuration = animationTime(Math.round(1000 * Math.sqrt(2 * this.fallDistance / this.gravity)));95
effect.setUniform(this.shader, 'uDuration', (this.duration + this.pause + this.fallDuration) * 0.001);96
effect.setUniform(this.shader, 'uCrumpleEnd', this.duration / Math.max(1, this.duration + this.pause + this.fallDuration));97
}98
99
static shouldAnimateWindow(window) {100
101
// We don't want to animate most of plasmashell's windows, yet, some102
// of them we want to, for example, Task Manager Settings window.103
// The problem is that all those window share single window class.104
// So, the only way to decide whether a window should be animated is105
// to use a heuristic: if a window has decoration, then it's most106
// likely a dialog or a settings window so we have to animate it.107
if (window.windowClass == 'plasmashell plasmashell' ||108
window.windowClass == 'plasmashell org.kde.plasmashell') {109
return window.hasDecoration;110
}111
112
// This is primarily to avoid animating the AltTab popup.113
// See https://github.com/Schneegans/Burn-My-Windows/issues/384 for details.114
if (!window.hasDecoration && window.onAllDesktops) {115
return false116
}117
118
if (classBlacklist.indexOf(window.windowClass) != -1) {119
return false;120
}121
122
if (nameBlacklist.indexOf(window.caption) != -1) {123
return false;124
}125
126
if (window.hasDecoration) {127
return true;128
}129
130
// Don't animate combobox popups, tooltips, popup menus, etc.131
if (window.popupWindow) {132
return false;133
}134
135
// Dont't animate the outline and the screenlocker as it looks bad.136
if (window.lockScreen || window.outline) {137
return false;138
}139
140
// Override-redirect windows are usually used for user interface141
// concepts that are not expected to be animated by this effect.142
if (!window.managed) {143
return false;144
}145
146
return window.normalWindow || window.dialog;147
}148
149
setupForcedRoles(window) {150
// marble: no forced blur/contrast (blurred window-sized rect + cost)151
// window.setData(Effect.WindowForceBackgroundContrastRole, true);152
// marble: no forced blur/contrast (blurred window-sized rect + cost)153
// window.setData(Effect.WindowForceBlurRole, true);154
}155
156
cleanupForcedRoles(window) {157
window.setData(Effect.WindowForceBackgroundContrastRole, null);158
window.setData(Effect.WindowForceBlurRole, null);159
}160
161
slotWindowAdded(window) {162
if (effects.hasActiveFullScreenEffect) {163
return;164
}165
if (!BurnMyWindowsMarbleMinimizeEffect.shouldAnimateWindow(window)) {166
return;167
}168
if (!window.visible) {169
return;170
}171
if (effect.isGrabbed(window, Effect.WindowAddedGrabRole)) {172
return;173
}174
this.setupForcedRoles(window);175
176
effect.setUniform(this.shader, 'uForOpening', 1.0);177
effect.setUniform(this.shader, 'uIsFullscreen', window.fullScreen ? 1.0 : 0.0);178
179
180
181
window.bmwInAnimation = animate({182
window: window,183
curve: QEasingCurve.Linear,184
duration: this.duration,185
animations: [{186
type: Effect.ShaderUniform,187
fragmentShader: this.shader,188
uniform: 'uProgress',189
from: 0.0,190
to: 1.0191
}]192
});193
}194
195
slotWindowMinimized(window) {196
if (effects.hasActiveFullScreenEffect) return;197
const ir = window.iconGeometry;198
if (!ir || ir.width == 0 || ir.height == 0) return; // no taskbar entry199
this.stopAll(window);200
const wr = window.geometry;201
const dx = (ir.x + ir.width / 2) - (wr.x + wr.width / 2);202
const dy = (ir.y + ir.height / 2) - (wr.y + wr.height / 2);203
const dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));204
// straight-line free fall from rest: d = 0.5 g t^2 -> t = sqrt(2d/g)205
const fall = animationTime(Math.round(1000 * Math.sqrt(2 * dist / this.gravity)));206
const total = this.duration + this.pause + fall;207
effect.setUniform(this.shader, "uForOpening", 0.0);208
effect.setUniform(this.shader, "uIsFullscreen", window.fullScreen ? 1.0 : 0.0);209
effect.setUniform(this.shader, "uDuration", total * 0.001);210
effect.setUniform(this.shader, "uCrumpleEnd", this.duration / Math.max(1, total));211
window.bmwMinAnimation = animate({212
window: window, curve: QEasingCurve.Linear, duration: total,213
animations: [{ type: Effect.ShaderUniform, fragmentShader: this.shader, uniform: "uProgress", from: 0.0, to: 1.0 },214
{ type: Effect.Opacity, from: 1.0, to: 1.0 }]215
});216
window.bmwMarbleDone = animate({217
window: window, curve: QEasingCurve.Linear, duration: this.duration + this.pause,218
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: 0.0, value2: 0.0} }]219
});220
window.bmwFall = {dx: dx, dy: dy, duration: fall};221
window.bmwFallPending = true;222
}223
224
slotWindowUnminimized(window) {225
if (effects.hasActiveFullScreenEffect) return;226
this.stopAll(window);227
window.bmwUnminAnimation = animate({228
window: window, curve: QEasingCurve.OutQuad, duration: animationTime(200),229
animations: [{ type: Effect.Opacity, from: 0.0, to: 1.0 }]230
});231
}232
233
stopAll(window) {234
window.bmwFallPending = false;235
for (const k of ["bmwMinAnimation", "bmwMarbleDone", "bmwFallAnimation", "bmwUnminAnimation"]) {236
if (window[k]) { cancel(window[k]); delete window[k]; }237
}238
}239
240
slotAnimationEnded(window, id) {241
if (!window || !window.bmwFallPending) return; // first end = marble marker242
window.bmwFallPending = false;243
const f = window.bmwFall;244
window.bmwFallAnimation = animate({245
window: window, curve: QEasingCurve.InQuad, duration: f.duration, keepAtTarget: true,246
animations: [{ type: Effect.Translation, from: {value1: 0.0, value2: 0.0}, to: {value1: f.dx, value2: f.dy} },247
{ type: Effect.Opacity, from: 1.0, to: 1.0 }]248
});249
}250
251
slotWindowDataChanged(window, role) {252
if (role == Effect.WindowAddedGrabRole) {253
if (window.bmwInAnimation && effect.isGrabbed(window, role)) {254
cancel(window.bmwInAnimation);255
delete window.bmwInAnimation;256
this.cleanupForcedRoles(window);257
}258
} else if (role == Effect.WindowClosedGrabRole) {259
if (window.bmwOutAnimation && effect.isGrabbed(window, role)) {260
cancel(window.bmwOutAnimation);261
delete window.bmwOutAnimation;262
this.cleanupForcedRoles(window);263
}264
}265
}266
}267
268
new BurnMyWindowsMarbleMinimizeEffect();@@ -0,0 +1,9 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
3
<kcfgfile name="" />
4
<group name="">
5
<entry name="Duration" type="UInt"><default>300</default></entry>
6
<entry name="Pause" type="UInt"><default>600</default></entry>
7
<entry name="Gravity" type="UInt"><default>4000</default></entry>
8
</group>
9
</kcfg>
@@ -0,0 +1,9 @@1
<?xml version="1.0" encoding="UTF-8"?>2
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">3
<kcfgfile name="" />4
<group name="">5
<entry name="Duration" type="UInt"><default>300</default></entry>6
<entry name="Pause" type="UInt"><default>600</default></entry>7
<entry name="Gravity" type="UInt"><default>4000</default></entry>8
</group>9
</kcfg>@@ -0,0 +1,790 @@
1
#define KWIN_LEGACY
2
#define PLASMA6
3
4
// This file is automatically generated during the build process.
5
6
//////////////////////////////////////////////////////////////////////////////////////////
7
// ) ( //
8
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
9
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
10
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
11
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
12
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
13
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
14
// |__/ //
15
//////////////////////////////////////////////////////////////////////////////////////////
16
17
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
18
// SPDX-License-Identifier: GPL-3.0-or-later
19
20
//////////////////////////////////////////////////////////////////////////////////////////
21
// This file is automatically included in each shader. //
22
//////////////////////////////////////////////////////////////////////////////////////////
23
24
// --------------------------------------------------------------------- standard uniforms
25
26
// Each shader can access these standard input values:
27
28
// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
29
// bool uIsFullscreen: True if the window is maximized or in fullscreen mode.
30
// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
31
// float uProgress: A value which transitions from 0 to 1 during the animation.
32
// float uDuration: The duration of the current animation in seconds.
33
// vec2 uSize: The size of uTexture in pixels.
34
// float uPadding: The empty area around the actual window (e.g. where the shadow
35
// is drawn). For now, this will only be set on GNOME.
36
37
// Furthermore, there are two global methods for reading the window input color and
38
// setting the shader output color. Both methods assume straight alpha:
39
40
// vec4 getInputColor(vec2 coords)
41
// void setOutputColor(vec4 outColor)
42
43
uniform bool uForOpening;
44
uniform bool uIsFullscreen;
45
uniform float uProgress;
46
uniform float uDuration;
47
48
#if defined(KWIN) // --------------------------------------------------------------------
49
50
#if defined(PLASMA6)
51
#include "colormanagement.glsl"
52
#endif
53
54
uniform sampler2D sampler;
55
uniform int textureWidth;
56
uniform int textureHeight;
57
58
in vec2 texcoord0;
59
out vec4 fragColor;
60
61
// Using defines here as OpenGL ES forbids non-constant global initializers.
62
#define uSize vec2(textureWidth, textureHeight)
63
#define iTexCoord vec2(texcoord0.x, texcoord0.y)
64
float uPadding = 0.0;
65
66
vec4 getInputColor(vec2 coords) {
67
vec4 color = texture2D(sampler, coords);
68
69
if (color.a > 0.0) {
70
color.rgb /= color.a;
71
}
72
73
return color;
74
}
75
76
void setOutputColor(vec4 outColor) {
77
78
// If a uniform is not used, it will be optimized away. This condition is always
79
// false, but it will prevent the compiler from optimizing away the uniforms uForOpening
80
// and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
81
// uniform is used in the shader.
82
if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
83
outColor = vec4(0.0);
84
}
85
86
fragColor = vec4(outColor.rgb * outColor.a, outColor.a);
87
88
#if defined(PLASMA6)
89
fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
90
fragColor = nitsToDestinationEncoding(fragColor);
91
#endif
92
}
93
94
#elif defined(KWIN_LEGACY) // -----------------------------------------------------------
95
96
#if defined(PLASMA6)
97
#include "colormanagement.glsl"
98
#endif
99
100
uniform sampler2D sampler;
101
uniform int textureWidth;
102
uniform int textureHeight;
103
104
varying vec2 texcoord0;
105
106
vec2 uSize = vec2(textureWidth, textureHeight);
107
vec2 iTexCoord = vec2(texcoord0.x, texcoord0.y);
108
float uPadding = 0.0;
109
110
vec4 getInputColor(vec2 coords) {
111
vec4 color = texture2D(sampler, coords);
112
113
if (color.a > 0.0) {
114
color.rgb /= color.a;
115
}
116
117
return color;
118
}
119
120
void setOutputColor(vec4 outColor) {
121
// If a uniform is not used, it will be optimized away. This condition is always
122
// false, but it will prevent the compiler from optimizing away the uniforms uForOpening
123
// and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
124
// uniform is used in the shader.
125
if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
126
outColor = vec4(0.0);
127
}
128
129
gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a);
130
131
#if defined(PLASMA6)
132
fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
133
fragColor = nitsToDestinationEncoding(fragColor);
134
#endif
135
}
136
137
#else // GNOME --------------------------------------------------------------------------
138
139
// On GNOME, the uniforms are just normal uniforms.
140
uniform sampler2D uTexture;
141
uniform vec2 uSize;
142
uniform float uPadding;
143
144
// On GNOME, we set iTexCoord to be an alias for the cogl variables.
145
#define iTexCoord vec2(cogl_tex_coord_in[0])
146
147
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
148
vec4 getInputColor(vec2 coords) {
149
vec4 color = texture2D(uTexture, coords);
150
151
if (color.a > 0.0) {
152
color.rgb /= color.a;
153
}
154
155
return color;
156
}
157
158
void setOutputColor(vec4 outColor) { cogl_color_out = outColor; }
159
160
#endif // -------------------------------------------------------------------------------
161
162
// A simple blur function
163
vec4 getBlurredInputColor(vec2 uv, float radius, float samples) {
164
// Initialize the color accumulator to zero.
165
vec4 color = vec4(0.0);
166
167
// Define a constant for 2 * PI (tau), which represents a full circle in radians.
168
const float tau = 6.28318530718;
169
170
// Number of directions for sampling around the circle.
171
const float directions = 15.0;
172
173
// Outer loop iterates over multiple directions evenly spaced around a circle.
174
for (float d = 0.0; d < tau; d += tau / directions) {
175
// Inner loop samples along each direction, with decreasing intensity.
176
for (float s = 0.0; s < 1.0; s += 1.0 / samples) {
177
// Calculate the offset for this sample based on direction, radius, and step.
178
// The (1.0 - s) term ensures more sampling occurs closer to the center.
179
vec2 offset = vec2(cos(d), sin(d)) * radius * (1.0 - s) / uSize;
180
181
// Add the sampled color at the offset position to the accumulator.
182
color += getInputColor(uv + offset);
183
}
184
}
185
186
// Normalize the accumulated color by dividing by the total number of samples
187
// and directions to ensure the result is averaged.
188
return color / samples / directions;
189
}
190
191
// ----------------------------------------------------------------- compositing operators
192
193
// The Shell.GLSLEffect uses straight alpha blending. This helper method allows
194
// compositing color values in the shader in the same way.
195
vec4 alphaOver(vec4 under, vec4 over) {
196
if (under.a == 0.0 && over.a == 0.0) {
197
return vec4(0.0);
198
}
199
200
float alpha = mix(under.a, 1.0, over.a);
201
return vec4(mix(under.rgb * under.a, over.rgb, over.a) / alpha, alpha);
202
}
203
204
// ------------------------------------------------------------------------- color helpers
205
206
// Maps the given value from [0..1] to the given colors.
207
vec3 tritone(float val, vec3 shadows, vec3 midtones, vec3 highlights) {
208
if (val < 0.5) {
209
return mix(shadows, midtones, smoothstep(0.0, 1.0, val * 2.0));
210
}
211
212
return mix(midtones, highlights, smoothstep(0.0, 1.0, val * 2.0 - 1.0));
213
}
214
215
// Darkens the given color. If fac is zero, the color will not change, if fac is one, the
216
// color will be black.
217
vec3 darken(vec3 color, float fac) { return color * (1.0 - fac); }
218
219
// Lightens the given color. If fac is zero, the color will not change, if fac is one, the
220
// color will be white.
221
vec3 lighten(vec3 color, float fac) { return color + (vec3(1.0) - color) * fac; }
222
223
// change the color based on an offset amount
224
vec3 offsetHue(vec3 color, float hueOffset) {
225
// Convert RGB to HSV
226
float maxC = max(max(color.r, color.g), color.b);
227
float minC = min(min(color.r, color.g), color.b);
228
float delta = maxC - minC;
229
230
float hue = 0.0;
231
if (delta > 0.0) {
232
if (maxC == color.r) {
233
hue = mod((color.g - color.b) / delta, 6.0);
234
} else if (maxC == color.g) {
235
hue = (color.b - color.r) / delta + 2.0;
236
} else {
237
hue = (color.r - color.g) / delta + 4.0;
238
}
239
}
240
hue /= 6.0;
241
242
float saturation = (maxC > 0.0) ? (delta / maxC) : 0.0;
243
float value = maxC;
244
245
// Offset the hue
246
hue = mod(hue + hueOffset, 1.0);
247
248
// Convert HSV back to RGB
249
float c = value * saturation;
250
float x = c * (1.0 - abs(mod(hue * 6.0, 2.0) - 1.0));
251
float m = value - c;
252
253
vec3 rgb;
254
if (hue < 1.0 / 6.0) {
255
rgb = vec3(c, x, 0.0);
256
} else if (hue < 2.0 / 6.0) {
257
rgb = vec3(x, c, 0.0);
258
} else if (hue < 3.0 / 6.0) {
259
rgb = vec3(0.0, c, x);
260
} else if (hue < 4.0 / 6.0) {
261
rgb = vec3(0.0, x, c);
262
} else if (hue < 5.0 / 6.0) {
263
rgb = vec3(x, 0.0, c);
264
} else {
265
rgb = vec3(c, 0.0, x);
266
}
267
268
return rgb + m;
269
}
270
271
// ---------------------------------------------------------------------- easing functions
272
273
// Here are some basic easing function. More can be added if required!
274
// Taken from here:
275
// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/clutter/clutter/clutter-easing.c
276
277
float easeOutQuad(float x) { return -1.0 * x * (x - 2.0); }
278
279
float easeInQuad(float x) { return x * x; }
280
281
float easeInBack(float x, float e) { return x * x * ((e + 1.0) * x - e); }
282
283
float easeOutBack(float x, float e) {
284
float p = x - 1.0;
285
return p * p * ((e + 1.0) * p + e) + 1.0;
286
}
287
288
// https://easings.net/
289
/*
290
Easing functions define the rate of change of a parameter over time, commonly used in
291
animations, UI transitions, and game development. They provide a way to make movements
292
more natural or visually appealing rather than linear and mechanical. Popular categories
293
of easing functions include:
294
295
Linear: Constant speed from start to finish.
296
Quadratic (Ease In, Ease Out, Ease In Out): Changes at varying rates, with smoother starts
297
or stops. Cubic: Similar to quadratic but allows for even more nuanced transitions.
298
Exponential: Drastic changes at the start or end, often used for dramatic effects.
299
Bounce: Mimics a bouncing object with oscillations.
300
Elastic: Simulates the behavior of a spring, with overshooting and oscillations.
301
Below are text-based "graphs" of some easing functions, where the horizontal axis
302
represents time and the vertical axis represents progress.
303
*/
304
305
// Quadratic Easing
306
// Smooth acceleration and deceleration using quadratic (t^2) curves.
307
308
float easeInOutQuad(float t) {
309
// Accelerates for the first half, decelerates for the second half.
310
return t < 0.5 ? 2.0 * t * t : -1.0 + (4.0 - 2.0 * t) * t;
311
}
312
313
// Cubic Easing
314
// Smoother transitions compared to quadratic easing using cubic (t^3) curves.
315
316
float easeInCubic(float t) {
317
// Starts slow and accelerates as t increases.
318
return t * t * t;
319
}
320
321
float easeOutCubic(float t) {
322
// Starts fast and decelerates as t approaches 1.0.
323
float f = t - 1.0;
324
return f * f * f + 1.0;
325
}
326
327
float easeInOutCubic(float t) {
328
// Combines easeIn and easeOut cubic behavior for smooth transitions.
329
return t < 0.5 ? 4.0 * t * t * t : (t - 1.0) * (2.0 * t - 2.0) * (2.0 * t - 2.0) + 1.0;
330
}
331
332
// Quartic Easing
333
// Even smoother transitions than cubic, using quartic (t^4) curves.
334
335
float easeInQuart(float t) {
336
// Starts very slow and accelerates steeply.
337
return t * t * t * t;
338
}
339
340
float easeOutQuart(float t) {
341
// Starts steeply and slows down dramatically.
342
float f = t - 1.0;
343
return 1.0 - f * f * f * f;
344
}
345
346
float easeInOutQuart(float t) {
347
// Combines easeIn and easeOut quartic behavior for very smooth transitions.
348
return t < 0.5 ? 8.0 * t * t * t * t
349
: 1.0 - 8.0 * (t - 1.0) * (t - 1.0) * (t - 1.0) * (t - 1.0);
350
}
351
352
// Sine Easing
353
// Smooth, wave-like acceleration and deceleration using sine curves.
354
355
float easeInSine(float t) {
356
// Starts very slow, following a sine wave curve.
357
return 1.0 - cos((t * 3.141592653589793) / 2.0);
358
}
359
360
float easeOutSine(float t) {
361
// Starts fast and slows down following a sine wave curve.
362
return sin((t * 3.141592653589793) / 2.0);
363
}
364
365
float easeInOutSine(float t) {
366
// Smooth start and end, mimicking half a sine wave.
367
return -0.5 * (cos(3.141592653589793 * t) - 1.0);
368
}
369
370
// Exponential Easing
371
// Sharp transitions with rapid acceleration and deceleration.
372
373
float easeInExpo(float t) {
374
// Very slow start, accelerates exponentially.
375
return t == 0.0 ? 0.0 : pow(2.0, 10.0 * (t - 1.0));
376
}
377
378
float easeOutExpo(float t) {
379
// Starts fast and slows down exponentially.
380
return t == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * t);
381
}
382
383
float easeInOutExpo(float t) {
384
// Combines easeIn and easeOut exponential for sharp transitions.
385
if (t == 0.0) return 0.0;
386
if (t == 1.0) return 1.0;
387
return t < 0.5 ? 0.5 * pow(2.0, 20.0 * t - 10.0)
388
: 1.0 - 0.5 * pow(2.0, -20.0 * t + 10.0);
389
}
390
391
// Back Easing
392
// Creates an overshooting effect for more dynamic animations.
393
394
float easeInOutBack(float t) {
395
// Uses constants to define the overshooting magnitude.
396
const float c1 = 1.70158;
397
const float c2 = c1 * 1.525;
398
return t < 0.5
399
? (pow(2.0 * t, 2.0) * ((c2 + 1.0) * 2.0 * t - c2)) / 2.0
400
: (pow(2.0 * t - 2.0, 2.0) * ((c2 + 1.0) * (t * 2.0 - 2.0) + c2) + 2.0) / 2.0;
401
}
402
403
// --------------------------------------------------------------------- edge mask helpers
404
405
// This method returns a mask which smoothly transitions towards zero when approaching
406
// the window's borders. If the window is currently maximized or in fullscreen mode, this
407
// will return 1.0 everywhere. There is a variant which takes the transition area width in
408
// pixels and one which takes this as a percentage.
409
float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {
410
float mask = 1.0;
411
412
if (!uIsFullscreen) {
413
mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));
414
mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
415
mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));
416
mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));
417
}
418
419
return mask;
420
}
421
422
// Returns an edge mask which fades to zero at the boundaries of the actor. The width of
423
// the fade zone is given in pixels. This uses the standard uniforms uSize and uPadding.
424
// This means that the fading zone is not actually at the actors boundaries but at the
425
// position of the window border in the texture.
426
// The offset parameter controls whether the fading is placed inside the window borders
427
// (offset = 0), ontop the window borders (offset = 0.5) or outside the window borders
428
// (offset = 1).
429
float getAbsoluteEdgeMask(float fadePixels, float offset) {
430
float padding = max(0.0, uPadding - fadePixels * offset);
431
vec2 uv = iTexCoord.st * uSize - padding;
432
return getEdgeMask(uv, uSize - 2.0 * padding, fadePixels);
433
}
434
435
// Returns an edge mask which fades to zero at the boundaries of the actor. The width of
436
// the fade zone is given relative to the actor size. This neither uses uSize and
437
// uPadding.
438
float getRelativeEdgeMask(float fadeAmount) {
439
vec2 uv = iTexCoord.st;
440
return getEdgeMask(uv, vec2(1.0), fadeAmount);
441
}
442
443
// ------------------------------------------------------------------------------- 2D math
444
445
// The math for the whirling is inspired by this post:
446
// http://www.geeks3d.com/20110428/shader-library-swirl-post-processing-filter-in-glsl
447
vec2 whirl(vec2 coords, float warping, float rotation) {
448
float angle = pow(1.0 - length(coords), 2.0) * warping + rotation;
449
float s = sin(angle);
450
float c = cos(angle);
451
return vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));
452
}
453
454
// Returns the shortest distance between the given point and the line defined by "origin"
455
// and "direction".
456
float distToLine(vec2 origin, vec2 direction, vec2 point) {
457
vec2 perpendicular = vec2(direction.y, -direction.x);
458
return abs(dot(normalize(perpendicular), origin - point));
459
}
460
461
// Returns a positive number if a -> b forms a clockwise corner, or a negative number if
462
// the corner is counter-clockwise.
463
float getWinding(vec2 a, vec2 b) { return cross(vec3(a, 0.0), vec3(b, 0.0)).z; }
464
465
// Rotates the given 2D vector a clockwise by the angle alpha (given in radians).
466
vec2 rotate(vec2 a, float angle) {
467
return vec2(a.x * cos(angle) - a.y * sin(angle), a.x * sin(angle) + a.y * cos(angle));
468
}
469
470
// rotates a given 2d vector, around a given center (angle is in radians)
471
vec2 rotate(vec2 a, float angle, vec2 center) {
472
return vec2(cos(angle) * (a.x - center.x) + sin(angle) * (a.y - center.y) + center.x,
473
cos(angle) * (a.y - center.y) - sin(angle) * (a.x - center.x) + center.y);
474
}
475
476
// --------------------------------------------------------------------------------- noise
477
478
// These noise algorithms are based on implementations by various authors from
479
// shadertoy.com, which are all available under the MIT License. See the respective links
480
// in the comments below.
481
482
// Hash functions
483
// MIT License, https://www.shadertoy.com/view/4djSRW
484
// Copyright (c) 2014 David Hoskins.
485
486
// 1 out, 1 in...
487
float hash11(float p) {
488
p = fract(p * .1031);
489
p *= p + 33.33;
490
p *= p + p;
491
return fract(p);
492
}
493
494
// 1 out, 2 in...
495
float hash12(vec2 p) {
496
vec3 p3 = fract(vec3(p.xyx) * .1031);
497
p3 += dot(p3, p3.yzx + 33.33);
498
return fract((p3.x + p3.y) * p3.z);
499
}
500
501
// 1 out, 3 in...
502
float hash13(vec3 p3) {
503
p3 = fract(p3 * .1031);
504
p3 += dot(p3, p3.zyx + 31.32);
505
return fract((p3.x + p3.y) * p3.z);
506
}
507
508
// 2 out, 1 in...
509
vec2 hash21(float p) {
510
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
511
p3 += dot(p3, p3.yzx + 33.33);
512
return fract((p3.xx + p3.yz) * p3.zy);
513
}
514
515
// 2 out, 2 in...
516
vec2 hash22(vec2 p) {
517
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
518
p3 += dot(p3, p3.yzx + 33.33);
519
return fract((p3.xx + p3.yz) * p3.zy);
520
}
521
522
// 2 out, 3 in...
523
vec2 hash23(vec3 p3) {
524
p3 = fract(p3 * vec3(.1031, .1030, .0973));
525
p3 += dot(p3, p3.yzx + 33.33);
526
return fract((p3.xx + p3.yz) * p3.zy);
527
}
528
529
// 3 out, 1 in...
530
vec3 hash31(float p) {
531
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
532
p3 += dot(p3, p3.yzx + 33.33);
533
return fract((p3.xxy + p3.yzz) * p3.zyx);
534
}
535
536
// 3 out, 2 in...
537
vec3 hash32(vec2 p) {
538
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
539
p3 += dot(p3, p3.yxz + 33.33);
540
return fract((p3.xxy + p3.yzz) * p3.zyx);
541
}
542
543
// 3 out, 3 in...
544
vec3 hash33(vec3 p3) {
545
p3 = fract(p3 * vec3(.1031, .1030, .0973));
546
p3 += dot(p3, p3.yxz + 33.33);
547
return fract((p3.xxy + p3.yxx) * p3.zyx);
548
}
549
550
// 4 out, 1 in...
551
vec4 hash41(float p) {
552
vec4 p4 = fract(vec4(p) * vec4(.1031, .1030, .0973, .1099));
553
p4 += dot(p4, p4.wzxy + 33.33);
554
return fract((p4.xxyz + p4.yzzw) * p4.zywx);
555
}
556
557
// 4 out, 2 in...
558
vec4 hash42(vec2 p) {
559
vec4 p4 = fract(vec4(p.xyxy) * vec4(.1031, .1030, .0973, .1099));
560
p4 += dot(p4, p4.wzxy + 33.33);
561
return fract((p4.xxyz + p4.yzzw) * p4.zywx);
562
}
563
564
// 4 out, 3 in...
565
vec4 hash43(vec3 p) {
566
vec4 p4 = fract(vec4(p.xyzx) * vec4(.1031, .1030, .0973, .1099));
567
p4 += dot(p4, p4.wzxy + 33.33);
568
return fract((p4.xxyz + p4.yzzw) * p4.zywx);
569
}
570
571
// 4 out, 4 in...
572
vec4 hash44(vec4 p4) {
573
p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
574
p4 += dot(p4, p4.wzxy + 33.33);
575
return fract((p4.xxyz + p4.yzzw) * p4.zywx);
576
}
577
578
// 2D Simplex Noise
579
// MIT License, https://www.shadertoy.com/view/Msf3WH
580
// Copyright © 2013 Inigo Quilez
581
float simplex2D(vec2 p) {
582
const float K1 = 0.366025404; // (sqrt(3)-1)/2;
583
const float K2 = 0.211324865; // (3-sqrt(3))/6;
584
585
vec2 i = floor(p + (p.x + p.y) * K1);
586
vec2 a = p - i + (i.x + i.y) * K2;
587
float m = step(a.y, a.x);
588
vec2 o = vec2(m, 1.0 - m);
589
vec2 b = a - o + K2;
590
vec2 c = a - 1.0 + 2.0 * K2;
591
vec3 h = max(0.5 - vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0);
592
vec3 n = h * h * h * h *
593
vec3(dot(a, -1.0 + 2.0 * hash22(i + 0.0)), dot(b, -1.0 + 2.0 * hash22(i + o)),
594
dot(c, -1.0 + 2.0 * hash22(i + 1.0)));
595
return 0.5 + 0.5 * dot(n, vec3(70.0));
596
}
597
598
float simplex2DFractal(vec2 p) {
599
mat2 m = mat2(1.6, 1.2, -1.2, 1.6);
600
float f = 0.5000 * simplex2D(p);
601
p = m * p;
602
f += 0.2500 * simplex2D(p);
603
p = m * p;
604
f += 0.1250 * simplex2D(p);
605
p = m * p;
606
f += 0.0625 * simplex2D(p);
607
p = m * p;
608
609
return f;
610
}
611
612
// 3D Simplex Noise
613
// MIT License, https://www.shadertoy.com/view/XsX3zB
614
// Copyright © 2013 Nikita Miropolskiy
615
float simplex3D(vec3 p) {
616
617
// skew constants for 3D simplex functions
618
const float F3 = 0.3333333;
619
const float G3 = 0.1666667;
620
621
// 1. find current tetrahedron T and it's four vertices
622
// s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices
623
// x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertice
624
625
// calculate s and x
626
vec3 s = floor(p + dot(p, vec3(F3)));
627
vec3 x = p - s + dot(s, vec3(G3));
628
629
// calculate i1 and i2
630
vec3 e = step(vec3(0.0), x - x.yzx);
631
vec3 i1 = e * (1.0 - e.zxy);
632
vec3 i2 = 1.0 - e.zxy * (1.0 - e);
633
634
// x1, x2, x3
635
vec3 x1 = x - i1 + G3;
636
vec3 x2 = x - i2 + 2.0 * G3;
637
vec3 x3 = x - 1.0 + 3.0 * G3;
638
639
// 2. find four surflets and store them in d
640
vec4 w, d;
641
642
// calculate surflet weights
643
w.x = dot(x, x);
644
w.y = dot(x1, x1);
645
w.z = dot(x2, x2);
646
w.w = dot(x3, x3);
647
648
// w fades from 0.6 at the center of the surflet to 0.0 at the margin
649
w = max(0.6 - w, 0.0);
650
651
// calculate surflet components
652
d.x = dot(-0.5 + hash33(s), x);
653
d.y = dot(-0.5 + hash33(s + i1), x1);
654
d.z = dot(-0.5 + hash33(s + i2), x2);
655
d.w = dot(-0.5 + hash33(s + 1.0), x3);
656
657
// multiply d by w^4
658
w *= w;
659
w *= w;
660
d *= w;
661
662
// 3. return the sum of the four surflets
663
return dot(d, vec4(52.0)) * 0.5 + 0.5;
664
}
665
666
// Directional artifacts can be reduced by rotating each octave
667
float simplex3DFractal(vec3 m) {
668
669
// const matrices for 3D rotation
670
const mat3 rot1 = mat3(-0.37, 0.36, 0.85, -0.14, -0.93, 0.34, 0.92, 0.01, 0.4);
671
const mat3 rot2 = mat3(-0.55, -0.39, 0.74, 0.33, -0.91, -0.24, 0.77, 0.12, 0.63);
672
const mat3 rot3 = mat3(-0.71, 0.52, -0.47, -0.08, -0.72, -0.68, -0.7, -0.45, 0.56);
673
674
return 0.5333333 * simplex3D(m * rot1) + 0.2666667 * simplex3D(2.0 * m * rot2) +
675
0.1333333 * simplex3D(4.0 * m * rot3) + 0.0666667 * simplex3D(8.0 * m);
676
}
677
678
// --------------------------------------------------------------------------------- remap
679
680
/*
681
These functions remap a given value from one range to another.
682
The remap operation is particularly useful in shader programming
683
to scale or normalize data, ensuring compatibility across various
684
input ranges. Each version of the remap function supports a
685
different data type:
686
687
1. float: Remap a single scalar value.
688
2. vec2: Remap a 2D vector.
689
3. vec3: Remap a 3D vector.
690
4. vec4: Remap a 4D vector.
691
692
The general formula used is:
693
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin)
694
695
This ensures a linear transformation from the old range to the new range.
696
*/
697
698
// Remap for float
699
// Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].
700
// This is useful for normalizing or scaling scalar values to fit within a desired range.
701
float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {
702
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
703
newMax);
704
}
705
706
// Remap for vec2
707
// Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin,
708
// newMax]. Each component of the vec2 is individually scaled and transformed.
709
vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {
710
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
711
newMax);
712
}
713
714
// Remap for vec3
715
// Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin,
716
// newMax]. Each component of the vec3 is individually scaled and transformed.
717
vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {
718
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
719
newMax);
720
}
721
722
// Remap for vec4
723
// Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin,
724
// newMax]. Each component of the vec4 is individually scaled and transformed.
725
vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {
726
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
727
newMax);
728
}
729
//////////////////////////////////////////////////////////////////////////////////////////
730
// ) ( //
731
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
732
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
733
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
734
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
735
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
736
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
737
// |__/ //
738
//////////////////////////////////////////////////////////////////////////////////////////
739
740
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
741
// SPDX-License-Identifier: GPL-3.0-or-later
742
743
// The content from common.glsl is automatically prepended to each shader effect.
744
745
// Marble [Burn-My-Windows variant] v7: window morphs into a glossy 2D marble.
746
// The fall happens in main.js (Translation, constant gravity) after the marble is done.
747
uniform float uCrumpleEnd;
748
749
void main() {
750
float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
751
if (uDuration < -1.0) c = 0.0; // keep uDuration alive
752
float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
753
754
vec2 hs = 0.5 * uSize;
755
vec2 p = iTexCoord * uSize - hs;
756
float R0 = 0.035 * min(uSize.x, uSize.y); // ~7% diameter
757
vec2 b = mix(hs, vec2(R0), e); // half size of the morphing shape
758
float rad = mix(0.0, R0, e * e); // corner radius grows to a full circle
759
vec2 dq = max(abs(p) - (b - rad), 0.0);
760
float d = length(dq) - rad + min(max(abs(p).x - (b - rad).x, abs(p).y - (b - rad).y), 0.0);
761
762
// soft drop shadow (bottom-right), drawn where the marble is not
763
vec2 ps = p - vec2(0.12, 0.22) * R0 * e;
764
float sh = 0.35 * e * (1.0 - smoothstep(-0.2 * R0, 0.25 * R0, length(ps) - R0 * 0.9 * e + (1.0 - e) * 1e5));
765
if (d > 0.0) { setOutputColor(vec4(0.0, 0.0, 0.0, sh * step(0.5, e))); return; }
766
767
vec2 q = p / b; // -1..1 inside
768
float r2 = min(dot(q, q), 1.0);
769
float z = sqrt(1.0 - r2 * e); // sphere height (flat at e=0)
770
vec2 uv = 0.5 + 0.5 * q * mix(1.0, 0.75 + 0.45 * (1.0 - z), e);
771
vec4 col = getInputColor(clamp(uv, 0.0, 1.0));
772
col.a = step(0.97, col.a); // ignore the window shadow
773
col.a = mix(col.a, 1.0, e); // marble is solid
774
col.rgb = clamp(col.rgb, 0.0, 1.0);
775
776
// glossy marble shading
777
vec3 n = vec3(q * e, z);
778
float diff = clamp(dot(n, vec3(-0.45, -0.55, 0.70)), 0.0, 1.0);
779
vec2 hv = q - vec2(-0.38, -0.42);
780
float hd = dot(hv, hv);
781
float spot = (1.0 - smoothstep(0.004, 0.012, hd)); // small sharp highlight
782
float glow = 0.35 * (1.0 - smoothstep(0.0, 0.25, hd)); // softer glow
783
float fres = 1.0 - z; fres *= fres; // rim light
784
float bottom = 1.0 - 0.55 * clamp(q.y * 0.9 + 0.2, 0.0, 1.0) * (1.0 - z * 0.5);
785
float lit = mix(1.0, (0.45 + 0.65 * diff) * bottom, e);
786
col.rgb = col.rgb * lit + e * (vec3(spot * 0.9 + glow) + fres * vec3(0.25, 0.28, 0.32));
787
col.rgb = min(col.rgb, vec3(1.0));
788
col.a *= clamp(-d, 0.0, 1.0); // 1px anti-aliased edge
789
setOutputColor(col);
790
}
@@ -0,0 +1,790 @@1
#define KWIN_LEGACY2
#define PLASMA63
4
// This file is automatically generated during the build process.5
6
//////////////////////////////////////////////////////////////////////////////////////////7
// ) ( //8
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //9
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //10
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //11
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //12
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //13
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //14
// |__/ //15
//////////////////////////////////////////////////////////////////////////////////////////16
17
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>18
// SPDX-License-Identifier: GPL-3.0-or-later19
20
//////////////////////////////////////////////////////////////////////////////////////////21
// This file is automatically included in each shader. //22
//////////////////////////////////////////////////////////////////////////////////////////23
24
// --------------------------------------------------------------------- standard uniforms25
26
// Each shader can access these standard input values:27
28
// vec2 iTexCoord: Texture coordinates for retrieving the window input color.29
// bool uIsFullscreen: True if the window is maximized or in fullscreen mode.30
// bool uForOpening: True if a window-open animation is ongoing, false otherwise.31
// float uProgress: A value which transitions from 0 to 1 during the animation.32
// float uDuration: The duration of the current animation in seconds.33
// vec2 uSize: The size of uTexture in pixels.34
// float uPadding: The empty area around the actual window (e.g. where the shadow35
// is drawn). For now, this will only be set on GNOME.36
37
// Furthermore, there are two global methods for reading the window input color and38
// setting the shader output color. Both methods assume straight alpha:39
40
// vec4 getInputColor(vec2 coords)41
// void setOutputColor(vec4 outColor)42
43
uniform bool uForOpening;44
uniform bool uIsFullscreen;45
uniform float uProgress;46
uniform float uDuration;47
48
#if defined(KWIN) // --------------------------------------------------------------------49
50
#if defined(PLASMA6)51
#include "colormanagement.glsl"52
#endif53
54
uniform sampler2D sampler;55
uniform int textureWidth;56
uniform int textureHeight;57
58
in vec2 texcoord0;59
out vec4 fragColor;60
61
// Using defines here as OpenGL ES forbids non-constant global initializers.62
#define uSize vec2(textureWidth, textureHeight)63
#define iTexCoord vec2(texcoord0.x, texcoord0.y)64
float uPadding = 0.0;65
66
vec4 getInputColor(vec2 coords) {67
vec4 color = texture2D(sampler, coords);68
69
if (color.a > 0.0) {70
color.rgb /= color.a;71
}72
73
return color;74
}75
76
void setOutputColor(vec4 outColor) {77
78
// If a uniform is not used, it will be optimized away. This condition is always79
// false, but it will prevent the compiler from optimizing away the uniforms uForOpening80
// and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a81
// uniform is used in the shader.82
if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {83
outColor = vec4(0.0);84
}85
86
fragColor = vec4(outColor.rgb * outColor.a, outColor.a);87
88
#if defined(PLASMA6)89
fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);90
fragColor = nitsToDestinationEncoding(fragColor);91
#endif92
}93
94
#elif defined(KWIN_LEGACY) // -----------------------------------------------------------95
96
#if defined(PLASMA6)97
#include "colormanagement.glsl"98
#endif99
100
uniform sampler2D sampler;101
uniform int textureWidth;102
uniform int textureHeight;103
104
varying vec2 texcoord0;105
106
vec2 uSize = vec2(textureWidth, textureHeight);107
vec2 iTexCoord = vec2(texcoord0.x, texcoord0.y);108
float uPadding = 0.0;109
110
vec4 getInputColor(vec2 coords) {111
vec4 color = texture2D(sampler, coords);112
113
if (color.a > 0.0) {114
color.rgb /= color.a;115
}116
117
return color;118
}119
120
void setOutputColor(vec4 outColor) {121
// If a uniform is not used, it will be optimized away. This condition is always122
// false, but it will prevent the compiler from optimizing away the uniforms uForOpening123
// and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a124
// uniform is used in the shader.125
if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {126
outColor = vec4(0.0);127
}128
129
gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a);130
131
#if defined(PLASMA6)132
fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);133
fragColor = nitsToDestinationEncoding(fragColor);134
#endif135
}136
137
#else // GNOME --------------------------------------------------------------------------138
139
// On GNOME, the uniforms are just normal uniforms.140
uniform sampler2D uTexture;141
uniform vec2 uSize;142
uniform float uPadding;143
144
// On GNOME, we set iTexCoord to be an alias for the cogl variables.145
#define iTexCoord vec2(cogl_tex_coord_in[0])146
147
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.148
vec4 getInputColor(vec2 coords) {149
vec4 color = texture2D(uTexture, coords);150
151
if (color.a > 0.0) {152
color.rgb /= color.a;153
}154
155
return color;156
}157
158
void setOutputColor(vec4 outColor) { cogl_color_out = outColor; }159
160
#endif // -------------------------------------------------------------------------------161
162
// A simple blur function163
vec4 getBlurredInputColor(vec2 uv, float radius, float samples) {164
// Initialize the color accumulator to zero.165
vec4 color = vec4(0.0);166
167
// Define a constant for 2 * PI (tau), which represents a full circle in radians.168
const float tau = 6.28318530718;169
170
// Number of directions for sampling around the circle.171
const float directions = 15.0;172
173
// Outer loop iterates over multiple directions evenly spaced around a circle.174
for (float d = 0.0; d < tau; d += tau / directions) {175
// Inner loop samples along each direction, with decreasing intensity.176
for (float s = 0.0; s < 1.0; s += 1.0 / samples) {177
// Calculate the offset for this sample based on direction, radius, and step.178
// The (1.0 - s) term ensures more sampling occurs closer to the center.179
vec2 offset = vec2(cos(d), sin(d)) * radius * (1.0 - s) / uSize;180
181
// Add the sampled color at the offset position to the accumulator.182
color += getInputColor(uv + offset);183
}184
}185
186
// Normalize the accumulated color by dividing by the total number of samples187
// and directions to ensure the result is averaged.188
return color / samples / directions;189
}190
191
// ----------------------------------------------------------------- compositing operators192
193
// The Shell.GLSLEffect uses straight alpha blending. This helper method allows194
// compositing color values in the shader in the same way.195
vec4 alphaOver(vec4 under, vec4 over) {196
if (under.a == 0.0 && over.a == 0.0) {197
return vec4(0.0);198
}199
200
float alpha = mix(under.a, 1.0, over.a);201
return vec4(mix(under.rgb * under.a, over.rgb, over.a) / alpha, alpha);202
}203
204
// ------------------------------------------------------------------------- color helpers205
206
// Maps the given value from [0..1] to the given colors.207
vec3 tritone(float val, vec3 shadows, vec3 midtones, vec3 highlights) {208
if (val < 0.5) {209
return mix(shadows, midtones, smoothstep(0.0, 1.0, val * 2.0));210
}211
212
return mix(midtones, highlights, smoothstep(0.0, 1.0, val * 2.0 - 1.0));213
}214
215
// Darkens the given color. If fac is zero, the color will not change, if fac is one, the216
// color will be black.217
vec3 darken(vec3 color, float fac) { return color * (1.0 - fac); }218
219
// Lightens the given color. If fac is zero, the color will not change, if fac is one, the220
// color will be white.221
vec3 lighten(vec3 color, float fac) { return color + (vec3(1.0) - color) * fac; }222
223
// change the color based on an offset amount224
vec3 offsetHue(vec3 color, float hueOffset) {225
// Convert RGB to HSV226
float maxC = max(max(color.r, color.g), color.b);227
float minC = min(min(color.r, color.g), color.b);228
float delta = maxC - minC;229
230
float hue = 0.0;231
if (delta > 0.0) {232
if (maxC == color.r) {233
hue = mod((color.g - color.b) / delta, 6.0);234
} else if (maxC == color.g) {235
hue = (color.b - color.r) / delta + 2.0;236
} else {237
hue = (color.r - color.g) / delta + 4.0;238
}239
}240
hue /= 6.0;241
242
float saturation = (maxC > 0.0) ? (delta / maxC) : 0.0;243
float value = maxC;244
245
// Offset the hue246
hue = mod(hue + hueOffset, 1.0);247
248
// Convert HSV back to RGB249
float c = value * saturation;250
float x = c * (1.0 - abs(mod(hue * 6.0, 2.0) - 1.0));251
float m = value - c;252
253
vec3 rgb;254
if (hue < 1.0 / 6.0) {255
rgb = vec3(c, x, 0.0);256
} else if (hue < 2.0 / 6.0) {257
rgb = vec3(x, c, 0.0);258
} else if (hue < 3.0 / 6.0) {259
rgb = vec3(0.0, c, x);260
} else if (hue < 4.0 / 6.0) {261
rgb = vec3(0.0, x, c);262
} else if (hue < 5.0 / 6.0) {263
rgb = vec3(x, 0.0, c);264
} else {265
rgb = vec3(c, 0.0, x);266
}267
268
return rgb + m;269
}270
271
// ---------------------------------------------------------------------- easing functions272
273
// Here are some basic easing function. More can be added if required!274
// Taken from here:275
// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/clutter/clutter/clutter-easing.c276
277
float easeOutQuad(float x) { return -1.0 * x * (x - 2.0); }278
279
float easeInQuad(float x) { return x * x; }280
281
float easeInBack(float x, float e) { return x * x * ((e + 1.0) * x - e); }282
283
float easeOutBack(float x, float e) {284
float p = x - 1.0;285
return p * p * ((e + 1.0) * p + e) + 1.0;286
}287
288
// https://easings.net/289
/*290
Easing functions define the rate of change of a parameter over time, commonly used in291
animations, UI transitions, and game development. They provide a way to make movements292
more natural or visually appealing rather than linear and mechanical. Popular categories293
of easing functions include:294
295
Linear: Constant speed from start to finish.296
Quadratic (Ease In, Ease Out, Ease In Out): Changes at varying rates, with smoother starts297
or stops. Cubic: Similar to quadratic but allows for even more nuanced transitions.298
Exponential: Drastic changes at the start or end, often used for dramatic effects.299
Bounce: Mimics a bouncing object with oscillations.300
Elastic: Simulates the behavior of a spring, with overshooting and oscillations.301
Below are text-based "graphs" of some easing functions, where the horizontal axis302
represents time and the vertical axis represents progress.303
*/304
305
// Quadratic Easing306
// Smooth acceleration and deceleration using quadratic (t^2) curves.307
308
float easeInOutQuad(float t) {309
// Accelerates for the first half, decelerates for the second half.310
return t < 0.5 ? 2.0 * t * t : -1.0 + (4.0 - 2.0 * t) * t;311
}312
313
// Cubic Easing314
// Smoother transitions compared to quadratic easing using cubic (t^3) curves.315
316
float easeInCubic(float t) {317
// Starts slow and accelerates as t increases.318
return t * t * t;319
}320
321
float easeOutCubic(float t) {322
// Starts fast and decelerates as t approaches 1.0.323
float f = t - 1.0;324
return f * f * f + 1.0;325
}326
327
float easeInOutCubic(float t) {328
// Combines easeIn and easeOut cubic behavior for smooth transitions.329
return t < 0.5 ? 4.0 * t * t * t : (t - 1.0) * (2.0 * t - 2.0) * (2.0 * t - 2.0) + 1.0;330
}331
332
// Quartic Easing333
// Even smoother transitions than cubic, using quartic (t^4) curves.334
335
float easeInQuart(float t) {336
// Starts very slow and accelerates steeply.337
return t * t * t * t;338
}339
340
float easeOutQuart(float t) {341
// Starts steeply and slows down dramatically.342
float f = t - 1.0;343
return 1.0 - f * f * f * f;344
}345
346
float easeInOutQuart(float t) {347
// Combines easeIn and easeOut quartic behavior for very smooth transitions.348
return t < 0.5 ? 8.0 * t * t * t * t349
: 1.0 - 8.0 * (t - 1.0) * (t - 1.0) * (t - 1.0) * (t - 1.0);350
}351
352
// Sine Easing353
// Smooth, wave-like acceleration and deceleration using sine curves.354
355
float easeInSine(float t) {356
// Starts very slow, following a sine wave curve.357
return 1.0 - cos((t * 3.141592653589793) / 2.0);358
}359
360
float easeOutSine(float t) {361
// Starts fast and slows down following a sine wave curve.362
return sin((t * 3.141592653589793) / 2.0);363
}364
365
float easeInOutSine(float t) {366
// Smooth start and end, mimicking half a sine wave.367
return -0.5 * (cos(3.141592653589793 * t) - 1.0);368
}369
370
// Exponential Easing371
// Sharp transitions with rapid acceleration and deceleration.372
373
float easeInExpo(float t) {374
// Very slow start, accelerates exponentially.375
return t == 0.0 ? 0.0 : pow(2.0, 10.0 * (t - 1.0));376
}377
378
float easeOutExpo(float t) {379
// Starts fast and slows down exponentially.380
return t == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * t);381
}382
383
float easeInOutExpo(float t) {384
// Combines easeIn and easeOut exponential for sharp transitions.385
if (t == 0.0) return 0.0;386
if (t == 1.0) return 1.0;387
return t < 0.5 ? 0.5 * pow(2.0, 20.0 * t - 10.0)388
: 1.0 - 0.5 * pow(2.0, -20.0 * t + 10.0);389
}390
391
// Back Easing392
// Creates an overshooting effect for more dynamic animations.393
394
float easeInOutBack(float t) {395
// Uses constants to define the overshooting magnitude.396
const float c1 = 1.70158;397
const float c2 = c1 * 1.525;398
return t < 0.5399
? (pow(2.0 * t, 2.0) * ((c2 + 1.0) * 2.0 * t - c2)) / 2.0400
: (pow(2.0 * t - 2.0, 2.0) * ((c2 + 1.0) * (t * 2.0 - 2.0) + c2) + 2.0) / 2.0;401
}402
403
// --------------------------------------------------------------------- edge mask helpers404
405
// This method returns a mask which smoothly transitions towards zero when approaching406
// the window's borders. If the window is currently maximized or in fullscreen mode, this407
// will return 1.0 everywhere. There is a variant which takes the transition area width in408
// pixels and one which takes this as a percentage.409
float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {410
float mask = 1.0;411
412
if (!uIsFullscreen) {413
mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));414
mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));415
mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));416
mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));417
}418
419
return mask;420
}421
422
// Returns an edge mask which fades to zero at the boundaries of the actor. The width of423
// the fade zone is given in pixels. This uses the standard uniforms uSize and uPadding.424
// This means that the fading zone is not actually at the actors boundaries but at the425
// position of the window border in the texture.426
// The offset parameter controls whether the fading is placed inside the window borders427
// (offset = 0), ontop the window borders (offset = 0.5) or outside the window borders428
// (offset = 1).429
float getAbsoluteEdgeMask(float fadePixels, float offset) {430
float padding = max(0.0, uPadding - fadePixels * offset);431
vec2 uv = iTexCoord.st * uSize - padding;432
return getEdgeMask(uv, uSize - 2.0 * padding, fadePixels);433
}434
435
// Returns an edge mask which fades to zero at the boundaries of the actor. The width of436
// the fade zone is given relative to the actor size. This neither uses uSize and437
// uPadding.438
float getRelativeEdgeMask(float fadeAmount) {439
vec2 uv = iTexCoord.st;440
return getEdgeMask(uv, vec2(1.0), fadeAmount);441
}442
443
// ------------------------------------------------------------------------------- 2D math444
445
// The math for the whirling is inspired by this post:446
// http://www.geeks3d.com/20110428/shader-library-swirl-post-processing-filter-in-glsl447
vec2 whirl(vec2 coords, float warping, float rotation) {448
float angle = pow(1.0 - length(coords), 2.0) * warping + rotation;449
float s = sin(angle);450
float c = cos(angle);451
return vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));452
}453
454
// Returns the shortest distance between the given point and the line defined by "origin"455
// and "direction".456
float distToLine(vec2 origin, vec2 direction, vec2 point) {457
vec2 perpendicular = vec2(direction.y, -direction.x);458
return abs(dot(normalize(perpendicular), origin - point));459
}460
461
// Returns a positive number if a -> b forms a clockwise corner, or a negative number if462
// the corner is counter-clockwise.463
float getWinding(vec2 a, vec2 b) { return cross(vec3(a, 0.0), vec3(b, 0.0)).z; }464
465
// Rotates the given 2D vector a clockwise by the angle alpha (given in radians).466
vec2 rotate(vec2 a, float angle) {467
return vec2(a.x * cos(angle) - a.y * sin(angle), a.x * sin(angle) + a.y * cos(angle));468
}469
470
// rotates a given 2d vector, around a given center (angle is in radians)471
vec2 rotate(vec2 a, float angle, vec2 center) {472
return vec2(cos(angle) * (a.x - center.x) + sin(angle) * (a.y - center.y) + center.x,473
cos(angle) * (a.y - center.y) - sin(angle) * (a.x - center.x) + center.y);474
}475
476
// --------------------------------------------------------------------------------- noise477
478
// These noise algorithms are based on implementations by various authors from479
// shadertoy.com, which are all available under the MIT License. See the respective links480
// in the comments below.481
482
// Hash functions483
// MIT License, https://www.shadertoy.com/view/4djSRW484
// Copyright (c) 2014 David Hoskins.485
486
// 1 out, 1 in...487
float hash11(float p) {488
p = fract(p * .1031);489
p *= p + 33.33;490
p *= p + p;491
return fract(p);492
}493
494
// 1 out, 2 in...495
float hash12(vec2 p) {496
vec3 p3 = fract(vec3(p.xyx) * .1031);497
p3 += dot(p3, p3.yzx + 33.33);498
return fract((p3.x + p3.y) * p3.z);499
}500
501
// 1 out, 3 in...502
float hash13(vec3 p3) {503
p3 = fract(p3 * .1031);504
p3 += dot(p3, p3.zyx + 31.32);505
return fract((p3.x + p3.y) * p3.z);506
}507
508
// 2 out, 1 in...509
vec2 hash21(float p) {510
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));511
p3 += dot(p3, p3.yzx + 33.33);512
return fract((p3.xx + p3.yz) * p3.zy);513
}514
515
// 2 out, 2 in...516
vec2 hash22(vec2 p) {517
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));518
p3 += dot(p3, p3.yzx + 33.33);519
return fract((p3.xx + p3.yz) * p3.zy);520
}521
522
// 2 out, 3 in...523
vec2 hash23(vec3 p3) {524
p3 = fract(p3 * vec3(.1031, .1030, .0973));525
p3 += dot(p3, p3.yzx + 33.33);526
return fract((p3.xx + p3.yz) * p3.zy);527
}528
529
// 3 out, 1 in...530
vec3 hash31(float p) {531
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));532
p3 += dot(p3, p3.yzx + 33.33);533
return fract((p3.xxy + p3.yzz) * p3.zyx);534
}535
536
// 3 out, 2 in...537
vec3 hash32(vec2 p) {538
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));539
p3 += dot(p3, p3.yxz + 33.33);540
return fract((p3.xxy + p3.yzz) * p3.zyx);541
}542
543
// 3 out, 3 in...544
vec3 hash33(vec3 p3) {545
p3 = fract(p3 * vec3(.1031, .1030, .0973));546
p3 += dot(p3, p3.yxz + 33.33);547
return fract((p3.xxy + p3.yxx) * p3.zyx);548
}549
550
// 4 out, 1 in...551
vec4 hash41(float p) {552
vec4 p4 = fract(vec4(p) * vec4(.1031, .1030, .0973, .1099));553
p4 += dot(p4, p4.wzxy + 33.33);554
return fract((p4.xxyz + p4.yzzw) * p4.zywx);555
}556
557
// 4 out, 2 in...558
vec4 hash42(vec2 p) {559
vec4 p4 = fract(vec4(p.xyxy) * vec4(.1031, .1030, .0973, .1099));560
p4 += dot(p4, p4.wzxy + 33.33);561
return fract((p4.xxyz + p4.yzzw) * p4.zywx);562
}563
564
// 4 out, 3 in...565
vec4 hash43(vec3 p) {566
vec4 p4 = fract(vec4(p.xyzx) * vec4(.1031, .1030, .0973, .1099));567
p4 += dot(p4, p4.wzxy + 33.33);568
return fract((p4.xxyz + p4.yzzw) * p4.zywx);569
}570
571
// 4 out, 4 in...572
vec4 hash44(vec4 p4) {573
p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));574
p4 += dot(p4, p4.wzxy + 33.33);575
return fract((p4.xxyz + p4.yzzw) * p4.zywx);576
}577
578
// 2D Simplex Noise579
// MIT License, https://www.shadertoy.com/view/Msf3WH580
// Copyright © 2013 Inigo Quilez581
float simplex2D(vec2 p) {582
const float K1 = 0.366025404; // (sqrt(3)-1)/2;583
const float K2 = 0.211324865; // (3-sqrt(3))/6;584
585
vec2 i = floor(p + (p.x + p.y) * K1);586
vec2 a = p - i + (i.x + i.y) * K2;587
float m = step(a.y, a.x);588
vec2 o = vec2(m, 1.0 - m);589
vec2 b = a - o + K2;590
vec2 c = a - 1.0 + 2.0 * K2;591
vec3 h = max(0.5 - vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0);592
vec3 n = h * h * h * h *593
vec3(dot(a, -1.0 + 2.0 * hash22(i + 0.0)), dot(b, -1.0 + 2.0 * hash22(i + o)),594
dot(c, -1.0 + 2.0 * hash22(i + 1.0)));595
return 0.5 + 0.5 * dot(n, vec3(70.0));596
}597
598
float simplex2DFractal(vec2 p) {599
mat2 m = mat2(1.6, 1.2, -1.2, 1.6);600
float f = 0.5000 * simplex2D(p);601
p = m * p;602
f += 0.2500 * simplex2D(p);603
p = m * p;604
f += 0.1250 * simplex2D(p);605
p = m * p;606
f += 0.0625 * simplex2D(p);607
p = m * p;608
609
return f;610
}611
612
// 3D Simplex Noise613
// MIT License, https://www.shadertoy.com/view/XsX3zB614
// Copyright © 2013 Nikita Miropolskiy615
float simplex3D(vec3 p) {616
617
// skew constants for 3D simplex functions618
const float F3 = 0.3333333;619
const float G3 = 0.1666667;620
621
// 1. find current tetrahedron T and it's four vertices622
// s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices623
// x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertice624
625
// calculate s and x626
vec3 s = floor(p + dot(p, vec3(F3)));627
vec3 x = p - s + dot(s, vec3(G3));628
629
// calculate i1 and i2630
vec3 e = step(vec3(0.0), x - x.yzx);631
vec3 i1 = e * (1.0 - e.zxy);632
vec3 i2 = 1.0 - e.zxy * (1.0 - e);633
634
// x1, x2, x3635
vec3 x1 = x - i1 + G3;636
vec3 x2 = x - i2 + 2.0 * G3;637
vec3 x3 = x - 1.0 + 3.0 * G3;638
639
// 2. find four surflets and store them in d640
vec4 w, d;641
642
// calculate surflet weights643
w.x = dot(x, x);644
w.y = dot(x1, x1);645
w.z = dot(x2, x2);646
w.w = dot(x3, x3);647
648
// w fades from 0.6 at the center of the surflet to 0.0 at the margin649
w = max(0.6 - w, 0.0);650
651
// calculate surflet components652
d.x = dot(-0.5 + hash33(s), x);653
d.y = dot(-0.5 + hash33(s + i1), x1);654
d.z = dot(-0.5 + hash33(s + i2), x2);655
d.w = dot(-0.5 + hash33(s + 1.0), x3);656
657
// multiply d by w^4658
w *= w;659
w *= w;660
d *= w;661
662
// 3. return the sum of the four surflets663
return dot(d, vec4(52.0)) * 0.5 + 0.5;664
}665
666
// Directional artifacts can be reduced by rotating each octave667
float simplex3DFractal(vec3 m) {668
669
// const matrices for 3D rotation670
const mat3 rot1 = mat3(-0.37, 0.36, 0.85, -0.14, -0.93, 0.34, 0.92, 0.01, 0.4);671
const mat3 rot2 = mat3(-0.55, -0.39, 0.74, 0.33, -0.91, -0.24, 0.77, 0.12, 0.63);672
const mat3 rot3 = mat3(-0.71, 0.52, -0.47, -0.08, -0.72, -0.68, -0.7, -0.45, 0.56);673
674
return 0.5333333 * simplex3D(m * rot1) + 0.2666667 * simplex3D(2.0 * m * rot2) +675
0.1333333 * simplex3D(4.0 * m * rot3) + 0.0666667 * simplex3D(8.0 * m);676
}677
678
// --------------------------------------------------------------------------------- remap679
680
/*681
These functions remap a given value from one range to another.682
The remap operation is particularly useful in shader programming683
to scale or normalize data, ensuring compatibility across various684
input ranges. Each version of the remap function supports a685
different data type:686
687
1. float: Remap a single scalar value.688
2. vec2: Remap a 2D vector.689
3. vec3: Remap a 3D vector.690
4. vec4: Remap a 4D vector.691
692
The general formula used is:693
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin)694
695
This ensures a linear transformation from the old range to the new range.696
*/697
698
// Remap for float699
// Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].700
// This is useful for normalizing or scaling scalar values to fit within a desired range.701
float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {702
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,703
newMax);704
}705
706
// Remap for vec2707
// Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin,708
// newMax]. Each component of the vec2 is individually scaled and transformed.709
vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {710
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,711
newMax);712
}713
714
// Remap for vec3715
// Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin,716
// newMax]. Each component of the vec3 is individually scaled and transformed.717
vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {718
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,719
newMax);720
}721
722
// Remap for vec4723
// Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin,724
// newMax]. Each component of the vec4 is individually scaled and transformed.725
vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {726
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,727
newMax);728
}729
//////////////////////////////////////////////////////////////////////////////////////////730
// ) ( //731
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //732
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //733
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //734
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //735
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //736
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //737
// |__/ //738
//////////////////////////////////////////////////////////////////////////////////////////739
740
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>741
// SPDX-License-Identifier: GPL-3.0-or-later742
743
// The content from common.glsl is automatically prepended to each shader effect.744
745
// Marble [Burn-My-Windows variant] v7: window morphs into a glossy 2D marble.746
// The fall happens in main.js (Translation, constant gravity) after the marble is done.747
uniform float uCrumpleEnd;748
749
void main() {750
float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);751
if (uDuration < -1.0) c = 0.0; // keep uDuration alive752
float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep753
754
vec2 hs = 0.5 * uSize;755
vec2 p = iTexCoord * uSize - hs;756
float R0 = 0.035 * min(uSize.x, uSize.y); // ~7% diameter757
vec2 b = mix(hs, vec2(R0), e); // half size of the morphing shape758
float rad = mix(0.0, R0, e * e); // corner radius grows to a full circle759
vec2 dq = max(abs(p) - (b - rad), 0.0);760
float d = length(dq) - rad + min(max(abs(p).x - (b - rad).x, abs(p).y - (b - rad).y), 0.0);761
762
// soft drop shadow (bottom-right), drawn where the marble is not763
vec2 ps = p - vec2(0.12, 0.22) * R0 * e;764
float sh = 0.35 * e * (1.0 - smoothstep(-0.2 * R0, 0.25 * R0, length(ps) - R0 * 0.9 * e + (1.0 - e) * 1e5));765
if (d > 0.0) { setOutputColor(vec4(0.0, 0.0, 0.0, sh * step(0.5, e))); return; }766
767
vec2 q = p / b; // -1..1 inside768
float r2 = min(dot(q, q), 1.0);769
float z = sqrt(1.0 - r2 * e); // sphere height (flat at e=0)770
vec2 uv = 0.5 + 0.5 * q * mix(1.0, 0.75 + 0.45 * (1.0 - z), e);771
vec4 col = getInputColor(clamp(uv, 0.0, 1.0));772
col.a = step(0.97, col.a); // ignore the window shadow773
col.a = mix(col.a, 1.0, e); // marble is solid774
col.rgb = clamp(col.rgb, 0.0, 1.0);775
776
// glossy marble shading777
vec3 n = vec3(q * e, z);778
float diff = clamp(dot(n, vec3(-0.45, -0.55, 0.70)), 0.0, 1.0);779
vec2 hv = q - vec2(-0.38, -0.42);780
float hd = dot(hv, hv);781
float spot = (1.0 - smoothstep(0.004, 0.012, hd)); // small sharp highlight782
float glow = 0.35 * (1.0 - smoothstep(0.0, 0.25, hd)); // softer glow783
float fres = 1.0 - z; fres *= fres; // rim light784
float bottom = 1.0 - 0.55 * clamp(q.y * 0.9 + 0.2, 0.0, 1.0) * (1.0 - z * 0.5);785
float lit = mix(1.0, (0.45 + 0.65 * diff) * bottom, e);786
col.rgb = col.rgb * lit + e * (vec3(spot * 0.9 + glow) + fres * vec3(0.25, 0.28, 0.32));787
col.rgb = min(col.rgb, vec3(1.0));788
col.a *= clamp(-d, 0.0, 1.0); // 1px anti-aliased edge789
setOutputColor(col);790
}@@ -0,0 +1,791 @@
1
#version 140
2
#define KWIN
3
#define PLASMA6
4
5
// This file is automatically generated during the build process.
6
7
//////////////////////////////////////////////////////////////////////////////////////////
8
// ) ( //
9
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
10
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
11
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
12
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
13
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
14
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
15
// |__/ //
16
//////////////////////////////////////////////////////////////////////////////////////////
17
18
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
19
// SPDX-License-Identifier: GPL-3.0-or-later
20
21
//////////////////////////////////////////////////////////////////////////////////////////
22
// This file is automatically included in each shader. //
23
//////////////////////////////////////////////////////////////////////////////////////////
24
25
// --------------------------------------------------------------------- standard uniforms
26
27
// Each shader can access these standard input values:
28
29
// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
30
// bool uIsFullscreen: True if the window is maximized or in fullscreen mode.
31
// bool uForOpening: True if a window-open animation is ongoing, false otherwise.
32
// float uProgress: A value which transitions from 0 to 1 during the animation.
33
// float uDuration: The duration of the current animation in seconds.
34
// vec2 uSize: The size of uTexture in pixels.
35
// float uPadding: The empty area around the actual window (e.g. where the shadow
36
// is drawn). For now, this will only be set on GNOME.
37
38
// Furthermore, there are two global methods for reading the window input color and
39
// setting the shader output color. Both methods assume straight alpha:
40
41
// vec4 getInputColor(vec2 coords)
42
// void setOutputColor(vec4 outColor)
43
44
uniform bool uForOpening;
45
uniform bool uIsFullscreen;
46
uniform float uProgress;
47
uniform float uDuration;
48
49
#if defined(KWIN) // --------------------------------------------------------------------
50
51
#if defined(PLASMA6)
52
#include "colormanagement.glsl"
53
#endif
54
55
uniform sampler2D sampler;
56
uniform int textureWidth;
57
uniform int textureHeight;
58
59
in vec2 texcoord0;
60
out vec4 fragColor;
61
62
// Using defines here as OpenGL ES forbids non-constant global initializers.
63
#define uSize vec2(textureWidth, textureHeight)
64
#define iTexCoord vec2(texcoord0.x, texcoord0.y)
65
float uPadding = 0.0;
66
67
vec4 getInputColor(vec2 coords) {
68
vec4 color = texture2D(sampler, coords);
69
70
if (color.a > 0.0) {
71
color.rgb /= color.a;
72
}
73
74
return color;
75
}
76
77
void setOutputColor(vec4 outColor) {
78
79
// If a uniform is not used, it will be optimized away. This condition is always
80
// false, but it will prevent the compiler from optimizing away the uniforms uForOpening
81
// and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
82
// uniform is used in the shader.
83
if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
84
outColor = vec4(0.0);
85
}
86
87
fragColor = vec4(outColor.rgb * outColor.a, outColor.a);
88
89
#if defined(PLASMA6)
90
fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
91
fragColor = nitsToDestinationEncoding(fragColor);
92
#endif
93
}
94
95
#elif defined(KWIN_LEGACY) // -----------------------------------------------------------
96
97
#if defined(PLASMA6)
98
#include "colormanagement.glsl"
99
#endif
100
101
uniform sampler2D sampler;
102
uniform int textureWidth;
103
uniform int textureHeight;
104
105
varying vec2 texcoord0;
106
107
vec2 uSize = vec2(textureWidth, textureHeight);
108
vec2 iTexCoord = vec2(texcoord0.x, texcoord0.y);
109
float uPadding = 0.0;
110
111
vec4 getInputColor(vec2 coords) {
112
vec4 color = texture2D(sampler, coords);
113
114
if (color.a > 0.0) {
115
color.rgb /= color.a;
116
}
117
118
return color;
119
}
120
121
void setOutputColor(vec4 outColor) {
122
// If a uniform is not used, it will be optimized away. This condition is always
123
// false, but it will prevent the compiler from optimizing away the uniforms uForOpening
124
// and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
125
// uniform is used in the shader.
126
if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {
127
outColor = vec4(0.0);
128
}
129
130
gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a);
131
132
#if defined(PLASMA6)
133
fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);
134
fragColor = nitsToDestinationEncoding(fragColor);
135
#endif
136
}
137
138
#else // GNOME --------------------------------------------------------------------------
139
140
// On GNOME, the uniforms are just normal uniforms.
141
uniform sampler2D uTexture;
142
uniform vec2 uSize;
143
uniform float uPadding;
144
145
// On GNOME, we set iTexCoord to be an alias for the cogl variables.
146
#define iTexCoord vec2(cogl_tex_coord_in[0])
147
148
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.
149
vec4 getInputColor(vec2 coords) {
150
vec4 color = texture2D(uTexture, coords);
151
152
if (color.a > 0.0) {
153
color.rgb /= color.a;
154
}
155
156
return color;
157
}
158
159
void setOutputColor(vec4 outColor) { cogl_color_out = outColor; }
160
161
#endif // -------------------------------------------------------------------------------
162
163
// A simple blur function
164
vec4 getBlurredInputColor(vec2 uv, float radius, float samples) {
165
// Initialize the color accumulator to zero.
166
vec4 color = vec4(0.0);
167
168
// Define a constant for 2 * PI (tau), which represents a full circle in radians.
169
const float tau = 6.28318530718;
170
171
// Number of directions for sampling around the circle.
172
const float directions = 15.0;
173
174
// Outer loop iterates over multiple directions evenly spaced around a circle.
175
for (float d = 0.0; d < tau; d += tau / directions) {
176
// Inner loop samples along each direction, with decreasing intensity.
177
for (float s = 0.0; s < 1.0; s += 1.0 / samples) {
178
// Calculate the offset for this sample based on direction, radius, and step.
179
// The (1.0 - s) term ensures more sampling occurs closer to the center.
180
vec2 offset = vec2(cos(d), sin(d)) * radius * (1.0 - s) / uSize;
181
182
// Add the sampled color at the offset position to the accumulator.
183
color += getInputColor(uv + offset);
184
}
185
}
186
187
// Normalize the accumulated color by dividing by the total number of samples
188
// and directions to ensure the result is averaged.
189
return color / samples / directions;
190
}
191
192
// ----------------------------------------------------------------- compositing operators
193
194
// The Shell.GLSLEffect uses straight alpha blending. This helper method allows
195
// compositing color values in the shader in the same way.
196
vec4 alphaOver(vec4 under, vec4 over) {
197
if (under.a == 0.0 && over.a == 0.0) {
198
return vec4(0.0);
199
}
200
201
float alpha = mix(under.a, 1.0, over.a);
202
return vec4(mix(under.rgb * under.a, over.rgb, over.a) / alpha, alpha);
203
}
204
205
// ------------------------------------------------------------------------- color helpers
206
207
// Maps the given value from [0..1] to the given colors.
208
vec3 tritone(float val, vec3 shadows, vec3 midtones, vec3 highlights) {
209
if (val < 0.5) {
210
return mix(shadows, midtones, smoothstep(0.0, 1.0, val * 2.0));
211
}
212
213
return mix(midtones, highlights, smoothstep(0.0, 1.0, val * 2.0 - 1.0));
214
}
215
216
// Darkens the given color. If fac is zero, the color will not change, if fac is one, the
217
// color will be black.
218
vec3 darken(vec3 color, float fac) { return color * (1.0 - fac); }
219
220
// Lightens the given color. If fac is zero, the color will not change, if fac is one, the
221
// color will be white.
222
vec3 lighten(vec3 color, float fac) { return color + (vec3(1.0) - color) * fac; }
223
224
// change the color based on an offset amount
225
vec3 offsetHue(vec3 color, float hueOffset) {
226
// Convert RGB to HSV
227
float maxC = max(max(color.r, color.g), color.b);
228
float minC = min(min(color.r, color.g), color.b);
229
float delta = maxC - minC;
230
231
float hue = 0.0;
232
if (delta > 0.0) {
233
if (maxC == color.r) {
234
hue = mod((color.g - color.b) / delta, 6.0);
235
} else if (maxC == color.g) {
236
hue = (color.b - color.r) / delta + 2.0;
237
} else {
238
hue = (color.r - color.g) / delta + 4.0;
239
}
240
}
241
hue /= 6.0;
242
243
float saturation = (maxC > 0.0) ? (delta / maxC) : 0.0;
244
float value = maxC;
245
246
// Offset the hue
247
hue = mod(hue + hueOffset, 1.0);
248
249
// Convert HSV back to RGB
250
float c = value * saturation;
251
float x = c * (1.0 - abs(mod(hue * 6.0, 2.0) - 1.0));
252
float m = value - c;
253
254
vec3 rgb;
255
if (hue < 1.0 / 6.0) {
256
rgb = vec3(c, x, 0.0);
257
} else if (hue < 2.0 / 6.0) {
258
rgb = vec3(x, c, 0.0);
259
} else if (hue < 3.0 / 6.0) {
260
rgb = vec3(0.0, c, x);
261
} else if (hue < 4.0 / 6.0) {
262
rgb = vec3(0.0, x, c);
263
} else if (hue < 5.0 / 6.0) {
264
rgb = vec3(x, 0.0, c);
265
} else {
266
rgb = vec3(c, 0.0, x);
267
}
268
269
return rgb + m;
270
}
271
272
// ---------------------------------------------------------------------- easing functions
273
274
// Here are some basic easing function. More can be added if required!
275
// Taken from here:
276
// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/clutter/clutter/clutter-easing.c
277
278
float easeOutQuad(float x) { return -1.0 * x * (x - 2.0); }
279
280
float easeInQuad(float x) { return x * x; }
281
282
float easeInBack(float x, float e) { return x * x * ((e + 1.0) * x - e); }
283
284
float easeOutBack(float x, float e) {
285
float p = x - 1.0;
286
return p * p * ((e + 1.0) * p + e) + 1.0;
287
}
288
289
// https://easings.net/
290
/*
291
Easing functions define the rate of change of a parameter over time, commonly used in
292
animations, UI transitions, and game development. They provide a way to make movements
293
more natural or visually appealing rather than linear and mechanical. Popular categories
294
of easing functions include:
295
296
Linear: Constant speed from start to finish.
297
Quadratic (Ease In, Ease Out, Ease In Out): Changes at varying rates, with smoother starts
298
or stops. Cubic: Similar to quadratic but allows for even more nuanced transitions.
299
Exponential: Drastic changes at the start or end, often used for dramatic effects.
300
Bounce: Mimics a bouncing object with oscillations.
301
Elastic: Simulates the behavior of a spring, with overshooting and oscillations.
302
Below are text-based "graphs" of some easing functions, where the horizontal axis
303
represents time and the vertical axis represents progress.
304
*/
305
306
// Quadratic Easing
307
// Smooth acceleration and deceleration using quadratic (t^2) curves.
308
309
float easeInOutQuad(float t) {
310
// Accelerates for the first half, decelerates for the second half.
311
return t < 0.5 ? 2.0 * t * t : -1.0 + (4.0 - 2.0 * t) * t;
312
}
313
314
// Cubic Easing
315
// Smoother transitions compared to quadratic easing using cubic (t^3) curves.
316
317
float easeInCubic(float t) {
318
// Starts slow and accelerates as t increases.
319
return t * t * t;
320
}
321
322
float easeOutCubic(float t) {
323
// Starts fast and decelerates as t approaches 1.0.
324
float f = t - 1.0;
325
return f * f * f + 1.0;
326
}
327
328
float easeInOutCubic(float t) {
329
// Combines easeIn and easeOut cubic behavior for smooth transitions.
330
return t < 0.5 ? 4.0 * t * t * t : (t - 1.0) * (2.0 * t - 2.0) * (2.0 * t - 2.0) + 1.0;
331
}
332
333
// Quartic Easing
334
// Even smoother transitions than cubic, using quartic (t^4) curves.
335
336
float easeInQuart(float t) {
337
// Starts very slow and accelerates steeply.
338
return t * t * t * t;
339
}
340
341
float easeOutQuart(float t) {
342
// Starts steeply and slows down dramatically.
343
float f = t - 1.0;
344
return 1.0 - f * f * f * f;
345
}
346
347
float easeInOutQuart(float t) {
348
// Combines easeIn and easeOut quartic behavior for very smooth transitions.
349
return t < 0.5 ? 8.0 * t * t * t * t
350
: 1.0 - 8.0 * (t - 1.0) * (t - 1.0) * (t - 1.0) * (t - 1.0);
351
}
352
353
// Sine Easing
354
// Smooth, wave-like acceleration and deceleration using sine curves.
355
356
float easeInSine(float t) {
357
// Starts very slow, following a sine wave curve.
358
return 1.0 - cos((t * 3.141592653589793) / 2.0);
359
}
360
361
float easeOutSine(float t) {
362
// Starts fast and slows down following a sine wave curve.
363
return sin((t * 3.141592653589793) / 2.0);
364
}
365
366
float easeInOutSine(float t) {
367
// Smooth start and end, mimicking half a sine wave.
368
return -0.5 * (cos(3.141592653589793 * t) - 1.0);
369
}
370
371
// Exponential Easing
372
// Sharp transitions with rapid acceleration and deceleration.
373
374
float easeInExpo(float t) {
375
// Very slow start, accelerates exponentially.
376
return t == 0.0 ? 0.0 : pow(2.0, 10.0 * (t - 1.0));
377
}
378
379
float easeOutExpo(float t) {
380
// Starts fast and slows down exponentially.
381
return t == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * t);
382
}
383
384
float easeInOutExpo(float t) {
385
// Combines easeIn and easeOut exponential for sharp transitions.
386
if (t == 0.0) return 0.0;
387
if (t == 1.0) return 1.0;
388
return t < 0.5 ? 0.5 * pow(2.0, 20.0 * t - 10.0)
389
: 1.0 - 0.5 * pow(2.0, -20.0 * t + 10.0);
390
}
391
392
// Back Easing
393
// Creates an overshooting effect for more dynamic animations.
394
395
float easeInOutBack(float t) {
396
// Uses constants to define the overshooting magnitude.
397
const float c1 = 1.70158;
398
const float c2 = c1 * 1.525;
399
return t < 0.5
400
? (pow(2.0 * t, 2.0) * ((c2 + 1.0) * 2.0 * t - c2)) / 2.0
401
: (pow(2.0 * t - 2.0, 2.0) * ((c2 + 1.0) * (t * 2.0 - 2.0) + c2) + 2.0) / 2.0;
402
}
403
404
// --------------------------------------------------------------------- edge mask helpers
405
406
// This method returns a mask which smoothly transitions towards zero when approaching
407
// the window's borders. If the window is currently maximized or in fullscreen mode, this
408
// will return 1.0 everywhere. There is a variant which takes the transition area width in
409
// pixels and one which takes this as a percentage.
410
float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {
411
float mask = 1.0;
412
413
if (!uIsFullscreen) {
414
mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));
415
mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
416
mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));
417
mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));
418
}
419
420
return mask;
421
}
422
423
// Returns an edge mask which fades to zero at the boundaries of the actor. The width of
424
// the fade zone is given in pixels. This uses the standard uniforms uSize and uPadding.
425
// This means that the fading zone is not actually at the actors boundaries but at the
426
// position of the window border in the texture.
427
// The offset parameter controls whether the fading is placed inside the window borders
428
// (offset = 0), ontop the window borders (offset = 0.5) or outside the window borders
429
// (offset = 1).
430
float getAbsoluteEdgeMask(float fadePixels, float offset) {
431
float padding = max(0.0, uPadding - fadePixels * offset);
432
vec2 uv = iTexCoord.st * uSize - padding;
433
return getEdgeMask(uv, uSize - 2.0 * padding, fadePixels);
434
}
435
436
// Returns an edge mask which fades to zero at the boundaries of the actor. The width of
437
// the fade zone is given relative to the actor size. This neither uses uSize and
438
// uPadding.
439
float getRelativeEdgeMask(float fadeAmount) {
440
vec2 uv = iTexCoord.st;
441
return getEdgeMask(uv, vec2(1.0), fadeAmount);
442
}
443
444
// ------------------------------------------------------------------------------- 2D math
445
446
// The math for the whirling is inspired by this post:
447
// http://www.geeks3d.com/20110428/shader-library-swirl-post-processing-filter-in-glsl
448
vec2 whirl(vec2 coords, float warping, float rotation) {
449
float angle = pow(1.0 - length(coords), 2.0) * warping + rotation;
450
float s = sin(angle);
451
float c = cos(angle);
452
return vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));
453
}
454
455
// Returns the shortest distance between the given point and the line defined by "origin"
456
// and "direction".
457
float distToLine(vec2 origin, vec2 direction, vec2 point) {
458
vec2 perpendicular = vec2(direction.y, -direction.x);
459
return abs(dot(normalize(perpendicular), origin - point));
460
}
461
462
// Returns a positive number if a -> b forms a clockwise corner, or a negative number if
463
// the corner is counter-clockwise.
464
float getWinding(vec2 a, vec2 b) { return cross(vec3(a, 0.0), vec3(b, 0.0)).z; }
465
466
// Rotates the given 2D vector a clockwise by the angle alpha (given in radians).
467
vec2 rotate(vec2 a, float angle) {
468
return vec2(a.x * cos(angle) - a.y * sin(angle), a.x * sin(angle) + a.y * cos(angle));
469
}
470
471
// rotates a given 2d vector, around a given center (angle is in radians)
472
vec2 rotate(vec2 a, float angle, vec2 center) {
473
return vec2(cos(angle) * (a.x - center.x) + sin(angle) * (a.y - center.y) + center.x,
474
cos(angle) * (a.y - center.y) - sin(angle) * (a.x - center.x) + center.y);
475
}
476
477
// --------------------------------------------------------------------------------- noise
478
479
// These noise algorithms are based on implementations by various authors from
480
// shadertoy.com, which are all available under the MIT License. See the respective links
481
// in the comments below.
482
483
// Hash functions
484
// MIT License, https://www.shadertoy.com/view/4djSRW
485
// Copyright (c) 2014 David Hoskins.
486
487
// 1 out, 1 in...
488
float hash11(float p) {
489
p = fract(p * .1031);
490
p *= p + 33.33;
491
p *= p + p;
492
return fract(p);
493
}
494
495
// 1 out, 2 in...
496
float hash12(vec2 p) {
497
vec3 p3 = fract(vec3(p.xyx) * .1031);
498
p3 += dot(p3, p3.yzx + 33.33);
499
return fract((p3.x + p3.y) * p3.z);
500
}
501
502
// 1 out, 3 in...
503
float hash13(vec3 p3) {
504
p3 = fract(p3 * .1031);
505
p3 += dot(p3, p3.zyx + 31.32);
506
return fract((p3.x + p3.y) * p3.z);
507
}
508
509
// 2 out, 1 in...
510
vec2 hash21(float p) {
511
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
512
p3 += dot(p3, p3.yzx + 33.33);
513
return fract((p3.xx + p3.yz) * p3.zy);
514
}
515
516
// 2 out, 2 in...
517
vec2 hash22(vec2 p) {
518
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
519
p3 += dot(p3, p3.yzx + 33.33);
520
return fract((p3.xx + p3.yz) * p3.zy);
521
}
522
523
// 2 out, 3 in...
524
vec2 hash23(vec3 p3) {
525
p3 = fract(p3 * vec3(.1031, .1030, .0973));
526
p3 += dot(p3, p3.yzx + 33.33);
527
return fract((p3.xx + p3.yz) * p3.zy);
528
}
529
530
// 3 out, 1 in...
531
vec3 hash31(float p) {
532
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
533
p3 += dot(p3, p3.yzx + 33.33);
534
return fract((p3.xxy + p3.yzz) * p3.zyx);
535
}
536
537
// 3 out, 2 in...
538
vec3 hash32(vec2 p) {
539
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
540
p3 += dot(p3, p3.yxz + 33.33);
541
return fract((p3.xxy + p3.yzz) * p3.zyx);
542
}
543
544
// 3 out, 3 in...
545
vec3 hash33(vec3 p3) {
546
p3 = fract(p3 * vec3(.1031, .1030, .0973));
547
p3 += dot(p3, p3.yxz + 33.33);
548
return fract((p3.xxy + p3.yxx) * p3.zyx);
549
}
550
551
// 4 out, 1 in...
552
vec4 hash41(float p) {
553
vec4 p4 = fract(vec4(p) * vec4(.1031, .1030, .0973, .1099));
554
p4 += dot(p4, p4.wzxy + 33.33);
555
return fract((p4.xxyz + p4.yzzw) * p4.zywx);
556
}
557
558
// 4 out, 2 in...
559
vec4 hash42(vec2 p) {
560
vec4 p4 = fract(vec4(p.xyxy) * vec4(.1031, .1030, .0973, .1099));
561
p4 += dot(p4, p4.wzxy + 33.33);
562
return fract((p4.xxyz + p4.yzzw) * p4.zywx);
563
}
564
565
// 4 out, 3 in...
566
vec4 hash43(vec3 p) {
567
vec4 p4 = fract(vec4(p.xyzx) * vec4(.1031, .1030, .0973, .1099));
568
p4 += dot(p4, p4.wzxy + 33.33);
569
return fract((p4.xxyz + p4.yzzw) * p4.zywx);
570
}
571
572
// 4 out, 4 in...
573
vec4 hash44(vec4 p4) {
574
p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
575
p4 += dot(p4, p4.wzxy + 33.33);
576
return fract((p4.xxyz + p4.yzzw) * p4.zywx);
577
}
578
579
// 2D Simplex Noise
580
// MIT License, https://www.shadertoy.com/view/Msf3WH
581
// Copyright © 2013 Inigo Quilez
582
float simplex2D(vec2 p) {
583
const float K1 = 0.366025404; // (sqrt(3)-1)/2;
584
const float K2 = 0.211324865; // (3-sqrt(3))/6;
585
586
vec2 i = floor(p + (p.x + p.y) * K1);
587
vec2 a = p - i + (i.x + i.y) * K2;
588
float m = step(a.y, a.x);
589
vec2 o = vec2(m, 1.0 - m);
590
vec2 b = a - o + K2;
591
vec2 c = a - 1.0 + 2.0 * K2;
592
vec3 h = max(0.5 - vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0);
593
vec3 n = h * h * h * h *
594
vec3(dot(a, -1.0 + 2.0 * hash22(i + 0.0)), dot(b, -1.0 + 2.0 * hash22(i + o)),
595
dot(c, -1.0 + 2.0 * hash22(i + 1.0)));
596
return 0.5 + 0.5 * dot(n, vec3(70.0));
597
}
598
599
float simplex2DFractal(vec2 p) {
600
mat2 m = mat2(1.6, 1.2, -1.2, 1.6);
601
float f = 0.5000 * simplex2D(p);
602
p = m * p;
603
f += 0.2500 * simplex2D(p);
604
p = m * p;
605
f += 0.1250 * simplex2D(p);
606
p = m * p;
607
f += 0.0625 * simplex2D(p);
608
p = m * p;
609
610
return f;
611
}
612
613
// 3D Simplex Noise
614
// MIT License, https://www.shadertoy.com/view/XsX3zB
615
// Copyright © 2013 Nikita Miropolskiy
616
float simplex3D(vec3 p) {
617
618
// skew constants for 3D simplex functions
619
const float F3 = 0.3333333;
620
const float G3 = 0.1666667;
621
622
// 1. find current tetrahedron T and it's four vertices
623
// s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices
624
// x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertice
625
626
// calculate s and x
627
vec3 s = floor(p + dot(p, vec3(F3)));
628
vec3 x = p - s + dot(s, vec3(G3));
629
630
// calculate i1 and i2
631
vec3 e = step(vec3(0.0), x - x.yzx);
632
vec3 i1 = e * (1.0 - e.zxy);
633
vec3 i2 = 1.0 - e.zxy * (1.0 - e);
634
635
// x1, x2, x3
636
vec3 x1 = x - i1 + G3;
637
vec3 x2 = x - i2 + 2.0 * G3;
638
vec3 x3 = x - 1.0 + 3.0 * G3;
639
640
// 2. find four surflets and store them in d
641
vec4 w, d;
642
643
// calculate surflet weights
644
w.x = dot(x, x);
645
w.y = dot(x1, x1);
646
w.z = dot(x2, x2);
647
w.w = dot(x3, x3);
648
649
// w fades from 0.6 at the center of the surflet to 0.0 at the margin
650
w = max(0.6 - w, 0.0);
651
652
// calculate surflet components
653
d.x = dot(-0.5 + hash33(s), x);
654
d.y = dot(-0.5 + hash33(s + i1), x1);
655
d.z = dot(-0.5 + hash33(s + i2), x2);
656
d.w = dot(-0.5 + hash33(s + 1.0), x3);
657
658
// multiply d by w^4
659
w *= w;
660
w *= w;
661
d *= w;
662
663
// 3. return the sum of the four surflets
664
return dot(d, vec4(52.0)) * 0.5 + 0.5;
665
}
666
667
// Directional artifacts can be reduced by rotating each octave
668
float simplex3DFractal(vec3 m) {
669
670
// const matrices for 3D rotation
671
const mat3 rot1 = mat3(-0.37, 0.36, 0.85, -0.14, -0.93, 0.34, 0.92, 0.01, 0.4);
672
const mat3 rot2 = mat3(-0.55, -0.39, 0.74, 0.33, -0.91, -0.24, 0.77, 0.12, 0.63);
673
const mat3 rot3 = mat3(-0.71, 0.52, -0.47, -0.08, -0.72, -0.68, -0.7, -0.45, 0.56);
674
675
return 0.5333333 * simplex3D(m * rot1) + 0.2666667 * simplex3D(2.0 * m * rot2) +
676
0.1333333 * simplex3D(4.0 * m * rot3) + 0.0666667 * simplex3D(8.0 * m);
677
}
678
679
// --------------------------------------------------------------------------------- remap
680
681
/*
682
These functions remap a given value from one range to another.
683
The remap operation is particularly useful in shader programming
684
to scale or normalize data, ensuring compatibility across various
685
input ranges. Each version of the remap function supports a
686
different data type:
687
688
1. float: Remap a single scalar value.
689
2. vec2: Remap a 2D vector.
690
3. vec3: Remap a 3D vector.
691
4. vec4: Remap a 4D vector.
692
693
The general formula used is:
694
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin)
695
696
This ensures a linear transformation from the old range to the new range.
697
*/
698
699
// Remap for float
700
// Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].
701
// This is useful for normalizing or scaling scalar values to fit within a desired range.
702
float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {
703
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
704
newMax);
705
}
706
707
// Remap for vec2
708
// Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin,
709
// newMax]. Each component of the vec2 is individually scaled and transformed.
710
vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {
711
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
712
newMax);
713
}
714
715
// Remap for vec3
716
// Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin,
717
// newMax]. Each component of the vec3 is individually scaled and transformed.
718
vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {
719
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
720
newMax);
721
}
722
723
// Remap for vec4
724
// Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin,
725
// newMax]. Each component of the vec4 is individually scaled and transformed.
726
vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {
727
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,
728
newMax);
729
}
730
//////////////////////////////////////////////////////////////////////////////////////////
731
// ) ( //
732
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
733
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
734
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
735
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
736
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
737
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
738
// |__/ //
739
//////////////////////////////////////////////////////////////////////////////////////////
740
741
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
742
// SPDX-License-Identifier: GPL-3.0-or-later
743
744
// The content from common.glsl is automatically prepended to each shader effect.
745
746
// Marble [Burn-My-Windows variant] v7: window morphs into a glossy 2D marble.
747
// The fall happens in main.js (Translation, constant gravity) after the marble is done.
748
uniform float uCrumpleEnd;
749
750
void main() {
751
float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);
752
if (uDuration < -1.0) c = 0.0; // keep uDuration alive
753
float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep
754
755
vec2 hs = 0.5 * uSize;
756
vec2 p = iTexCoord * uSize - hs;
757
float R0 = 0.035 * min(uSize.x, uSize.y); // ~7% diameter
758
vec2 b = mix(hs, vec2(R0), e); // half size of the morphing shape
759
float rad = mix(0.0, R0, e * e); // corner radius grows to a full circle
760
vec2 dq = max(abs(p) - (b - rad), 0.0);
761
float d = length(dq) - rad + min(max(abs(p).x - (b - rad).x, abs(p).y - (b - rad).y), 0.0);
762
763
// soft drop shadow (bottom-right), drawn where the marble is not
764
vec2 ps = p - vec2(0.12, 0.22) * R0 * e;
765
float sh = 0.35 * e * (1.0 - smoothstep(-0.2 * R0, 0.25 * R0, length(ps) - R0 * 0.9 * e + (1.0 - e) * 1e5));
766
if (d > 0.0) { setOutputColor(vec4(0.0, 0.0, 0.0, sh * step(0.5, e))); return; }
767
768
vec2 q = p / b; // -1..1 inside
769
float r2 = min(dot(q, q), 1.0);
770
float z = sqrt(1.0 - r2 * e); // sphere height (flat at e=0)
771
vec2 uv = 0.5 + 0.5 * q * mix(1.0, 0.75 + 0.45 * (1.0 - z), e);
772
vec4 col = getInputColor(clamp(uv, 0.0, 1.0));
773
col.a = step(0.97, col.a); // ignore the window shadow
774
col.a = mix(col.a, 1.0, e); // marble is solid
775
col.rgb = clamp(col.rgb, 0.0, 1.0);
776
777
// glossy marble shading
778
vec3 n = vec3(q * e, z);
779
float diff = clamp(dot(n, vec3(-0.45, -0.55, 0.70)), 0.0, 1.0);
780
vec2 hv = q - vec2(-0.38, -0.42);
781
float hd = dot(hv, hv);
782
float spot = (1.0 - smoothstep(0.004, 0.012, hd)); // small sharp highlight
783
float glow = 0.35 * (1.0 - smoothstep(0.0, 0.25, hd)); // softer glow
784
float fres = 1.0 - z; fres *= fres; // rim light
785
float bottom = 1.0 - 0.55 * clamp(q.y * 0.9 + 0.2, 0.0, 1.0) * (1.0 - z * 0.5);
786
float lit = mix(1.0, (0.45 + 0.65 * diff) * bottom, e);
787
col.rgb = col.rgb * lit + e * (vec3(spot * 0.9 + glow) + fres * vec3(0.25, 0.28, 0.32));
788
col.rgb = min(col.rgb, vec3(1.0));
789
col.a *= clamp(-d, 0.0, 1.0); // 1px anti-aliased edge
790
setOutputColor(col);
791
}
@@ -0,0 +1,791 @@1
#version 1402
#define KWIN3
#define PLASMA64
5
// This file is automatically generated during the build process.6
7
//////////////////////////////////////////////////////////////////////////////////////////8
// ) ( //9
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //10
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //11
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //12
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //13
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //14
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //15
// |__/ //16
//////////////////////////////////////////////////////////////////////////////////////////17
18
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>19
// SPDX-License-Identifier: GPL-3.0-or-later20
21
//////////////////////////////////////////////////////////////////////////////////////////22
// This file is automatically included in each shader. //23
//////////////////////////////////////////////////////////////////////////////////////////24
25
// --------------------------------------------------------------------- standard uniforms26
27
// Each shader can access these standard input values:28
29
// vec2 iTexCoord: Texture coordinates for retrieving the window input color.30
// bool uIsFullscreen: True if the window is maximized or in fullscreen mode.31
// bool uForOpening: True if a window-open animation is ongoing, false otherwise.32
// float uProgress: A value which transitions from 0 to 1 during the animation.33
// float uDuration: The duration of the current animation in seconds.34
// vec2 uSize: The size of uTexture in pixels.35
// float uPadding: The empty area around the actual window (e.g. where the shadow36
// is drawn). For now, this will only be set on GNOME.37
38
// Furthermore, there are two global methods for reading the window input color and39
// setting the shader output color. Both methods assume straight alpha:40
41
// vec4 getInputColor(vec2 coords)42
// void setOutputColor(vec4 outColor)43
44
uniform bool uForOpening;45
uniform bool uIsFullscreen;46
uniform float uProgress;47
uniform float uDuration;48
49
#if defined(KWIN) // --------------------------------------------------------------------50
51
#if defined(PLASMA6)52
#include "colormanagement.glsl"53
#endif54
55
uniform sampler2D sampler;56
uniform int textureWidth;57
uniform int textureHeight;58
59
in vec2 texcoord0;60
out vec4 fragColor;61
62
// Using defines here as OpenGL ES forbids non-constant global initializers.63
#define uSize vec2(textureWidth, textureHeight)64
#define iTexCoord vec2(texcoord0.x, texcoord0.y)65
float uPadding = 0.0;66
67
vec4 getInputColor(vec2 coords) {68
vec4 color = texture2D(sampler, coords);69
70
if (color.a > 0.0) {71
color.rgb /= color.a;72
}73
74
return color;75
}76
77
void setOutputColor(vec4 outColor) {78
79
// If a uniform is not used, it will be optimized away. This condition is always80
// false, but it will prevent the compiler from optimizing away the uniforms uForOpening81
// and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a82
// uniform is used in the shader.83
if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {84
outColor = vec4(0.0);85
}86
87
fragColor = vec4(outColor.rgb * outColor.a, outColor.a);88
89
#if defined(PLASMA6)90
fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);91
fragColor = nitsToDestinationEncoding(fragColor);92
#endif93
}94
95
#elif defined(KWIN_LEGACY) // -----------------------------------------------------------96
97
#if defined(PLASMA6)98
#include "colormanagement.glsl"99
#endif100
101
uniform sampler2D sampler;102
uniform int textureWidth;103
uniform int textureHeight;104
105
varying vec2 texcoord0;106
107
vec2 uSize = vec2(textureWidth, textureHeight);108
vec2 iTexCoord = vec2(texcoord0.x, texcoord0.y);109
float uPadding = 0.0;110
111
vec4 getInputColor(vec2 coords) {112
vec4 color = texture2D(sampler, coords);113
114
if (color.a > 0.0) {115
color.rgb /= color.a;116
}117
118
return color;119
}120
121
void setOutputColor(vec4 outColor) {122
// If a uniform is not used, it will be optimized away. This condition is always123
// false, but it will prevent the compiler from optimizing away the uniforms uForOpening124
// and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a125
// uniform is used in the shader.126
if (outColor.a > 1000.0 && uForOpening && uIsFullscreen) {127
outColor = vec4(0.0);128
}129
130
gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a);131
132
#if defined(PLASMA6)133
fragColor = sourceEncodingToNitsInDestinationColorspace(fragColor);134
fragColor = nitsToDestinationEncoding(fragColor);135
#endif136
}137
138
#else // GNOME --------------------------------------------------------------------------139
140
// On GNOME, the uniforms are just normal uniforms.141
uniform sampler2D uTexture;142
uniform vec2 uSize;143
uniform float uPadding;144
145
// On GNOME, we set iTexCoord to be an alias for the cogl variables.146
#define iTexCoord vec2(cogl_tex_coord_in[0])147
148
// Shell.GLSLEffect uses straight alpha. So we have to convert from premultiplied.149
vec4 getInputColor(vec2 coords) {150
vec4 color = texture2D(uTexture, coords);151
152
if (color.a > 0.0) {153
color.rgb /= color.a;154
}155
156
return color;157
}158
159
void setOutputColor(vec4 outColor) { cogl_color_out = outColor; }160
161
#endif // -------------------------------------------------------------------------------162
163
// A simple blur function164
vec4 getBlurredInputColor(vec2 uv, float radius, float samples) {165
// Initialize the color accumulator to zero.166
vec4 color = vec4(0.0);167
168
// Define a constant for 2 * PI (tau), which represents a full circle in radians.169
const float tau = 6.28318530718;170
171
// Number of directions for sampling around the circle.172
const float directions = 15.0;173
174
// Outer loop iterates over multiple directions evenly spaced around a circle.175
for (float d = 0.0; d < tau; d += tau / directions) {176
// Inner loop samples along each direction, with decreasing intensity.177
for (float s = 0.0; s < 1.0; s += 1.0 / samples) {178
// Calculate the offset for this sample based on direction, radius, and step.179
// The (1.0 - s) term ensures more sampling occurs closer to the center.180
vec2 offset = vec2(cos(d), sin(d)) * radius * (1.0 - s) / uSize;181
182
// Add the sampled color at the offset position to the accumulator.183
color += getInputColor(uv + offset);184
}185
}186
187
// Normalize the accumulated color by dividing by the total number of samples188
// and directions to ensure the result is averaged.189
return color / samples / directions;190
}191
192
// ----------------------------------------------------------------- compositing operators193
194
// The Shell.GLSLEffect uses straight alpha blending. This helper method allows195
// compositing color values in the shader in the same way.196
vec4 alphaOver(vec4 under, vec4 over) {197
if (under.a == 0.0 && over.a == 0.0) {198
return vec4(0.0);199
}200
201
float alpha = mix(under.a, 1.0, over.a);202
return vec4(mix(under.rgb * under.a, over.rgb, over.a) / alpha, alpha);203
}204
205
// ------------------------------------------------------------------------- color helpers206
207
// Maps the given value from [0..1] to the given colors.208
vec3 tritone(float val, vec3 shadows, vec3 midtones, vec3 highlights) {209
if (val < 0.5) {210
return mix(shadows, midtones, smoothstep(0.0, 1.0, val * 2.0));211
}212
213
return mix(midtones, highlights, smoothstep(0.0, 1.0, val * 2.0 - 1.0));214
}215
216
// Darkens the given color. If fac is zero, the color will not change, if fac is one, the217
// color will be black.218
vec3 darken(vec3 color, float fac) { return color * (1.0 - fac); }219
220
// Lightens the given color. If fac is zero, the color will not change, if fac is one, the221
// color will be white.222
vec3 lighten(vec3 color, float fac) { return color + (vec3(1.0) - color) * fac; }223
224
// change the color based on an offset amount225
vec3 offsetHue(vec3 color, float hueOffset) {226
// Convert RGB to HSV227
float maxC = max(max(color.r, color.g), color.b);228
float minC = min(min(color.r, color.g), color.b);229
float delta = maxC - minC;230
231
float hue = 0.0;232
if (delta > 0.0) {233
if (maxC == color.r) {234
hue = mod((color.g - color.b) / delta, 6.0);235
} else if (maxC == color.g) {236
hue = (color.b - color.r) / delta + 2.0;237
} else {238
hue = (color.r - color.g) / delta + 4.0;239
}240
}241
hue /= 6.0;242
243
float saturation = (maxC > 0.0) ? (delta / maxC) : 0.0;244
float value = maxC;245
246
// Offset the hue247
hue = mod(hue + hueOffset, 1.0);248
249
// Convert HSV back to RGB250
float c = value * saturation;251
float x = c * (1.0 - abs(mod(hue * 6.0, 2.0) - 1.0));252
float m = value - c;253
254
vec3 rgb;255
if (hue < 1.0 / 6.0) {256
rgb = vec3(c, x, 0.0);257
} else if (hue < 2.0 / 6.0) {258
rgb = vec3(x, c, 0.0);259
} else if (hue < 3.0 / 6.0) {260
rgb = vec3(0.0, c, x);261
} else if (hue < 4.0 / 6.0) {262
rgb = vec3(0.0, x, c);263
} else if (hue < 5.0 / 6.0) {264
rgb = vec3(x, 0.0, c);265
} else {266
rgb = vec3(c, 0.0, x);267
}268
269
return rgb + m;270
}271
272
// ---------------------------------------------------------------------- easing functions273
274
// Here are some basic easing function. More can be added if required!275
// Taken from here:276
// https://gitlab.gnome.org/GNOME/mutter/-/blob/main/clutter/clutter/clutter-easing.c277
278
float easeOutQuad(float x) { return -1.0 * x * (x - 2.0); }279
280
float easeInQuad(float x) { return x * x; }281
282
float easeInBack(float x, float e) { return x * x * ((e + 1.0) * x - e); }283
284
float easeOutBack(float x, float e) {285
float p = x - 1.0;286
return p * p * ((e + 1.0) * p + e) + 1.0;287
}288
289
// https://easings.net/290
/*291
Easing functions define the rate of change of a parameter over time, commonly used in292
animations, UI transitions, and game development. They provide a way to make movements293
more natural or visually appealing rather than linear and mechanical. Popular categories294
of easing functions include:295
296
Linear: Constant speed from start to finish.297
Quadratic (Ease In, Ease Out, Ease In Out): Changes at varying rates, with smoother starts298
or stops. Cubic: Similar to quadratic but allows for even more nuanced transitions.299
Exponential: Drastic changes at the start or end, often used for dramatic effects.300
Bounce: Mimics a bouncing object with oscillations.301
Elastic: Simulates the behavior of a spring, with overshooting and oscillations.302
Below are text-based "graphs" of some easing functions, where the horizontal axis303
represents time and the vertical axis represents progress.304
*/305
306
// Quadratic Easing307
// Smooth acceleration and deceleration using quadratic (t^2) curves.308
309
float easeInOutQuad(float t) {310
// Accelerates for the first half, decelerates for the second half.311
return t < 0.5 ? 2.0 * t * t : -1.0 + (4.0 - 2.0 * t) * t;312
}313
314
// Cubic Easing315
// Smoother transitions compared to quadratic easing using cubic (t^3) curves.316
317
float easeInCubic(float t) {318
// Starts slow and accelerates as t increases.319
return t * t * t;320
}321
322
float easeOutCubic(float t) {323
// Starts fast and decelerates as t approaches 1.0.324
float f = t - 1.0;325
return f * f * f + 1.0;326
}327
328
float easeInOutCubic(float t) {329
// Combines easeIn and easeOut cubic behavior for smooth transitions.330
return t < 0.5 ? 4.0 * t * t * t : (t - 1.0) * (2.0 * t - 2.0) * (2.0 * t - 2.0) + 1.0;331
}332
333
// Quartic Easing334
// Even smoother transitions than cubic, using quartic (t^4) curves.335
336
float easeInQuart(float t) {337
// Starts very slow and accelerates steeply.338
return t * t * t * t;339
}340
341
float easeOutQuart(float t) {342
// Starts steeply and slows down dramatically.343
float f = t - 1.0;344
return 1.0 - f * f * f * f;345
}346
347
float easeInOutQuart(float t) {348
// Combines easeIn and easeOut quartic behavior for very smooth transitions.349
return t < 0.5 ? 8.0 * t * t * t * t350
: 1.0 - 8.0 * (t - 1.0) * (t - 1.0) * (t - 1.0) * (t - 1.0);351
}352
353
// Sine Easing354
// Smooth, wave-like acceleration and deceleration using sine curves.355
356
float easeInSine(float t) {357
// Starts very slow, following a sine wave curve.358
return 1.0 - cos((t * 3.141592653589793) / 2.0);359
}360
361
float easeOutSine(float t) {362
// Starts fast and slows down following a sine wave curve.363
return sin((t * 3.141592653589793) / 2.0);364
}365
366
float easeInOutSine(float t) {367
// Smooth start and end, mimicking half a sine wave.368
return -0.5 * (cos(3.141592653589793 * t) - 1.0);369
}370
371
// Exponential Easing372
// Sharp transitions with rapid acceleration and deceleration.373
374
float easeInExpo(float t) {375
// Very slow start, accelerates exponentially.376
return t == 0.0 ? 0.0 : pow(2.0, 10.0 * (t - 1.0));377
}378
379
float easeOutExpo(float t) {380
// Starts fast and slows down exponentially.381
return t == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * t);382
}383
384
float easeInOutExpo(float t) {385
// Combines easeIn and easeOut exponential for sharp transitions.386
if (t == 0.0) return 0.0;387
if (t == 1.0) return 1.0;388
return t < 0.5 ? 0.5 * pow(2.0, 20.0 * t - 10.0)389
: 1.0 - 0.5 * pow(2.0, -20.0 * t + 10.0);390
}391
392
// Back Easing393
// Creates an overshooting effect for more dynamic animations.394
395
float easeInOutBack(float t) {396
// Uses constants to define the overshooting magnitude.397
const float c1 = 1.70158;398
const float c2 = c1 * 1.525;399
return t < 0.5400
? (pow(2.0 * t, 2.0) * ((c2 + 1.0) * 2.0 * t - c2)) / 2.0401
: (pow(2.0 * t - 2.0, 2.0) * ((c2 + 1.0) * (t * 2.0 - 2.0) + c2) + 2.0) / 2.0;402
}403
404
// --------------------------------------------------------------------- edge mask helpers405
406
// This method returns a mask which smoothly transitions towards zero when approaching407
// the window's borders. If the window is currently maximized or in fullscreen mode, this408
// will return 1.0 everywhere. There is a variant which takes the transition area width in409
// pixels and one which takes this as a percentage.410
float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {411
float mask = 1.0;412
413
if (!uIsFullscreen) {414
mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));415
mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));416
mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));417
mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));418
}419
420
return mask;421
}422
423
// Returns an edge mask which fades to zero at the boundaries of the actor. The width of424
// the fade zone is given in pixels. This uses the standard uniforms uSize and uPadding.425
// This means that the fading zone is not actually at the actors boundaries but at the426
// position of the window border in the texture.427
// The offset parameter controls whether the fading is placed inside the window borders428
// (offset = 0), ontop the window borders (offset = 0.5) or outside the window borders429
// (offset = 1).430
float getAbsoluteEdgeMask(float fadePixels, float offset) {431
float padding = max(0.0, uPadding - fadePixels * offset);432
vec2 uv = iTexCoord.st * uSize - padding;433
return getEdgeMask(uv, uSize - 2.0 * padding, fadePixels);434
}435
436
// Returns an edge mask which fades to zero at the boundaries of the actor. The width of437
// the fade zone is given relative to the actor size. This neither uses uSize and438
// uPadding.439
float getRelativeEdgeMask(float fadeAmount) {440
vec2 uv = iTexCoord.st;441
return getEdgeMask(uv, vec2(1.0), fadeAmount);442
}443
444
// ------------------------------------------------------------------------------- 2D math445
446
// The math for the whirling is inspired by this post:447
// http://www.geeks3d.com/20110428/shader-library-swirl-post-processing-filter-in-glsl448
vec2 whirl(vec2 coords, float warping, float rotation) {449
float angle = pow(1.0 - length(coords), 2.0) * warping + rotation;450
float s = sin(angle);451
float c = cos(angle);452
return vec2(dot(coords, vec2(c, -s)), dot(coords, vec2(s, c)));453
}454
455
// Returns the shortest distance between the given point and the line defined by "origin"456
// and "direction".457
float distToLine(vec2 origin, vec2 direction, vec2 point) {458
vec2 perpendicular = vec2(direction.y, -direction.x);459
return abs(dot(normalize(perpendicular), origin - point));460
}461
462
// Returns a positive number if a -> b forms a clockwise corner, or a negative number if463
// the corner is counter-clockwise.464
float getWinding(vec2 a, vec2 b) { return cross(vec3(a, 0.0), vec3(b, 0.0)).z; }465
466
// Rotates the given 2D vector a clockwise by the angle alpha (given in radians).467
vec2 rotate(vec2 a, float angle) {468
return vec2(a.x * cos(angle) - a.y * sin(angle), a.x * sin(angle) + a.y * cos(angle));469
}470
471
// rotates a given 2d vector, around a given center (angle is in radians)472
vec2 rotate(vec2 a, float angle, vec2 center) {473
return vec2(cos(angle) * (a.x - center.x) + sin(angle) * (a.y - center.y) + center.x,474
cos(angle) * (a.y - center.y) - sin(angle) * (a.x - center.x) + center.y);475
}476
477
// --------------------------------------------------------------------------------- noise478
479
// These noise algorithms are based on implementations by various authors from480
// shadertoy.com, which are all available under the MIT License. See the respective links481
// in the comments below.482
483
// Hash functions484
// MIT License, https://www.shadertoy.com/view/4djSRW485
// Copyright (c) 2014 David Hoskins.486
487
// 1 out, 1 in...488
float hash11(float p) {489
p = fract(p * .1031);490
p *= p + 33.33;491
p *= p + p;492
return fract(p);493
}494
495
// 1 out, 2 in...496
float hash12(vec2 p) {497
vec3 p3 = fract(vec3(p.xyx) * .1031);498
p3 += dot(p3, p3.yzx + 33.33);499
return fract((p3.x + p3.y) * p3.z);500
}501
502
// 1 out, 3 in...503
float hash13(vec3 p3) {504
p3 = fract(p3 * .1031);505
p3 += dot(p3, p3.zyx + 31.32);506
return fract((p3.x + p3.y) * p3.z);507
}508
509
// 2 out, 1 in...510
vec2 hash21(float p) {511
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));512
p3 += dot(p3, p3.yzx + 33.33);513
return fract((p3.xx + p3.yz) * p3.zy);514
}515
516
// 2 out, 2 in...517
vec2 hash22(vec2 p) {518
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));519
p3 += dot(p3, p3.yzx + 33.33);520
return fract((p3.xx + p3.yz) * p3.zy);521
}522
523
// 2 out, 3 in...524
vec2 hash23(vec3 p3) {525
p3 = fract(p3 * vec3(.1031, .1030, .0973));526
p3 += dot(p3, p3.yzx + 33.33);527
return fract((p3.xx + p3.yz) * p3.zy);528
}529
530
// 3 out, 1 in...531
vec3 hash31(float p) {532
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));533
p3 += dot(p3, p3.yzx + 33.33);534
return fract((p3.xxy + p3.yzz) * p3.zyx);535
}536
537
// 3 out, 2 in...538
vec3 hash32(vec2 p) {539
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));540
p3 += dot(p3, p3.yxz + 33.33);541
return fract((p3.xxy + p3.yzz) * p3.zyx);542
}543
544
// 3 out, 3 in...545
vec3 hash33(vec3 p3) {546
p3 = fract(p3 * vec3(.1031, .1030, .0973));547
p3 += dot(p3, p3.yxz + 33.33);548
return fract((p3.xxy + p3.yxx) * p3.zyx);549
}550
551
// 4 out, 1 in...552
vec4 hash41(float p) {553
vec4 p4 = fract(vec4(p) * vec4(.1031, .1030, .0973, .1099));554
p4 += dot(p4, p4.wzxy + 33.33);555
return fract((p4.xxyz + p4.yzzw) * p4.zywx);556
}557
558
// 4 out, 2 in...559
vec4 hash42(vec2 p) {560
vec4 p4 = fract(vec4(p.xyxy) * vec4(.1031, .1030, .0973, .1099));561
p4 += dot(p4, p4.wzxy + 33.33);562
return fract((p4.xxyz + p4.yzzw) * p4.zywx);563
}564
565
// 4 out, 3 in...566
vec4 hash43(vec3 p) {567
vec4 p4 = fract(vec4(p.xyzx) * vec4(.1031, .1030, .0973, .1099));568
p4 += dot(p4, p4.wzxy + 33.33);569
return fract((p4.xxyz + p4.yzzw) * p4.zywx);570
}571
572
// 4 out, 4 in...573
vec4 hash44(vec4 p4) {574
p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));575
p4 += dot(p4, p4.wzxy + 33.33);576
return fract((p4.xxyz + p4.yzzw) * p4.zywx);577
}578
579
// 2D Simplex Noise580
// MIT License, https://www.shadertoy.com/view/Msf3WH581
// Copyright © 2013 Inigo Quilez582
float simplex2D(vec2 p) {583
const float K1 = 0.366025404; // (sqrt(3)-1)/2;584
const float K2 = 0.211324865; // (3-sqrt(3))/6;585
586
vec2 i = floor(p + (p.x + p.y) * K1);587
vec2 a = p - i + (i.x + i.y) * K2;588
float m = step(a.y, a.x);589
vec2 o = vec2(m, 1.0 - m);590
vec2 b = a - o + K2;591
vec2 c = a - 1.0 + 2.0 * K2;592
vec3 h = max(0.5 - vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0);593
vec3 n = h * h * h * h *594
vec3(dot(a, -1.0 + 2.0 * hash22(i + 0.0)), dot(b, -1.0 + 2.0 * hash22(i + o)),595
dot(c, -1.0 + 2.0 * hash22(i + 1.0)));596
return 0.5 + 0.5 * dot(n, vec3(70.0));597
}598
599
float simplex2DFractal(vec2 p) {600
mat2 m = mat2(1.6, 1.2, -1.2, 1.6);601
float f = 0.5000 * simplex2D(p);602
p = m * p;603
f += 0.2500 * simplex2D(p);604
p = m * p;605
f += 0.1250 * simplex2D(p);606
p = m * p;607
f += 0.0625 * simplex2D(p);608
p = m * p;609
610
return f;611
}612
613
// 3D Simplex Noise614
// MIT License, https://www.shadertoy.com/view/XsX3zB615
// Copyright © 2013 Nikita Miropolskiy616
float simplex3D(vec3 p) {617
618
// skew constants for 3D simplex functions619
const float F3 = 0.3333333;620
const float G3 = 0.1666667;621
622
// 1. find current tetrahedron T and it's four vertices623
// s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices624
// x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertice625
626
// calculate s and x627
vec3 s = floor(p + dot(p, vec3(F3)));628
vec3 x = p - s + dot(s, vec3(G3));629
630
// calculate i1 and i2631
vec3 e = step(vec3(0.0), x - x.yzx);632
vec3 i1 = e * (1.0 - e.zxy);633
vec3 i2 = 1.0 - e.zxy * (1.0 - e);634
635
// x1, x2, x3636
vec3 x1 = x - i1 + G3;637
vec3 x2 = x - i2 + 2.0 * G3;638
vec3 x3 = x - 1.0 + 3.0 * G3;639
640
// 2. find four surflets and store them in d641
vec4 w, d;642
643
// calculate surflet weights644
w.x = dot(x, x);645
w.y = dot(x1, x1);646
w.z = dot(x2, x2);647
w.w = dot(x3, x3);648
649
// w fades from 0.6 at the center of the surflet to 0.0 at the margin650
w = max(0.6 - w, 0.0);651
652
// calculate surflet components653
d.x = dot(-0.5 + hash33(s), x);654
d.y = dot(-0.5 + hash33(s + i1), x1);655
d.z = dot(-0.5 + hash33(s + i2), x2);656
d.w = dot(-0.5 + hash33(s + 1.0), x3);657
658
// multiply d by w^4659
w *= w;660
w *= w;661
d *= w;662
663
// 3. return the sum of the four surflets664
return dot(d, vec4(52.0)) * 0.5 + 0.5;665
}666
667
// Directional artifacts can be reduced by rotating each octave668
float simplex3DFractal(vec3 m) {669
670
// const matrices for 3D rotation671
const mat3 rot1 = mat3(-0.37, 0.36, 0.85, -0.14, -0.93, 0.34, 0.92, 0.01, 0.4);672
const mat3 rot2 = mat3(-0.55, -0.39, 0.74, 0.33, -0.91, -0.24, 0.77, 0.12, 0.63);673
const mat3 rot3 = mat3(-0.71, 0.52, -0.47, -0.08, -0.72, -0.68, -0.7, -0.45, 0.56);674
675
return 0.5333333 * simplex3D(m * rot1) + 0.2666667 * simplex3D(2.0 * m * rot2) +676
0.1333333 * simplex3D(4.0 * m * rot3) + 0.0666667 * simplex3D(8.0 * m);677
}678
679
// --------------------------------------------------------------------------------- remap680
681
/*682
These functions remap a given value from one range to another.683
The remap operation is particularly useful in shader programming684
to scale or normalize data, ensuring compatibility across various685
input ranges. Each version of the remap function supports a686
different data type:687
688
1. float: Remap a single scalar value.689
2. vec2: Remap a 2D vector.690
3. vec3: Remap a 3D vector.691
4. vec4: Remap a 4D vector.692
693
The general formula used is:694
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin)695
696
This ensures a linear transformation from the old range to the new range.697
*/698
699
// Remap for float700
// Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].701
// This is useful for normalizing or scaling scalar values to fit within a desired range.702
float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {703
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,704
newMax);705
}706
707
// Remap for vec2708
// Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin,709
// newMax]. Each component of the vec2 is individually scaled and transformed.710
vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {711
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,712
newMax);713
}714
715
// Remap for vec3716
// Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin,717
// newMax]. Each component of the vec3 is individually scaled and transformed.718
vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {719
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,720
newMax);721
}722
723
// Remap for vec4724
// Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin,725
// newMax]. Each component of the vec4 is individually scaled and transformed.726
vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {727
return clamp(newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin), newMin,728
newMax);729
}730
//////////////////////////////////////////////////////////////////////////////////////////731
// ) ( //732
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //733
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //734
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //735
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //736
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //737
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //738
// |__/ //739
//////////////////////////////////////////////////////////////////////////////////////////740
741
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>742
// SPDX-License-Identifier: GPL-3.0-or-later743
744
// The content from common.glsl is automatically prepended to each shader effect.745
746
// Marble [Burn-My-Windows variant] v7: window morphs into a glossy 2D marble.747
// The fall happens in main.js (Translation, constant gravity) after the marble is done.748
uniform float uCrumpleEnd;749
750
void main() {751
float c = clamp(uProgress / uCrumpleEnd, 0.0, 1.0);752
if (uDuration < -1.0) c = 0.0; // keep uDuration alive753
float e = c * c * c * (c * (c * 6.0 - 15.0) + 10.0); // smootherstep754
755
vec2 hs = 0.5 * uSize;756
vec2 p = iTexCoord * uSize - hs;757
float R0 = 0.035 * min(uSize.x, uSize.y); // ~7% diameter758
vec2 b = mix(hs, vec2(R0), e); // half size of the morphing shape759
float rad = mix(0.0, R0, e * e); // corner radius grows to a full circle760
vec2 dq = max(abs(p) - (b - rad), 0.0);761
float d = length(dq) - rad + min(max(abs(p).x - (b - rad).x, abs(p).y - (b - rad).y), 0.0);762
763
// soft drop shadow (bottom-right), drawn where the marble is not764
vec2 ps = p - vec2(0.12, 0.22) * R0 * e;765
float sh = 0.35 * e * (1.0 - smoothstep(-0.2 * R0, 0.25 * R0, length(ps) - R0 * 0.9 * e + (1.0 - e) * 1e5));766
if (d > 0.0) { setOutputColor(vec4(0.0, 0.0, 0.0, sh * step(0.5, e))); return; }767
768
vec2 q = p / b; // -1..1 inside769
float r2 = min(dot(q, q), 1.0);770
float z = sqrt(1.0 - r2 * e); // sphere height (flat at e=0)771
vec2 uv = 0.5 + 0.5 * q * mix(1.0, 0.75 + 0.45 * (1.0 - z), e);772
vec4 col = getInputColor(clamp(uv, 0.0, 1.0));773
col.a = step(0.97, col.a); // ignore the window shadow774
col.a = mix(col.a, 1.0, e); // marble is solid775
col.rgb = clamp(col.rgb, 0.0, 1.0);776
777
// glossy marble shading778
vec3 n = vec3(q * e, z);779
float diff = clamp(dot(n, vec3(-0.45, -0.55, 0.70)), 0.0, 1.0);780
vec2 hv = q - vec2(-0.38, -0.42);781
float hd = dot(hv, hv);782
float spot = (1.0 - smoothstep(0.004, 0.012, hd)); // small sharp highlight783
float glow = 0.35 * (1.0 - smoothstep(0.0, 0.25, hd)); // softer glow784
float fres = 1.0 - z; fres *= fres; // rim light785
float bottom = 1.0 - 0.55 * clamp(q.y * 0.9 + 0.2, 0.0, 1.0) * (1.0 - z * 0.5);786
float lit = mix(1.0, (0.45 + 0.65 * diff) * bottom, e);787
col.rgb = col.rgb * lit + e * (vec3(spot * 0.9 + glow) + fres * vec3(0.25, 0.28, 0.32));788
col.rgb = min(col.rgb, vec3(1.0));789
col.a *= clamp(-d, 0.0, 1.0); // 1px anti-aliased edge790
setOutputColor(col);791
}@@ -0,0 +1,14 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<ui version="4.0">
3
<class>MarbleConfig</class>
4
<widget class="QWidget" name="MarbleConfig">
5
<layout class="QFormLayout" name="formLayout">
6
<item row="0" column="0"><widget class="QLabel" name="l1"><property name="text"><string>Marble morph duration (ms)</string></property></widget></item>
7
<item row="0" column="1"><widget class="QSpinBox" name="kcfg_Duration"><property name="maximum"><number>5000</number></property></widget></item>
8
<item row="2" column="0"><widget class="QLabel" name="l2"><property name="text"><string>Gravity (px/s²)</string></property></widget></item>
9
<item row="2" column="1"><widget class="QSpinBox" name="kcfg_Gravity"><property name="maximum"><number>50000</number></property></widget></item>
10
<item row="1" column="0"><widget class="QLabel" name="l3"><property name="text"><string>Pause before fall (ms)</string></property></widget></item>
11
<item row="1" column="1"><widget class="QSpinBox" name="kcfg_Pause"><property name="maximum"><number>5000</number></property></widget></item>
12
</layout>
13
</widget>
14
</ui>
@@ -0,0 +1,14 @@1
<?xml version="1.0" encoding="UTF-8"?>2
<ui version="4.0">3
<class>MarbleConfig</class>4
<widget class="QWidget" name="MarbleConfig">5
<layout class="QFormLayout" name="formLayout">6
<item row="0" column="0"><widget class="QLabel" name="l1"><property name="text"><string>Marble morph duration (ms)</string></property></widget></item>7
<item row="0" column="1"><widget class="QSpinBox" name="kcfg_Duration"><property name="maximum"><number>5000</number></property></widget></item>8
<item row="2" column="0"><widget class="QLabel" name="l2"><property name="text"><string>Gravity (px/s²)</string></property></widget></item>9
<item row="2" column="1"><widget class="QSpinBox" name="kcfg_Gravity"><property name="maximum"><number>50000</number></property></widget></item>10
<item row="1" column="0"><widget class="QLabel" name="l3"><property name="text"><string>Pause before fall (ms)</string></property></widget></item>11
<item row="1" column="1"><widget class="QSpinBox" name="kcfg_Pause"><property name="maximum"><number>5000</number></property></widget></item>12
</layout>13
</widget>14
</ui>@@ -0,0 +1,30 @@
1
{
2
"KPackageStructure": "KWin/Effect",
3
"KPlugin": {
4
"Name": "Marble Magic Lamp [Burn-My-Windows variant]",
5
"Description": "Minimizing turns the window into a glossy marble that falls to its taskbar entry",
6
"Icon": "preferences-system-windows-effect",
7
"Category": "Appearance",
8
"Authors": [
9
{ "Name": "Simon Schneegans", "Email": "code@simonschneegans.de" },
10
{ "Name": "Martin Flöser", "Email": "mgraesslin@kde.org" },
11
{ "Name": "Vlad Zahorodnii", "Email": "vlad.zahorodnii@kde.org" }
12
],
13
"Id": "kwin6_effect_marble_minimize",
14
"License": "GPLv3",
15
"Version": "1.0",
16
"EnabledByDefault": false,
17
"Website": "https://github.com/Schneegans/Burn-My-Windows/",
18
"BugReportUrl": "https://github.com/Schneegans/Burn-My-Windows/issues",
19
"ServiceTypes": [
20
"KWin/Effect"
21
]
22
},
23
"X-KDE-ConfigModule": "kcm_kwin4_genericscripted",
24
"X-KDE-Ordering": "60",
25
"X-KDE-PluginKeyword": "kwin6_effect_marble_minimize",
26
"X-KWin-Config-TranslationDomain": "burn-my-windows",
27
"X-KWin-Exclusive-Category": "minimize",
28
"X-Plasma-API": "javascript",
29
"X-Plasma-MainScript": "code/main.js"
30
}
@@ -0,0 +1,30 @@1
{2
"KPackageStructure": "KWin/Effect",3
"KPlugin": {4
"Name": "Marble Magic Lamp [Burn-My-Windows variant]",5
"Description": "Minimizing turns the window into a glossy marble that falls to its taskbar entry",6
"Icon": "preferences-system-windows-effect",7
"Category": "Appearance",8
"Authors": [ 9
{ "Name": "Simon Schneegans", "Email": "code@simonschneegans.de" },10
{ "Name": "Martin Flöser", "Email": "mgraesslin@kde.org" },11
{ "Name": "Vlad Zahorodnii", "Email": "vlad.zahorodnii@kde.org" }12
],13
"Id": "kwin6_effect_marble_minimize",14
"License": "GPLv3",15
"Version": "1.0",16
"EnabledByDefault": false,17
"Website": "https://github.com/Schneegans/Burn-My-Windows/",18
"BugReportUrl": "https://github.com/Schneegans/Burn-My-Windows/issues",19
"ServiceTypes": [20
"KWin/Effect"21
]22
},23
"X-KDE-ConfigModule": "kcm_kwin4_genericscripted",24
"X-KDE-Ordering": "60",25
"X-KDE-PluginKeyword": "kwin6_effect_marble_minimize",26
"X-KWin-Config-TranslationDomain": "burn-my-windows",27
"X-KWin-Exclusive-Category": "minimize",28
"X-Plasma-API": "javascript",29
"X-Plasma-MainScript": "code/main.js"30
}