From e90353b0c548d12310a78119a057ec9d34269043 Mon Sep 17 00:00:00 2001 From: Justin Garza Date: Tue, 21 Jan 2025 19:46:15 -0500 Subject: [PATCH] using clang-format-16 and a bit more comments and a minor adjustment --- resources/shaders/mushroom.frag | 3 +++ resources/shaders/rgbwarp.frag | 22 +++++++++++----------- resources/shaders/team-rocket.frag | 17 ++++++++--------- resources/shaders/unicorn-fart.frag | 20 +++++++++++--------- src/Shader.js | 2 +- src/ShaderFactory.js | 2 +- 6 files changed, 35 insertions(+), 31 deletions(-) diff --git a/resources/shaders/mushroom.frag b/resources/shaders/mushroom.frag index d7905f8..6b81741 100644 --- a/resources/shaders/mushroom.frag +++ b/resources/shaders/mushroom.frag @@ -367,6 +367,7 @@ vec4 getStars(vec2 starUV, float aspect, float progress, float oColorAlpha) //each star in each ring 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) @@ -379,6 +380,8 @@ vec4 getStars(vec2 starUV, float aspect, float progress, float oColorAlpha) // //put the star in back or the front of the window float depth = cos(progress * uRingRotation * 6.28 + (s*(6.28/uStarCount)) ); + + //if we want the star behind or infront of the window if (depth < 0.0) { result = alphaOver(result,getStarColor(y,a5ps)); diff --git a/resources/shaders/rgbwarp.frag b/resources/shaders/rgbwarp.frag index 18885f4..0fc18eb 100644 --- a/resources/shaders/rgbwarp.frag +++ b/resources/shaders/rgbwarp.frag @@ -45,8 +45,6 @@ float FadeInOut(float t, float power) } - - void main() { // Calculate the progression value based on the animation direction. @@ -64,27 +62,29 @@ void main() { // w is the wave float w = 0.0; + //w will be used to calculate the the size of the wave float p = mix(0.0, 1.0 + uWavesize, progress); w = 1.0 - abs(p - f.y); w = clamp(w,0.0,1.0); - w = pow(w, mix(100.0,1.0,uWavesize) ); - float mask = 1.0; - if (p - f.y < 0.0) - { - mask = 0.0; - w = 0.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 - oColor.a = getInputColor(uv).a * easeInOutSine(progress) * mask; + if (oColor.r + oColor.g + oColor.b > 0.0) + { + oColor.a = getInputColor(uv).a ; + } + else + { + oColor.a = 0.0; + } setOutputColor(oColor); diff --git a/resources/shaders/team-rocket.frag b/resources/shaders/team-rocket.frag index e21a1f1..63c7b3a 100644 --- a/resources/shaders/team-rocket.frag +++ b/resources/shaders/team-rocket.frag @@ -31,15 +31,15 @@ // void setOutputColor(vec4 outColor) // The width of the fading effect is loaded from the settings. -// uniform float uFadeWidth; -uniform float uWT; -uniform float uXpos; -uniform float uYpos; -uniform float uSparkleRot; -uniform float uSparkleSize; -uniform bool uWinRot; -uniform vec2 uSeed; +//variables +uniform float uWT; //window time ... how we split the time between the window and the sparkle/star +uniform float uXpos; // the Xposition of the star +uniform float uYpos; // the Yposition of the star +uniform float uSparkleRot; //the rotation of the star +uniform float uSparkleSize; // the size of the star +uniform bool uWinRot; //window rotation... but it's more of a warp +uniform vec2 uSeed; // and random numbers //use to scale the window vec2 scaleUV(vec2 uv, vec2 scale, vec2 centerOffset) @@ -54,7 +54,6 @@ vec2 scaleUV(vec2 uv, vec2 scale, vec2 centerOffset) // scale from center uv = uv * 0.5 + 0.5; - return uv; } diff --git a/resources/shaders/unicorn-fart.frag b/resources/shaders/unicorn-fart.frag index 7a63590..9ae9175 100644 --- a/resources/shaders/unicorn-fart.frag +++ b/resources/shaders/unicorn-fart.frag @@ -32,15 +32,16 @@ // The width of the fading effect is loaded from the settings. -uniform float uSparkCount; -uniform vec2 uSparkStartEnd; -uniform float uSparkOffset; -uniform float uStarCount; -uniform float uStarRot; -uniform float uStarSize; -uniform vec2 uStarStartEnd; -uniform float uBlurQuality; -uniform float uSeed; +//variables +uniform float uSparkCount; //number of sparkles +uniform vec2 uSparkStartEnd; // the start and end of the sparkles +uniform float uSparkOffset; //how much the sparkles can be offset +uniform float uStarCount; //number of Stars +uniform float uStarRot; // how much the stars rotate +uniform float uStarSize; // the size of the stars +uniform vec2 uStarStartEnd; //start and end of the star's movement +uniform float uBlurQuality; // blurquality for the window +uniform float uSeed; // a random number //particle colors @@ -517,5 +518,6 @@ void main() { oColor = alphaOver(oColor, getStars(mix(0.0001,0.999,ioSine))); } + //output setOutputColor(oColor); } \ No newline at end of file diff --git a/src/Shader.js b/src/Shader.js index 2a06f1e..2d19502 100644 --- a/src/Shader.js +++ b/src/Shader.js @@ -59,7 +59,7 @@ export var Shader = GObject.registerClass({ 'end-animation': {} } }, - class Shader extends Shell.GLSLEffect{ + class Shader extends Shell.GLSLEffect { // -------------------------------------------- // The constructor automagically loads the shader's source code (in // vfunc_build_pipeline()) from the resource file resources/shaders/.glsl diff --git a/src/ShaderFactory.js b/src/ShaderFactory.js index 06fbea7..6056262 100644 --- a/src/ShaderFactory.js +++ b/src/ShaderFactory.js @@ -61,7 +61,7 @@ export default class ShaderFactory { // Only try to register the new type once. if (GObject.type_from_name(typeName) == null) { 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. _init() { super._init(outerThis._nick);