From 32d78ceced5cc580cc13dd14046b91acea6248c3 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sun, 13 Aug 2023 13:35:03 +0200 Subject: [PATCH 1/2] :tada: Add support for colorful wisps --- docs/changelog.md | 1 + kwin/wisps/config.ui | 12 +++++++- kwin/wisps/main.xml | 11 +++++-- kwin/wisps/onSettingsChanged.js | 4 ++- resources/shaders/wisps.frag | 21 ++++++++----- resources/ui/adw/wisps.ui | 30 ++++++++++++++----- resources/ui/gtk3/wisps.ui | 20 +++++++++---- resources/ui/gtk4/wisps.ui | 18 +++++++---- ...nsions.burn-my-windows-profile.gschema.xml | 18 +++++++++-- src/effects/Wisps.js | 29 +++++++++++++++--- 10 files changed, 125 insertions(+), 39 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 8723daa..3b8fc44 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -13,6 +13,7 @@ SPDX-License-Identifier: CC-BY-4.0 - Two convenience buttons have been added to the preferences dialog. One allows you to select all effects, the other one allows you to deselect all effects. - A new main menu entry has been added which allows you to open the effect-profile directory. This is useful if you want to back up or share your profiles with others. +- The Wisps effect now supports colorful wisps. You can now specify three colors for the effect. These colors make up a gradient which is used to color the wisps. #### Bug Fixes diff --git a/kwin/wisps/config.ui b/kwin/wisps/config.ui index 87c9a7f..47d07c7 100755 --- a/kwin/wisps/config.ui +++ b/kwin/wisps/config.ui @@ -71,7 +71,17 @@ SPDX-License-Identifier: GPL-3.0-or-later - + + + + + + + + + + + diff --git a/kwin/wisps/main.xml b/kwin/wisps/main.xml index 870f169..ea6cd36 100755 --- a/kwin/wisps/main.xml +++ b/kwin/wisps/main.xml @@ -5,8 +5,7 @@ SPDX-FileCopyrightText: Simon Schneegans SPDX-License-Identifier: GPL-3.0-or-later --> - + @@ -15,8 +14,14 @@ SPDX-License-Identifier: GPL-3.0-or-later 1 - + #ff64c8 + + #6464ff + + + #64c8ff + \ No newline at end of file diff --git a/kwin/wisps/onSettingsChanged.js b/kwin/wisps/onSettingsChanged.js index b92ff16..0e789cc 100644 --- a/kwin/wisps/onSettingsChanged.js +++ b/kwin/wisps/onSettingsChanged.js @@ -7,4 +7,6 @@ effect.setUniform(this.shader, 'uDuration', this.duration * 0.001); effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0)); -effect.setUniform(this.shader, 'uColor', this.readRGBConfig('Color')); +effect.setUniform(this.shader, 'uColor1', this.readRGBConfig('Color1')); +effect.setUniform(this.shader, 'uColor2', this.readRGBConfig('Color2')); +effect.setUniform(this.shader, 'uColor3', this.readRGBConfig('Color3')); diff --git a/resources/shaders/wisps.frag b/resources/shaders/wisps.frag index e7aaf85..9322bd7 100644 --- a/resources/shaders/wisps.frag +++ b/resources/shaders/wisps.frag @@ -15,8 +15,10 @@ // The content from common.glsl is automatically prepended to each shader effect. uniform vec2 uSeed; -uniform vec3 uColor; uniform float uScale; +uniform vec3 uColor1; +uniform vec3 uColor2; +uniform vec3 uColor3; const float WISPS_RADIUS = 20.0; const float WISPS_SPEED = 10.0; @@ -28,7 +30,7 @@ const float SCALING = 0.9; // Returns a grid of randomly moving points. Each grid cell contains one point which // moves on an ellipse. -float getWisps(vec2 texCoords, float gridSize, vec2 seed) { +vec4 getWisps(vec2 texCoords, float gridSize, vec2 seed) { // Shift coordinates by a random offset and make sure the have a 1:1 aspect ratio. vec2 coords = (texCoords + hash22(seed)) * uSize; @@ -56,13 +58,16 @@ float getWisps(vec2 texCoords, float gridSize, vec2 seed) { cellUV += offset; + vec3 color = tritone(hash12(cellID * seed * 1.256), uColor1, uColor2, uColor3); + // Use distance to center of shifted / rotated UV coordinates to draw a glaring point. float dist = length(cellUV - 0.5) * gridSize / radius; if (dist < 1.0) { - return min(5.0, 0.01 / pow(dist, 2.0)); + float alpha = min(5.0, 0.01 / pow(dist, 2.0)); + return vec4(color * alpha, alpha); } - return 0.0; + return vec4(0.0); } void main() { @@ -78,9 +83,9 @@ void main() { // Compute several layers of moving wisps. vec2 uv = (iTexCoord.st - 0.5) / mix(1.0, 0.5, progress) + 0.5; uv /= uScale; - float wisps = 0.0; + vec4 wisps = vec4(0.0); for (float i = 0.0; i < WISPS_LAYERS; ++i) { - wisps += getWisps(uv * 0.3, WISPS_SPACING, uSeed * (i + 1.0)); + wisps = alphaOver(wisps, getWisps(uv * 0.3, WISPS_SPACING, uSeed * (i + 1.0))); } // Compute shrinking edge mask. @@ -100,8 +105,8 @@ void main() { oColor.a *= windowMask * mask; // Add the wisps. - vec4 wispColor = wisps * vec4(uColor, min(wispsIn, 1.0 - wispsOut) * mask); - oColor = alphaOver(oColor, wispColor); + wisps.a *= min(wispsIn, 1.0 - wispsOut) * mask; + oColor = alphaOver(oColor, wisps); // These are pretty useful for understanding how this works. // oColor = vec4(vec3(windowMask), 1.0); diff --git a/resources/ui/adw/wisps.ui b/resources/ui/adw/wisps.ui index 788e668..44b74f2 100644 --- a/resources/ui/adw/wisps.ui +++ b/resources/ui/adw/wisps.ui @@ -78,17 +78,33 @@ SPDX-License-Identifier: GPL-3.0-or-later Color - wisps-color - - 0 - 1 - 250 - center + + + + + 1 + center + + + + + 1 + center + + + + + 1 + center + + - + edit-clear-symbolic center Reset to Default Value diff --git a/resources/ui/gtk3/wisps.ui b/resources/ui/gtk3/wisps.ui index 5029d44..ad25765 100644 --- a/resources/ui/gtk3/wisps.ui +++ b/resources/ui/gtk3/wisps.ui @@ -117,11 +117,13 @@ SPDX-License-Identifier: GPL-3.0-or-later + 0 + 8 Color @@ -132,16 +134,22 @@ SPDX-License-Identifier: GPL-3.0-or-later - - 0 + 1 - 8 - 8 - 250 - + + 1 + + + + + 1 + + + + edit-clear-symbolic diff --git a/resources/ui/gtk4/wisps.ui b/resources/ui/gtk4/wisps.ui index e5d3a37..a9bd50c 100644 --- a/resources/ui/gtk4/wisps.ui +++ b/resources/ui/gtk4/wisps.ui @@ -120,16 +120,22 @@ SPDX-License-Identifier: GPL-3.0-or-later - - 0 + 1 - 8 - 8 - 250 - + + 1 + + + + + 1 + + + + edit-clear-symbolic Reset to Default Value