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,67 @@
1
+ // BandWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BandWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Alternating bands wipe in from opposite sides together and interleave like fingers, while both images stay still
5
+ // Tags: wipe, stripes, interleave, horizontal
6
+
7
+ // @range(2, 40, 1) Number of bands
8
+ uniform int bands; // = 8
9
+ // @param Cut the frame into columns that wipe up and down instead of rows that wipe sideways
10
+ uniform bool vertical; // = false
11
+ // @range(0, 0.2) Softness of the bands' leading edges
12
+ uniform float smoothness; // = 0.02
13
+ // @range(0, 0.8) Delay between the first and the last band, so they cascade from the top (or the left)
14
+ uniform float stagger; // = 0.1
15
+
16
+ // half width of the antialiased edges, in frame heights
17
+ const float AA = 0.0015;
18
+
19
+ // how far band i has wiped in (0..1) at position a along the bands (0..l), alternate bands
20
+ // entering from opposite ends
21
+ float bandMask(float i, float n, float a, float l, float s) {
22
+ // each band takes the same time, starting a little after the one before it from the top
23
+ // (or the left)
24
+ float k = vertical ? i : n - 1.0 - i;
25
+ float g = clamp(stagger, 0.0, 0.95);
26
+ float t = clamp((progress - g * k / max(n - 1.0, 1.0)) / (1.0 - g), 0.0, 1.0);
27
+ t = mix(t, t * t * (3.0 - 2.0 * t), 0.5);
28
+ float x = mod(i, 2.0) > 0.5 ? l - a : a;
29
+ // the edge starts fully before the band and ends fully past it
30
+ float c = mix(-s, l + s, t);
31
+ return 1.0 - smoothstep(c - s, c + s, x);
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
+ float n = float(bands < 1 ? 1 : bands);
39
+ // along: position along the bands, in frame heights; across: position across them (0..1)
40
+ float along = vertical ? uv.y : uv.x * ratio;
41
+ float across = vertical ? uv.x : uv.y;
42
+ float l = vertical ? 1.0 : ratio;
43
+ // the antialiasing across the bands, in units of across
44
+ float aaAcross = vertical ? AA / ratio : AA;
45
+ float s = max(smoothness, AA);
46
+
47
+ float f = across * n;
48
+ float i = clamp(floor(f), 0.0, n - 1.0);
49
+ float m = bandMask(i, n, along, l, s);
50
+
51
+ // near a cut between two bands, blend with the neighbor band over a pixel or so so the cut
52
+ // does not alias (at the frame's borders the neighbor is the band itself)
53
+ float fr = f - i;
54
+ float edge = min(fr, 1.0 - fr) / n;
55
+ if (edge < aaAcross) {
56
+ float j = clamp(fr < 0.5 ? i - 1.0 : i + 1.0, 0.0, n - 1.0);
57
+ m = mix(bandMask(j, n, along, l, s), m, 0.5 + 0.5 * smoothstep(0.0, aaAcross, edge));
58
+ }
59
+
60
+ if (m <= 0.0) return getFromColor(uv);
61
+ if (m >= 1.0) return getToColor(uv);
62
+ vec4 a = getFromColor(uv);
63
+ vec4 b = getToColor(uv);
64
+ // mixed premultiplied, so transparent images do not bleed their color
65
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
66
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
67
+ }
@@ -1,37 +1,140 @@
1
1
  // BookFlip — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BookFlip.glsl
2
2
  // Author: hong
3
3
  // License: MIT
4
- // Description: The outgoing image turns like a book page from right to left, revealing the incoming one
4
+ // Description: The right half of the outgoing image is a book page that turns over from right to left on the spine at the middle of the frame, curling near its free edge, its back bringing the left half of the incoming image
5
5
  // Tags: page, flip, 3d
6
6
 
7
- // Avoids dividing by zero when the page is edge-on (progress = 0.5).
8
- float nonZero(float x) {
9
- return abs(x) < 1e-4 ? (x < 0.0 ? -1e-4 : 1e-4) : x;
7
+ // @range(0, 1) Strength of the perspective: the page grows as it lifts toward the viewer
8
+ uniform float perspective; // = 0.5
9
+ // @range(0, 1) How much the page darkens as it turns away from the light, and the shadows it casts
10
+ uniform float shading; // = 0.6
11
+ // @range(0, 1) How much the page bends near its free edge, which trails behind as it turns
12
+ uniform float curl; // = 0.5
13
+
14
+ const float PI = 3.141592653589793;
15
+ // width of the anti-aliased edges, as a part of the frame's height
16
+ const float EDGE = 0.0015;
17
+ // part of the page's width that curls
18
+ const float CURL_PART = 0.45;
19
+ // direction of the light, in (x, height toward the viewer)
20
+ const vec2 LIGHT = vec2(-0.447214, 0.894427);
21
+
22
+ float cross2(vec2 a, vec2 b) {
23
+ return a.x * b.y - a.y * b.x;
10
24
  }
11
25
 
12
- vec2 skewRight(vec2 p) {
13
- float skewX = (p.x - progress)/nonZero(0.5 - progress) * 0.5;
14
- float skewY = (p.y - 0.5)/(0.5 + progress * (p.x - 0.5) / 0.5)* 0.5 + 0.5;
15
- return vec2(skewX, skewY);
26
+ // the page's angle, 0 lying on the right to PI lying on the left: eased, but never at rest
27
+ float pageAngle() {
28
+ float p = clamp(progress, 0.0, 1.0);
29
+ return PI * p * (0.35 + p * (1.95 - 1.3 * p));
16
30
  }
17
31
 
18
- vec2 skewLeft(vec2 p) {
19
- float skewX = (p.x - 0.5)/nonZero(progress - 0.5) * 0.5 + 0.5;
20
- float skewY = (p.y - 0.5) / (0.5 + (1.0 - progress ) * (0.5 - p.x) / 0.5) * 0.5 + 0.5;
21
- return vec2(skewX, skewY);
32
+ // The page is seen in a cross-section across the spine, in (x, height toward the viewer) from the spine:
33
+ // a straight part at angle a from the spine, then, when k is not 0, an arc of curvature k centered on c up to its free edge,
34
+ // extruded along y. Returns the nearest point of the page hit by the ray from eye along dir:
35
+ // (ray length, distance along the page, angle there), with a negative ray length when it is missed.
36
+ vec3 hitPage(vec2 eye, vec2 dir, float a, float k, float straight, vec2 c, float w) {
37
+ vec3 best = vec3(-1.0, 0.0, 0.0);
38
+ vec2 d = vec2(cos(a), sin(a));
39
+ // the straight part
40
+ float den = cross2(d, dir);
41
+ if (abs(den) > 1e-7) {
42
+ float u = cross2(eye, dir) / den;
43
+ float t = cross2(eye, d) / den;
44
+ if (t > 0.0 && u >= 0.0 && u <= straight) best = vec3(t, u, a);
45
+ }
46
+ if (k != 0.0) {
47
+ float r = 1.0 / k;
48
+ vec2 oc = eye - c;
49
+ float qa = dot(dir, dir);
50
+ float qb = dot(oc, dir);
51
+ float disc = qb * qb - qa * (dot(oc, oc) - r * r);
52
+ if (disc >= 0.0) {
53
+ float sq = sqrt(disc);
54
+ for (int i = 0; i < 2; i++) {
55
+ float t = (-qb + (i == 0 ? -sq : sq)) / qa;
56
+ if (t > 0.0 && (best.x < 0.0 || t < best.x)) {
57
+ // (sin(b), -cos(b)) where b is the angle of the page at that point
58
+ vec2 v = (oc + t * dir) * k;
59
+ float db = atan(v.x, -v.y) - a;
60
+ db -= 2.0 * PI * floor((db + PI) / (2.0 * PI));
61
+ float s = db / k;
62
+ if (s >= 0.0 && s <= w - straight) best = vec3(t, straight + s, a + db);
63
+ }
64
+ }
65
+ }
66
+ }
67
+ return best;
22
68
  }
23
69
 
24
- vec4 addShade() {
25
- float shadeVal = max(0.7, abs(progress - 0.5) * 2.0);
26
- return vec4(vec3(shadeVal ), 1.0);
70
+ // the point of the curled part of the page where its angle is b
71
+ vec2 curlPoint(vec2 c, float k, float b) {
72
+ return c + vec2(sin(b), -cos(b)) / k;
27
73
  }
28
74
 
29
- vec4 transition (vec2 p) {
30
- float pr = step(1.0 - progress, p.x);
75
+ vec4 transition (vec2 uv) {
76
+ float a = pageAngle();
77
+ float lift = sin(a);
78
+ // half the frame's width: the page's width
79
+ float w = 0.5 * ratio;
80
+ float x = uv.x * ratio - w;
81
+ // the viewer is above the spine, the page lifting toward it
82
+ float dist = w * (1.0 + 1.5 / max(perspective, 0.01));
83
+ vec2 eye = vec2(0.0, dist);
84
+ vec2 dir = vec2(x, -dist);
85
+
86
+ // the shape of the page: straight, then curled with its free edge trailing behind (a negative curvature)
87
+ vec2 d = vec2(cos(a), sin(a));
88
+ float k = -clamp(curl, 0.0, 1.0) * lift / (CURL_PART * w);
89
+ if (abs(k) * CURL_PART * w <= 1e-4) k = 0.0;
90
+ float straight = k != 0.0 ? (1.0 - CURL_PART) * w : w;
91
+ vec2 c = straight * d + vec2(-d.y, d.x) / (k != 0.0 ? k : 1.0);
92
+ vec2 bend = straight * d;
93
+ vec2 middle = k != 0.0 ? curlPoint(c, k, a + 0.5 * k * (w - straight)) : bend;
94
+ vec2 edge = k != 0.0 ? curlPoint(c, k, a + k * (w - straight)) : bend;
31
95
 
32
- if (p.x < 0.5) {
33
- return mix(getFromColor(p), getToColor(skewLeft(p)) * addShade(), pr);
34
- } else {
35
- return mix(getFromColor(skewRight(p)) * addShade(), getToColor(p), pr);
96
+ // anti-aliased edges, only once the page has left the frame's plane, so that it covers it exactly at both ends
97
+ float aa = EDGE * min(20.0 * lift, 1.0);
98
+ vec4 img = vec4(0.0);
99
+ float m = 0.0;
100
+ vec3 hit = hitPage(eye, dir, a, k, straight, c, w);
101
+ if (hit.x > 0.0) {
102
+ float t = hit.x;
103
+ float u = hit.y;
104
+ float b = hit.z;
105
+ vec2 pt = eye + t * dir;
106
+ // the height on the page, magnified as it comes closer (its top and bottom edges are out of the frame)
107
+ float y = clamp(0.5 + (uv.y - 0.5) * t, 0.0, 1.0);
108
+ // near its free edge, the distance to it on the screen
109
+ float edgeX = edge.x * dist / max(dist - edge.y, 1e-4);
110
+ m = aa > 0.0 && u > (k != 0.0 ? straight : 0.5 * w) ? clamp(abs(x - edgeX) / aa, 0.0, 1.0) : 1.0;
111
+ vec2 normal = vec2(-sin(b), cos(b));
112
+ bool front = dot(normal, eye - pt) > 0.0;
113
+ img = front
114
+ ? getFromColor(vec2(clamp(w + u, w, ratio) / ratio, y))
115
+ : getToColor(vec2(clamp(w - u, 0.0, w) / ratio, y));
116
+ // lit from the upper left: brighter as it turns toward the light, darker as it turns away, with a soft crease along the spine
117
+ float diffuse = max(dot(front ? normal : -normal, LIGHT), 0.0) / LIGHT.y;
118
+ float shade = mix(1.0, 0.25 + 0.75 * diffuse, shading);
119
+ shade *= 1.0 - 0.35 * shading * lift * exp(-u / (0.04 * w));
120
+ img.rgb *= shade;
121
+ if (m >= 1.0) return img;
36
122
  }
123
+
124
+ // the pages beneath: the outgoing image on the left, the incoming one on the right
125
+ vec4 color = x < 0.0 ? getFromColor(uv) : getToColor(uv);
126
+ // the lifted page shades them, the more it hides of the sky (and so the more near the spine and its free edge)
127
+ vec2 toEdge = edge - vec2(x, 0.0);
128
+ float cosEdge = toEdge.x / max(length(toEdge), 1e-6);
129
+ float blocked = 0.5 * abs((x < 0.0 ? 1.0 : -1.0) - cosEdge);
130
+ float shadow = blocked * blocked * (3.0 - 2.0 * blocked);
131
+ // and casts a shadow, the light coming from the upper left, softer as the page is higher
132
+ float slope = -LIGHT.x / LIGHT.y;
133
+ vec3 reach = vec3(bend.x, middle.x, edge.x) + slope * vec3(bend.y, middle.y, edge.y);
134
+ float lo = min(0.0, min(reach.x, min(reach.y, reach.z)));
135
+ float hi = max(0.0, max(reach.x, max(reach.y, reach.z)));
136
+ float soft = max(0.25 * edge.y, 1e-5);
137
+ shadow = max(0.5 * shadow, 0.85 * clamp(min(x - lo, hi - x) / soft + 0.5, 0.0, 1.0) * min(4.0 * lift, 1.0));
138
+ color.rgb *= 1.0 - shading * shadow;
139
+ return mix(color, img, m);
37
140
  }
package/glsl3/BowTie.glsl CHANGED
@@ -1,7 +1,7 @@
1
1
  // BowTie — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BowTie.glsl
2
2
  // Author: KMojek
3
3
  // License: MIT
4
- // Description: A bow-tie wipe with an adjustable shape that can run in reverse
4
+ // Description: Two triangles grow from the top and bottom edges into a bow tie that reveals the incoming image, with an adjustable shape, and can run in reverse
5
5
  // Tags: wipe, shape
6
6
 
7
7
  uniform float adjust; // = 0.5
@@ -0,0 +1,217 @@
1
+ // Clothesline — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Clothesline.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The camera pulls back to show the outgoing image as a print hung by two clothespins on a line in front of a wall, the line is pulled sideways and carries it away while the incoming print slides in, both prints swinging and tilting like hanging paper, then the camera moves back in on the incoming print until it fills the frame
5
+ // Tags: 3d, perspective, slide, swing, paper, directional
6
+
7
+ // @param Way the line is pulled: 1 brings the incoming print in from the right, -1 from the left
8
+ uniform float direction; // = 1.0
9
+ // @range(0, 1) How much the prints swing and tilt as the line moves
10
+ uniform float sway; // = 0.5
11
+ // @range(0.4, 0.95) Size of the prints when the camera is farthest, as a part of the frame
12
+ uniform float size; // = 0.72
13
+ // @color Color of the wall behind the line
14
+ uniform vec4 background; // = vec4(0.86, 0.84, 0.8, 1.0)
15
+ // @color Color of the line
16
+ uniform vec4 lineColor; // = vec4(0.42, 0.34, 0.26, 1.0)
17
+ // @color Color of the clothespins
18
+ uniform vec4 pinColor; // = vec4(0.84, 0.68, 0.47, 1.0)
19
+
20
+ const float FOCAL = 2.0; // distance from the camera to a print when it fills the frame
21
+ const float GAP = 0.35; // space between two prints on the line, in frame heights
22
+ const float WALL = 0.14; // distance from the line to the wall behind it
23
+ const float ROPE = 0.0055; // half thickness of the line
24
+ const vec2 PIN = vec2(0.021, 0.072); // half size of a clothespin
25
+ const float PIN_Y = -0.01; // center of a clothespin below the top edge of its print
26
+ const float AA = 0.0015; // width of the antialiased edges, in frame heights
27
+ const vec3 LIGHT = vec3(-0.28, 0.48, 0.83); // toward the light: above, a bit on the left, in front
28
+ const float PIN_X = 0.32; // clothespins from the center of their print, in print widths
29
+ const int STEPS = 32; // steps of the swing simulation over the whole transition
30
+
31
+ // the line moves between these progress values
32
+ const float SLIDE_START = 0.1;
33
+ const float SLIDE_END = 0.86;
34
+
35
+ vec4 premultiply(vec4 c) {
36
+ return vec4(c.rgb * c.a, c.a);
37
+ }
38
+
39
+ // time of the line's move at p, from 0 to 1
40
+ float slideTime(float p) {
41
+ return clamp((p - SLIDE_START) / (SLIDE_END - SLIDE_START), 0.0, 1.0);
42
+ }
43
+
44
+ // part of its travel done (smootherstep of the time)
45
+ float slideAmount(float u) {
46
+ return u * u * u * (u * (u * 6.0 - 15.0) + 10.0);
47
+ }
48
+
49
+ // acceleration of the travel at p, per progress squared
50
+ float slideAccel(float p) {
51
+ float u = slideTime(p);
52
+ float dur = SLIDE_END - SLIDE_START;
53
+ return 60.0 * u * (1.0 - u) * (1.0 - 2.0 * u) / (dur * dur);
54
+ }
55
+
56
+ // the sideways swing of the prints' bottoms, along the travel: a damped pendulum driven by the
57
+ // line's acceleration, lagging behind it at the start and overshooting at the stop
58
+ float swing(float p) {
59
+ const float OMEGA = 10.0; // about 1.6 swings over the transition
60
+ const float DAMP = 0.28;
61
+ const float STEP = 1.0 / float(STEPS);
62
+ float x = 0.0;
63
+ float v = 0.0;
64
+ // fixed steps, the last one cut at p, so that every frame follows the same curve
65
+ for (int i = 0; i < STEPS; i++) {
66
+ float t0 = float(i) * STEP;
67
+ float dt = clamp(p - t0, 0.0, STEP);
68
+ float a = slideAccel(t0 + 0.5 * dt) - OMEGA * OMEGA * x - 2.0 * DAMP * OMEGA * v;
69
+ v += a * dt;
70
+ x += v * dt;
71
+ }
72
+ // it settles as the camera moves back in
73
+ return x * (1.0 - smoothstep(0.7, 1.0, p));
74
+ }
75
+
76
+ // signed distance to a rounded box of half size b and corner radius r
77
+ float roundedBox(vec2 q, vec2 b, float r) {
78
+ vec2 d = abs(q) - b + r;
79
+ return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r;
80
+ }
81
+
82
+ // the point (u across, v down from the top edge) where the ray o + t d meets the plane of a print
83
+ // hanging from (cx, 0.5, 0) and swung back by psi around its top edge, and t
84
+ vec3 printHit(vec3 o, vec3 d, float cx, float psi) {
85
+ vec3 dn = vec3(0.0, -cos(psi), -sin(psi));
86
+ vec3 n = vec3(0.0, sin(psi), -cos(psi));
87
+ vec3 p0 = vec3(cx, 0.5, 0.0);
88
+ float t = dot(p0 - o, n) / dot(d, n);
89
+ vec3 q = o + d * t - p0;
90
+ return vec3(q.x, dot(q, dn), t);
91
+ }
92
+
93
+ // the bottom of the print bends sideways by bend frame heights
94
+ float bendShift(float v, float bend) {
95
+ float h = clamp(v, 0.0, 1.0);
96
+ return bend * h * (0.6 + 0.4 * h);
97
+ }
98
+
99
+ // signed distance to the paper (negative inside), in frame heights
100
+ float paperDist(vec2 uv, float bend) {
101
+ vec2 q = abs(vec2(uv.x - bendShift(uv.y, bend), uv.y - 0.5)) - vec2(0.5 * ratio, 0.5);
102
+ return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
103
+ }
104
+
105
+ // signed distance to the two clothespins of a print
106
+ float pinDist(vec2 uv) {
107
+ vec2 q = vec2(abs(uv.x) - PIN_X * ratio, uv.y - PIN_Y);
108
+ return roundedBox(q, PIN, 0.012);
109
+ }
110
+
111
+ // the print hanging at cx over col (premultiplied), then its clothespins
112
+ vec4 drawPrint(vec4 col, vec3 h, bool isFrom, float bend, float psi, float aa, float vis) {
113
+ vec2 lp = h.xy;
114
+ float d = paperDist(lp, bend);
115
+ float cov = clamp(0.5 - d / (h.z * aa), 0.0, 1.0);
116
+ if (cov > 0.0) {
117
+ vec2 st = clamp(vec2((lp.x - bendShift(lp.y, bend)) / ratio + 0.5, 1.0 - lp.y), 0.0, 1.0);
118
+ vec4 c = premultiply(isFrom ? getFromColor(st) : getToColor(st));
119
+ // the paper darkens as it swings back and bends, and under the clothespins
120
+ float shade = 1.0 - 1.2 * abs(sin(psi)) * lp.y - 0.35 * abs(bend) * lp.y;
121
+ float ps = pinDist(lp - vec2(0.006, 0.01));
122
+ shade -= 0.35 * vis * (1.0 - smoothstep(-0.004, 0.012, ps));
123
+ c.rgb *= clamp(shade, 0.0, 1.0);
124
+ col = c * cov + col * (1.0 - c.a * cov);
125
+ }
126
+ return col;
127
+ }
128
+
129
+ vec4 drawPins(vec4 col, vec3 h, float aa, float vis) {
130
+ vec2 lp = h.xy;
131
+ float d = pinDist(lp);
132
+ float cov = vis * clamp(0.5 - d / (h.z * aa), 0.0, 1.0);
133
+ if (cov > 0.0) {
134
+ // rounded wood, with the steel spring across it
135
+ float k = clamp((abs(lp.x) - PIN_X * ratio) / PIN.x, -1.0, 1.0);
136
+ vec3 c = pinColor.rgb * (0.62 + 0.45 * sqrt(1.0 - k * k));
137
+ float y = lp.y - PIN_Y;
138
+ float spring = 1.0 - smoothstep(0.004, 0.007, abs(y + 0.02));
139
+ c = mix(c, vec3(0.3, 0.31, 0.33) * (0.6 + 0.8 * sqrt(1.0 - k * k)), spring);
140
+ // the groove that grips the paper
141
+ c *= 1.0 - 0.3 * (1.0 - smoothstep(0.002, 0.005, abs(y - 0.012)));
142
+ vec4 pc = premultiply(vec4(c, pinColor.a));
143
+ col = pc * cov + col * (1.0 - pc.a * cov);
144
+ }
145
+ return col;
146
+ }
147
+
148
+ vec4 transition(vec2 uv) {
149
+ float p = progress;
150
+ float s = direction < 0.0 ? -1.0 : 1.0;
151
+ float sw = clamp(sway, 0.0, 1.0);
152
+
153
+ // the camera pulls back, then moves back in on the incoming print
154
+ float back = smoothstep(0.0, 0.3, p) * (1.0 - smoothstep(0.6, 1.0, p));
155
+ float zoom = mix(1.0, clamp(size, 0.1, 1.0), back);
156
+ float vis = smoothstep(0.0, 0.35, back);
157
+ vec3 o = vec3(0.0, 0.05 * back, FOCAL / zoom);
158
+ vec3 d = vec3((uv - 0.5) * vec2(ratio, 1.0), -FOCAL);
159
+ float aa = max(AA * min(1.0, 40.0 * back), 1e-6);
160
+
161
+ // the line carries the prints along
162
+ float u = slideTime(p);
163
+ float m = slideAmount(u);
164
+ float speed = 16.0 * u * u * (1.0 - u) * (1.0 - u);
165
+ float spacing = ratio + GAP;
166
+ float cFrom = -s * spacing * m;
167
+ float cTo = s * spacing * (1.0 - m);
168
+ // the bottoms lag behind and overshoot, and swing back in the wind of the move
169
+ float bend = s * 0.65 * sw * swing(p);
170
+ float psi = 0.45 * sw * speed;
171
+
172
+ vec3 hf = printHit(o, d, cFrom, psi);
173
+ vec3 ht = printHit(o, d, cTo, psi);
174
+
175
+ // the wall, seen around the prints (only behind their transparent parts at the ends),
176
+ // with the soft shadows of the prints, the pins and the line
177
+ vec4 col = premultiply(background);
178
+ float cover = max(
179
+ clamp(0.5 - paperDist(hf.xy, bend) / (hf.z * aa), 0.0, 1.0),
180
+ clamp(0.5 - paperDist(ht.xy, bend) / (ht.z * aa), 0.0, 1.0));
181
+ col *= mix(1.0, back, cover);
182
+ if (back > 0.0) {
183
+ vec3 w = o + d * ((o.z + WALL) / FOCAL);
184
+ vec3 sf = printHit(w, LIGHT, cFrom, psi);
185
+ vec3 st = printHit(w, LIGHT, cTo, psi);
186
+ float blur = 0.025;
187
+ float sh = 1.0 - smoothstep(-blur, blur, min(paperDist(sf.xy, bend), paperDist(st.xy, bend)));
188
+ sh = max(sh, 1.0 - smoothstep(-0.012, 0.02, min(pinDist(sf.xy), pinDist(st.xy))));
189
+ float ry = w.y + LIGHT.y * (WALL / LIGHT.z) - (0.5 - 0.012);
190
+ sh = max(sh, 0.8 * (1.0 - smoothstep(0.0, 0.012, abs(ry))));
191
+ // and a soft falloff of the light away from the top left
192
+ float fall = 0.1 * clamp(length(w.xy - vec2(-0.4 * ratio, 0.6)) / (1.2 * ratio + 0.6), 0.0, 1.0);
193
+ col.rgb *= (1.0 - 0.42 * vis * sh) * (1.0 - fall * vis);
194
+ }
195
+
196
+ col = drawPrint(col, hf, true, bend, psi, aa, vis);
197
+ col = drawPrint(col, ht, false, bend, psi, aa, vis);
198
+
199
+ // the line, in front of the top of the prints
200
+ if (vis > 0.0) {
201
+ float tl = (o.z - 0.004) / FOCAL;
202
+ float ly = o.y + d.y * tl - (0.5 - 0.012);
203
+ float lc = vis * clamp(0.5 - (abs(ly) - ROPE) / (tl * aa), 0.0, 1.0);
204
+ if (lc > 0.0) {
205
+ float k = clamp(ly / ROPE, -1.0, 1.0);
206
+ // twisted strands, carried along with the line, lit from above
207
+ float lx = o.x + d.x * tl + s * spacing * m;
208
+ float strand = 0.88 + 0.12 * sin((lx + ly * 0.6) * 360.0);
209
+ vec3 c = lineColor.rgb * (0.7 + 0.45 * sqrt(1.0 - k * k) + 0.15 * k) * strand;
210
+ vec4 lcp = premultiply(vec4(c, lineColor.a));
211
+ col = lcp * lc + col * (1.0 - lcp.a * lc);
212
+ }
213
+ col = drawPins(col, hf, aa, vis);
214
+ col = drawPins(col, ht, aa, vis);
215
+ }
216
+ return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
217
+ }
@@ -0,0 +1,174 @@
1
+ // ComicPanels — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ComicPanels.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The frame splits into slanted comic-book panels with gutters and ink borders; one after another in reading order, each panel lifts off the page with a zoom kick and a drop shadow and punches over to the incoming image, then the gutters close up over the full incoming image
5
+ // Tags: comic, panels, grid, zoom
6
+
7
+ // @range(0, 0.1) Width of the gutters between the panels, as a part of the frame's height
8
+ uniform float gutter; // = 0.03
9
+ // @color Color of the gutters and of the page's margin
10
+ uniform vec4 gutterColor; // = vec4(1.0, 1.0, 1.0, 1.0)
11
+ // @color Color of the ink borders around the panels
12
+ uniform vec4 borderColor; // = vec4(0.0, 0.0, 0.0, 1.0)
13
+ // @range(0, 100, 1) Changes the layout of the panels
14
+ uniform float seed; // = 0.0
15
+
16
+ const float PI = 3.141592653589793;
17
+ // width of the ink borders, as a part of the frame's height
18
+ const float INK = 0.005;
19
+ // width of the anti-aliased edges, as a part of the frame's height
20
+ const float EDGE = 0.0012;
21
+ // part of the transition taken by each panel's punch
22
+ const float PUNCH = 0.3;
23
+ // the first panel's punch starts at START, the last one ends at END
24
+ const float START = 0.05;
25
+ const float END = 0.97;
26
+ // number of spikes of the burst that brings the incoming image into a panel
27
+ const float SPIKES = 11.0;
28
+
29
+ float hash(vec2 v) {
30
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
31
+ v3 += dot(v3, v3.yzx + 33.33);
32
+ return fract((v3.x + v3.y) * v3.z);
33
+ }
34
+
35
+ // number of panels in row r (0 is the top row)
36
+ float cols(float r) {
37
+ float h = hash(vec2(r * 7.0 + 3.0, seed * 1.37 + 11.0));
38
+ float n = h < 0.15 ? 1.0 : (h < 0.6 ? 2.0 : 3.0);
39
+ // the middle row is never a single panel, a narrow frame takes at most 2 panels per row
40
+ if (r == 1.0) n = max(n, 2.0);
41
+ if (ratio < 0.8) n = min(n, 2.0);
42
+ return n;
43
+ }
44
+
45
+ // signed distance of p (x from 0 to ratio, y from 0 at the top to 1) below the gutter k between the rows
46
+ // (0 is the top of the frame, 3 its bottom)
47
+ float rowDist(float k, vec2 p) {
48
+ if (k < 0.5) return p.y;
49
+ if (k > 2.5) return p.y - 1.0;
50
+ float y = (k + (hash(vec2(k * 5.0 + 1.0, seed * 1.37)) - 0.5) * 0.35) / 3.0;
51
+ float s = (hash(vec2(k * 9.0 + 4.0, seed * 1.37 + 5.0)) - 0.5) * 0.24;
52
+ return (p.y - y - s * (p.x / ratio - 0.5)) / sqrt(1.0 + s * s / (ratio * ratio));
53
+ }
54
+
55
+ // signed distance of p right of the gutter j of row r, which has n panels (0 is the left of the frame, n its right)
56
+ float colDist(float r, float j, float n, vec2 p) {
57
+ if (j < 0.5) return p.x;
58
+ if (j > n - 0.5) return p.x - ratio;
59
+ float x = (j + (hash(vec2(r * 3.0 + j * 13.0, seed * 1.37 + 2.0)) - 0.5) * 0.45) / n;
60
+ float s = (hash(vec2(r * 11.0 + j * 5.0, seed * 1.37 + 7.0)) - 0.5) * 0.5;
61
+ return (p.x - ratio * (x + s * (p.y - 0.5))) / sqrt(1.0 + ratio * ratio * s * s);
62
+ }
63
+
64
+ // signed distance to the edges of panel c of row r, positive inside
65
+ float panelDist(float r, float c, float n, vec2 p) {
66
+ return min(min(rowDist(r, p), -rowDist(r + 1.0, p)), min(colDist(r, c, n, p), -colDist(r, c + 1.0, n, p)));
67
+ }
68
+
69
+ // a point inside panel c of row r, as far from its top as from its bottom and from its left as from its right
70
+ vec2 panelCenter(float r, float c, float n) {
71
+ // the sums of the distances to the opposite edges are linear: find where they are 0
72
+ float y0 = rowDist(r, vec2(0.5 * ratio, 0.0)) + rowDist(r + 1.0, vec2(0.5 * ratio, 0.0));
73
+ float y1 = rowDist(r, vec2(0.5 * ratio, 1.0)) + rowDist(r + 1.0, vec2(0.5 * ratio, 1.0));
74
+ float y = y0 / (y0 - y1);
75
+ float x0 = colDist(r, c, n, vec2(0.0, y)) + colDist(r, c + 1.0, n, vec2(0.0, y));
76
+ float x1 = colDist(r, c, n, vec2(1.0, y)) + colDist(r, c + 1.0, n, vec2(1.0, y));
77
+ return vec2(x0 / (x0 - x1), y);
78
+ }
79
+
80
+ // the panel's punch, 0 to 1: panel k of the n panels of the page, in reading order
81
+ float panelTime(float k, float total) {
82
+ float t0 = START + (END - START - PUNCH) * k / max(total - 1.0, 1.0);
83
+ return clamp((progress - t0) / PUNCH, 0.0, 1.0);
84
+ }
85
+
86
+ // how high the panel is lifted off the page: a quick rise, a slower settle
87
+ float lift(float t) {
88
+ float u = 1.0 - (1.0 - t) * (1.0 - t);
89
+ return sin(PI * u);
90
+ }
91
+
92
+ // the panel's image at the page point p: the outgoing one until the incoming one bursts out of the panel's center
93
+ // in a jagged star with an ink outline
94
+ vec4 panelImage(vec2 p, vec2 center, float t) {
95
+ float k = lift(t);
96
+ // the image zooms in with the kick, then settles
97
+ vec2 q = center + (p - center) / (1.0 + 0.1 * k);
98
+ vec2 uv = vec2(q.x / ratio, 1.0 - q.y);
99
+ if (t <= 0.0) return getFromColor(uv);
100
+ if (t >= 1.0) return getToColor(uv);
101
+ vec2 v = p - center;
102
+ float a = (atan(v.y, v.x + 1e-6) + PI) / (2.0 * PI) * SPIKES + center.x * 7.0;
103
+ float i = floor(a);
104
+ // the spikes, of uneven lengths
105
+ // (the spike index wraps around so that the star has no seam where the angle wraps)
106
+ float spike = (1.0 - abs(2.0 * (a - i) - 1.0)) * (0.5 + 0.5 * hash(vec2(mod(i, SPIKES), center.y * 13.0 + seed)));
107
+ // large enough to cover the widest panel, a whole row of a wide frame
108
+ float burst = 1.5 * max(1.0, ratio / 1.8) * smoothstep(0.06, 0.42, t);
109
+ float d = length(v) - burst * (0.62 + 0.38 * spike);
110
+ float w = 1.4 * INK;
111
+ vec4 c = mix(getToColor(uv), borderColor, smoothstep(-w - EDGE, -w + EDGE, d));
112
+ return mix(c, getFromColor(uv), smoothstep(-EDGE, EDGE, d));
113
+ }
114
+
115
+ // the panel drawn over color: its gutter edge at g from its edges, its ink border inside it
116
+ vec4 drawPanel(vec4 color, vec4 img, float d, float g, float ink, float fade) {
117
+ vec4 c = mix(borderColor, img, mix(1.0, smoothstep(g + ink - EDGE, g + ink + EDGE, d), fade));
118
+ return mix(color, c, mix(1.0, smoothstep(g - EDGE, g + EDGE, d), fade));
119
+ }
120
+
121
+ vec4 transition(vec2 uv) {
122
+ if (progress <= 0.0) return getFromColor(uv);
123
+ if (progress >= 1.0) return getToColor(uv);
124
+ vec2 p = vec2(uv.x * ratio, 1.0 - uv.y);
125
+
126
+ // the gutters open at the start and close over the incoming image at the end
127
+ float open = smoothstep(0.0, 0.14, progress) * (1.0 - smoothstep(0.8, 1.0, progress));
128
+ float g = 0.5 * gutter * open;
129
+ float ink = INK * open;
130
+ // the edges come in gently instead of popping in at half coverage
131
+ float fade = clamp(open * 6.0, 0.0, 1.0);
132
+
133
+ float n0 = cols(0.0);
134
+ float n1 = cols(1.0);
135
+ float n2 = cols(2.0);
136
+ float total = n0 + n1 + n2;
137
+
138
+ // the panel under the point, on the page
139
+ float r = rowDist(1.0, p) < 0.0 ? 0.0 : (rowDist(2.0, p) < 0.0 ? 1.0 : 2.0);
140
+ float n = r == 0.0 ? n0 : (r == 1.0 ? n1 : n2);
141
+ float c = colDist(r, 1.0, n, p) < 0.0 ? 0.0 : (colDist(r, 2.0, n, p) < 0.0 || n < 2.5 ? 1.0 : 2.0);
142
+ c = min(c, n - 1.0);
143
+ float first = r == 0.0 ? 0.0 : (r == 1.0 ? n0 : n0 + n1);
144
+ float t = panelTime(first + c, total);
145
+
146
+ vec4 color = gutterColor;
147
+ if (t <= 0.0 || t >= 1.0) {
148
+ color = drawPanel(color, panelImage(p, panelCenter(r, c, n), t), panelDist(r, c, n, p), g, ink, fade);
149
+ }
150
+
151
+ // the panels lifted off the page, the later ones on top: at most 4 of them punch at once
152
+ float spacing = (END - START - PUNCH) / max(total - 1.0, 1.0);
153
+ // (with a margin, so that a panel at the very end of its punch is not missed to rounding)
154
+ float kFirst = floor((progress - START - PUNCH) / spacing - 0.01) + 1.0;
155
+ for (int i = 0; i < 4; i++) {
156
+ float pk = kFirst + float(i);
157
+ if (pk < 0.0 || pk > total - 0.5) continue;
158
+ float pt = panelTime(pk, total);
159
+ if (pt <= 0.0 || pt >= 1.0) continue;
160
+ float pr = pk < n0 ? 0.0 : (pk < n0 + n1 ? 1.0 : 2.0);
161
+ float pn = pr == 0.0 ? n0 : (pr == 1.0 ? n1 : n2);
162
+ float pc = pk - (pr == 0.0 ? 0.0 : (pr == 1.0 ? n0 : n0 + n1));
163
+ float k = lift(pt);
164
+ vec2 center = panelCenter(pr, pc, pn);
165
+ float s = 1.0 + 0.08 * k;
166
+ // its soft shadow on the page, down and to the right
167
+ vec2 sq = center + (p - vec2(0.012, 0.018) * k - center) / s;
168
+ float sd = panelDist(pr, pc, pn, sq) - g;
169
+ color.rgb *= 1.0 - 0.4 * k * fade * smoothstep(-0.02, 0.01, sd);
170
+ vec2 q = center + (p - center) / s;
171
+ color = drawPanel(color, panelImage(q, center, pt), panelDist(pr, pc, pn, q), g, ink, 1.0);
172
+ }
173
+ return color;
174
+ }