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