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,106 @@
1
+ // RingsWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/RingsWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Concentric rings ripple out from the center and, one after another, each sweeps around like a clock hand in the opposite direction of its neighbors to reveal the incoming image, or fills across its width, with optional colored borders between the rings
5
+ // Tags: wipe, circle, radial, rings, clock
6
+
7
+ // @range(1, 20, 1) Number of rings, from the center to the farthest corner
8
+ uniform int count; // = 6
9
+ // @param Center of the rings, in texture coordinates
10
+ uniform vec2 center; // = vec2(0.5, 0.5)
11
+ // @range(0, 1) Delay between the starts of two rings: 0 moves them all together, 1 starts each one when the previous one is done
12
+ uniform float stagger; // = 0.5
13
+ // @param Each ring fills across its width, outward and inward in turn, instead of sweeping around
14
+ uniform bool radial; // = false
15
+ // @range(0, 0.05) Width of the borders between the rings while they move, in frame heights (0 disables them)
16
+ uniform float borderWidth; // = 0.008
17
+ // @color Color of the borders between the rings
18
+ uniform vec4 borderColor; // = vec4(1.0, 1.0, 1.0, 1.0)
19
+ // @range(0, 0.1) Softness of the edges
20
+ uniform float smoothness; // = 0.004
21
+
22
+ const float PI = 3.141592653589793;
23
+ // half width of the antialiased edge, in frame heights
24
+ const float AA = 0.0015;
25
+
26
+ // progress of ring i, from 0 (not started) to 1 (done), each ring lasting d and starting
27
+ // k * d after the previous one
28
+ float ringProgress(float i, float k, float d, float t) {
29
+ return clamp((t - i * k * d) / d, 0.0, 1.0);
30
+ }
31
+
32
+ // how much ring i, of width w and progress lp, shows the incoming image at radius rad and
33
+ // turn a (0 to 1)
34
+ float ringMask(float i, float lp, float w, float rad, float a, float s) {
35
+ bool odd = mod(i, 2.0) > 0.5;
36
+ if (radial) {
37
+ // the filled part grows across the ring, from its inner edge or from its outer one,
38
+ // starting and ending a soft edge past the ring; measured within the ring, so a ring
39
+ // that has not started does not leak into its neighbor's antialiased boundary
40
+ float e = s / w;
41
+ float f = mix(-e, 1.0 + e, lp);
42
+ float x = clamp((rad - i * w) / w, 0.0, 1.0);
43
+ float dist = (odd ? f - (1.0 - x) : f - x) * w;
44
+ return smoothstep(-s, s, dist);
45
+ }
46
+ // the filled part is a growing arc from the top, clockwise on even rings and
47
+ // counterclockwise on odd ones; both of its ends are soft, and it starts empty and
48
+ // ends full, wrapping around, by a soft edge measured along the circle (no shorter than
49
+ // the softness itself near the center, so the center is not left half blended)
50
+ float aa = odd ? 1.0 - a : a;
51
+ float arc = 2.0 * PI * max(rad, s);
52
+ float e = s / arc;
53
+ float lo = mix(e, -e, lp);
54
+ float hi = mix(-e, 1.0 + e, lp);
55
+ float dist = max(min(aa - lo, hi - aa), min(aa - 1.0 - lo, hi - aa + 1.0));
56
+ return smoothstep(-s, s, dist * arc);
57
+ }
58
+
59
+ vec4 transition(vec2 uv) {
60
+ vec4 a = getFromColor(uv);
61
+ vec4 b = getToColor(uv);
62
+ if (progress <= 0.0) return a;
63
+ if (progress >= 1.0) return b;
64
+
65
+ float n = float(count < 1 ? 1 : count);
66
+ // measured in square pixels, so the rings are round
67
+ vec2 p = (uv - center) * vec2(ratio, 1.0);
68
+ // the rings reach the farthest corner
69
+ vec2 far = max(center, 1.0 - center) * vec2(ratio, 1.0);
70
+ float R = length(far) + AA;
71
+ float w = R / n;
72
+ float rad = length(p);
73
+ float turn = rad > 0.0 ? fract(atan(p.x, p.y) / (2.0 * PI)) : 0.0;
74
+ float s = max(min(smoothness, 0.25 * w), AA);
75
+ float t = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.35);
76
+ float k = clamp(stagger, 0.0, 1.0);
77
+ float d = 1.0 / (1.0 + k * (n - 1.0));
78
+
79
+ // blend the two rings on either side of the nearest boundary, so it is antialiased
80
+ float j = floor(rad / w + 0.5);
81
+ float inner = clamp(j - 1.0, 0.0, n - 1.0);
82
+ float outer = clamp(j, 0.0, n - 1.0);
83
+ float li = ringProgress(inner, k, d, t);
84
+ float lo = ringProgress(outer, k, d, t);
85
+ float m = mix(
86
+ ringMask(inner, li, w, rad, turn, s),
87
+ ringMask(outer, lo, w, rad, turn, s),
88
+ smoothstep(-AA, AA, rad - j * w)
89
+ );
90
+
91
+ // mixed premultiplied, so transparent images do not bleed their color
92
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
93
+
94
+ // the border between two rings shows from when the inner one starts until the outer one
95
+ // is done, without dimming when one hands over to the other
96
+ if (borderWidth > 0.0 && j >= 1.0 && j <= n - 1.0) {
97
+ float on = min(1.0, 4.0 * li * (1.0 - lo));
98
+ // never wider than the ring, and thinner than the antialiasing only by fading out
99
+ float hw = min(0.5 * borderWidth, 0.5 * w - AA);
100
+ float line = (1.0 - smoothstep(hw - AA, hw + AA, abs(rad - j * w)))
101
+ * min(1.0, borderWidth / (2.0 * AA));
102
+ float o = borderColor.a * line * on;
103
+ c = vec4(borderColor.rgb * o, o) + c * (1.0 - o);
104
+ }
105
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
106
+ }
@@ -0,0 +1,73 @@
1
+ // SawtoothWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SawtoothWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A wipe whose edge is a row of sharp, regular triangular teeth sweeps across the frame, or two toothed edges that start interlocked part from the middle like jaws opening
5
+ // Tags: wipe, shape, directional, zigzag
6
+
7
+ // @param Direction the toothed edge moves toward (with jaws, the axis along which the two edges part)
8
+ uniform vec2 direction; // = vec2(1.0, 0.0)
9
+ // @range(1, 40, 1) Number of teeth along the edge
10
+ uniform int teeth; // = 8
11
+ // @range(0, 3) Length of the teeth, relative to their width
12
+ uniform float depth; // = 1.0
13
+ // @param Two toothed edges part from the middle instead of one sweeping across
14
+ uniform bool jaws; // = false
15
+ // @range(0, 0.1) Softness of the edge
16
+ uniform float smoothness; // = 0.004
17
+
18
+ // half width of the antialiased edge, in frame heights
19
+ const float AA = 0.0015;
20
+
21
+ // signed distance to a zigzag line of period w and peak-to-peak height h, centered on y = 0,
22
+ // its tips pointing up at x = 0; positive above it
23
+ float zigzag(vec2 q, float w, float h) {
24
+ // fold into half a tooth: the slope from the bottom of a notch to the tip of a tooth
25
+ float x = abs(fract(q.x / w) - 0.5) * w;
26
+ vec2 a = vec2(0.0, -0.5 * h);
27
+ vec2 ab = vec2(0.5 * w, h);
28
+ vec2 aq = vec2(x, q.y) - a;
29
+ float d = length(aq - ab * clamp(dot(aq, ab) / dot(ab, ab), 0.0, 1.0));
30
+ return q.y > h * (2.0 * x / w - 0.5) ? d : -d;
31
+ }
32
+
33
+ vec4 transition(vec2 uv) {
34
+ vec4 a = getFromColor(uv);
35
+ vec4 b = getToColor(uv);
36
+ if (progress <= 0.0) return a;
37
+ if (progress >= 1.0) return b;
38
+
39
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
40
+ // measured in square pixels, so the teeth are not stretched
41
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
42
+ // half extents of the frame along the direction and across it
43
+ float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
44
+ float w = 0.5 * (abs(dir.y) * ratio + abs(dir.x));
45
+ float period = 2.0 * w / float(teeth < 1 ? 1 : teeth);
46
+ // position across the edge, with the notches on the sides of the frame so that it shows
47
+ // whole teeth, and along the direction
48
+ vec2 q = vec2(dot(p, vec2(-dir.y, dir.x)) + w + 0.5 * period, dot(p, dir));
49
+ float h = max(depth, 0.0) * period;
50
+ // the soft edge never gets wide enough to blur small teeth away
51
+ float s = max(min(smoothness, 0.25 * period), AA);
52
+ float t = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.35);
53
+
54
+ float d;
55
+ if (jaws) {
56
+ // the two edges are the same zigzag, interlocked at the start (crossed by the soft
57
+ // edge, measured across the slopes of the teeth), then moving apart until each one
58
+ // has left the frame on its side
59
+ float overlap = s * sqrt(1.0 + 4.0 * h * h / (period * period));
60
+ float o = mix(-overlap, e + 0.5 * h + s, t);
61
+ d = max(zigzag(q - vec2(0.0, o), period, h), -zigzag(q + vec2(0.0, o), period, h));
62
+ } else {
63
+ // the edge starts fully ahead of the frame and ends fully past it
64
+ float c = mix(-e - 0.5 * h - s, e + 0.5 * h + s, t);
65
+ d = zigzag(q - vec2(0.0, c), period, h);
66
+ }
67
+ // > 0 where the incoming image shows
68
+ float m = 1.0 - smoothstep(-s, s, d);
69
+
70
+ // mixed premultiplied, so transparent images do not bleed their color
71
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
72
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
73
+ }
@@ -0,0 +1,40 @@
1
+ // SnakeBlockWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SnakeBlockWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Blocks switch to the incoming image one at a time, row after row from the top (or column after column from the left), each line running the opposite way to the one before, like a snake winding across the frame
5
+ // Tags: wipe, blocks, grid, zigzag
6
+
7
+ // @param Number of blocks (columns, rows)
8
+ uniform ivec2 grid; // = ivec2(8, 6)
9
+ // @param Wind down the columns instead of along the rows
10
+ uniform bool vertical; // = false
11
+ // @range(0, 4) How long each block takes to fade in, in turns of one block (0 switches it at once)
12
+ uniform float smoothness; // = 0.5
13
+
14
+ vec4 transition(vec2 uv) {
15
+ vec4 a = getFromColor(uv);
16
+ vec4 b = getToColor(uv);
17
+ if (progress <= 0.0) return a;
18
+ if (progress >= 1.0) return b;
19
+
20
+ vec2 g = max(vec2(grid), 1.0);
21
+ // block coordinates from the top left corner
22
+ vec2 cell = min(floor(vec2(uv.x, 1.0 - uv.y) * g), g - 1.0);
23
+ // the snake runs along the rows, or along the columns when vertical
24
+ float lines = vertical ? g.x : g.y;
25
+ float len = vertical ? g.y : g.x;
26
+ float line = vertical ? cell.x : cell.y;
27
+ float pos = vertical ? cell.y : cell.x;
28
+ // every other line runs backward
29
+ if (mod(line, 2.0) > 0.5) pos = len - 1.0 - pos;
30
+ float order = line * len + pos;
31
+
32
+ // block k fades in from k to k + w, on a timeline from 0 to n - 1 + w
33
+ float n = lines * len;
34
+ float w = max(smoothness, 0.001);
35
+ float m = clamp((progress * (n - 1.0 + w) - order) / w, 0.0, 1.0);
36
+
37
+ // mixed premultiplied, so transparent images do not bleed their color
38
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
39
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
40
+ }
@@ -0,0 +1,86 @@
1
+ // Snapshot — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Snapshot.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A camera flash freezes the outgoing image into a printed photo with a white border, which shrinks, tilts and drops out of the frame, revealing the incoming image behind it
5
+ // Tags: photo, flash, scale, rotate, fall, shadow
6
+
7
+ // @range(0, 1) How much the photo turns as it drops
8
+ uniform float tilt; // = 0.35
9
+ // @range(0, 0.15) Width of the photo's border, relative to the frame height
10
+ uniform float border; // = 0.04
11
+ // @range(0, 1) Strength of the camera flash
12
+ uniform float flash; // = 0.85
13
+ // @range(0, 1) Darkness of the soft shadow the photo casts on the incoming image
14
+ uniform float shadow; // = 0.45
15
+ // @color Color of the photo's border
16
+ uniform vec4 borderColor; // = vec4(0.96, 0.94, 0.89, 1.0)
17
+
18
+ const float SHRINK = 0.24; // how much smaller the photo gets before it drops
19
+ const float RADIUS = 0.008; // corner radius of the photo, in frame heights
20
+ const float AA = 0.0015; // width of the antialiased edges, in frame heights
21
+
22
+ // signed distance to a rounded box of half size b and corner radius r
23
+ float roundedBox(vec2 q, vec2 b, float r) {
24
+ vec2 d = abs(q) - b + r;
25
+ return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r;
26
+ }
27
+
28
+ vec4 premultiply(vec4 c) {
29
+ return vec4(c.rgb * c.a, c.a);
30
+ }
31
+
32
+ vec4 transition(vec2 uv) {
33
+ float p = progress;
34
+ vec2 asp = vec2(ratio, 1.0);
35
+ vec2 q = (uv - 0.5) * asp;
36
+ vec2 halfImage = 0.5 * asp;
37
+ vec2 halfCard = halfImage + border;
38
+
39
+ // the photo shrinks right after the flash, then falls with gravity, turning as it goes
40
+ float k = smoothstep(0.05, 0.4, p);
41
+ float t = clamp((p - 0.3) / 0.7, 0.0, 1.0);
42
+ float fall = t * t;
43
+ float s = 1.0 - SHRINK * k;
44
+ float a = -tilt * (0.12 * k + 0.88 * fall);
45
+ // fall far enough for the turned photo and its shadow to be out of the frame at the end
46
+ float bound = (abs(sin(tilt)) * halfCard.x + abs(cos(tilt)) * halfCard.y) * (1.0 - SHRINK);
47
+ // it is lifted a little toward the viewer before it falls
48
+ float lift = 0.035 * k * (1.0 - fall);
49
+ vec2 center = vec2(0.08 * fall, lift - (0.5 + bound + 0.1) * fall);
50
+
51
+ float rad = RADIUS * k;
52
+
53
+ float ca = cos(a), sa = sin(a);
54
+ mat2 unrotate = mat2(ca, -sa, sa, ca);
55
+
56
+ // the incoming image, already behind the photo, in its soft shadow
57
+ vec4 col = getToColor(uv);
58
+ float sh = shadow * k;
59
+ if (sh > 0.0) {
60
+ vec2 rs = unrotate * (q - center - vec2(0.012, -0.022) * k) / s;
61
+ float ds = roundedBox(rs, halfCard, rad) * s;
62
+ float blur = 0.035 * s;
63
+ col.rgb *= 1.0 - sh * (1.0 - smoothstep(-blur, blur, ds));
64
+ }
65
+ col = premultiply(col);
66
+
67
+ // the photo: the outgoing image, framed by its border
68
+ vec2 r = unrotate * (q - center) / s;
69
+ float dCard = roundedBox(r, halfCard, rad) * s;
70
+ float dImage = roundedBox(r, halfImage, 0.0) * s;
71
+ // the edges are pushed out by one antialiasing width, so the photo covers the full frame at the start
72
+ float cardCover = clamp(1.5 - dCard / AA, 0.0, 1.0);
73
+ float imageCover = clamp(1.5 - dImage / AA, 0.0, 1.0);
74
+ // the image replaces what is behind it, while the border is laid over the incoming image, which shows through a translucent border
75
+ vec4 photo = premultiply(getFromColor(clamp(r / asp + 0.5, 0.0, 1.0)));
76
+ vec4 paper = premultiply(borderColor);
77
+ vec4 card = mix(paper + col * (1.0 - paper.a), photo, imageCover);
78
+ col = mix(col, card, cardCover);
79
+ if (col.a <= 0.0) return vec4(0.0);
80
+ col.rgb /= col.a;
81
+
82
+ // the flash only adds light: a quick bloom to white that fades as the photo comes out
83
+ float f = flash * smoothstep(0.0, 0.05, p) * (1.0 - smoothstep(0.05, 0.3, p));
84
+ col.rgb = 1.0 - (1.0 - col.rgb) * (1.0 - f);
85
+ return col;
86
+ }
@@ -0,0 +1,95 @@
1
+ // Sphere — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Sphere.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image wraps itself onto a shaded ball that shrinks and rolls away, revealing the incoming image under its shadow
5
+ // Tags: 3d, sphere, roll, wrap, shape
6
+
7
+ // @param Direction the ball rolls away toward
8
+ uniform vec2 direction; // = vec2(1.0, 0.0)
9
+ // @range(0.1, 0.5) Radius of the ball once wrapped, relative to the shorter side of the frame
10
+ uniform float size; // = 0.3
11
+ // @range(0, 1) Strength of the light and shading on the ball
12
+ uniform float shading; // = 0.6
13
+ // @range(0, 1) Darkness of the soft shadow the ball casts on the incoming image
14
+ uniform float shadow; // = 0.5
15
+
16
+ const float PI = 3.14159265;
17
+ // half width of the antialiased ball edge, in frame heights
18
+ const float AA = 0.0015;
19
+ // toward the light, from the top left
20
+ const vec3 LIGHT = vec3(-0.5, 0.6, 1.0) / 1.2689;
21
+
22
+ vec4 transition(vec2 uv) {
23
+ if (progress <= 0.0) return getFromColor(uv);
24
+ vec4 b = getToColor(uv);
25
+ if (progress >= 1.0) return b;
26
+
27
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
28
+ vec2 side = vec2(-dir.y, dir.x);
29
+ // measured in square pixels, so the ball is round
30
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
31
+ float shorter = min(ratio, 1.0);
32
+ float r0 = clamp(size, 0.1, 0.5) * shorter;
33
+
34
+ // the image curves into a ball (infinite radius: exactly flat at the start), then the
35
+ // ball shrinks while rolling away until it and its shadow have left the frame
36
+ float w = clamp(progress / 0.45, 0.0, 1.0);
37
+ w = 1.0 - (1.0 - w) * (1.0 - w);
38
+ float away = smoothstep(0.3, 1.0, progress);
39
+ away *= away;
40
+ float wrapped = r0 / max(w, 1e-4);
41
+ float radius = wrapped * mix(1.0, 0.5, away);
42
+ // the image is pulled tighter as it wraps, so that it ends up covering the whole ball
43
+ // (its shortest half extent reaches around to the back)
44
+ float tight = mix(1.0, min(1.0, 0.48 * shorter / (PI * r0)), w * w);
45
+ float paper = radius * tight;
46
+ // half extent of the frame along the direction
47
+ float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
48
+ // far enough that the ball (0.5 * r0 by then) and its shadow (within 0.9 * r0 of it) have left
49
+ float full = e + 1.1 * r0 + 2.0 * AA;
50
+ float travel = away * full;
51
+ vec2 center = dir * travel;
52
+ // rolling without slipping: the integral of dtravel / radius while the radius shrinks
53
+ float angle = -2.0 * full * log(1.0 - 0.5 * away) / wrapped;
54
+
55
+ vec2 d = p - center;
56
+ float r = length(d);
57
+
58
+ // soft shadow on the incoming image, below and to the right of the ball (light from the top left)
59
+ vec2 sd = d - vec2(0.25, -0.3) * radius * w;
60
+ float sh = shadow * w * (1.0 - smoothstep(0.6 * radius, 1.4 * radius, length(sd)));
61
+ vec4 bg = vec4(b.rgb * b.a * (1.0 - sh), b.a);
62
+
63
+ vec4 ball = vec4(0.0);
64
+ float cover = 1.0 - smoothstep(radius - AA, radius + AA, r);
65
+ if (cover > 0.0) {
66
+ // normal of the visible point of the ball (no squared radius, which overflows when it is huge)
67
+ vec2 nd = d / radius;
68
+ vec3 n = vec3(nd, sqrt(max(1.0 - dot(nd, nd), 0.0)));
69
+ // undo the roll: rotate around the axis across the direction
70
+ float u = dot(n.xy, dir);
71
+ float s = dot(n.xy, side);
72
+ float cu = cos(angle), su = sin(angle);
73
+ vec3 q = vec3(u * cu - n.z * su, s, u * su + n.z * cu);
74
+ // the image is wrapped around the ball from its front point, distances kept along the surface
75
+ float lq = length(q.xy);
76
+ float arc = atan(lq, q.z) * paper;
77
+ vec2 img = lq > 0.0 ? (q.x * dir + q.y * side) / lq * arc : vec2(0.0);
78
+ vec2 iuv = img / vec2(ratio, 1.0) + 0.5;
79
+ // distance to the edge of the image, antialiased like the ball's outline
80
+ vec2 edge = min(iuv, 1.0 - iuv) * vec2(ratio, 1.0);
81
+ float inside = cover * smoothstep(-AA, AA, min(edge.x, edge.y));
82
+ if (inside > 0.0) {
83
+ vec4 c = getFromColor(clamp(iuv, 0.0, 1.0));
84
+ float diff = max(dot(n, LIGHT), 0.0);
85
+ float spec = pow(max(reflect(-LIGHT, n).z, 0.0), 24.0);
86
+ float k = shading * w;
87
+ vec3 lit = c.rgb * mix(1.0, 0.25 + 0.85 * diff, k) + 0.35 * k * spec;
88
+ ball = vec4(clamp(lit, 0.0, 1.0) * c.a, c.a) * inside;
89
+ }
90
+ }
91
+
92
+ // the ball over the incoming image, premultiplied so transparent images do not bleed their color
93
+ vec4 c = ball + bg * (1.0 - ball.a);
94
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
95
+ }
@@ -0,0 +1,65 @@
1
+ // SpiralBlockWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SpiralBlockWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Square blocks switch to the incoming image one after another along a rectangular spiral, from the border inward or from the center outward
5
+ // Tags: wipe, grid, blocks, spiral
6
+
7
+ // @param Number of blocks (columns, rows)
8
+ uniform ivec2 grid; // = ivec2(8, 6)
9
+ // @param Spiral from the top left corner inward; false spirals from the center outward, ending at the top left corner
10
+ uniform bool inward; // = true
11
+ // @param Turn clockwise; false turns counterclockwise
12
+ uniform bool clockwise; // = true
13
+ // @range(0, 0.5) Duration of each block's fade, as a fraction of the transition
14
+ uniform float smoothness; // = 0.05
15
+
16
+ // Position of the cell c (from the top left corner) along the spiral that runs clockwise
17
+ // from the top left corner of a n.x by n.y grid inward, from 0 to n.x * n.y - 1
18
+ float spiralIndex(vec2 c, vec2 n) {
19
+ // ring: distance to the border, in cells
20
+ float k = min(min(c.x, c.y), min(n.x - 1.0 - c.x, n.y - 1.0 - c.y));
21
+ // size of the ring, and the cell's position in it
22
+ vec2 s = n - 2.0 * k;
23
+ vec2 l = c - k;
24
+ // the outer rings come first
25
+ float before = n.x * n.y - s.x * s.y;
26
+ float along;
27
+ if (l.y == 0.0) along = l.x; // top side, to the right
28
+ else if (l.x == s.x - 1.0) along = s.x - 1.0 + l.y; // right side, down
29
+ else if (l.y == s.y - 1.0) along = 2.0 * s.x + s.y - 3.0 - l.x; // bottom side, to the left
30
+ else along = 2.0 * (s.x - 1.0) + 2.0 * (s.y - 1.0) - l.y; // left side, up
31
+ return before + along;
32
+ }
33
+
34
+ vec4 transition(vec2 uv) {
35
+ if (progress <= 0.0) return getFromColor(uv);
36
+ if (progress >= 1.0) return getToColor(uv);
37
+
38
+ vec2 n = max(vec2(grid), vec2(1.0));
39
+ // the cell, counted from the top left corner
40
+ vec2 c = min(floor(vec2(uv.x, 1.0 - uv.y) * n), n - 1.0);
41
+ // the transposed spiral turns the other way from the same corner; walking the spiral
42
+ // outward reverses it too
43
+ if (clockwise != inward) {
44
+ c = c.yx;
45
+ n = n.yx;
46
+ }
47
+ float count = n.x * n.y;
48
+ float i = spiralIndex(c, n);
49
+ if (!inward) i = count - 1.0 - i;
50
+
51
+ // the blocks switch one after another, each one fading in over w blocks of time, the first
52
+ // fade starting at 0 and the last ending at 1; without fade, block i switches at (i + 0.5) / count
53
+ float w = max(smoothness, 0.0) * count;
54
+ float o = max(0.5 * (1.0 - w), 0.0);
55
+ float x = progress * (count - 1.0 + 2.0 * o + w) - i - o;
56
+ float m = w > 0.0 ? smoothstep(0.0, w, x) : step(0.0, x);
57
+
58
+ if (m <= 0.0) return getFromColor(uv);
59
+ if (m >= 1.0) return getToColor(uv);
60
+ vec4 a = getFromColor(uv);
61
+ vec4 b = getToColor(uv);
62
+ // mixed premultiplied, so transparent images do not bleed their color
63
+ vec4 col = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
64
+ return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
65
+ }
@@ -0,0 +1,106 @@
1
+ // Vortex — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Vortex.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image breaks into hundreds of small squares that a tornado carries away along a spiral around the center, from the eye outward, uncovering the incoming image
5
+ // Tags: tiles, spiral, rotation, shatter
6
+
7
+ // @range(4, 40, 1) Number of rows of squares
8
+ uniform int grid; // = 24
9
+ // Center of the tornado
10
+ uniform vec2 center; // = vec2(0.5, 0.5)
11
+ // @range(-4, 4) Turns each square makes around the center as it flies away (negative turns clockwise)
12
+ uniform float spin; // = 1.0
13
+ // @range(0, 1) How randomly the squares leave: 0 from the center outward, 1 in any order
14
+ uniform float randomness; // = 0.2
15
+
16
+ // the squares leave in GROUPS waves, each one flying for DURATION of the transition
17
+ const int GROUPS = 24;
18
+ const float DURATION = 0.25;
19
+ // half width of the antialiased edge of the squares, in frame heights
20
+ const float AA = 0.0015;
21
+ const float TAU = 6.2831853;
22
+
23
+ float hash(vec2 n) {
24
+ return fract(sin(dot(n, vec2(12.9898, 78.233))) * 43758.5453);
25
+ }
26
+
27
+ // the wave a square (by its cell index) leaves with
28
+ int groupOf(vec2 n, float h, vec2 c, float maxR) {
29
+ // only the very corners leave last
30
+ float r = min(length((n + 0.5) * h - c) / (0.85 * maxR), 1.0);
31
+ float key = clamp(mix(r * sqrt(r), hash(n), clamp(randomness, 0.0, 1.0)), 0.0, 0.9999);
32
+ return int(floor(key * float(GROUPS)));
33
+ }
34
+
35
+ // local time of a wave's flight, 0 before it leaves, 1 once it has vanished
36
+ float flight(int g) {
37
+ float delay = float(g) / float(GROUPS) * (1.0 - DURATION);
38
+ return clamp((progress - delay) / DURATION, 0.0, 1.0);
39
+ }
40
+
41
+ vec4 premultiplied(vec4 c) {
42
+ return vec4(c.rgb * c.a, c.a);
43
+ }
44
+
45
+ vec4 transition(vec2 uv) {
46
+ if (progress <= 0.0) return getFromColor(uv);
47
+ if (progress >= 1.0) return getToColor(uv);
48
+
49
+ // measured in square pixels, so the squares stay square
50
+ vec2 aspect = vec2(ratio, 1.0);
51
+ vec2 p = uv * aspect;
52
+ vec2 c = center * aspect;
53
+ float maxR = max(max(length(c), length(c - vec2(ratio, 0.0))), max(length(c - vec2(0.0, 1.0)), length(c - aspect)));
54
+ float h = 1.0 / float(grid < 1 ? 1 : grid);
55
+ // how far a square is pushed away from the center by the end of its flight
56
+ float reach = 0.7 * maxR;
57
+
58
+ // the incoming image, under the squares that have not left yet
59
+ vec2 n0 = floor(p / h);
60
+ vec4 col = flight(groupOf(n0, h, c, maxR)) <= 0.0 ? premultiplied(getFromColor(uv)) : premultiplied(getToColor(uv));
61
+
62
+ // the flying squares, painted from the last wave to leave (lowest) to the first (highest)
63
+ for (int k = 0; k < GROUPS; k++) {
64
+ int g = GROUPS - 1 - k;
65
+ float s = flight(g);
66
+ if (s <= 0.0 || s >= 1.0) continue;
67
+ float e = s * s;
68
+ // like in a tornado, the squares near the eye (the first to leave) spin much faster than
69
+ // the outer ones; all of them orbit before they are flung out
70
+ float angle = spin * TAU * e * 2.0 / (1.0 + 6.0 * float(g) / float(GROUPS));
71
+ float push = reach * e * s;
72
+ // the squares lift toward the viewer, then shrink away
73
+ float size = (1.0 + 0.35 * sin(3.1415927 * s)) * (1.0 - s * s * s);
74
+ float ca = cos(angle);
75
+ float sa = sin(angle);
76
+ mat2 rot = mat2(ca, sa, -sa, ca);
77
+ // undo the wave's spiral to guess which square lands here, then test its neighbors exactly
78
+ vec2 u = (p - c) * rot;
79
+ float ru = length(u);
80
+ vec2 guess = c + (ru > 0.0 ? u / ru : vec2(0.0)) * max(ru - push, 0.0);
81
+ vec2 ng = floor(guess / h);
82
+ for (int j = -1; j <= 1; j++) {
83
+ for (int i = -1; i <= 1; i++) {
84
+ vec2 n = ng + vec2(float(i), float(j));
85
+ if (groupOf(n, h, c, maxR) != g) continue;
86
+ vec2 home = (n + 0.5) * h;
87
+ vec2 rel = home - c;
88
+ float rr = length(rel);
89
+ vec2 dir = rr > 0.0 ? rel / rr : vec2(0.0);
90
+ vec2 pos = c + rot * (dir * (rr + push));
91
+ // each square also tumbles on itself
92
+ float tumble = angle + (hash(n + 17.0) - 0.5) * 3.0 * e * sign(spin);
93
+ float ct = cos(tumble);
94
+ float st = sin(tumble);
95
+ vec2 d = ((p - pos) * mat2(ct, st, -st, ct)) / max(size, 1e-4);
96
+ float edge = 0.5 * h - max(abs(d.x), abs(d.y));
97
+ float cov = clamp(edge * size / (2.0 * AA) + 0.5, 0.0, 1.0);
98
+ vec2 src = home + d;
99
+ if (cov <= 0.0 || src.x < 0.0 || src.y < 0.0 || src.x > ratio || src.y > 1.0) continue;
100
+ vec4 piece = premultiplied(getFromColor(src / aspect)) * cov;
101
+ col = piece + col * (1.0 - piece.a);
102
+ }
103
+ }
104
+ }
105
+ return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
106
+ }