diff --git a/docs/changelog.md b/docs/changelog.md index e60279d..a8bd78d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -12,6 +12,7 @@ #### Other Enhancements * Added a menu entry with a link to the guide for creating new effect types. +* Added a new option to the Matrix Effect: **Vertical Overshooting**: This can add some vertical variation to the start and end position of the letter drops. ## [Burn My Window 9](https://github.com/schneegans/Burn-My-Windows/releases/tag/v9) diff --git a/resources/ui/gtk4/Matrix.ui b/resources/ui/gtk4/Matrix.ui index c6c7720..d15e81a 100644 --- a/resources/ui/gtk4/Matrix.ui +++ b/resources/ui/gtk4/Matrix.ui @@ -152,6 +152,52 @@ + + + 0 + + + + + Vertical Overshooting + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + + + 1.0 + 0.0 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + Reset to Default Value + + + + + + + + 0 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 ee796fc..73845d9 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml @@ -123,6 +123,12 @@ The color matrix trails. + + 0.25 + Matrix Overshoot + The vertical overshooting of the matrix effect. + + diff --git a/src/Matrix.js b/src/Matrix.js index df2bd46..678d5ce 100644 --- a/src/Matrix.js +++ b/src/Matrix.js @@ -70,6 +70,7 @@ var Matrix = class Matrix { dialog.bindAdjustment('matrix-animation-time'); dialog.bindAdjustment('matrix-scale'); dialog.bindAdjustment('matrix-randomness'); + dialog.bindAdjustment('matrix-overshoot'); dialog.bindColorButton('matrix-trail-color'); dialog.bindColorButton('matrix-tip-color'); @@ -88,7 +89,12 @@ var Matrix = class Matrix { // the actor - usually windows are faded to transparency and scaled down slightly by // GNOME Shell. For this effect, windows should neither be scaled nor faded. static getCloseTransition(actor, settings) { - return {'opacity': {to: 255}, 'scale-x': {to: 1.0}, 'scale-y': {to: 1.0}}; + const yScale = 1.0 + settings.get_double('matrix-overshoot'); + return { + 'opacity': {to: 255}, + 'scale-x': {to: 1.0}, + 'scale-y': {from: yScale, to: yScale} + }; } } @@ -143,6 +149,7 @@ if (utils.isInShellProcess()) { const float LETTER_SIZE = ${settings.get_int('matrix-scale')}; const float LETTER_FLICKER_SPEED = 2.0; const float RANDOMNESS = ${settings.get_double('matrix-randomness')}; + const float OVERSHOOT = ${settings.get_double('matrix-overshoot')}; // This returns a flickering grid of random letters. float getText(vec2 fragCoord) { @@ -161,37 +168,45 @@ if (utils.isInShellProcess()) { // to one below each drop and to zero above it. This second value is used for fading // the window texture. vec2 getRain(vec2 fragCoord) { - vec2 coords = fragCoord * vec2(uSizeX, uSizeY); - coords.x -= mod(coords.x, LETTER_SIZE); - - float delay = fract(sin(coords.x)*78.233) * mix(0.0, 1.0, RANDOMNESS); - float speed = fract(cos(coords.x)*12.989) * mix(0.0, 0.3, RANDOMNESS) + 1.5; - - float distToDrop = (uProgress*2-delay)*speed - fragCoord.y; + float column = cogl_tex_coord_in[0].x * uSizeX; + column -= mod(column, LETTER_SIZE); + float delay = fract(sin(column)*78.233) * mix(0.0, 1.0, RANDOMNESS); + float speed = fract(cos(column)*12.989) * mix(0.0, 0.3, RANDOMNESS) + 1.5; + + float distToDrop = (uProgress*2-delay)*speed - cogl_tex_coord_in[0].y; + float rainAlpha = distToDrop >= 0 ? exp(-distToDrop/TRAIL_LENGTH) : 0; float windowAlpha = 1 - clamp(uSizeY*distToDrop, 0, FADE_WIDTH) / FADE_WIDTH; + + // Fade at window borders. + rainAlpha *= getAbsoluteEdgeMask(EDGE_FADE); + + // Add some variation to the drop start and end position. + float shorten = fract(sin(column+42.0)*33.423) * mix(0.0, OVERSHOOT*0.25, RANDOMNESS); + rainAlpha *= smoothstep(0, 1, clamp(cogl_tex_coord_in[0].y / shorten, 0, 1)); + rainAlpha *= smoothstep(0, 1, clamp((1.0 - cogl_tex_coord_in[0].y) / shorten, 0, 1)); return vec2(rainAlpha, windowAlpha); } void main() { + vec2 coords = cogl_tex_coord_in[0].st; + coords.y = coords.y * (OVERSHOOT + 1.0) - OVERSHOOT * 0.5; + // Get a cool matrix effect. See comments for those methods above. - vec2 rain = getRain(cogl_tex_coord_in[0].st); - float text = getText(cogl_tex_coord_in[0].st); + vec2 rain = getRain(coords); + float text = getText(coords); // Get the window texture and fade it according to the effect mask. - cogl_color_out = texture2D(uTexture, cogl_tex_coord_in[0].st) * rain.y; + cogl_color_out = texture2D(uTexture, coords) * rain.y; // This is used to fade out the remaining trails in the end. float finalFade = 1-clamp((uProgress-FINAL_FADE_START_TIME)/ (1-FINAL_FADE_START_TIME), 0, 1); float rainAlpha = finalFade * rain.x; - // Fade at window borders. - rainAlpha *= getAbsoluteEdgeMask(EDGE_FADE); - // Add the matrix effect to the window. vec3 trailColor = vec3(${trailColor.red / 255}, ${trailColor.green / 255},