diff --git a/extension.js b/extension.js index 6a8ebc7..4f707a0 100644 --- a/extension.js +++ b/extension.js @@ -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. diff --git a/resources/shaders/doom.frag b/resources/shaders/doom.frag index 804da44..4672c94 100644 --- a/resources/shaders/doom.frag +++ b/resources/shaders/doom.frag @@ -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); diff --git a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml index 4147b5a..0a4a25e 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml @@ -100,7 +100,7 @@ - 1500 + 1000 Doom Animation Time The time the Doom effect takes. diff --git a/src/Doom.js b/src/Doom.js index ee20212..e5d0855 100644 --- a/src/Doom.js +++ b/src/Doom.js @@ -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}; }