✨ Apply clang-format
This commit is contained in:
@@ -39,25 +39,23 @@ uniform float uFadeOut;
|
||||
uniform float uBlur;
|
||||
uniform vec2 uSeed;
|
||||
|
||||
|
||||
/*
|
||||
this controls the end shape
|
||||
-5.0 large Star
|
||||
-3.0 Star
|
||||
1.0 Dimond
|
||||
2.0 Circle
|
||||
3.0 Squircle
|
||||
3.0 Squircle
|
||||
5.0 Square
|
||||
*/
|
||||
uniform float uEdgeShape;
|
||||
|
||||
//the size of the edge color
|
||||
// the size of the edge color
|
||||
uniform float uEdgeSize;
|
||||
|
||||
//soft <--> hard
|
||||
// soft <--> hard
|
||||
uniform float uEdgeHardness;
|
||||
|
||||
|
||||
// A simple blur function
|
||||
vec4 blur(vec2 uv, float radius, float samples) {
|
||||
vec4 color = vec4(0.0);
|
||||
@@ -77,122 +75,107 @@ vec4 blur(vec2 uv, float radius, float samples) {
|
||||
|
||||
void main() {
|
||||
|
||||
// This gradually dissolves from [1..0] from the outside to the center. We
|
||||
// switch the direction for opening and closing.
|
||||
float progress = uForOpening ? uProgress : 1.0 - uProgress ;
|
||||
// This gradually dissolves from [1..0] from the outside to the center. We
|
||||
// switch the direction for opening and closing.
|
||||
float progress = uForOpening ? uProgress : 1.0 - uProgress;
|
||||
|
||||
//adjusting for Gnome
|
||||
if (uPadding > 0.0)
|
||||
{
|
||||
progress = remap(
|
||||
progress, 0.0, ((uSize.x - (uPadding*2.0)) / uSize.x)
|
||||
,0.0, 1.0
|
||||
);
|
||||
}
|
||||
|
||||
// adjusting for Gnome
|
||||
if (uPadding > 0.0) {
|
||||
progress = remap(progress, 0.0, ((uSize.x - (uPadding * 2.0)) / uSize.x), 0.0, 1.0);
|
||||
}
|
||||
|
||||
// Get the color from the window texture.
|
||||
vec4 oColor = getInputColor(iTexCoord.st);
|
||||
|
||||
// Calculate the aspect ratio of the render area
|
||||
float aspect = uSize.x / uSize.y;
|
||||
// Get the color from the window texture.
|
||||
vec4 oColor = getInputColor(iTexCoord.st);
|
||||
|
||||
//standard uv
|
||||
vec2 uv = iTexCoord.st;
|
||||
// Calculate the aspect ratio of the render area
|
||||
float aspect = uSize.x / uSize.y;
|
||||
|
||||
// tuv is for when progress is near 0
|
||||
vec2 tuv = uv;
|
||||
tuv -= 0.5; // Shift UV coordinates to center (from [-0.5 to 0.5])
|
||||
tuv.x *= aspect; // Scale x-coordinate to match aspect ratio
|
||||
tuv += 0.5; // Shift UV coordinates back (from [0 to 1])
|
||||
|
||||
//mixing the UVs
|
||||
uv = mix(tuv,uv,easeOutExpo(progress));
|
||||
// standard uv
|
||||
vec2 uv = iTexCoord.st;
|
||||
|
||||
// this controls the shape
|
||||
// -1.0 would be a diamond-ish
|
||||
// 0.0 would be a rounded diamond
|
||||
// 1.0 would be a circle
|
||||
// 2.0 will be sqircle
|
||||
// 1000.0 will be very square
|
||||
float p = mix(uEdgeShape,1000.0,
|
||||
easeInExpo(progress)
|
||||
);
|
||||
// tuv is for when progress is near 0
|
||||
vec2 tuv = uv;
|
||||
tuv -= 0.5; // Shift UV coordinates to center (from [-0.5 to 0.5])
|
||||
tuv.x *= aspect; // Scale x-coordinate to match aspect ratio
|
||||
tuv += 0.5; // Shift UV coordinates back (from [0 to 1])
|
||||
|
||||
//this will be used later to make a mask
|
||||
float m = mix(
|
||||
0.0,
|
||||
1.0,
|
||||
clamp(
|
||||
pow(abs(uv.x-0.5)*2.0,p) + pow(abs(uv.y-0.5)*2.0,p),0.0,1.0
|
||||
)
|
||||
);
|
||||
// mixing the UVs
|
||||
uv = mix(tuv, uv, easeOutExpo(progress));
|
||||
|
||||
// this controls the shape
|
||||
// -1.0 would be a diamond-ish
|
||||
// 0.0 would be a rounded diamond
|
||||
// 1.0 would be a circle
|
||||
// 2.0 will be sqircle
|
||||
// 1000.0 will be very square
|
||||
float p = mix(uEdgeShape, 1000.0, easeInExpo(progress));
|
||||
|
||||
//this calculates the edge of the effect
|
||||
float edge = abs(m-progress) ;
|
||||
float e = mix(0.0,uEdgeSize,1.0 - progress);
|
||||
edge = remap(edge,0.0,e,0.0,1.0);
|
||||
edge = clamp(edge,0.0,1.0);
|
||||
edge = 1.0 - edge;
|
||||
// this will be used later to make a mask
|
||||
float m =
|
||||
mix(0.0, 1.0,
|
||||
clamp(pow(abs(uv.x - 0.5) * 2.0, p) + pow(abs(uv.y - 0.5) * 2.0, p), 0.0, 1.0));
|
||||
|
||||
//this is the mask
|
||||
float mask = (m > progress) ? 0.0 : 1.0 ;
|
||||
// this calculates the edge of the effect
|
||||
float edge = abs(m - progress);
|
||||
float e = mix(0.0, uEdgeSize, 1.0 - progress);
|
||||
edge = remap(edge, 0.0, e, 0.0, 1.0);
|
||||
edge = clamp(edge, 0.0, 1.0);
|
||||
edge = 1.0 - edge;
|
||||
|
||||
//we need two of these
|
||||
float mask0 = mix(mask,mask+edge,1.0 - uEdgeHardness);
|
||||
float mask1 = mix(edge,edge*mask,uEdgeHardness);
|
||||
// this is the mask
|
||||
float mask = (m > progress) ? 0.0 : 1.0;
|
||||
|
||||
//calculate color
|
||||
vec3 color = cos(progress*uColorSpeed+uv.xyx+vec3(0,2,4)).xyz;
|
||||
//coloroffset
|
||||
float colorOffset = (uRandomColorOffset) ? hash12(uSeed) : uColorOffset ;
|
||||
color = offsetHue(color, colorOffset + 0.10);
|
||||
//clamp and saturate
|
||||
color = clamp(color * uColorSaturation,vec3(0.0),vec3(1.0));
|
||||
|
||||
//save this for later
|
||||
float oColorAlpha = oColor.a;
|
||||
// we need two of these
|
||||
float mask0 = mix(mask, mask + edge, 1.0 - uEdgeHardness);
|
||||
float mask1 = mix(edge, edge * mask, uEdgeHardness);
|
||||
|
||||
//blur-ify
|
||||
if (uBlur > 0.0)
|
||||
{
|
||||
//used for blur later ...
|
||||
//calculate this before saturating it
|
||||
float b = (color.r + color.g + color.b)/3.0;
|
||||
// calculate color
|
||||
vec3 color = cos(progress * uColorSpeed + uv.xyx + vec3(0, 2, 4)).xyz;
|
||||
// coloroffset
|
||||
float colorOffset = (uRandomColorOffset) ? hash12(uSeed) : uColorOffset;
|
||||
color = offsetHue(color, colorOffset + 0.10);
|
||||
// clamp and saturate
|
||||
color = clamp(color * uColorSaturation, vec3(0.0), vec3(1.0));
|
||||
|
||||
|
||||
oColor = blur( iTexCoord.st, b * uBlur * mask1, 7.0);
|
||||
}
|
||||
// save this for later
|
||||
float oColorAlpha = oColor.a;
|
||||
|
||||
//apply masks and colors
|
||||
oColor.a *= mask0;
|
||||
// blur-ify
|
||||
if (uBlur > 0.0) {
|
||||
// used for blur later ...
|
||||
// calculate this before saturating it
|
||||
float b = (color.r + color.g + color.b) / 3.0;
|
||||
|
||||
//i was doing this to try to adjust for light mode
|
||||
// i don;t like the way these make the effect look
|
||||
// ...maybe a toggle for it later
|
||||
/*
|
||||
float oColorPercent = (oColor.r + oColor.g + oColor.b)/3.0;
|
||||
oColor.r = mix(oColor.r , 1.0 - oColor.r, mask1 * oColorPercent);
|
||||
oColor.g = mix(oColor.g , 1.0 - oColor.g, mask1 * oColorPercent);
|
||||
oColor.b = mix(oColor.b , 1.0 - oColor.b, mask1 * oColorPercent);
|
||||
// --or
|
||||
oColor.r = mix(oColor.r , 0.0, mask1 * oColorPercent);
|
||||
oColor.g = mix(oColor.g , 0.0, mask1 * oColorPercent);
|
||||
oColor.b = mix(oColor.b , 0.0, mask1 * oColorPercent);
|
||||
*/
|
||||
|
||||
oColor += mask1 * vec4(color.rgb,1.0);
|
||||
oColor.a *= oColorAlpha;
|
||||
oColor = blur(iTexCoord.st, b * uBlur * mask1, 7.0);
|
||||
}
|
||||
|
||||
//i want to fade out the last ~10% of the animation
|
||||
float lastfade = remap(progress,0.0,uFadeOut,0.0,1.0);
|
||||
lastfade = clamp(lastfade,0.0,1.0);
|
||||
lastfade = easeInSine(lastfade);
|
||||
|
||||
//apply the lastfade
|
||||
oColor.a *= lastfade;
|
||||
// apply masks and colors
|
||||
oColor.a *= mask0;
|
||||
|
||||
setOutputColor(oColor);
|
||||
// i was doing this to try to adjust for light mode
|
||||
// i don;t like the way these make the effect look
|
||||
// ...maybe a toggle for it later
|
||||
/*
|
||||
float oColorPercent = (oColor.r + oColor.g + oColor.b)/3.0;
|
||||
oColor.r = mix(oColor.r , 1.0 - oColor.r, mask1 * oColorPercent);
|
||||
oColor.g = mix(oColor.g , 1.0 - oColor.g, mask1 * oColorPercent);
|
||||
oColor.b = mix(oColor.b , 1.0 - oColor.b, mask1 * oColorPercent);
|
||||
// --or
|
||||
oColor.r = mix(oColor.r , 0.0, mask1 * oColorPercent);
|
||||
oColor.g = mix(oColor.g , 0.0, mask1 * oColorPercent);
|
||||
oColor.b = mix(oColor.b , 0.0, mask1 * oColorPercent);
|
||||
*/
|
||||
|
||||
oColor += mask1 * vec4(color.rgb, 1.0);
|
||||
oColor.a *= oColorAlpha;
|
||||
|
||||
// i want to fade out the last ~10% of the animation
|
||||
float lastfade = remap(progress, 0.0, uFadeOut, 0.0, 1.0);
|
||||
lastfade = clamp(lastfade, 0.0, 1.0);
|
||||
lastfade = easeInSine(lastfade);
|
||||
|
||||
// apply the lastfade
|
||||
oColor.a *= lastfade;
|
||||
|
||||
setOutputColor(oColor);
|
||||
}
|
||||
Reference in New Issue
Block a user