gl-transitions 2.1.0 → 2.3.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 (166) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/compatibility.json +496 -0
  3. package/gl-transitions.js +1 -1
  4. package/gl-transitions.json +1 -1
  5. package/glsl3/Accordion.glsl +85 -0
  6. package/glsl3/Ascii.glsl +124 -0
  7. package/glsl3/BlockCover.glsl +87 -0
  8. package/glsl3/BloomDissolve.glsl +110 -0
  9. package/glsl3/BokehDissolve.glsl +123 -0
  10. package/glsl3/BrushWipe.glsl +100 -0
  11. package/glsl3/CameraShake.glsl +98 -0
  12. package/glsl3/CardSwipe.glsl +81 -0
  13. package/glsl3/CurvedWipe.glsl +52 -0
  14. package/glsl3/CylinderRoll.glsl +102 -0
  15. package/glsl3/Disintegrate.glsl +112 -0
  16. package/glsl3/FilmDissolve.glsl +49 -0
  17. package/glsl3/FilmStrip.glsl +105 -0
  18. package/glsl3/FlameWipe.glsl +154 -0
  19. package/glsl3/GooeyWipe.glsl +97 -0
  20. package/glsl3/InkBleed.glsl +96 -0
  21. package/glsl3/LensFlare.glsl +125 -0
  22. package/glsl3/LightRays.glsl +106 -0
  23. package/glsl3/LightStreaks.glsl +117 -0
  24. package/glsl3/LightWipe.glsl +89 -0
  25. package/glsl3/PhotoDevelop.glsl +59 -0
  26. package/glsl3/PixelStretch.glsl +73 -0
  27. package/glsl3/PlusWipe.glsl +38 -0
  28. package/glsl3/PopIn.glsl +57 -0
  29. package/glsl3/Refraction.glsl +95 -0
  30. package/glsl3/SmokeDissolve.glsl +102 -0
  31. package/glsl3/SplatterWipe.glsl +154 -0
  32. package/glsl3/StretchSlide.glsl +62 -0
  33. package/glsl3/WedgeWipe.glsl +35 -0
  34. package/glsl3/WhipSpin.glsl +69 -0
  35. package/glsl3/WhipTilt.glsl +79 -0
  36. package/index.js +1 -1
  37. package/layouts.json +1512 -371
  38. package/llms-full.txt +793 -292
  39. package/llms.txt +185 -154
  40. package/msl/Accordion.metal +421 -0
  41. package/msl/Ascii.metal +567 -0
  42. package/msl/BlockCover.metal +403 -0
  43. package/msl/BloomDissolve.metal +416 -0
  44. package/msl/BokehDissolve.metal +447 -0
  45. package/msl/BrushWipe.metal +488 -0
  46. package/msl/CameraShake.metal +393 -0
  47. package/msl/CardSwipe.metal +342 -0
  48. package/msl/CurvedWipe.metal +229 -0
  49. package/msl/CylinderRoll.metal +374 -0
  50. package/msl/Disintegrate.metal +468 -0
  51. package/msl/FilmDissolve.metal +199 -0
  52. package/msl/FilmStrip.metal +429 -0
  53. package/msl/FlameWipe.metal +575 -0
  54. package/msl/GooeyWipe.metal +398 -0
  55. package/msl/InkBleed.metal +409 -0
  56. package/msl/LensFlare.metal +455 -0
  57. package/msl/LightRays.metal +427 -0
  58. package/msl/LightStreaks.metal +518 -0
  59. package/msl/LightWipe.metal +321 -0
  60. package/msl/PhotoDevelop.metal +245 -0
  61. package/msl/PixelStretch.metal +337 -0
  62. package/msl/PlusWipe.metal +199 -0
  63. package/msl/PopIn.metal +245 -0
  64. package/msl/Refraction.metal +333 -0
  65. package/msl/SmokeDissolve.metal +400 -0
  66. package/msl/SplatterWipe.metal +677 -0
  67. package/msl/StretchSlide.metal +243 -0
  68. package/msl/WedgeWipe.metal +154 -0
  69. package/msl/WhipSpin.metal +278 -0
  70. package/msl/WhipTilt.metal +327 -0
  71. package/package.json +1 -1
  72. package/skills/gl-transitions/references/catalog.md +113 -37
  73. package/sksl/Accordion.sksl +94 -0
  74. package/sksl/Ascii.sksl +131 -0
  75. package/sksl/BlockCover.sksl +96 -0
  76. package/sksl/BloomDissolve.sksl +119 -0
  77. package/sksl/BokehDissolve.sksl +132 -0
  78. package/sksl/BrushWipe.sksl +109 -0
  79. package/sksl/CameraShake.sksl +108 -0
  80. package/sksl/CardSwipe.sksl +93 -0
  81. package/sksl/CurvedWipe.sksl +64 -0
  82. package/sksl/CylinderRoll.sksl +112 -0
  83. package/sksl/Disintegrate.sksl +117 -0
  84. package/sksl/FilmDissolve.sksl +60 -0
  85. package/sksl/FilmStrip.sksl +114 -0
  86. package/sksl/FlameWipe.sksl +162 -0
  87. package/sksl/GooeyWipe.sksl +109 -0
  88. package/sksl/InkBleed.sksl +109 -0
  89. package/sksl/LensFlare.sksl +135 -0
  90. package/sksl/LightRays.sksl +115 -0
  91. package/sksl/LightStreaks.sksl +126 -0
  92. package/sksl/LightWipe.sksl +97 -0
  93. package/sksl/PhotoDevelop.sksl +72 -0
  94. package/sksl/PixelStretch.sksl +84 -0
  95. package/sksl/PlusWipe.sksl +50 -0
  96. package/sksl/PopIn.sksl +69 -0
  97. package/sksl/Refraction.sksl +103 -0
  98. package/sksl/SmokeDissolve.sksl +115 -0
  99. package/sksl/SplatterWipe.sksl +161 -0
  100. package/sksl/StretchSlide.sksl +74 -0
  101. package/sksl/WedgeWipe.sksl +46 -0
  102. package/sksl/WhipSpin.sksl +79 -0
  103. package/sksl/WhipTilt.sksl +90 -0
  104. package/sksl/index.js +1 -1
  105. package/transitions/Accordion.glsl +84 -0
  106. package/transitions/Ascii.glsl +123 -0
  107. package/transitions/BlockCover.glsl +86 -0
  108. package/transitions/BloomDissolve.glsl +109 -0
  109. package/transitions/BokehDissolve.glsl +122 -0
  110. package/transitions/BrushWipe.glsl +99 -0
  111. package/transitions/CameraShake.glsl +97 -0
  112. package/transitions/CardSwipe.glsl +80 -0
  113. package/transitions/CurvedWipe.glsl +51 -0
  114. package/transitions/CylinderRoll.glsl +101 -0
  115. package/transitions/Disintegrate.glsl +111 -0
  116. package/transitions/FilmDissolve.glsl +48 -0
  117. package/transitions/FilmStrip.glsl +104 -0
  118. package/transitions/FlameWipe.glsl +153 -0
  119. package/transitions/GooeyWipe.glsl +96 -0
  120. package/transitions/InkBleed.glsl +95 -0
  121. package/transitions/LensFlare.glsl +124 -0
  122. package/transitions/LightRays.glsl +105 -0
  123. package/transitions/LightStreaks.glsl +116 -0
  124. package/transitions/LightWipe.glsl +88 -0
  125. package/transitions/PhotoDevelop.glsl +58 -0
  126. package/transitions/PixelStretch.glsl +72 -0
  127. package/transitions/PlusWipe.glsl +37 -0
  128. package/transitions/PopIn.glsl +56 -0
  129. package/transitions/Refraction.glsl +94 -0
  130. package/transitions/SmokeDissolve.glsl +101 -0
  131. package/transitions/SplatterWipe.glsl +153 -0
  132. package/transitions/StretchSlide.glsl +61 -0
  133. package/transitions/WedgeWipe.glsl +34 -0
  134. package/transitions/WhipSpin.glsl +68 -0
  135. package/transitions/WhipTilt.glsl +78 -0
  136. package/wgsl/Accordion.wgsl +376 -0
  137. package/wgsl/Ascii.wgsl +519 -0
  138. package/wgsl/BlockCover.wgsl +352 -0
  139. package/wgsl/BloomDissolve.wgsl +372 -0
  140. package/wgsl/BokehDissolve.wgsl +409 -0
  141. package/wgsl/BrushWipe.wgsl +443 -0
  142. package/wgsl/CameraShake.wgsl +348 -0
  143. package/wgsl/CardSwipe.wgsl +308 -0
  144. package/wgsl/CurvedWipe.wgsl +198 -0
  145. package/wgsl/CylinderRoll.wgsl +330 -0
  146. package/wgsl/Disintegrate.wgsl +426 -0
  147. package/wgsl/FilmDissolve.wgsl +169 -0
  148. package/wgsl/FilmStrip.wgsl +381 -0
  149. package/wgsl/FlameWipe.wgsl +531 -0
  150. package/wgsl/GooeyWipe.wgsl +353 -0
  151. package/wgsl/InkBleed.wgsl +366 -0
  152. package/wgsl/LensFlare.wgsl +406 -0
  153. package/wgsl/LightRays.wgsl +380 -0
  154. package/wgsl/LightStreaks.wgsl +460 -0
  155. package/wgsl/LightWipe.wgsl +277 -0
  156. package/wgsl/PhotoDevelop.wgsl +213 -0
  157. package/wgsl/PixelStretch.wgsl +298 -0
  158. package/wgsl/PlusWipe.wgsl +165 -0
  159. package/wgsl/PopIn.wgsl +213 -0
  160. package/wgsl/Refraction.wgsl +294 -0
  161. package/wgsl/SmokeDissolve.wgsl +363 -0
  162. package/wgsl/SplatterWipe.wgsl +613 -0
  163. package/wgsl/StretchSlide.wgsl +213 -0
  164. package/wgsl/WedgeWipe.wgsl +126 -0
  165. package/wgsl/WhipSpin.wgsl +241 -0
  166. package/wgsl/WhipTilt.wgsl +291 -0
@@ -0,0 +1,84 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image folds up like a pleated paper toward one side while the incoming one unfolds out of the other, both in 3D with lit and shadowed pleats
4
+ // Tags: fold, 3d, slide, stripes
5
+
6
+ // @range(1, 12, 1) Number of pleats in each image (a pleat is a pair of panels, one lit and one in the shade)
7
+ uniform int pleats; // = 4
8
+ // @param Direction in which the images move, snapped to its main axis (left, right, up or down): the outgoing image folds up toward it, the incoming one unfolds from the opposite side
9
+ uniform vec2 direction; // = vec2(-1.0, 0.0)
10
+ // @range(0, 1) Contrast between the lit and the shaded panels
11
+ uniform float shading; // = 0.7
12
+ // @range(0, 3) Amount of perspective: the valleys between the pleats recede
13
+ uniform float perspective; // = 1.5
14
+ // @color Color seen around the folded images, where the valleys recede
15
+ uniform vec4 backColor; // = vec4(0.0, 0.0, 0.0, 1.0)
16
+
17
+ // light from the front and the side: its sideways and front components
18
+ const float LIGHT_SIDE = 0.55;
19
+ const float LIGHT_FRONT = 0.835;
20
+ // width of the anti-aliased folds and edges, in frame heights
21
+ const float EDGE = 0.0015;
22
+
23
+ // brightness of a panel folded by angle (c, s) = (cos, sin), facing the light (sign 1) or away (-1)
24
+ float panelLight(float c, float s, float facing) {
25
+ float lambert = (c * LIGHT_FRONT + facing * s * LIGHT_SIDE) / LIGHT_FRONT;
26
+ return mix(1.0, clamp(lambert, 0.08, 1.25), shading);
27
+ }
28
+
29
+ // one folded image: f is the position along it (0 to 1, from its anchored side), c the visible part
30
+ // of its length (cos of the fold angle), len its length and b the position across it, in frame heights
31
+ vec4 pleated(float f, float c, float len, float b, float bLen, bool incoming, bool flipA, bool vertical) {
32
+ float m = 2.0 * float(pleats > 1 ? pleats : 1);
33
+ float s = sqrt(max(1.0 - c * c, 0.0));
34
+ float u = f * m;
35
+ // f = 1 is the end of the last panel, not the start of one more
36
+ float panel = min(floor(u), m - 1.0);
37
+ float fu = u - panel;
38
+ // the ridges (odd boundaries) stay in the frame's plane, the valleys (even ones) recede
39
+ float tri = 1.0 - abs(mod(u, 2.0) - 1.0);
40
+ float panelLen = len / m;
41
+ float z = panelLen * s * (1.0 - tri);
42
+ // farther parts look smaller
43
+ float scale = 1.0 / (1.0 + perspective * z);
44
+ float bb = (b - 0.5 * bLen) / scale / bLen + 0.5;
45
+ // soft top and bottom edges while folded (sharp when flat, to keep the first and last frames exact)
46
+ float edge = EDGE * min(1.0, 20.0 * s * c) + 1e-6;
47
+ float cover = clamp(min(bb, 1.0 - bb) * bLen * scale / edge, 0.0, 1.0);
48
+ float a = flipA ? 1.0 - f : f;
49
+ vec2 st = clamp(vertical ? vec2(bb, a) : vec2(a, bb), 0.0, 1.0);
50
+ vec4 img = incoming ? getToColor(st) : getFromColor(st);
51
+ // even panels face the light, odd ones turn away; blend across each fold over a pixel or so
52
+ float facing = mod(panel, 2.0) < 0.5 ? 1.0 : -1.0;
53
+ float toEdge = min(fu, 1.0 - fu) * panelLen * c;
54
+ float k = 0.5 + 0.5 * clamp(toEdge / EDGE, 0.0, 1.0);
55
+ float light = mix(panelLight(c, s, -facing), panelLight(c, s, facing), k);
56
+ // a touch of shade deep in the valleys
57
+ float valley = 1.0 - tri;
58
+ light *= 1.0 - 0.4 * shading * s * valley * valley;
59
+ return mix(backColor, vec4(img.rgb * light, img.a), cover);
60
+ }
61
+
62
+ vec4 transition(vec2 uv) {
63
+ bool vertical = abs(direction.y) > abs(direction.x);
64
+ bool positive = vertical ? direction.y > 0.0 : direction.x > 0.0;
65
+ // a: along the motion, 0 on the side the outgoing image folds up toward; b: across it
66
+ float a = vertical ? uv.y : uv.x;
67
+ if (positive) a = 1.0 - a;
68
+ float b = vertical ? uv.x : uv.y;
69
+ float len = vertical ? 1.0 : ratio;
70
+ float bLen = vertical ? ratio : 1.0;
71
+
72
+ float p = progress;
73
+ float e = p * p * (3.0 - 2.0 * p);
74
+ e = mix(p, e, 0.8);
75
+ // visible part of each image's length
76
+ float cFrom = 1.0 - e;
77
+ float cTo = e;
78
+ if (a < cFrom || cTo <= 0.0) {
79
+ // the outgoing image, anchored on its side
80
+ return pleated(a / cFrom, cFrom, len, b * bLen, bLen, false, positive, vertical);
81
+ }
82
+ // the incoming image, anchored on the opposite side
83
+ return pleated(1.0 - (1.0 - a) / cTo, cTo, len, b * bLen, bLen, true, positive, vertical);
84
+ }
@@ -0,0 +1,123 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The image turns into text-mode characters, denser where it is brighter, the characters scramble into those of the incoming image, then resolve back into it
4
+ // Tags: text, pattern, retro, digital
5
+
6
+ // @range(0.01, 0.1) Height of a character, in frame heights
7
+ uniform float cellSize; // = 0.04
8
+ // @param Color the characters with the image (otherwise, with the ink color)
9
+ uniform bool colored; // = true
10
+ // @color Color of the characters when they are not colored with the image
11
+ uniform vec4 ink; // = vec4(0.3, 1.0, 0.45, 1.0)
12
+ // @color Color behind the characters
13
+ uniform vec4 background; // = vec4(0.0, 0.0, 0.0, 1.0)
14
+
15
+ // width of a character cell, in cell heights
16
+ const float ASPECT = 0.6;
17
+ // half width of the strokes, in cell heights
18
+ const float STROKE = 0.05;
19
+
20
+ float hash12(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
+ // distance to the segment from a to b
27
+ float segment(vec2 q, vec2 a, vec2 b) {
28
+ vec2 pa = q - a;
29
+ vec2 ba = b - a;
30
+ return length(pa - ba * clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0));
31
+ }
32
+
33
+ // distance to the strokes of the character of this density, from 0 (" ") to 9 ("@"),
34
+ // at q, in cell heights from the cell's center
35
+ float glyph(float g, vec2 q) {
36
+ if (g < 0.5) return 1.0; // " "
37
+ if (g < 1.5) return length(q - vec2(0.0, -0.27)) - 0.035; // "."
38
+ if (g < 2.5) return min(length(q - vec2(0.0, -0.25)), length(q - vec2(0.0, 0.1))) - 0.035; // ":"
39
+ if (g < 3.5) return segment(q, vec2(-0.17, 0.0), vec2(0.17, 0.0)) - STROKE; // "-"
40
+ if (g < 4.5) { // "="
41
+ return min(segment(q, vec2(-0.18, 0.1), vec2(0.18, 0.1)), segment(q, vec2(-0.18, -0.1), vec2(0.18, -0.1))) - STROKE;
42
+ }
43
+ if (g < 5.5) { // "+"
44
+ return min(segment(q, vec2(-0.19, 0.0), vec2(0.19, 0.0)), segment(q, vec2(0.0, -0.19), vec2(0.0, 0.19))) - STROKE;
45
+ }
46
+ if (g < 6.5) { // "*"
47
+ float d = segment(q, vec2(0.0, -0.2), vec2(0.0, 0.2));
48
+ d = min(d, segment(q, vec2(-0.18, -0.11), vec2(0.18, 0.11)));
49
+ d = min(d, segment(q, vec2(-0.18, 0.11), vec2(0.18, -0.11)));
50
+ return d - STROKE;
51
+ }
52
+ if (g < 7.5) { // "#"
53
+ float d = min(segment(q, vec2(-0.06, -0.3), vec2(-0.1, 0.3)), segment(q, vec2(0.12, -0.3), vec2(0.08, 0.3)));
54
+ d = min(d, min(segment(q, vec2(-0.24, 0.11), vec2(0.24, 0.11)), segment(q, vec2(-0.24, -0.11), vec2(0.24, -0.11))));
55
+ return d - STROKE;
56
+ }
57
+ if (g < 8.5) { // "%"
58
+ float d = segment(q, vec2(-0.2, -0.3), vec2(0.2, 0.3));
59
+ d = min(d, abs(length(q - vec2(-0.13, 0.19)) - 0.08));
60
+ d = min(d, abs(length(q - vec2(0.13, -0.19)) - 0.08));
61
+ return d - STROKE;
62
+ }
63
+ // "@": a ring around a small "a"
64
+ float d = abs(length(q) - 0.25);
65
+ d = min(d, abs(length(q - vec2(-0.02, 0.0)) - 0.1));
66
+ d = min(d, segment(q, vec2(0.08, 0.1), vec2(0.08, -0.12)));
67
+ return d - 0.8 * STROKE;
68
+ }
69
+
70
+ // the brightness of a color, from 0 to 1, as a character density
71
+ float density(vec4 c) {
72
+ return floor(pow(clamp(dot(c.rgb, vec3(0.299, 0.587, 0.114)) * c.a, 0.0, 1.0), 0.75) * 9.99);
73
+ }
74
+
75
+ // the average color of a cell, from 4 samples
76
+ vec4 cellColor(vec2 center, vec2 dims, bool incoming) {
77
+ vec4 c = vec4(0.0);
78
+ for (int i = 0; i < 4; i++) {
79
+ vec2 o = (vec2(mod(float(i), 2.0), floor(float(i) / 2.0)) - 0.5) * 0.5 * dims;
80
+ vec2 st = clamp((center + o) / vec2(ratio, 1.0) + 0.5, 0.0, 1.0);
81
+ c += incoming ? getToColor(st) : getFromColor(st);
82
+ }
83
+ return c * 0.25;
84
+ }
85
+
86
+ vec4 transition(vec2 uv) {
87
+ float p = progress;
88
+ float h = cellSize;
89
+ vec2 fp = (uv - 0.5) * vec2(ratio, 1.0);
90
+ vec2 dims = vec2(ASPECT * h, h);
91
+ vec2 cell = floor(fp / dims);
92
+ vec2 center = (cell + 0.5) * dims;
93
+ vec2 q = (fp - center) / h;
94
+
95
+ // each cell switches to the incoming image at its own time, scrambling through
96
+ // random characters around it
97
+ float r = hash12(cell + 100.0);
98
+ float at = 0.4 + 0.2 * r;
99
+ bool incoming = p > at;
100
+ vec4 c = cellColor(center, dims, incoming);
101
+ float g = density(c);
102
+ float scramble = 1.0 - smoothstep(0.02, 0.045, abs(p - at));
103
+ if (hash12(cell + floor(p * 40.0) * vec2(17.0, 31.0)) < scramble) {
104
+ g = 1.0 + floor(9.0 * hash12(cell * 1.7 + floor(p * 40.0) * vec2(5.0, 11.0)));
105
+ }
106
+
107
+ float cover = 1.0 - smoothstep(-0.02, 0.02, glyph(g, q));
108
+ vec3 tint = colored ? mix(c.rgb, c.rgb / max(max(c.r, max(c.g, c.b)), 0.05), 0.7) : ink.rgb;
109
+ float alpha = colored ? c.a : ink.a * c.a;
110
+ // where the image is transparent, so are the characters and their background
111
+ // colored characters glow faintly over their cell, so the picture stays readable
112
+ vec3 behind = colored ? mix(background.rgb, c.rgb, 0.3) : background.rgb;
113
+ vec4 back = vec4(behind, background.a * c.a);
114
+ vec4 text = mix(back, vec4(clamp(tint, 0.0, 1.0), alpha), cover);
115
+
116
+ // each cell dissolves into its character at its own time, from 0.05 to 0.35,
117
+ // and back into the incoming image from 0.65 to 0.95
118
+ float into = 0.05 + 0.22 * hash12(cell + 200.0);
119
+ float outof = 0.95 - 0.22 * hash12(cell + 300.0);
120
+ float show = smoothstep(into, into + 0.08, p) * (1.0 - smoothstep(outof - 0.08, outof, p));
121
+ vec4 image = p < 0.5 ? getFromColor(uv) : getToColor(uv);
122
+ return mix(image, text, show);
123
+ }
@@ -0,0 +1,86 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: Blocks of a solid color pop in at random over the outgoing image until they cover the frame, then pop out in another random order to show the incoming image
4
+ // Tags: blocks, grid, squares, color, cover
5
+
6
+ // @range(1, 40, 1) Number of blocks along the longer side of the frame (the blocks stay about square)
7
+ uniform int blocks; // = 16
8
+ // @color Color of the blocks
9
+ uniform vec4 color; // = vec4(0.95, 0.32, 0.26, 1.0)
10
+ // @range(0, 1) How much a block overshoots its cell as it pops in
11
+ uniform float pop; // = 0.5
12
+ // @range(0, 0.5) Softness of the blocks' edges, in blocks
13
+ uniform float smoothness; // = 0.03
14
+
15
+ const float duration = 0.14; // of one block's pop, in progress
16
+ const float cut = 0.45; // the frame is fully covered from cut - hold to cut + hold
17
+ const float hold = 0.02;
18
+
19
+ float hash (vec2 p) {
20
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
21
+ p3 += dot(p3, p3.yzx + 33.33);
22
+ return fract((p3.x + p3.y) * p3.z);
23
+ }
24
+
25
+ // eases from 0 to 1, a little past 1 (more with a larger c) and back
26
+ float backOut (float t, float c) {
27
+ float u = t - 1.0;
28
+ return 1.0 + (c + 1.0) * u * u * u + c * u * u;
29
+ }
30
+
31
+ // when a cell's block starts to pop in (.x) and to pop out (.y)
32
+ vec2 timing (vec2 cell) {
33
+ return vec2(
34
+ (cut - hold - duration) * hash(cell + 0.5),
35
+ cut + hold + (1.0 - cut - hold - duration) * hash(cell + 71.7));
36
+ }
37
+
38
+ // scale of the block of a cell: 0 when it is not there, 1 when it fills its cell
39
+ float blockScale (vec2 cell, float c) {
40
+ vec2 t = timing(cell);
41
+ float a = clamp((progress - t.x) / duration, 0.0, 1.0);
42
+ float b = clamp((progress - t.y) / duration, 0.0, 1.0);
43
+ // it grows from nothing with an overshoot, and shrinks back to nothing
44
+ return b > 0.0 ? (1.0 - b) * (1.0 - b) : backOut(a, c);
45
+ }
46
+
47
+ // how much of the point q (in cells) the block of a cell covers
48
+ float coverage (vec2 q, vec2 cell, float s, float sm) {
49
+ // at scale 1, its solid part fills the whole cell, so that a covered frame shows no seams
50
+ float h = s * (0.5 + sm);
51
+ vec2 d = abs(q - cell - 0.5);
52
+ return s > 0.0 ? 1.0 - smoothstep(h - sm, h, max(d.x, d.y)) : 0.0;
53
+ }
54
+
55
+ vec4 transition (vec2 uv) {
56
+ float nLong = max(float(blocks), 1.0);
57
+ vec2 n = ratio >= 1.0
58
+ ? vec2(nLong, max(1.0, floor(nLong / ratio + 0.5)))
59
+ : vec2(max(1.0, floor(nLong * ratio + 0.5)), nLong);
60
+ vec2 q = uv * n;
61
+ vec2 cell = floor(q);
62
+ float sm = max(smoothness, 0.001);
63
+ float c = 2.0 * clamp(pop, 0.0, 1.0);
64
+ float s = blockScale(cell, c);
65
+ if (s >= 1.0) return color;
66
+ float cover = coverage(q, cell, s, sm);
67
+ // a neighbour's block can overshoot onto this cell, near its border only
68
+ float u = -2.0 * c / (3.0 * (c + 1.0));
69
+ float reach = backOut(1.0 + u, c) * (0.5 + sm);
70
+ vec2 o = abs(q - cell - 0.5);
71
+ if (max(o.x, o.y) > 1.0 - reach) {
72
+ for (int j = -1; j <= 1; j++) {
73
+ for (int i = -1; i <= 1; i++) {
74
+ vec2 nb = cell + vec2(float(i), float(j));
75
+ vec2 inside = step(vec2(0.0), nb) * step(nb, n - 1.0);
76
+ if (inside.x * inside.y > 0.0 && (i != 0 || j != 0)) {
77
+ cover = max(cover, coverage(q, nb, blockScale(nb, c), sm));
78
+ }
79
+ }
80
+ }
81
+ }
82
+ // each cell switches to the incoming image while its own block covers it
83
+ vec2 t = timing(cell);
84
+ vec4 under = progress < 0.5 * (t.x + duration + t.y) ? getFromColor(uv) : getToColor(uv);
85
+ return mix(under, color, cover);
86
+ }
@@ -0,0 +1,109 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The highlights of the outgoing image blow out into a soft, wide glow that floods the frame; under it the incoming image takes over, then the glow subsides back into its highlights while the image stays sharp
4
+ // Tags: light, glow, bloom, dissolve
5
+
6
+ // @range(0, 0.6) Reach of the glow at the peak, in frame heights
7
+ uniform float spread; // = 0.25
8
+ // @range(0, 1) Brightness above which the image glows (the whole frame does at the peak)
9
+ uniform float threshold; // = 0.6
10
+ // @range(0, 4) Brightness of the glow
11
+ uniform float intensity; // = 1.5
12
+ // @color Tint of the glow, toward its edges
13
+ uniform vec3 tint; // = vec3(1.0, 0.9, 0.75)
14
+
15
+ // pairs of opposite taps: 20 reads per pixel
16
+ const int PAIRS = 10;
17
+ const float GOLDEN_ANGLE = 2.399963;
18
+
19
+ float hash12(vec2 v) {
20
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
21
+ v3 += dot(v3, v3.yzx + 33.33);
22
+ return fract((v3.x + v3.y) * v3.z);
23
+ }
24
+
25
+ // mirror the coordinates back into the frame
26
+ vec2 mirror(vec2 v) {
27
+ return 1.0 - abs(1.0 - mod(v, 2.0));
28
+ }
29
+
30
+ // the image on screen at a point, premultiplied: one image, or both during the short switch
31
+ vec4 image(vec2 st, float m) {
32
+ if (m <= 0.0) {
33
+ vec4 c = getFromColor(st);
34
+ return vec4(c.rgb * c.a, c.a);
35
+ }
36
+ if (m >= 1.0) {
37
+ vec4 c = getToColor(st);
38
+ return vec4(c.rgb * c.a, c.a);
39
+ }
40
+ vec4 a = getFromColor(st);
41
+ vec4 b = getToColor(st);
42
+ return mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
43
+ }
44
+
45
+ // the light of a pixel (premultiplied): its color above the knee, full well before white
46
+ vec3 glow(vec4 c, float knee) {
47
+ float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
48
+ return c.rgb * smoothstep(knee, knee + max(0.3 * (1.0 - knee), 1e-3), lum);
49
+ }
50
+
51
+ vec4 transition(vec2 uv) {
52
+ float p = progress;
53
+ // the glow blooms on the outgoing image, and subsides on the incoming one
54
+ float amount = 4.0 * p * (1.0 - p);
55
+ float peak = amount * amount;
56
+ // around the middle, the whole frame catches the light and floods with glow
57
+ float flood = peak * peak * peak;
58
+ // the switch, under the glow at its brightest
59
+ float m = smoothstep(0.44, 0.56, p);
60
+ if (amount <= 0.0) return m < 0.5 ? getFromColor(uv) : getToColor(uv);
61
+
62
+ // the image stays sharp underneath (premultiplied colors, only the images on screen are read)
63
+ vec4 c = image(uv, m);
64
+ if (c.a <= 0.0) return vec4(0.0);
65
+ c.rgb /= c.a;
66
+
67
+ // more and more of the image catches the light as the glow grows
68
+ float knee = threshold * (1.0 - 0.3 * peak) * (1.0 - flood);
69
+ float radius = spread * amount;
70
+ // a rotation and a radial shift of the spiral for each pixel blend the taps into a smooth glow;
71
+ // hashed by integer cell so that every GPU computes the same values
72
+ vec2 cell = floor(uv * vec2(ratio, 1.0) * 997.0);
73
+ float spin = 6.2831853 * hash12(cell);
74
+ float shift = hash12(cell + 71.0);
75
+
76
+ // a golden-angle spiral, denser toward the center so the glow is bright at its core with a wide soft tail;
77
+ // each tap is read with its opposite, which cancels most of the noise across smooth gradients
78
+ vec3 bloom = vec3(0.0);
79
+ vec4 soft = vec4(0.0);
80
+ float total = 0.0;
81
+ for (int i = 0; i < PAIRS; i++) {
82
+ float s = (float(i) + shift) / float(PAIRS);
83
+ float r = s * s;
84
+ float a = float(i) * GOLDEN_ANGLE + spin;
85
+ vec2 offset = radius * r * vec2(cos(a) / ratio, sin(a));
86
+ vec4 i0 = image(mirror(uv + offset), m);
87
+ vec4 i1 = image(mirror(uv - offset), m);
88
+ vec3 l = glow(i0, knee) + glow(i1, knee);
89
+ // the sparse outer taps weigh less, so the tail of the glow stays smooth
90
+ float w = 1.0 - 0.75 * s;
91
+ // white at the core, tinted toward the edges
92
+ bloom += w * mix(vec3(1.0), tint, smoothstep(0.0, 0.5, r)) * l;
93
+ total += w;
94
+ // a closer blur of the image, to soften it
95
+ float sw = (1.0 - s) * (1.0 - s);
96
+ soft += sw * (i0 + i1);
97
+ }
98
+ bloom /= 2.0 * total;
99
+ // at the peak the light softens the image itself, which hides the switch
100
+ vec3 blurred = soft.a > 0.0 ? soft.rgb / soft.a : c.rgb;
101
+ vec3 base = mix(c.rgb, blurred, 0.7 * flood);
102
+ bloom *= intensity * peak * (1.0 + 2.0 * flood);
103
+ // compressed, so that the glow floods the frame without flattening into white
104
+ bloom = 0.92 * (1.0 - exp(-bloom));
105
+
106
+ // the glow is a light screened over the image: it adds nothing to its alpha
107
+ base = min(base * (1.0 + 0.25 * peak), 1.0);
108
+ return vec4(base + bloom - base * bloom, c.a);
109
+ }
@@ -0,0 +1,122 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The image falls out of focus like a camera lens, its highlights swelling into large bright bokeh discs, and the incoming image sharpens back out of its own bokeh
4
+ // Tags: blur, bokeh, lens, dissolve, light
5
+
6
+ // @range(0.01, 0.15) Radius of the bokeh discs at the peak, in frame heights
7
+ uniform float radius; // = 0.05
8
+ // @range(0, 9) Number of aperture blades, which shape the discs into polygons (below 3: round)
9
+ uniform int blades; // = 0
10
+ // @range(0, 1) Brightness above which a pixel is a highlight that swells into a disc
11
+ uniform float threshold; // = 0.7
12
+ // @range(0, 3) Brightness of the bokeh discs
13
+ uniform float intensity; // = 1.0
14
+
15
+ #define PI 3.141592653589793
16
+ const int TAPS = 16;
17
+
18
+ // mirror the coordinates back into the frame
19
+ vec2 mirror(vec2 v) {
20
+ return 1.0 - abs(1.0 - mod(v, 2.0));
21
+ }
22
+
23
+ // a hash of an integer cell, stable across precisions
24
+ float hash12(vec2 p) {
25
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
26
+ p3 += dot(p3, p3.yzx + 33.33);
27
+ return fract((p3.x + p3.y) * p3.z);
28
+ }
29
+
30
+ // how much a pixel is a highlight: none below the threshold, full at white
31
+ float highlight(vec4 c, float t) {
32
+ float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
33
+ // nothing is brighter than white, so a threshold of 1 makes no highlights
34
+ if (t >= 1.0) return 0.0;
35
+ float h = smoothstep(t, 1.0, lum);
36
+ return h * h * c.a;
37
+ }
38
+
39
+ vec4 transition(vec2 uv) {
40
+ // the lens defocuses then focuses back: 0 at both ends, 1 at the peak
41
+ float t = 1.0 - abs(2.0 * progress - 1.0);
42
+ float k = t * t * (3.0 - 2.0 * t);
43
+ // the incoming image takes over while everything is out of focus
44
+ float w = smoothstep(0.35, 0.65, progress);
45
+ float r = radius * k;
46
+ // the highlights weigh more as they swell, so they read as bright discs
47
+ float boost = 12.0 * intensity * k;
48
+
49
+ // fewer than 3 blades: a round aperture
50
+ float n = blades >= 3 ? float(blades) : 0.0;
51
+ float sector = n > 0.0 ? 2.0 * PI / n : 1.0;
52
+ float apothem = cos(0.5 * sector);
53
+
54
+ // per-pixel stratification of the taps over the disc, so its edge stays crisp
55
+ vec2 cell = floor(uv * vec2(ratio, 1.0) * 997.0);
56
+ float spin = 2.0 * PI * hash12(cell);
57
+ float jitter = hash12(cell + 17.0);
58
+
59
+ // each image is only read while it shows
60
+ bool useFrom = w < 1.0;
61
+ bool useTo = w > 0.0;
62
+ // premultiplied, weighted sums of each image, and the light of their highlights,
63
+ // starting with the pixel itself
64
+ vec4 s0 = vec4(0.0);
65
+ vec4 s1 = vec4(0.0);
66
+ float t0 = 0.0;
67
+ float t1 = 0.0;
68
+ vec3 l0 = vec3(0.0);
69
+ vec3 l1 = vec3(0.0);
70
+ if (useFrom) {
71
+ vec4 c = getFromColor(uv);
72
+ float h = highlight(c, threshold);
73
+ float wt = 1.0 + boost * h;
74
+ s0 = wt * vec4(c.rgb * c.a, c.a);
75
+ t0 = wt;
76
+ l0 = h * c.rgb;
77
+ }
78
+ if (useTo) {
79
+ vec4 c = getToColor(uv);
80
+ float h = highlight(c, threshold);
81
+ float wt = 1.0 + boost * h;
82
+ s1 = wt * vec4(c.rgb * c.a, c.a);
83
+ t1 = wt;
84
+ l1 = h * c.rgb;
85
+ }
86
+ for (int i = 0; i < TAPS; i++) {
87
+ float fi = float(i);
88
+ float a = fi * 2.39996323 + spin;
89
+ float d = sqrt((fi + jitter) / float(TAPS));
90
+ if (n > 0.0) {
91
+ // the aperture's polygon: its boundary in the direction of the tap
92
+ float s = mod(a, sector) - 0.5 * sector;
93
+ d *= apothem / cos(s);
94
+ }
95
+ vec2 st = mirror(uv + r * d * vec2(cos(a) / ratio, sin(a)));
96
+ if (useFrom) {
97
+ vec4 c = getFromColor(st);
98
+ float h = highlight(c, threshold);
99
+ float wt = 1.0 + boost * h;
100
+ s0 += wt * vec4(c.rgb * c.a, c.a);
101
+ t0 += wt;
102
+ l0 += h * c.rgb;
103
+ }
104
+ if (useTo) {
105
+ vec4 c = getToColor(st);
106
+ float h = highlight(c, threshold);
107
+ float wt = 1.0 + boost * h;
108
+ s1 += wt * vec4(c.rgb * c.a, c.a);
109
+ t1 += wt;
110
+ l1 += h * c.rgb;
111
+ }
112
+ }
113
+ vec4 b = mix(useFrom ? s0 / t0 : vec4(0.0), useTo ? s1 / t1 : vec4(0.0), w);
114
+ if (b.a <= 0.0) {
115
+ return vec4(0.0);
116
+ }
117
+ vec3 rgb = b.rgb / b.a;
118
+ // the discs glow: light lifts the color, never the alpha
119
+ vec3 light = mix(l0, l1, w) * (intensity * k * 4.0 / float(TAPS + 1));
120
+ rgb = 1.0 - (1.0 - clamp(rgb, 0.0, 1.0)) * exp(-light);
121
+ return vec4(rgb, b.a);
122
+ }
@@ -0,0 +1,99 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: A few broad brush strokes sweep across the frame in turn, back and forth, painting in the incoming image with streaky bristle edges and dry, ragged ends
4
+ // Tags: wipe, paint, brush, organic
5
+
6
+ // @range(1, 8, 1) Number of brush strokes needed to cover the frame
7
+ uniform float strokes; // = 4.0
8
+ // @range(-45, 45) Angle of the strokes, in degrees
9
+ uniform float angle; // = -7.0
10
+ // @range(0, 1) How rough the bristles make the edges and ends of the strokes
11
+ uniform float roughness; // = 0.6
12
+ // @range(0, 1) How much the strokes wave along their way
13
+ uniform float waviness; // = 0.5
14
+
15
+ const float PI = 3.141592653589793;
16
+
17
+ float hash (vec2 p) {
18
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
19
+ p3 += dot(p3, p3.yzx + 33.33);
20
+ return fract((p3.x + p3.y) * p3.z);
21
+ }
22
+
23
+ // value noise, smooth along both axes
24
+ float vnoise (vec2 p) {
25
+ vec2 i = floor(p);
26
+ vec2 f = fract(p);
27
+ f = f * f * (3.0 - 2.0 * f);
28
+ return mix(
29
+ mix(hash(i), hash(i + vec2(1.0, 0.0)), f.x),
30
+ mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), f.x),
31
+ f.y
32
+ );
33
+ }
34
+
35
+ // bristle streaks: fine across the stroke (t), long along it (u)
36
+ float bristles (float t, float u, float seed) {
37
+ return 0.6 * vnoise(vec2(t * 26.0 + seed, u * 1.3 + seed)) + 0.4 * vnoise(vec2(t * 8.0 - seed, u * 0.7));
38
+ }
39
+
40
+ // one stroke: k its index, t the position across it (-1..1 is its core), u along it
41
+ // returns (coverage, wet streak shading)
42
+ vec2 stroke (float k, float t, float u, float U, float n, float h) {
43
+ float dir = mod(k, 2.0) < 0.5 ? 1.0 : -1.0;
44
+ float x = u * dir;
45
+ float dur = min(1.0, 1.8 / (n + 0.8));
46
+ float start = n > 1.0 ? k * (1.0 - dur) / (n - 1.0) : 0.0;
47
+ float s = clamp((progress - start) / dur, 0.0, 1.0);
48
+ s = mix(s, s * s * (3.0 - 2.0 * s), 0.7);
49
+ float r = roughness;
50
+ float lag = (0.15 + 0.6 * r) * h; // how far the longest bristles run ahead of the shortest
51
+ float dry = (0.1 + 0.9 * r) * h; // length of the streaky, dry trail behind the head of the stroke
52
+ // at the end even the shortest bristles, at the rounded corners, are past the far edge with their dry trail
53
+ float head = mix(-U, U + lag + 0.3 * h + 1.15 * dry + 0.01, s);
54
+ float b = bristles(t, k * 3.7, k * 17.0);
55
+ float front = head - lag * (1.0 - b) - 0.3 * h * t * t; // a rounded, ragged head
56
+ float streak = bristles(t * 1.7, x * 2.0 / h, k * 5.0 + 9.0);
57
+ float along = clamp(((front - x) / (dry + 0.001) - 0.1 - 0.8 * streak) * 6.0, 0.0, 1.0);
58
+ float fringe = 0.1 + 0.7 * r;
59
+ float e = (abs(t) - 1.0) / fringe; // < 0 in the core of the stroke
60
+ float reach = 0.5 + 0.5 * vnoise(vec2(x * 2.5 / h, k * 7.0 + (t > 0.0 ? 3.0 : 0.0))); // the edge wanders
61
+ float hair = clamp(bristles(t * 1.4, x * 3.0 / h, k * 11.0 + 3.0) * 2.0 - 0.5, 0.0, 1.0);
62
+ float side = clamp((reach * hair - e) * 12.0 + 1.0, 0.0, 1.0);
63
+ float cover = along * side;
64
+ float wet = (1.0 - clamp((progress - start - dur) / 0.25, 0.0, 1.0)) * min(1.0, (1.0 - progress) * 6.0);
65
+ return vec2(cover, cover * wet * (bristles(t * 2.0, x * 2.0 / h, k) - 0.5));
66
+ }
67
+
68
+ vec4 transition (vec2 uv) {
69
+ float a = angle * PI / 180.0;
70
+ float c = cos(a);
71
+ float sn = sin(a);
72
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
73
+ float u = c * q.x + sn * q.y; // along the strokes
74
+ float v = -sn * q.x + c * q.y; // across them
75
+ float U = 0.5 * (abs(c) * ratio + abs(sn));
76
+ float V = 0.5 * (abs(sn) * ratio + abs(c));
77
+ float n = max(1.0, floor(strokes + 0.5));
78
+ float h = 2.0 * V / n; // height of a stroke
79
+ // waves shared by the neighbouring strokes so that they always tile the frame
80
+ float A = 0.12 * waviness * h;
81
+ float w = v + A * sin(u * 5.0 / U + v * 2.0 / h + 1.3) + 0.5 * A * sin(u * 11.0 / U - v * 3.0 / h);
82
+ float y = (V + 1.5 * A - w) / (2.0 * V + 3.0 * A) * n; // strokes go from top to bottom
83
+ float hh = (2.0 * V + 3.0 * A) / n;
84
+ float k = clamp(floor(y), 0.0, n - 1.0);
85
+ float cover = 0.0;
86
+ float shade = 0.0;
87
+ for (int i = -1; i <= 1; i++) {
88
+ float j = k + float(i);
89
+ if (j >= 0.0 && j <= n - 1.0) {
90
+ vec2 s = stroke(j, (y - j - 0.5) * 2.0, u, U, n, hh);
91
+ cover = max(cover, s.x);
92
+ shade = mix(shade, s.y, s.x); // the latest stroke is on top
93
+ }
94
+ }
95
+ vec4 from = getFromColor(uv);
96
+ vec4 to = getToColor(uv);
97
+ to.rgb = min(to.rgb * (1.0 + 0.2 * shade), 1.0);
98
+ return mix(from, to, cover);
99
+ }