🔧 Streamline RGB warp effect
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// SPDX-FileCopyrightText: Justin Garza JGarza9788@gmail.com
|
||||
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// The content from common.glsl is automatically prepended to each shader effect. This
|
||||
@@ -31,65 +32,43 @@
|
||||
// void setOutputColor(vec4 outColor)
|
||||
|
||||
uniform float uBrightness;
|
||||
uniform float uStretchR;
|
||||
uniform float uStretchG;
|
||||
uniform float uStretchB;
|
||||
uniform float uSpeedR;
|
||||
uniform float uSpeedG;
|
||||
uniform float uSpeedB;
|
||||
|
||||
|
||||
float FadeInOut(float t, float power)
|
||||
{
|
||||
float s = -1.0 * pow((t-0.5)/(0.5),power)+1.0;
|
||||
s = clamp(s,0.0,1.0);
|
||||
float FadeInOut(float t, float power) {
|
||||
float s = -1.0 * pow((t - 0.5) / (0.5), power) + 1.0;
|
||||
s = clamp(s, 0.0, 1.0);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 ? uProgress : 1.0 - uProgress;
|
||||
float progress = uForOpening ? 1.0 - uProgress : uProgress;
|
||||
|
||||
//progress will now go from 0.5 to 1.0
|
||||
progress = mix(0.5,1.0,progress);
|
||||
// Percentage of the progress time which is spent until all pixels start moving up.
|
||||
float minSpeed = min(uSpeedR, min(uSpeedG, uSpeedB));
|
||||
float waveTime = mix(0.1, 0.9, minSpeed);
|
||||
float waveProgress = progress / waveTime;
|
||||
|
||||
// the UV
|
||||
vec2 uv = iTexCoord.st;
|
||||
//flipped the uv
|
||||
vec2 f = vec2(uv.x,1.0 - uv.y);
|
||||
// Gradient from top to bottom (0 at top, 1 at bottom).
|
||||
float t = iTexCoord.t;
|
||||
|
||||
// w is the wave
|
||||
float w = 0.0;
|
||||
// Calculate the vertical wave offset.
|
||||
float offset = max(waveProgress - t, 0.0);
|
||||
offset /= (1.0 / waveTime) - 1.0;
|
||||
offset *= (1.0 - waveTime);
|
||||
|
||||
vec4 colorR = getInputColor(iTexCoord + vec2(0.0, offset * (uSpeedR - minSpeed + 1.0)));
|
||||
vec4 colorG = getInputColor(iTexCoord + vec2(0.0, offset * (uSpeedG - minSpeed + 1.0)));
|
||||
vec4 colorB = getInputColor(iTexCoord + vec2(0.0, offset * (uSpeedB - minSpeed + 1.0)));
|
||||
|
||||
//w will be used to calculate the the size of the wave
|
||||
float p = mix(0.0, 1.0 + 1.0, progress);
|
||||
w = 1.0 - abs(p - f.y);
|
||||
w = clamp(w,0.0,1.0);
|
||||
w = pow(w, mix(100.0,1.0,1.0) );
|
||||
|
||||
//starting output color
|
||||
vec4 oColor = vec4(0.0);
|
||||
|
||||
// outputs for RGB is based on the color of the window, times uStreatch(RG and B), and another multipler for the brightness
|
||||
|
||||
oColor.r = getInputColor(uv + vec2(0.0,w * uStretchR ) ).r * mix(1.0, uBrightness, FadeInOut(progress,4));
|
||||
oColor.g = getInputColor(uv + vec2(0.0,w * uStretchG ) ).g * mix(1.0, uBrightness, FadeInOut(progress,4));
|
||||
oColor.b = getInputColor(uv + vec2(0.0,w * uStretchB ) ).b * mix(1.0, uBrightness, FadeInOut(progress,4));
|
||||
|
||||
//if you can think of a better way to handle the alpha ... try that
|
||||
|
||||
if (oColor.r + oColor.g + oColor.b > 0.0)
|
||||
{
|
||||
oColor.a = getInputColor(uv).a ;
|
||||
}
|
||||
else
|
||||
{
|
||||
oColor.a = 0.0;
|
||||
}
|
||||
|
||||
vec4 oColor =
|
||||
vec4(colorR.r, colorG.g, colorB.b, (colorR.a + colorG.a + colorB.a) / 3.0);
|
||||
oColor.rgb *= mix(1.0, uBrightness, FadeInOut(progress, 4));
|
||||
|
||||
oColor.a *= getRelativeEdgeMask(0.1);
|
||||
|
||||
setOutputColor(oColor);
|
||||
}
|
||||
|
||||
+64
-68
@@ -13,71 +13,70 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<!-- Animation Time Adjustment Section -->
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
|
||||
|
||||
<property name="title" translatable="yes">Animation Time [ms]</property>
|
||||
<child>
|
||||
|
||||
|
||||
<object class="GtkScale">
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">1</property>
|
||||
<property name="digits">0</property>
|
||||
<property name="value-pos">left</property>
|
||||
<property name="width-request">300</property>
|
||||
|
||||
<property name="draw-value">1</property>
|
||||
<property name="digits">0</property>
|
||||
<property name="value-pos">left</property>
|
||||
<property name="width-request">300</property>
|
||||
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="rgbwarp-animation-time">
|
||||
<property name="upper">5000</property>
|
||||
<property name="lower">100</property>
|
||||
<property name="step-increment">10</property>
|
||||
<property name="page-increment">100</property>
|
||||
<property name="upper">5000</property>
|
||||
<property name="lower">100</property>
|
||||
<property name="step-increment">10</property>
|
||||
<property name="page-increment">100</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-rgbwarp-animation-time">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||
<style>
|
||||
<class name="flat" />
|
||||
<class name="flat" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
|
||||
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
|
||||
|
||||
<property name="title" translatable="yes">Brightness</property>
|
||||
<!-- <property name="subtitle" translatable="yes"></property> -->
|
||||
|
||||
|
||||
<child>
|
||||
<object class="GtkScale" >
|
||||
<object class="GtkScale">
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">1</property>
|
||||
<property name="digits">2</property>
|
||||
<property name="value-pos">left</property>
|
||||
<property name="width-request">300</property>
|
||||
|
||||
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="rgbwarp-brightness">
|
||||
<property name="upper">1.0</property>
|
||||
<property name="lower">0.0</property>
|
||||
<property name="step-increment">0.1</property>
|
||||
<property name="page-increment">0.25</property>
|
||||
<property name="upper">1.0</property>
|
||||
<property name="lower">0.0</property>
|
||||
<property name="step-increment">0.1</property>
|
||||
<property name="page-increment">0.25</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-rgbwarp-brightness">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||
<style>
|
||||
@@ -90,32 +89,31 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
|
||||
<property name="title" translatable="yes">Offset Red</property>
|
||||
<!-- <property name="subtitle" translatable="yes"></property> -->
|
||||
|
||||
|
||||
<property name="title" translatable="yes">Red Speed</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkScale" >
|
||||
<object class="GtkScale">
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">1</property>
|
||||
<property name="digits">2</property>
|
||||
<property name="value-pos">left</property>
|
||||
<property name="width-request">300</property>
|
||||
|
||||
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="rgbwarp-offset-r">
|
||||
<property name="upper">1.0</property>
|
||||
<property name="lower">0.0</property>
|
||||
<property name="step-increment">0.01</property>
|
||||
<property name="page-increment">0.1</property>
|
||||
<object class="GtkAdjustment" id="rgbwarp-speed-r">
|
||||
<property name="upper">1.0</property>
|
||||
<property name="lower">0.0</property>
|
||||
<property name="step-increment">0.01</property>
|
||||
<property name="page-increment">0.1</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-rgbwarp-offset-r">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<object class="GtkButton" id="reset-rgbwarp-speed-r">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||
<style>
|
||||
@@ -128,32 +126,31 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
|
||||
<property name="title" translatable="yes">Offset Green</property>
|
||||
<!-- <property name="subtitle" translatable="yes"></property> -->
|
||||
|
||||
|
||||
<property name="title" translatable="yes">Green Speed</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkScale" >
|
||||
<object class="GtkScale">
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">1</property>
|
||||
<property name="digits">2</property>
|
||||
<property name="value-pos">left</property>
|
||||
<property name="width-request">300</property>
|
||||
|
||||
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="rgbwarp-offset-g">
|
||||
<property name="upper">1.0</property>
|
||||
<property name="lower">0.0</property>
|
||||
<property name="step-increment">0.01</property>
|
||||
<property name="page-increment">0.1</property>
|
||||
<object class="GtkAdjustment" id="rgbwarp-speed-g">
|
||||
<property name="upper">1.0</property>
|
||||
<property name="lower">0.0</property>
|
||||
<property name="step-increment">0.01</property>
|
||||
<property name="page-increment">0.1</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-rgbwarp-offset-g">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<object class="GtkButton" id="reset-rgbwarp-speed-g">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||
<style>
|
||||
@@ -166,32 +163,31 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
|
||||
<property name="title" translatable="yes">Offset Blue</property>
|
||||
<!-- <property name="subtitle" translatable="yes"></property> -->
|
||||
|
||||
|
||||
<property name="title" translatable="yes">Blue Speed</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkScale" >
|
||||
<object class="GtkScale">
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">1</property>
|
||||
<property name="digits">2</property>
|
||||
<property name="value-pos">left</property>
|
||||
<property name="width-request">300</property>
|
||||
|
||||
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="rgbwarp-offset-b">
|
||||
<property name="upper">1.0</property>
|
||||
<property name="lower">0.0</property>
|
||||
<property name="step-increment">0.01</property>
|
||||
<property name="page-increment">0.1</property>
|
||||
<object class="GtkAdjustment" id="rgbwarp-speed-b">
|
||||
<property name="upper">1.0</property>
|
||||
<property name="lower">0.0</property>
|
||||
<property name="step-increment">0.01</property>
|
||||
<property name="page-increment">0.1</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-rgbwarp-offset-b">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<object class="GtkButton" id="reset-rgbwarp-speed-b">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||
<style>
|
||||
@@ -205,4 +201,4 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</object>
|
||||
|
||||
|
||||
</interface>
|
||||
</interface>
|
||||
Reference in New Issue
Block a user