✨ Apply clang-format
This commit is contained in:
@@ -39,7 +39,6 @@ uniform float uFadeOut;
|
||||
uniform float uBlur;
|
||||
uniform vec2 uSeed;
|
||||
|
||||
|
||||
/*
|
||||
this controls the end shape
|
||||
-5.0 large Star
|
||||
@@ -57,7 +56,6 @@ uniform float uEdgeSize;
|
||||
// soft <--> hard
|
||||
uniform float uEdgeHardness;
|
||||
|
||||
|
||||
// A simple blur function
|
||||
vec4 blur(vec2 uv, float radius, float samples) {
|
||||
vec4 color = vec4(0.0);
|
||||
@@ -82,15 +80,10 @@ void main() {
|
||||
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
|
||||
);
|
||||
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);
|
||||
|
||||
@@ -115,19 +108,12 @@ void main() {
|
||||
// 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)
|
||||
);
|
||||
float p = mix(uEdgeShape, 1000.0, easeInExpo(progress));
|
||||
|
||||
// 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
|
||||
)
|
||||
);
|
||||
|
||||
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 calculates the edge of the effect
|
||||
float edge = abs(m - progress);
|
||||
@@ -155,13 +141,11 @@ void main() {
|
||||
float oColorAlpha = oColor.a;
|
||||
|
||||
// blur-ify
|
||||
if (uBlur > 0.0)
|
||||
{
|
||||
if (uBlur > 0.0) {
|
||||
// used for blur later ...
|
||||
// calculate this before saturating it
|
||||
float b = (color.r + color.g + color.b) / 3.0;
|
||||
|
||||
|
||||
oColor = blur(iTexCoord.st, b * uBlur * mask1, 7.0);
|
||||
}
|
||||
|
||||
@@ -194,5 +178,4 @@ void main() {
|
||||
oColor.a *= lastfade;
|
||||
|
||||
setOutputColor(oColor);
|
||||
|
||||
}
|
||||
+53
-113
@@ -60,15 +60,11 @@ uniform vec4 uStarColor5;
|
||||
uniform vec2 uSeed;
|
||||
|
||||
// helps to find the angle
|
||||
vec3 getPosByAngle(float angle)
|
||||
{
|
||||
return vec3(cos(angle), sin(angle), 0);
|
||||
}
|
||||
|
||||
vec3 getPosByAngle(float angle) { 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 getStar(vec2 uv, vec2 center, float npoints, float radiusRatio, float size,
|
||||
float rotation) {
|
||||
|
||||
float radiusMax = 1.0;
|
||||
float radiusMin = radiusMax * radiusRatio;
|
||||
@@ -79,17 +75,23 @@ float getStar(vec2 uv, vec2 center, float npoints, float radiusRatio, float size
|
||||
// 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
|
||||
// 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
|
||||
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`
|
||||
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
|
||||
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)
|
||||
|
||||
@@ -102,13 +104,12 @@ float getStar(vec2 uv, vec2 center, float npoints, float radiusRatio, float size
|
||||
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)
|
||||
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)
|
||||
{
|
||||
vec2 scaleUV(vec2 uv, vec2 scale) {
|
||||
// Put texture coordinate origin to center of window.
|
||||
uv = uv * 2.0 - 1.0;
|
||||
|
||||
@@ -121,10 +122,8 @@ vec2 scaleUV(vec2 uv, vec2 scale)
|
||||
return uv;
|
||||
}
|
||||
|
||||
|
||||
// this returns the Spark
|
||||
float getSpark(vec2 uv, vec2 center, float brightness, float size, float rotation)
|
||||
{
|
||||
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
|
||||
@@ -137,23 +136,16 @@ float getSpark(vec2 uv, vec2 center, float brightness, float size, float rotatio
|
||||
// this is basically the brightness
|
||||
float p = mix(-1.0, 1000.0, easeInExpo(bn));
|
||||
|
||||
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
|
||||
)
|
||||
);
|
||||
|
||||
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));
|
||||
|
||||
float mask = easeInSine(1.0 - (m - bn)) - 0.004;
|
||||
mask = clamp(mask, 0.0, 1.0);
|
||||
|
||||
return mask;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// returns the star's color
|
||||
vec4 getStarColor(float v, float alpha) {
|
||||
// Clamp v to ensure it's in [0.0, 1.0]
|
||||
@@ -202,8 +194,6 @@ vec4 getStarColor(float v, float alpha) {
|
||||
return vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 1| __________
|
||||
// | / \
|
||||
// | / \
|
||||
@@ -215,60 +205,39 @@ 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
|
||||
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;
|
||||
s = clamp(s, 0.0, 1.0) * max_size;
|
||||
return s;
|
||||
}
|
||||
|
||||
// this gives us the jerky 8bit growth effect.
|
||||
float eightBitScale(float progress)
|
||||
{
|
||||
float eightBitScale(float progress) {
|
||||
float scale = 1.0;
|
||||
if (progress <= 0.1)
|
||||
{
|
||||
if (progress <= 0.1) {
|
||||
scale = 0.25;
|
||||
}
|
||||
else if (progress <= 0.2)
|
||||
{
|
||||
} else if (progress <= 0.2) {
|
||||
scale = 0.5;
|
||||
}
|
||||
else if (progress <= 0.3)
|
||||
{
|
||||
} else if (progress <= 0.3) {
|
||||
scale = 0.25;
|
||||
}
|
||||
else if (progress <= 0.4)
|
||||
{
|
||||
} else if (progress <= 0.4) {
|
||||
scale = 0.5;
|
||||
}
|
||||
else if (progress <= 0.5)
|
||||
{
|
||||
} else if (progress <= 0.5) {
|
||||
scale = 0.25;
|
||||
}
|
||||
else if (progress <= 0.6)
|
||||
{
|
||||
} else if (progress <= 0.6) {
|
||||
scale = 0.5;
|
||||
}
|
||||
else if (progress <= 0.7)
|
||||
{
|
||||
} else if (progress <= 0.7) {
|
||||
scale = 1.0;
|
||||
}
|
||||
else if (progress <= 0.8)
|
||||
{
|
||||
} else if (progress <= 0.8) {
|
||||
scale = 0.25;
|
||||
}
|
||||
else if (progress <= 0.9)
|
||||
{
|
||||
} else if (progress <= 0.9) {
|
||||
scale = 0.5;
|
||||
}
|
||||
return scale;
|
||||
}
|
||||
|
||||
|
||||
// gets all the sparks
|
||||
vec4 getSparks(float progress)
|
||||
{
|
||||
vec4 getSparks(float progress) {
|
||||
// the UV for this function
|
||||
float aspect = uSize.x / uSize.y;
|
||||
vec2 uv = iTexCoord.st * vec2(aspect, 1.0);
|
||||
@@ -286,8 +255,7 @@ vec4 getSparks(float progress)
|
||||
float x = 0.0;
|
||||
|
||||
// loop for each spart
|
||||
for (float xusp = 0.0; xusp < uSparkCount; ++xusp)
|
||||
{
|
||||
for (float xusp = 0.0; xusp < uSparkCount; ++xusp) {
|
||||
// calculate some variables
|
||||
h = hash21(xusp + uSeed.x);
|
||||
y = mix(0.0 - h.y, 1.0 + (1.0 - h.y), progress);
|
||||
@@ -297,9 +265,7 @@ vec4 getSparks(float progress)
|
||||
x += 0.5 * aspect;
|
||||
|
||||
// here we get the mask for the spark
|
||||
float a4ps = getSpark(
|
||||
uv,
|
||||
vec2( x , y), //position (x, y)
|
||||
float a4ps = getSpark(uv, vec2(x, y), // position (x, y)
|
||||
zeroStartEnd(y, 1.0, 4.0) * xEdge, // Brightness
|
||||
zeroStartEnd(y, 0.5, 4.0) * xEdge, // Size
|
||||
progress * 6.28 * float(uSparkRotation) // rotation
|
||||
@@ -307,9 +273,7 @@ vec4 getSparks(float progress)
|
||||
|
||||
// set it to the results
|
||||
result = alphaOver(
|
||||
result,
|
||||
vec4(uSparkColor.r,uSparkColor.g,uSparkColor.b,uSparkColor.a * a4ps)
|
||||
);
|
||||
result, vec4(uSparkColor.r, uSparkColor.g, uSparkColor.b, uSparkColor.a * a4ps));
|
||||
}
|
||||
|
||||
// and we are returning the result
|
||||
@@ -317,8 +281,7 @@ vec4 getSparks(float progress)
|
||||
}
|
||||
|
||||
// gets the Rays
|
||||
vec4 getRays(float progress)
|
||||
{
|
||||
vec4 getRays(float progress) {
|
||||
// create the UV for it
|
||||
vec2 rayUV = iTexCoord.st;
|
||||
rayUV *= vec2(10.0, 0.5);
|
||||
@@ -334,22 +297,16 @@ vec4 getRays(float progress)
|
||||
ray *= zeroStartEnd(progress, 1.0, 8.0);
|
||||
|
||||
// adjust the numbers and clamp
|
||||
ray = remap(
|
||||
ray * 1.10,
|
||||
0.0,1.0,
|
||||
-5.0,1.0
|
||||
);
|
||||
ray = remap(ray * 1.10, 0.0, 1.0, -5.0, 1.0);
|
||||
|
||||
float alpha = clamp(uRaysColor.a * ray, 0.0, 1.0);
|
||||
|
||||
// return
|
||||
return vec4(uRaysColor.r, uRaysColor.g, uRaysColor.b, alpha);
|
||||
|
||||
}
|
||||
|
||||
// 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
|
||||
vec4 result = vec4(0.0);
|
||||
|
||||
@@ -357,22 +314,22 @@ vec4 getStars(vec2 starUV, float aspect, float progress, float oColorAlpha)
|
||||
float y = 0.0;
|
||||
|
||||
// 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
|
||||
for (float s = 0.0; s < uStarCount; ++s)
|
||||
{
|
||||
for (float s = 0.0; s < uStarCount; ++s) {
|
||||
|
||||
// this returns a Star
|
||||
|
||||
float a5ps = getStar(
|
||||
starUV,
|
||||
vec2( sin(progress * uRingRotation * 6.28 + (s*(6.28/uStarCount))) * aspect * 0.33 , y), //position (x, y)
|
||||
float a5ps =
|
||||
getStar(starUV,
|
||||
vec2(sin(progress * uRingRotation * 6.28 + (s * (6.28 / uStarCount))) *
|
||||
aspect * 0.33,
|
||||
y), // position (x, y)
|
||||
5.0, // nPoints
|
||||
0.5, // radiusRatio
|
||||
zeroStartEnd(y, 0.1, 2.0), // Size
|
||||
@@ -385,26 +342,18 @@ vec4 getStars(vec2 starUV, float aspect, float progress, float oColorAlpha)
|
||||
|
||||
// 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));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
result = alphaOver(getStarColor(y, a5ps) * (1.0 - oColorAlpha), result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// and we are returning the result
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
// Calculate the animation progress, flipping direction if opening
|
||||
@@ -414,7 +363,6 @@ void main() {
|
||||
// Initialize the output color to fully transparent black
|
||||
vec4 oColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
|
||||
// get scales
|
||||
float scale8bit = eightBitScale(progress);
|
||||
vec2 scaleV2 = vec2(easeInOutSine(progress), easeInQuad(progress));
|
||||
@@ -422,9 +370,7 @@ void main() {
|
||||
vec2 fscale = mix(vec2(scale8bit), scaleV2, uScaleStyle);
|
||||
|
||||
// Fetch the color based on the scaled texture coordinates
|
||||
oColor = getInputColor(
|
||||
scaleUV(iTexCoord.st, fscale)
|
||||
);
|
||||
oColor = getInputColor(scaleUV(iTexCoord.st, fscale));
|
||||
|
||||
// Store the alpha value of the fetched color for later use
|
||||
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);
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
|
||||
// Set the final output color to the computed value
|
||||
setOutputColor(oColor);
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ export var Shader = GObject.registerClass({
|
||||
},
|
||||
|
||||
class Shader extends Shell.GLSLEffect {
|
||||
|
||||
// --------------------------------------------
|
||||
// The constructor automagically loads the shader's source code (in
|
||||
// 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...
|
||||
return common + '\n' + code + '\n';
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -172,6 +172,4 @@ export function parseColor(string) {
|
||||
|
||||
|
||||
return [color.red / 255, color.green / 255, color.blue / 255, color.alpha / 255];
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user