🔧 Make doom effect work for opening windows
This commit is contained in:
+1
-1
@@ -434,7 +434,7 @@ class Extension {
|
|||||||
// windows are faded in / out scaled up / down slightly by GNOME Shell. Here, we tweak
|
// 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
|
// the transitions so that nothing changes. The window stays opaque and is scaled to
|
||||||
// actorScale.
|
// 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
|
// To make things deterministic during testing, we set the effect duration to 5
|
||||||
// seconds.
|
// seconds.
|
||||||
|
|||||||
@@ -19,8 +19,10 @@ uniform float uVerticalScale;
|
|||||||
uniform float uPixelSize;
|
uniform float uPixelSize;
|
||||||
|
|
||||||
void main() {
|
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 pixelGrid = vec2(pixelSize) / uSize;
|
||||||
|
|
||||||
vec2 texcoord = iTexCoord.st;
|
vec2 texcoord = iTexCoord.st;
|
||||||
@@ -29,12 +31,19 @@ void main() {
|
|||||||
texcoord += pixelGrid * 0.5;
|
texcoord += pixelGrid * 0.5;
|
||||||
|
|
||||||
float hScale = uHorizontalScale * uSize.x * 0.001;
|
float hScale = uHorizontalScale * uSize.x * 0.001;
|
||||||
float vScale = uVerticalScale * uSize.y * 0.0001;
|
float vScale = uVerticalScale * uSize.y * 0.00002 * uActorScale;
|
||||||
float shift = max(simplex2DFractal(texcoord.xx * hScale) * vScale +
|
|
||||||
(1.0 + vScale * 0.8) * uProgress - 0.8 * vScale,
|
|
||||||
0.0);
|
|
||||||
|
|
||||||
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);
|
vec4 oColor = getInputColor(texcoord);
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="doom-animation-time" type="i">
|
<key name="doom-animation-time" type="i">
|
||||||
<default>1500</default>
|
<default>1000</default>
|
||||||
<summary>Doom Animation Time</summary>
|
<summary>Doom Animation Time</summary>
|
||||||
<description>The time the Doom effect takes.</description>
|
<description>The time the Doom effect takes.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|||||||
+6
-1
@@ -46,7 +46,10 @@ var Doom = class {
|
|||||||
|
|
||||||
// Write all uniform values at the start of each animation.
|
// Write all uniform values at the start of each animation.
|
||||||
shader.connect('begin-animation', (shader, settings, forOpening, actor) => {
|
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);
|
let actorScale = 2.0 * Math.max(1.0, global.stage.height / actor.height);
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
shader.set_uniform_float(shader._uActorScale, 1, [actorScale]);
|
shader.set_uniform_float(shader._uActorScale, 1, [actorScale]);
|
||||||
shader.set_uniform_float(shader._uHorizontalScale, 1, [settings.get_double('doom-horizontal-scale')]);
|
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
|
// 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
|
// animation. This is useful if the effect requires drawing something beyond the usual
|
||||||
// bounds of the actor. This only works for GNOME 3.38+.
|
// 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);
|
let actorScale = 2.0 * Math.max(1.0, global.stage.height / actor.height);
|
||||||
return {x: 1.0, y: actorScale};
|
return {x: 1.0, y: actorScale};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user