gl-transitions 3.1.0 → 3.3.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 (106) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/compatibility.json +306 -0
  3. package/gl-transitions.js +1 -1
  4. package/gl-transitions.json +1 -1
  5. package/glsl3/CardDeal.glsl +146 -0
  6. package/glsl3/CircleBurst.glsl +77 -0
  7. package/glsl3/CodeRain.glsl +114 -0
  8. package/glsl3/CurtainRise.glsl +71 -0
  9. package/glsl3/EchoSlide.glsl +93 -0
  10. package/glsl3/GeometricCollage.glsl +241 -0
  11. package/glsl3/GravityLens.glsl +66 -0
  12. package/glsl3/HingedSquares.glsl +121 -0
  13. package/glsl3/HorizontalHold.glsl +62 -0
  14. package/glsl3/LayoutGrid.glsl +147 -0
  15. package/glsl3/ProjectorThrow.glsl +75 -0
  16. package/glsl3/Reassemble.glsl +156 -0
  17. package/glsl3/RingSpin.glsl +112 -0
  18. package/glsl3/Shockwave.glsl +103 -0
  19. package/glsl3/ShoreWash.glsl +150 -0
  20. package/glsl3/ShutterWipe.glsl +68 -0
  21. package/glsl3/SpotlightWipe.glsl +63 -0
  22. package/glsl3/StopMotion.glsl +118 -0
  23. package/glsl3/Vaporize.glsl +125 -0
  24. package/index.js +1 -1
  25. package/layouts.json +725 -1
  26. package/llms-full.txt +734 -422
  27. package/llms.txt +238 -219
  28. package/msl/CardDeal.metal +539 -0
  29. package/msl/CircleBurst.metal +351 -0
  30. package/msl/CodeRain.metal +451 -0
  31. package/msl/CurtainRise.metal +263 -0
  32. package/msl/EchoSlide.metal +438 -0
  33. package/msl/GeometricCollage.metal +1188 -0
  34. package/msl/GravityLens.metal +236 -0
  35. package/msl/HingedSquares.metal +564 -0
  36. package/msl/HorizontalHold.metal +286 -0
  37. package/msl/LayoutGrid.metal +544 -0
  38. package/msl/ProjectorThrow.metal +313 -0
  39. package/msl/Reassemble.metal +667 -0
  40. package/msl/RingSpin.metal +474 -0
  41. package/msl/Shockwave.metal +256 -0
  42. package/msl/ShoreWash.metal +538 -0
  43. package/msl/ShutterWipe.metal +286 -0
  44. package/msl/SpotlightWipe.metal +217 -0
  45. package/msl/StopMotion.metal +551 -0
  46. package/msl/Vaporize.metal +462 -0
  47. package/package.json +1 -1
  48. package/skills/gl-transitions/references/catalog.md +94 -44
  49. package/sksl/CardDeal.sksl +156 -0
  50. package/sksl/CircleBurst.sksl +84 -0
  51. package/sksl/CodeRain.sksl +124 -0
  52. package/sksl/CurtainRise.sksl +84 -0
  53. package/sksl/EchoSlide.sksl +99 -0
  54. package/sksl/GeometricCollage.sksl +242 -0
  55. package/sksl/GravityLens.sksl +77 -0
  56. package/sksl/HingedSquares.sksl +124 -0
  57. package/sksl/HorizontalHold.sksl +74 -0
  58. package/sksl/LayoutGrid.sksl +156 -0
  59. package/sksl/ProjectorThrow.sksl +85 -0
  60. package/sksl/Reassemble.sksl +166 -0
  61. package/sksl/RingSpin.sksl +121 -0
  62. package/sksl/Shockwave.sksl +116 -0
  63. package/sksl/ShoreWash.sksl +159 -0
  64. package/sksl/ShutterWipe.sksl +80 -0
  65. package/sksl/SpotlightWipe.sksl +74 -0
  66. package/sksl/StopMotion.sksl +126 -0
  67. package/sksl/Vaporize.sksl +134 -0
  68. package/sksl/index.js +1 -1
  69. package/transitions/CardDeal.glsl +145 -0
  70. package/transitions/CircleBurst.glsl +76 -0
  71. package/transitions/CodeRain.glsl +113 -0
  72. package/transitions/CurtainRise.glsl +70 -0
  73. package/transitions/EchoSlide.glsl +92 -0
  74. package/transitions/GeometricCollage.glsl +240 -0
  75. package/transitions/GravityLens.glsl +65 -0
  76. package/transitions/HingedSquares.glsl +120 -0
  77. package/transitions/HorizontalHold.glsl +61 -0
  78. package/transitions/LayoutGrid.glsl +146 -0
  79. package/transitions/ProjectorThrow.glsl +74 -0
  80. package/transitions/Reassemble.glsl +155 -0
  81. package/transitions/RingSpin.glsl +111 -0
  82. package/transitions/Shockwave.glsl +102 -0
  83. package/transitions/ShoreWash.glsl +149 -0
  84. package/transitions/ShutterWipe.glsl +67 -0
  85. package/transitions/SpotlightWipe.glsl +62 -0
  86. package/transitions/StopMotion.glsl +117 -0
  87. package/transitions/Vaporize.glsl +124 -0
  88. package/wgsl/CardDeal.wgsl +496 -0
  89. package/wgsl/CircleBurst.wgsl +310 -0
  90. package/wgsl/CodeRain.wgsl +415 -0
  91. package/wgsl/CurtainRise.wgsl +235 -0
  92. package/wgsl/EchoSlide.wgsl +386 -0
  93. package/wgsl/GeometricCollage.wgsl +1075 -0
  94. package/wgsl/GravityLens.wgsl +206 -0
  95. package/wgsl/HingedSquares.wgsl +506 -0
  96. package/wgsl/HorizontalHold.wgsl +243 -0
  97. package/wgsl/LayoutGrid.wgsl +495 -0
  98. package/wgsl/ProjectorThrow.wgsl +274 -0
  99. package/wgsl/Reassemble.wgsl +609 -0
  100. package/wgsl/RingSpin.wgsl +426 -0
  101. package/wgsl/Shockwave.wgsl +226 -0
  102. package/wgsl/ShoreWash.wgsl +492 -0
  103. package/wgsl/ShutterWipe.wgsl +252 -0
  104. package/wgsl/SpotlightWipe.wgsl +186 -0
  105. package/wgsl/StopMotion.wgsl +496 -0
  106. package/wgsl/Vaporize.wgsl +420 -0
@@ -0,0 +1,62 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // 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
4
+ // Tags: light, spotlight, stage, iris, reveal
5
+
6
+ // @param Point where the spotlight comes to rest and opens from
7
+ uniform vec2 center; // = vec2(0.5, 0.5)
8
+ // @range(0.08, 0.45) Width of the spotlight while it searches, in frame heights
9
+ uniform float size; // = 0.3
10
+ // @range(0, 1) How dark the stage gets around the spotlight
11
+ uniform float darkness; // = 0.85
12
+ // @color Tint of the spotlight
13
+ uniform vec3 warmth; // = vec3(1.0, 0.93, 0.8)
14
+
15
+ // height of the oval over its width: a cone of light hitting a stage seen at an angle
16
+ const float FLAT = 0.72;
17
+ // distance to the spotlight's center, in oval radii, inside which the incoming image is fully lit
18
+ const float LIT = 0.74;
19
+
20
+ // a point of the curved path the spotlight searches along, from the lower left to its resting point
21
+ vec2 path(float t, vec2 c) {
22
+ vec2 a = vec2(0.08, 0.3);
23
+ vec2 b = vec2(0.35, 1.15);
24
+ vec2 d = vec2(1.05, 0.95);
25
+ float s = 1.0 - t;
26
+ return s * s * s * a + 3.0 * s * s * t * b + 3.0 * s * t * t * d + t * t * t * c;
27
+ }
28
+
29
+ vec4 transition(vec2 uv) {
30
+ vec2 asp = vec2(ratio, 1.0);
31
+ float p = progress;
32
+
33
+ // the spotlight slides along its path and eases to rest, its last few steps overlapping the start
34
+ // of its widening so the motion never stops
35
+ float t = clamp(p / 0.5, 0.0, 1.0);
36
+ t = t * t * (3.0 - 2.0 * t);
37
+ vec2 c = path(t, center);
38
+
39
+ // it widens until its lit core covers the farthest corner of the frame
40
+ vec2 far = max(center, 1.0 - center) * asp;
41
+ float full = length(vec2(far.x, far.y / FLAT)) / LIT;
42
+ float g = smoothstep(0.44, 1.0, p);
43
+ float radius = mix(0.5 * size, full, g * (0.3 + 0.7 * g));
44
+
45
+ // distance to the spotlight's center, 1 on the oval's edge
46
+ vec2 q = (uv - c) * asp;
47
+ float r = length(vec2(q.x, q.y / FLAT)) / radius;
48
+
49
+ // light of the spotlight: a flat core, a soft penumbra, a slightly brighter rim and a faint spill
50
+ float core = 1.0 - smoothstep(0.72, 1.08, r);
51
+ float ring = (r - 0.9) / 0.09;
52
+ 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);
53
+
54
+ // the stage lights go down at the start and come back up at the end
55
+ float s = darkness * smoothstep(0.0, 0.18, p) * (1.0 - smoothstep(0.72, 1.0, p));
56
+ vec3 light = 1.0 - s + s * spot * warmth;
57
+
58
+ // as it comes to rest, the spotlight lights the incoming image inside it
59
+ float lit = smoothstep(0.42, 0.58, p) * (1.0 - smoothstep(LIT, 1.0, r));
60
+ vec4 col = mix(getFromColor(uv), getToColor(uv), lit);
61
+ return vec4(col.rgb * light, col.a);
62
+ }
@@ -0,0 +1,117 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image is a paper cutout that jerks off the frame in choppy stop-motion steps, with a tiny new tilt and offset each step and a drop shadow, while the incoming cutout jerks in the same way and lands
4
+ // Tags: stop-motion, paper, cutout, slide, shadow, choppy
5
+
6
+ // @range(6, 30, 1) Number of held poses during the transition: fewer is choppier
7
+ uniform int steps; // = 12
8
+ // @range(0, 1) Size of the small random tilt and offset given to the cutouts at each step
9
+ uniform float jitter; // = 0.5
10
+ // @range(0, 1) Darkness of the drop shadow the cutouts cast
11
+ uniform float shadow; // = 0.5
12
+ // @color Color of the background behind the cutouts
13
+ uniform vec4 backColor; // = vec4(0.80, 0.71, 0.56, 1.0)
14
+ // @color Color of the paper rim around the cutouts
15
+ uniform vec4 rimColor; // = vec4(0.97, 0.96, 0.93, 1.0)
16
+
17
+ const float SHRINK = 0.2; // how much smaller the cutouts are than the frame while they move
18
+ const float RIM = 0.012; // width of the paper rim around the cutouts, in frame heights
19
+ const float RADIUS = 0.006; // corner radius of the cutouts, in frame heights
20
+ const float AA = 0.0015; // width of the antialiased edges, in frame heights
21
+
22
+ // Hoskins' hash of an integer step
23
+ float hash11(float p) {
24
+ p = fract(p * 0.1031);
25
+ p *= p + 33.33;
26
+ p *= p + p;
27
+ return fract(p);
28
+ }
29
+
30
+ // signed distance to a rounded box of half size b and corner radius r
31
+ float roundedBox(vec2 q, vec2 b, float r) {
32
+ vec2 d = abs(q) - b + r;
33
+ return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r;
34
+ }
35
+
36
+ vec4 premultiply(vec4 c) {
37
+ return vec4(c.rgb * c.a, c.a);
38
+ }
39
+
40
+ // distance from the center far enough for a cutout of half size h turned by a, and its shadow, to be out of the frame
41
+ float offFrame(vec2 h, float a) {
42
+ return 0.5 * ratio + abs(cos(a)) * h.x + abs(sin(a)) * h.y + 0.08;
43
+ }
44
+
45
+ // half size of a cutout scaled by s, with its rim for the lift l
46
+ vec2 cutoutSize(float s, float l) {
47
+ return (0.5 * vec2(ratio, 1.0) + RIM * l) * s;
48
+ }
49
+
50
+ // draws over col (premultiplied) a cutout of the outgoing or incoming image, centered at c, turned by a, scaled by s, lifted by l
51
+ vec4 drawCutout(vec4 col, vec2 q, vec2 c, float a, float s, float l, bool incoming) {
52
+ vec2 asp = vec2(ratio, 1.0);
53
+ vec2 halfImage = 0.5 * asp;
54
+ vec2 halfCut = halfImage + RIM * l;
55
+ float rad = RADIUS * l;
56
+ float ca = cos(a), sa = sin(a);
57
+ mat2 unrotate = mat2(ca, -sa, sa, ca);
58
+
59
+ // the drop shadow, cast down and to the right, softer and further as the cutout is lifted,
60
+ // as dark as the image casting it is opaque
61
+ vec2 rs = unrotate * (q - c - vec2(0.018, -0.026) * l) / s;
62
+ vec2 ss = clamp(rs / asp + 0.5, 0.0, 1.0);
63
+ float sAlpha = max(incoming ? getToColor(ss).a : getFromColor(ss).a, rimColor.a);
64
+ float ds = roundedBox(rs, halfCut, rad) * s;
65
+ float blur = 0.004 + 0.016 * l;
66
+ col.rgb *= 1.0 - clamp(shadow, 0.0, 1.0) * 0.75 * l * sAlpha * (1.0 - smoothstep(-blur, blur, ds));
67
+
68
+ vec2 r = unrotate * (q - c) / s;
69
+ float dCut = roundedBox(r, halfCut, rad) * s;
70
+ float dImage = roundedBox(r, halfImage, 0.0) * s;
71
+ float cutCover = clamp(0.5 - dCut / AA, 0.0, 1.0);
72
+ float imageCover = clamp(0.5 - dImage / AA, 0.0, 1.0);
73
+ vec2 st = clamp(r / asp + 0.5, 0.0, 1.0);
74
+ vec4 img = premultiply(incoming ? getToColor(st) : getFromColor(st));
75
+ // the image on its paper rim, laid over what is below
76
+ vec4 cut = mix(premultiply(rimColor), img, imageCover) * cutCover;
77
+ return cut + col * (1.0 - cut.a);
78
+ }
79
+
80
+ vec4 transition(vec2 uv) {
81
+ float n = float(steps < 2 ? 2 : steps);
82
+ // the pose held at this time: the first and last are the full images, held half a step each
83
+ float k = floor(progress * n + 0.5);
84
+ if (k <= 0.0) return getFromColor(uv);
85
+ if (k >= n) return getToColor(uv);
86
+
87
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
88
+ float j = clamp(jitter, 0.0, 1.0);
89
+
90
+ // the outgoing cutout is picked up off the frame in two poses, then jerked out to the left, faster and faster
91
+ float l0 = min(k / 2.0, 1.0);
92
+ float m0 = clamp((k - 1.0) / (0.45 * n), 0.0, 1.0);
93
+ m0 = m0 * m0 * (0.4 + 0.6 * m0);
94
+ float s0 = 1.0 - SHRINK * l0;
95
+ float a0 = 0.22 * m0 + l0 * j * 0.2 * (hash11(k) - 0.5);
96
+ vec2 c0 = vec2(-offFrame(cutoutSize(s0, l0), a0) * m0, 0.05 * m0 * m0)
97
+ + l0 * j * vec2(0.07 * (hash11(k + 100.0) - 0.5), 0.05 * (hash11(k + 200.0) - 0.5));
98
+
99
+ // the incoming cutout is jerked in from the right, slowing down, then laid flat onto the frame in two poses
100
+ float l1 = min((n - k) / 2.0, 1.0);
101
+ float m1 = clamp((n - 2.0 - k) / (0.45 * n), 0.0, 1.0);
102
+ m1 = m1 * m1 * (0.4 + 0.6 * m1);
103
+ float s1 = 1.0 - SHRINK * l1;
104
+ float a1 = -0.25 * m1 + l1 * j * 0.2 * (hash11(k + 300.0) - 0.5);
105
+ vec2 c1 = vec2(offFrame(cutoutSize(s1, l1), a1) * m1, -0.06 * m1 * m1)
106
+ + l1 * j * vec2(0.07 * (hash11(k + 400.0) - 0.5), 0.05 * (hash11(k + 500.0) - 0.5));
107
+
108
+ // the background, then the outgoing cutout, then the incoming one on top
109
+ vec4 col = premultiply(backColor);
110
+ if (m0 < 1.0) col = drawCutout(col, q, c0, a0, s0, l0, false);
111
+ if (m1 < 1.0) col = drawCutout(col, q, c1, a1, s1, l1, true);
112
+ if (col.a <= 0.0) return vec4(0.0);
113
+ col.rgb /= col.a;
114
+ // the light dims a little from one shot to the next
115
+ col.rgb *= 1.0 - 0.04 * j * hash11(k + 600.0);
116
+ return col;
117
+ }
@@ -0,0 +1,124 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image goes up in smoke: from one side, the picture itself turns to vapour that rises over what is still intact, curls into wisps and pales as it thins out, revealing the incoming image underneath
4
+ // Tags: smoke, organic, noise, directional, reveal
5
+
6
+ // @param Direction the vapour rises toward (the image starts turning to vapour on the opposite side)
7
+ uniform vec2 direction; // = vec2(0.0, 1.0)
8
+ // @range(0.1, 0.6) How high the vapour rises above the image before it is gone, in frame heights
9
+ uniform float rise; // = 0.4
10
+ // @range(0, 1) How much the vapour swirls and curls as it rises
11
+ uniform float swirl; // = 0.6
12
+ // @color Color the vapour pales to as it thins out
13
+ uniform vec4 color; // = vec4(0.92, 0.92, 0.94, 1.0)
14
+
15
+ // raggedness of the line where the image turns to vapour, and the width over which it dissolves
16
+ const float RAGGED = 0.09;
17
+ const float BAND = 0.12;
18
+ // how long the vapour lives, as a part of the transition
19
+ const float LIFE = 0.16;
20
+ const int TAPS = 6;
21
+
22
+ float hash12(vec2 p) {
23
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
24
+ p3 += dot(p3, p3.yzx + 33.33);
25
+ return fract((p3.x + p3.y) * p3.z);
26
+ }
27
+
28
+ float vnoise(vec2 p) {
29
+ vec2 i = floor(p);
30
+ vec2 f = fract(p);
31
+ f = f * f * (3.0 - 2.0 * f);
32
+ return mix(
33
+ mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
34
+ mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
35
+ f.y
36
+ );
37
+ }
38
+
39
+ float fbm(vec2 p) {
40
+ return 0.55 * vnoise(p) + 0.3 * vnoise(p * 2.03 + 5.1) + 0.15 * vnoise(p * 4.1 + 9.7);
41
+ }
42
+
43
+ // a swirling flow without sources or sinks: the curl of a noise field
44
+ vec2 curl(vec2 p) {
45
+ float e = 0.1;
46
+ float n = vnoise(p);
47
+ float nx = vnoise(p + vec2(e, 0.0));
48
+ float ny = vnoise(p + vec2(0.0, e));
49
+ return vec2(ny - n, n - nx) / e;
50
+ }
51
+
52
+ // where the line is at time t, as a part of its way across: quicker through the margins
53
+ // outside the frame, slower across it
54
+ float sweep(float t) {
55
+ return t + 0.6 * t * (1.0 - t) * (1.0 - 2.0 * t);
56
+ }
57
+
58
+ vec2 mirror(vec2 v) {
59
+ return 1.0 - abs(1.0 - mod(v, 2.0));
60
+ }
61
+
62
+ vec4 transition(vec2 uv) {
63
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(0.0, 1.0);
64
+ vec2 side = vec2(-dir.y, dir.x);
65
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
66
+ float along = dot(q, dir);
67
+ float across = dot(q, side);
68
+ float ext = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
69
+
70
+ // the line where the image turns to vapour sweeps across the frame, ragged
71
+ float ragged = RAGGED * (2.0 * fbm(q * 2.5 + 1.3) - 1.0);
72
+ float start = -ext - RAGGED;
73
+ float travel = 2.0 * ext + 2.0 * RAGGED + BAND;
74
+ float front = start + travel * sweep(progress) + ragged;
75
+
76
+ // under the vapour: the outgoing image where it is still intact, dissolving into the
77
+ // incoming one just behind the line
78
+ float gone = smoothstep(0.0, BAND, front - along);
79
+ vec4 base = mix(getFromColor(uv), getToColor(uv), gone);
80
+
81
+ // the vapour above the line: the higher it is, the longer ago it left the image
82
+ float height = max(rise, 0.05) * (0.7 + 0.6 * vnoise(vec2(across * 3.0 + 2.7, 0.5)));
83
+ float age = (along - front) / height;
84
+ float released = progress - age * LIFE;
85
+ if (age <= 0.0 || age >= 1.0 || released <= 0.0) return base;
86
+
87
+ // where it came from: the line, back when it was released
88
+ float origin = start + travel * sweep(released) + ragged;
89
+ vec2 org = q - dir * (along - origin);
90
+
91
+ // it swirls and curls as it rises
92
+ vec2 sw = curl(org * 3.0 + dir * progress * 1.5) * (swirl * 0.08 * sqrt(age));
93
+ vec2 src = org - sw;
94
+
95
+ // and spreads out sideways, blurring as it rises
96
+ vec2 spreadOut = (side * 0.07 + dir * 0.02) * sqrt(age);
97
+ vec4 c = vec4(0.0);
98
+ for (int i = 0; i < TAPS; i++) {
99
+ float t = float(i) / float(TAPS - 1) - 0.5;
100
+ vec4 img = getFromColor(mirror((src + spreadOut * t) / vec2(ratio, 1.0) + 0.5));
101
+ c += vec4(img.rgb * img.a, img.a);
102
+ }
103
+ c = c.a > 0.0 ? vec4(c.rgb / c.a, c.a / float(TAPS)) : vec4(0.0);
104
+
105
+ // it breaks up into wisps that rise with it and thin out: thin parts go first
106
+ vec2 wq = (q - 0.6 * sw - dir * (progress * 2.5)) * 4.0;
107
+ float w = fbm(vec2(dot(wq, side), dot(wq, dir) * 0.6) + 2.0);
108
+ float density = smoothstep(1.2 * age - 0.2, 1.2 * age + 0.1, w);
109
+ density *= 1.0 - smoothstep(0.3, 1.0, age);
110
+ // (only the image turns to vapour, not what lies beyond its edge)
111
+ density *= smoothstep(-ext, -ext + 0.05, origin);
112
+
113
+ // it pales and loses its colour as it thins
114
+ float pale = smoothstep(0.0, 0.5, age);
115
+ float l = dot(c.rgb, vec3(0.299, 0.587, 0.114));
116
+ c = mix(c, vec4(mix(vec3(l), color.rgb, 0.7), c.a * color.a), pale * 0.85);
117
+ // the edges of the wisps catch the light
118
+ c.rgb = min(c.rgb + 0.12 * pale * density * (1.0 - density), vec3(1.0));
119
+ // laid over what is under it
120
+ float a = density * c.a;
121
+ float outA = a + base.a * (1.0 - a);
122
+ if (outA <= 0.0) return vec4(0.0);
123
+ return vec4((c.rgb * a + base.rgb * base.a * (1.0 - a)) / outA, outA);
124
+ }