Merge branch 'main' into feature/esm-modules

This commit is contained in:
Simon Schneegans
2023-08-18 05:47:31 +02:00
42 changed files with 2460 additions and 1896 deletions
+35 -12
View File
@@ -20,13 +20,14 @@
// Each shader can access these standard input values:
// vec2 iTexCoord: Texture coordinates for retrieving the window input color.
// 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.
// 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:
@@ -35,6 +36,7 @@
// void setOutputColor(vec4 outColor)
uniform bool uForOpening;
uniform bool uIsFullscreen;
uniform float uProgress;
uniform float uDuration;
@@ -62,6 +64,15 @@ vec4 getInputColor(vec2 coords) {
}
void setOutputColor(vec4 outColor) {
// If a uniform is not used, it will be optimized away. This condition is always
// false, but it will prevent the compiler from optimizing away the uniforms uForOpening
// and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
// uniform is used in the shader.
if (outColor.a > 10e42 && uForOpening && uIsFullscreen) {
outColor = vec4(0.0);
}
fragColor = vec4(outColor.rgb * outColor.a, outColor.a);
}
@@ -88,6 +99,14 @@ vec4 getInputColor(vec2 coords) {
}
void setOutputColor(vec4 outColor) {
// If a uniform is not used, it will be optimized away. This condition is always
// false, but it will prevent the compiler from optimizing away the uniforms uForOpening
// and uIsFullscreen. On KWin, we need to do this as we do not have a way to check if a
// uniform is used in the shader.
if (outColor.a > 10e42 && uForOpening && uIsFullscreen) {
outColor = vec4(0.0);
}
gl_FragColor = vec4(outColor.rgb * outColor.a, outColor.a);
}
@@ -168,14 +187,18 @@ float easeOutBack(float x, float e) {
// --------------------------------------------------------------------- edge mask helpers
// This method returns a mask which smoothly transitions towards zero when approaching
// the window's borders. There is a variant which takes the transition area width in
// the window's borders. If the window is currently maximized or in fullscreen mode, this
// will return 1.0 everywhere. There is a variant which takes the transition area width in
// pixels and one which takes this as a percentage.
float getEdgeMask(vec2 uv, vec2 maxUV, float fadeWidth) {
float mask = 1.0;
mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));
mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));
mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));
if (!uIsFullscreen) {
mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));
mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
mask *= smoothstep(0.0, 1.0, clamp((maxUV.x - uv.x) / fadeWidth, 0.0, 1.0));
mask *= smoothstep(0.0, 1.0, clamp((maxUV.y - uv.y) / fadeWidth, 0.0, 1.0));
}
return mask;
}
+13 -8
View File
@@ -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);
+23 -7
View File
@@ -78,17 +78,33 @@ SPDX-License-Identifier: GPL-3.0-or-later
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Color</property>
<property name="activatable-widget">wisps-color</property>
<child>
<object class="GtkColorButton" id="wisps-color">
<property name="use_alpha">0</property>
<property name="show_editor">1</property>
<property name="width-request">250</property>
<property name="valign">center</property>
<object class="GtkBox">
<style>
<class name="linked" />
</style>
<child>
<object class="GtkColorButton" id="wisps-color-1">
<property name="show_editor">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkColorButton" id="wisps-color-2">
<property name="show_editor">1</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="GtkColorButton" id="wisps-color-3">
<property name="show_editor">1</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="reset-wisps-color">
<object class="GtkButton" id="reset-wisps-colors">
<property name="icon-name">edit-clear-symbolic</property>
<property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
+6
View File
@@ -51,6 +51,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
</item>
</submenu>
</section>
<section>
<item>
<attribute name="label" translatable="yes">Open Effect-Profile Directory</attribute>
<attribute name="action">prefs.profile-dir</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">About Burn-My-Windows</attribute>