gl-transitions 2.0.0 → 2.2.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 (131) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/compatibility.json +386 -0
  3. package/gl-transitions.js +1 -1
  4. package/gl-transitions.json +1 -1
  5. package/glsl3/ApertureWipe.glsl +45 -0
  6. package/glsl3/Comb.glsl +26 -0
  7. package/glsl3/Curtains.glsl +47 -0
  8. package/glsl3/CylinderRoll.glsl +102 -0
  9. package/glsl3/DiamondWipe.glsl +21 -0
  10. package/glsl3/DitherDissolve.glsl +27 -0
  11. package/glsl3/FallOver.glsl +36 -0
  12. package/glsl3/Fisheye.glsl +23 -0
  13. package/glsl3/Halftone.glsl +49 -0
  14. package/glsl3/Honeycomb.glsl +55 -0
  15. package/glsl3/LightStreaks.glsl +117 -0
  16. package/glsl3/PaperTear.glsl +76 -0
  17. package/glsl3/PixelStretch.glsl +73 -0
  18. package/glsl3/Prisms.glsl +81 -0
  19. package/glsl3/Puzzle.glsl +124 -0
  20. package/glsl3/Refraction.glsl +95 -0
  21. package/glsl3/Shred.glsl +67 -0
  22. package/glsl3/SpiralWipe.glsl +41 -0
  23. package/glsl3/Tunnel.glsl +42 -0
  24. package/glsl3/TvRoll.glsl +43 -0
  25. package/glsl3/TvTurnOff.glsl +47 -0
  26. package/glsl3/WhipPan.glsl +50 -0
  27. package/glsl3/WhipSpin.glsl +69 -0
  28. package/glsl3/WhipTilt.glsl +79 -0
  29. package/index.js +1 -1
  30. package/layouts.json +764 -0
  31. package/llms-full.txt +620 -256
  32. package/llms.txt +160 -136
  33. package/msl/ApertureWipe.metal +193 -0
  34. package/msl/Comb.metal +167 -0
  35. package/msl/Curtains.metal +207 -0
  36. package/msl/CylinderRoll.metal +374 -0
  37. package/msl/DiamondWipe.metal +123 -0
  38. package/msl/DitherDissolve.metal +157 -0
  39. package/msl/FallOver.metal +192 -0
  40. package/msl/Fisheye.metal +121 -0
  41. package/msl/Halftone.metal +230 -0
  42. package/msl/Honeycomb.metal +263 -0
  43. package/msl/LightStreaks.metal +518 -0
  44. package/msl/PaperTear.metal +373 -0
  45. package/msl/PixelStretch.metal +337 -0
  46. package/msl/Prisms.metal +424 -0
  47. package/msl/Puzzle.metal +632 -0
  48. package/msl/Refraction.metal +333 -0
  49. package/msl/Shred.metal +294 -0
  50. package/msl/SpiralWipe.metal +196 -0
  51. package/msl/Tunnel.metal +207 -0
  52. package/msl/TvRoll.metal +205 -0
  53. package/msl/TvTurnOff.metal +238 -0
  54. package/msl/WhipPan.metal +218 -0
  55. package/msl/WhipSpin.metal +278 -0
  56. package/msl/WhipTilt.metal +327 -0
  57. package/package.json +1 -1
  58. package/skills/gl-transitions/references/catalog.md +69 -39
  59. package/sksl/ApertureWipe.sksl +56 -0
  60. package/sksl/Comb.sksl +39 -0
  61. package/sksl/Curtains.sksl +60 -0
  62. package/sksl/CylinderRoll.sksl +112 -0
  63. package/sksl/DiamondWipe.sksl +34 -0
  64. package/sksl/DitherDissolve.sksl +39 -0
  65. package/sksl/FallOver.sksl +49 -0
  66. package/sksl/Fisheye.sksl +36 -0
  67. package/sksl/Halftone.sksl +61 -0
  68. package/sksl/Honeycomb.sksl +64 -0
  69. package/sksl/LightStreaks.sksl +126 -0
  70. package/sksl/PaperTear.sksl +82 -0
  71. package/sksl/PixelStretch.sksl +84 -0
  72. package/sksl/Prisms.sksl +94 -0
  73. package/sksl/Puzzle.sksl +134 -0
  74. package/sksl/Refraction.sksl +103 -0
  75. package/sksl/Shred.sksl +79 -0
  76. package/sksl/SpiralWipe.sksl +51 -0
  77. package/sksl/Tunnel.sksl +55 -0
  78. package/sksl/TvRoll.sksl +55 -0
  79. package/sksl/TvTurnOff.sksl +59 -0
  80. package/sksl/WhipPan.sksl +62 -0
  81. package/sksl/WhipSpin.sksl +79 -0
  82. package/sksl/WhipTilt.sksl +90 -0
  83. package/sksl/index.js +1 -1
  84. package/transitions/ApertureWipe.glsl +44 -0
  85. package/transitions/Comb.glsl +25 -0
  86. package/transitions/Curtains.glsl +46 -0
  87. package/transitions/CylinderRoll.glsl +101 -0
  88. package/transitions/DiamondWipe.glsl +20 -0
  89. package/transitions/DitherDissolve.glsl +26 -0
  90. package/transitions/FallOver.glsl +35 -0
  91. package/transitions/Fisheye.glsl +22 -0
  92. package/transitions/Halftone.glsl +48 -0
  93. package/transitions/Honeycomb.glsl +54 -0
  94. package/transitions/LightStreaks.glsl +116 -0
  95. package/transitions/PaperTear.glsl +75 -0
  96. package/transitions/PixelStretch.glsl +72 -0
  97. package/transitions/Prisms.glsl +80 -0
  98. package/transitions/Puzzle.glsl +123 -0
  99. package/transitions/Refraction.glsl +94 -0
  100. package/transitions/Shred.glsl +66 -0
  101. package/transitions/SpiralWipe.glsl +40 -0
  102. package/transitions/Tunnel.glsl +41 -0
  103. package/transitions/TvRoll.glsl +42 -0
  104. package/transitions/TvTurnOff.glsl +46 -0
  105. package/transitions/WhipPan.glsl +49 -0
  106. package/transitions/WhipSpin.glsl +68 -0
  107. package/transitions/WhipTilt.glsl +78 -0
  108. package/wgsl/ApertureWipe.wgsl +160 -0
  109. package/wgsl/Comb.wgsl +139 -0
  110. package/wgsl/Curtains.wgsl +179 -0
  111. package/wgsl/CylinderRoll.wgsl +330 -0
  112. package/wgsl/DiamondWipe.wgsl +94 -0
  113. package/wgsl/DitherDissolve.wgsl +123 -0
  114. package/wgsl/FallOver.wgsl +164 -0
  115. package/wgsl/Fisheye.wgsl +93 -0
  116. package/wgsl/Halftone.wgsl +196 -0
  117. package/wgsl/Honeycomb.wgsl +222 -0
  118. package/wgsl/LightStreaks.wgsl +460 -0
  119. package/wgsl/PaperTear.wgsl +324 -0
  120. package/wgsl/PixelStretch.wgsl +298 -0
  121. package/wgsl/Prisms.wgsl +385 -0
  122. package/wgsl/Puzzle.wgsl +587 -0
  123. package/wgsl/Refraction.wgsl +294 -0
  124. package/wgsl/Shred.wgsl +259 -0
  125. package/wgsl/SpiralWipe.wgsl +165 -0
  126. package/wgsl/Tunnel.wgsl +177 -0
  127. package/wgsl/TvRoll.wgsl +165 -0
  128. package/wgsl/TvTurnOff.wgsl +196 -0
  129. package/wgsl/WhipPan.wgsl +177 -0
  130. package/wgsl/WhipSpin.wgsl +241 -0
  131. package/wgsl/WhipTilt.wgsl +291 -0
@@ -0,0 +1,73 @@
1
+ // PixelStretch — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/PixelStretch.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A line sweeps across the frame and drags the outgoing image's pixels behind it as long streaks, which shorten as it goes and reveal the incoming image
5
+ // Tags: smear, streaks, directional, chromatic
6
+
7
+ // @param Direction in which the line sweeps
8
+ uniform vec2 direction; // = vec2(1.0, 0.0)
9
+ // @range(0, 1) Length of the streaks at the middle of the sweep, as a part of the frame
10
+ uniform float stretch; // = 0.45
11
+ // @range(0, 1) Amount of RGB split along the streaks
12
+ uniform float chroma; // = 0.5
13
+ // @range(0, 0.2) Softness of the line and of the streaks' ends, as a part of the frame
14
+ uniform float softness; // = 0.03
15
+ // @range(0, 1) How much the streaks jitter, each row at its own length
16
+ uniform float jitter; // = 0.5
17
+
18
+ float hash(float n) {
19
+ n = fract(n * 0.1031);
20
+ n *= n + 33.33;
21
+ n *= n + n;
22
+ return fract(n);
23
+ }
24
+
25
+ // smooth max with a compact support: exactly max(x, y) when they are k apart
26
+ float smax(float x, float y, float k) {
27
+ float h = max(k - abs(x - y), 0.0) / k;
28
+ return max(x, y) + h * h * k * 0.25;
29
+ }
30
+
31
+ // position s along the sweep (0 to 1 across the frame) to a frame coordinate
32
+ vec2 at(vec2 uv, float s0, float s, vec2 d, float ext) {
33
+ return clamp(uv + d * (s - s0) * ext, 0.0, 1.0);
34
+ }
35
+
36
+ vec4 transition(vec2 uv) {
37
+ vec2 d = normalize(direction + vec2(1e-6, 0.0));
38
+ // ext: length of the frame along the sweep, in uv units
39
+ float ext = abs(d.x) + abs(d.y);
40
+ float s = 0.5 + dot(uv - 0.5, d) / ext;
41
+ // rows across the streaks (about one per pixel line), in frame heights
42
+ vec2 n = vec2(-d.y, d.x);
43
+ float t = dot((uv - 0.5) * vec2(ratio, 1.0), n);
44
+ float row = floor(t * 540.0);
45
+ float clump = floor(t * 60.0);
46
+ float rnd = 0.6 * hash(row + 17.0) + 0.4 * hash(clump + 311.0);
47
+
48
+ float p = progress;
49
+ float k = softness + 1e-4;
50
+ // the line starts and ends at rest just beyond the frame, past its soft edge, so both ends are exact;
51
+ // it enters at once and slows down a little toward the end
52
+ float margin = k + 0.002;
53
+ float a = mix(-margin, 1.0 + margin, mix(p, p * p * (3.0 - 2.0 * p), 0.5));
54
+
55
+ // the streaks are longest when the line crosses the middle and vanish as it reaches the edges,
56
+ // so they never repeat the frame's own border (often dark, or letterboxing)
57
+ float h = clamp(4.0 * a * (1.0 - a), 0.0, 1.0);
58
+ float len = stretch * h * (1.0 - 0.6 * jitter * rnd);
59
+ float split = 0.02 * chroma * h;
60
+
61
+ // ahead of the line the outgoing image is intact; behind it, each pixel repeats the pixel at the line
62
+ vec4 fr = getFromColor(at(uv, s, smax(s, a + split, k), d, ext));
63
+ vec4 fg = getFromColor(at(uv, s, smax(s, a, k), d, ext));
64
+ vec4 fb = getFromColor(at(uv, s, smax(s, a - split, k), d, ext));
65
+ vec4 streak = vec4(fr.r, fg.g, fb.b, fg.a);
66
+ // a faint flicker along the streaks
67
+ float behind = step(s, a);
68
+ streak.rgb *= 1.0 + 0.06 * jitter * h * (hash(row * 3.0 + 5.0) - 0.5) * behind;
69
+
70
+ // past the end of its streak, each row shows the incoming image as it is
71
+ float w = smoothstep(len - k, len + k, a - s);
72
+ return mix(streak, getToColor(uv), w);
73
+ }
@@ -0,0 +1,81 @@
1
+ // Prisms — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Prisms.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The frame is cut into 3D prisms that turn in a cascade, like a rotating billboard, from the outgoing image on one face to the incoming one on the next
5
+ // Tags: 3d, rotate, stripes
6
+
7
+ // @range(2, 40, 1) Number of prisms
8
+ uniform int slats; // = 8
9
+ // @range(0, 0.9) Delay of the last prism's turn, as a part of the transition
10
+ uniform float stagger; // = 0.45
11
+ // @range(0, 4) Amount of perspective
12
+ uniform float perspective; // = 1.0
13
+ // @range(0, 1) How much the faces darken as they turn away
14
+ uniform float shading; // = 0.6
15
+ // @param Cut the frame into horizontal prisms instead
16
+ uniform bool horizontal; // = false
17
+ // @color Color seen where the turning prisms leave the frame uncovered
18
+ uniform vec4 backColor; // = vec4(0.0, 0.0, 0.0, 1.0)
19
+
20
+ const float PI = 3.141592653589793;
21
+ // width of the anti-aliased edges, in frame heights
22
+ const float EDGE = 0.002;
23
+
24
+ vec4 transition (vec2 uv) {
25
+ float n = float(slats);
26
+ // a: the axis across the prisms, b: the axis they turn around
27
+ float a = horizontal ? uv.y : uv.x;
28
+ float b = horizontal ? uv.x : uv.y;
29
+ // the prisms' half width in frame heights, and the perspective from their depth
30
+ float hw = 0.5 / n * (horizontal ? 1.0 : ratio);
31
+ float k = min(perspective * hw, 0.5);
32
+ float bScale = horizontal ? ratio : 1.0;
33
+ // a turning prism is wider than its strip: keep the two nearest faces
34
+ vec4 near1 = vec4(0.0), near2 = vec4(0.0);
35
+ float cover1 = 0.0, cover2 = 0.0;
36
+ float z1 = -2.0, z2 = -2.0;
37
+ for (int d = -1; d <= 1; d++) {
38
+ float i = floor(a * n) + float(d);
39
+ if (i < 0.0 || i > n - 1.0) continue;
40
+ // each prism turns after a delay that grows across the frame, left to right or top to bottom
41
+ float order = (horizontal ? n - 1.0 - i : i) / (n - 1.0);
42
+ float t = clamp((progress - stagger * order) / (1.0 - stagger), 0.0, 1.0);
43
+ t = mix(t, t * t * (3.0 - 2.0 * t), 0.7);
44
+ float c = cos(0.5 * PI * t);
45
+ float s = sin(0.5 * PI * t);
46
+ // soft edges while turning (sharp at rest, to keep the first and last frames exact)
47
+ float edge = EDGE * min(1.0, 20.0 * s * c) + 1e-6;
48
+ // x: position across the strip, -1 to 1; the prism's square section has its faces at distance 1
49
+ float x = 2.0 * (a * n - i) - 1.0;
50
+ for (int f = 0; f < 2; f++) {
51
+ // f = 0: the outgoing face turning away, f = 1: the incoming face turning in
52
+ float cf = f == 0 ? c : s;
53
+ if (cf < 1e-4) continue;
54
+ // u: position on the face, z: depth (1 for a face at rest)
55
+ float u = f == 0 ? (x + s) / c : (x - c) / s;
56
+ float z = f == 0 ? u * s + c : s - u * c;
57
+ if (abs(u) > 1.0 || z <= z2) continue;
58
+ // nearer parts look bigger
59
+ float scale = 1.0 - k * (z - 1.0);
60
+ float y = (b - 0.5) * scale + 0.5;
61
+ if (y < 0.0 || y > 1.0) continue;
62
+ // soften the outer edges only: the faces meet at the prism's corner
63
+ float outer = f == 0 ? 1.0 + u : 1.0 - u;
64
+ float cover = clamp(outer * hw * cf / edge, 0.0, 1.0)
65
+ * clamp(min(y, 1.0 - y) * bScale / scale / edge, 0.0, 1.0);
66
+ float sa = (i + 0.5 + 0.5 * u) / n;
67
+ vec2 p = horizontal ? vec2(y, sa) : vec2(sa, y);
68
+ vec4 img = f == 0 ? getFromColor(p) : getToColor(p);
69
+ // lit from the front and the incoming side: the outgoing face darkens as it turns away
70
+ float lambert = clamp(f == 0 ? c - 0.6 * s : s + 0.6 * c, 0.0, 1.0);
71
+ vec4 color = vec4(img.rgb * mix(1.0 - shading, 1.0, lambert), img.a);
72
+ if (z > z1) {
73
+ near2 = near1; cover2 = cover1; z2 = z1;
74
+ near1 = color; cover1 = cover; z1 = z;
75
+ } else {
76
+ near2 = color; cover2 = cover; z2 = z;
77
+ }
78
+ }
79
+ }
80
+ return mix(mix(backColor, near2, cover2), near1, cover1);
81
+ }
@@ -0,0 +1,124 @@
1
+ // Puzzle — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Puzzle.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The image is cut into jigsaw puzzle pieces that lift one after another and fall away, revealing the incoming image
5
+ // Tags: tiles, shadow, rotate, fragments
6
+
7
+ // @range(2, 12) Number of pieces across the shorter side
8
+ uniform float pieces; // = 5.0
9
+ // @range(0, 1) Darkness of the shadows of the lifted pieces
10
+ uniform float shadow; // = 0.6
11
+
12
+ // Hash of a cell, without sin, in [0, 1)
13
+ float hash(vec2 c) {
14
+ vec2 p = fract(c * vec2(0.1031, 0.1030));
15
+ p += dot(p, p.yx + 33.33);
16
+ return fract((p.x + p.y) * p.x);
17
+ }
18
+
19
+ float boxDist(vec2 p, vec2 halfSize) {
20
+ vec2 q = abs(p) - halfSize;
21
+ return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
22
+ }
23
+
24
+ // Signed distance of a point, relative to the center of piece c, to that piece (cell units).
25
+ // Each edge has a knob (a round head on a neck): a tab for one piece, a blank for its neighbor; border edges are flat.
26
+ float pieceDist(vec2 p, vec2 c, vec2 grid, float aspect) {
27
+ vec2 halfSize = vec2(0.5 * aspect, 0.5);
28
+ float d = boxDist(p, halfSize);
29
+ float tabs = 1e3;
30
+ for (int e = 0; e < 4; e++) {
31
+ // right, left, top, bottom: the edge key is the cell on its left or below
32
+ vec2 dir = e == 0 ? vec2(1.0, 0.0) : e == 1 ? vec2(-1.0, 0.0) : e == 2 ? vec2(0.0, 1.0) : vec2(0.0, -1.0);
33
+ vec2 key = c + min(dir, 0.0);
34
+ vec2 next = c + dir;
35
+ if (next.x >= 0.0 && next.y >= 0.0 && next.x < grid.x && next.y < grid.y) {
36
+ float h = hash(key + (e < 2 ? vec2(0.0) : vec2(71.0, 37.0)));
37
+ // the knob points right or up from the key cell when h < 0.5
38
+ bool tab = (h < 0.5) == (dir.x + dir.y > 0.0);
39
+ vec2 out1 = dir * (tab ? 1.0 : -1.0);
40
+ vec2 along = vec2(abs(dir.y), abs(dir.x));
41
+ vec2 edge = dir * halfSize + along * (fract(h * 2.0) - 0.5) * 0.16;
42
+ float k = min(
43
+ length(p - edge - out1 * 0.15) - 0.125,
44
+ boxDist(p - edge - out1 * 0.06, abs(dir) * 0.08 + along * 0.085));
45
+ if (tab) tabs = min(tabs, k);
46
+ else d = max(d, -k);
47
+ }
48
+ }
49
+ return min(d, tabs);
50
+ }
51
+
52
+ vec4 transition(vec2 uv) {
53
+ // a grid of nearly square cells that fits the frame exactly
54
+ float rows = ratio < 1.0 ? floor(pieces / ratio + 0.5) : pieces;
55
+ float cols = ratio < 1.0 ? pieces : floor(pieces * ratio + 0.5);
56
+ vec2 grid = vec2(cols, rows);
57
+ float aspect = ratio * rows / cols;
58
+ vec2 g = uv * grid;
59
+ vec2 cell = floor(g);
60
+
61
+ const float aa = 0.01; // soft edges, in cells
62
+ float boardSum = 0.0;
63
+ float allSum = 0.0;
64
+ // the two top moving pieces under this point
65
+ float prio1 = -1.0, prio2 = -1.0, cov1 = 0.0, cov2 = 0.0, shade1 = 1.0, shade2 = 1.0;
66
+ vec2 uv1 = uv, uv2 = uv;
67
+ float shadowAll = 0.0;
68
+ float seam = 1.0;
69
+ for (int i = 0; i < 9; i++) {
70
+ vec2 c = cell + vec2(mod(float(i), 3.0), floor(float(i) / 3.0)) - 1.0;
71
+ if (c.x < 0.0 || c.y < 0.0 || c.x >= cols || c.y >= rows) continue;
72
+ vec2 center = c + 0.5;
73
+ vec2 local = (g - center) * vec2(aspect, 1.0);
74
+ float h = hash(c + vec2(13.0, 7.0));
75
+ // diagonal order from the top left, a little shuffled
76
+ float diag = (c.x / max(cols - 1.0, 1.0) + (rows - 1.0 - c.y) / max(rows - 1.0, 1.0)) * 0.5;
77
+ float delay = (diag + 1.2 * (h - 0.5) * diag * (1.0 - diag)) * 0.6;
78
+ float t = clamp((progress - delay) / 0.4, 0.0, 1.0);
79
+
80
+ // where the piece was: the board keeps the outgoing image where pieces are still in place
81
+ float d0 = pieceDist(local, c, grid, aspect);
82
+ float w = 1.0 - smoothstep(-aa, aa, d0);
83
+ allSum += w;
84
+ if (t <= 0.0) {
85
+ boardSum += w;
86
+ seam = min(seam, abs(d0));
87
+ continue;
88
+ }
89
+ // lift, then fall away: shrink, spin, drift down and darken
90
+ float lift = smoothstep(0.0, 0.25, t);
91
+ float fall = clamp((t - 0.2) / 0.8, 0.0, 1.0);
92
+ fall *= fall;
93
+ float s = max(1.0 - fall, 0.001);
94
+ float a = (h - 0.5) * 3.0 * fall;
95
+ vec2 off = vec2(0.0, -1.2 * fall);
96
+ mat2 rot = mat2(cos(a), -sin(a), sin(a), cos(a));
97
+ vec2 pl = rot * (local - off) / s;
98
+ float dp = pieceDist(pl, c, grid, aspect);
99
+ float cov = (1.0 - smoothstep(-aa, aa, dp * s)) * min(s * 20.0, 1.0); // fades when tiny
100
+ // darker when falling, and on its edges when lifted
101
+ float shade = (1.0 - 0.5 * fall) * (1.0 - 0.3 * lift * (1.0 - smoothstep(0.0, 0.035, -dp)));
102
+ vec2 puv = (center + pl / vec2(aspect, 1.0)) / grid;
103
+ // soft shadow, offset to the bottom right while lifted
104
+ vec2 sl = rot * (local - off - vec2(0.08, -0.1) * lift) / s;
105
+ float sh = (1.0 - smoothstep(-0.05, 0.12, pieceDist(sl, c, grid, aspect) * s)) * lift * (1.0 - fall) * shadow;
106
+ // the hole it leaves is in its shadow too
107
+ shadowAll = max(shadowAll, max(sh, w * lift * (1.0 - smoothstep(0.2, 0.5, t)) * shadow));
108
+ float prio = delay;
109
+ if (cov > 0.0 && prio > prio1) {
110
+ prio2 = prio1; cov2 = cov1; uv2 = uv1; shade2 = shade1;
111
+ prio1 = prio; cov1 = cov; uv1 = puv; shade1 = shade;
112
+ } else if (cov > 0.0 && prio > prio2) {
113
+ prio2 = prio; cov2 = cov; uv2 = puv; shade2 = shade;
114
+ }
115
+ }
116
+ vec4 base = mix(getToColor(uv), getFromColor(uv), boardSum / max(allSum, 0.001));
117
+ // the cuts show on the board as the transition starts
118
+ base.rgb *= (1.0 - shadowAll) * (1.0 - 0.4 * smoothstep(0.0, 0.1, progress) * (1.0 - smoothstep(0.0, 0.015, seam)));
119
+ vec4 p2 = getFromColor(uv2);
120
+ p2.rgb *= shade2;
121
+ vec4 p1 = getFromColor(uv1);
122
+ p1.rgb *= shade1;
123
+ return mix(mix(base, p2, cov2), p1, cov1);
124
+ }
@@ -0,0 +1,95 @@
1
+ // Refraction — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Refraction.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The frame is seen through flowing liquid glass that bends the outgoing image more and more, with rainbow fringes, flares up as the incoming image takes over, then calms down and clears
5
+ // Tags: distortion, refraction, chromatic-aberration, glow
6
+
7
+ // @range(0, 0.3) How far the glass bends the image at the peak
8
+ uniform float strength; // = 0.15
9
+ // @range(0.5, 8) Size of the flowing waves: higher makes smaller waves
10
+ uniform float scale; // = 2.5
11
+ // @range(0, 1) Spread of the rainbow fringes
12
+ uniform float dispersion; // = 0.5
13
+ // @range(0, 3) Brightness of the flare at the peak
14
+ uniform float brightness; // = 1.0
15
+
16
+ // the wavelengths sampled from red to violet
17
+ const int TAPS = 7;
18
+
19
+ // the glass surface: smooth waves of a few sizes, warped into each other and flowing over time
20
+ float surface(vec2 q, float t) {
21
+ q += 0.45 * vec2(sin(1.3 * q.y + 0.9 * t), sin(1.1 * q.x - 1.2 * t));
22
+ float h = sin(q.x + 0.6 * t) * sin(1.2 * q.y - 0.8 * t);
23
+ h += 0.5 * sin(dot(q, vec2(1.6, -1.2)) + 1.4 * t);
24
+ h += 0.3 * sin(dot(q, vec2(-1.1, 2.9)) - 1.9 * t + 1.7 * sin(0.9 * q.x));
25
+ h += 0.15 * sin(dot(q, vec2(4.3, 3.1)) + 2.6 * t);
26
+ return h;
27
+ }
28
+
29
+ // a hash without sin, to jitter the wavelengths from pixel to pixel
30
+ float hash12(vec2 v) {
31
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
32
+ v3 += dot(v3, v3.yzx + 33.33);
33
+ return fract((v3.x + v3.y) * v3.z);
34
+ }
35
+
36
+ // mirror the coordinates back into the frame
37
+ vec2 mirror(vec2 v) {
38
+ return 1.0 - abs(1.0 - mod(v, 2.0));
39
+ }
40
+
41
+ // rough spectral response of a wavelength w (0 = red, 1 = violet), in RGB
42
+ vec3 spectrum(float w) {
43
+ vec3 c = vec3(
44
+ 1.0 - smoothstep(0.0, 0.55, w) + 0.35 * smoothstep(0.75, 1.0, w),
45
+ 1.0 - abs(2.0 * w - 1.0) * 1.2,
46
+ smoothstep(0.45, 1.0, w)
47
+ );
48
+ return clamp(c, 0.0, 1.0);
49
+ }
50
+
51
+ vec4 transition(vec2 uv) {
52
+ float p = progress;
53
+ // 0 at both ends, 1 in the middle: the glass builds up slowly, then calms down
54
+ float h = 1.0 - abs(2.0 * p - 1.0);
55
+ float amount = h * h * (2.0 - h);
56
+
57
+ // the glass refracts along the slope of its surface
58
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0) * scale;
59
+ float t = 3.0 * p;
60
+ float e = 0.01;
61
+ vec2 slope = vec2(
62
+ surface(q + vec2(e, 0.0), t) - surface(q - vec2(e, 0.0), t),
63
+ surface(q + vec2(0.0, e), t) - surface(q - vec2(0.0, e), t)
64
+ ) / (2.0 * e);
65
+ vec2 offset = slope * strength * amount / scale;
66
+ // the switch to the incoming image, around the peak: it appears through the glass's waves,
67
+ // the crests first, then the troughs
68
+ float wave = clamp(0.5 * surface(q, t), -1.0, 1.0);
69
+ float m = smoothstep(-0.015, 0.015, p - 0.5 + 0.1 * wave);
70
+
71
+ // each wavelength bends a little differently: red the least, violet the most
72
+ vec3 color = vec3(0.0);
73
+ vec3 weights = vec3(0.0);
74
+ float alpha = 0.0;
75
+ // jittered wavelengths blend the fringes into a continuous rainbow
76
+ float jitter = hash12(uv * vec2(ratio, 1.0) * 1000.0) - 0.5;
77
+ for (int i = 0; i < TAPS; i++) {
78
+ float w = float(i) / float(TAPS - 1);
79
+ float wj = (float(i) + jitter) / float(TAPS - 1);
80
+ vec2 st = mirror(uv + offset * (1.0 + dispersion * (wj - 0.5) * 1.6));
81
+ vec4 c = mix(getFromColor(st), getToColor(st), m);
82
+ vec3 s = spectrum(w);
83
+ color += s * c.rgb * c.a;
84
+ weights += s;
85
+ alpha += c.a;
86
+ }
87
+ alpha /= float(TAPS);
88
+ color = color / weights / max(alpha, 1e-5);
89
+
90
+ // a flare at the peak: the image is pushed toward an overexposed white
91
+ float flare = 2.0 * brightness * pow(h, 8.0);
92
+ color = color * (1.0 + flare) / (1.0 + flare * color);
93
+ color += 0.1 * flare * dot(color, vec3(0.3333));
94
+ return vec4(clamp(color, 0.0, 1.0), alpha);
95
+ }
@@ -0,0 +1,67 @@
1
+ // Shred — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Shred.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image is cut into paper strips that drop away at uneven speeds, tilting as they fall, revealing the incoming image
5
+ // Tags: slices, stripes, vertical, shadow
6
+
7
+ // @range(4, 60, 1) Number of strips
8
+ uniform int strips; // = 20
9
+ // @range(0, 0.8) Spread of the strips' start times, as a part of the transition
10
+ uniform float stagger; // = 0.4
11
+ // @range(0, 0.3) Largest tilt of a falling strip, in radians
12
+ uniform float tilt; // = 0.1
13
+ // @range(0, 1) Darkness of the strips' cut edges and of their shadow
14
+ uniform float shadow; // = 0.5
15
+
16
+ // a deterministic random value in [0, 1) for each strip
17
+ float hash (float n) {
18
+ n = fract(n * 0.1031);
19
+ n *= n + 33.33;
20
+ n *= n + n;
21
+ return fract(n);
22
+ }
23
+
24
+ vec4 transition (vec2 uv) {
25
+ float n = float(strips);
26
+ float w = ratio / n; // strip width, in frame heights
27
+ vec2 q = vec2(uv.x * ratio, uv.y);
28
+ vec4 color = getToColor(uv);
29
+ float cover = -1.0;
30
+ float shade = 0.0;
31
+ // narrow strips tilt less, so that they only reach over their neighbours
32
+ float maxTilt = min(tilt, 2.0 * w);
33
+ for (int d = -3; d <= 3; d++) {
34
+ float i = floor(uv.x * n) + float(d);
35
+ if (i < 0.0 || i > n - 1.0) continue;
36
+ // about one strip in five starts right away
37
+ float delay = stagger * max(0.0, 1.25 * hash(i + 1.0) - 0.25);
38
+ float speed = 1.0 + 0.5 * hash(i + 71.0);
39
+ float t = clamp((progress - delay) / (1.0 - delay), 0.0, 1.0);
40
+ // a pull then a fall that speeds up, long enough to leave the frame
41
+ float fall = (0.4 * t + 0.6 * t * t) * (1.0 + w * (0.5 + tilt)) * speed;
42
+ float angle = maxTilt * (2.0 * hash(i + 37.0) - 1.0) * t;
43
+ // the strips are cut apart as they start moving
44
+ float lift = min(1.0, 8.0 * t);
45
+ float gap = 0.06 * w * lift;
46
+ // position in the strip's own frame, relative to its center
47
+ vec2 v = q - vec2((i + 0.5) * w, 0.5 - fall);
48
+ float ca = cos(angle), sa = sin(angle);
49
+ vec2 l = vec2(ca * v.x + sa * v.y, ca * v.y - sa * v.x);
50
+ vec2 edge = vec2(0.5 * w - gap, 0.5) - abs(l);
51
+ // a soft shadow, cast down and right by the moving strip
52
+ vec2 so = abs(l - lift * vec2(0.15 * w, -0.25 * w)) - vec2(0.5 * w - gap, 0.5);
53
+ shade = max(shade, lift * (1.0 - smoothstep(0.0, 0.5 * w, max(so.x, so.y))));
54
+ if (min(edge.x, edge.y) >= 0.0 && fall > cover) {
55
+ vec2 p = vec2((i + 0.5) * w + l.x, 0.5 + l.y);
56
+ vec4 img = getFromColor(vec2(p.x / ratio, p.y));
57
+ // darker cut edges
58
+ float cut = lift * (1.0 - smoothstep(0.0, 0.25 * w, edge.x));
59
+ color = vec4(img.rgb * (1.0 - 0.5 * shadow * cut), img.a);
60
+ cover = fall;
61
+ }
62
+ }
63
+ if (cover < 0.0) {
64
+ color = vec4(color.rgb * (1.0 - 0.6 * shadow * shade), color.a);
65
+ }
66
+ return color;
67
+ }
@@ -0,0 +1,41 @@
1
+ // SpiralWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SpiralWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A spiral arm winds out from the center and widens to reveal the incoming image
5
+ // Tags: shape, wipe, radial
6
+
7
+ #define PI 3.141592653589793
8
+
9
+ // @range(2, 8) Number of turns of the spiral
10
+ uniform float turns; // = 3.0
11
+ // @range(0, 0.5) Softness of the arm's edges
12
+ uniform float smoothness; // = 0.05
13
+ // @param Wind clockwise; false winds counterclockwise
14
+ uniform bool clockwise; // = true
15
+
16
+ // Coverage of the arm turn at position s (in turns along the spiral), d away from its middle line
17
+ float arm (float s, float d) {
18
+ // The tip reaches the frame's corners at 60% of the transition, and the whole arm widens until the end
19
+ float end = -0.5 + (turns + 0.5) / 0.6;
20
+ float tip = mix(-0.5, end, progress);
21
+ s = max(s, -0.5);
22
+ float width = sqrt(clamp((tip - s) / max(end - s, 0.001), 0.0, 1.0));
23
+ // Edge softness in arm widths, at least a pixel wide
24
+ float e = smoothness + 0.005 * turns;
25
+ return smoothstep(0.0, e, width * (0.5 + e) - d);
26
+ }
27
+
28
+ vec4 transition (vec2 uv) {
29
+ // Square pixels, normalized so the frame's corners are at distance 1
30
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0) / (0.5 * length(vec2(ratio, 1.0)));
31
+ // Fraction of a turn, starting at the top
32
+ float a = dot(q, q) < 1e-12 ? 0.0 : atan(q.x, q.y) / (2.0 * PI);
33
+ a = fract(clockwise ? a : -a);
34
+ // Radius in turns of the spiral, and the arm turn the point is in
35
+ float w = length(q) * turns - a;
36
+ float n = floor(w);
37
+ float f = w - n;
38
+ // The arm turns around it can overlap it near the edges
39
+ float m = max(arm(n + a, abs(f - 0.5)), max(arm(n + 1.0 + a, 1.5 - f), arm(n - 1.0 + a, f + 0.5)));
40
+ return mix(getFromColor(uv), getToColor(uv), m);
41
+ }
@@ -0,0 +1,42 @@
1
+ // Tunnel — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Tunnel.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The camera flies down a tunnel lined with the outgoing image toward the incoming one, which opens at its far end and grows to fill the frame
5
+ // Tags: zoom, 3d, warp, radial
6
+
7
+ // @range(0.5, 10) How far and fast the camera flies down the tunnel
8
+ uniform float speed; // = 6.0
9
+ // @range(-2, 2) How much the walls spiral as they rush by
10
+ uniform float twist; // = 0.5
11
+
12
+ vec2 rotate(vec2 v, float a) {
13
+ float c = cos(a);
14
+ float s = sin(a);
15
+ return vec2(c * v.x - s * v.y, s * v.x + c * v.y);
16
+ }
17
+
18
+ vec4 transition(vec2 uv) {
19
+ vec2 aspect = vec2(ratio, 1.0);
20
+ vec2 c = (uv - 0.5) * aspect;
21
+ float r = length(c);
22
+ // A tube as wide as the frame's corners runs from the camera to an end wall
23
+ // at depth `far`; the outgoing image is projected onto it from the starting
24
+ // point of view, so it looks flat at first. The camera flies to one unit
25
+ // before the end wall, where the incoming image hangs.
26
+ float R = length(0.5 * aspect);
27
+ float far = 1.0 + speed;
28
+ // the distance to the end wall shrinks geometrically, so the end grows evenly
29
+ float e = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.7);
30
+ float d = pow(far, 1.0 - e);
31
+ float t = far - d; // distance flown
32
+ // the end wall covers the center of the view, the tube's walls the rest
33
+ float k = r * d < R ? d / far : R / (R + t * r); // image scale at that point
34
+ float a = twist * min(t * r / R, t / d); // spiral, continuous at the end wall
35
+ vec4 walls = getFromColor(0.5 + rotate(c * k, a) / aspect);
36
+ walls.rgb *= 0.4 + 0.6 * sqrt(k); // darker where the walls are close
37
+ // the incoming image opens in the end wall
38
+ float open = smoothstep(0.0, 0.6, progress);
39
+ vec2 q = 0.5 + (uv - 0.5) * d / max(open, 1e-4);
40
+ vec2 inside = step(0.0, q) * step(q, vec2(1.0));
41
+ return mix(walls, getToColor(q), inside.x * inside.y * step(r * d, R));
42
+ }
@@ -0,0 +1,43 @@
1
+ // TvRoll — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/TvRoll.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image rolls faster and faster, like an old TV losing its vertical hold, then the roll slows down and locks on the incoming image
5
+ // Tags: retro, vertical, scanlines
6
+
7
+ // @range(1, 8) Number of frames that roll by
8
+ uniform int rolls; // = 3
9
+ // @range(0, 0.5) Height of the bar between the frames
10
+ uniform float barHeight; // = 0.12
11
+ // @color Color of the bar between the frames
12
+ uniform vec4 barColor; // = vec4(0.0, 0.0, 0.0, 1.0)
13
+
14
+ // The rolling picture at a vertical position y, in frames of height 1 + barHeight
15
+ vec4 picture(vec2 uv, float y, float m) {
16
+ float period = 1.0 + barHeight;
17
+ y = mod(y, period);
18
+ if (y > 1.0) return barColor;
19
+ vec2 q = vec2(uv.x, y);
20
+ return mix(getFromColor(q), getToColor(q), m);
21
+ }
22
+
23
+ vec4 transition(vec2 uv) {
24
+ float period = 1.0 + barHeight;
25
+ // smooth start and stop: the picture locks again after a whole number of frames
26
+ float s = progress * progress * (3.0 - 2.0 * progress);
27
+ float offset = period * fract(float(rolls) * s);
28
+ float speed = 4.0 * progress * (1.0 - progress); // 0 at both ends, 1 in the middle
29
+ float m = smoothstep(0.42, 0.58, progress); // the channel changes at full speed
30
+ // the horizontal sync wobbles a little
31
+ vec2 p = uv + vec2(0.004 * speed * sin(uv.y * 9.0 + progress * 30.0), 0.0);
32
+ // vertical motion blur
33
+ vec4 c = vec4(0.0);
34
+ for (int i = 0; i < 5; i++) {
35
+ c += picture(p, p.y + offset - 0.0015 * float(rolls) * speed * float(i), m);
36
+ }
37
+ c /= 5.0;
38
+ // scanlines and a flickering brightness
39
+ float scan = 0.5 + 0.5 * sin(uv.y * 400.0);
40
+ float flicker = 0.08 * (0.5 + 0.5 * sin(progress * 97.0));
41
+ c.rgb *= 1.0 - speed * (0.08 * scan + flicker);
42
+ return c;
43
+ }
@@ -0,0 +1,47 @@
1
+ // TvTurnOff — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/TvTurnOff.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image collapses into a glowing line and a dot, like an old TV turned off, then the incoming image powers on from the dot
5
+ // Tags: retro, vertical, flash
6
+
7
+ // @color Color of the switched-off screen
8
+ uniform vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0)
9
+ // @range(0, 2) Strength of the glow around the line and the dot
10
+ uniform float glow; // = 1.0
11
+
12
+ vec4 getColor(vec2 uv, bool isFrom) {
13
+ return isFrom ? getFromColor(uv) : getToColor(uv);
14
+ }
15
+
16
+ // The screen at a time t of its power-off: 0 is the full image, 1 is off
17
+ vec4 screen(vec2 uv, float t, bool isFrom) {
18
+ float collapse = smoothstep(0.0, 0.4, t); // the image squeezes into a line
19
+ float shrink = smoothstep(0.3, 0.65, t); // the line shrinks into a dot
20
+ float fade = 0.4 * smoothstep(0.75, 1.0, t); // the dot dims
21
+ float radius = 0.01 * (1.0 - fade);
22
+ // half size of the picture, in height units (x is scaled by ratio)
23
+ vec2 size = vec2(mix(0.5 * ratio, radius, shrink), mix(0.5, radius, collapse));
24
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
25
+ vec2 q = clamp(0.5 + 0.5 * p / size, 0.0, 1.0);
26
+ vec4 c = getColor(q, isFrom);
27
+ // the squeezed picture gets brighter and burns to white
28
+ float white = smoothstep(0.4, 1.0, collapse);
29
+ vec4 light = vec4(mix(min(c.rgb * (1.0 + 2.0 * collapse), 1.0), vec3(1.0), white), c.a);
30
+ // soft edges, outside the picture so that t = 0 is the exact image
31
+ vec2 d = abs(p) - size;
32
+ float dist = length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
33
+ float inside = clamp(1.0 - dist / 0.004, 0.0, 1.0);
34
+ // a glow around the line, tinted by the center of the picture, then warm white around the dot
35
+ vec4 mid = getColor(vec2(0.5), isFrom);
36
+ vec4 halo = vec4(mix(mix(mid.rgb, vec3(1.0), 0.7), vec3(1.0, 0.92, 0.8), shrink), mid.a);
37
+ float h = 1.0 - exp(-2.0 * glow * white * exp(-max(dist, 0.0) / (0.02 + 0.04 * shrink)));
38
+ vec4 col = mix(color, halo, h * (1.0 - fade));
39
+ return mix(col, light, inside * (1.0 - fade));
40
+ }
41
+
42
+ vec4 transition(vec2 uv) {
43
+ if (progress < 0.5) {
44
+ return screen(uv, 2.0 * progress, true);
45
+ }
46
+ return screen(uv, 2.0 - 2.0 * progress, false);
47
+ }
@@ -0,0 +1,50 @@
1
+ // WhipPan — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/WhipPan.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A fast camera pan that streaks both images with motion blur, the incoming one arriving from the opposite side
5
+ // Tags: slide, motion-blur, directional
6
+
7
+ // @param Direction in which the images move
8
+ uniform vec2 direction; // = vec2(-1.0, 0.0)
9
+ // @range(0, 1) Length of the motion blur at full speed
10
+ uniform float blur; // = 0.4
11
+
12
+ const int SAMPLES = 24;
13
+
14
+ // The panned strip: the outgoing image, then the incoming one behind it
15
+ vec4 strip(vec2 q, vec2 d) {
16
+ vec2 qt = q + d;
17
+ // which side of the seam between the two images (works for diagonals too)
18
+ if (dot(q - 0.5, -d) < 0.5 * dot(d, d)) {
19
+ return getFromColor(clamp(q, 0.0, 1.0));
20
+ }
21
+ return getToColor(clamp(qt, 0.0, 1.0));
22
+ }
23
+
24
+ float rand(vec2 co) {
25
+ return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
26
+ }
27
+
28
+ vec4 transition(vec2 uv) {
29
+ vec2 d = sign(direction);
30
+ // ease in and out: slow start, whip in the middle, slow landing
31
+ float p = progress;
32
+ float h = 1.0 - abs(2.0 * p - 1.0); // 0 at both ends, 1 in the middle
33
+ // mostly cubic, with a bit of linear so that it starts moving at once
34
+ float e = 0.5 * h * (0.1 + 0.9 * h * h);
35
+ float pos = p < 0.5 ? e : 1.0 - e;
36
+ float len = blur * h * (0.1 + 2.7 * h * h) / 2.8; // follows the speed
37
+
38
+ vec2 q = uv - d * pos;
39
+ // average along the motion, jittered to hide the sample steps
40
+ float jitter = rand(uv);
41
+ vec3 color = vec3(0.0);
42
+ float alpha = 0.0;
43
+ for (int i = 0; i < SAMPLES; i++) {
44
+ float t = (float(i) + jitter) / float(SAMPLES) - 0.5;
45
+ vec4 c = strip(q + d * t * len, d);
46
+ color += c.rgb * c.a;
47
+ alpha += c.a;
48
+ }
49
+ return vec4(color / max(alpha, 1e-5), alpha / float(SAMPLES));
50
+ }