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,97 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The camera jolts violently in random directions, with motion blur and color fringes along each jolt; the cut happens at the peak of the shake, which then settles on the incoming image
4
+ // Tags: shake, camera, motion-blur, chromatic, impact
5
+
6
+ // @range(0, 1) How far the camera jolts (and rolls) at the peak of the shake
7
+ uniform float strength; // = 0.5
8
+ // @range(4, 32) Number of jolts over the transition
9
+ uniform float jolts; // = 12.0
10
+ // @range(0, 1) Length of the motion blur along each jolt
11
+ uniform float blur; // = 0.5
12
+ // @range(0, 1) How far the color channels split apart along each jolt
13
+ uniform float split; // = 0.5
14
+
15
+ const int TAPS = 10;
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
+ vec2 mirror(vec2 v) {
24
+ return 1.0 - abs(1.0 - mod(v, 2.0));
25
+ }
26
+
27
+ // the camera position at jolt key k: offset (x, y) and roll, each in -1..1
28
+ vec3 jolt(float k) {
29
+ // successive jolts go in nearly opposite directions
30
+ float a = 2.4 * k + 1.2 * hash12(vec2(k, 11.0));
31
+ float m = 0.55 + 0.45 * hash12(vec2(k, 23.0));
32
+ return vec3(m * cos(a), m * sin(a), 2.0 * hash12(vec2(k, 37.0)) - 1.0);
33
+ }
34
+
35
+ // how strong the shake is at time t: it builds up quickly, peaks around the cut, then settles
36
+ float envelope(float t) {
37
+ float h = clamp(1.6 * (1.0 - abs(2.0 * t - 1.0)), 0.0, 1.0);
38
+ return h * h * (3.0 - 2.0 * h);
39
+ }
40
+
41
+ // the image seen by the camera at time t (in progress units), premultiplied
42
+ vec4 shot(vec2 uv, float t, bool incoming) {
43
+ float env = envelope(t);
44
+ // a key every 1/jolts, one of them exactly at the cut
45
+ float s = (t - 0.5) * jolts;
46
+ float k = floor(s);
47
+ float g = 1.0 - (s - k);
48
+ float e = 1.0 - g * g * g; // snaps to the next key, then holds
49
+ vec3 j = mix(jolt(k), jolt(k + 1.0), e) * env;
50
+ float omax = 0.14 * strength * env;
51
+ float rmax = 0.07 * strength * env;
52
+ vec2 off = j.xy * omax;
53
+ float roll = j.z * rmax;
54
+ // zoom in just enough that the frame edges never show, for any offset and roll up to these
55
+ float zoom = (cos(rmax) + sin(rmax) * max(ratio, 1.0 / ratio)) / (1.0 - 2.0 * omax);
56
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
57
+ q = mat2(cos(roll), sin(roll), -sin(roll), cos(roll)) * q / zoom;
58
+ vec2 p = mirror(q / vec2(ratio, 1.0) + 0.5 + off);
59
+ vec4 c = incoming ? getToColor(p) : getFromColor(p);
60
+ return vec4(c.rgb * c.a, c.a);
61
+ }
62
+
63
+ vec4 transition(vec2 uv) {
64
+ // the exposure follows the shake: no blur at the very ends
65
+ float open = envelope(progress);
66
+ float shutter = 0.8 * blur / jolts * open;
67
+ float lag = 0.2 * split / jolts * open;
68
+ // each channel, premultiplied, and its alpha
69
+ vec2 sumR = vec2(0.0);
70
+ vec2 sumG = vec2(0.0);
71
+ vec2 sumB = vec2(0.0);
72
+ float wsum = 0.0;
73
+ for (int i = 0; i < TAPS; i++) {
74
+ float u = (float(i) + 0.5) / float(TAPS) - 0.5;
75
+ float t = progress + u * shutter;
76
+ // the trails fade out at both ends of the exposure
77
+ float w = 1.0 - 1.4 * abs(u);
78
+ // the cut happens during the exposure: the channels of a tap show the same image
79
+ bool incoming = t >= 0.5;
80
+ // red leads and blue trails the motion, so they split by the speed of the jolt
81
+ vec4 r = shot(uv, t + lag, incoming);
82
+ vec4 c = shot(uv, t, incoming);
83
+ vec4 b = shot(uv, t - lag, incoming);
84
+ sumR += w * r.ra;
85
+ sumG += w * c.ga;
86
+ sumB += w * b.ba;
87
+ wsum += w;
88
+ }
89
+ float alpha = (sumR.y + sumG.y + sumB.y) / (3.0 * wsum);
90
+ if (alpha <= 0.0) return vec4(0.0);
91
+ vec3 color = vec3(
92
+ sumR.x / max(sumR.y, 1e-5),
93
+ sumG.x / max(sumG.y, 1e-5),
94
+ sumB.x / max(sumB.y, 1e-5)
95
+ );
96
+ return vec4(color, alpha);
97
+ }
@@ -0,0 +1,80 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image is flicked off like the top card of a stack, swinging around a point below it as it flies out, while the incoming card behind it grows to fill the frame
4
+ // Tags: card, swipe, stack, rotate, slide, directional
5
+
6
+ // @param Direction in which the outgoing card is flicked
7
+ uniform vec2 direction; // = vec2(1.0, 0.25)
8
+ // @range(0, 1) How much the outgoing card swings as it flies out
9
+ uniform float rotation; // = 0.5
10
+ // @range(0, 0.5) How much smaller the incoming card starts
11
+ uniform float depth; // = 0.15
12
+ // @color Color seen around the incoming card while it is smaller than the frame
13
+ uniform vec4 backColor; // = vec4(0.06, 0.06, 0.07, 1.0)
14
+
15
+ const float RADIUS = 0.045; // corner radius of the cards, in frame heights
16
+ const float AA = 0.002; // width of the antialiased card edges
17
+
18
+ // signed distance to a rounded box of half size b and corner radius r
19
+ float roundedBox(vec2 q, vec2 b, float r) {
20
+ vec2 d = abs(q) - b + r;
21
+ return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r;
22
+ }
23
+
24
+ vec4 premultiply(vec4 c) {
25
+ return vec4(c.rgb * c.a, c.a);
26
+ }
27
+
28
+ vec4 transition(vec2 uv) {
29
+ float dl = length(direction);
30
+ vec2 d = dl > 1e-6 ? direction / dl : vec2(0.970143, 0.242536);
31
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
32
+ vec2 b = vec2(0.5 * ratio, 0.5);
33
+ float p = progress;
34
+
35
+ // the incoming card, behind: grows from a smaller card to the full frame,
36
+ // and its corners straighten as it fills it
37
+ float h = clamp((p - 0.2) / 0.8, 0.0, 1.0);
38
+ float g = h * h * (3.0 - 2.0 * h);
39
+ float k = 1.0 - g;
40
+ float sc = 1.0 - depth * k;
41
+ float rb = RADIUS * min(1.0, 12.0 * k);
42
+ float db = roundedBox(q, b * sc, rb);
43
+ float cb = clamp(0.5 - db / max(AA * min(1.0, 40.0 * k), 1e-6), 0.0, 1.0);
44
+ vec4 tc = getToColor(clamp(0.5 + (uv - 0.5) / sc, 0.0, 1.0));
45
+ // still in the shade of the top card at first
46
+ tc.rgb *= 1.0 - 0.35 * k * k;
47
+ // the cards are opaque: each one replaces what is behind it, keeping its image's alpha
48
+ vec4 col = mix(premultiply(backColor), premultiply(tc), cb);
49
+
50
+ // the outgoing card, on top: swings around a point below it as it is flicked away
51
+ float t = clamp(p / 0.75, 0.0, 1.0);
52
+ float lift = smoothstep(0.0, 0.15, p);
53
+ float u = min(t / 0.7, 1.0);
54
+ float swing = u * u * (3.0 - 2.0 * u);
55
+ // it tilts toward the side it is flicked to
56
+ float a = (d.x < 0.0 ? 1.3 : -1.3) * rotation * swing;
57
+ vec2 pivot = vec2(0.0, -1.1);
58
+ // where the swing alone takes the center of the card, to throw it far enough
59
+ float ca = cos(a), sa = sin(a);
60
+ vec2 swung = pivot + mat2(ca, sa, -sa, ca) * -pivot;
61
+ float far = 2.0 * length(b) + length(swung) + 0.3;
62
+ vec2 shift = d * far * t * t * (0.4 + 0.6 * t);
63
+ mat2 unrotate = mat2(ca, -sa, sa, ca);
64
+ vec2 r = unrotate * (q - shift - pivot) + pivot;
65
+ float rf = RADIUS * lift;
66
+
67
+ // its soft shadow on the card behind, cast down and away as it lifts
68
+ float sh = 0.6 * lift * (1.0 - t);
69
+ if (sh > 0.0) {
70
+ vec2 rs = unrotate * (q - (0.03 * d + vec2(0.0, -0.03)) * lift - shift - pivot) + pivot;
71
+ float ds = roundedBox(rs, b, rf);
72
+ col.rgb *= 1.0 - sh * (1.0 - smoothstep(-0.05, 0.08, ds));
73
+ }
74
+
75
+ float df = roundedBox(r, b, rf);
76
+ float cf = clamp(0.5 - df / max(AA * min(1.0, 40.0 * lift), 1e-6), 0.0, 1.0);
77
+ vec4 fc = getFromColor(clamp(r / vec2(ratio, 1.0) + 0.5, 0.0, 1.0));
78
+ col = mix(col, premultiply(fc), cf);
79
+ return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
80
+ }
@@ -0,0 +1,51 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image is pulled away by its middle: the wipe edge bulges into a smooth curve that leads the way, then flattens as it reaches the far side
4
+ // Tags: wipe, curve, directional, shadow
5
+
6
+ // @param Direction the edge moves toward
7
+ uniform vec2 direction; // = vec2(0.0, 1.0)
8
+ // @range(0, 1) How far the middle of the edge leads its sides
9
+ uniform float curvature; // = 0.6
10
+ // @range(0, 0.2) Softness of the edge
11
+ uniform float smoothness; // = 0.02
12
+ // @color Color of the soft shadow the lifted edge casts on the incoming image (its alpha is its strength; 0 for none)
13
+ uniform vec4 shadow; // = vec4(0.0, 0.0, 0.0, 0.4)
14
+
15
+ const float PI = 3.141592653589793;
16
+
17
+ // a gentle ease in and out, which does not linger at the ends
18
+ float ease (float t) {
19
+ return 0.5 * (t + t * t * (3.0 - 2.0 * t));
20
+ }
21
+
22
+ vec4 transition (vec2 uv) {
23
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(0.0, 1.0);
24
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
25
+ // half extents of the frame along the direction and across it
26
+ float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
27
+ float w = 0.5 * (abs(dir.y) * ratio + abs(dir.x));
28
+ vec2 across = vec2(-dir.y, dir.x);
29
+ float d = dot(p, dir);
30
+ // where the pixel is across the frame, from -1 to 1 (on a diagonal, these are the corners); it is the same
31
+ // all along the direction, so the edge is a single curve, centered on the middle of the frame
32
+ float x = clamp(dot(p, across) / w, -1.0, 1.0);
33
+ float s = max(smoothness, 0.001);
34
+ // each point of the edge runs on its own clock: the middle runs ahead and slows down at the far side,
35
+ // where the sides catch up with it; the lead keeps the curve's shape alike on wide and narrow frames
36
+ float k = clamp(curvature, 0.0, 1.0) * min(1.0, w / e) * (1.0 - x * x);
37
+ float t = progress + k * progress * (1.0 - progress);
38
+ float travel = 2.0 * (e + s);
39
+ float edge = -e - s + travel * ease(t);
40
+ float side = -e - s + travel * ease(progress);
41
+ float m = 1.0 - smoothstep(-s, s, d - edge);
42
+ // the more the edge is lifted, the wider and softer the shadow it casts on the incoming image
43
+ float lift = edge - side;
44
+ float spread = 0.012 + 0.25 * lift;
45
+ // it falls behind the edge only, on the incoming image, cast by the outgoing image at the edge
46
+ vec4 to = getToColor(uv);
47
+ vec2 caster = clamp((p + (edge - d) * dir) / vec2(ratio, 1.0) + 0.5, 0.0, 1.0);
48
+ float sh = shadow.a * sin(PI * progress) * exp(-max(edge - d, 0.0) / spread) * m * getFromColor(caster).a * to.a;
49
+ to.rgb = mix(to.rgb, shadow.rgb, sh);
50
+ return mix(getFromColor(uv), to, m);
51
+ }
@@ -0,0 +1,101 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The frame wraps around a drum that rolls up, the outgoing image turning away over its top in a motion blur and the incoming one coming around from below and unrolling flat
4
+ // Tags: 3d, roll, motion-blur, vertical, chromatic
5
+
6
+ // @range(0, 1) How much the frame wraps around the drum
7
+ uniform float curvature; // = 0.8
8
+ // @range(0, 1) Length of the motion blur at full speed
9
+ uniform float blur; // = 0.5
10
+ // @range(0, 1) How much the drum darkens as it turns away
11
+ uniform float shading; // = 0.6
12
+ // @range(0, 1) Amount of RGB split along the roll, growing with speed
13
+ uniform float chroma; // = 0.5
14
+ // @param Roll downward instead, the incoming image coming around from above
15
+ uniform bool downward; // = false
16
+
17
+ const int SAMPLES = 24;
18
+ // the half angle of the drum seen in the frame height, at full curvature
19
+ const float MAX_ANGLE = 1.1;
20
+ // distance from the camera to the drum's axis, in drum radii
21
+ const float DIST = 2.6;
22
+ // how much the horizontal lines arc away from the middle, per frame height squared
23
+ const float ARC = 0.12;
24
+
25
+ float hash(vec2 c) {
26
+ vec2 q = fract(c * vec2(0.1031, 0.1030));
27
+ q += dot(q, q.yx + 33.33);
28
+ return fract((q.x + q.y) * q.x);
29
+ }
30
+
31
+ // mirrored coordinate, folded back into 0..1
32
+ float fold(float v) {
33
+ return 1.0 - abs(1.0 - mod(v, 2.0));
34
+ }
35
+
36
+ // the strip around the drum: the outgoing image, with the incoming one below it (or above)
37
+ vec4 strip(float x, float v) {
38
+ if (downward ? v > 1.0 : v < 0.0) {
39
+ return getToColor(vec2(x, fold(downward ? v - 1.0 : v + 1.0)));
40
+ }
41
+ return getFromColor(vec2(x, fold(v)));
42
+ }
43
+
44
+ // angle on the drum seen at the projected height c (the drum has a radius of 1)
45
+ float angleAt(float c) {
46
+ c = clamp(c, -0.98 / sqrt(DIST * DIST - 1.0), 0.98 / sqrt(DIST * DIST - 1.0));
47
+ return asin(c * DIST / sqrt(1.0 + c * c)) - atan(c);
48
+ }
49
+
50
+ vec4 transition(vec2 uv) {
51
+ float p = progress;
52
+ // ease in, roll fast in the middle, ease out
53
+ float h = 1.0 - abs(2.0 * p - 1.0); // 0 at both ends, 1 in the middle
54
+ float e = 0.5 * h * (0.1 + 0.9 * h * h);
55
+ float roll = p < 0.5 ? e : 1.0 - e;
56
+ // the blur and the RGB split stay low until the peak of the roll
57
+ float h3 = h * h * h;
58
+ float peak = h3 * h3;
59
+
60
+ // the frame wraps around the drum early, and unwraps to flat sooner as the incoming image settles
61
+ float bend = curvature * (p < 0.5 ? h * (2.0 - h) : h * h * (3.0 - 2.0 * h));
62
+ float phi = MAX_ANGLE * bend + 1e-4;
63
+ float arcK = ARC * bend;
64
+ // the height of the frame's edge, projected with perspective
65
+ float edgeY = sin(phi) / (DIST - cos(phi));
66
+
67
+ vec2 n = 2.0 * uv - 1.0;
68
+ // the horizontal lines arc away from the middle, toward the left and right edges
69
+ float xr = n.x * ratio;
70
+ float yn = n.y * (1.0 + arcK * xr * xr);
71
+ float theta = angleAt(yn * edgeY);
72
+ // nearer parts of the drum look wider: the drum is made wide enough to fill the frame's corners
73
+ float thetaCorner = angleAt((1.0 + arcK * ratio * ratio) * edgeY);
74
+ float width = (DIST - 1.0) / (DIST - cos(theta));
75
+ float zoom = (DIST - cos(thetaCorner)) / (DIST - 1.0);
76
+ float x = 0.5 + 0.5 * n.x / (zoom * width);
77
+ // lit from the camera: darker as the surface turns away
78
+ float facing = (DIST * cos(theta) - 1.0)
79
+ / sqrt(1.0 + DIST * DIST - 2.0 * DIST * cos(theta)) ;
80
+ float light = mix(1.0, clamp(facing, 0.0, 1.0), shading);
81
+
82
+ // position on the strip (the frame height when flat), rolling the outgoing image away
83
+ float v = 0.5 * (theta / phi + 1.0) + (downward ? roll : -roll);
84
+ float len = 0.5 * blur * peak;
85
+ float split = chroma * peak;
86
+ float jitter = hash(uv * 1000.0);
87
+ vec3 color = vec3(0.0);
88
+ vec3 weight = vec3(0.0);
89
+ float alpha = 0.0;
90
+ for (int i = 0; i < SAMPLES; i++) {
91
+ float t = (float(i) + jitter) / float(SAMPLES) - 0.5;
92
+ vec4 img = strip(x, v + t * len);
93
+ // the channels weigh the samples differently along the roll: an RGB split
94
+ vec3 w = vec3(max(1.0 - 4.0 * split * t, 0.0), 1.0, max(1.0 + 4.0 * split * t, 0.0));
95
+ color += img.rgb * img.a * w;
96
+ weight += img.a * w;
97
+ alpha += img.a;
98
+ }
99
+ color = color / max(weight, vec3(1e-5));
100
+ return vec4(color * light, alpha / float(SAMPLES));
101
+ }
@@ -0,0 +1,111 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image crumbles into fine dust from one side, its grains blown away by the wind and fading out, revealing the incoming image underneath
4
+ // Tags: particles, dust, wind, directional
5
+
6
+ // @range(0.0075, 0.03) Size of the dust grains, in frame heights
7
+ uniform float particleSize; // = 0.008
8
+ // @param Direction in which the wind blows the dust
9
+ uniform vec2 direction; // = vec2(1.0, -0.15)
10
+ // @range(0, 1) How far the dust flies and scatters before it fades out
11
+ uniform float spread; // = 0.75
12
+
13
+ // the grains a pixel looks back to, along the wind: every grain up to 16 cells away,
14
+ // one in 2 up to 32 cells, one in 4 up to 64 cells (only those stay visible that far,
15
+ // so the dust thins out as it flies): 35 candidates, without unrolling a long loop
16
+ const int NEAR = 17;
17
+ const int CANDIDATES = 35;
18
+ // part of the transition during which a grain flies, from its release to its fade-out
19
+ const float LIFE = 0.45;
20
+
21
+ float hash12(vec2 p) {
22
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
23
+ p3 += dot(p3, p3.yzx + 33.33);
24
+ return fract((p3.x + p3.y) * p3.z);
25
+ }
26
+
27
+ // smooth value noise, between -1 and 1
28
+ float noise(vec2 p) {
29
+ vec2 i = floor(p);
30
+ vec2 f = fract(p);
31
+ f = f * f * (3.0 - 2.0 * f);
32
+ float a = hash12(i);
33
+ float b = hash12(i + vec2(1.0, 0.0));
34
+ float c = hash12(i + vec2(0.0, 1.0));
35
+ float d = hash12(i + vec2(1.0, 1.0));
36
+ return 2.0 * mix(mix(a, b, f.x), mix(c, d, f.x), f.y) - 1.0;
37
+ }
38
+
39
+ // the grains' sideways drift, in gusts along the wind, between -1 and 1: it depends only
40
+ // on where a grain comes from along the wind, so that a pixel knows which row to look in
41
+ float gust(float x) {
42
+ float i = floor(x);
43
+ float f = fract(x);
44
+ f = f * f * (3.0 - 2.0 * f);
45
+ return 2.0 * mix(hash12(vec2(i, 7.0)), hash12(vec2(i + 1.0, 7.0)), f) - 1.0;
46
+ }
47
+
48
+ // when the grain at this center (in cells) is released, from the downwind side first,
49
+ // along a ragged front
50
+ float release(vec2 center, float h, float halfLength, float s) {
51
+ float front = 1.0 - (center.x + halfLength) / (2.0 * halfLength) + 0.14 * noise(center * s * 6.0) + 0.08 * (h - 0.5);
52
+ return clamp((front + 0.12) / 1.24, 0.0, 1.0) * (1.0 - LIFE);
53
+ }
54
+
55
+ vec4 transition(vec2 uv) {
56
+ vec2 d = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
57
+ vec2 n = vec2(-d.y, d.x);
58
+ // grid of grains aligned with the wind: x along it, y across it, in cells
59
+ vec2 fp = (uv - 0.5) * vec2(ratio, 1.0);
60
+ float s = particleSize;
61
+ vec2 g = vec2(dot(fp, d), dot(fp, n)) / s;
62
+ float halfLength = 0.5 * (ratio * abs(d.x) + abs(d.y)) / s;
63
+ // the longest flight, in cells (at most 60, within the 64 cells looked back to)
64
+ float reach = min(spread * 0.45 / s, 60.0);
65
+ float px = floor(g.x);
66
+
67
+ // this pixel's own grain: once it has left, the incoming image shows through
68
+ vec2 own = floor(g);
69
+ vec4 under = progress > release(own + 0.5, hash12(own), halfLength, s) ? getToColor(uv) : getFromColor(uv);
70
+ vec2 grainUV = vec2(0.5);
71
+ float cover = 0.0;
72
+ for (int i = 0; i < CANDIDATES; i++) {
73
+ // the column of the candidate grain
74
+ float fi = float(i);
75
+ float cx = px - fi;
76
+ if (i >= NEAR + 9) {
77
+ cx = floor(px / 4.0) * 4.0 - 4.0 * (fi - float(NEAR + 9) + 8.0);
78
+ } else if (i >= NEAR) {
79
+ cx = floor(px / 2.0) * 2.0 - 2.0 * (fi - float(NEAR) + 8.0);
80
+ }
81
+ // how far the grain stays visible (in cells): further when its column is a multiple
82
+ // of 2, and of 4, as far as the pixels look back to
83
+ float visible = mod(cx, 4.0) < 0.5 ? 63.0 : mod(cx, 2.0) < 0.5 ? 31.0 : 15.0;
84
+ float drift = 0.3 * gust(cx * s * 4.0);
85
+ // the row the grain comes from: its sideways drift is known from its column and how
86
+ // far it has flown to get here
87
+ vec2 cell = vec2(cx, floor(g.y - drift * (g.x - cx - 0.5)));
88
+ vec2 center = cell + 0.5;
89
+ vec2 cuv = (center.x * d + center.y * n) * s / vec2(ratio, 1.0) + 0.5;
90
+ if (cuv.x < 0.0 || cuv.x > 1.0 || cuv.y < 0.0 || cuv.y > 1.0) continue;
91
+ float h = hash12(cell);
92
+ float t = (progress - release(center, h, halfLength, s)) / LIFE;
93
+ if (t <= 0.0 || t >= 1.0) continue;
94
+ float r2 = fract(h * 13.7);
95
+ // the grain speeds up, drifts sideways, shrinks and fades out
96
+ float travel = reach * (0.4 + 0.6 * r2) * t * (0.2 + 0.8 * t);
97
+ // it first fills its cell, then crumbles to a smaller speck
98
+ float crumble = smoothstep(0.0, 0.25, t);
99
+ vec2 pos = center + vec2(travel + (fract(h * 71.1) - 0.5) * 0.3 * crumble, drift * travel);
100
+ vec2 local = abs(g - pos);
101
+ float size = mix(0.5, 0.3 * (1.0 - 0.5 * t) * (0.6 + 0.4 * h), crumble);
102
+ float feather = 0.001 + 0.12 * crumble;
103
+ float a = (1.0 - smoothstep(size - feather, size, max(local.x, local.y))) * (1.0 - smoothstep(0.15, 1.0, t))
104
+ * (1.0 - smoothstep(0.6 * visible, visible, travel));
105
+ if (a > cover) {
106
+ cover = a;
107
+ grainUV = cuv;
108
+ }
109
+ }
110
+ return mix(under, getFromColor(grainUV), cover);
111
+ }
@@ -0,0 +1,48 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: A cross-dissolve blended in linear light, as light adds up on film: the frame keeps its brightness all the way through and the highlights of each image shine through the other
4
+ // Tags: dissolve, fade, blend, light
5
+
6
+ // @range(0, 1) Extra light where the two images overlap at mid-dissolve, softly rolled off so it never clips
7
+ uniform float overlap; // = 0.25
8
+ // @range(0, 1) Easing of the dissolve: 0 is linear, 1 eases in and out
9
+ uniform float smoothness; // = 0.5
10
+
11
+ // sRGB to linear light (the exact piecewise curve)
12
+ vec3 toLinear(vec3 c) {
13
+ vec3 lo = c / 12.92;
14
+ vec3 hi = pow((c + 0.055) / 1.055, vec3(2.4));
15
+ return mix(lo, hi, vec3(greaterThan(c, vec3(0.04045))));
16
+ }
17
+
18
+ // linear light back to sRGB
19
+ vec3 toSrgb(vec3 c) {
20
+ vec3 lo = c * 12.92;
21
+ vec3 hi = 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055;
22
+ return mix(lo, hi, vec3(greaterThan(c, vec3(0.0031308))));
23
+ }
24
+
25
+ vec4 transition(vec2 uv) {
26
+ vec4 a = getFromColor(uv);
27
+ vec4 b = getToColor(uv);
28
+ if (progress <= 0.0) return a;
29
+ if (progress >= 1.0) return b;
30
+
31
+ float t = mix(progress, smoothstep(0.0, 1.0, progress), smoothness);
32
+
33
+ // premultiplied linear light
34
+ vec3 la = toLinear(clamp(a.rgb, 0.0, 1.0)) * a.a;
35
+ vec3 lb = toLinear(clamp(b.rgb, 0.0, 1.0)) * b.a;
36
+ vec3 base = mix(la, lb, t);
37
+ float alpha = mix(a.a, b.a, t);
38
+
39
+ // the overlap: each image stays brighter for longer, as in an additive dissolve,
40
+ // rolled off toward full exposure so that bright areas glow instead of clipping
41
+ float extra = overlap * min(t, 1.0 - t);
42
+ vec3 excess = extra * (la + lb);
43
+ vec3 room = max(vec3(alpha) - base, vec3(1e-5));
44
+ vec3 color = base + room * (1.0 - exp(-excess / room));
45
+
46
+ if (alpha <= 0.0) return vec4(0.0);
47
+ return vec4(toSrgb(clamp(color / alpha, 0.0, 1.0)), alpha);
48
+ }
@@ -0,0 +1,104 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The picture slips like film in a projector gate: it shrinks to show the sprocket holes, the strip runs down with motion blur and a slight weave, then the incoming frame lands in place
4
+ // Tags: retro, vertical, motion-blur, film
5
+
6
+ // @range(1, 6, 1) Number of frames that slip by
7
+ uniform int frames; // = 2
8
+ // @range(0, 0.4) How much the picture shrinks during the slip, showing the film's edges
9
+ uniform float shrink; // = 0.2
10
+ // @range(0, 1) Length of the motion blur at full speed
11
+ uniform float blur; // = 0.5
12
+ // @range(0, 1) Amount of horizontal weave and vertical jitter
13
+ uniform float weave; // = 0.5
14
+ // @color Color of the film around the pictures and of the line between frames
15
+ uniform vec4 filmColor; // = vec4(0.06, 0.05, 0.05, 1.0)
16
+ // @color Color of the light through the sprocket holes
17
+ uniform vec4 holeColor; // = vec4(0.96, 0.93, 0.85, 1.0)
18
+
19
+ // height of the line between two frames, in frame heights
20
+ const float FRAME_LINE = 0.08;
21
+ // sprocket holes per frame
22
+ const float HOLES = 4.0;
23
+ const int SAMPLES = 16;
24
+
25
+ // a fine, evenly spread dither pattern over small cells of the frame
26
+ float dither(vec2 cell) {
27
+ return fract(52.9829189 * fract(dot(cell, vec2(0.06711056, 0.00583715))));
28
+ }
29
+
30
+ // the film at (x, y): x across it (0 to 1 over the picture), y along it from the start of frame
31
+ // number base, in frame heights; holes fades the sprocket holes in
32
+ vec4 film(float x, float y, float base, float n, float aa, float holeX, vec2 holeSize, float holes) {
33
+ float pitch = 1.0 + FRAME_LINE;
34
+ float jy = floor(y / pitch);
35
+ float j = base + jy;
36
+ float fy = y - jy * pitch;
37
+ vec4 c = filmColor;
38
+ if (x >= 0.0 && x <= 1.0 && fy <= 1.0) {
39
+ vec2 q = vec2(x, fy);
40
+ c = j < n ? getFromColor(q) : getToColor(q);
41
+ }
42
+ // soft edges for the picture during the slip (none at rest, where it fills the frame)
43
+ float inside = min(min(x, 1.0 - x) * ratio, min(fy, 1.0 - fy));
44
+ c = mix(filmColor, c, clamp(inside / aa + 0.5, 0.0, 1.0));
45
+ // the sprocket holes, in the margins on both sides, in frame heights
46
+ float hy = mod(y, pitch / HOLES) - 0.5 * pitch / HOLES;
47
+ float hx = (abs(x - 0.5) - holeX) * ratio;
48
+ vec2 dd = abs(vec2(hx, hy)) - holeSize + 0.3 * holeSize.x;
49
+ float sd = length(max(dd, 0.0)) + min(max(dd.x, dd.y), 0.0) - 0.3 * holeSize.x;
50
+ return mix(c, holeColor, clamp(0.5 - sd / aa, 0.0, 1.0) * holes);
51
+ }
52
+
53
+ vec4 transition(vec2 uv) {
54
+ if (progress <= 0.0) return getFromColor(uv);
55
+ if (progress >= 1.0) return getToColor(uv);
56
+ float n = max(float(frames), 1.0);
57
+ float pitch = 1.0 + FRAME_LINE;
58
+ float p = progress;
59
+ // the picture shrinks first, slips, then grows back
60
+ float env = smoothstep(0.0, 0.3, p) * (1.0 - smoothstep(0.7, 1.0, p));
61
+ float k = 1.0 - shrink * env;
62
+ // the slip, in frames: smooth start and landing
63
+ float x0 = clamp((p - 0.15) / 0.7, 0.0, 1.0);
64
+ float slip = x0 * x0 * x0 * (x0 * (x0 * 6.0 - 15.0) + 10.0);
65
+ float speed = 30.0 * x0 * x0 * (1.0 - x0) * (1.0 - x0) / 0.7; // d(slip)/d(progress), up to ~2.7
66
+ // weave and jitter, only while the film moves
67
+ float wob = weave * env;
68
+ // (the weave stays within the film's margin)
69
+ float dx = wob * smoothstep(0.0, 0.1, shrink) * (0.006 * sin(p * 47.0) + 0.004 * sin(p * 113.0 + 1.3));
70
+ float dy = wob * 0.012 * sin(p * 71.0 + 0.4) * (1.0 - speed / 2.7);
71
+
72
+ // the frames slipped by so far: whole frames, and the position within the current one
73
+ float frameSlip = slip * n;
74
+ float base = floor(frameSlip);
75
+ float x = (uv.x - 0.5) / k + 0.5 + dx;
76
+ float y = (uv.y - 0.5) / k + 0.5 + dy + (frameSlip - base) * pitch;
77
+ // anti-aliasing width, in frame heights: none at rest or without margin
78
+ float aa = 0.002 * min(1.0, 10.0 * env) * min(1.0, 20.0 * shrink) + 1e-4;
79
+ // the holes sit in the middle of the margin the shrinking picture shows
80
+ float margin = 0.5 * shrink / max(1.0 - shrink, 0.01);
81
+ float holeX = 0.5 + 0.5 * margin;
82
+ vec2 holeSize = vec2(0.28 * margin * ratio, 0.11 * pitch / HOLES);
83
+ float holes = smoothstep(0.0, 0.02, margin);
84
+
85
+ // motion blur along the strip, dithered to hide the steps
86
+ float len = blur * 0.06 * speed * n;
87
+ vec4 color = vec4(0.0);
88
+ if (len < 1e-5) {
89
+ color = film(x, y, base, n, aa, holeX, holeSize, holes);
90
+ } else {
91
+ // averaged with premultiplied colors, so transparent parts don't darken the others
92
+ float jitter = dither(floor(uv * vec2(ratio, 1.0) * 540.0));
93
+ for (int i = 0; i < SAMPLES; i++) {
94
+ float t = (float(i) + jitter) / float(SAMPLES) - 0.5;
95
+ vec4 c = film(x, y + t * len, base, n, aa, holeX, holeSize, holes);
96
+ color += vec4(c.rgb * c.a, c.a);
97
+ }
98
+ color /= float(SAMPLES);
99
+ color.rgb = color.a > 0.0 ? color.rgb / color.a : vec3(0.0);
100
+ }
101
+ // the projector's light flickers a little while the film runs
102
+ color.rgb *= 1.0 - 0.08 * wob * (0.5 + 0.5 * sin(p * 157.0));
103
+ return color;
104
+ }