gl-transitions 1.63.0 → 1.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Author: huynx
|
|
2
2
|
// License: MIT
|
|
3
3
|
|
|
4
|
-
vec2 bottom_left = vec2(0.0, 1.0);
|
|
5
|
-
vec2 bottom_right = vec2(1.0, 1.0);
|
|
6
|
-
vec2 top_left = vec2(0.0, 0.0);
|
|
7
|
-
vec2 top_right = vec2(1.0, 0.0);
|
|
8
|
-
vec2 center = vec2(0.5, 0.5);
|
|
4
|
+
const vec2 bottom_left = vec2(0.0, 1.0);
|
|
5
|
+
const vec2 bottom_right = vec2(1.0, 1.0);
|
|
6
|
+
const vec2 top_left = vec2(0.0, 0.0);
|
|
7
|
+
const vec2 top_right = vec2(1.0, 0.0);
|
|
8
|
+
const vec2 center = vec2(0.5, 0.5);
|
|
9
9
|
|
|
10
10
|
float check(vec2 p1, vec2 p2, vec2 p3)
|
|
11
11
|
{
|
|
@@ -3,26 +3,28 @@
|
|
|
3
3
|
uniform float amplitude; // = 1.0
|
|
4
4
|
uniform float waves; // = 30.0
|
|
5
5
|
uniform float colorSeparation; // = 0.3
|
|
6
|
-
float PI = 3.14159265358979323846264;
|
|
6
|
+
const float PI = 3.14159265358979323846264;
|
|
7
7
|
float compute(vec2 p, float progress, vec2 center) {
|
|
8
8
|
vec2 o = p*sin(progress * amplitude)-center;
|
|
9
9
|
// horizontal vector
|
|
10
10
|
vec2 h = vec2(1., 0.);
|
|
11
11
|
// butterfly polar function (don't ask me why this one :))
|
|
12
12
|
float theta = acos(dot(o, h)) * waves;
|
|
13
|
-
|
|
13
|
+
float s = sin((2.*theta - PI) / 24.);
|
|
14
|
+
float s2 = s * s;
|
|
15
|
+
return (exp(cos(theta)) - 2.*cos(4.*theta) + s2 * s2 * s) / 10.;
|
|
14
16
|
}
|
|
15
17
|
vec4 transition(vec2 uv) {
|
|
16
|
-
|
|
18
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
19
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
20
|
+
vec2 p = uv;
|
|
17
21
|
float inv = 1. - progress;
|
|
18
|
-
|
|
19
|
-
float dist = length(dir);
|
|
20
|
-
float disp = compute(p, progress, vec2(0.5, 0.5)) ;
|
|
22
|
+
float disp = compute(p, progress, vec2(0.5, 0.5));
|
|
21
23
|
vec4 texTo = getToColor(p + inv*disp);
|
|
22
24
|
vec4 texFrom = vec4(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
getFromColor(p + progress*disp*(1.0 - colorSeparation)).r,
|
|
26
|
+
getFromColor(p + progress*disp).g,
|
|
27
|
+
getFromColor(p + progress*disp*(1.0 + colorSeparation)).b,
|
|
28
|
+
1.0);
|
|
27
29
|
return texTo*progress + texFrom*inv;
|
|
28
30
|
}
|