gl-transitions 2.5.0 → 3.1.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 (257) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +16 -1
  3. package/compatibility.json +383 -149
  4. package/gl-transitions.js +1 -1
  5. package/gl-transitions.json +1 -1
  6. package/glsl3/BandWipe.glsl +67 -0
  7. package/glsl3/BookFlip.glsl +124 -21
  8. package/glsl3/BowTie.glsl +1 -1
  9. package/glsl3/Clothesline.glsl +217 -0
  10. package/glsl3/ComicPanels.glsl +174 -0
  11. package/glsl3/Cube.glsl +105 -52
  12. package/glsl3/DirectionalWipe.glsl +1 -1
  13. package/glsl3/DominoFall.glsl +114 -0
  14. package/glsl3/Doorway.glsl +74 -38
  15. package/glsl3/Drape.glsl +186 -0
  16. package/glsl3/DuotoneFade.glsl +58 -0
  17. package/glsl3/FacetedGlass.glsl +137 -0
  18. package/glsl3/FrostWipe.glsl +176 -0
  19. package/glsl3/Funnel.glsl +71 -0
  20. package/glsl3/GlintDissolve.glsl +125 -0
  21. package/glsl3/GlitterDissolve.glsl +171 -0
  22. package/glsl3/GridFlip.glsl +151 -56
  23. package/glsl3/HeartWipe.glsl +71 -11
  24. package/glsl3/InsetWipe.glsl +58 -0
  25. package/glsl3/InsideCube.glsl +114 -0
  26. package/glsl3/KeyholeWipe.glsl +104 -0
  27. package/glsl3/LedWall.glsl +127 -0
  28. package/glsl3/LightningFlash.glsl +200 -0
  29. package/glsl3/MoireWipe.glsl +75 -0
  30. package/glsl3/PaperFold.glsl +168 -0
  31. package/glsl3/PuzzleCube.glsl +205 -0
  32. package/glsl3/RibbonTwist.glsl +53 -0
  33. package/glsl3/Shatter.glsl +231 -35
  34. package/glsl3/SketchDissolve.glsl +100 -0
  35. package/glsl3/SlotReels.glsl +118 -0
  36. package/glsl3/SplitFlap.glsl +124 -0
  37. package/glsl3/Swirl.glsl +52 -21
  38. package/glsl3/TruchetWipe.glsl +80 -0
  39. package/glsl3/Tumble.glsl +113 -0
  40. package/glsl3/WarpSpeed.glsl +120 -0
  41. package/glsl3/WaterDrop.glsl +69 -13
  42. package/glsl3/WaveWipe.glsl +154 -0
  43. package/index.js +1 -1
  44. package/layouts.json +1158 -193
  45. package/llms-full.txt +865 -540
  46. package/llms.txt +219 -204
  47. package/msl/BandWipe.metal +353 -0
  48. package/msl/BookFlip.metal +575 -114
  49. package/msl/BowTie.metal +1 -1
  50. package/msl/Clothesline.metal +828 -0
  51. package/msl/ComicPanels.metal +959 -0
  52. package/msl/Cube.metal +466 -170
  53. package/msl/DirectionalWipe.metal +1 -1
  54. package/msl/DominoFall.metal +510 -0
  55. package/msl/Doorway.metal +350 -124
  56. package/msl/Drape.metal +767 -0
  57. package/msl/DuotoneFade.metal +218 -0
  58. package/msl/FacetedGlass.metal +529 -0
  59. package/msl/FrostWipe.metal +677 -0
  60. package/msl/Funnel.metal +276 -0
  61. package/msl/GlintDissolve.metal +558 -0
  62. package/msl/GlitterDissolve.metal +637 -0
  63. package/msl/GridFlip.metal +548 -191
  64. package/msl/HeartWipe.metal +230 -58
  65. package/msl/InsetWipe.metal +232 -0
  66. package/msl/InsideCube.metal +537 -0
  67. package/msl/KeyholeWipe.metal +370 -0
  68. package/msl/LedWall.metal +437 -0
  69. package/msl/LightningFlash.metal +1038 -0
  70. package/msl/MoireWipe.metal +252 -0
  71. package/msl/PaperFold.metal +762 -0
  72. package/msl/PuzzleCube.metal +1179 -0
  73. package/msl/RibbonTwist.metal +235 -0
  74. package/msl/Shatter.metal +1136 -160
  75. package/msl/SketchDissolve.metal +446 -0
  76. package/msl/SlotReels.metal +436 -0
  77. package/msl/SplitFlap.metal +589 -0
  78. package/msl/Swirl.metal +144 -77
  79. package/msl/TruchetWipe.metal +285 -0
  80. package/msl/Tumble.metal +466 -0
  81. package/msl/WarpSpeed.metal +549 -0
  82. package/msl/WaterDrop.metal +258 -49
  83. package/msl/WaveWipe.metal +618 -0
  84. package/package.json +1 -1
  85. package/skills/gl-transitions/references/catalog.md +119 -74
  86. package/sksl/BandWipe.sksl +77 -0
  87. package/sksl/BookFlip.sksl +117 -20
  88. package/sksl/BowTie.sksl +1 -1
  89. package/sksl/Clothesline.sksl +217 -0
  90. package/sksl/ComicPanels.sksl +176 -0
  91. package/sksl/Cube.sksl +99 -46
  92. package/sksl/DirectionalWipe.sksl +1 -1
  93. package/sksl/DominoFall.sksl +122 -0
  94. package/sksl/Doorway.sksl +65 -35
  95. package/sksl/Drape.sksl +192 -0
  96. package/sksl/DuotoneFade.sksl +71 -0
  97. package/sksl/FacetedGlass.sksl +148 -0
  98. package/sksl/FrostWipe.sksl +183 -0
  99. package/sksl/Funnel.sksl +83 -0
  100. package/sksl/GlintDissolve.sksl +136 -0
  101. package/sksl/GlitterDissolve.sksl +175 -0
  102. package/sksl/GridFlip.sksl +141 -52
  103. package/sksl/HeartWipe.sksl +60 -11
  104. package/sksl/InsetWipe.sksl +70 -0
  105. package/sksl/InsideCube.sksl +123 -0
  106. package/sksl/KeyholeWipe.sksl +109 -0
  107. package/sksl/LedWall.sksl +137 -0
  108. package/sksl/LightningFlash.sksl +202 -0
  109. package/sksl/MoireWipe.sksl +85 -0
  110. package/sksl/PaperFold.sksl +170 -0
  111. package/sksl/PuzzleCube.sksl +203 -0
  112. package/sksl/RibbonTwist.sksl +66 -0
  113. package/sksl/Shatter.sksl +218 -33
  114. package/sksl/SketchDissolve.sksl +111 -0
  115. package/sksl/SlotReels.sksl +127 -0
  116. package/sksl/SplitFlap.sksl +131 -0
  117. package/sksl/Swirl.sksl +49 -20
  118. package/sksl/TruchetWipe.sksl +92 -0
  119. package/sksl/Tumble.sksl +122 -0
  120. package/sksl/WarpSpeed.sksl +131 -0
  121. package/sksl/WaterDrop.sksl +64 -10
  122. package/sksl/WaveWipe.sksl +165 -0
  123. package/sksl/index.js +1 -1
  124. package/transitions/BandWipe.glsl +66 -0
  125. package/transitions/BookFlip.glsl +124 -21
  126. package/transitions/BowTie.glsl +1 -1
  127. package/transitions/Clothesline.glsl +216 -0
  128. package/transitions/ComicPanels.glsl +173 -0
  129. package/transitions/Cube.glsl +105 -52
  130. package/transitions/DirectionalWipe.glsl +1 -1
  131. package/transitions/DominoFall.glsl +113 -0
  132. package/transitions/Doorway.glsl +74 -38
  133. package/transitions/Drape.glsl +185 -0
  134. package/transitions/DuotoneFade.glsl +57 -0
  135. package/transitions/FacetedGlass.glsl +136 -0
  136. package/transitions/FrostWipe.glsl +175 -0
  137. package/transitions/Funnel.glsl +70 -0
  138. package/transitions/GlintDissolve.glsl +124 -0
  139. package/transitions/GlitterDissolve.glsl +170 -0
  140. package/transitions/GridFlip.glsl +151 -56
  141. package/transitions/HeartWipe.glsl +71 -11
  142. package/transitions/InsetWipe.glsl +57 -0
  143. package/transitions/InsideCube.glsl +113 -0
  144. package/transitions/KeyholeWipe.glsl +103 -0
  145. package/transitions/LedWall.glsl +126 -0
  146. package/transitions/LightningFlash.glsl +199 -0
  147. package/transitions/MoireWipe.glsl +74 -0
  148. package/transitions/PaperFold.glsl +167 -0
  149. package/transitions/PuzzleCube.glsl +204 -0
  150. package/transitions/RibbonTwist.glsl +52 -0
  151. package/transitions/Shatter.glsl +231 -35
  152. package/transitions/SketchDissolve.glsl +99 -0
  153. package/transitions/SlotReels.glsl +117 -0
  154. package/transitions/SplitFlap.glsl +123 -0
  155. package/transitions/Swirl.glsl +52 -21
  156. package/transitions/TruchetWipe.glsl +79 -0
  157. package/transitions/Tumble.glsl +112 -0
  158. package/transitions/WarpSpeed.glsl +119 -0
  159. package/transitions/WaterDrop.glsl +69 -13
  160. package/transitions/WaveWipe.glsl +153 -0
  161. package/wgsl/BandWipe.wgsl +319 -0
  162. package/wgsl/BookFlip.wgsl +552 -105
  163. package/wgsl/BowTie.wgsl +1 -1
  164. package/wgsl/Clothesline.wgsl +756 -0
  165. package/wgsl/ComicPanels.wgsl +886 -0
  166. package/wgsl/Cube.wgsl +461 -156
  167. package/wgsl/DirectionalWipe.wgsl +1 -1
  168. package/wgsl/DominoFall.wgsl +461 -0
  169. package/wgsl/Doorway.wgsl +333 -117
  170. package/wgsl/Drape.wgsl +715 -0
  171. package/wgsl/DuotoneFade.wgsl +185 -0
  172. package/wgsl/FacetedGlass.wgsl +476 -0
  173. package/wgsl/FrostWipe.wgsl +617 -0
  174. package/wgsl/Funnel.wgsl +248 -0
  175. package/wgsl/GlintDissolve.wgsl +519 -0
  176. package/wgsl/GlitterDissolve.wgsl +582 -0
  177. package/wgsl/GridFlip.wgsl +523 -188
  178. package/wgsl/HeartWipe.wgsl +225 -55
  179. package/wgsl/InsetWipe.wgsl +200 -0
  180. package/wgsl/InsideCube.wgsl +496 -0
  181. package/wgsl/KeyholeWipe.wgsl +337 -0
  182. package/wgsl/LedWall.wgsl +397 -0
  183. package/wgsl/LightningFlash.wgsl +964 -0
  184. package/wgsl/MoireWipe.wgsl +222 -0
  185. package/wgsl/PaperFold.wgsl +700 -0
  186. package/wgsl/PuzzleCube.wgsl +1087 -0
  187. package/wgsl/RibbonTwist.wgsl +206 -0
  188. package/wgsl/Shatter.wgsl +1091 -148
  189. package/wgsl/SketchDissolve.wgsl +409 -0
  190. package/wgsl/SlotReels.wgsl +391 -0
  191. package/wgsl/SplitFlap.wgsl +533 -0
  192. package/wgsl/Swirl.wgsl +138 -77
  193. package/wgsl/TruchetWipe.wgsl +255 -0
  194. package/wgsl/Tumble.wgsl +424 -0
  195. package/wgsl/WarpSpeed.wgsl +497 -0
  196. package/wgsl/WaterDrop.wgsl +251 -49
  197. package/wgsl/WaveWipe.wgsl +581 -0
  198. package/glsl3/BlockDissolve.glsl +0 -16
  199. package/glsl3/BowTieVertical.glsl +0 -117
  200. package/glsl3/Box.glsl +0 -33
  201. package/glsl3/LinearBlur.glsl +0 -30
  202. package/glsl3/MosaicBlend.glsl +0 -21
  203. package/glsl3/MosaicFade.glsl +0 -20
  204. package/glsl3/RotateFade.glsl +0 -22
  205. package/glsl3/ScaleIn.glsl +0 -18
  206. package/glsl3/WipeDown.glsl +0 -12
  207. package/glsl3/WipeLeft.glsl +0 -12
  208. package/glsl3/WipeRight.glsl +0 -12
  209. package/glsl3/WipeUp.glsl +0 -12
  210. package/msl/BlockDissolve.metal +0 -108
  211. package/msl/BowTieVertical.metal +0 -375
  212. package/msl/Box.metal +0 -204
  213. package/msl/LinearBlur.metal +0 -169
  214. package/msl/MosaicBlend.metal +0 -136
  215. package/msl/MosaicFade.metal +0 -137
  216. package/msl/RotateFade.metal +0 -116
  217. package/msl/ScaleIn.metal +0 -111
  218. package/msl/WipeDown.metal +0 -105
  219. package/msl/WipeLeft.metal +0 -105
  220. package/msl/WipeRight.metal +0 -105
  221. package/msl/WipeUp.metal +0 -105
  222. package/sksl/BlockDissolve.sksl +0 -29
  223. package/sksl/BowTieVertical.sksl +0 -130
  224. package/sksl/Box.sksl +0 -47
  225. package/sksl/LinearBlur.sksl +0 -44
  226. package/sksl/MosaicBlend.sksl +0 -34
  227. package/sksl/MosaicFade.sksl +0 -33
  228. package/sksl/RotateFade.sksl +0 -34
  229. package/sksl/ScaleIn.sksl +0 -32
  230. package/sksl/WipeDown.sksl +0 -26
  231. package/sksl/WipeLeft.sksl +0 -26
  232. package/sksl/WipeRight.sksl +0 -26
  233. package/sksl/WipeUp.sksl +0 -26
  234. package/transitions/BlockDissolve.glsl +0 -15
  235. package/transitions/BowTieVertical.glsl +0 -116
  236. package/transitions/Box.glsl +0 -32
  237. package/transitions/LinearBlur.glsl +0 -29
  238. package/transitions/MosaicBlend.glsl +0 -20
  239. package/transitions/MosaicFade.glsl +0 -19
  240. package/transitions/RotateFade.glsl +0 -21
  241. package/transitions/ScaleIn.glsl +0 -17
  242. package/transitions/WipeDown.glsl +0 -11
  243. package/transitions/WipeLeft.glsl +0 -11
  244. package/transitions/WipeRight.glsl +0 -11
  245. package/transitions/WipeUp.glsl +0 -11
  246. package/wgsl/BlockDissolve.wgsl +0 -78
  247. package/wgsl/BowTieVertical.wgsl +0 -331
  248. package/wgsl/Box.wgsl +0 -176
  249. package/wgsl/LinearBlur.wgsl +0 -131
  250. package/wgsl/MosaicBlend.wgsl +0 -108
  251. package/wgsl/MosaicFade.wgsl +0 -107
  252. package/wgsl/RotateFade.wgsl +0 -85
  253. package/wgsl/ScaleIn.wgsl +0 -79
  254. package/wgsl/WipeDown.wgsl +0 -77
  255. package/wgsl/WipeLeft.wgsl +0 -77
  256. package/wgsl/WipeRight.wgsl +0 -77
  257. package/wgsl/WipeUp.wgsl +0 -77
@@ -0,0 +1,117 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The frame is cut into vertical reels that spin downward like drums, motion-blurred with speed, carrying the outgoing image then the incoming one, and stop one after another from left to right with a small mechanical bounce
4
+ // Tags: 3d, spin, stripes, motion-blur
5
+
6
+ // @range(1, 16, 1) Number of reels
7
+ uniform int reels; // = 5
8
+ // @range(0, 1) Amount of vertical motion blur while the reels spin fast
9
+ uniform float blur; // = 0.6
10
+ // @range(0, 0.9) Delay between the first and the last reel's stop, as a part of the transition
11
+ uniform float stagger; // = 0.45
12
+ // @range(0, 1) Size of the bounce when a reel stops
13
+ uniform float bounce; // = 0.5
14
+ // @color Color of the separators between the reels
15
+ uniform vec4 separator; // = vec4(0.04, 0.04, 0.05, 1.0)
16
+
17
+ const float PI = 3.141592653589793;
18
+ // half of the arc of the drum seen in the frame, in radians
19
+ const float ARC = 1.15;
20
+ // duration of the bounce, as a part of the transition
21
+ const float SETTLE = 0.1;
22
+ // width of the separators, in frame heights
23
+ const float LINE = 0.006;
24
+ // width of the anti-aliased edges, in frame heights
25
+ const float EDGE = 0.0015;
26
+
27
+ // the time at which the reel stops, before its bounce
28
+ float stopTime(float i, float n) {
29
+ float order = n > 1.0 ? i / (n - 1.0) : 1.0;
30
+ return (1.0 - SETTLE) * (1.0 - clamp(stagger, 0.0, 0.9) * (1.0 - order));
31
+ }
32
+
33
+ // how far the reel has turned at time t, in image heights: it speeds up, slows down to its stop
34
+ // a little past the incoming image and springs back onto it
35
+ float reelOffset(float t, float stopT, float turns) {
36
+ float amp = 0.07 * bounce;
37
+ // speed at the stop, matched with the start of the bounce
38
+ float v1 = amp * PI * stopT / (turns * SETTLE);
39
+ float u = clamp(t / stopT, 0.0, 1.0);
40
+ float g = u * u * (3.0 - 2.0 * u) + v1 * (u * u * u - u * u);
41
+ float b = clamp((t - stopT) / SETTLE, 0.0, 1.0);
42
+ return turns * g + amp * sin(PI * b) * (1.0 - b) * (1.0 - b);
43
+ }
44
+
45
+ // the reel's speed at time t, the derivative of reelOffset, in image heights per transition
46
+ float reelSpeed(float t, float stopT, float turns) {
47
+ float amp = 0.07 * bounce;
48
+ float v1 = amp * PI * stopT / (turns * SETTLE);
49
+ if (t < stopT) {
50
+ float u = max(t / stopT, 0.0);
51
+ return turns * (6.0 * u * (1.0 - u) + v1 * u * (3.0 * u - 2.0)) / stopT;
52
+ }
53
+ float b = min((t - stopT) / SETTLE, 1.0);
54
+ return amp * (1.0 - b) * (PI * cos(PI * b) * (1.0 - b) - 2.0 * sin(PI * b)) / SETTLE;
55
+ }
56
+
57
+ vec4 transition (vec2 uv) {
58
+ float n = max(float(reels), 1.0);
59
+ float i = min(floor(uv.x * n), n - 1.0);
60
+ float lx = uv.x * n - i;
61
+ float stopT = stopTime(i, n);
62
+ // an odd number of turns, more for the reels that spin longer, so they land on the incoming image
63
+ float turns = 2.0 * floor(stopT * 4.0) + 1.0;
64
+
65
+ // the reel is a drum while it spins, and flattens back as it settles
66
+ float drum = smoothstep(0.0, 0.12, progress) * (1.0 - smoothstep(stopT, stopT + SETTLE, progress));
67
+ float y = 2.0 * uv.y - 1.0;
68
+ // theta: the angle around the drum's axis, 0 facing the viewer
69
+ float theta = asin(clamp(y * sin(ARC), -1.0, 1.0));
70
+ float v = mix(uv.y, 0.5 + theta / (2.0 * ARC), drum);
71
+ // the far edges of the drum look narrower
72
+ float depth = (1.0 - cos(theta)) * drum;
73
+ float px = 0.5 + (lx - 0.5) * (1.0 + 0.2 * depth);
74
+
75
+ // offset from the resting position, -turns at the start, 0 once landed
76
+ float off = reelOffset(progress, stopT, turns) - turns;
77
+ float speed = abs(reelSpeed(progress, stopT, turns));
78
+ // the blur spans the distance the reel travels in about a frame
79
+ float spread = blur * min(speed * 0.02, 0.22) * drum;
80
+
81
+ // up to 8 taps along the reel, weighted toward the middle, one when it stands still
82
+ vec4 c = vec4(0.0);
83
+ float wsum = 0.0;
84
+ for (int k = 0; k < 8; k++) {
85
+ float f = float(k) / 7.0 - 0.5;
86
+ float w = 1.0 - abs(f);
87
+ float vv = v + off + spread * f;
88
+ float seg = floor(vv);
89
+ vec2 q = vec2((i + clamp(px, 0.0, 1.0)) / n, vv - seg);
90
+ // the drum carries the incoming image on even segments, the outgoing one on odd segments
91
+ vec4 s = mod(seg, 2.0) < 0.5 ? getToColor(q) : getFromColor(q);
92
+ // a thin shadow at the seams between the images, not at the frame's top and bottom edges
93
+ s.rgb *= 1.0 - 0.6 * drum * (1.0 - y * y) * (1.0 - smoothstep(0.0, 0.02, min(q.y, 1.0 - q.y)));
94
+ c += w * s;
95
+ wsum += w;
96
+ if (spread < 1e-4) break;
97
+ }
98
+ c /= wsum;
99
+
100
+ // the drum's faces darken as they turn away, with a soft highlight above its middle
101
+ float facing = cos(theta);
102
+ c.rgb *= mix(1.0, 0.25 + 0.75 * facing * facing, drum);
103
+ c.rgb += drum * 0.07 * c.a * exp(-12.0 * (y - 0.3) * (y - 0.3));
104
+
105
+ // separators between the reels, and the background around the narrower far edges of the drums
106
+ float env = smoothstep(0.0, 0.1, progress) * (1.0 - smoothstep(0.9, 1.0, progress));
107
+ float reelW = ratio / n;
108
+ float persp = reelW / (1.0 + 0.2 * depth);
109
+ // distance to the reel's sides, and to its sides next to the other reels
110
+ float dSide = min(px, 1.0 - px) * persp;
111
+ float dInner = min(i > 0.5 ? px : 2.0, i < n - 1.5 ? 1.0 - px : 2.0) * persp;
112
+ float line = 1.0 - smoothstep(0.5 * LINE - EDGE, 0.5 * LINE + EDGE, dInner);
113
+ float outside = 1.0 - smoothstep(-EDGE, 0.0, dSide);
114
+ // a soft shadow cast by the separators on the reels
115
+ c.rgb *= 1.0 - 0.35 * env * (1.0 - smoothstep(0.0, 0.03 * reelW + LINE, dInner));
116
+ return mix(c, separator, max(line * env, outside));
117
+ }
@@ -0,0 +1,123 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The frame becomes a split-flap board: in each cell the top half of the outgoing image flips down on a hinge across the middle, cell after cell, its back bringing the bottom half of the incoming image
4
+ // Tags: 3d, flip, grid
5
+
6
+ // @param Number of cells (columns, rows)
7
+ uniform ivec2 size; // = ivec2(8, 6)
8
+ // @range(0, 0.9) Delay of the last cell's flip, as a part of the transition
9
+ uniform float stagger; // = 0.6
10
+ // @range(0, 1) How much the order of the cells is shuffled, from a wave across the board to random
11
+ uniform float randomness; // = 0.3
12
+ // @range(1, 4, 1) Number of flaps that fall in each cell, the ones before the last showing other parts of the incoming image
13
+ uniform int flaps; // = 1
14
+ // @range(0, 0.05) Width of the gaps between the cells, as a part of the frame's shorter side (the hinges get half of it)
15
+ uniform float gap; // = 0.004
16
+ // @range(0, 1) Amount of perspective: the falling flaps grow as they come toward the viewer
17
+ uniform float perspective; // = 0.35
18
+ // @range(0, 1) How much the flaps darken as they turn away from the light, and the shadows they cast
19
+ uniform float shading; // = 0.4
20
+ // @color Color seen in the gaps between the cells
21
+ uniform vec4 background; // = vec4(0.0, 0.0, 0.0, 1.0)
22
+
23
+ const float PI = 3.141592653589793;
24
+ // width of the anti-aliased edges, as a part of the frame's shorter side
25
+ const float EDGE = 0.001;
26
+
27
+ float hash12(vec2 v) {
28
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
29
+ v3 += dot(v3, v3.yzx + 33.33);
30
+ return fract((v3.x + v3.y) * v3.z);
31
+ }
32
+
33
+ // the cell's flip, 0 to 1
34
+ float cellTime(vec2 cell, vec2 grid) {
35
+ float wave = (cell.x + 0.5 * (grid.y - 1.0 - cell.y)) / max(grid.x - 1.0 + 0.5 * (grid.y - 1.0), 1.0);
36
+ float order = mix(wave, hash12(cell + 17.0), randomness);
37
+ float delay = clamp(stagger, 0.0, 0.99);
38
+ return clamp((progress - order * delay) / (1.0 - delay), 0.0, 1.0);
39
+ }
40
+
41
+ // the card on the front of the falling flap, at the cell's flip t
42
+ float flapIndex(float t, float n) {
43
+ return min(floor(t * n), n - 1.0);
44
+ }
45
+
46
+ // the falling flap's angle, 0 upright to PI down: it starts gently and lands fast
47
+ float flapAngle(float t, float n) {
48
+ float u = t * n - flapIndex(t, n);
49
+ return PI * u * (0.3 + 0.7 * u);
50
+ }
51
+
52
+ // card i of a cell at the point lc of the card: the outgoing image first, the incoming one last,
53
+ // and in between the incoming image of another cell
54
+ vec4 card(float i, float n, vec2 cell, vec2 grid, vec2 lc) {
55
+ if (i < 0.5) return getFromColor((cell + lc) / grid);
56
+ vec2 src = cell;
57
+ if (i < n - 0.5) src = floor(vec2(hash12(cell * 3.7 + i * 11.3), hash12(cell * 5.3 + i * 7.9 + 1.7)) * grid);
58
+ return getToColor((src + lc) / grid);
59
+ }
60
+
61
+ // 1 inside a half card, 0 in the gaps: x across the card and f the distance from the hinge, in cell sizes
62
+ float cardMask(float x, float f, vec2 cellSize, float g) {
63
+ if (g <= 0.0) return 1.0;
64
+ float e = EDGE * min(1.0, g / max(gap, 1e-4));
65
+ // the gap at the hinge is half as wide as the one between the cells
66
+ float d = min(min(x, 1.0 - x) * cellSize.x, min(2.0 * f, 0.5 - f) * cellSize.y);
67
+ return smoothstep(0.5 * g - e, 0.5 * g + e, d);
68
+ }
69
+
70
+ vec4 transition (vec2 uv) {
71
+ vec2 grid = max(vec2(size), 1.0);
72
+ float n = max(float(flaps), 1.0);
73
+ vec2 cellSize = vec2(ratio, 1.0) / grid / min(ratio, 1.0);
74
+ vec2 cell = floor(uv * grid);
75
+ vec2 l = uv * grid - cell;
76
+ // the gaps open at the start and close at the end
77
+ float g = gap * smoothstep(0.0, 0.12, progress) * (1.0 - smoothstep(0.88, 1.0, progress));
78
+ // w: height above the hinge, in cell heights
79
+ float w = l.y - 0.5;
80
+ bool upper = w >= 0.0;
81
+
82
+ // the board behind the falling flaps: the top half of the next card once the flap has left it,
83
+ // the bottom half of the current card until the flap has landed on it
84
+ float t = cellTime(cell, grid);
85
+ float k = flapIndex(t, n);
86
+ float a = flapAngle(t, n);
87
+ bool started = t * n > k;
88
+ bool landed = t >= 1.0;
89
+ vec4 color = card(k + (upper ? (started ? 1.0 : 0.0) : (landed ? 1.0 : 0.0)), n, cell, grid, l);
90
+ // shadows of the flap leaning over the top half, then falling onto the bottom half
91
+ if (started && !landed) color.rgb *= 1.0 - 0.45 * shading * max(upper ? cos(a) : -cos(a), 0.0);
92
+ color = mix(background, color, cardMask(l.x, abs(w), cellSize, g));
93
+
94
+ // the falling flaps of this cell and of its neighbors, which grow beyond their cells as they come closer
95
+ float nearest = -1.0;
96
+ for (int d = -1; d <= 1; d++) {
97
+ vec2 nc = cell + vec2(float(d), 0.0);
98
+ if (nc.x < 0.0 || nc.x > grid.x - 1.0) continue;
99
+ float nt = d == 0 ? t : cellTime(nc, grid);
100
+ float na = d == 0 ? a : flapAngle(nt, n);
101
+ float fc = cos(na);
102
+ float fs = sin(na);
103
+ // a point at distance f from the hinge is at height f * fc and depth f * fs, nearer points look wider
104
+ if (abs(fc) < 1e-5 || (w >= 0.0) != (fc > 0.0)) continue;
105
+ float f = w / fc;
106
+ if (f > 0.5) continue;
107
+ float z = f * fs;
108
+ if (z <= nearest) continue;
109
+ float lx = 0.5 + (l.x - float(d) - 0.5) * (1.0 - perspective * z);
110
+ if (lx < 0.0 || lx > 1.0) continue;
111
+ bool front = fc > 0.0;
112
+ vec2 lc = vec2(lx, front ? 0.5 + f : 0.5 - f);
113
+ float m = cardMask(lx, f, cellSize, g);
114
+ if (m <= 0.0) continue;
115
+ vec4 img = card(flapIndex(nt, n) + (front ? 0.0 : 1.0), n, nc, grid, lc);
116
+ // lit from above the viewer: the front darkens as it turns down, the back brightens as it lands
117
+ float lambert = (front ? 0.92 * fc - 0.4 * fs : 0.4 * fs - 0.92 * fc) / 0.92;
118
+ img.rgb *= mix(1.0 - shading, 1.0, clamp(lambert, 0.0, 1.0));
119
+ color = mix(color, img, m);
120
+ nearest = z;
121
+ }
122
+ return color;
123
+ }
@@ -1,33 +1,64 @@
1
1
  // License: MIT
2
2
  // Author: Sergey Kosarevsky
3
- // Description: Both images swirl around the center while crossfading
3
+ // Description: The image twists into a round swirl around the center that peaks mid-way, where the outgoing image dissolves into the incoming one, then untwists
4
4
  // Tags: swirl, rotate, blend
5
5
  // ( http://www.linderdaum.com )
6
6
  // ported by gre from https://gist.github.com/corporateshark/cacfedb8cca0f5ce3f7c
7
7
 
8
- vec4 transition(vec2 UV)
9
- {
10
- float Radius = 1.0;
8
+ // @range(-3, 3) Turns of the swirl at its center at the peak (negative turns clockwise)
9
+ uniform float strength; // = 1.0
10
+ // @range(0.1, 2) Radius of the swirl, in frame heights
11
+ uniform float radius; // = 0.9
12
+ // Center of the swirl
13
+ uniform vec2 center; // = vec2(0.5, 0.5)
11
14
 
12
- float T = progress;
15
+ const float PI = 3.141592653589793;
16
+ const float TAU = 6.283185307179586;
17
+ // how much the swirl pulls the image toward its center at the peak
18
+ const float ZOOM = 0.12;
19
+ // spread of the motion blur, as a fraction of the swirl's speed
20
+ const float BLUR = 0.05;
21
+ const int TAPS = 12;
13
22
 
14
- UV -= vec2( 0.5, 0.5 );
15
-
16
- float Dist = length(UV);
23
+ // fold the coordinates back into the frame, so the image stays filled without smearing its border
24
+ vec2 mirrored(vec2 v) {
25
+ vec2 m = mod(v, 2.0);
26
+ return mix(m, 2.0 - m, step(1.0, m));
27
+ }
17
28
 
18
- if ( Dist < Radius )
19
- {
20
- float Percent = (Radius - Dist) / Radius;
21
- float A = ( T <= 0.5 ) ? mix( 0.0, 1.0, T/0.5 ) : mix( 1.0, 0.0, (T-0.5)/0.5 );
22
- float Theta = Percent * Percent * A * 8.0 * 3.14159;
23
- float S = sin( Theta );
24
- float C = cos( Theta );
25
- UV = vec2( dot(UV, vec2(C, -S)), dot(UV, vec2(S, C)) );
26
- }
27
- UV += vec2( 0.5, 0.5 );
29
+ vec4 transition(vec2 uv) {
30
+ // the swirl eases in and out, and is exactly 0 at both ends
31
+ float s = sin(PI * progress);
32
+ float amount = s * s;
33
+ // its speed, used for the motion blur, also 0 at both ends
34
+ float speed = PI * sin(TAU * progress);
35
+ // the switch from the outgoing to the incoming image happens around the peak
36
+ float reveal = smoothstep(0.3, 0.7, progress);
28
37
 
29
- vec4 C0 = getFromColor(UV);
30
- vec4 C1 = getToColor(UV);
38
+ // measured in frame heights, so the swirl is round
39
+ vec2 aspect = vec2(ratio, 1.0);
40
+ vec2 d = (uv - center) * aspect;
41
+ float x = clamp(length(d) / max(radius, 1e-3), 0.0, 1.0);
42
+ // the twist fades out smoothly toward the edge of the swirl
43
+ float falloff = (1.0 - x) * (1.0 - x);
44
+ float twist = strength * TAU * falloff;
45
+ float angle = twist * amount;
46
+ // capped so the blur taps never spread apart into visible streaks
47
+ float spread = clamp(twist * speed * BLUR, -1.2, 1.2);
48
+ // the swirl also slightly pulls the image toward its center
49
+ d *= 1.0 - ZOOM * amount * falloff;
31
50
 
32
- return mix( C0, C1, T );
51
+ vec4 col = vec4(0.0);
52
+ float total = 0.0;
53
+ for (int i = 0; i < TAPS; i++) {
54
+ float k = float(i) / float(TAPS - 1) - 0.5;
55
+ float w = 1.0 - abs(k);
56
+ float a = angle + spread * k;
57
+ float c = cos(a);
58
+ float sn = sin(a);
59
+ vec2 q = mirrored(center + vec2(c * d.x - sn * d.y, sn * d.x + c * d.y) / aspect);
60
+ col += mix(getFromColor(q), getToColor(q), reveal) * w;
61
+ total += w;
62
+ }
63
+ return col / total;
33
64
  }
@@ -0,0 +1,79 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: A grid of square tiles, each holding two quarter-circle arcs, links into long winding paths; starting from the middle and spreading outward, the paths are drawn as thin lines of the incoming image, then thicken into bands with a dark outline and a soft shadow until they merge over the whole frame
4
+ // Tags: truchet, pattern, tiles, paths, graphic, reveal
5
+
6
+ // @range(3, 20, 1) Number of tiles across the frame's height
7
+ uniform float cells; // = 8.0
8
+ // @range(0, 1) Strength of the dark outline and of the shadow along the bands
9
+ uniform float outline; // = 0.6
10
+ // @range(0, 1) How much the paths are staggered from the middle outward: 0 draws them all at once
11
+ uniform float spread; // = 0.75
12
+
13
+ // half width of the antialiased edges, in frame heights
14
+ const float AA = 0.0012;
15
+ // width of the outline, in frame heights
16
+ const float LINE = 0.003;
17
+ // how far the shadow reaches outside a band, in frame heights
18
+ const float SHADOW = 0.025;
19
+ // half width of the thin line a path is first drawn as, in tiles
20
+ const float STROKE = 0.08;
21
+
22
+ float hash12(vec2 v) {
23
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
24
+ v3 += dot(v3, v3.yzx + 33.33);
25
+ return fract((v3.x + v3.y) * v3.z);
26
+ }
27
+
28
+ float vnoise(vec2 v) {
29
+ vec2 i = floor(v);
30
+ vec2 f = fract(v);
31
+ f = f * f * (3.0 - 2.0 * f);
32
+ return mix(
33
+ mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
34
+ mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
35
+ f.y
36
+ );
37
+ }
38
+
39
+ vec4 transition(vec2 uv) {
40
+ if (progress <= 0.0) return getFromColor(uv);
41
+ if (progress >= 1.0) return getToColor(uv);
42
+
43
+ float n = max(floor(cells + 0.5), 1.0);
44
+ // aspect-correct square tiles, centered on the frame
45
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
46
+ vec2 g = p * n + 0.5;
47
+ vec2 cell = floor(g);
48
+ vec2 q = fract(g);
49
+ // each tile is mirrored at random, so its two arcs (centered on opposite corners) link up with its neighbors' in two ways
50
+ if (hash12(cell + 17.0) > 0.5) q.x = 1.0 - q.x;
51
+ // distance to the nearest arc, in tiles: continuous across the tiles' edges, at most 0.5 (at the corners)
52
+ float d = min(abs(length(q) - 0.5), abs(length(q - 1.0) - 0.5));
53
+
54
+ // when the paths reach this point: from the middle outward, made irregular by a noise
55
+ float T = clamp(length(p) / (0.5 * length(vec2(ratio, 1.0))) + 0.4 * (vnoise(p * 3.0 + 4.0) - 0.5), 0.0, 1.0);
56
+ float lag = 0.8 * clamp(spread, 0.0, 1.0);
57
+ // every point is fully covered at progress 0.95
58
+ float s = clamp((progress - lag * T) / (0.95 - lag), 0.0, 1.0);
59
+ // in tiles: the paths are first drawn as thin lines, then the bands widen past the tiles' corners
60
+ float aa = AA * n;
61
+ float k = clamp((s - 0.25) / 0.75, 0.0, 1.0);
62
+ float w = STROKE * smoothstep(0.0, 0.3, s) + (0.5 + LINE * n + 3.0 * aa - STROKE) * k * k;
63
+ // signed distance to the edge of the bands (negative inside), in tiles
64
+ float e = d - w;
65
+
66
+ float band = 1.0 - smoothstep(-2.0 * aa, 0.0, e);
67
+ // outside the bands: a thin outline on their edge and a soft shadow, fading in with the line
68
+ float gap = max(e + aa, 0.0);
69
+ float fall = 1.0 - smoothstep(0.0, SHADOW * n, gap);
70
+ float edge = max(0.8 * (1.0 - smoothstep(LINE * n, LINE * n + 2.0 * aa, gap)), 0.4 * fall * fall);
71
+ float shade = clamp(outline, 0.0, 1.0) * smoothstep(0.0, STROKE, w) * edge;
72
+
73
+ vec4 a = getFromColor(uv);
74
+ a.rgb *= 1.0 - shade;
75
+ vec4 b = getToColor(uv);
76
+ // mixed premultiplied, so transparent images do not bleed their color
77
+ vec4 o = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), band);
78
+ return o.a > 0.0 ? vec4(o.rgb / o.a, o.a) : vec4(0.0);
79
+ }
@@ -0,0 +1,112 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image is thrown away like a rigid card, tumbling end over end with a slight spin as it flies off into the distance in perspective, its darker back showing on every flip and its soft shadow shrinking on the incoming image behind it
4
+ // Tags: 3d, rotate, flip, card, perspective
5
+
6
+ // @range(-4, 4) Number of turns end over end, negative to tumble the other way
7
+ uniform float flips; // = 2.0
8
+ // @range(-1, 1) Turns of the secondary spin around the line of sight
9
+ uniform float spin; // = 0.15
10
+ // @param Where the card flies toward on screen, in frame heights from the center
11
+ uniform vec2 direction; // = vec2(0.0, 0.3)
12
+ // @range(0.1, 1) Strength of the perspective
13
+ uniform float perspective; // = 0.6
14
+ // @range(0, 1) Shading of the card as it turns, darkness of its back and of its shadow
15
+ uniform float shading; // = 0.7
16
+
17
+ const float PI = 3.141592653589793;
18
+ // width of the anti-aliased card edges, in frame heights
19
+ const float EDGE = 0.0015;
20
+ // direction toward the light: above, to the right, in front
21
+ const vec3 LIGHT = vec3(0.348, 0.696, -0.628);
22
+
23
+ // rotates v around the line of sight
24
+ vec3 roll(vec3 v, float c, float s) {
25
+ return vec3(c * v.x - s * v.y, s * v.x + c * v.y, v.z);
26
+ }
27
+
28
+ // signed distance to the card's rectangle, in its plane
29
+ float cardDistance(vec2 q) {
30
+ vec2 e = abs(q) - vec2(0.5 * ratio, 0.5);
31
+ return max(e.x, e.y);
32
+ }
33
+
34
+ // casts the ray d from the eye onto the card's plane, rel being the card's center from the eye:
35
+ // (the point hit in the card's axes, the distance along d), or a negative distance when it misses
36
+ vec3 castOnCard(vec3 d, vec3 rel, vec3 U, vec3 V, vec3 N) {
37
+ float dn = dot(d, N);
38
+ if (abs(dn) < 1e-6) return vec3(0.0, 0.0, -1.0);
39
+ float k = dot(rel, N) / dn;
40
+ vec3 h = k * d - rel;
41
+ return vec3(dot(h, U), dot(h, V), k);
42
+ }
43
+
44
+ vec2 cardUv(vec2 q) {
45
+ return clamp(vec2(q.x / ratio, q.y) + 0.5, 0.0, 1.0);
46
+ }
47
+
48
+ vec4 transition(vec2 uv) {
49
+ // the card is gone a little before the end
50
+ float t = clamp(progress / 0.95, 0.0, 1.0);
51
+ // its size on screen shrinks faster and faster, down to a few percent
52
+ float size = exp(-2.8 * t * t * (0.4 + 0.6 * t));
53
+ float away = 1.0 - size;
54
+ // it spins at its own pace, starting smoothly
55
+ float turn = t * t * (3.0 - 2.0 * t);
56
+ float a = 2.0 * PI * flips * turn;
57
+ float r = 2.0 * PI * spin * turn;
58
+ float cr = cos(r), sr = sin(r);
59
+ // end over end around its horizontal axis, then around the line of sight
60
+ vec3 U = roll(vec3(1.0, 0.0, 0.0), cr, sr);
61
+ vec3 V = roll(vec3(0.0, cos(a), sin(a)), cr, sr);
62
+ vec3 N = roll(vec3(0.0, -sin(a), cos(a)), cr, sr);
63
+
64
+ // the camera, at dist in front of the plane z = 0, sees the frame at rest on it
65
+ float dist = 1.0 / clamp(perspective, 0.1, 1.0);
66
+ // the card's center, seen at direction * away on screen while it goes away, with a slight rise
67
+ vec2 seen = direction * away + vec2(0.0, 0.12 * t * (1.0 - t));
68
+ vec3 rel = vec3(seen / size, dist / size);
69
+ float fade = 1.0 - smoothstep(0.8, 1.0, t);
70
+ float shadowAmount = 0.6 * shading * sqrt(size) * fade;
71
+
72
+ vec2 p = vec2((uv.x - 0.5) * ratio, uv.y - 0.5);
73
+ vec4 color = getToColor(uv);
74
+
75
+ // the soft shadow on the incoming image, cast down and to the left, shrinking with the card
76
+ if (shadowAmount > 0.0) {
77
+ vec3 ds = vec3(p - vec2(-0.05, -0.08) * min(4.0 * t, 1.0) * size, dist);
78
+ vec3 hs = castOnCard(ds, rel, U, V, N);
79
+ if (hs.z > 0.0) {
80
+ float blur = 0.005 + 0.06 * min(3.0 * t, 1.0) * size;
81
+ float sd = cardDistance(hs.xy) * max(abs(dot(ds, N)) / length(ds), 0.05) / hs.z;
82
+ float sh = (1.0 - smoothstep(-blur, blur, sd)) * getFromColor(cardUv(hs.xy)).a;
83
+ color.rgb *= 1.0 - shadowAmount * sh;
84
+ }
85
+ }
86
+
87
+ // cast the ray onto the card
88
+ vec3 d = vec3(p, dist);
89
+ vec3 hit = castOnCard(d, rel, U, V, N);
90
+ if (hit.z <= 0.0) return color;
91
+ float dn = dot(d, N);
92
+ // anti-aliased edges: a screen pixel covers more of the card when it is far or seen at a grazing angle
93
+ float grazing = max(abs(dn) / length(d), 0.05);
94
+ float e = EDGE * min(20.0 * t, 1.0) * hit.z / grazing;
95
+ float m = clamp(0.5 - cardDistance(hit.xy) / max(e, 1e-6), 0.0, 1.0) * fade;
96
+ if (m <= 0.0) return color;
97
+
98
+ vec4 card = getFromColor(cardUv(hit.xy));
99
+ // the side facing the camera: the front, or the back which shows the image through, darker and duller
100
+ bool front = dn > 0.0;
101
+ vec3 facing = front ? -N : N;
102
+ float lit = min((0.35 + 0.65 * max(dot(facing, LIGHT), 0.0)) / (0.35 + 0.65 * -LIGHT.z), 1.0);
103
+ float shade = mix(1.0, lit * (front ? 1.0 : 0.55), shading);
104
+ if (!front) card.rgb = mix(card.rgb, vec3(dot(card.rgb, vec3(0.299, 0.587, 0.114))), 0.4 * shading);
105
+ // a glint as the card turns through the light, a light added to the image
106
+ float glint = pow(max(dot(facing, normalize(LIGHT - normalize(d))), 0.0), 60.0);
107
+ card.rgb = card.rgb * shade + 0.35 * shading * glint * smoothstep(0.0, 0.2, t);
108
+ if (m >= 1.0) return card;
109
+ // blend premultiplied, so that a transparent layer gives no color to the other one
110
+ vec4 mixed = mix(vec4(color.rgb * color.a, color.a), vec4(card.rgb * card.a, card.a), m);
111
+ return mixed.a > 0.0 ? vec4(mixed.rgb / mixed.a, mixed.a) : vec4(0.0);
112
+ }
@@ -0,0 +1,119 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The camera jumps to light speed: star streaks shoot out from the center and stretch longer and longer while the outgoing image is pulled into a radial smear, then after a flash the incoming image emerges from the center as the streaks shrink back
4
+ // Tags: zoom, radial, light, motion-blur, space
5
+
6
+ // @param Point the camera flies toward, from (0, 0) at the bottom left to (1, 1) at the top right
7
+ uniform vec2 center; // = vec2(0.5, 0.5)
8
+ // @range(20, 400) Number of star streaks around the center
9
+ uniform float streaks; // = 160.0
10
+ // @color Color of the streaks and of the flash, added as light
11
+ uniform vec4 streakColor; // = vec4(0.78, 0.88, 1.0, 1.0)
12
+ // @range(0, 1) Length of the streaks and of the radial smear
13
+ uniform float strength; // = 0.6
14
+ // @range(0, 1) Brightness of the flash at the peak of the jump
15
+ uniform float flash; // = 0.5
16
+
17
+ const float PI = 3.141592653589793;
18
+ const int TAPS = 12;
19
+
20
+ float hash(vec2 p) {
21
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
22
+ p3 += dot(p3, p3.yzx + 33.33);
23
+ return fract((p3.x + p3.y) * p3.z);
24
+ }
25
+
26
+ // one layer of stars: one per angular cell, flying outward and stretched along its ray
27
+ float stars(float a, float r, float n, float layer, float travel, float speed, float reach) {
28
+ float cell = floor(a * n);
29
+ float h1 = hash(vec2(cell, layer));
30
+ float h2 = hash(vec2(cell, layer + 17.0));
31
+ float h3 = hash(vec2(cell, layer + 31.0));
32
+ // where the star is in its flight, from near the center to past the corners,
33
+ // speeding up as it comes closer
34
+ float life = fract(h1 + travel * (0.6 + 0.8 * h2));
35
+ float head = reach * (0.05 + 1.05 * pow(life, 1.4));
36
+ // the streak is the path of the star during the exposure: longer when the camera is faster
37
+ float tail = head * (1.0 - min(0.9, speed * (0.15 + 0.5 * h3)));
38
+ float along = clamp((r - tail) / max(head - tail, 1e-4), 0.0, 1.0);
39
+ float inside = step(tail, r) * (1.0 - smoothstep(head - 0.006, head, r));
40
+ // brightest at the head, fading toward the tail
41
+ float profile = inside * along * along;
42
+ // thin across the ray, a bit wider away from the center, with a faint halo,
43
+ // faded out before the edges of the cell so that no seam shows between cells
44
+ float f = fract(a * n);
45
+ float cellWidth = 2.0 * PI * r / n;
46
+ float offset = 0.3 + 0.4 * h3;
47
+ float across = (f - offset) * cellWidth;
48
+ float width = min(0.0014 + 0.002 * r / reach, 0.15 * cellWidth);
49
+ float x = across * across / (width * width);
50
+ float line = (exp(-x) + 0.25 * exp(-x / 9.0)) * smoothstep(0.0, 0.2, min(f, 1.0 - f));
51
+ // fade in from far away, out past the frame, and only some cells hold a star
52
+ float fade = smoothstep(0.0, 0.2, life) * (1.0 - smoothstep(0.9, 1.0, life));
53
+ return profile * line * fade * (0.4 + 0.6 * h2) * step(0.25, hash(vec2(cell, layer + 43.0)));
54
+ }
55
+
56
+ // an image pulled into a radial smear toward the center: scaled by k, blurred over a fraction b
57
+ vec4 smear(vec2 uv, float k, float b, float jitter, bool incoming) {
58
+ if (b <= 0.0 && k >= 1.0) {
59
+ vec4 c = incoming ? getToColor(uv) : getFromColor(uv);
60
+ return vec4(c.rgb * c.a, c.a);
61
+ }
62
+ vec4 sum = vec4(0.0);
63
+ for (int i = 0; i < TAPS; i++) {
64
+ float s = k * (1.0 - b * (float(i) + jitter) / float(TAPS));
65
+ vec2 q = center + (uv - center) * s;
66
+ vec4 c = incoming ? getToColor(q) : getFromColor(q);
67
+ sum += vec4(c.rgb * c.a, c.a);
68
+ }
69
+ return sum / float(TAPS);
70
+ }
71
+
72
+ vec4 transition(vec2 uv) {
73
+ float p = progress;
74
+ vec2 aspect = vec2(ratio, 1.0);
75
+ vec2 d = (uv - center) * aspect;
76
+ float r = length(d);
77
+ // (nudged off zero, where atan is undefined)
78
+ float a = atan(d.y, d.x + 1e-6) / (2.0 * PI) + 0.5;
79
+ // distance from the center to the farthest corner
80
+ vec2 far = max(center, 1.0 - center) * aspect;
81
+ float reach = length(far);
82
+
83
+ // the camera speeds up to the jump, at the middle, then slows down
84
+ float speed = sin(PI * p);
85
+ speed *= speed;
86
+ float travel = 3.0 * (p - sin(2.0 * PI * p) / (2.0 * PI));
87
+ float jitter = hash(floor(uv * aspect * 997.0));
88
+
89
+ // the outgoing image is pulled forward into the smear; the incoming one arrives
90
+ // magnified and smeared, and settles
91
+ float goOut = smoothstep(0.0, 0.55, p);
92
+ float goIn = 1.0 - smoothstep(0.45, 1.0, p);
93
+ // the incoming image emerges from the center and spreads out to the corners
94
+ float soft = 0.35 * reach;
95
+ float edge = mix(-soft, reach + soft, smoothstep(0.42, 0.78, p));
96
+ float m = 1.0 - smoothstep(edge - soft, edge, r);
97
+ vec4 before = vec4(0.0);
98
+ vec4 after = vec4(0.0);
99
+ if (m < 1.0) before = smear(uv, 1.0 - 0.3 * strength * goOut * goOut, 0.6 * strength * goOut, jitter, false);
100
+ if (m > 0.0) after = smear(uv, 1.0 - 0.3 * strength * goIn * goIn, 0.6 * strength * goIn, jitter, true);
101
+ vec4 c = mix(before, after, m);
102
+ // darker while in the jump, so that the streaks stand out, and brighter soon after it
103
+ // so the incoming image comes out clear
104
+ float dark = p < 0.5 ? speed : speed * speed * speed;
105
+ c.rgb *= 1.0 - 0.65 * (0.5 + 0.5 * strength) * dark;
106
+
107
+ // the streaks: two layers of stars, their length growing with the speed
108
+ float n = max(floor(streaks), 1.0);
109
+ float len = speed * (0.5 + 1.5 * strength);
110
+ float s = stars(a, r, n, 1.0, travel, len, reach);
111
+ s += stars(fract(a + 0.37), r, max(floor(n * 0.71), 1.0), 2.0, travel * 1.3, len, reach);
112
+ // the flash, brightest at the center, where the incoming image emerges
113
+ float core = r / (0.35 * reach);
114
+ float peak = (p - 0.5) * 9.0;
115
+ float glow = flash * exp(-peak * peak) * speed * (0.35 + 0.9 * exp(-core * core));
116
+ vec3 light = streakColor.rgb * streakColor.a * (2.2 * s * speed + glow);
117
+ // light is added to the image, but adds no opacity
118
+ return c.a > 0.0 ? vec4(clamp(c.rgb / c.a + light, 0.0, 1.0), c.a) : vec4(0.0);
119
+ }