diff --git a/resources/shaders/portal.frag b/resources/shaders/portal.frag index 92c12e1..d0bdf18 100644 --- a/resources/shaders/portal.frag +++ b/resources/shaders/portal.frag @@ -14,28 +14,30 @@ // The content from common.glsl is automatically prepended to each shader effect. -uniform vec3 uColor; uniform vec2 uSeed; +uniform vec3 uColor; +uniform float uRotationSpeed; +uniform float uWhirl; +uniform float uDetails; -const float PORTAL_OPEN_TIME = 0.3; const float PORTAL_WOBBLE_TIME = 0.8; const float PORTAL_WOBBLE_STRENGTH = 1.2; -const float PORTAL_CLOSE_TIME = 0.3; -const float PORTAL_ROTATION_SPEED = 0.3; -const float PORTAL_WARPING = 3.0; const float GLOW_EDGE_WIDTH = 5.0; -const float WINDOW_ANIMATION_TIME = 0.3; -const float WINDOW_SCALE = 0.3; -const float WINDOW_SQUISH = 1.0; -const float WINDOW_TILT = -1.0; +const float WINDOW_SCALE = 0.3; +const float WINDOW_SQUISH = 1.0; +const float WINDOW_TILT = -1.0; + +float PORTAL_OPEN_TIME = 0.3 * 1.5 / uDuration; +float PORTAL_CLOSE_TIME = 0.3 * 1.5 / uDuration; +float WINDOW_OPEN_TIME = 0.3 * 1.5 / uDuration; // This will distort the given coordinate to achieve the wobble effect of the portal when // the window passes through. The wobble happens around the point where the window appears -// or disappears (which is controlled by WINDOW_ANIMATION_TIME) and takes +// or disappears (which is controlled by WINDOW_OPEN_TIME) and takes // PORTAL_WOBBLE_TIME. vec2 getPortalWobble(vec2 coords) { - float progress = (uForOpening ? (1.0 - uProgress) : uProgress) / WINDOW_ANIMATION_TIME; + float progress = (uForOpening ? (1.0 - uProgress) : uProgress) / WINDOW_OPEN_TIME; progress = clamp(1.0 - abs((progress - 1.0) / PORTAL_WOBBLE_TIME), 0.0, 1.0); progress = easeInBack(progress, 1.7); float dist = length(coords); @@ -70,8 +72,8 @@ vec2 getRandomDisplace(vec2 seed, float scale) { // twisting (higher multipliers will make coordinates which are closer to the origin be // rotated more than coordinates farther away). vec2 getWhirledCoords(vec2 coords, float speedMultiplier, float warpMultiplier) { - float rotation = PORTAL_ROTATION_SPEED * uProgress * uDuration * speedMultiplier; - float warping = PORTAL_WARPING * (2.0 + 0.5 * uProgress) * warpMultiplier; + float rotation = uRotationSpeed * uProgress * uDuration * speedMultiplier; + float warping = uWhirl * (6.0 + 1.5 * uProgress) * warpMultiplier; return whirl(coords, warping, rotation); } @@ -101,13 +103,13 @@ vec4 getPortalColor() { // This is used below to scale the detail level of the layers. If the portal is small, // we want to have less details, if the portal is huge on the screen, theres plenty of // space for details. - float detailScale = 1000.0 / (uSize.x + uSize.y); + float detailScale = 10000.0 / (uSize.x + uSize.y) / uDetails; // ---------------------------------------------------------------------------- 1. layer // We start with the background layer. This is a radial gradient from a dark color in // the center to a not-so-dark color in the outer regions. We distort the coordinates to // add some variations to the colors and to the shape of the portal. - vec2 layerCoords = getWhirledCoords(coords - wobble * 1.0, 0.5, 1.0); + vec2 layerCoords = getWhirledCoords(coords - wobble * 1.0, 0.25, 1.0); vec2 displace = getRandomDisplace(layerCoords, 2.1); layerCoords += displace * 0.1; float dist = length(layerCoords); @@ -124,7 +126,7 @@ vec4 getPortalColor() { // ---------------------------------------------------------------------------- 3. layer // The second layer of whirly bands uses a lighter color and a different set of // distorted coordinates. - layerCoords = getWhirledCoords(coords - wobble * 1.5, 1.5, 0.5); + layerCoords = getWhirledCoords(coords - wobble * 1.5, 0.75, 0.5); displace = getRandomDisplace(layerCoords, 12.2); layerCoords += displace * 0.1; noise = simplex2D(layerCoords / detailScale * 1.3 + uSeed); @@ -145,9 +147,9 @@ vec4 getPortalColor() { // ---------------------------------------------------------------------------- 5. layer // Finally, we add some sparkling lights. - layerCoords = getWhirledCoords(coords - wobble * 1.8, 2.5, 0.0); + layerCoords = getWhirledCoords(coords - wobble * 1.8, 1.25, 0.0); noise = simplex2D(layerCoords / detailScale * 3.0 + uSeed); - layer.rgb = lighten(uColor, 0.5) * clamp(pow(noise * rand + 0.9, 50.0), 0.0, 1.0); + layer.rgb = lighten(uColor, 0.8) * clamp(pow(noise * rand + 0.9, 50.0), 0.0, 1.0); color.rgb += layer.rgb; // Finally, fade in / out the portal when it appears / disappears. @@ -160,9 +162,9 @@ vec4 getPortalColor() { // animation will happen in a fraction of the full animation time (at the end of the // animation when opening a window and at the beginning of the animation when closing the // window). The fraction of the animation time take for the window animation is defined by -// WINDOW_ANIMATION_TIME. +// WINDOW_OPEN_TIME. vec4 getWindowColor() { - float progress = (uForOpening ? (1.0 - uProgress) : uProgress) / WINDOW_ANIMATION_TIME; + float progress = (uForOpening ? (1.0 - uProgress) : uProgress) / WINDOW_OPEN_TIME; // Add some elastic easing to make the effect more dynamic. progress = easeInBack(clamp(progress, 0.0, 1.0), 1.2); diff --git a/resources/ui/adw/Portal.ui b/resources/ui/adw/Portal.ui index 3b5ee15..bd80cd2 100644 --- a/resources/ui/adw/Portal.ui +++ b/resources/ui/adw/Portal.ui @@ -22,7 +22,7 @@ SPDX-License-Identifier: GPL-3.0-or-later 5000 - 100 + 1000 1 100 @@ -42,6 +42,105 @@ SPDX-License-Identifier: GPL-3.0-or-later + + + Rotation Speed + + + center + 1 + 2 + left + 300 + + + 2 + -2 + 0.1 + 1 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Whirl + + + center + 1 + 2 + left + 300 + + + 2 + -2 + 0.1 + 1 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Details + + + center + 1 + 1 + left + 300 + + + 100 + 1 + 1 + 10 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + Color diff --git a/resources/ui/gtk3/Portal.ui b/resources/ui/gtk3/Portal.ui index 3df8685..af666e3 100644 --- a/resources/ui/gtk3/Portal.ui +++ b/resources/ui/gtk3/Portal.ui @@ -9,11 +9,32 @@ SPDX-License-Identifier: GPL-3.0-or-later 5000 - 100 + 1000 1 100 + + 2 + -2 + 0.1 + 1 + + + + 2 + -2 + 0.1 + 1 + + + + 100 + 1 + 1 + 10 + + vertical @@ -78,6 +99,162 @@ SPDX-License-Identifier: GPL-3.0-or-later + + + 10 + 10 + 10 + 10 + 0 + + + 8 + + + Rotation Speed + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + + portal-rotation-speed + + + + + + + + edit-clear-symbolic + 1 + + + Reset to Default Value + + + + + + + + + + + 10 + 10 + 10 + 10 + 0 + + + 8 + + + Whirl + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + + portal-whirl + + + + + + + + edit-clear-symbolic + 1 + + + Reset to Default Value + + + + + + + + + + + 10 + 10 + 10 + 10 + 0 + + + 8 + + + Details + 0 + start + center + 1 + + + + + end + center + 1 + 1 + left + 300 + + portal-details + + + + + + + + edit-clear-symbolic + 1 + + + Reset to Default Value + + + + + + + + 10 diff --git a/resources/ui/gtk4/Portal.ui b/resources/ui/gtk4/Portal.ui index d5d5e0f..f5a5237 100644 --- a/resources/ui/gtk4/Portal.ui +++ b/resources/ui/gtk4/Portal.ui @@ -46,7 +46,7 @@ SPDX-License-Identifier: GPL-3.0-or-later 5000 - 100 + 1000 1 100 @@ -68,6 +68,150 @@ SPDX-License-Identifier: GPL-3.0-or-later + + + 0 + + + + + Whirl + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + + + 2 + -2 + 0.1 + 1 + + + + + + + edit-clear-symbolic + Reset to Default Value + + + + + + + + + + + 0 + + + + + Rotation Speed + 0 + start + center + 1 + + + + + end + center + 1 + 2 + left + 300 + + + 2 + -2 + 0.1 + 1 + + + + + + + edit-clear-symbolic + Reset to Default Value + + + + + + + + + + + 0 + + + + + Details + 0 + start + center + 1 + + + + + end + center + 1 + 1 + left + 300 + + + 100 + 1 + 1 + 10 + + + + + + + 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 eaec967..8e2fa45 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml @@ -740,11 +740,29 @@ SPDX-License-Identifier: CC0-1.0 - "rgb(155, 255, 50)" + "rgb(121, 233, 24)" Portal Color The color of the effect. + + 0.3 + Portal Rotation Speed + The angular speed of the portal. + + + + 1.0 + Portal Whirl + The amount of distortion. + + + + 15.0 + Portal Details + The amount of details in the portal. + + diff --git a/src/Portal.js b/src/Portal.js index feca74c..dea66e7 100644 --- a/src/Portal.js +++ b/src/Portal.js @@ -43,8 +43,11 @@ var Portal = class { const Clutter = imports.gi.Clutter; // Store uniform locations of newly created shaders. - shader._uColor = shader.get_uniform_location('uColor'); shader._uSeed = shader.get_uniform_location('uSeed'); + shader._uColor = shader.get_uniform_location('uColor'); + shader._uDetails = shader.get_uniform_location('uDetails'); + shader._uRotationSpeed = shader.get_uniform_location('uRotationSpeed'); + shader._uWhirl = shader.get_uniform_location('uWhirl'); // Write all uniform values at the start of each animation. shader.connect('begin-animation', (shader, settings) => { @@ -54,8 +57,11 @@ var Portal = class { const testMode = settings.get_boolean('test-mode'); // clang-format off - shader.set_uniform_float(shader._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]); shader.set_uniform_float(shader._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]); + shader.set_uniform_float(shader._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]); + shader.set_uniform_float(shader._uDetails, 1, [settings.get_double('portal-details')]); + shader.set_uniform_float(shader._uRotationSpeed, 1, [settings.get_double('portal-rotation-speed')]); + shader.set_uniform_float(shader._uWhirl, 1, [settings.get_double('portal-whirl')]); // clang-format on }); }); @@ -94,6 +100,9 @@ var Portal = class { // Bind all properties. dialog.bindAdjustment('portal-animation-time'); + dialog.bindAdjustment('portal-rotation-speed'); + dialog.bindAdjustment('portal-whirl'); + dialog.bindAdjustment('portal-details'); dialog.bindColorButton('portal-color'); // Finally, return the new settings page.