diff --git a/extension.js b/extension.js index 06776d9..479e4d5 100644 --- a/extension.js +++ b/extension.js @@ -49,6 +49,7 @@ import TVGlitch from './src/effects/TVGlitch.js'; import Wisps from './src/effects/Wisps.js'; import Mushroom from './src/effects/Mushroom.js'; +import SimpleFade from './src/effects/SimpleFade.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; @@ -82,7 +83,7 @@ export default class BurnMyWindows extends Extension { new Matrix(), new PaintBrush(), new Pixelate(), new PixelWheel(), new PixelWipe(), new Portal(), new RGBWarp(), new SnapOfDisintegration(), new TeamRocket(), new TRexAttack(), new TVEffect(), new TVGlitch(), - new Wisps(), new Mushroom(), + new Wisps(), new Mushroom(), new SimpleFade(), ]; diff --git a/prefs.js b/prefs.js index af81f62..6e14c8c 100644 --- a/prefs.js +++ b/prefs.js @@ -50,7 +50,7 @@ import TVEffect from './src/effects/TVEffect.js'; import TVGlitch from './src/effects/TVGlitch.js'; import Wisps from './src/effects/Wisps.js'; - +import SimpleFade from './src/effects/SimpleFade.js'; import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; @@ -84,7 +84,7 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences { Pixelate, PixelWheel, PixelWipe, Portal, RGBWarp, SnapOfDisintegration, TeamRocket, TRexAttack, TVEffect, - TVGlitch, Wisps, + TVGlitch, Wisps, SimpleFade, ]; diff --git a/resources/shaders/simple-fade.frag b/resources/shaders/simple-fade.frag new file mode 100644 index 0000000..39d09db --- /dev/null +++ b/resources/shaders/simple-fade.frag @@ -0,0 +1,116 @@ +////////////////////////////////////////////////////////////////////////////////////////// +// ) ( // +// ( /( ( ( ) ( ( ( ( )\ ) ( ( // +// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( // +// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ // +// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) // +// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< // +// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ // +// |__/ // +////////////////////////////////////////////////////////////////////////////////////////// + +// SPDX-FileCopyrightText: Justin Garza JGarza9788@gmail.com +// SPDX-License-Identifier: GPL-3.0-or-later + +// The content from common.glsl is automatically prepended to each shader effect. This +// provides the standard input: + +// vec2 iTexCoord: Texture coordinates for retrieving the window input color. +// bool uIsFullscreen: True if the window is maximized or in fullscreen mode. +// bool uForOpening: True if a window-open animation is ongoing, false otherwise. +// float uProgress: A value which transitions from 0 to 1 during the animation. +// float uDuration: The duration of the current animation in seconds. +// vec2 uSize: The size of uTexture in pixels. +// float uPadding: The empty area around the actual window (e.g. where the shadow +// is drawn). For now, this will only be set on GNOME. + +// Furthermore, there are two global methods for reading the window input color and +// setting the shader output color. Both methods assume straight alpha: + +// vec4 getInputColor(vec2 coords) +// void setOutputColor(vec4 outColor) + +// The width of the fading effect is loaded from the settings. +// uniform float uFadeWidth; + +float uBlurQuality = 5.0; +vec4 uSeed = vec4(0.4,0.2,0.4,0.6); + +// A simple blur function +vec4 blur(vec2 uv, float radius, float samples) { + // Initialize the color accumulator to zero. + vec4 color = vec4(0.0); + + // Define a constant for 2 * PI (tau), which represents a full circle in radians. + const float tau = 6.28318530718; + + // Number of directions for sampling around the circle. + const float directions = 15.0; + + // Outer loop iterates over multiple directions evenly spaced around a circle. + for (float d = 0.0; d < tau; d += tau / directions) { + // Inner loop samples along each direction, with decreasing intensity. + for (float s = 0.0; s < 1.0; s += 1.0 / samples) { + // Calculate the offset for this sample based on direction, radius, and step. + // The (1.0 - s) term ensures more sampling occurs closer to the center. + vec2 offset = vec2(cos(d), sin(d)) * radius * (1.0 - s) / uSize; + + // Add the sampled color at the offset position to the accumulator. + color += getInputColor(uv + offset); + } + } + + // Normalize the accumulated color by dividing by the total number of samples + // and directions to ensure the result is averaged. + return color / samples / directions; +} + + + +void main() { + // Calculate the progression value based on the animation direction. + // If opening, use uProgress as-is; if closing, invert the progression. + float progress = uForOpening ? 1.0 - uProgress : uProgress ; + + //r is for random .. 4 random numbers between -1.0 and 1.0 + vec4 r = hash42(iTexCoord.st * progress * 0.1) * 2.0 - vec4(0.5); + + //zero to one... mostly one + float ztomo = remap( + progress, + 0.0,0.1, + 0.0,1.0 + ); + ztomo = easeInOutSine(ztomo); + + + //out Expo + float oExpo = easeOutExpo(progress); + float iExpo = easeInExpo(progress); + float ioSine = easeInOutSine(progress); + float ioSine_r = 1.0 - ioSine; + + vec2 uv = iTexCoord.st; + + // change the center + uv = uv * 2.0 - 1.0; + + //scale + uv /= ioSine_r; + + //re-center + uv = uv * 0.5 + 0.5; + + // uv.x -= simplex3D(r.xyz * 50.0) * 0.1; + // uv.y -= simplex3D(r.xyz * 50.0) * 0.1; + + // uv.x -= sin(progress) + +//get color + vec4 oColor = blur(uv, ztomo * 100.0,uBlurQuality); + oColor.a *= ioSine_r; + + + + setOutputColor(oColor); +} \ No newline at end of file diff --git a/resources/shaders/team-rocket.frag b/resources/shaders/team-rocket.frag index cc6dd02..e21a1f1 100644 --- a/resources/shaders/team-rocket.frag +++ b/resources/shaders/team-rocket.frag @@ -123,8 +123,6 @@ void main() { // scale progress ... the first half of the animation float scalep = remap( progress, - //0.0,clamp(uWT + 0.1,0.0,1.0), - // 0.0,0.6, 0.0,uWT+0.1, 0.0,1.0 ); @@ -135,8 +133,6 @@ void main() { // sparkle progress ... the second half of the animation float sparkp = remap( progress, - // clamp((1.0 - uWT) - 0.1,0.0,1.0),1.0, - // 0.4,1.0, uWT-0.1,1.0, 0.0,1.0 ); diff --git a/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml b/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml index 8a2e27d..cf39324 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml @@ -1126,6 +1126,29 @@ SPDX-License-Identifier: CC0-1.0 Sparkle Size + + + + + + + false + Simple Fade Enable Effect + Use the Simple Fade effect. + + + + 3000 + Simple Fade Animation Time + The time the Simple Fade effect takes. + + + + 0.1 + Simple Fade Width + Width of the fading effect. + + diff --git a/src/effects/AuraGlow.js b/src/effects/AuraGlow.js index 4383735..a6028ba 100644 --- a/src/effects/AuraGlow.js +++ b/src/effects/AuraGlow.js @@ -173,7 +173,7 @@ export default class Effect { */ // if we use a switch instead of a checkbox - + const switchWidget = dialog.getBuilder().get_object('aura-glow-random-color'); if (switchWidget) { // Connect to the "state-set" signal to update preferences dynamically based on @@ -191,7 +191,7 @@ export default class Effect { // Log an error if the switch widget is not found in the UI. log('Error: \'aura-glow-random-color\' switch widget not found.'); } - + // Retrieve the necessary objects const colorOffset = dialog.getBuilder().get_object('aura-glow-color-offset-scale'); diff --git a/src/effects/SimpleFade.js b/src/effects/SimpleFade.js new file mode 100644 index 0000000..ad50b01 --- /dev/null +++ b/src/effects/SimpleFade.js @@ -0,0 +1,93 @@ +////////////////////////////////////////////////////////////////////////////////////////// +// ) ( // +// ( /( ( ( ) ( ( ( ( )\ ) ( ( // +// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( // +// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ // +// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) // +// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< // +// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ // +// |__/ // +////////////////////////////////////////////////////////////////////////////////////////// + +// SPDX-FileCopyrightText: Justin Garza JGarza9788@gmail.com +// SPDX-License-Identifier: GPL-3.0-or-later + +'use strict'; + +import * as utils from '../utils.js'; + +// We import the ShaderFactory only in the Shell process as it is not required in the +// preferences process. The preferences process does not create any shader instances, it +// only uses the static metadata of the effect. +const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js'); + +const _ = await utils.importGettext(); + +////////////////////////////////////////////////////////////////////////////////////////// +// This effect ... // +// <- Please add a description of your effect here -> // +////////////////////////////////////////////////////////////////////////////////////////// + +// The effect class can be used to get some metadata (like the effect's name or supported +// GNOME Shell versions), to initialize the respective page of the settings dialog, as +// well as to create the actual shader for the effect. +export default class Effect { + // The constructor creates a ShaderFactory which will be used by extension.js to create + // shader instances for this effect. The shaders will be automagically created using the + // GLSL file in resources/shaders/.glsl. The callback will be called for each + // newly created shader instance. + constructor() { + this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => { + // Store uniform locations of newly created shaders. + // shader._uFadeWidth = shader.get_uniform_location('uFadeWidth'); + + // Write all uniform values at the start of each animation. + shader.connect('begin-animation', (shader, settings) => { + + // shader.set_uniform_float(shader._uFadeWidth, 1, [ + // settings.get_double('simple-fade-width'), + // ]); + + }); + }); + } + + // ---------------------------------------------------------------------------- metadata + + // The effect is available on all GNOME Shell versions supported by this extension. + static getMinShellVersion() { + return [3, 36]; + } + + // This will be called in various places where a unique identifier for this effect is + // required. It should match the prefix of the settings keys which store whether the + // effect is enabled currently (e.g. '*-enable-effect'), and its animation time + // (e.g. '*-animation-time'). Also, the shader file and the settings UI files should be + // named likes this. + static getNick() { + return 'simple-fade'; + } + + // This will be shown in the sidebar of the preferences dialog as well as in the + // drop-down menus where the user can choose the effect. + static getLabel() { + return _('Simple Fade Effect'); + } + + // -------------------------------------------------------------------- API for prefs.js + + // This is called by the preferences dialog whenever a new effect profile is loaded. It + // binds all user interface elements to the respective settings keys of the profile. + static bindPreferences(dialog) { + // Empty for now... Code is added here later in the tutorial! + } + + // ---------------------------------------------------------------- API for extension.js + + // 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+. + static getActorScale(settings, forOpening, actor) { + return {x: 1.0, y: 1.0}; + } +} \ No newline at end of file diff --git a/src/effects/TeamRocket.js b/src/effects/TeamRocket.js index ba7d9cc..c1ecd4b 100644 --- a/src/effects/TeamRocket.js +++ b/src/effects/TeamRocket.js @@ -39,14 +39,14 @@ export default class Effect { constructor() { this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => { // Store uniform locations of newly created shaders. - shader._uWT = shader.get_uniform_location('uWT'); + shader._uWT = shader.get_uniform_location('uWT'); shader._uXpos = shader.get_uniform_location('uXpos'); shader._uYpos = shader.get_uniform_location('uYpos'); shader._uWinRot = shader.get_uniform_location('uWinRot'); shader._uSparkleRot = shader.get_uniform_location('uSparkleRot'); shader._uSparkleSize = shader.get_uniform_location('uSparkleSize'); - shader._uSeed = shader.get_uniform_location('uSeed'); + shader._uSeed = shader.get_uniform_location('uSeed'); // Write all uniform values at the start of each animation. shader.connect('begin-animation', (shader, settings) => { @@ -63,7 +63,7 @@ export default class Effect { ]); shader.set_uniform_float(shader._uWinRot, 1, - [settings.get_boolean('team-rocket-win-rot')]); + [settings.get_boolean('team-rocket-win-rot')]); shader.set_uniform_float(shader._uSparkleRot, 1, [ settings.get_double('team-rocket-sparkle-rot'),