gl-transitions 3.1.0 → 3.2.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/compatibility.json +96 -0
  3. package/gl-transitions.js +1 -1
  4. package/gl-transitions.json +1 -1
  5. package/glsl3/CircleBurst.glsl +77 -0
  6. package/glsl3/CodeRain.glsl +114 -0
  7. package/glsl3/CurtainRise.glsl +71 -0
  8. package/glsl3/GravityLens.glsl +66 -0
  9. package/glsl3/RingSpin.glsl +112 -0
  10. package/glsl3/SpotlightWipe.glsl +63 -0
  11. package/index.js +1 -1
  12. package/layouts.json +231 -0
  13. package/llms-full.txt +521 -422
  14. package/llms.txt +225 -219
  15. package/msl/CircleBurst.metal +351 -0
  16. package/msl/CodeRain.metal +451 -0
  17. package/msl/CurtainRise.metal +263 -0
  18. package/msl/GravityLens.metal +236 -0
  19. package/msl/RingSpin.metal +474 -0
  20. package/msl/SpotlightWipe.metal +217 -0
  21. package/package.json +1 -1
  22. package/skills/gl-transitions/references/catalog.md +31 -19
  23. package/sksl/CircleBurst.sksl +84 -0
  24. package/sksl/CodeRain.sksl +124 -0
  25. package/sksl/CurtainRise.sksl +84 -0
  26. package/sksl/GravityLens.sksl +77 -0
  27. package/sksl/RingSpin.sksl +121 -0
  28. package/sksl/SpotlightWipe.sksl +74 -0
  29. package/sksl/index.js +1 -1
  30. package/transitions/CircleBurst.glsl +76 -0
  31. package/transitions/CodeRain.glsl +113 -0
  32. package/transitions/CurtainRise.glsl +70 -0
  33. package/transitions/GravityLens.glsl +65 -0
  34. package/transitions/RingSpin.glsl +111 -0
  35. package/transitions/SpotlightWipe.glsl +62 -0
  36. package/wgsl/CircleBurst.wgsl +310 -0
  37. package/wgsl/CodeRain.wgsl +415 -0
  38. package/wgsl/CurtainRise.wgsl +235 -0
  39. package/wgsl/GravityLens.wgsl +206 -0
  40. package/wgsl/RingSpin.wgsl +426 -0
  41. package/wgsl/SpotlightWipe.wgsl +186 -0
@@ -0,0 +1,84 @@
1
+ // CurtainRise — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CurtainRise.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image rises like a theater festoon curtain: cords lift its hem into scalloped swags while the fabric gathers into shaded ruffles, and it is drawn up out of the frame over the incoming image
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform float swags;
16
+
17
+ uniform float sag;
18
+
19
+ uniform float ruffles;
20
+
21
+ uniform float shading;
22
+
23
+ const float PI = 3.141592653589793;
24
+
25
+ vec4 transition (vec2 uv) {
26
+ float p = progress;
27
+
28
+ float f = 1.0 - (1.0 - p) * (1.0 - p) * (1.0 - p);
29
+
30
+ float e = mix(p, p * p * (3.0 - 2.0 * p), 0.4);
31
+ float s = sag * f;
32
+ float lift = mix(-0.01, 1.0 + sag + 0.08, e);
33
+
34
+ float n = max(1.0, floor(swags * sqrt(ratio / 1.78) + 0.5));
35
+ float u = fract(uv.x * n) * 2.0 - 1.0;
36
+ float bump = 1.0 - u * u;
37
+ float hem = lift - s * bump;
38
+ float aa = 0.002 + 0.004 * f;
39
+ float inside = smoothstep(hem - aa, hem + aa, uv.y);
40
+
41
+ vec4 c = vec4(0.0);
42
+ if (inside > 0.0) {
43
+
44
+ float h = max(1.0 - max(hem, 0.0), 1e-4);
45
+ float q = clamp((1.0 - uv.y) / h, 0.0, 1.0);
46
+
47
+
48
+ float m = min(max(1.0, floor(ruffles + 0.5)), h / 0.02);
49
+ float a = 2.0 * PI * m * q;
50
+
51
+ float g = 0.85 * f * min(1.0, 0.3 + 5.0 * (1.0 - h)) * (0.6 + 0.4 * bump);
52
+ float v = clamp(q + g * sin(a) / (2.0 * PI * m), 0.0, 1.0);
53
+
54
+ float pull = 0.25 * f * q * q * sin(PI * u) / (PI * n);
55
+ c = getFromColor(vec2(uv.x - pull, 1.0 - v));
56
+
57
+
58
+ float slope = 2.5 * g * cos(a);
59
+ float diffuse = (1.0 - 0.35 * slope) / sqrt(1.0 + slope * slope);
60
+ float crease = 0.5 + 0.5 * sin(a);
61
+ float light = mix(1.0, diffuse * (1.0 - 0.45 * crease * crease), shading * g);
62
+
63
+ light += 0.18 * shading * g * smoothstep(0.4, 1.0, -cos(a));
64
+
65
+ float depth = f * q * (0.3 + 0.7 * q);
66
+ light *= 1.0 - shading * depth * (0.35 * u * u + 0.5 * exp(-(1.0 - abs(u)) * 14.0));
67
+
68
+ light *= 1.0 - 0.35 * shading * f * exp(-(uv.y - hem) * 120.0);
69
+ c.rgb *= light;
70
+ if (inside >= 1.0) return c;
71
+ }
72
+ vec4 to = getToColor(uv);
73
+
74
+ float below = max(hem - uv.y, 0.0);
75
+ float shadow = 0.6 * shading * exp(-below * 22.0) * smoothstep(0.0, 0.05, lift) * (1.0 - smoothstep(1.0, 1.06, lift - s));
76
+ to.rgb *= 1.0 - shadow;
77
+ return mix(to, c, inside);
78
+ }
79
+
80
+ half4 main(float2 _coord) {
81
+ vec2 _uv = _coord / _resolution;
82
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
83
+ return half4(_c.rgb * _c.a, _c.a);
84
+ }
@@ -0,0 +1,77 @@
1
+ // GravityLens — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/GravityLens.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A black disk appears and grows, bending the outgoing image around it like a heavy mass bends light: the image is stretched into a bright ring at the disk's edge and swallowed until the frame is black, then the disk shrinks back, unbending the incoming image
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform vec2 center;
16
+
17
+ uniform float strength;
18
+
19
+ uniform float glow;
20
+
21
+ uniform vec4 hole;
22
+
23
+ const float OVERSHOOT = 0.12;
24
+
25
+ const float PEAK = 0.55;
26
+
27
+ const float AA = 0.002;
28
+
29
+ const vec3 WARM = vec3(1.0, 0.86, 0.68);
30
+
31
+ vec2 mirrored(vec2 v) {
32
+ vec2 m = mod(v, 2.0);
33
+ return mix(m, 2.0 - m, step(1.0, m));
34
+ }
35
+
36
+ vec4 transition(vec2 uv) {
37
+
38
+ bool swallowing = progress < PEAK;
39
+ float u = swallowing ? progress / PEAK : (1.0 - progress) / (1.0 - PEAK);
40
+ float u2 = u * u;
41
+ float k = u2 * (0.6 + 0.4 * u2);
42
+
43
+
44
+ vec2 aspect = vec2(ratio, 1.0);
45
+ vec2 far = max(center, 1.0 - center) * aspect;
46
+ float rh = length(far) * (1.0 + OVERSHOOT) * k;
47
+
48
+ float re = rh * (1.0 + max(strength, 0.0));
49
+
50
+ vec2 d = (uv - center) * aspect;
51
+ float r = max(length(d), 1e-5);
52
+
53
+ vec2 q = mirrored(center + d * (1.0 - re * re / (r * r)) / aspect);
54
+ vec4 c = swallowing ? getFromColor(q) : getToColor(q);
55
+
56
+ float amount = smoothstep(0.0, 0.04, rh);
57
+
58
+ float inner = clamp((r - rh) / (re - rh + 1e-4), 0.0, 1.0);
59
+ c.rgb *= 1.0 - 0.7 * amount * (1.0 - inner * inner * (3.0 - 2.0 * inner));
60
+
61
+
62
+ float g = max(glow, 0.0) * amount;
63
+ float einstein = (r - re) / (0.3 * (re - rh) + 0.01);
64
+ float photon = max(r - rh, 0.0) / (0.006 + 0.012 * rh);
65
+ float light = g * (0.7 * exp(-einstein * einstein) + 1.6 * exp(-photon * photon));
66
+ c.rgb = min(c.rgb * (1.0 + light) + WARM * (0.35 * light * c.a), vec3(1.0));
67
+
68
+
69
+ float cov = clamp((rh - r) / (2.0 * AA), 0.0, 1.0);
70
+ return mix(c, hole, cov);
71
+ }
72
+
73
+ half4 main(float2 _coord) {
74
+ vec2 _uv = _coord / _resolution;
75
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
76
+ return half4(_c.rgb * _c.a, _c.a);
77
+ }
@@ -0,0 +1,121 @@
1
+ // RingSpin — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/RingSpin.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The frame is cut into concentric rings that spin like the dials of a combination lock, in alternating directions and blurred with speed, one after another from the center outward; each ring overshoots a little and locks into place on the incoming image
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform int rings;
16
+
17
+ uniform int square;
18
+
19
+ uniform int turns;
20
+
21
+ uniform float stagger;
22
+
23
+ uniform float blur;
24
+
25
+ uniform float settle;
26
+
27
+ const float PI = 3.141592653589793;
28
+
29
+ const float SETTLE = 0.2;
30
+
31
+ const float GAP = 0.0035;
32
+ const float RIM = 0.012;
33
+ const float EDGE = 0.0015;
34
+
35
+ vec2 mirrorUV(vec2 v) {
36
+ return 1.0 - abs(1.0 - mod(v, 2.0));
37
+ }
38
+
39
+ vec2 rotate(vec2 v, float a) {
40
+ float c = cos(a), s = sin(a);
41
+ return vec2(c * v.x + s * v.y, c * v.y - s * v.x);
42
+ }
43
+
44
+ float ringDelay(float n) {
45
+ float m = max(n - 1.0, 1.0);
46
+ return min(clamp(stagger, 0.0, 0.8) / m, 0.7 / (1.0 + 0.7 * m));
47
+ }
48
+
49
+ float ringTime(float i, float n) {
50
+ float d = ringDelay(n);
51
+ return progress >= 1.0 ? 1.0 : clamp((progress - d * i) / (1.0 - d * (n - 1.0)), 0.0, 1.0);
52
+ }
53
+
54
+ float activity(float i, float n) {
55
+ float t = ringTime(i, n);
56
+ return smoothstep(0.0, 0.08, t) * (1.0 - smoothstep(0.88, 1.0, t));
57
+ }
58
+
59
+ float spin(float t, float total) {
60
+ float amp = 0.1 * settle * sign(total);
61
+ float stopT = 1.0 - SETTLE;
62
+
63
+ float v1 = amp * PI * stopT / (total * SETTLE);
64
+ float u = clamp(t / stopT, 0.0, 1.0);
65
+ float b = clamp((t - stopT) / SETTLE, 0.0, 1.0);
66
+ return total * (u * u * (3.0 - 2.0 * u) + v1 * (u * u * u - u * u)) + amp * sin(PI * b) * (1.0 - b) * (1.0 - b);
67
+ }
68
+
69
+ vec4 transition(vec2 uv) {
70
+ vec2 aspect = vec2(ratio, 1.0);
71
+ vec2 c = (uv - 0.5) * aspect;
72
+ float r = (square != 0) ? max(abs(c.x), abs(c.y)) : length(c);
73
+ float n = clamp(float(rings), 1.0, 12.0);
74
+ float w = ((square != 0) ? 0.5 * max(ratio, 1.0) : length(0.5 * aspect)) / n;
75
+ float f = r / w;
76
+ float i = min(floor(f), n - 1.0);
77
+ float t = ringTime(i, n);
78
+
79
+ vec4 col;
80
+ if (t <= 0.0) col = getFromColor(uv);
81
+ else if (t >= 1.0) col = getToColor(uv);
82
+ else {
83
+ float total = 2.0 * PI * max(float(turns), 1.0) * (mod(i, 2.0) < 0.5 ? 1.0 : -1.0);
84
+ float a = spin(t, total);
85
+
86
+
87
+ float u = min(t / (1.0 - SETTLE), 1.0);
88
+ float omega = abs(total) * 6.0 * u * (1.0 - u) / ((1.0 - SETTLE) * (1.0 - ringDelay(n) * (n - 1.0)));
89
+ float span = blur * min(omega * 0.015, 0.1 / max(r, 0.01));
90
+
91
+ float m = smoothstep(0.3, 0.5, t);
92
+ col = vec4(0.0);
93
+ float ws = 0.0;
94
+ for (int k = 0; k < 8; k++) {
95
+ float x = float(k) / 7.0 - 0.5;
96
+ vec2 q = mirrorUV(rotate(c, a + span * x) / aspect + 0.5);
97
+ vec4 s = mix(getFromColor(q), getToColor(q), m);
98
+ col += (1.0 - abs(x)) * s;
99
+ ws += 1.0 - abs(x);
100
+ }
101
+ col /= ws;
102
+ }
103
+
104
+
105
+
106
+ float bj = clamp(floor(f + 0.5), 1.0, max(n - 1.0, 1.0));
107
+ float act = n > 1.5 ? max(activity(bj - 1.0, n), activity(bj, n)) : 0.0;
108
+ float d = (f - bj) * w;
109
+ vec2 nr = (square != 0) ? (abs(c.x) > abs(c.y) ? vec2(sign(c.x), 0.0) : vec2(0.0, sign(c.y))) : c / max(r, 1e-4);
110
+
111
+ float light = -sign(d) * dot(nr, vec2(-0.6, 0.8)) * (1.0 - smoothstep(GAP, GAP + RIM, abs(d))) * act;
112
+ col.rgb = light > 0.0 ? mix(col.rgb, vec3(col.a), 0.35 * light) : col.rgb * (1.0 + 0.45 * light);
113
+ col.rgb *= 1.0 - 0.85 * act * (1.0 - smoothstep(GAP - EDGE, GAP + EDGE, abs(d)));
114
+ return col;
115
+ }
116
+
117
+ half4 main(float2 _coord) {
118
+ vec2 _uv = _coord / _resolution;
119
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
120
+ return half4(_c.rgb * _c.a, _c.a);
121
+ }
@@ -0,0 +1,74 @@
1
+ // SpotlightWipe — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SpotlightWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The stage lights go down on the outgoing image and a soft oval spotlight searches across it along a curved path, comes to rest and lights the incoming image inside it, then widens until the stage lights come back up on the incoming image
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform vec2 center;
16
+
17
+ uniform float size;
18
+
19
+ uniform float darkness;
20
+
21
+ uniform vec3 warmth;
22
+
23
+ const float FLAT = 0.72;
24
+
25
+ const float LIT = 0.74;
26
+
27
+ vec2 path(float t, vec2 c) {
28
+ vec2 a = vec2(0.08, 0.3);
29
+ vec2 b = vec2(0.35, 1.15);
30
+ vec2 d = vec2(1.05, 0.95);
31
+ float s = 1.0 - t;
32
+ return s * s * s * a + 3.0 * s * s * t * b + 3.0 * s * t * t * d + t * t * t * c;
33
+ }
34
+
35
+ vec4 transition(vec2 uv) {
36
+ vec2 asp = vec2(ratio, 1.0);
37
+ float p = progress;
38
+
39
+
40
+
41
+ float t = clamp(p / 0.5, 0.0, 1.0);
42
+ t = t * t * (3.0 - 2.0 * t);
43
+ vec2 c = path(t, center);
44
+
45
+
46
+ vec2 far = max(center, 1.0 - center) * asp;
47
+ float full = length(vec2(far.x, far.y / FLAT)) / LIT;
48
+ float g = smoothstep(0.44, 1.0, p);
49
+ float radius = mix(0.5 * size, full, g * (0.3 + 0.7 * g));
50
+
51
+
52
+ vec2 q = (uv - c) * asp;
53
+ float r = length(vec2(q.x, q.y / FLAT)) / radius;
54
+
55
+
56
+ float core = 1.0 - smoothstep(0.72, 1.08, r);
57
+ float ring = (r - 0.9) / 0.09;
58
+ float spot = max(core * (1.0 - 0.1 * r * r), 0.12 * (1.0 - smoothstep(0.9, 2.4, r))) + 0.16 * exp(-ring * ring);
59
+
60
+
61
+ float s = darkness * smoothstep(0.0, 0.18, p) * (1.0 - smoothstep(0.72, 1.0, p));
62
+ vec3 light = 1.0 - s + s * spot * warmth;
63
+
64
+
65
+ float lit = smoothstep(0.42, 0.58, p) * (1.0 - smoothstep(LIT, 1.0, r));
66
+ vec4 col = mix(getFromColor(uv), getToColor(uv), lit);
67
+ return vec4(col.rgb * light, col.a);
68
+ }
69
+
70
+ half4 main(float2 _coord) {
71
+ vec2 _uv = _coord / _resolution;
72
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
73
+ return half4(_c.rgb * _c.a, _c.a);
74
+ }