gl-transitions 2.4.0 → 3.0.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 (182) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +16 -1
  3. package/compatibility.json +251 -121
  4. package/gl-transitions.js +1 -1
  5. package/gl-transitions.json +1 -1
  6. package/glsl3/ArrowWipe.glsl +100 -0
  7. package/glsl3/BandWipe.glsl +67 -0
  8. package/glsl3/BlockSlide.glsl +87 -0
  9. package/glsl3/BowTie.glsl +1 -1
  10. package/glsl3/CellDissolve.glsl +91 -0
  11. package/glsl3/Crumple.glsl +173 -0
  12. package/glsl3/DirectionalWipe.glsl +1 -1
  13. package/glsl3/GlintDissolve.glsl +125 -0
  14. package/glsl3/HeatHaze.glsl +79 -0
  15. package/glsl3/Hologram.glsl +97 -0
  16. package/glsl3/InsetWipe.glsl +58 -0
  17. package/glsl3/LightningFlash.glsl +200 -0
  18. package/glsl3/LiquidFill.glsl +102 -0
  19. package/glsl3/PlasmaDissolve.glsl +51 -0
  20. package/glsl3/RingsWipe.glsl +106 -0
  21. package/glsl3/SawtoothWipe.glsl +73 -0
  22. package/glsl3/SnakeBlockWipe.glsl +40 -0
  23. package/glsl3/Snapshot.glsl +86 -0
  24. package/glsl3/Sphere.glsl +95 -0
  25. package/glsl3/SpiralBlockWipe.glsl +65 -0
  26. package/glsl3/Vortex.glsl +106 -0
  27. package/glsl3/WarpSpeed.glsl +120 -0
  28. package/index.js +1 -1
  29. package/layouts.json +846 -253
  30. package/llms-full.txt +665 -476
  31. package/llms.txt +197 -189
  32. package/msl/ArrowWipe.metal +391 -0
  33. package/msl/BandWipe.metal +353 -0
  34. package/msl/BlockSlide.metal +418 -0
  35. package/msl/BowTie.metal +1 -1
  36. package/msl/CellDissolve.metal +374 -0
  37. package/msl/Crumple.metal +766 -0
  38. package/msl/DirectionalWipe.metal +1 -1
  39. package/msl/GlintDissolve.metal +558 -0
  40. package/msl/HeatHaze.metal +320 -0
  41. package/msl/Hologram.metal +380 -0
  42. package/msl/InsetWipe.metal +232 -0
  43. package/msl/LightningFlash.metal +1038 -0
  44. package/msl/LiquidFill.metal +373 -0
  45. package/msl/PlasmaDissolve.metal +178 -0
  46. package/msl/RingsWipe.metal +437 -0
  47. package/msl/SawtoothWipe.metal +310 -0
  48. package/msl/SnakeBlockWipe.metal +216 -0
  49. package/msl/Snapshot.metal +321 -0
  50. package/msl/Sphere.metal +345 -0
  51. package/msl/SpiralBlockWipe.metal +281 -0
  52. package/msl/Vortex.metal +522 -0
  53. package/msl/WarpSpeed.metal +549 -0
  54. package/package.json +1 -1
  55. package/skills/gl-transitions/references/catalog.md +92 -59
  56. package/sksl/ArrowWipe.sksl +111 -0
  57. package/sksl/BandWipe.sksl +77 -0
  58. package/sksl/BlockSlide.sksl +99 -0
  59. package/sksl/BowTie.sksl +1 -1
  60. package/sksl/CellDissolve.sksl +103 -0
  61. package/sksl/Crumple.sksl +179 -0
  62. package/sksl/DirectionalWipe.sksl +1 -1
  63. package/sksl/GlintDissolve.sksl +136 -0
  64. package/sksl/HeatHaze.sksl +90 -0
  65. package/sksl/Hologram.sksl +108 -0
  66. package/sksl/InsetWipe.sksl +70 -0
  67. package/sksl/LightningFlash.sksl +202 -0
  68. package/sksl/LiquidFill.sksl +113 -0
  69. package/sksl/PlasmaDissolve.sksl +64 -0
  70. package/sksl/RingsWipe.sksl +115 -0
  71. package/sksl/SawtoothWipe.sksl +83 -0
  72. package/sksl/SnakeBlockWipe.sksl +53 -0
  73. package/sksl/Snapshot.sksl +98 -0
  74. package/sksl/Sphere.sksl +108 -0
  75. package/sksl/SpiralBlockWipe.sksl +76 -0
  76. package/sksl/Vortex.sksl +116 -0
  77. package/sksl/WarpSpeed.sksl +131 -0
  78. package/sksl/index.js +1 -1
  79. package/transitions/ArrowWipe.glsl +99 -0
  80. package/transitions/BandWipe.glsl +66 -0
  81. package/transitions/BlockSlide.glsl +86 -0
  82. package/transitions/BowTie.glsl +1 -1
  83. package/transitions/CellDissolve.glsl +90 -0
  84. package/transitions/Crumple.glsl +172 -0
  85. package/transitions/DirectionalWipe.glsl +1 -1
  86. package/transitions/GlintDissolve.glsl +124 -0
  87. package/transitions/HeatHaze.glsl +78 -0
  88. package/transitions/Hologram.glsl +96 -0
  89. package/transitions/InsetWipe.glsl +57 -0
  90. package/transitions/LightningFlash.glsl +199 -0
  91. package/transitions/LiquidFill.glsl +101 -0
  92. package/transitions/PlasmaDissolve.glsl +50 -0
  93. package/transitions/RingsWipe.glsl +105 -0
  94. package/transitions/SawtoothWipe.glsl +72 -0
  95. package/transitions/SnakeBlockWipe.glsl +39 -0
  96. package/transitions/Snapshot.glsl +85 -0
  97. package/transitions/Sphere.glsl +94 -0
  98. package/transitions/SpiralBlockWipe.glsl +64 -0
  99. package/transitions/Vortex.glsl +105 -0
  100. package/transitions/WarpSpeed.glsl +119 -0
  101. package/wgsl/ArrowWipe.wgsl +352 -0
  102. package/wgsl/BandWipe.wgsl +319 -0
  103. package/wgsl/BlockSlide.wgsl +384 -0
  104. package/wgsl/BowTie.wgsl +1 -1
  105. package/wgsl/CellDissolve.wgsl +323 -0
  106. package/wgsl/Crumple.wgsl +709 -0
  107. package/wgsl/DirectionalWipe.wgsl +1 -1
  108. package/wgsl/GlintDissolve.wgsl +519 -0
  109. package/wgsl/HeatHaze.wgsl +282 -0
  110. package/wgsl/Hologram.wgsl +339 -0
  111. package/wgsl/InsetWipe.wgsl +200 -0
  112. package/wgsl/LightningFlash.wgsl +964 -0
  113. package/wgsl/LiquidFill.wgsl +339 -0
  114. package/wgsl/PlasmaDissolve.wgsl +149 -0
  115. package/wgsl/RingsWipe.wgsl +394 -0
  116. package/wgsl/SawtoothWipe.wgsl +279 -0
  117. package/wgsl/SnakeBlockWipe.wgsl +188 -0
  118. package/wgsl/Snapshot.wgsl +287 -0
  119. package/wgsl/Sphere.wgsl +316 -0
  120. package/wgsl/SpiralBlockWipe.wgsl +250 -0
  121. package/wgsl/Vortex.wgsl +463 -0
  122. package/wgsl/WarpSpeed.wgsl +497 -0
  123. package/glsl3/BlockDissolve.glsl +0 -16
  124. package/glsl3/BowTieVertical.glsl +0 -117
  125. package/glsl3/Box.glsl +0 -33
  126. package/glsl3/LinearBlur.glsl +0 -30
  127. package/glsl3/MosaicBlend.glsl +0 -21
  128. package/glsl3/MosaicFade.glsl +0 -20
  129. package/glsl3/RotateFade.glsl +0 -22
  130. package/glsl3/ScaleIn.glsl +0 -18
  131. package/glsl3/WipeDown.glsl +0 -12
  132. package/glsl3/WipeLeft.glsl +0 -12
  133. package/glsl3/WipeRight.glsl +0 -12
  134. package/glsl3/WipeUp.glsl +0 -12
  135. package/msl/BlockDissolve.metal +0 -108
  136. package/msl/BowTieVertical.metal +0 -375
  137. package/msl/Box.metal +0 -204
  138. package/msl/LinearBlur.metal +0 -169
  139. package/msl/MosaicBlend.metal +0 -136
  140. package/msl/MosaicFade.metal +0 -137
  141. package/msl/RotateFade.metal +0 -116
  142. package/msl/ScaleIn.metal +0 -111
  143. package/msl/WipeDown.metal +0 -105
  144. package/msl/WipeLeft.metal +0 -105
  145. package/msl/WipeRight.metal +0 -105
  146. package/msl/WipeUp.metal +0 -105
  147. package/sksl/BlockDissolve.sksl +0 -29
  148. package/sksl/BowTieVertical.sksl +0 -130
  149. package/sksl/Box.sksl +0 -47
  150. package/sksl/LinearBlur.sksl +0 -44
  151. package/sksl/MosaicBlend.sksl +0 -34
  152. package/sksl/MosaicFade.sksl +0 -33
  153. package/sksl/RotateFade.sksl +0 -34
  154. package/sksl/ScaleIn.sksl +0 -32
  155. package/sksl/WipeDown.sksl +0 -26
  156. package/sksl/WipeLeft.sksl +0 -26
  157. package/sksl/WipeRight.sksl +0 -26
  158. package/sksl/WipeUp.sksl +0 -26
  159. package/transitions/BlockDissolve.glsl +0 -15
  160. package/transitions/BowTieVertical.glsl +0 -116
  161. package/transitions/Box.glsl +0 -32
  162. package/transitions/LinearBlur.glsl +0 -29
  163. package/transitions/MosaicBlend.glsl +0 -20
  164. package/transitions/MosaicFade.glsl +0 -19
  165. package/transitions/RotateFade.glsl +0 -21
  166. package/transitions/ScaleIn.glsl +0 -17
  167. package/transitions/WipeDown.glsl +0 -11
  168. package/transitions/WipeLeft.glsl +0 -11
  169. package/transitions/WipeRight.glsl +0 -11
  170. package/transitions/WipeUp.glsl +0 -11
  171. package/wgsl/BlockDissolve.wgsl +0 -78
  172. package/wgsl/BowTieVertical.wgsl +0 -331
  173. package/wgsl/Box.wgsl +0 -176
  174. package/wgsl/LinearBlur.wgsl +0 -131
  175. package/wgsl/MosaicBlend.wgsl +0 -108
  176. package/wgsl/MosaicFade.wgsl +0 -107
  177. package/wgsl/RotateFade.wgsl +0 -85
  178. package/wgsl/ScaleIn.wgsl +0 -79
  179. package/wgsl/WipeDown.wgsl +0 -77
  180. package/wgsl/WipeLeft.wgsl +0 -77
  181. package/wgsl/WipeRight.wgsl +0 -77
  182. package/wgsl/WipeUp.wgsl +0 -77
@@ -0,0 +1,78 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: Shimmering heat waves rise through the frame, strongest at the bottom, making the outgoing image wobble like the air over hot asphalt; the incoming image shows through the haze and settles as it calms
4
+ // Tags: distort, heat, shimmer, noise, organic, blend
5
+
6
+ // @range(0, 0.1) How far the haze bends the image, in frame heights (the strongest waves bend it about 1.5 times as far)
7
+ uniform float strength; // = 0.04
8
+ // @range(1, 12) Size of the heat waves: more, smaller ones with a larger value
9
+ uniform float scale; // = 6.0
10
+ // @range(0, 6) How fast the heat waves rise
11
+ uniform float speed; // = 2.0
12
+
13
+ // reflects coordinates that leave the frame back into it, so the edges do not smear
14
+ vec2 mirror(vec2 v) {
15
+ return 1.0 - abs(1.0 - mod(v, 2.0));
16
+ }
17
+
18
+ float hash12(vec2 v) {
19
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
20
+ v3 += dot(v3, v3.yzx + 33.33);
21
+ return fract((v3.x + v3.y) * v3.z);
22
+ }
23
+
24
+ float vnoise(vec2 v) {
25
+ vec2 i = floor(v);
26
+ vec2 f = fract(v);
27
+ f = f * f * (3.0 - 2.0 * f);
28
+ return mix(
29
+ mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
30
+ mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
31
+ f.y
32
+ );
33
+ }
34
+
35
+ // centered on 0, within [-1.5, 1.5]
36
+ float fbm(vec2 v) {
37
+ float sum = 0.0;
38
+ float amp = 0.5;
39
+ for (int i = 0; i < 4; i++) {
40
+ sum += amp * vnoise(v);
41
+ v = mat2(1.6, 1.2, -1.2, 1.6) * v + 5.3;
42
+ amp *= 0.5;
43
+ }
44
+ return (sum / 0.9375 - 0.5) * 3.0;
45
+ }
46
+
47
+ vec4 transition(vec2 uv) {
48
+ if (progress <= 0.0) return getFromColor(uv);
49
+ if (progress >= 1.0) return getToColor(uv);
50
+
51
+ const float PI = 3.141592653589793;
52
+ float p = progress;
53
+ // the haze builds up then calms down
54
+ float amount = sin(PI * p);
55
+ // the waves scroll upward and slowly churn as they rise
56
+ float t = p * speed;
57
+ // in square pixels, then squashed vertically into the thin bands of rising air
58
+ vec2 q = vec2(uv.x * ratio, uv.y * 2.5) * scale;
59
+ q.y -= t * scale;
60
+ // the bands are bent by a slower, larger turbulence so they do not stay straight
61
+ vec2 w = vec2(fbm(q * 0.35 + vec2(0.0, t)), fbm(q * 0.35 + vec2(7.1, -t)));
62
+ q += 1.5 * w;
63
+ vec2 offset = vec2(fbm(q), 0.5 * fbm(q + vec2(3.7, 1.9)));
64
+ // the hot air is near the ground: strongest at the bottom, fainter at the top
65
+ float ground = mix(1.0, 0.3, uv.y);
66
+ offset *= strength * amount * ground * vec2(1.0 / ratio, 1.0);
67
+
68
+ vec2 d = mirror(uv + offset);
69
+ // the images swap in the thick of the haze
70
+ float m = smoothstep(0.3, 0.7, p);
71
+ if (m <= 0.0) return getFromColor(d);
72
+ if (m >= 1.0) return getToColor(d);
73
+ vec4 a = getFromColor(d);
74
+ vec4 b = getToColor(d);
75
+ // mixed premultiplied, so transparent images do not bleed their color
76
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
77
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
78
+ }
@@ -0,0 +1,96 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image turns into a flickering hologram (blue by default) with scanlines and jittering rows, breaks up, and the hologram resolves into the incoming image in full color
4
+ // Tags: hologram, sci-fi, scanlines, flicker, glitch
5
+
6
+ // @color Color of the hologram
7
+ uniform vec3 tint; // = vec3(0.2, 0.75, 1.0)
8
+ // @color Color behind the hologram, seen between its scanlines and where it breaks up
9
+ uniform vec4 background; // = vec4(0.0, 0.02, 0.05, 1.0)
10
+ // @range(20, 300) Number of scanlines over the frame height
11
+ uniform float scanlines; // = 150.0
12
+ // @range(0, 0.2) How far rows of the hologram jump sideways, relative to the frame width
13
+ uniform float jitter; // = 0.04
14
+ // @range(0, 1) Strength of the flicker and of the rows that drop out
15
+ uniform float flicker; // = 0.6
16
+
17
+ const float PI = 3.14159265;
18
+ // steps per transition of the flicker and the jitter
19
+ const float STEPS = 32.0;
20
+
21
+ float hash(vec2 p) {
22
+ p = fract(p * vec2(443.897, 441.423));
23
+ p += dot(p, p.yx + 19.19);
24
+ return fract((p.x + p.y) * p.x);
25
+ }
26
+
27
+ float luma(vec3 c) {
28
+ return dot(c, vec3(0.299, 0.587, 0.114));
29
+ }
30
+
31
+ vec4 premultiplied(vec4 c) {
32
+ return vec4(c.rgb * c.a, c.a);
33
+ }
34
+
35
+ // the image the hologram shows: rows switch from the outgoing image to the incoming one
36
+ // while the hologram breaks up
37
+ vec4 source(vec2 uv, float m) {
38
+ return m > 0.5 ? getToColor(uv) : getFromColor(uv);
39
+ }
40
+
41
+ vec4 transition(vec2 uv) {
42
+ if (progress <= 0.0) return getFromColor(uv);
43
+ if (progress >= 1.0) return getToColor(uv);
44
+
45
+ float p = progress;
46
+ // how much of the hologram shows, and how broken up it is (peaking mid-transition)
47
+ float h = smoothstep(0.0, 0.3, p) * (1.0 - smoothstep(0.7, 1.0, p));
48
+ float b = smoothstep(0.0, 1.0, 1.0 - abs(p - 0.5) / 0.22);
49
+ float f = floor(p * STEPS);
50
+
51
+ // rows of the hologram jump sideways, more while it breaks up
52
+ float band = floor(uv.y * 36.0);
53
+ float jump = step(1.0 - (0.2 + 0.6 * b) * h, hash(vec2(band, f)));
54
+ float offset = (hash(vec2(band, f + 0.37)) - 0.5) * 2.0 * jitter * jump * (0.3 + 0.7 * b);
55
+ offset += sin(uv.y * 23.0 + f * 1.7) * 0.0015 * h;
56
+ vec2 q = uv + vec2(offset, 0.0);
57
+
58
+ // when each row of the hologram switches to the incoming image
59
+ float m = step(hash(vec2(floor(uv.y * 24.0), 7.0)), (p - 0.35) / 0.3);
60
+
61
+ // the hologram: the luma of the image in the tint, with colored fringes
62
+ // (sampled inside the frame, the fringes weighted by the alpha of their texels)
63
+ vec4 c = source(clamp(q, 0.0, 1.0), m);
64
+ vec2 dx = vec2(0.003 + 0.01 * b, 0.0);
65
+ float l = luma(c.rgb);
66
+ vec4 cr = source(clamp(q + dx, 0.0, 1.0), m);
67
+ vec4 cb = source(clamp(q - dx, 0.0, 1.0), m);
68
+ float lr = luma(cr.rgb) * cr.a;
69
+ float lb = luma(cb.rgb) * cb.a;
70
+ vec3 g = smoothstep(0.05, 0.9, vec3(lr, l, lb));
71
+ // the brightest parts burn toward white
72
+ vec3 holo = tint * (0.06 + 1.25 * g) + 0.45 * g * g * g;
73
+ // brighter scan band rolling down
74
+ float roll = fract(uv.y + 2.0 * p);
75
+ holo += tint * 0.35 * smoothstep(0.85, 1.0, roll) * (1.0 - smoothstep(0.98, 1.0, roll));
76
+ holo = clamp(holo, 0.0, 1.0);
77
+ // nothing outside the image where a row jumped out of the frame
78
+ float inside = step(0.0, q.x) * step(q.x, 1.0);
79
+
80
+ // opacity of the hologram: scanlines, flicker and missing rows
81
+ float lines = 0.5 + 0.5 * sin((uv.y * scanlines - p * 6.0) * 2.0 * PI);
82
+ float vis = mix(1.0, 0.15 + 0.85 * lines, h);
83
+ vis *= 1.0 - flicker * (0.25 + 0.75 * b) * hash(vec2(f, 3.1)) * h;
84
+ float gap = step(hash(vec2(floor(uv.y * 90.0), f + 0.71)), flicker * 0.45 * b);
85
+ vis *= 1.0 - gap;
86
+ vec4 layer = vec4(holo, c.a * vis * inside);
87
+ // the hologram over its background, transparent where neither the image nor the
88
+ // hologram is
89
+ vec4 plain = premultiplied(source(uv, m));
90
+ vec4 back = premultiplied(vec4(background.rgb, background.a * max(plain.a, layer.a)));
91
+ vec4 holoColor = premultiplied(layer) + back * (1.0 - layer.a);
92
+
93
+ // the images in full color, then the hologram over them
94
+ vec4 o = mix(plain, holoColor, h);
95
+ return o.a > 0.0 ? vec4(o.rgb / o.a, o.a) : vec4(0.0);
96
+ }
@@ -0,0 +1,57 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: A rectangle anchored in a corner, on an edge or in the center grows until the incoming image fills the frame, revealing it in place without scaling it; in reverse, the outgoing image shrinks into the rectangle
4
+ // Tags: wipe, shape, box
5
+
6
+ // @param Where the rectangle grows from: (0, 0) bottom left, (1, 1) top right, (0.5, 0) middle of the bottom edge, (0.5, 0.5) center
7
+ uniform vec2 anchor; // = vec2(1.0, 1.0)
8
+ // @range(0, 0.2) Softness of the rectangle's edge
9
+ uniform float smoothness; // = 0.0
10
+ // @range(0, 0.1) Width of a border drawn around the rectangle, in frame heights (0: no border)
11
+ uniform float borderWidth; // = 0.0
12
+ // @color Color of the border
13
+ uniform vec4 borderColor; // = vec4(1.0, 1.0, 1.0, 1.0)
14
+ // @param The outgoing image shrinks into the rectangle instead, toward the anchor
15
+ uniform bool reverse; // = false
16
+
17
+ // half width of the antialiased edge, in frame heights
18
+ const float AA = 0.001;
19
+
20
+ vec4 premultiplied(vec4 c) {
21
+ return vec4(c.rgb * c.a, c.a);
22
+ }
23
+
24
+ vec4 transition(vec2 uv) {
25
+ vec4 a = getFromColor(uv);
26
+ vec4 b = getToColor(uv);
27
+ if (progress <= 0.0) return a;
28
+ if (progress >= 1.0) return b;
29
+
30
+ vec2 an = clamp(anchor, 0.0, 1.0);
31
+ vec2 sq = vec2(ratio, 1.0);
32
+ // the rectangle keeps the proportions that make it reach every far side of the frame
33
+ // at once; measured in square pixels so its edge and border have an even width
34
+ vec2 ext = max(an, 1.0 - an) * sq;
35
+ vec2 d = abs(uv - an) * sq;
36
+ float s = max(smoothness, AA);
37
+ float bw = max(borderWidth, 0.0);
38
+
39
+ // eased growth, from a rectangle whose border is not yet in the frame to one whose
40
+ // soft edge has left it on every side
41
+ float t = reverse ? 1.0 - progress : progress;
42
+ float p = mix(t, t * t * (3.0 - 2.0 * t), 0.3);
43
+ vec2 size = p * ext + mix(-(bw + s), s, p);
44
+ // signed distance to the rectangle's edge, square-cornered, < 0 inside
45
+ float e = max(d.x - size.x, d.y - size.y);
46
+
47
+ // the rectangle shows the incoming image, or the outgoing one in reverse
48
+ vec4 inside = reverse ? a : b;
49
+ vec4 c = premultiplied(reverse ? b : a);
50
+ if (bw > 0.0) {
51
+ // laid over the image outside the rectangle, so a translucent border tints it
52
+ float m = 1.0 - smoothstep(bw - s, bw + s, e);
53
+ c = premultiplied(borderColor) * m + c * (1.0 - borderColor.a * m);
54
+ }
55
+ c = mix(c, premultiplied(inside), 1.0 - smoothstep(-s, s, e));
56
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
57
+ }
@@ -0,0 +1,199 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: Forked lightning bolts crack down from the top of the frame, the screen flashes white in a few stuttering strobes, and the incoming image appears lit by the last flickers as they fade out
4
+ // Tags: light, flash, weather, strobe
5
+
6
+ // @range(1, 3, 1) Number of bolts: the main one strikes the ground, the others fork out higher in the sky
7
+ uniform int bolts; // = 2
8
+ // @range(0, 1) Where the main bolt strikes, from the left (0) to the right (1) of the frame
9
+ uniform float strike; // = 0.55
10
+ // @range(0, 100, 1) Changes the shape of the bolts
11
+ uniform float seed; // = 0.0
12
+ // @color Color of the light, added to the images
13
+ uniform vec3 color; // = vec3(0.75, 0.85, 1.0)
14
+ // @range(0, 1) Size and brightness of the glow around the bolts
15
+ uniform float glow; // = 0.5
16
+ // @range(1, 4, 1) Number of strobes; the images switch during the brightest one
17
+ uniform int flashes; // = 3
18
+
19
+ // the bolts crack down until this time, then the strobes start
20
+ const float LEADER = 0.3;
21
+
22
+ float hash(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
+ // a value noise that is linear between its cells: a jagged polyline, centered on 0
29
+ float jag(float s, float k) {
30
+ float i = floor(s);
31
+ return mix(hash(vec2(i, k)), hash(vec2(i + 1.0, k)), fract(s)) - 0.5;
32
+ }
33
+
34
+ // the zigzag of a bolt around its straight line, at height y (narrower in a portrait frame)
35
+ float zigzag(float y, float k) {
36
+ return min(ratio, 1.0) * (0.15 * jag(y * 5.0, k) + 0.06 * jag(y * 13.0, k + 1.0) + 0.03 * jag(y * 31.0, k + 2.0) + 0.012 * jag(y * 67.0, k + 3.0));
37
+ }
38
+
39
+ // the x of a bolt at height y: from x0 at the top (y = 1) to x1 at its end (y = y1),
40
+ // given z0 and z1, its zigzag at both ends
41
+ float boltX(float y, float x0, float x1, float y1, float z0, float z1, float k) {
42
+ float t = (1.0 - y) / (1.0 - y1);
43
+ return mix(x0 - z0, x1 - z1, t) + zigzag(y, k);
44
+ }
45
+
46
+ // the x of a branch at height y: it leaves its bolt at (xb, yb), where its own zigzag is zb,
47
+ // and drifts sideways by dir per unit of height
48
+ float branchX(float y, float xb, float yb, float zb, float dir, float k) {
49
+ return xb + dir * (yb - y) + 0.6 * (zigzag(y, k) - zb);
50
+ }
51
+
52
+ // distance to a curve x = f(y), knowing its x and its slope at the pixel's height,
53
+ // and how far above or below its ends the pixel is; the slope only corrects the distance
54
+ // close to the curve, so the glow farther away does not streak along the zigzags
55
+ float curveDist(vec2 q, float x, float slope, float outside) {
56
+ float dx = abs(q.x - x);
57
+ float d = dx * mix(inversesqrt(1.0 + slope * slope), 1.0, smoothstep(0.0, 0.08, dx));
58
+ return length(vec2(d, max(outside, 0.0)));
59
+ }
60
+
61
+ // a strobe at time t0: a quick rise, a plateau of length hold, then a decay
62
+ float pulse(float p, float t0, float hold, float decay) {
63
+ float x = p - t0;
64
+ if (x < 0.0) return smoothstep(-0.012, 0.0, x);
65
+ return exp(-max(x - hold, 0.0) / decay);
66
+ }
67
+
68
+ vec4 transition(vec2 uv) {
69
+ float p = progress;
70
+ vec2 q = vec2(uv.x * ratio, uv.y);
71
+ // (seeds far apart, so that neighboring seeds share no hash keys)
72
+ float k0 = floor(seed) * 61.0;
73
+ int nb = bolts < 1 ? 1 : (bolts > 3 ? 3 : bolts);
74
+ int nf = flashes < 1 ? 1 : (flashes > 4 ? 4 : flashes);
75
+ // the images switch during the brightest strobe, the second one (or the only one)
76
+ int cut = nf > 1 ? 1 : 0;
77
+
78
+ // the strobes, a bit irregular; the bolts are lit by all of them, the screen mostly by the brightest
79
+ float flash = 0.0;
80
+ float lit = 0.0;
81
+ float tCut = LEADER;
82
+ float tLast = LEADER;
83
+ float t = LEADER;
84
+ for (int i = 0; i < 4; i++) {
85
+ if (i < nf) {
86
+ bool isCut = i == cut;
87
+ float amp = isCut ? 1.0 : (i < cut ? 0.55 : 0.7 * pow(0.75, float(i - cut - 1)));
88
+ float s = amp * pulse(p, t, isCut ? 0.025 : 0.004, isCut ? 0.03 : 0.022);
89
+ flash = max(flash, s);
90
+ lit = max(lit, pulse(p, t, 0.01, 0.045));
91
+ if (isCut) tCut = t;
92
+ tLast = t;
93
+ t += (isCut ? 0.12 : 0.08) + 0.04 * hash(vec2(float(i), k0 + 5.0));
94
+ }
95
+ }
96
+ // the stutter: the light jumps from one level to another a few times per strobe
97
+ float stutter = mix(0.7, 1.0, hash(vec2(floor(p * 70.0), k0 + 9.0)));
98
+ flash *= stutter;
99
+ // the brightest strobe whites the screen out while the images switch
100
+ float whiteout = pulse(p, tCut, 0.025, 0.02);
101
+ // then a few last flickers, fading out
102
+ float tail = p > tLast ? exp(-(p - tLast) / 0.1) * smoothstep(0.03, 0.06, p - tLast) : 0.0;
103
+ flash = max(flash, 0.35 * tail * step(0.45, hash(vec2(floor(p * 40.0), k0 + 13.0))));
104
+
105
+ // the bolts crack down in a few jumps while faintly lit, then light up with the strobes and go out
106
+ float grow = clamp(p / LEADER, 0.0, 1.0);
107
+ grow = (floor(grow * 7.0) + smoothstep(0.0, 1.0, fract(grow * 7.0))) / 7.0;
108
+ float faint = 0.5 * mix(0.6, 1.0, hash(vec2(floor(p * 50.0), k0 + 11.0)));
109
+ float boltLight = p < LEADER ? faint * smoothstep(0.0, 0.06, p) : max(lit * stutter, faint * exp(-(p - LEADER) / 0.12));
110
+ boltLight = max(boltLight, 0.6 * flash * tail);
111
+ boltLight *= 1.0 - smoothstep(tLast + 0.1, tLast + 0.3, p);
112
+
113
+ // the bolts: the main one strikes the ground at strike, the others stop in the sky
114
+ float core = 0.0;
115
+ float halo = 0.0;
116
+ float near = 10.0;
117
+ bool lightsOn = boltLight > 0.0 || flash > 0.0;
118
+ for (int b = 0; b < 3; b++) {
119
+ if (b < nb && lightsOn) {
120
+ float fb = float(b);
121
+ float kb = k0 + fb * 17.0;
122
+ float x1 = strike * ratio;
123
+ float y1 = -0.05;
124
+ float bright = 1.0;
125
+ if (b > 0) {
126
+ // the second bolt goes to the roomier side, the third to the other side if there is room there
127
+ float roomy = strike < 0.5 ? 1.0 : -1.0;
128
+ bool cramped = min(strike, 1.0 - strike) < 0.25;
129
+ float side = b == 1 || cramped ? roomy : -roomy;
130
+ float dist = b == 2 && cramped ? 0.5 : 0.22;
131
+ x1 = clamp(x1 + side * ratio * (dist + 0.12 * hash(vec2(fb, kb))), 0.08 * ratio, 0.92 * ratio);
132
+ y1 = 0.25 + 0.25 * hash(vec2(fb, kb + 1.0));
133
+ bright = 0.7;
134
+ }
135
+ float x0 = clamp(x1 + (hash(vec2(fb, kb + 2.0)) - 0.5) * 0.5 * min(ratio, 1.0), 0.1 * ratio, 0.9 * ratio);
136
+ // the tip of the bolt while it cracks down
137
+ float tip = mix(1.02, y1, grow);
138
+ // (the slope is measured over a few pixels, so it changes smoothly at the corners)
139
+ float e = 0.01;
140
+ float z0 = zigzag(1.0, kb);
141
+ float z1 = zigzag(y1, kb);
142
+ float x = boltX(q.y, x0, x1, y1, z0, z1, kb);
143
+ float slope = (boltX(q.y + e, x0, x1, y1, z0, z1, kb) - boltX(q.y - e, x0, x1, y1, z0, z1, kb)) / (2.0 * e);
144
+ float d = curveDist(q, x, slope, max(max(y1, tip) - q.y, q.y - 1.05));
145
+ near = min(near, d);
146
+ float w = 0.003 * mix(1.0, 0.7, fb / 2.0);
147
+ core += bright * exp(-d * d / (w * w));
148
+ halo += bright * (0.7 * exp(-d * 24.0) + 0.25 * exp(-d * 6.0));
149
+ // three branches, leaving the bolt on either side and fading toward their ends
150
+ for (int j = 0; j < 3; j++) {
151
+ float fj = float(j);
152
+ float kj = kb + 3.0 + fj * 5.0;
153
+ float tb = 0.12 + 0.2 * fj + 0.15 * hash(vec2(fj, kj));
154
+ float yb = mix(1.0, y1, tb);
155
+ float len = (0.3 + 0.25 * hash(vec2(fj, kj + 1.0))) * (1.0 - tb) * (1.0 - y1);
156
+ float dir = (j == 1 ? -1.0 : 1.0) * (0.2 + 0.45 * hash(vec2(fj, kj + 2.0))) * min(ratio, 1.0);
157
+ float xb = boltX(yb, x0, x1, y1, z0, z1, kb);
158
+ float zb = zigzag(yb, kj);
159
+ float bx = branchX(q.y, xb, yb, zb, dir, kj);
160
+ float bs = (branchX(q.y + e, xb, yb, zb, dir, kj) - branchX(q.y - e, xb, yb, zb, dir, kj)) / (2.0 * e);
161
+ float bd = curveDist(q, bx, bs, max(max(yb - len, tip) - q.y, q.y - yb));
162
+ near = min(near, bd);
163
+ float along = clamp((yb - q.y) / len, 0.0, 1.0);
164
+ float fade = bright * (1.0 - 0.8 * along);
165
+ float bw = w * mix(0.8, 0.4, along);
166
+ core += fade * exp(-bd * bd / (bw * bw));
167
+ halo += fade * 0.6 * (0.7 * exp(-bd * 24.0) + 0.25 * exp(-bd * 6.0));
168
+ }
169
+ }
170
+ }
171
+
172
+ // the outgoing image gives way to the incoming one at the brightest strobe, hidden by it
173
+ float m = smoothstep(tCut, tCut + 0.025, p);
174
+ vec4 c = vec4(0.0);
175
+ if (m < 1.0) {
176
+ vec4 a = getFromColor(uv);
177
+ c += (1.0 - m) * vec4(a.rgb * a.a, a.a);
178
+ }
179
+ if (m > 0.0) {
180
+ vec4 a = getToColor(uv);
181
+ c += m * vec4(a.rgb * a.a, a.a);
182
+ }
183
+ if (c.a <= 0.0) return vec4(0.0);
184
+ vec3 col = c.rgb / c.a;
185
+
186
+ // the effect fades in at the start and is gone at the end
187
+ float live = smoothstep(0.0, 0.03, p) * (1.0 - smoothstep(0.85, 1.0, p));
188
+ // the sky darkens a little as the storm builds, then the strobes overexpose the image,
189
+ // more around the bolts, and the bolts glow over it
190
+ float dim = 0.4 * smoothstep(0.0, LEADER, p) * (1.0 - smoothstep(tCut, tLast + 0.15, p));
191
+ float f = flash * mix(0.6 + 0.4 * exp(-near * 4.0), 1.0, smoothstep(0.6, 1.0, flash));
192
+ col *= 1.0 - dim * live;
193
+ col = col * (1.0 + 2.5 * f * live) + color * (1.1 * f * live);
194
+ float g = 0.4 + 1.2 * glow;
195
+ vec3 light = mix(color, vec3(1.0), 0.75) * min(core, 1.5) * 1.6 + color * g * halo;
196
+ col += light * boltLight * live;
197
+ col = mix(col, vec3(1.0), 0.92 * whiteout * live);
198
+ return vec4(clamp(col, 0.0, 1.0), c.a);
199
+ }
@@ -0,0 +1,101 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The incoming image rises over the outgoing one like liquid filling a glass, its surface sloshing in waves, lit by a bright meniscus line, bending the image just below it, with a few bubbles rising through it
4
+ // Tags: liquid, water, wave, directional, reveal
5
+
6
+ // @param Direction the liquid rises toward
7
+ uniform vec2 direction; // = vec2(0.0, 1.0)
8
+ // @range(0, 0.3) Height of the waves on the surface, in frame heights
9
+ uniform float amplitude; // = 0.06
10
+ // @range(0.5, 6) Number of waves across the frame
11
+ uniform float waves; // = 1.5
12
+ // @color Color of the bright line along the surface and the rims of the bubbles (its alpha is its strength)
13
+ uniform vec4 highlight; // = vec4(1.0, 1.0, 1.0, 0.8)
14
+ // @range(0, 0.1) How much the incoming image is bent just below the surface
15
+ uniform float refraction; // = 0.03
16
+ // @range(0, 1) How many bubbles rise through the liquid
17
+ uniform float bubbles; // = 0.5
18
+
19
+ const float PI = 3.141592653589793;
20
+ // half width of the antialiased edges, in frame heights
21
+ const float AA = 0.0015;
22
+ // width of the meniscus line, in frame heights
23
+ const float LINE = 0.006;
24
+ // size of the cells the bubbles are scattered in, in frame heights
25
+ const float CELL = 0.08;
26
+
27
+ float hash (vec2 p) {
28
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
29
+ p3 += dot(p3, p3.yzx + 33.33);
30
+ return fract((p3.x + p3.y) * p3.z);
31
+ }
32
+
33
+ // height of the surface above its mean level at x (across the frame, from -1 to 1), between -1 and 1:
34
+ // a slosh from side to side and a smaller wave running along it
35
+ float surface (float x, float t) {
36
+ float k = PI * max(waves, 0.01);
37
+ return 0.6 * sin(k * x + 0.5 * PI) * cos(2.0 * PI * 1.3 * t)
38
+ + 0.4 * sin(1.7 * k * x - 9.0 * t + 1.3);
39
+ }
40
+
41
+ vec4 transition (vec2 uv) {
42
+ vec4 a = getFromColor(uv);
43
+ if (progress <= 0.0) return a;
44
+ if (progress >= 1.0) return getToColor(uv);
45
+
46
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(0.0, 1.0);
47
+ vec2 across = vec2(-dir.y, dir.x);
48
+ // measured in square pixels, so the waves and bubbles are not stretched
49
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
50
+ // half extents of the frame along the direction and across it
51
+ float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
52
+ float w = 0.5 * (abs(dir.y) * ratio + abs(dir.x));
53
+ float d = dot(p, dir);
54
+ float x = dot(p, across);
55
+ float t = progress;
56
+ // the liquid moves most in the middle of the transition and settles at the ends
57
+ float stir = sin(PI * t);
58
+ float amp = max(amplitude, 0.0) * (0.35 + 0.65 * stir);
59
+ // the surface starts fully below the frame and ends fully above it, waves and meniscus included
60
+ float margin = max(amplitude, 0.0) + 2.0 * LINE + AA;
61
+ float mean = mix(-e - margin, e + margin, mix(t, t * t * (3.0 - 2.0 * t), 0.5));
62
+ float level = mean + amp * surface(x / w, t);
63
+ // > 0 below the surface, in the liquid
64
+ float depth = level - d;
65
+ float m = smoothstep(-AA, AA, depth);
66
+
67
+ // the incoming image is bent by the waves just below the surface, less and less deeper down
68
+ float bend = refraction * stir * exp(-max(depth, 0.0) / 0.06);
69
+ vec2 offset = bend * (dir * sin(18.0 * x - 7.0 * t) + across * cos(13.0 * x + 5.0 * t));
70
+ vec4 b = getToColor(clamp(uv + offset / vec2(ratio, 1.0), 0.0, 1.0));
71
+
72
+ // bubbles rise in columns through the liquid, carried up with it and rising faster still
73
+ float glow = 0.0;
74
+ float rise = mean + 0.5 * t;
75
+ vec2 bq = vec2(x, d - rise) / CELL;
76
+ vec2 cell = floor(bq);
77
+ float hs = hash(cell + 7.1);
78
+ float r = (0.12 + 0.18 * hash(cell + 3.7)) * stir;
79
+ float px = AA / CELL;
80
+ if (hs < bubbles * 0.6 && r > px) {
81
+ // placed so that it stays inside its cell, wobble and soft edge included
82
+ vec2 c = cell + 0.5 + (0.42 - r - px) * (vec2(hash(cell + 1.3), hash(cell + 9.4)) * 2.0 - 1.0);
83
+ // a slight wobble as it rises
84
+ c.x += 0.08 * sin(6.0 * t + 6.28 * hs);
85
+ float dist = length(bq - c);
86
+ // its rim, and a small glint near its top
87
+ float rim = smoothstep(0.7 * r - px, 0.7 * r + px, dist) * (1.0 - smoothstep(r - px, r + px, dist));
88
+ float glint = 1.0 - smoothstep(0.25 * r - px, 0.25 * r + px, length(bq - c - 0.45 * r * vec2(-0.7, 0.7)));
89
+ // only in the liquid, and fading out as it nears the surface
90
+ glow = max(rim * 0.6, glint) * smoothstep(0.0, 0.05, depth) * stir;
91
+ }
92
+ // the meniscus: a bright line along the surface, on the liquid side
93
+ float line = 1.0 - smoothstep(LINE - AA, LINE + AA, abs(depth - LINE));
94
+ line += 0.35 * stir * exp(-max(depth, 0.0) / 0.03) * m;
95
+ float light = highlight.a * clamp(max(line, glow), 0.0, 1.0) * (0.4 + 0.6 * stir);
96
+ b.rgb = mix(b.rgb, highlight.rgb, light);
97
+
98
+ // mixed premultiplied, so transparent images do not bleed their color
99
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
100
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
101
+ }
@@ -0,0 +1,50 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: A flowing plasma of sine waves, as in the old demos, draws moving bands through which the incoming image spreads like tendrils, with a glowing edge
4
+ // Tags: wipe, plasma, organic, glow
5
+
6
+ // @range(0.5, 10) Size of the plasma: higher values make more, thinner bands
7
+ uniform float scale; // = 3.0
8
+ // @range(0, 0.5) Softness of the band edges
9
+ uniform float smoothness; // = 0.1
10
+ // @range(0, 1) How much the plasma flows during the transition (at most 1, so a revealed area never goes back)
11
+ uniform float flow; // = 1.0
12
+ // @color Color of the glow along the edges
13
+ uniform vec3 edgeColor; // = vec3(1.0, 0.45, 0.9)
14
+ // @range(0, 2) Strength of the glow along the edges
15
+ uniform float edgeStrength; // = 0.6
16
+
17
+ const float PI = 3.14159265;
18
+
19
+ vec4 transition(vec2 uv) {
20
+ vec4 a = getFromColor(uv);
21
+ vec4 b = getToColor(uv);
22
+ if (progress <= 0.0) return a;
23
+ if (progress >= 1.0) return b;
24
+
25
+ // measured in square pixels, so the waves are not stretched
26
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0) * max(scale, 0.0) * 2.0 * PI;
27
+ // the phase of the waves; the folded plasma below then changes by at most 0.9 * flow per
28
+ // unit of progress, slower than the threshold, so the reveal never goes back
29
+ float t = clamp(flow, 0.0, 1.0) * progress * 0.5;
30
+ // the classic plasma: sines of x, y, a diagonal and the distance to an off-center point
31
+ float v = sin(p.x * 0.6 + t)
32
+ + sin(p.y * 0.8 - t * 0.8)
33
+ + sin((p.x * 0.5 + p.y * 0.7) * 0.7 + t * 0.6)
34
+ + sin(length(p - vec2(0.15, -0.1) * max(scale, 0.0) * 2.0 * PI) * 0.9 - t * 1.2);
35
+ // folded into bands in [0, 1]
36
+ v = abs(fract(v * 0.25 + 0.5) * 2.0 - 1.0);
37
+
38
+ // the soft edge is fully below every band at the start and above every band at the end
39
+ float s = max(smoothness, 0.001);
40
+ float threshold = mix(-s, 1.0 + s, progress);
41
+ // > 0 where the incoming image shows
42
+ float m = 1.0 - smoothstep(threshold - s, threshold + s, v);
43
+
44
+ // mixed premultiplied, so transparent images do not bleed their color
45
+ vec4 col = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
46
+ if (col.a <= 0.0) return vec4(0.0);
47
+ // a light along the edge, adding nothing to the alpha
48
+ float glow = 4.0 * m * (1.0 - m) * max(edgeStrength, 0.0);
49
+ return vec4(col.rgb / col.a + edgeColor * glow, col.a);
50
+ }