🔧 Make doom effect work for opening windows

This commit is contained in:
Simon Schneegans
2022-08-27 20:52:57 +02:00
parent 9a63fdeb9d
commit cc6750a595
4 changed files with 23 additions and 9 deletions
+1 -1
View File
@@ -434,7 +434,7 @@ class Extension {
// windows are faded in / out scaled up / down slightly by GNOME Shell. Here, we tweak
// the transitions so that nothing changes. The window stays opaque and is scaled to
// actorScale.
const actorScale = effect.getActorScale(this._settings, actor);
const actorScale = effect.getActorScale(this._settings, forOpening, actor);
// To make things deterministic during testing, we set the effect duration to 5
// seconds.
+15 -6
View File
@@ -19,8 +19,10 @@ uniform float uVerticalScale;
uniform float uPixelSize;
void main() {
// We simply inverse the progress for opening windows.
float pixelateProgress = uForOpening ? 0.9 - uProgress : uProgress;
float pixelSize = ceil(uPixelSize * uProgress + 1.0);
float pixelSize = max(1.0, ceil(uPixelSize * pixelateProgress + 1.0));
vec2 pixelGrid = vec2(pixelSize) / uSize;
vec2 texcoord = iTexCoord.st;
@@ -29,12 +31,19 @@ void main() {
texcoord += pixelGrid * 0.5;
float hScale = uHorizontalScale * uSize.x * 0.001;
float vScale = uVerticalScale * uSize.y * 0.0001;
float shift = max(simplex2DFractal(texcoord.xx * hScale) * vScale +
(1.0 + vScale * 0.8) * uProgress - 0.8 * vScale,
0.0);
float vScale = uVerticalScale * uSize.y * 0.00002 * uActorScale;
texcoord.y -= uActorScale * shift;
float noise = simplex2DFractal(texcoord.xx * hScale) * 2.0 - 0.5;
float shiftProgress = uForOpening ? mix(-vScale - 1.0, 0.0, uProgress)
: mix(-vScale, 1.0 + vScale, uProgress);
float shift = noise * vScale + shiftProgress;
if (uForOpening) {
texcoord.y -= 0.5 * uActorScale * min(shift, 0.0);
} else {
texcoord.y -= 0.5 * uActorScale * max(shift, 0.0);
}
vec4 oColor = getInputColor(texcoord);
@@ -100,7 +100,7 @@
</key>
<key name="doom-animation-time" type="i">
<default>1500</default>
<default>1000</default>
<summary>Doom Animation Time</summary>
<description>The time the Doom effect takes.</description>
</key>
+6 -1
View File
@@ -46,7 +46,10 @@ var Doom = class {
// Write all uniform values at the start of each animation.
shader.connect('begin-animation', (shader, settings, forOpening, actor) => {
// For this effect, we scale the actor vertically so that it covers the entire
// screen. This ensures that the melted window will not be cut off.
let actorScale = 2.0 * Math.max(1.0, global.stage.height / actor.height);
// clang-format off
shader.set_uniform_float(shader._uActorScale, 1, [actorScale]);
shader.set_uniform_float(shader._uHorizontalScale, 1, [settings.get_double('doom-horizontal-scale')]);
@@ -103,7 +106,9 @@ var Doom = class {
// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
getActorScale(settings, actor) {
// For this effect, we scale the actor vertically so that it covers the entire screen.
// This ensures that the melted window will not be cut off.
getActorScale(settings, forOpening, actor) {
let actorScale = 2.0 * Math.max(1.0, global.stage.height / actor.height);
return {x: 1.0, y: actorScale};
}