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,57 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image is printed in two inks, shadows first, as a bold high-contrast duotone; the incoming image is printed over it in the same two inks, its dark tones landing before its highlights, then its own colors come back, highlights first
4
+ // Tags: color, duotone, print, poster, gradient-map, luminance
5
+
6
+ // @color Ink printed in the shadows (its alpha is its strength)
7
+ uniform vec4 shadowInk; // = vec4(0.11, 0.09, 0.46, 1.0)
8
+ // @color Ink printed in the highlights (its alpha is its strength)
9
+ uniform vec4 highlightInk; // = vec4(1.0, 0.45, 0.62, 1.0)
10
+ // @range(0, 1) How hard the tones are pushed apart toward the two inks
11
+ uniform float contrast; // = 0.6
12
+ // @range(0, 1) Amount of print grain in the inks and along the handoff
13
+ uniform float grain; // = 0.4
14
+
15
+ float dfHash(vec2 v) {
16
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
17
+ v3 += dot(v3, v3.yzx + 33.33);
18
+ return fract((v3.x + v3.y) * v3.z);
19
+ }
20
+
21
+ float dfLuma(vec4 c) {
22
+ return clamp(dot(c.rgb, vec3(0.299, 0.587, 0.114)), 0.0, 1.0);
23
+ }
24
+
25
+ vec4 transition(vec2 uv) {
26
+ vec4 a = getFromColor(uv);
27
+ vec4 b = getToColor(uv);
28
+ float la = dfLuma(a);
29
+ float lb = dfLuma(b);
30
+ // fixed print grain, in cells of about 1/360 of the shorter side
31
+ vec2 q = uv * 360.0 * vec2(max(ratio, 1.0), max(1.0 / ratio, 1.0));
32
+ float g = dfHash(floor(q)) - 0.5;
33
+
34
+ // the inks land on the outgoing image (shadows first), then lift off the incoming one (highlights first)
35
+ float inks = smoothstep(0.0, 0.35, progress);
36
+ float lift = smoothstep(0.65, 1.0, progress);
37
+ float amount = min(
38
+ clamp(inks * 1.35 - 0.35 * la, 0.0, 1.0),
39
+ clamp((1.0 - lift) * 1.35 - 0.35 * lb, 0.0, 1.0)
40
+ );
41
+ amount = amount * amount * (3.0 - 2.0 * amount);
42
+
43
+ // the incoming image is printed over the outgoing one, darkest tones first, along a grainy edge
44
+ float x = smoothstep(0.25, 0.75, progress) * 1.6 - 0.3;
45
+ float t = lb + 0.2 * grain * g;
46
+ float s = smoothstep(t - 0.15, t + 0.15, x);
47
+
48
+ // gradient map on luminance, with the tones pushed toward the two inks
49
+ float c = 0.4 * contrast;
50
+ float tone = smoothstep(c + 0.03, 1.03 - c, mix(la, lb, s) + 0.08 * grain * g);
51
+ vec4 ink = mix(shadowInk, highlightInk, tone);
52
+
53
+ // the images are blended with premultiplied alpha, and where neither is drawn nothing is printed
54
+ vec4 base = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), s);
55
+ if (base.a <= 0.0) return vec4(0.0);
56
+ return vec4(mix(base.rgb / base.a, ink.rgb, amount * ink.a), base.a);
57
+ }
@@ -0,0 +1,136 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The frame is seen through a pane of irregular cut-glass facets, each one showing its own shifted, zoomed and tilted view of the image, with bright beveled edges and thin dark seams; the facets turn to the incoming image one by one, then the glass flattens out and clears
4
+ // Tags: glass, refraction, facets, voronoi, distortion
5
+
6
+ // @range(2, 20) Number of facets across the height of the frame
7
+ uniform float facets; // = 5.0
8
+ // @range(0, 0.3) How far each facet shifts its view of the image at the peak
9
+ uniform float refraction; // = 0.1
10
+ // @range(0, 1) Strength of the highlights and shadows along the beveled edges, and of the glint as each facet turns
11
+ uniform float bevel; // = 0.6
12
+ // @color Color of the light caught by the bevels
13
+ uniform vec4 highlight; // = vec4(1.0, 0.98, 0.92, 1.0)
14
+ // @param Random seed: another value gives other facets, turning in another order
15
+ uniform float seed; // = 0.0
16
+
17
+ // half width of the antialiased seams, in frame heights
18
+ const float AA = 0.0015;
19
+
20
+ vec2 hash22(vec2 p) {
21
+ vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
22
+ p3 += dot(p3, p3.yzx + 33.33);
23
+ return fract((p3.xx + p3.yz) * p3.zy);
24
+ }
25
+
26
+ // mirror the coordinates back into the frame
27
+ vec2 mirror(vec2 v) {
28
+ return 1.0 - abs(1.0 - mod(v, 2.0));
29
+ }
30
+
31
+ vec4 transition(vec2 uv) {
32
+ if (progress <= 0.0) return getFromColor(uv);
33
+ if (progress >= 1.0) return getToColor(uv);
34
+
35
+ // 0 at both ends, 1 in the middle: the glass builds up, then flattens out
36
+ float h = 1.0 - abs(2.0 * progress - 1.0);
37
+ float amount = h * h * (3.0 - 2.0 * h);
38
+
39
+ float n = max(facets, 1.0);
40
+ vec2 aspect = vec2(ratio, 1.0);
41
+ // measured in square pixels, so the facets are not stretched
42
+ vec2 p = uv * aspect * n;
43
+ vec2 i = floor(p);
44
+ vec2 f = p - i;
45
+ vec2 offset = vec2(17.31, 41.97) * seed;
46
+ // width of the bevels, in facet sizes
47
+ float bw = 0.18 * amount;
48
+
49
+ // nearest facet center
50
+ vec2 mg = vec2(0.0);
51
+ vec2 mr = vec2(0.0);
52
+ float md = 8.0;
53
+ for (int y = -1; y <= 1; y++) {
54
+ for (int x = -1; x <= 1; x++) {
55
+ vec2 g = vec2(float(x), float(y));
56
+ vec2 r = g + 0.1 + 0.8 * hash22(i + g + offset) - f;
57
+ float d = dot(r, r);
58
+ if (d < md) {
59
+ md = d;
60
+ mr = r;
61
+ mg = g;
62
+ }
63
+ }
64
+ }
65
+
66
+ // distance to the nearest facet edge, and the direction toward the edges, blended
67
+ // between neighboring edges near the corners so the bevel lighting turns smoothly
68
+ float edge = 8.0;
69
+ vec2 normal = vec2(0.0);
70
+ for (int y = -2; y <= 2; y++) {
71
+ for (int x = -2; x <= 2; x++) {
72
+ vec2 g = mg + vec2(float(x), float(y));
73
+ vec2 r = g + 0.1 + 0.8 * hash22(i + g + offset) - f;
74
+ vec2 dr = r - mr;
75
+ if (dot(dr, dr) > 0.00001) {
76
+ vec2 dn = normalize(dr);
77
+ float e = dot(0.5 * (mr + r), dn);
78
+ edge = min(edge, e);
79
+ float w = max(1.0 - e / bw, 0.0);
80
+ normal += dn * w * w;
81
+ }
82
+ }
83
+ }
84
+ float nl = length(normal);
85
+ normal = nl > 0.0 ? normal / nl : vec2(0.0);
86
+
87
+ // the facet's own random cut: a shift, a zoom and a tilt
88
+ vec2 id = i + mg + offset;
89
+ vec2 h1 = hash22(id + 31.7);
90
+ vec2 h2 = hash22(id + 59.3);
91
+ vec2 h3 = hash22(id + 97.1);
92
+ float angle = 6.2831853 * h1.x;
93
+ vec2 dir = vec2(cos(angle), sin(angle));
94
+ vec2 shift = dir * (0.4 + 0.6 * h1.y) * refraction;
95
+ float zoom = (h2.x - 0.5) * 6.0 * refraction;
96
+ float tilt = (h2.y - 0.5) * 2.0 * refraction;
97
+
98
+ // from the facet center to the pixel, in frame heights
99
+ vec2 q = -mr / n;
100
+ vec2 view = -q * zoom + vec2(-q.y, q.x) * sin(tilt) + q * (cos(tilt) - 1.0);
101
+
102
+ // the bevel along the facet's edge: 1 on the edge, 0 inside
103
+ float bv = 1.0 - smoothstep(0.0, bw, edge);
104
+ bv *= bv;
105
+ // the bevel bends the image outward, more strongly than the flat facet
106
+ vec2 bend = normal * bv * 0.4 * refraction;
107
+
108
+ // the facet turns to the incoming image at its own time, and its view turns over with it
109
+ float start = 0.15 + 0.5 * h3.x;
110
+ float m = smoothstep(start, start + 0.2, progress);
111
+ vec2 d = amount * (view + bend);
112
+ vec2 s = amount * shift;
113
+ vec4 ca = getFromColor(mirror(uv + (s + d) / aspect));
114
+ vec4 cb = getToColor(mirror(uv + (d - s) / aspect));
115
+ // mixed premultiplied, so transparent images do not bleed their color
116
+ vec4 c = mix(vec4(ca.rgb * ca.a, ca.a), vec4(cb.rgb * cb.a, cb.a), m);
117
+
118
+ // light from the top left: each flat facet catches it a little differently
119
+ vec2 light = normalize(vec2(-0.6, 0.8));
120
+ vec2 slope = dir * (0.4 + 0.6 * h1.y);
121
+ float facetLight = 0.12 * amount * dot(slope, light);
122
+ // the bevels catch it strongly on one side and shade the other
123
+ float lit = dot(normal, light);
124
+ float k = clamp(bevel, 0.0, 1.0);
125
+ float glow = k * bv * max(lit, 0.0) * 1.1 * amount;
126
+ float shade = k * bv * max(-lit, 0.0) * 0.6 * amount;
127
+ // a glint as the facet turns over
128
+ float turn = sin(3.14159265 * m);
129
+ glow += k * 0.15 * amount * turn * turn;
130
+ // thin dark seams between the facets
131
+ float seam = 0.6 * amount * (1.0 - smoothstep(0.0, 2.0 * AA, edge / n - 0.5 * AA));
132
+
133
+ c.rgb *= (1.0 + facetLight) * (1.0 - shade) * (1.0 - seam);
134
+ c.rgb += highlight.rgb * highlight.a * glow * c.a;
135
+ return c.a > 0.0 ? vec4(clamp(c.rgb / c.a, 0.0, 1.0), c.a) : vec4(0.0);
136
+ }
@@ -0,0 +1,175 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: Ice crystals grow in from the edges of the frame with feathery, branching fronts, frosting the outgoing image white and blurry until it is covered, then thaw back out to the edges on the incoming image
4
+ // Tags: frost, ice, crystal, blur, cover
5
+
6
+ // @range(0, 1) How far the crystal fingers reach ahead of the frost
7
+ uniform float spread; // = 0.5
8
+ // @range(2, 12) Size of the crystals: more, smaller ones with a larger value
9
+ uniform float scale; // = 5.0
10
+ // @range(0, 1) How much the frost blurs the image under it
11
+ uniform float blur; // = 0.5
12
+ // @color Color of the frost
13
+ uniform vec4 color; // = vec4(0.86, 0.93, 1.0, 1.0)
14
+
15
+ const int TAPS = 12;
16
+
17
+ float hash12(vec2 v) {
18
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
19
+ v3 += dot(v3, v3.yzx + 33.33);
20
+ return fract((v3.x + v3.y) * v3.z);
21
+ }
22
+
23
+ float vnoise(vec2 v) {
24
+ vec2 i = floor(v);
25
+ vec2 f = fract(v);
26
+ f = f * f * (3.0 - 2.0 * f);
27
+ return mix(
28
+ mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
29
+ mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
30
+ f.y
31
+ );
32
+ }
33
+
34
+ // ridged noise: thin bright veins where the noise crosses its middle, like crystal ferns
35
+ float ridged(vec2 v) {
36
+ float sum = 0.0;
37
+ float amp = 0.5;
38
+ for (int i = 0; i < 4; i++) {
39
+ float n = 1.0 - abs(2.0 * vnoise(v) - 1.0);
40
+ sum += amp * n * n;
41
+ v = mat2(1.6, 1.2, -1.2, 1.6) * v + 4.7;
42
+ amp *= 0.5;
43
+ }
44
+ return sum / 0.9375;
45
+ }
46
+
47
+ // crystal grains, cells of size 1: x is how far from the boundary between two grains
48
+ // (0 on it, where the crystals start), y a random number for the grain, zw the position
49
+ // relative to the grain's seed
50
+ vec4 grains(vec2 v) {
51
+ vec2 i = floor(v);
52
+ vec2 f = fract(v);
53
+ float d1 = 8.0;
54
+ float d2 = 8.0;
55
+ vec3 seed = vec3(0.0);
56
+ for (int y = -1; y <= 1; y++) {
57
+ for (int x = -1; x <= 1; x++) {
58
+ vec2 c = vec2(float(x), float(y));
59
+ vec2 o = c + vec2(hash12(i + c), hash12(i + c + 17.3)) - f;
60
+ float d = dot(o, o);
61
+ if (d < d1) {
62
+ d2 = d1;
63
+ d1 = d;
64
+ seed = vec3(hash12(i + c + 41.9), -o);
65
+ } else if (d < d2) {
66
+ d2 = d;
67
+ }
68
+ }
69
+ }
70
+ return vec4(sqrt(d2) - sqrt(d1), seed);
71
+ }
72
+
73
+ // mirror the coordinates back into the frame
74
+ vec2 mirror(vec2 v) {
75
+ return 1.0 - abs(1.0 - mod(v, 2.0));
76
+ }
77
+
78
+ // the image under the frost: the outgoing one, then the incoming one, switched under full cover
79
+ vec4 image(vec2 uv, float m) {
80
+ if (m <= 0.0) return getFromColor(uv);
81
+ if (m >= 1.0) return getToColor(uv);
82
+ return mix(getFromColor(uv), getToColor(uv), m);
83
+ }
84
+
85
+ vec4 transition(vec2 uv) {
86
+ float p = progress;
87
+ // 0 at both ends, 1 while the frost covers the whole frame (from 0.425 to 0.575)
88
+ float h = 1.0 - abs(2.0 * p - 1.0);
89
+ float a = clamp(h / 0.85, 0.0, 1.0);
90
+ a = a * (1.6 - 0.6 * a); // fast start, slowing down as the frost closes in
91
+ float m = smoothstep(0.47, 0.53, p);
92
+ if (a <= 0.0) return image(uv, m);
93
+
94
+ // how deep in the frame the pixel is: 0 on the edges, 1 at the center
95
+ vec2 q = uv * vec2(ratio, 1.0);
96
+ vec2 dEdge = min(uv, 1.0 - uv) * vec2(ratio, 1.0);
97
+ float depth = min(dEdge.x, dEdge.y) / (0.5 * min(ratio, 1.0));
98
+ depth = 1.0 - (1.0 - depth) * (1.0 - depth); // the covered area grows evenly
99
+
100
+ // the front, which moves from the edges past the deepest point; the crystals below only
101
+ // hold it back, so nothing is frosted (yet, or any more) deeper than it
102
+ float reach = 0.2 + 0.6 * clamp(spread, 0.0, 1.0);
103
+ float front = mix(-0.1, 1.0 + reach + 0.2, a);
104
+ if (depth > front + 0.08) return image(uv, m);
105
+
106
+ // crystals: ferns grow from the boundaries between grains, with parallel needles shooting
107
+ // off them at an angle that changes from grain to grain
108
+ vec2 gv = q * scale;
109
+ // the stems bend a little
110
+ vec4 gr = grains(gv + 0.35 * vec2(vnoise(gv * 1.7), vnoise(gv * 1.7 + 23.1)));
111
+ // the needles' direction, any angle (a rational point on the unit circle)
112
+ float u = 2.0 * gr.y - 1.0;
113
+ vec2 dir = vec2(1.0 - u * u, 2.0 * u) / (1.0 + u * u);
114
+ float t = dot(gr.zw, dir) * 7.0;
115
+ float needle = 1.0 - abs(2.0 * fract(t) - 1.0); // 1 along each needle, 0 between them
116
+ float nh = fract(gr.y + 0.618034 * floor(t));
117
+ float len = mix(0.15, 0.6, nh); // each needle has its own length
118
+ float r = ridged(gv * 1.3);
119
+ float rf = ridged(gv * 4.0 + 11.0);
120
+ // when the frost reaches the pixel, after the edges: the stems first, then the needles, then
121
+ // the gaps between them
122
+ float grow = min(gr.x * 3.5, gr.x / len * 0.5 + (1.0 - needle) * 1.2 + 0.2 * fract(nh * 13.7));
123
+ float field = depth + reach * (0.8 * min(grow, 1.0) + 0.2 * (1.0 - r)) + 0.1 * (1.0 - rf);
124
+ float inside = front - field; // > 0 under the frost
125
+ float f = smoothstep(0.0, 0.03, inside);
126
+ // a thin, faint haze of fine crystals just ahead of the front
127
+ float haze = 0.4 * smoothstep(0.9, 1.0, rf) * smoothstep(-0.08, 0.0, inside);
128
+ float frost = max(f, haze);
129
+ if (frost <= 0.0) return image(uv, m);
130
+
131
+ // thicker ice close to the edges, where it started growing
132
+ float thick = smoothstep(0.0, 0.5, inside);
133
+ float full = smoothstep(0.75, 0.95, h); // the frost turns opaque to hide the switch
134
+
135
+ // frosted glass: blur over a small jittered disc, scattered along the crystals
136
+ float radius = (0.004 + 0.03 * blur) * frost * (0.5 + 0.5 * thick);
137
+ float rot = 6.2831853 * hash12(floor(q * 90.0));
138
+ vec3 rgb = vec3(0.0);
139
+ float alpha = 0.0;
140
+ for (int i = 0; i < TAPS; i++) {
141
+ float k = (float(i) + 0.5) / float(TAPS);
142
+ float th = rot + float(i) * 2.3999632;
143
+ vec2 off = sqrt(k) * vec2(cos(th), sin(th)) * radius;
144
+ vec4 c = image(mirror(uv + off / vec2(ratio, 1.0)), m);
145
+ rgb += c.rgb * c.a;
146
+ alpha += c.a;
147
+ }
148
+ alpha /= float(TAPS);
149
+ rgb = alpha > 0.0 ? rgb / (alpha * float(TAPS)) : vec3(0.0);
150
+
151
+ // a cool white crystal tint, brighter on the stems, the needles (fading out toward their tips)
152
+ // and the growing front
153
+ float stem = 1.0 - smoothstep(0.0, 0.03, gr.x);
154
+ float needles = smoothstep(0.7, 1.0, needle) * (1.0 - smoothstep(0.0, len, gr.x));
155
+ float glint = 0.4 + 0.6 * rf;
156
+ float veins = clamp(glint * max(0.35 * stem, 0.55 * needles) + 0.3 * smoothstep(0.6, 0.95, r), 0.0, 1.0);
157
+ float rim = smoothstep(0.0, 0.02, inside) * (1.0 - smoothstep(0.02, 0.07, inside));
158
+ vec3 ice = clamp(color.rgb * (0.82 + 0.25 * veins), 0.0, 1.0);
159
+ float cover = frost * (0.35 + 0.3 * thick + 0.25 * veins);
160
+ cover = clamp(mix(cover, frost, full), 0.0, 1.0);
161
+ vec4 under = vec4(rgb * mix(vec3(1.0), color.rgb, 0.5 * frost), alpha);
162
+ // the frost color mixes as straight RGBA, like every fill color
163
+ vec4 res = mix(under, vec4(ice, color.a), cover);
164
+
165
+ // fine sparkles on the ice, twinkling as it grows
166
+ vec2 sq = q * 36.0;
167
+ vec2 cell = floor(sq);
168
+ vec2 d = abs(sq - cell - 0.25 - 0.5 * vec2(hash12(cell + 1.3), hash12(cell + 5.9)));
169
+ float star = max(0.0, 1.0 - 9.0 * length(d)) + max(0.0, 1.0 - 4.0 * (d.x + d.y) - 30.0 * min(d.x, d.y));
170
+ float tw = 0.5 + 0.5 * sin(6.2831853 * (hash12(cell + 9.1) + 2.0 * p));
171
+ float sparkle = step(0.82, hash12(cell + 3.7)) * min(star, 1.0) * tw * f * (0.4 + 0.6 * veins);
172
+ float light = clamp(0.4 * rim + 0.8 * sparkle, 0.0, 1.0);
173
+ res = mix(res, vec4(mix(color.rgb, vec3(1.0), 0.6), color.a), light);
174
+ return clamp(res, 0.0, 1.0);
175
+ }
@@ -0,0 +1,70 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image narrows into a curved funnel toward a point on the bottom edge and slides into it, its sides bending like a window minimized into a dock, revealing the incoming image behind it
4
+ // Tags: distort, slide, vertical, shadow
5
+
6
+ // @range(0, 1) Point of the bottom edge where the image disappears, from left (0) to right (1)
7
+ uniform float target; // = 0.7
8
+ // @range(0, 1) Shape of the funnel's sides: 0 straight, 1 bent into an S curve
9
+ uniform float curvature; // = 0.8
10
+ // @range(0, 1) Strength of the shading of the bent image and of the shadow it casts
11
+ uniform float shadow; // = 0.5
12
+
13
+ // width of the funnel's neck, as a part of the frame's height
14
+ const float NECK = 0.04;
15
+ // how far below the bottom edge the image's top ends, so it is gone at the end
16
+ const float OVERSHOOT = 0.03;
17
+ // width of the anti-aliased edges, as a part of the frame's height
18
+ const float EDGE = 0.0015;
19
+ // reach of the soft shadow, as a part of the frame's height
20
+ const float SOFT = 0.06;
21
+
22
+ vec4 transition(vec2 uv) {
23
+ float t = progress;
24
+ // one eased timing: the funnel forms from the very start while the slide accelerates into it
25
+ float f = smoothstep(0.0, 1.0, 1.0 - (1.0 - t) * (1.0 - t) * (1.0 - t));
26
+ float slide = (1.0 + OVERSHOOT) * t * t * (1.5 - 0.5 * t);
27
+
28
+ float r = max(ratio, 1e-4);
29
+ float nh = 0.5 * NECK / r;
30
+ // the whole neck stays in the frame
31
+ float tx = clamp(target, nh, 1.0 - nh);
32
+ float c = clamp(curvature, 0.0, 1.0);
33
+
34
+ // the funnel's profile, 0 at the neck on the bottom edge to 1 at the top of the frame
35
+ float q = clamp(uv.y, 0.0, 1.0);
36
+ float w = mix(q, q * q * (3.0 - 2.0 * q), c);
37
+ float dw = mix(1.0, 6.0 * q * (1.0 - q), c);
38
+ float L = f * mix(tx - nh, 0.0, w);
39
+ float R = 1.0 - f * (1.0 - mix(tx + nh, 1.0, w));
40
+ float dL = -f * (tx - nh) * dw;
41
+ float dR = f * (1.0 - tx - nh) * dw;
42
+ float v = uv.y + slide;
43
+
44
+ // anti-aliased coverage, measured across the slanted sides (a side on the frame's border is not an edge)
45
+ float e = EDGE * min(1.0, 10.0 * t) + 1e-6;
46
+ float left = L > 0.0 ? (uv.x - L) * r / sqrt(1.0 + dL * dL * r * r) : 1.0;
47
+ float right = R < 1.0 ? (R - uv.x) * r / sqrt(1.0 + dR * dR * r * r) : 1.0;
48
+ float cov = clamp(min(min(left, right), 1.0 - v) / e + 0.5, 0.0, 1.0);
49
+
50
+ vec4 img = vec4(0.0);
51
+ float s = clamp(shadow, 0.0, 1.0);
52
+ if (cov > 0.0) {
53
+ float width = R - L;
54
+ vec2 src = clamp(vec2((uv.x - L) / width, v), 0.0, 1.0);
55
+ img = getFromColor(src);
56
+ // the squeezed rows round like a bent sheet, darker on their sides and toward the neck
57
+ float across = 2.0 * src.x - 1.0;
58
+ img.rgb *= 1.0 - s * (1.0 - width) * (0.5 * across * across + 0.3 * (1.0 - w));
59
+ if (cov >= 1.0) return img;
60
+ }
61
+
62
+ vec4 bg = getToColor(uv);
63
+ // soft shadow of the funnel cast on the incoming image
64
+ float ox = max(L - uv.x, uv.x - R) * r;
65
+ float oy = uv.y - (1.0 - slide);
66
+ float dist = length(max(vec2(ox, oy), 0.0));
67
+ bg.rgb *= 1.0 - s * 0.6 * f * (1.0 - t) * (1.0 - smoothstep(0.0, SOFT, dist));
68
+
69
+ return mix(bg, img, cov);
70
+ }
@@ -0,0 +1,124 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The bright points of the outgoing image sparkle into crisp four-point star glints that swell and twinkle up to the cut, then shrink back into the highlights of the incoming image, which stays sharp
4
+ // Tags: light, glints, sparkle, dissolve
5
+
6
+ // @range(0.02, 0.3) Length of the longest rays of the glints at the peak, in frame heights
7
+ uniform float size; // = 0.15
8
+ // @range(0, 1) Brightness above which the image sparkles
9
+ uniform float threshold; // = 0.6
10
+ // @range(0, 4) Brightness of the glints
11
+ uniform float intensity; // = 2.0
12
+ // @param Add a shorter, softer pair of diagonal rays to each glint
13
+ uniform bool diagonals; // = false
14
+ // @range(-45, 45) Angle of the cross, in degrees
15
+ uniform float rotation; // = 0.0
16
+ // @range(0, 1) Rainbow fringes along the rays
17
+ uniform float rainbow; // = 0.35
18
+ // @color Tint of the glints, added as light
19
+ uniform vec3 tint; // = vec3(1.0, 0.95, 0.85)
20
+
21
+ // the long rays reach over this many cells of the glint grid
22
+ const float REACH = 6.0;
23
+
24
+ float hash12(vec2 v) {
25
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
26
+ v3 += dot(v3, v3.yzx + 33.33);
27
+ return fract((v3.x + v3.y) * v3.z);
28
+ }
29
+
30
+ // one thin ray along x, from the glint center to its tip at x = len (in cells)
31
+ float ray(vec2 d, float len, float width) {
32
+ float a = abs(d.x) / len;
33
+ if (a >= 1.0) return 0.0;
34
+ float fall = (1.0 - a) * (1.0 - a);
35
+ float w = width * (1.0 - 0.7 * a);
36
+ return fall * exp(-d.y * d.y / (w * w));
37
+ }
38
+
39
+ vec3 spectrum(float a) {
40
+ return 0.5 + 0.5 * cos(6.2831853 * (a + vec3(0.0, 0.33, 0.67)));
41
+ }
42
+
43
+ vec4 transition(vec2 uv) {
44
+ float p = progress;
45
+ // the glints swell up to the cut, then shrink back: 0 at both ends
46
+ float t = 1.0 - abs(2.0 * p - 1.0);
47
+ float amount = t * (2.0 - t);
48
+ // a short crossfade under the glints at their brightest
49
+ float m = smoothstep(0.42, 0.58, p);
50
+ if (amount <= 0.0) return m < 0.5 ? getFromColor(uv) : getToColor(uv);
51
+
52
+ vec4 fromColor = getFromColor(uv);
53
+ vec4 toColor = getToColor(uv);
54
+ vec4 c = mix(vec4(fromColor.rgb * fromColor.a, fromColor.a), vec4(toColor.rgb * toColor.a, toColor.a), m);
55
+ if (c.a <= 0.0) return vec4(0.0);
56
+ vec3 base = c.rgb / c.a;
57
+
58
+ // a grid of glint cells, turned with the cross so that its long rays run along the rows and columns
59
+ float cell = size / REACH;
60
+ float ang = radians(rotation);
61
+ vec2 cs = vec2(cos(ang), sin(ang));
62
+ vec2 aspect = vec2(ratio, 1.0);
63
+ vec2 o = (uv - 0.5) * aspect;
64
+ vec2 q = vec2(o.x * cs.x + o.y * cs.y, o.y * cs.x - o.x * cs.y) / cell;
65
+ vec2 home = floor(q);
66
+ // thin rays, in cells, thin enough to vanish before the next row of cells
67
+ float width = min(0.0022 / cell, 0.07);
68
+
69
+ vec3 light = vec3(0.0);
70
+ // the glints of the own cell, of the cells along its row and column (whose long rays reach this
71
+ // pixel) and of its four diagonal neighbours (for their short diagonal rays and their cores)
72
+ for (int k = 0; k < 29; k++) {
73
+ float fk = float(k);
74
+ vec2 off = vec2(0.0);
75
+ if (k >= 1 && k <= 12) off = vec2(fk < 7.0 ? fk - 7.0 : fk - 6.0, 0.0);
76
+ else if (k >= 13 && k <= 24) off = vec2(0.0, fk < 19.0 ? fk - 19.0 : fk - 18.0);
77
+ else if (k >= 25) off = vec2(mod(fk, 2.0) * 2.0 - 1.0, fk < 27.0 ? -1.0 : 1.0);
78
+ // the rays are never longer than this, so farther glints cannot reach the pixel
79
+ if (max(abs(off.x), abs(off.y)) > REACH * amount + 1.0) continue;
80
+ vec2 id = home + off;
81
+ // only some of the cells hold a glint
82
+ if (hash12(id + 89.5) > 0.55) continue;
83
+ float h0 = hash12(id + 0.5);
84
+ float h1 = hash12(id + 19.5);
85
+ float h2 = hash12(id + 41.5);
86
+ float h3 = hash12(id + 67.5);
87
+ // the glint: somewhere in its cell, so that the grid never shows
88
+ vec2 center = id + 0.5 + 0.6 * (vec2(h0, h1) - 0.5);
89
+ vec2 cw = center * cell;
90
+ vec2 st = vec2(cw.x * cs.x - cw.y * cs.y, cw.x * cs.y + cw.y * cs.x) / aspect + 0.5;
91
+ if (st.x < 0.0 || st.x > 1.0 || st.y < 0.0 || st.y > 1.0) continue;
92
+ // each glint reads one image: it blinks out at its own moment of the crossfade and comes back
93
+ // on the incoming image
94
+ float turn = 0.15 + 0.7 * h3;
95
+ vec4 src = m < turn ? getFromColor(st) : getToColor(st);
96
+ float lum = dot(src.rgb, vec3(0.2126, 0.7152, 0.0722)) * src.a;
97
+ // the brighter the image, the more of its cells sparkle
98
+ float knee = threshold + 0.8 * (1.0 - threshold) * h2;
99
+ float b = smoothstep(knee, knee + 0.2 * (1.0 - threshold) + 1e-3, lum);
100
+ if (b <= 0.0) continue;
101
+ // each glint twinkles at its own pace
102
+ float twinkle = (0.6 + 0.4 * sin(6.2831853 * (h2 + (1.5 + h0) * p))) * smoothstep(0.0, 0.12, abs(m - turn));
103
+ float len = REACH * amount * (0.45 + 0.55 * b) * (0.3 + 0.7 * h1 * h1) * (0.85 + 0.15 * twinkle);
104
+ vec2 d = q - center;
105
+ float r = length(d);
106
+ float star = ray(d, len, width) + ray(d.yx, len, width);
107
+ if (diagonals) {
108
+ vec2 e = vec2(d.x + d.y, d.x - d.y) * 0.70710678;
109
+ star += 0.5 * (ray(e, 0.25 * len, width) + ray(e.yx, 0.25 * len, width));
110
+ }
111
+ // a bright core and a faint halo
112
+ float cr = r / (0.08 * len);
113
+ star += exp(-cr * cr) + 0.3 * exp(-r / 0.2);
114
+ // white light with the hue of the highlight, and rainbow fringes toward the tips
115
+ float along = r / len;
116
+ vec3 hue = mix(vec3(1.0), spectrum(1.3 * along + h0), rainbow * smoothstep(0.05, 0.4, along));
117
+ vec3 col = mix(src.rgb / max(max(src.r, max(src.g, src.b)), 1e-3), vec3(1.0), 0.6);
118
+ light += b * twinkle * star * hue * col;
119
+ }
120
+ light *= tint * intensity * amount * amount;
121
+ // compressed, so that crossing rays never flatten into white
122
+ light = 1.0 - exp(-light);
123
+ return vec4(clamp(base + light - base * light, 0.0, 1.0), c.a);
124
+ }