✨ Apply clang-format

This commit is contained in:
Simon Schneegans
2025-02-09 08:19:00 +01:00
parent 3ab1ffbc15
commit 91789d3617
8 changed files with 307 additions and 389 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ export default class BurnMyWindows extends Extension {
new Matrix(), new PaintBrush(), new Pixelate(), new PixelWheel(), new Matrix(), new PaintBrush(), new Pixelate(), new PixelWheel(),
new PixelWipe(), new Portal(), new RGBWarp(), new SnapOfDisintegration(), new PixelWipe(), new Portal(), new RGBWarp(), new SnapOfDisintegration(),
new TeamRocket(), new TRexAttack(), new TVEffect(), new TVGlitch(), new TeamRocket(), new TRexAttack(), new TVEffect(), new TVGlitch(),
new Wisps(), new Mushroom() new Wisps(), new Mushroom()
]; ];
// Load all of our resources. // Load all of our resources.
+1 -1
View File
@@ -83,7 +83,7 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {
Pixelate, PixelWheel, PixelWipe, Pixelate, PixelWheel, PixelWipe,
Portal, RGBWarp, SnapOfDisintegration, Portal, RGBWarp, SnapOfDisintegration,
TeamRocket, TRexAttack, TVEffect, TeamRocket, TRexAttack, TVEffect,
TVGlitch, Wisps, TVGlitch, Wisps,
]; ];
+88 -105
View File
@@ -39,25 +39,23 @@ uniform float uFadeOut;
uniform float uBlur; uniform float uBlur;
uniform vec2 uSeed; uniform vec2 uSeed;
/* /*
this controls the end shape this controls the end shape
-5.0 large Star -5.0 large Star
-3.0 Star -3.0 Star
1.0 Dimond 1.0 Dimond
2.0 Circle 2.0 Circle
3.0 Squircle 3.0 Squircle
5.0 Square 5.0 Square
*/ */
uniform float uEdgeShape; uniform float uEdgeShape;
//the size of the edge color // the size of the edge color
uniform float uEdgeSize; uniform float uEdgeSize;
//soft <--> hard // soft <--> hard
uniform float uEdgeHardness; uniform float uEdgeHardness;
// A simple blur function // A simple blur function
vec4 blur(vec2 uv, float radius, float samples) { vec4 blur(vec2 uv, float radius, float samples) {
vec4 color = vec4(0.0); vec4 color = vec4(0.0);
@@ -77,122 +75,107 @@ vec4 blur(vec2 uv, float radius, float samples) {
void main() { void main() {
// This gradually dissolves from [1..0] from the outside to the center. We // This gradually dissolves from [1..0] from the outside to the center. We
// switch the direction for opening and closing. // switch the direction for opening and closing.
float progress = uForOpening ? uProgress : 1.0 - uProgress ; float progress = uForOpening ? uProgress : 1.0 - uProgress;
//adjusting for Gnome // adjusting for Gnome
if (uPadding > 0.0) if (uPadding > 0.0) {
{ progress = remap(progress, 0.0, ((uSize.x - (uPadding * 2.0)) / uSize.x), 0.0, 1.0);
progress = remap( }
progress, 0.0, ((uSize.x - (uPadding*2.0)) / uSize.x)
,0.0, 1.0
);
}
// Get the color from the window texture. // Get the color from the window texture.
vec4 oColor = getInputColor(iTexCoord.st); vec4 oColor = getInputColor(iTexCoord.st);
// Calculate the aspect ratio of the render area
float aspect = uSize.x / uSize.y;
//standard uv // Calculate the aspect ratio of the render area
vec2 uv = iTexCoord.st; float aspect = uSize.x / uSize.y;
// tuv is for when progress is near 0 // standard uv
vec2 tuv = uv; vec2 uv = iTexCoord.st;
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));
// this controls the shape // tuv is for when progress is near 0
// -1.0 would be a diamond-ish vec2 tuv = uv;
// 0.0 would be a rounded diamond tuv -= 0.5; // Shift UV coordinates to center (from [-0.5 to 0.5])
// 1.0 would be a circle tuv.x *= aspect; // Scale x-coordinate to match aspect ratio
// 2.0 will be sqircle tuv += 0.5; // Shift UV coordinates back (from [0 to 1])
// 1000.0 will be very square
float p = mix(uEdgeShape,1000.0,
easeInExpo(progress)
);
//this will be used later to make a mask // mixing the UVs
float m = mix( uv = mix(tuv, uv, easeOutExpo(progress));
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 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 // this will be used later to make a mask
float edge = abs(m-progress) ; float m =
float e = mix(0.0,uEdgeSize,1.0 - progress); mix(0.0, 1.0,
edge = remap(edge,0.0,e,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));
edge = clamp(edge,0.0,1.0);
edge = 1.0 - edge;
//this is the mask // this calculates the edge of the effect
float mask = (m > progress) ? 0.0 : 1.0 ; 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 // this is the mask
float mask0 = mix(mask,mask+edge,1.0 - uEdgeHardness); float mask = (m > progress) ? 0.0 : 1.0;
float mask1 = mix(edge,edge*mask,uEdgeHardness);
//calculate color // we need two of these
vec3 color = cos(progress*uColorSpeed+uv.xyx+vec3(0,2,4)).xyz; float mask0 = mix(mask, mask + edge, 1.0 - uEdgeHardness);
//coloroffset float mask1 = mix(edge, edge * mask, uEdgeHardness);
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;
//blur-ify // calculate color
if (uBlur > 0.0) vec3 color = cos(progress * uColorSpeed + uv.xyx + vec3(0, 2, 4)).xyz;
{ // coloroffset
//used for blur later ... float colorOffset = (uRandomColorOffset) ? hash12(uSeed) : uColorOffset;
//calculate this before saturating it color = offsetHue(color, colorOffset + 0.10);
float b = (color.r + color.g + color.b)/3.0; // clamp and saturate
color = clamp(color * uColorSaturation, vec3(0.0), vec3(1.0));
// save this for later
oColor = blur( iTexCoord.st, b * uBlur * mask1, 7.0); float oColorAlpha = oColor.a;
}
//apply masks and colors // blur-ify
oColor.a *= mask0; 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 oColor = blur(iTexCoord.st, b * uBlur * mask1, 7.0);
// 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 // apply masks and colors
float lastfade = remap(progress,0.0,uFadeOut,0.0,1.0); oColor.a *= mask0;
lastfade = clamp(lastfade,0.0,1.0);
lastfade = easeInSine(lastfade);
//apply the lastfade
oColor.a *= lastfade;
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);
} }
+215 -275
View File
@@ -35,15 +35,15 @@
// use 8BitStyle or not (sliding scale) // use 8BitStyle or not (sliding scale)
uniform float uScaleStyle; uniform float uScaleStyle;
//these are for the sparks // these are for the sparks
uniform float uSparkCount; uniform float uSparkCount;
uniform vec4 uSparkColor; uniform vec4 uSparkColor;
uniform float uSparkRotation; uniform float uSparkRotation;
//these are for the Rays // these are for the Rays
uniform vec4 uRaysColor; uniform vec4 uRaysColor;
//these are for the stars // these are for the stars
uniform float uRingCount; uniform float uRingCount;
uniform float uRingRotation; uniform float uRingRotation;
uniform float uStarCount; uniform float uStarCount;
@@ -56,64 +56,65 @@ uniform vec4 uStarColor3;
uniform vec4 uStarColor4; uniform vec4 uStarColor4;
uniform vec4 uStarColor5; uniform vec4 uStarColor5;
//seed // seed
uniform vec2 uSeed; uniform vec2 uSeed;
//helps to find the angle // helps to find the angle
vec3 getPosByAngle(float angle) vec3 getPosByAngle(float angle) { return vec3(cos(angle), sin(angle), 0); }
{
return vec3(cos(angle), sin(angle), 0); // gets the mask of a Star
float getStar(vec2 uv, vec2 center, float npoints, float radiusRatio, float size,
float rotation) {
float radiusMax = 1.0;
float radiusMin = radiusMax * radiusRatio;
float PI = 3.1415926;
float starangle = 2.0 * PI / npoints; // Angle between points on the star
// Offset rotation to ensure one point is always up when rotation = 0
rotation += PI / 2.0 - starangle / 1.0;
// Define the positions for the outer and inner points of the star's initial angle,
// rotated by `rotation`
vec3 p0 =
(radiusMax * size) * getPosByAngle(rotation); // Outer point, rotated by `rotation`
vec3 p1 = (radiusMin * size) *
getPosByAngle(starangle + rotation); // Inner point, also rotated
// Calculate the position of the current fragment relative to the star's center
vec2 curPosuv =
(uv - center); // Center UV coordinates, then scale to fit the star size
float curRadius = length(curPosuv); // Radius from center, no need to scale further
float curPosAngle =
atan(curPosuv.y, curPosuv.x) - rotation; // Calculate angle and adjust by `rotation`
// Determine the fractional position within the current star segment
float a =
fract(curPosAngle / starangle); // Fractional angle position within one segment
if (a >= 0.5)
a = 1.0 - a; // Ensure we are within the first half of the segment (symmetry)
// Calculate the current point on the star segment, applying rotation
a = a * starangle; // Actual angle for this position on the segment
vec3 curPos = curRadius * getPosByAngle(a + rotation); // Final position, rotated
// Calculate directions for edge detection using cross product
vec3 dir0 = p1 - p0; // Vector from outer to inner point
vec3 dir1 = curPos - p0; // Vector from outer point to current position
// Use cross product to determine if `curPos` is inside the star's edge
return step(0.0,
cross(dir0, dir1).z); // Returns 1.0 if inside, 0.0 if outside (solid edge)
} }
// use to scale the window
//gets the mask of a Star vec2 scaleUV(vec2 uv, vec2 scale) {
float getStar(vec2 uv, vec2 center, float npoints, float radiusRatio, float size, float rotation)
{
float radiusMax = 1.0;
float radiusMin = radiusMax * radiusRatio;
float PI = 3.1415926;
float starangle = 2.0 * PI / npoints; // Angle between points on the star
// Offset rotation to ensure one point is always up when rotation = 0
rotation += PI / 2.0 - starangle / 1.0;
// Define the positions for the outer and inner points of the star's initial angle, rotated by `rotation`
vec3 p0 = (radiusMax * size) * getPosByAngle(rotation); // Outer point, rotated by `rotation`
vec3 p1 = (radiusMin * size) * getPosByAngle(starangle + rotation); // Inner point, also rotated
// Calculate the position of the current fragment relative to the star's center
vec2 curPosuv = (uv - center); // Center UV coordinates, then scale to fit the star size
float curRadius = length(curPosuv); // Radius from center, no need to scale further
float curPosAngle = atan(curPosuv.y, curPosuv.x) - rotation; // Calculate angle and adjust by `rotation`
// Determine the fractional position within the current star segment
float a = fract(curPosAngle / starangle); // Fractional angle position within one segment
if (a >= 0.5)
a = 1.0 - a; // Ensure we are within the first half of the segment (symmetry)
// Calculate the current point on the star segment, applying rotation
a = a * starangle; // Actual angle for this position on the segment
vec3 curPos = curRadius * getPosByAngle(a + rotation); // Final position, rotated
// Calculate directions for edge detection using cross product
vec3 dir0 = p1 - p0; // Vector from outer to inner point
vec3 dir1 = curPos - p0; // Vector from outer point to current position
// Use cross product to determine if `curPos` is inside the star's edge
return step(0.0, cross(dir0, dir1).z); // Returns 1.0 if inside, 0.0 if outside (solid edge)
}
//use to scale the window
vec2 scaleUV(vec2 uv, vec2 scale)
{
// Put texture coordinate origin to center of window. // Put texture coordinate origin to center of window.
uv = uv * 2.0 - 1.0; uv = uv * 2.0 - 1.0;
//scale // scale
uv /= mix(vec2(1.0,1.0), vec2(0.0,0.0), scale); uv /= mix(vec2(1.0, 1.0), vec2(0.0, 0.0), scale);
// scale from center // scale from center
uv = uv * 0.5 + 0.5; uv = uv * 0.5 + 0.5;
@@ -121,89 +122,78 @@ vec2 scaleUV(vec2 uv, vec2 scale)
return uv; return uv;
} }
// this returns the Spark
float getSpark(vec2 uv, vec2 center, float brightness, float size, float rotation) {
brightness = clamp(brightness, 0.001, 1.0);
size = clamp(size, 0.001, 1.0);
float bn = mix(0.0, 0.07, brightness); // recalculate size
//this returns the Spark uv = (uv + vec2(0.5));
float getSpark(vec2 uv, vec2 center, float brightness, float size, float rotation) uv = (uv - center); // Center UV coordinates, then scale to fit the star size
{
brightness = clamp(brightness,0.001,1.0);
size = clamp(size,0.001,1.0);
float bn = mix(0.0,0.07,brightness); //recalculate size
uv = (uv + vec2(0.5)) ;
uv = (uv - center) ;//Center UV coordinates, then scale to fit the star size
uv = scaleUV(uv, vec2(1.0 - size)); uv = scaleUV(uv, vec2(1.0 - size));
uv = rotate(uv, rotation, vec2(0.5)); //rotate the UV uv = rotate(uv, rotation, vec2(0.5)); // rotate the UV
//this is basically the brightness // this is basically the brightness
float p = mix(-1.0,1000.0,easeInExpo(bn)); float p = mix(-1.0, 1000.0, easeInExpo(bn));
float m = mix( float m =
0.0, mix(0.0, 1.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));
clamp(
pow(abs(uv.x-0.5)*2.0,p) + pow(abs(uv.y-0.5)*2.0,p),0.0,1.0 float mask = easeInSine(1.0 - (m - bn)) - 0.004;
) mask = clamp(mask, 0.0, 1.0);
);
float mask = easeInSine(1.0 - (m - bn)) - 0.004 ;
mask = clamp(mask,0.0,1.0);
return mask; return mask;
} }
// returns the star's color
//returns the star's color
vec4 getStarColor(float v, float alpha) { vec4 getStarColor(float v, float alpha) {
// Clamp v to ensure it's in [0.0, 1.0] // Clamp v to ensure it's in [0.0, 1.0]
v = clamp(v, 0.0, 1.0); v = clamp(v, 0.0, 1.0);
// Define steps for color interpolation // Define steps for color interpolation
float steps[6]; float steps[6];
steps[0] = 0.0; steps[0] = 0.0;
steps[1] = 0.1666; steps[1] = 0.1666;
steps[2] = 0.3332; steps[2] = 0.3332;
steps[3] = 0.4998; steps[3] = 0.4998;
steps[4] = 0.6664; steps[4] = 0.6664;
steps[5] = 0.8330; steps[5] = 0.8330;
// Define color values // Define color values
vec4 colors[6]; vec4 colors[6];
colors[0] = uStarColor0; colors[0] = uStarColor0;
colors[1] = uStarColor1; colors[1] = uStarColor1;
colors[2] = uStarColor2; colors[2] = uStarColor2;
colors[3] = uStarColor3; colors[3] = uStarColor3;
colors[4] = uStarColor4; colors[4] = uStarColor4;
colors[5] = uStarColor5; colors[5] = uStarColor5;
// Assign alpha values // Assign alpha values
for (int i = 0; i < 6; ++i) { for (int i = 0; i < 6; ++i) {
colors[i].a = alpha * colors[i].a; colors[i].a = alpha * colors[i].a;
}
// Handle edge cases
if (v <= steps[0]) {
return colors[0];
}
if (v >= steps[5]) {
return colors[5];
}
// Find the correct interpolation segment
for (int i = 0; i < 5; ++i) {
if (v <= steps[i + 1]) {
float t = (v - steps[i]) / (steps[i + 1] - steps[i]);
return mix(colors[i], colors[i + 1], t);
} }
}
// Handle edge cases // Fallback (should never be reached)
if (v <= steps[0]) { return vec4(0.0, 0.0, 0.0, 1.0);
return colors[0];
}
if (v >= steps[5]) {
return colors[5];
}
// Find the correct interpolation segment
for (int i = 0; i < 5; ++i) {
if (v <= steps[i + 1]) {
float t = (v - steps[i]) / (steps[i + 1] - steps[i]);
return mix(colors[i], colors[i + 1], t);
}
}
// Fallback (should never be reached)
return vec4(0.0, 0.0, 0.0, 1.0);
} }
// 1| __________ // 1| __________
// | / \ // | / \
// | / \ // | / \
@@ -215,196 +205,155 @@ graph above ... where t is close to 0, or 1 the result will fade to zero
i.e. this is just the function of power(x,p) shifted i.e. this is just the function of power(x,p) shifted
where x is time, and p is 2.0,4.0,8.0,10.0 ... or any positive even number where x is time, and p is 2.0,4.0,8.0,10.0 ... or any positive even number
*/ */
float zeroStartEnd(float t, float max_size, float power) float zeroStartEnd(float t, float max_size, float power) {
{ float s = -1.0 * pow((t - 0.5) / (0.5), power) + 1.0;
float s = -1.0 * pow((t-0.5)/(0.5),power)+1.0; s = clamp(s, 0.0, 1.0) * max_size;
s = clamp(s,0.0,1.0) * max_size;
return s; return s;
} }
//this gives us the jerky 8bit growth effect. // this gives us the jerky 8bit growth effect.
float eightBitScale(float progress) float eightBitScale(float progress) {
{ float scale = 1.0;
float scale = 1.0; if (progress <= 0.1) {
if (progress <= 0.1) scale = 0.25;
{ } else if (progress <= 0.2) {
scale = 0.25; scale = 0.5;
} } else if (progress <= 0.3) {
else if (progress <= 0.2) scale = 0.25;
{ } else if (progress <= 0.4) {
scale = 0.5; scale = 0.5;
} } else if (progress <= 0.5) {
else if (progress <= 0.3) scale = 0.25;
{ } else if (progress <= 0.6) {
scale = 0.25; scale = 0.5;
} } else if (progress <= 0.7) {
else if (progress <= 0.4) scale = 1.0;
{ } else if (progress <= 0.8) {
scale = 0.5; scale = 0.25;
} } else if (progress <= 0.9) {
else if (progress <= 0.5) scale = 0.5;
{ }
scale = 0.25; return scale;
}
else if (progress <= 0.6)
{
scale = 0.5;
}
else if (progress <= 0.7)
{
scale = 1.0;
}
else if (progress <= 0.8)
{
scale = 0.25;
}
else if (progress <= 0.9)
{
scale = 0.5;
}
return scale;
} }
// gets all the sparks
//gets all the sparks vec4 getSparks(float progress) {
vec4 getSparks(float progress) // the UV for this function
{
//the UV for this function
float aspect = uSize.x / uSize.y; float aspect = uSize.x / uSize.y;
vec2 uv = iTexCoord.st * vec2(aspect,1.0); vec2 uv = iTexCoord.st * vec2(aspect, 1.0);
//this will be the result to return // this will be the result to return
vec4 result = vec4(0.0); vec4 result = vec4(0.0);
// 0 at the edges // 0 at the edges
float xEdge = -1.0 * pow((uv.x-(aspect*0.5))/(aspect*0.5),8.0)+1.0; float xEdge = -1.0 * pow((uv.x - (aspect * 0.5)) / (aspect * 0.5), 8.0) + 1.0;
xEdge = clamp(xEdge,0.0,1.0); xEdge = clamp(xEdge, 0.0, 1.0);
//declare some variables before the loop // declare some variables before the loop
vec2 h = vec2(0.0); vec2 h = vec2(0.0);
float y = 0.0; float y = 0.0;
float x = 0.0; float x = 0.0;
//loop for each spart // loop for each spart
for (float xusp = 0.0; xusp < uSparkCount; ++xusp) for (float xusp = 0.0; xusp < uSparkCount; ++xusp) {
{ // calculate some variables
//calculate some variables h = hash21(xusp + uSeed.x);
h = hash21(xusp + uSeed.x); y = mix(0.0 - h.y, 1.0 + (1.0 - h.y), progress);
y = mix( 0.0 - h.y , 1.0+(1.0-h.y) , progress); y = clamp(y, 0.0, 1.0);
y = clamp(y,0.0,1.0);
x = 0.66 * sin(h.x * 6.28) ; x = 0.66 * sin(h.x * 6.28);
x += 0.5 * aspect; x += 0.5 * aspect;
//here we get the mask for the spark // here we get the mask for the spark
float a4ps = getSpark( float a4ps = getSpark(uv, vec2(x, y), // position (x, y)
uv, zeroStartEnd(y, 1.0, 4.0) * xEdge, // Brightness
vec2( x , y), //position (x, y) zeroStartEnd(y, 0.5, 4.0) * xEdge, // Size
zeroStartEnd(y,1.0 ,4.0) * xEdge ,//Brightness progress * 6.28 * float(uSparkRotation) // rotation
zeroStartEnd(y,0.5 ,4.0) * xEdge,//Size );
progress * 6.28 * float(uSparkRotation) //rotation
);
//set it to the results // set it to the results
result = alphaOver( result = alphaOver(
result, result, vec4(uSparkColor.r, uSparkColor.g, uSparkColor.b, uSparkColor.a * a4ps));
vec4(uSparkColor.r,uSparkColor.g,uSparkColor.b,uSparkColor.a * a4ps)
);
} }
// and we are returning the result // and we are returning the result
return result; return result;
} }
//gets the Rays // gets the Rays
vec4 getRays(float progress) vec4 getRays(float progress) {
{ // create the UV for it
//create the UV for it
vec2 rayUV = iTexCoord.st; vec2 rayUV = iTexCoord.st;
rayUV *= vec2(10.0,0.5); rayUV *= vec2(10.0, 0.5);
rayUV.y += progress * -1.0; rayUV.y += progress * -1.0;
rayUV.x += uSeed.y; rayUV.x += uSeed.y;
//gets the ray // gets the ray
float ray = simplex2D(rayUV); float ray = simplex2D(rayUV);
//0 around the edges // 0 around the edges
ray *= zeroStartEnd(iTexCoord.t,1.0,8.0); ray *= zeroStartEnd(iTexCoord.t, 1.0, 8.0);
ray *= zeroStartEnd(iTexCoord.s,1.0,8.0); ray *= zeroStartEnd(iTexCoord.s, 1.0, 8.0);
// 0 at the begining and end of the animation // 0 at the begining and end of the animation
ray *= zeroStartEnd(progress,1.0,8.0); ray *= zeroStartEnd(progress, 1.0, 8.0);
//adjust the numbers and clamp // adjust the numbers and clamp
ray = remap( ray = remap(ray * 1.10, 0.0, 1.0, -5.0, 1.0);
ray * 1.10,
0.0,1.0,
-5.0,1.0
);
float alpha = clamp(uRaysColor.a * ray,0.0,1.0); float alpha = clamp(uRaysColor.a * ray, 0.0, 1.0);
//return
return vec4(uRaysColor.r,uRaysColor.g,uRaysColor.b,alpha);
// return
return vec4(uRaysColor.r, uRaysColor.g, uRaysColor.b, alpha);
} }
//returns the stars // returns the stars
vec4 getStars(vec2 starUV, float aspect, float progress, float oColorAlpha) vec4 getStars(vec2 starUV, float aspect, float progress, float oColorAlpha) {
{ // this will be the result to return
//this will be the result to return
vec4 result = vec4(0.0); vec4 result = vec4(0.0);
vec2 h = vec2(0.0); vec2 h = vec2(0.0);
float y = 0.0; float y = 0.0;
//for each ring // for each ring
for (float r = 0.0; r < uRingCount; ++r) for (float r = 0.0; r < uRingCount; ++r) {
{
float spread = r*(1.0/uRingCount);
y = mix( 0.0 - spread , 1.0+(1.0-spread) , 1.0 - progress);
y = clamp(y,0.00001,0.99999);
//each star in each ring float spread = r * (1.0 / uRingCount);
for (float s = 0.0; s < uStarCount; ++s) y = mix(0.0 - spread, 1.0 + (1.0 - spread), 1.0 - progress);
{ y = clamp(y, 0.00001, 0.99999);
//this returns a Star // each star in each ring
for (float s = 0.0; s < uStarCount; ++s) {
float a5ps = getStar( // this returns a Star
starUV,
vec2( sin(progress * uRingRotation * 6.28 + (s*(6.28/uStarCount))) * aspect * 0.33 , y), //position (x, y) float a5ps =
5.0, //nPoints getStar(starUV,
0.5, //radiusRatio vec2(sin(progress * uRingRotation * 6.28 + (s * (6.28 / uStarCount))) *
zeroStartEnd(y,0.1,2.0), //Size aspect * 0.33,
0.0 //rotation y), // position (x, y)
5.0, // nPoints
0.5, // radiusRatio
zeroStartEnd(y, 0.1, 2.0), // Size
0.0 // rotation
); );
a5ps = clamp(a5ps,0.0,1.0); a5ps = clamp(a5ps, 0.0, 1.0);
// //put the star in back or the front of the window // //put the star in back or the front of the window
float depth = cos(progress * uRingRotation * 6.28 + (s*(6.28/uStarCount)) ); float depth = cos(progress * uRingRotation * 6.28 + (s * (6.28 / uStarCount)));
//if we want the star behind or infront of the window // if we want the star behind or infront of the window
if (depth < 0.0) if (depth < 0.0) {
{ result = alphaOver(result, getStarColor(y, a5ps));
result = alphaOver(result,getStarColor(y,a5ps)); } else {
} result = alphaOver(getStarColor(y, a5ps) * (1.0 - oColorAlpha), result);
else
{
result = alphaOver(getStarColor(y,a5ps) * (1.0 - oColorAlpha),result);
} }
} }
} }
// and we are returning the result // and we are returning the result
return result; return result;
} }
void main() { void main() {
// Calculate the animation progress, flipping direction if opening // Calculate the animation progress, flipping direction if opening
@@ -414,17 +363,14 @@ void main() {
// Initialize the output color to fully transparent black // Initialize the output color to fully transparent black
vec4 oColor = vec4(0.0, 0.0, 0.0, 0.0); vec4 oColor = vec4(0.0, 0.0, 0.0, 0.0);
// get scales
//get scales
float scale8bit = eightBitScale(progress); float scale8bit = eightBitScale(progress);
vec2 scaleV2 = vec2(easeInOutSine(progress), easeInQuad(progress)); vec2 scaleV2 = vec2(easeInOutSine(progress), easeInQuad(progress));
vec2 fscale = mix(vec2(scale8bit),scaleV2,uScaleStyle); vec2 fscale = mix(vec2(scale8bit), scaleV2, uScaleStyle);
// Fetch the color based on the scaled texture coordinates // Fetch the color based on the scaled texture coordinates
oColor = getInputColor( oColor = getInputColor(scaleUV(iTexCoord.st, fscale));
scaleUV(iTexCoord.st, fscale)
);
// Store the alpha value of the fetched color for later use // Store the alpha value of the fetched color for later use
float oColorAlpha = oColor.a; float oColorAlpha = oColor.a;
@@ -438,26 +384,20 @@ void main() {
vec2 starUV = vec2(iTexCoord.s - 0.5, 1.0 - iTexCoord.t) * vec2(aspect, 1.0); vec2 starUV = vec2(iTexCoord.s - 0.5, 1.0 - iTexCoord.t) * vec2(aspect, 1.0);
// If four-point stars are enabled, overlay them on the current color // If four-point stars are enabled, overlay them on the current color
if (uSparkCount > 0.0) if (uSparkCount > 0.0) {
{
oColor = alphaOver(oColor, getSparks(progress)); oColor = alphaOver(oColor, getSparks(progress));
} }
// If rays are enabled, overlay them on the current color // If rays are enabled, overlay them on the current color
if (uRaysColor.a > 0.0) if (uRaysColor.a > 0.0) {
{
oColor = alphaOver(oColor, getRays(progress)); oColor = alphaOver(oColor, getRays(progress));
} }
// If five-point stars are enabled, overlay them using stored alpha // If five-point stars are enabled, overlay them using stored alpha
if (uRingCount > 0.0 && uStarCount > 0.0) if (uRingCount > 0.0 && uStarCount > 0.0) {
{
oColor = alphaOver(oColor, getStars(starUV, aspect, progress, oColorAlpha)); oColor = alphaOver(oColor, getStars(starUV, aspect, progress, oColorAlpha));
} }
// Set the final output color to the computed value // Set the final output color to the computed value
setOutputColor(oColor); setOutputColor(oColor);
} }
-3
View File
@@ -61,7 +61,6 @@ export var Shader = GObject.registerClass({
}, },
class Shader extends Shell.GLSLEffect { class Shader extends Shell.GLSLEffect {
// -------------------------------------------- // --------------------------------------------
// The constructor automagically loads the shader's source code (in // The constructor automagically loads the shader's source code (in
// vfunc_build_pipeline()) from the resource file resources/shaders/<nick>.glsl // vfunc_build_pipeline()) from the resource file resources/shaders/<nick>.glsl
@@ -209,6 +208,4 @@ export var Shader = GObject.registerClass({
// Add a trailing newline. Else the GLSL compiler complains... // Add a trailing newline. Else the GLSL compiler complains...
return common + '\n' + code + '\n'; return common + '\n' + code + '\n';
} }
}); });
+1 -1
View File
@@ -61,7 +61,7 @@ export default class ShaderFactory {
// Only try to register the new type once. // Only try to register the new type once.
if (GObject.type_from_name(typeName) == null) { if (GObject.type_from_name(typeName) == null) {
const outerThis = this; const outerThis = this;
GObject.registerClass({GTypeName: typeName}, class ShaderImp extends Shader{ GObject.registerClass({GTypeName: typeName}, class ShaderImp extends Shader {
// This will actually load the GLSL source code from the resources. // This will actually load the GLSL source code from the resources.
_init() { _init() {
super._init(outerThis._nick); super._init(outerThis._nick);
+1 -1
View File
@@ -271,7 +271,7 @@ export default class Effect {
}, },
{ {
name: _('Cattuccino 😺'), // A soft pastel palette inspired by a name: _('Cattuccino 😺'), // A soft pastel palette inspired by a
// cappuccino theme // cappuccino theme
ScaleStyle: 1.0, ScaleStyle: 1.0,
SparkCount: 4, SparkCount: 4,
SparkColor: 'rgba(255,255,255,1.0)', SparkColor: 'rgba(255,255,255,1.0)',
-2
View File
@@ -172,6 +172,4 @@ export function parseColor(string) {
return [color.red / 255, color.green / 255, color.blue / 255, color.alpha / 255]; return [color.red / 255, color.green / 255, color.blue / 255, color.alpha / 255];
} }