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