gl-transitions 2.3.0 → 2.5.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 (106) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/compatibility.json +308 -0
  3. package/gl-transitions.js +1 -1
  4. package/gl-transitions.json +1 -1
  5. package/glsl3/ArrowWipe.glsl +100 -0
  6. package/glsl3/BlockSlide.glsl +87 -0
  7. package/glsl3/CellDissolve.glsl +91 -0
  8. package/glsl3/ColorPanelWipe.glsl +75 -0
  9. package/glsl3/Crumple.glsl +173 -0
  10. package/glsl3/EyeBlink.glsl +83 -0
  11. package/glsl3/Gallery.glsl +133 -0
  12. package/glsl3/HeatHaze.glsl +79 -0
  13. package/glsl3/Hologram.glsl +97 -0
  14. package/glsl3/LiquidFill.glsl +102 -0
  15. package/glsl3/PlasmaDissolve.glsl +51 -0
  16. package/glsl3/RingsWipe.glsl +106 -0
  17. package/glsl3/SawtoothWipe.glsl +73 -0
  18. package/glsl3/SnakeBlockWipe.glsl +40 -0
  19. package/glsl3/Snapshot.glsl +86 -0
  20. package/glsl3/Sphere.glsl +95 -0
  21. package/glsl3/SpiralBlockWipe.glsl +65 -0
  22. package/glsl3/VhsTracking.glsl +127 -0
  23. package/glsl3/Vortex.glsl +106 -0
  24. package/index.js +1 -1
  25. package/layouts.json +787 -18
  26. package/llms-full.txt +675 -354
  27. package/llms.txt +204 -185
  28. package/msl/ArrowWipe.metal +391 -0
  29. package/msl/BlockSlide.metal +418 -0
  30. package/msl/CellDissolve.metal +374 -0
  31. package/msl/ColorPanelWipe.metal +314 -0
  32. package/msl/Crumple.metal +766 -0
  33. package/msl/EyeBlink.metal +355 -0
  34. package/msl/Gallery.metal +813 -0
  35. package/msl/HeatHaze.metal +320 -0
  36. package/msl/Hologram.metal +380 -0
  37. package/msl/LiquidFill.metal +373 -0
  38. package/msl/PlasmaDissolve.metal +178 -0
  39. package/msl/RingsWipe.metal +437 -0
  40. package/msl/SawtoothWipe.metal +310 -0
  41. package/msl/SnakeBlockWipe.metal +216 -0
  42. package/msl/Snapshot.metal +321 -0
  43. package/msl/Sphere.metal +345 -0
  44. package/msl/SpiralBlockWipe.metal +281 -0
  45. package/msl/VhsTracking.metal +514 -0
  46. package/msl/Vortex.metal +522 -0
  47. package/package.json +1 -1
  48. package/skills/gl-transitions/references/catalog.md +84 -38
  49. package/sksl/ArrowWipe.sksl +111 -0
  50. package/sksl/BlockSlide.sksl +99 -0
  51. package/sksl/CellDissolve.sksl +103 -0
  52. package/sksl/ColorPanelWipe.sksl +85 -0
  53. package/sksl/Crumple.sksl +179 -0
  54. package/sksl/EyeBlink.sksl +94 -0
  55. package/sksl/Gallery.sksl +139 -0
  56. package/sksl/HeatHaze.sksl +90 -0
  57. package/sksl/Hologram.sksl +108 -0
  58. package/sksl/LiquidFill.sksl +113 -0
  59. package/sksl/PlasmaDissolve.sksl +64 -0
  60. package/sksl/RingsWipe.sksl +115 -0
  61. package/sksl/SawtoothWipe.sksl +83 -0
  62. package/sksl/SnakeBlockWipe.sksl +53 -0
  63. package/sksl/Snapshot.sksl +98 -0
  64. package/sksl/Sphere.sksl +108 -0
  65. package/sksl/SpiralBlockWipe.sksl +76 -0
  66. package/sksl/VhsTracking.sksl +138 -0
  67. package/sksl/Vortex.sksl +116 -0
  68. package/sksl/index.js +1 -1
  69. package/transitions/ArrowWipe.glsl +99 -0
  70. package/transitions/BlockSlide.glsl +86 -0
  71. package/transitions/CellDissolve.glsl +90 -0
  72. package/transitions/ColorPanelWipe.glsl +74 -0
  73. package/transitions/Crumple.glsl +172 -0
  74. package/transitions/EyeBlink.glsl +82 -0
  75. package/transitions/Gallery.glsl +132 -0
  76. package/transitions/HeatHaze.glsl +78 -0
  77. package/transitions/Hologram.glsl +96 -0
  78. package/transitions/LiquidFill.glsl +101 -0
  79. package/transitions/PlasmaDissolve.glsl +50 -0
  80. package/transitions/RingsWipe.glsl +105 -0
  81. package/transitions/SawtoothWipe.glsl +72 -0
  82. package/transitions/SnakeBlockWipe.glsl +39 -0
  83. package/transitions/Snapshot.glsl +85 -0
  84. package/transitions/Sphere.glsl +94 -0
  85. package/transitions/SpiralBlockWipe.glsl +64 -0
  86. package/transitions/VhsTracking.glsl +126 -0
  87. package/transitions/Vortex.glsl +105 -0
  88. package/wgsl/ArrowWipe.wgsl +352 -0
  89. package/wgsl/BlockSlide.wgsl +384 -0
  90. package/wgsl/CellDissolve.wgsl +323 -0
  91. package/wgsl/ColorPanelWipe.wgsl +274 -0
  92. package/wgsl/Crumple.wgsl +709 -0
  93. package/wgsl/EyeBlink.wgsl +308 -0
  94. package/wgsl/Gallery.wgsl +741 -0
  95. package/wgsl/HeatHaze.wgsl +282 -0
  96. package/wgsl/Hologram.wgsl +339 -0
  97. package/wgsl/LiquidFill.wgsl +339 -0
  98. package/wgsl/PlasmaDissolve.wgsl +149 -0
  99. package/wgsl/RingsWipe.wgsl +394 -0
  100. package/wgsl/SawtoothWipe.wgsl +279 -0
  101. package/wgsl/SnakeBlockWipe.wgsl +188 -0
  102. package/wgsl/Snapshot.wgsl +287 -0
  103. package/wgsl/Sphere.wgsl +316 -0
  104. package/wgsl/SpiralBlockWipe.wgsl +250 -0
  105. package/wgsl/VhsTracking.wgsl +462 -0
  106. package/wgsl/Vortex.wgsl +463 -0
@@ -0,0 +1,100 @@
1
+ // ArrowWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ArrowWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A notched arrowhead window onto the incoming image flies in from the edge behind it (or appears at the center), then swells until it fills the frame
5
+ // Tags: shape, wipe, arrow, chevron, directional
6
+
7
+ // @param Direction the arrow points and flies toward
8
+ uniform vec2 direction; // = vec2(1.0, 0.0)
9
+ // @range(0, 0.9) Depth of the notch at the back of the arrowhead (0 for a plain triangle)
10
+ uniform float notch; // = 0.4
11
+ // @range(20, 160) Opening angle of the arrowhead's tip, in degrees
12
+ uniform float width; // = 80.0
13
+ // @range(1, 3, 1) Number of nested chevrons flying in a row
14
+ uniform int count; // = 1
15
+ // @param Grow the arrow from the center of the frame instead of flying it in
16
+ uniform bool origin; // = false
17
+ // @range(0, 0.1) Softness of the arrow's edges
18
+ uniform float smoothness; // = 0.004
19
+
20
+ // Signed distance (in frame heights) to an arrowhead whose tip is at x = tip and whose notch
21
+ // reaches back to x = back, in the arrow's frame (x along the direction, y = |across|)
22
+ float arrow(vec2 q, float tip, float back, vec2 tipN, vec2 notchN) {
23
+ float front = dot(vec2(q.x - tip, q.y), tipN);
24
+ float rear = dot(vec2(back - q.x, -q.y), notchN);
25
+ return max(front, rear);
26
+ }
27
+
28
+ vec4 transition(vec2 uv) {
29
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
30
+ vec2 across = vec2(-dir.y, dir.x);
31
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
32
+ vec2 q = vec2(dot(p, dir), abs(dot(p, across)));
33
+
34
+ float s = max(smoothness, 0.001);
35
+ float n = clamp(notch, 0.0, 0.9);
36
+ float h = radians(0.5 * clamp(width, 20.0, 160.0));
37
+ float cot = cos(h) / sin(h);
38
+ // outward normals of the tip's edges and of the notch's edges
39
+ vec2 tipN = vec2(sin(h), cos(h));
40
+ float notchLen = length(vec2(1.0, n * cot));
41
+ vec2 notchN = vec2(1.0, n * cot) / notchLen;
42
+ // how far the tip must pass a point for the soft edge to clear it
43
+ float tipPad = s / sin(h);
44
+
45
+ // The frame's corners in the arrow's frame
46
+ vec2 c1 = vec2(0.5 * ratio, 0.5);
47
+ vec2 c2 = vec2(0.5 * ratio, -0.5);
48
+ vec2 k1 = vec2(abs(dot(c1, dir)), abs(dot(c1, across)));
49
+ vec2 k2 = vec2(abs(dot(c2, dir)), abs(dot(c2, across)));
50
+ // half extent of the frame along the direction, and where its back edge crosses the axis
51
+ float e = max(k1.x, k2.x);
52
+ float r = 0.5 / max(abs(dir.x) / ratio, abs(dir.y));
53
+ // To cover the frame, the tip must be ahead of every corner, and the notch behind every
54
+ // corner and behind the back edge's middle (with room for the soft edge)
55
+ float tipMin = max(k1.x + k1.y * cot, k2.x + k2.y * cot) + tipPad;
56
+ float notchMax = min(min(n * cot * k1.y - k1.x, n * cot * k2.y - k2.x), -r) - s * notchLen;
57
+
58
+ // The arrow (length 1 from tip to barbs) turns around the middle of its axis: its tip is
59
+ // half its body ahead of that point, its notch half its body behind
60
+ float body = 0.5 * (1.0 - n);
61
+ // The scale at which the arrow centered on the frame covers it
62
+ float cover = max(tipMin, -notchMax) / body;
63
+
64
+ float t = progress;
65
+ float o; // middle of the arrow
66
+ float l; // size of the arrow
67
+ if (origin) {
68
+ o = 0.0;
69
+ l = cover * t * (0.4 + 0.6 * t);
70
+ } else {
71
+ // while it flies, its larger side (length or span) is about the frame's smaller side
72
+ float l0 = 0.92 * min(1.0, ratio) / max(1.0, 2.0 * tan(h));
73
+ // starts just behind the frame, flies to the middle, then swells
74
+ float o0 = -e - 2.0 * tipPad - body * l0;
75
+ // it is already moving when it enters, and slows down as it starts to swell
76
+ float u = 1.0 - clamp(t / 0.65, 0.0, 1.0);
77
+ float fly = 1.0 - u * u * u;
78
+ // the swell speeds up and still moves at the end, so the last corners do not linger
79
+ float grow = clamp((t - 0.3) / 0.7, 0.0, 1.0);
80
+ o = mix(o0, 0.0, fly);
81
+ l = mix(l0, cover, grow * grow * (2.0 - grow));
82
+ }
83
+
84
+ // the nested chevrons follow the first one, each tucked behind the previous one's notch
85
+ float gap = (1.0 - n) * 1.35;
86
+ float d = arrow(q, o + body * l, o - body * l, tipN, notchN);
87
+ for (int i = 1; i < 3; i++) {
88
+ if (i < count) {
89
+ float back = o - float(i) * gap * l;
90
+ d = min(d, arrow(q, back + body * l, back - body * l, tipN, notchN));
91
+ }
92
+ }
93
+ // the soft edge slides from outside the arrow to inside it, so nothing shows at the start
94
+ float m = 1.0 - smoothstep(-s, s, d + 2.0 * s * (1.0 - t));
95
+
96
+ vec4 a = getFromColor(uv);
97
+ vec4 b = getToColor(uv);
98
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
99
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
100
+ }
@@ -0,0 +1,87 @@
1
+ // BlockSlide — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BlockSlide.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The frame is cut into a grid of blocks that slide out one after another in a staggered cascade, some of them shrinking as they go, while the blocks of the incoming image slide in behind them to take their place
5
+ // Tags: slide, blocks, grid, directional, zoom
6
+
7
+ // @param Number of blocks (columns, rows), at most 40 along the direction
8
+ uniform ivec2 grid; // = ivec2(5, 4)
9
+ // @param Direction the blocks slide toward (rounded to the nearest axis)
10
+ uniform vec2 direction; // = vec2(1.0, 0.0)
11
+ // @range(0, 0.95) Share of the transition over which the blocks set off one after another (0 slides them all together)
12
+ uniform float stagger; // = 0.6
13
+ // @range(0, 0.9) How much the zooming blocks shrink on their way, as a share of their size
14
+ uniform float zoom; // = 0.35
15
+ // @color Color seen in the gaps between the blocks
16
+ uniform vec4 background; // = vec4(0.0, 0.0, 0.0, 1.0)
17
+
18
+ // blocks per strip, at most
19
+ const int MAX_BLOCKS = 40;
20
+
21
+ float hash(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
+ vec4 transition(vec2 uv) {
28
+ if (progress <= 0.0) return getFromColor(uv);
29
+ if (progress >= 1.0) return getToColor(uv);
30
+
31
+ bool vertical = abs(direction.y) > abs(direction.x);
32
+ bool backward = vertical ? direction.y < 0.0 : direction.x < 0.0;
33
+ vec2 g = max(vec2(grid), 1.0);
34
+ // a: position along the motion, toward which the blocks slide, b: across it
35
+ float a = vertical ? uv.y : uv.x;
36
+ float b = vertical ? uv.x : uv.y;
37
+ if (backward) a = 1.0 - a;
38
+ float n = min(vertical ? g.y : g.x, float(MAX_BLOCKS));
39
+ float strips = vertical ? g.x : g.y;
40
+ // every block of a strip slides along it, so a point can only show a block of its own strip
41
+ float r = min(floor(b * strips), strips - 1.0);
42
+ // the strips set off one after another, from the top (or the left)
43
+ float rowOrder = strips > 1.0 ? (vertical ? r : strips - 1.0 - r) / (strips - 1.0) : 0.0;
44
+ float st = clamp(stagger, 0.0, 0.95);
45
+ float z = clamp(zoom, 0.0, 0.9);
46
+ // in blocks
47
+ float an = a * n;
48
+ float bn = b * strips - r;
49
+
50
+ // the incoming blocks follow the last outgoing block to leave, the rear one: they all
51
+ // stay behind it, so no block ever overlaps another, and each one gets closer to the
52
+ // block ahead of it until they all arrive together
53
+ float rear = clamp((progress - st * mix(rowOrder, 1.0, 0.2)) / (1.0 - st), 0.0, 1.0);
54
+ rear = rear * rear * (3.0 - 2.0 * rear);
55
+
56
+ for (int k = 0; k < MAX_BLOCKS; k++) {
57
+ float i = float(k);
58
+ if (i >= n) break;
59
+ // the block at the front sets off first, so that the outgoing blocks move apart
60
+ float order = mix(rowOrder, n > 1.0 ? (n - 1.0 - i) / (n - 1.0) : 0.0, 0.2);
61
+ float p = clamp((progress - st * order) / (1.0 - st), 0.0, 1.0);
62
+ p = p * p * (3.0 - 2.0 * p);
63
+ float pin = max(0.0, 1.0 - (1.0 - rear) * (1.0 + (n - 1.0 - i) / n));
64
+ // about half of the blocks shrink as they leave, and their incoming blocks grow as they come
65
+ float zi = hash(vec2(i, r) + 3.7) < 0.5 ? z : 0.0;
66
+ // position in the block, from its corner, for the outgoing block (xy), which travels the
67
+ // frame's length to leave it, and the incoming one (zw), from one length behind; at rest,
68
+ // the blocks tile the frame exactly
69
+ float sFrom = 1.0 - zi * p * p;
70
+ float sTo = 1.0 - zi * (1.0 - pin) * (1.0 - pin);
71
+ vec4 l = vec4(
72
+ (an - i - p * n - 0.5 * (1.0 - sFrom)) / sFrom,
73
+ (bn - 0.5 * (1.0 - sFrom)) / sFrom,
74
+ (an - i - (pin - 1.0) * n - 0.5 * (1.0 - sTo)) / sTo,
75
+ (bn - 0.5 * (1.0 - sTo)) / sTo);
76
+ bool inFrom = all(greaterThanEqual(l.xy, vec2(0.0))) && all(lessThan(l.xy, vec2(1.0)));
77
+ bool inTo = all(greaterThanEqual(l.zw, vec2(0.0))) && all(lessThan(l.zw, vec2(1.0)));
78
+ if (inFrom || inTo) {
79
+ // back to the frame's coordinates
80
+ vec2 q = (vec2(i, r) + (inTo ? l.zw : l.xy)) / vec2(n, strips);
81
+ if (backward) q.x = 1.0 - q.x;
82
+ q = vertical ? q.yx : q;
83
+ return inTo ? getToColor(q) : getFromColor(q);
84
+ }
85
+ }
86
+ return background;
87
+ }
@@ -0,0 +1,91 @@
1
+ // CellDissolve — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CellDissolve.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Irregular cells, like cracked mud or soap foam, switch to the incoming image one by one, with an optional bright border glowing along the cracks between them
5
+ // Tags: dissolve, cells, voronoi, random
6
+
7
+ // @range(1, 40) Number of cells across the height of the frame
8
+ uniform float cells; // = 8.0
9
+ // @range(0, 1) Duration of each cell's switch, as a fraction of the transition (0: each cell switches at once)
10
+ uniform float smoothness; // = 0.1
11
+ // @range(0, 0.05) Width of the border along the cell edges, in frame heights (0: no border)
12
+ uniform float border; // = 0.006
13
+ // @color Color of the border
14
+ uniform vec4 borderColor; // = vec4(1.0, 0.95, 0.8, 1.0)
15
+ // @param Random seed: another value gives other cells, switching in another order
16
+ uniform float seed; // = 0.0
17
+
18
+ // half width of the antialiased edges, in frame heights
19
+ const float AA = 0.0015;
20
+
21
+ vec2 hash22(vec2 p) {
22
+ vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
23
+ p3 += dot(p3, p3.yzx + 33.33);
24
+ return fract((p3.xx + p3.yz) * p3.zy);
25
+ }
26
+
27
+ vec4 transition(vec2 uv) {
28
+ vec4 a = getFromColor(uv);
29
+ vec4 b = getToColor(uv);
30
+ if (progress <= 0.0) return a;
31
+ if (progress >= 1.0) return b;
32
+
33
+ float n = max(cells, 1.0);
34
+ // measured in square pixels, so the cells are not stretched
35
+ vec2 p = uv * vec2(ratio, 1.0) * n;
36
+ vec2 i = floor(p);
37
+ vec2 f = p - i;
38
+ vec2 offset = vec2(17.31, 41.97) * seed;
39
+
40
+ // nearest cell point
41
+ vec2 mg = vec2(0.0);
42
+ vec2 mr = vec2(0.0);
43
+ float md = 8.0;
44
+ for (int y = -1; y <= 1; y++) {
45
+ for (int x = -1; x <= 1; x++) {
46
+ vec2 g = vec2(float(x), float(y));
47
+ vec2 r = g + hash22(i + g + offset) - f;
48
+ float d = dot(r, r);
49
+ if (d < md) {
50
+ md = d;
51
+ mr = r;
52
+ mg = g;
53
+ }
54
+ }
55
+ }
56
+
57
+ // distance to the nearest cell edge: the bisector with the closest neighbor point,
58
+ // searched over 5x5 cells around the nearest one so that no edge is missed
59
+ float edge = 8.0;
60
+ for (int y = -2; y <= 2; y++) {
61
+ for (int x = -2; x <= 2; x++) {
62
+ vec2 g = mg + vec2(float(x), float(y));
63
+ vec2 r = g + hash22(i + g + offset) - f;
64
+ vec2 dr = r - mr;
65
+ if (dot(dr, dr) > 0.00001) {
66
+ edge = min(edge, dot(0.5 * (mr + r), normalize(dr)));
67
+ }
68
+ }
69
+ }
70
+ // in frame heights
71
+ edge /= n;
72
+
73
+ // the cell's own switch time, from its hash
74
+ float h = hash22(i + mg + offset + 97.13).x;
75
+ float w = clamp(smoothness, 0.0, 1.0);
76
+ float start = h * (1.0 - w);
77
+ float m = w > 0.0 ? smoothstep(start, start + w, progress) : step(start, progress);
78
+
79
+ // mixed premultiplied, so transparent images do not bleed their color
80
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
81
+
82
+ // the cracks open at the start and close at the end
83
+ float open = smoothstep(0.0, 0.2, progress) * (1.0 - smoothstep(0.8, 1.0, progress));
84
+ float bw = max(border, 0.0) * open;
85
+ if (bw > 0.0) {
86
+ float l = 1.0 - smoothstep(0.5 * bw - AA, 0.5 * bw + AA, edge);
87
+ float ba = borderColor.a * l * min(1.0, bw / (2.0 * AA));
88
+ c = vec4(borderColor.rgb * ba, ba) + c * (1.0 - ba);
89
+ }
90
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
91
+ }
@@ -0,0 +1,75 @@
1
+ // ColorPanelWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ColorPanelWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Solid color panels, slightly staggered, sweep across and cover the frame, then sweep off the far side and reveal the incoming image
5
+ // Tags: wipe, panels, color, slanted, motion-graphics
6
+
7
+ // @param Direction the panels sweep toward
8
+ uniform vec2 direction; // = vec2(1.0, 0.0)
9
+ // @range(1, 3, 1) Number of panels
10
+ uniform int panels; // = 3
11
+ // @color Color of the first panel
12
+ uniform vec4 color1; // = vec4(0.98, 0.76, 0.22, 1.0)
13
+ // @color Color of the second panel
14
+ uniform vec4 color2; // = vec4(0.93, 0.33, 0.36, 1.0)
15
+ // @color Color of the third panel
16
+ uniform vec4 color3; // = vec4(0.16, 0.2, 0.42, 1.0)
17
+ // @range(0, 1) Delay between the panels, relative to the sweep of one panel (at 0, they move as one and only the last shows)
18
+ uniform float stagger; // = 0.35
19
+ // @range(-1, 1) Slant of the panels' edges
20
+ uniform float skew; // = 0.25
21
+
22
+ // the frame is fully covered from cut - hold to cut + hold, where the image switches
23
+ const float cut = 0.46;
24
+ const float hold = 0.01;
25
+ // half width of the antialiased edges, in frame heights
26
+ const float aa = 0.0015;
27
+
28
+ // a short acceleration, a fast sweep, and a long settle
29
+ float ease(float t) {
30
+ float s = clamp(t, 0.0, 1.0);
31
+ float u = 1.0 - s * s * (3.0 - 2.0 * s);
32
+ return 1.0 - u * u * u;
33
+ }
34
+
35
+ // how much of x a panel between the edges back and front covers
36
+ float cover(float x, float back, float front) {
37
+ return smoothstep(back - aa, back + aa, x) * (1.0 - smoothstep(front - aa, front + aa, x));
38
+ }
39
+
40
+ vec4 transition(vec2 uv) {
41
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
42
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
43
+ float k = clamp(skew, -1.0, 1.0);
44
+ // position along the sweep, slanted across it, in frame heights across the edges
45
+ vec2 a = (dir + k * vec2(-dir.y, dir.x)) / sqrt(1.0 + k * k);
46
+ float x = dot(p, a);
47
+ // half extent of the frame along x
48
+ float e = 0.5 * (abs(a.x) * ratio + abs(a.y));
49
+ float start = -e - 2.0 * aa;
50
+ float span = 2.0 * (e + 2.0 * aa);
51
+
52
+ int n = panels < 1 ? 1 : panels > 3 ? 3 : panels;
53
+ float m = float(n - 1);
54
+ float st = clamp(stagger, 0.0, 1.0);
55
+ // durations of a panel's sweep in and out
56
+ vec2 d = vec2(cut - hold, 1.0 - cut - hold) / (1.0 + m * st);
57
+
58
+ // the first panel enters first and leaves last: the outgoing image is ahead of it, the incoming one behind it
59
+ // (both are sampled, so that no texture read sits in a branch that differs between pixels)
60
+ float front0 = start + span * ease(progress / d.x);
61
+ float back0 = start + span * ease((progress - 1.0 + d.y) / d.y);
62
+ vec4 c = mix(getToColor(uv), getFromColor(uv), step(0.5 * (front0 + back0), x));
63
+ c = mix(c, color1, cover(x, back0, front0));
64
+
65
+ // each next panel covers the ones before it, enters after them and leaves before them
66
+ for (int i = 1; i < 3; i++) {
67
+ if (i < n) {
68
+ vec2 t = float(i) * st * d;
69
+ float front = start + span * ease((progress - t.x) / d.x);
70
+ float back = start + span * ease((progress - 1.0 + d.y + t.y) / d.y);
71
+ c = mix(c, i == 1 ? color2 : color3, cover(x, back, front));
72
+ }
73
+ }
74
+ return c.a > 0.0 ? c : vec4(0.0);
75
+ }
@@ -0,0 +1,173 @@
1
+ // Crumple — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Crumple.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image crumples into a creased paper ball, shaded along its folds, which is then tossed away to reveal the incoming image
5
+ // Tags: paper, 3d, shrink, shadow
6
+
7
+ // @range(1, 32, 1) Number of folds creasing the paper
8
+ uniform int creases; // = 16
9
+ // @range(0.05, 0.4) Radius of the paper ball, relative to the image height
10
+ uniform float size; // = 0.2
11
+ // @param Direction the ball is tossed toward
12
+ uniform vec2 direction; // = vec2(1.0, 0.4)
13
+ // @color Color of the bare paper showing through the ink along the sharpest creases
14
+ uniform vec4 paper; // = vec4(0.96, 0.95, 0.91, 1.0)
15
+ // @color Color of the shadow cast on the incoming image
16
+ uniform vec4 shadow; // = vec4(0.0, 0.0, 0.0, 0.45)
17
+
18
+ const float PI = 3.14159265;
19
+
20
+ vec2 hash2(vec2 p) {
21
+ p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));
22
+ return fract(sin(p) * 43758.5453);
23
+ }
24
+
25
+ mat2 rot(float a) {
26
+ float s = sin(a);
27
+ float c = cos(a);
28
+ return mat2(c, -s, s, c);
29
+ }
30
+
31
+ // distance from the center to the edge of the frame in the direction a (unit vector)
32
+ float frame(vec2 a) {
33
+ return min(0.5 * ratio / max(abs(a.x), 1e-4), 0.5 / max(abs(a.y), 1e-4));
34
+ }
35
+
36
+ // distance from the center to the edge of the paper in the direction a (unit vector):
37
+ // the frame shrinking and buckling while it crumples (c), turning into a lumpy ball (k)
38
+ float outline(vec2 a, float c, float k, float radius) {
39
+ float rect = frame(a);
40
+ float th = atan(a.y, a.x);
41
+ float buckle = 0.03 + 0.05 * abs(sin(4.0 * th + 0.7)) + 0.03 * abs(sin(9.0 * th + 2.0)) + 0.015 * abs(sin(23.0 * th + 1.3));
42
+ // the ball is a polygon with irregular corners
43
+ float i = floor((th / (2.0 * PI) + 0.5) * 9.0);
44
+ float a0 = i * 2.0 * PI / 9.0 - PI;
45
+ float a1 = a0 + 2.0 * PI / 9.0;
46
+ vec2 v0 = vec2(cos(a0), sin(a0)) * (0.78 + 0.27 * hash2(vec2(mod(i, 9.0), 3.0)).x);
47
+ vec2 v1 = vec2(cos(a1), sin(a1)) * (0.78 + 0.27 * hash2(vec2(mod(i + 1.0, 9.0), 3.0)).x);
48
+ vec2 e = v1 - v0;
49
+ float ball = radius * (v0.x * e.y - v0.y * e.x) / (a.x * e.y - a.y * e.x);
50
+ return mix(rect * mix(1.0, 0.75, c) * (1.0 - c * buckle), ball, k);
51
+ }
52
+
53
+ // n straight creases of random position, orientation and length, in a space where the
54
+ // paper spans about [-span, span]; each one tilts the paper on its two sides (a sharp ridge
55
+ // or valley between flat facets) and swallows a strip of the image. They come one after
56
+ // another as c grows; px is the half width of a crease line, in the units of x.
57
+ void fold(vec2 x, float seed, int n, vec2 span, float len, float c, float px, float weight,
58
+ inout vec2 grad, inout vec2 shift, inout float valley, inout float ridge) {
59
+ float tilt = 2.0 / sqrt(float(n));
60
+ for (int i = 0; i < 32; i++) {
61
+ if (i >= n) break;
62
+ float fi = float(i);
63
+ vec2 h = hash2(vec2(fi, seed));
64
+ vec2 g = hash2(vec2(fi, seed + 11.8));
65
+ vec2 o = (h - 0.5) * 2.0 * span;
66
+ vec2 nrm = vec2(cos(2.0 * PI * g.x), sin(2.0 * PI * g.x));
67
+ float d = dot(x - o, nrm);
68
+ float along = dot(x - o, vec2(-nrm.y, nrm.x));
69
+ float l = len * (0.5 + g.y);
70
+ float start = 0.4 * fi / float(n);
71
+ float act = weight * smoothstep(start, start + 0.3, c) * (1.0 - smoothstep(0.5 * l, l, abs(along)));
72
+ float amp = (h.x > 0.5 ? 1.0 : -1.0) * (0.5 + 0.5 * h.y);
73
+ float side = d / (abs(d) + px);
74
+ grad += act * amp * side * nrm * tilt;
75
+ shift += act * 0.03 * side * nrm;
76
+ float line = 1.0 - smoothstep(0.0, 2.0 * px, abs(d));
77
+ if (amp < 0.0) valley += act * line;
78
+ else ridge += act * line * amp;
79
+ }
80
+ }
81
+
82
+ vec4 transition(vec2 uv) {
83
+ if (progress <= 0.0) return getFromColor(uv);
84
+ vec4 b = getToColor(uv);
85
+ if (progress >= 1.0) return b;
86
+
87
+ // crumpling (c), balling up (k), then tossing (t)
88
+ float c = smoothstep(0.0, 0.6, progress);
89
+ float k = smoothstep(0.1, 0.62, progress);
90
+ float t = smoothstep(0.58, 1.0, progress);
91
+ t *= t;
92
+
93
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
94
+ float radius = max(size, 0.01) * mix(1.0, 0.6, t);
95
+ // far enough along the direction for the ball and its shadow (offset and blurred by up
96
+ // to about 0.09 each) to leave the frame
97
+ float reach = 0.5 * (abs(dir.x) * ratio + abs(dir.y)) + 1.2 * radius + 0.3;
98
+ float bend = dir.x < 0.0 ? -1.0 : 1.0;
99
+ vec2 center = dir * reach * t + vec2(-dir.y, dir.x) * 0.15 * bend * sin(PI * t);
100
+ float angle = 0.6 * c - 5.0 * bend * t;
101
+ // how high the paper is above the incoming image
102
+ float lift = 0.012 * c + 0.06 * t;
103
+
104
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
105
+
106
+ // soft shadow on the incoming image
107
+ vec2 sp = rot(angle) * (p - center - vec2(0.6, -1.0) * lift);
108
+ float sl = length(sp);
109
+ float sd = sl - outline(sl > 1e-5 ? sp / sl : vec2(1.0, 0.0), c, k, radius);
110
+ float blur = 0.005 + 1.2 * lift;
111
+ vec4 col = vec4(mix(b.rgb, shadow.rgb, shadow.a * c * (1.0 - smoothstep(-blur, blur, sd))), b.a);
112
+
113
+ vec2 q = rot(angle) * (p - center);
114
+ float l = length(q);
115
+ vec2 dq = l > 1e-5 ? q / l : vec2(1.0, 0.0);
116
+ float edge = outline(dq, c, k, radius);
117
+ // the edge (about a pixel at 300 px high) is antialiased only once the sheet has left the
118
+ // borders of the frame
119
+ float aa = 0.003 * smoothstep(0.0, 0.1, progress) + 1e-5;
120
+ float inside = 1.0 - smoothstep(-aa, aa, l - edge);
121
+ if (inside <= 0.0) return col;
122
+
123
+ // back onto the flat sheet: the outline is mapped onto the frame, the middle of the ball
124
+ // holds more of it, as if the edges were tucked under
125
+ float r = l / edge;
126
+ float rect = frame(dq);
127
+ vec2 s = dq * rect * mix(r, r * (0.6 + 0.4 * r), k);
128
+
129
+ // the creases of the sheet, then those of the ball, that crumpling adds over them
130
+ int count = creases < 1 ? 1 : creases;
131
+ vec2 grad = vec2(0.0);
132
+ vec2 shift = vec2(0.0);
133
+ float valley = 0.0;
134
+ float ridge = 0.0;
135
+ fold(s, 7.3, count, 0.45 * vec2(ratio, 1.0), 0.6, c, 0.003 * rect / edge, 1.0 - 0.8 * k, grad, shift, valley, ridge);
136
+ vec2 g2 = vec2(0.0);
137
+ vec2 s2 = vec2(0.0);
138
+ float v2 = 0.0;
139
+ float r2 = 0.0;
140
+ fold(q / radius, 2.9, count, vec2(0.7), 8.0, k, 0.003 / radius, k, g2, s2, v2, r2);
141
+ grad += g2 * 0.8;
142
+ vec2 piece = s + shift + s2 * 3.0;
143
+
144
+ // the facets over the volume of the ball, lit from the top left (the light does not turn
145
+ // with the ball)
146
+ float rr = clamp(l / (radius * 1.1), 0.0, 1.0);
147
+ vec3 sphere = vec3(q / (radius * 1.1) * k * 0.8, sqrt(1.0 - 0.64 * rr * rr * k));
148
+ vec3 n = normalize(sphere + vec3(grad, 0.0));
149
+ n.xy = rot(-angle) * n.xy;
150
+ vec3 light = normalize(vec3(-0.5, 0.6, 0.8));
151
+ float diffuse = max(dot(n, light), 0.0);
152
+ vec3 hv = normalize(light + vec3(0.0, 0.0, 1.0));
153
+ // only what facets add over the flat sheet
154
+ float spec = max(pow(max(dot(n, hv), 0.0), 20.0) - pow(hv.z, 20.0), 0.0);
155
+ float level = light.z;
156
+ float relief = min(2.0 * c, 1.0);
157
+ float shade = 1.0 + relief * ((0.12 + diffuse) / (0.12 + level) - 1.0) + 0.7 * spec * relief;
158
+ shade -= 0.2 * relief * min(valley, 1.0);
159
+ // occlusion toward the rim of the ball
160
+ shade *= 1.0 - 0.3 * k * smoothstep(0.6, 1.0, r);
161
+
162
+ // the edges of the sheet that the folds pull in are mirrored, as if folded back
163
+ vec2 f = piece / vec2(ratio, 1.0) + 0.5;
164
+ vec4 img = getFromColor(1.0 - abs(1.0 - mod(f, 2.0)));
165
+ // the ink cracks along the ridges
166
+ img.rgb = mix(img.rgb, paper.rgb, 0.6 * min(ridge, 1.0) * paper.a * c);
167
+ vec4 ball = vec4(img.rgb * shade, img.a);
168
+
169
+ // mixed premultiplied, so transparent images do not bleed their color
170
+ float m = inside * ball.a;
171
+ vec4 o = vec4(mix(col.rgb * col.a, ball.rgb, m), mix(col.a, 1.0, m));
172
+ return o.a > 0.0 ? vec4(o.rgb / o.a, o.a) : vec4(0.0);
173
+ }
@@ -0,0 +1,83 @@
1
+ // EyeBlink — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/EyeBlink.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Curved eyelids close from the top and bottom over the outgoing image, which blurs and dims, then open on the incoming image as it comes back into focus, as if the viewer blinked
5
+ // Tags: blink, eye, blur, shape
6
+
7
+ // @range(0, 1) How much the image blurs and dims while the eyes are closed
8
+ uniform float blur; // = 0.5
9
+ // @range(0.01, 0.3) Width of the soft shadow along the rim of the eyelids
10
+ uniform float softness; // = 0.12
11
+ // @range(1, 2, 1) Number of blinks: 1, or 2 for a quick double blink (the cut happens on the first one)
12
+ uniform int blinks; // = 1
13
+ // @color Color of the eyelids
14
+ uniform vec4 color; // = vec4(0.03, 0.02, 0.02, 1.0)
15
+
16
+ const int TAPS = 16;
17
+ // how much the eyelids curve: the opening is widest at the center and the corners close first
18
+ const float CURVE = 0.25;
19
+ // where the eyelids meet, below the middle: the upper lid travels further than the lower one
20
+ const float MEET = 0.44;
21
+
22
+ vec2 mirror(vec2 v) {
23
+ return 1.0 - abs(1.0 - mod(v, 2.0));
24
+ }
25
+
26
+ // a blink fully closed at c (held for 2 * hold): the lids close over wc before it
27
+ // and open over wo after it, slower, like a real blink
28
+ float lidBlink(float t, float c, float wc, float wo, float hold) {
29
+ return 1.0 - smoothstep(hold, t < c ? wc : wo, abs(t - c));
30
+ }
31
+
32
+ vec4 image(vec2 uv, bool incoming) {
33
+ vec4 c = incoming ? getToColor(uv) : getFromColor(uv);
34
+ return vec4(c.rgb * c.a, c.a);
35
+ }
36
+
37
+ vec4 transition(vec2 uv) {
38
+ bool two = blinks > 1;
39
+ // the moment the eyes are fully closed, when the images are swapped
40
+ float cut = two ? 0.3 : 0.42;
41
+ // how closed the eyes are: 0 open, 1 closed
42
+ float closed = two
43
+ ? max(lidBlink(progress, cut, 0.26, 0.26, 0.015), lidBlink(progress, 0.7, 0.14, 0.24, 0.01))
44
+ : lidBlink(progress, cut, 0.36, 0.5, 0.02);
45
+ bool incoming = progress >= cut;
46
+
47
+ // the rim of each eyelid is an arc; fully open, even its corners clear the frame by the widest shadow
48
+ float soft = clamp(softness, 0.001, 0.3);
49
+ float x = 2.0 * uv.x - 1.0;
50
+ float rim = (1.0 - closed) * (1.31 + CURVE) - CURVE * x * x;
51
+ // distance inside the opening from the nearest lid, as a share of that lid's travel
52
+ float y = uv.y - MEET;
53
+ float d = rim - max(y / (1.0 - MEET), -y / MEET);
54
+ // the lid fills beyond its rim, with a soft shadow falling inside the opening
55
+ float s = 1.0 - smoothstep(0.0, soft, d);
56
+ float lid = s * s;
57
+ if (lid >= 1.0) return color;
58
+
59
+ // how out of focus and dim the view is: it peaks at the cut, follows the lids, and clears at both ends
60
+ float f = progress < cut ? progress / cut : (1.0 - progress) / (1.0 - cut);
61
+ f = clamp(f, 0.0, 1.0);
62
+ f = max(f * (2.0 - f), closed) * blur;
63
+
64
+ vec4 c;
65
+ if (f <= 0.0) {
66
+ c = incoming ? getToColor(uv) : getFromColor(uv);
67
+ } else {
68
+ // a disc of taps along a golden-angle spiral, premultiplied
69
+ float r = 0.025 * f;
70
+ c = vec4(0.0);
71
+ for (int i = 0; i < TAPS; i++) {
72
+ float k = float(i) + 0.5;
73
+ float a = 2.39996 * k;
74
+ vec2 o = sqrt(k / float(TAPS)) * vec2(cos(a), sin(a)) * r;
75
+ c += image(mirror(uv + o * vec2(1.0 / ratio, 1.0)), incoming);
76
+ }
77
+ c /= float(TAPS);
78
+ c = c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
79
+ // less light reaches the eye as it closes
80
+ c.rgb *= 1.0 - 0.35 * f;
81
+ }
82
+ return mix(c, color, lid);
83
+ }