@@ -39,25 +39,23 @@ uniform float uFadeOut;
39
39
uniform float uBlur;
40
40
uniform vec2 uSeed;
41
41
42
-
43
42
/*
44
43
this controls the end shape
45
44
-5.0 large Star
46
45
-3.0 Star
47
46
1.0 Dimond
48
47
2.0 Circle
49
- 3.0 Squircle
48
+ 3.0 Squircle
50
49
5.0 Square
51
50
*/
52
51
uniform float uEdgeShape;
53
52
54
- // the size of the edge color
53
+ // the size of the edge color
55
54
uniform float uEdgeSize;
56
55
57
- // soft <--> hard
56
+ // soft <--> hard
58
57
uniform float uEdgeHardness;
59
58
60
-
61
59
// A simple blur function
62
60
vec4 blur(vec2 uv, float radius, float samples) {
63
61
vec4 color = vec4 (0.0 );
@@ -77,122 +75,107 @@ vec4 blur(vec2 uv, float radius, float samples) {
77
75
78
76
void main() {
79
77
80
- // This gradually dissolves from [1..0] from the outside to the center. We
81
- // switch the direction for opening and closing.
82
- float progress = uForOpening ? uProgress : 1.0 - uProgress ;
83
-
84
- // adjusting for Gnome
85
- if (uPadding > 0.0 )
86
- {
87
- progress = remap(
88
- progress, 0.0 , ((uSize.x - (uPadding* 2.0 )) / uSize.x)
89
- ,0.0 , 1.0
90
- );
91
- }
92
-
93
-
94
- // Get the color from the window texture.
95
- vec4 oColor = getInputColor(iTexCoord.st);
96
-
97
- // Calculate the aspect ratio of the render area
98
- float aspect = uSize.x / uSize.y;
99
-
100
- // standard uv
101
- vec2 uv = iTexCoord.st;
102
-
103
- // tuv is for when progress is near 0
104
- vec2 tuv = uv;
105
- tuv -= 0.5 ; // Shift UV coordinates to center (from [-0.5 to 0.5])
106
- tuv.x *= aspect; // Scale x-coordinate to match aspect ratio
107
- tuv += 0.5 ; // Shift UV coordinates back (from [0 to 1])
108
-
109
- // mixing the UVs
110
- uv = mix (tuv,uv,easeOutExpo(progress));
111
-
112
- // this controls the shape
113
- // -1.0 would be a diamond-ish
114
- // 0.0 would be a rounded diamond
115
- // 1.0 would be a circle
116
- // 2.0 will be sqircle
117
- // 1000.0 will be very square
118
- float p = mix (uEdgeShape,1000.0 ,
119
- easeInExpo(progress)
120
- );
121
-
122
- // this will be used later to make a mask
123
- float m = mix (
124
- 0.0 ,
125
- 1.0 ,
126
- clamp (
127
- pow (abs (uv.x- 0.5 )* 2.0 ,p) + pow (abs (uv.y- 0.5 )* 2.0 ,p),0.0 ,1.0
128
- )
129
- );
130
-
131
-
132
- // this calculates the edge of the effect
133
- float edge = abs (m- progress) ;
134
- float e = mix (0.0 ,uEdgeSize,1.0 - progress);
135
- edge = remap(edge,0.0 ,e,0.0 ,1.0 );
136
- edge = clamp (edge,0.0 ,1.0 );
137
- edge = 1.0 - edge;
138
-
139
- // this is the mask
140
- float mask = (m > progress) ? 0.0 : 1.0 ;
141
-
142
- // we need two of these
143
- float mask0 = mix (mask,mask+ edge,1.0 - uEdgeHardness);
144
- float mask1 = mix (edge,edge* mask,uEdgeHardness);
145
-
146
- // calculate color
147
- vec3 color = cos (progress* uColorSpeed+ uv.xyx+ vec3 (0 ,2 ,4 )).xyz;
148
- // coloroffset
149
- float colorOffset = (uRandomColorOffset) ? hash12(uSeed) : uColorOffset ;
150
- color = offsetHue(color, colorOffset + 0.10 );
151
- // clamp and saturate
152
- color = clamp (color * uColorSaturation,vec3 (0.0 ),vec3 (1.0 ));
153
-
154
- // save this for later
155
- float oColorAlpha = oColor.a;
156
-
157
- // blur-ify
158
- if (uBlur > 0.0 )
159
- {
160
- // used for blur later ...
161
- // calculate this before saturating it
162
- float b = (color.r + color.g + color.b)/ 3.0 ;
163
-
164
-
165
- oColor = blur( iTexCoord.st, b * uBlur * mask1, 7.0 );
166
- }
78
+ // This gradually dissolves from [1..0] from the outside to the center. We
79
+ // switch the direction for opening and closing.
80
+ float progress = uForOpening ? uProgress : 1.0 - uProgress;
167
81
168
- // apply masks and colors
169
- oColor.a *= mask0;
170
-
171
- // i was doing this to try to adjust for light mode
172
- // i don;t like the way these make the effect look
173
- // ...maybe a toggle for it later
174
- /*
175
- float oColorPercent = (oColor.r + oColor.g + oColor.b)/3.0;
176
- oColor.r = mix(oColor.r , 1.0 - oColor.r, mask1 * oColorPercent);
177
- oColor.g = mix(oColor.g , 1.0 - oColor.g, mask1 * oColorPercent);
178
- oColor.b = mix(oColor.b , 1.0 - oColor.b, mask1 * oColorPercent);
179
- // --or
180
- oColor.r = mix(oColor.r , 0.0, mask1 * oColorPercent);
181
- oColor.g = mix(oColor.g , 0.0, mask1 * oColorPercent);
182
- oColor.b = mix(oColor.b , 0.0, mask1 * oColorPercent);
183
- */
184
-
185
- oColor += mask1 * vec4 (color.rgb,1.0 );
186
- oColor.a *= oColorAlpha;
187
-
188
- // i want to fade out the last ~10% of the animation
189
- float lastfade = remap(progress,0.0 ,uFadeOut,0.0 ,1.0 );
190
- lastfade = clamp (lastfade,0.0 ,1.0 );
191
- lastfade = easeInSine(lastfade);
192
-
193
- // apply the lastfade
194
- oColor.a *= lastfade;
195
-
196
- setOutputColor(oColor);
82
+ // adjusting for Gnome
83
+ if (uPadding > 0.0 ) {
84
+ progress = remap(progress, 0.0 , ((uSize.x - (uPadding * 2.0 )) / uSize.x), 0.0 , 1.0 );
85
+ }
86
+
87
+ // Get the color from the window texture.
88
+ vec4 oColor = getInputColor(iTexCoord.st);
89
+
90
+ // Calculate the aspect ratio of the render area
91
+ float aspect = uSize.x / uSize.y;
92
+
93
+ // standard uv
94
+ vec2 uv = iTexCoord.st;
95
+
96
+ // tuv is for when progress is near 0
97
+ vec2 tuv = uv;
98
+ tuv -= 0.5 ; // Shift UV coordinates to center (from [-0.5 to 0.5])
99
+ tuv.x *= aspect; // Scale x-coordinate to match aspect ratio
100
+ tuv += 0.5 ; // Shift UV coordinates back (from [0 to 1])
101
+
102
+ // mixing the UVs
103
+ uv = mix (tuv, uv, easeOutExpo(progress));
104
+
105
+ // this controls the shape
106
+ // -1.0 would be a diamond-ish
107
+ // 0.0 would be a rounded diamond
108
+ // 1.0 would be a circle
109
+ // 2.0 will be sqircle
110
+ // 1000.0 will be very square
111
+ float p = mix (uEdgeShape, 1000.0 , easeInExpo(progress));
112
+
113
+ // this will be used later to make a mask
114
+ float m =
115
+ mix (0.0 , 1.0 ,
116
+ clamp (pow (abs (uv.x - 0.5 ) * 2.0 , p) + pow (abs (uv.y - 0.5 ) * 2.0 , p), 0.0 , 1.0 ));
117
+
118
+ // this calculates the edge of the effect
119
+ float edge = abs (m - progress);
120
+ float e = mix (0.0 , uEdgeSize, 1.0 - progress);
121
+ edge = remap(edge, 0.0 , e, 0.0 , 1.0 );
122
+ edge = clamp (edge, 0.0 , 1.0 );
123
+ edge = 1.0 - edge;
124
+
125
+ // this is the mask
126
+ float mask = (m > progress) ? 0.0 : 1.0 ;
127
+
128
+ // we need two of these
129
+ float mask0 = mix (mask, mask + edge, 1.0 - uEdgeHardness);
130
+ float mask1 = mix (edge, edge * mask, uEdgeHardness);
131
+
132
+ // calculate color
133
+ vec3 color = cos (progress * uColorSpeed + uv.xyx + vec3 (0 , 2 , 4 )).xyz;
134
+ // coloroffset
135
+ float colorOffset = (uRandomColorOffset) ? hash12(uSeed) : uColorOffset;
136
+ color = offsetHue(color, colorOffset + 0.10 );
137
+ // clamp and saturate
138
+ color = clamp (color * uColorSaturation, vec3 (0.0 ), vec3 (1.0 ));
139
+
140
+ // save this for later
141
+ float oColorAlpha = oColor.a;
142
+
143
+ // blur-ify
144
+ if (uBlur > 0.0 ) {
145
+ // used for blur later ...
146
+ // calculate this before saturating it
147
+ float b = (color.r + color.g + color.b) / 3.0 ;
148
+
149
+ oColor = blur(iTexCoord.st, b * uBlur * mask1, 7.0 );
150
+ }
197
151
152
+ // apply masks and colors
153
+ oColor.a *= mask0;
154
+
155
+ // i was doing this to try to adjust for light mode
156
+ // i don;t like the way these make the effect look
157
+ // ...maybe a toggle for it later
158
+ /*
159
+ float oColorPercent = (oColor.r + oColor.g + oColor.b)/3.0;
160
+ oColor.r = mix(oColor.r , 1.0 - oColor.r, mask1 * oColorPercent);
161
+ oColor.g = mix(oColor.g , 1.0 - oColor.g, mask1 * oColorPercent);
162
+ oColor.b = mix(oColor.b , 1.0 - oColor.b, mask1 * oColorPercent);
163
+ // --or
164
+ oColor.r = mix(oColor.r , 0.0, mask1 * oColorPercent);
165
+ oColor.g = mix(oColor.g , 0.0, mask1 * oColorPercent);
166
+ oColor.b = mix(oColor.b , 0.0, mask1 * oColorPercent);
167
+ */
168
+
169
+ oColor += mask1 * vec4 (color.rgb, 1.0 );
170
+ oColor.a *= oColorAlpha;
171
+
172
+ // i want to fade out the last ~10% of the animation
173
+ float lastfade = remap(progress, 0.0 , uFadeOut, 0.0 , 1.0 );
174
+ lastfade = clamp (lastfade, 0.0 , 1.0 );
175
+ lastfade = easeInSine(lastfade);
176
+
177
+ // apply the lastfade
178
+ oColor.a *= lastfade;
179
+
180
+ setOutputColor(oColor);
198
181
}
0 commit comments