gl-transitions 3.1.0 → 3.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 (106) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/compatibility.json +306 -0
  3. package/gl-transitions.js +1 -1
  4. package/gl-transitions.json +1 -1
  5. package/glsl3/CardDeal.glsl +146 -0
  6. package/glsl3/CircleBurst.glsl +77 -0
  7. package/glsl3/CodeRain.glsl +114 -0
  8. package/glsl3/CurtainRise.glsl +71 -0
  9. package/glsl3/EchoSlide.glsl +93 -0
  10. package/glsl3/GeometricCollage.glsl +241 -0
  11. package/glsl3/GravityLens.glsl +66 -0
  12. package/glsl3/HingedSquares.glsl +121 -0
  13. package/glsl3/HorizontalHold.glsl +62 -0
  14. package/glsl3/LayoutGrid.glsl +147 -0
  15. package/glsl3/ProjectorThrow.glsl +75 -0
  16. package/glsl3/Reassemble.glsl +156 -0
  17. package/glsl3/RingSpin.glsl +112 -0
  18. package/glsl3/Shockwave.glsl +103 -0
  19. package/glsl3/ShoreWash.glsl +150 -0
  20. package/glsl3/ShutterWipe.glsl +68 -0
  21. package/glsl3/SpotlightWipe.glsl +63 -0
  22. package/glsl3/StopMotion.glsl +118 -0
  23. package/glsl3/Vaporize.glsl +125 -0
  24. package/index.js +1 -1
  25. package/layouts.json +725 -1
  26. package/llms-full.txt +734 -422
  27. package/llms.txt +238 -219
  28. package/msl/CardDeal.metal +539 -0
  29. package/msl/CircleBurst.metal +351 -0
  30. package/msl/CodeRain.metal +451 -0
  31. package/msl/CurtainRise.metal +263 -0
  32. package/msl/EchoSlide.metal +438 -0
  33. package/msl/GeometricCollage.metal +1188 -0
  34. package/msl/GravityLens.metal +236 -0
  35. package/msl/HingedSquares.metal +564 -0
  36. package/msl/HorizontalHold.metal +286 -0
  37. package/msl/LayoutGrid.metal +544 -0
  38. package/msl/ProjectorThrow.metal +313 -0
  39. package/msl/Reassemble.metal +667 -0
  40. package/msl/RingSpin.metal +474 -0
  41. package/msl/Shockwave.metal +256 -0
  42. package/msl/ShoreWash.metal +538 -0
  43. package/msl/ShutterWipe.metal +286 -0
  44. package/msl/SpotlightWipe.metal +217 -0
  45. package/msl/StopMotion.metal +551 -0
  46. package/msl/Vaporize.metal +462 -0
  47. package/package.json +1 -1
  48. package/skills/gl-transitions/references/catalog.md +94 -44
  49. package/sksl/CardDeal.sksl +156 -0
  50. package/sksl/CircleBurst.sksl +84 -0
  51. package/sksl/CodeRain.sksl +124 -0
  52. package/sksl/CurtainRise.sksl +84 -0
  53. package/sksl/EchoSlide.sksl +99 -0
  54. package/sksl/GeometricCollage.sksl +242 -0
  55. package/sksl/GravityLens.sksl +77 -0
  56. package/sksl/HingedSquares.sksl +124 -0
  57. package/sksl/HorizontalHold.sksl +74 -0
  58. package/sksl/LayoutGrid.sksl +156 -0
  59. package/sksl/ProjectorThrow.sksl +85 -0
  60. package/sksl/Reassemble.sksl +166 -0
  61. package/sksl/RingSpin.sksl +121 -0
  62. package/sksl/Shockwave.sksl +116 -0
  63. package/sksl/ShoreWash.sksl +159 -0
  64. package/sksl/ShutterWipe.sksl +80 -0
  65. package/sksl/SpotlightWipe.sksl +74 -0
  66. package/sksl/StopMotion.sksl +126 -0
  67. package/sksl/Vaporize.sksl +134 -0
  68. package/sksl/index.js +1 -1
  69. package/transitions/CardDeal.glsl +145 -0
  70. package/transitions/CircleBurst.glsl +76 -0
  71. package/transitions/CodeRain.glsl +113 -0
  72. package/transitions/CurtainRise.glsl +70 -0
  73. package/transitions/EchoSlide.glsl +92 -0
  74. package/transitions/GeometricCollage.glsl +240 -0
  75. package/transitions/GravityLens.glsl +65 -0
  76. package/transitions/HingedSquares.glsl +120 -0
  77. package/transitions/HorizontalHold.glsl +61 -0
  78. package/transitions/LayoutGrid.glsl +146 -0
  79. package/transitions/ProjectorThrow.glsl +74 -0
  80. package/transitions/Reassemble.glsl +155 -0
  81. package/transitions/RingSpin.glsl +111 -0
  82. package/transitions/Shockwave.glsl +102 -0
  83. package/transitions/ShoreWash.glsl +149 -0
  84. package/transitions/ShutterWipe.glsl +67 -0
  85. package/transitions/SpotlightWipe.glsl +62 -0
  86. package/transitions/StopMotion.glsl +117 -0
  87. package/transitions/Vaporize.glsl +124 -0
  88. package/wgsl/CardDeal.wgsl +496 -0
  89. package/wgsl/CircleBurst.wgsl +310 -0
  90. package/wgsl/CodeRain.wgsl +415 -0
  91. package/wgsl/CurtainRise.wgsl +235 -0
  92. package/wgsl/EchoSlide.wgsl +386 -0
  93. package/wgsl/GeometricCollage.wgsl +1075 -0
  94. package/wgsl/GravityLens.wgsl +206 -0
  95. package/wgsl/HingedSquares.wgsl +506 -0
  96. package/wgsl/HorizontalHold.wgsl +243 -0
  97. package/wgsl/LayoutGrid.wgsl +495 -0
  98. package/wgsl/ProjectorThrow.wgsl +274 -0
  99. package/wgsl/Reassemble.wgsl +609 -0
  100. package/wgsl/RingSpin.wgsl +426 -0
  101. package/wgsl/Shockwave.wgsl +226 -0
  102. package/wgsl/ShoreWash.wgsl +492 -0
  103. package/wgsl/ShutterWipe.wgsl +252 -0
  104. package/wgsl/SpotlightWipe.wgsl +186 -0
  105. package/wgsl/StopMotion.wgsl +496 -0
  106. package/wgsl/Vaporize.wgsl +420 -0
@@ -0,0 +1,145 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The incoming image is dealt onto the frame like a hand of cards: tile after tile is flicked from below the frame, spinning through the air with a lifting shadow, and slides to a stop in its place until the picture is complete
4
+ // Tags: tiles, card, rotate, shadow, 3d
5
+
6
+ // @param Number of cards (columns, rows), at most 6 by 6
7
+ uniform ivec2 grid; // = ivec2(4, 3)
8
+ // @param Point the cards are dealt from, can be outside the frame
9
+ uniform vec2 deck; // = vec2(0.5, -0.4)
10
+ // @range(0, 2) Turns a card makes on its way, before it settles straight
11
+ uniform float spin; // = 0.6
12
+ // @range(0, 1) Darkness of the shadows the cards cast
13
+ uniform float shadow; // = 0.5
14
+
15
+ const float PI = 3.141592653589793;
16
+ const int MAX_CARDS = 36;
17
+ // time between two cards, relative to the time a card takes from the deck to its place
18
+ const float DEAL = 0.16;
19
+ // part of its way after which a card touches down and starts sliding
20
+ const float TOUCH = 0.55;
21
+ // speed of the throw, relative to an even pace
22
+ const float THROW = 2.2;
23
+ // length of the slide, in card heights
24
+ const float SLIDE = 0.35;
25
+ // highest point of a card's flight, and distance of the eye to the table, in frame heights
26
+ const float LIFT = 0.45;
27
+ const float EYE = 2.4;
28
+ // width of the anti-aliased edges, in frame heights
29
+ const float EDGE = 0.0015;
30
+
31
+ float hash(float n) {
32
+ vec2 p = fract(vec2(n) * vec2(0.1031, 0.1030));
33
+ p += dot(p, p.yx + 33.33);
34
+ return fract((p.x + p.y) * p.x);
35
+ }
36
+
37
+ vec2 gridSize() {
38
+ return clamp(vec2(grid), 1.0, 6.0);
39
+ }
40
+
41
+ // local time of card j: 0 on the deck, 1 once it lies still in its place
42
+ float cardTime(float j, float n) {
43
+ // the last card lands at the end
44
+ float flight = 1.0 / (1.0 + (n - 1.0) * DEAL);
45
+ return clamp((progress - j * DEAL * flight) / flight, 0.0, 1.0);
46
+ }
47
+
48
+ // center of the place of card j, dealt in reading order from the top left
49
+ vec2 cardCell(float j, vec2 g) {
50
+ float row = floor(j / g.x);
51
+ return vec2(j - row * g.x, g.y - 1.0 - row);
52
+ }
53
+
54
+ // signed distance to the edge of a card (positive inside), from its local coordinates q (0..1) and its size
55
+ float cardDist(vec2 q, vec2 size) {
56
+ vec2 e = min(q, 1.0 - q) * size;
57
+ return min(e.x, e.y);
58
+ }
59
+
60
+ vec4 transition(vec2 uv) {
61
+ if (progress <= 0.0) return getFromColor(uv);
62
+ if (progress >= 1.0) return getToColor(uv);
63
+
64
+ vec2 g = gridSize();
65
+ float n = g.x * g.y;
66
+ vec2 asp = vec2(ratio, 1.0);
67
+ vec2 size = asp / g;
68
+ vec2 p = uv * asp;
69
+ vec2 origin = deck * asp;
70
+ float darkness = clamp(shadow, 0.0, 1.0);
71
+
72
+ // the table: the cards already in their place, the outgoing image elsewhere
73
+ vec2 own = min(floor(uv * g), g - 1.0);
74
+ float ownIndex = (g.y - 1.0 - own.y) * g.x + own.x;
75
+ vec4 col = cardTime(ownIndex, n) >= 1.0 ? getToColor(uv) : getFromColor(uv);
76
+
77
+ // the cards on their way, from the first dealt to the last: later cards lie on top
78
+ for (int i = 0; i < MAX_CARDS; i++) {
79
+ float j = float(i);
80
+ if (j >= n) break;
81
+ float u = cardTime(j, n);
82
+ if (u <= 0.0) break;
83
+ if (u >= 1.0) continue;
84
+
85
+ vec2 cell = cardCell(j, g);
86
+ vec2 target = (cell + 0.5) * size;
87
+ vec2 way = target - origin;
88
+ float len = max(length(way), 1e-3);
89
+ vec2 side = vec2(-way.y, way.x);
90
+ float r1 = hash(j + 1.0);
91
+ float r2 = hash(j + 60.0);
92
+ float turn = r2 < 0.5 ? -1.0 : 1.0;
93
+ // share of its way the card slides on the table once it has touched down
94
+ float slide = min(SLIDE * size.y / len, 0.5);
95
+ // thrown fast, it flies (a), touches down and slides to a stop (s), braked by the table
96
+ float a = min(u / TOUCH, 1.0);
97
+ float s = clamp((u - TOUCH) / (1.0 - TOUCH), 0.0, 1.0);
98
+ // the flight ends at the speed the slide starts with
99
+ float v1 = 2.0 * slide * TOUCH / ((1.0 - TOUCH) * (1.0 - slide));
100
+ float f = (3.0 - 2.0 * a) * a * a + THROW * (a * a * a - 2.0 * a * a + a) + v1 * (a * a * a - a * a);
101
+ float e = u < TOUCH ? (1.0 - slide) * f : 1.0 - slide * (1.0 - s) * (1.0 - s);
102
+ // a slight curve, bending the way the card spins
103
+ vec2 c = origin + way * e + side * turn * (0.05 + 0.05 * r1) * sin(PI * e);
104
+ // height above the table, zero from the touch down on
105
+ float h = LIFT * (0.7 + 0.3 * r1) * sin(PI * a) * (1.0 - 0.35 * a);
106
+ float angle = turn * spin * (0.8 + 0.4 * r2) * 2.0 * PI * (1.0 - e);
107
+ // tilt of the card in the air, which wobbles as it spins
108
+ float tilt = 0.45 * sin(PI * a) * cos(angle * 0.5 + 6.0 * r1);
109
+ // 1 in the air, 0 once on the table
110
+ float air = 1.0 - a * a;
111
+ float fade = smoothstep(0.0, 0.05, u);
112
+
113
+ // shadow on the table, pushed away from the light and softened with height
114
+ vec2 sp = p - c - vec2(0.18, -0.3) * h - vec2(0.002, -0.003);
115
+ float ca = cos(angle), sa = sin(angle);
116
+ mat2 rot = mat2(ca, -sa, sa, ca);
117
+ vec2 sq = rot * sp / size + 0.5;
118
+ float soft = 0.006 + 0.08 * h;
119
+ float sh = smoothstep(-soft, soft, cardDist(sq, size));
120
+ // dark under a card in the air, a thin contact shadow fading as it comes to rest
121
+ float dark = mix(0.8 * (1.0 - s), 0.65 - 0.3 * h / LIFT, air);
122
+ col.rgb *= 1.0 - fade * darkness * dark * sh;
123
+
124
+ // the card, closer to the eye as it rises, seen in perspective as it tilts
125
+ vec2 d = rot * (p - c) * (EYE - h) / EYE;
126
+ float ct = cos(tilt), st = sin(tilt);
127
+ // past the horizon of the tilted card, the point is off the card
128
+ float den = EYE * ct + d.y * st;
129
+ float k = den > 1e-3 ? EYE * ct / den : 1e3;
130
+ vec2 q = vec2(k * d.x, k * d.y * ct + EYE * (1.0 - k) * st) / size + 0.5;
131
+ // its edges sharpen as it comes to rest, to meet its neighbors without a seam
132
+ float edge = EDGE * (1.0 + 2.0 * air) * min(10.0 * (1.0 - s), 1.0);
133
+ float m = fade * clamp(cardDist(q, size) / max(edge, 1e-6) + 0.5, 0.0, 1.0);
134
+ if (m > 0.0) {
135
+ vec4 face = getToColor((cell + clamp(q, 0.0, 1.0)) / g);
136
+ // light from the upper left: a tilted card catches it or turns away from it
137
+ float light = 1.0 + 0.6 * st * (0.6 - 0.4 * turn * sin(angle));
138
+ // a thin bright rim while it travels
139
+ float rim = 1.0 - smoothstep(0.0, 0.008, cardDist(q, size));
140
+ face.rgb = mix(min(face.rgb * light, vec3(face.a)), vec3(face.a), 0.45 * air * rim);
141
+ col = mix(col, face, m);
142
+ }
143
+ }
144
+ return col;
145
+ }
@@ -0,0 +1,76 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: Discs of three solid colors burst out of a point one after another, each covering the last, then a hole bursts open from the same point in the last one to reveal the incoming image
4
+ // Tags: circle, burst, color, reveal, motion-graphics
5
+
6
+ // @param Point the discs burst out of, in texture coordinates
7
+ uniform vec2 center; // = vec2(0.5, 0.5)
8
+ // @color Color of the first disc
9
+ uniform vec4 color1; // = vec4(0.99, 0.79, 0.29, 1.0)
10
+ // @color Color of the second disc
11
+ uniform vec4 color2; // = vec4(0.95, 0.38, 0.33, 1.0)
12
+ // @color Color of the third disc, which opens onto the incoming image
13
+ uniform vec4 color3; // = vec4(0.13, 0.15, 0.3, 1.0)
14
+ // @range(0, 1) Delay between the discs, relative to the burst of one disc (at 0, they burst as one: a single circle opens onto the incoming image)
15
+ uniform float stagger; // = 0.3
16
+
17
+ // half width of the antialiased edges, in frame heights
18
+ const float AA = 0.0015;
19
+ // width and opacity of the soft shadow each disc casts on what is under it
20
+ const float SW = 0.03;
21
+ const float SO = 0.32;
22
+
23
+ // local progress of a layer starting at s and lasting d
24
+ float phase(float s, float d) {
25
+ return clamp((progress - s) / d, 0.0, 1.0);
26
+ }
27
+
28
+ // radius of the edge of a layer at local progress t: it bursts out of just before the point and
29
+ // leaves the frame still moving, its shadow last
30
+ float radius(float t, float R) {
31
+ float u = 1.0 - t;
32
+ return mix(-SW - AA, R, mix(t, 1.0 - u * u * u, 0.8));
33
+ }
34
+
35
+ // fold texture coordinates back into the frame
36
+ vec2 mirror(vec2 v) {
37
+ return 1.0 - abs(1.0 - mod(abs(v), 2.0));
38
+ }
39
+
40
+ // a layer of color c and radius r laid over p (premultiplied), with its shadow around it, at distance x
41
+ vec4 layer(vec4 p, vec4 c, float r, float x) {
42
+ float k = smoothstep(r - AA, r + AA, x);
43
+ float s = SO * c.a * k * (1.0 - smoothstep(0.0, SW, x - r));
44
+ p = p * (1.0 - s) + vec4(0.0, 0.0, 0.0, s);
45
+ k = c.a * (1.0 - k);
46
+ return p * (1.0 - k) + vec4(c.rgb, 1.0) * k;
47
+ }
48
+
49
+ vec4 transition(vec2 uv) {
50
+ vec2 asp = vec2(ratio, 1.0);
51
+ float x = length((uv - center) * asp);
52
+ // past the farthest corner, with room for the shadows
53
+ float R = length(max(center, 1.0 - center) * asp) + SW + AA;
54
+ float k = clamp(stagger, 0.0, 1.0);
55
+ float d = 1.0 / (1.0 + 3.0 * k);
56
+
57
+ // the outgoing image is pushed in by the first burst
58
+ float t = phase(0.0, d);
59
+ vec4 a = getFromColor(mirror(center + (uv - center) / (1.0 + 0.06 * t * (2.0 - t))));
60
+ vec4 p = vec4(a.rgb * a.a, a.a);
61
+ p = layer(p, color1, radius(t, R), x);
62
+ p = layer(p, color2, radius(phase(k * d, d), R), x);
63
+ float r = radius(phase(2.0 * k * d, d), R);
64
+ p = layer(p, color3, r, x);
65
+
66
+ // the hole in the last disc shows the incoming image, which pops in slightly zoomed, overshoots
67
+ // and settles, shaded along the hole's rim as much as the disc around it is wide
68
+ t = phase(3.0 * k * d, d);
69
+ float h = radius(t, R);
70
+ float u = 1.0 - t;
71
+ vec4 b = getToColor(mirror(center + (uv - center) / (1.0 + 0.14 * u * u * (1.0 - 2.4 * t))));
72
+ float s = SO * color3.a * clamp((r - h) / SW, 0.0, 1.0) * (1.0 - smoothstep(0.0, SW, h - x));
73
+ vec4 q = vec4(b.rgb * b.a * (1.0 - s), b.a * (1.0 - s) + s);
74
+ p = mix(p, q, 1.0 - smoothstep(h - AA, h + AA, x));
75
+ return p.a > 0.0 ? vec4(p.rgb / p.a, p.a) : vec4(0.0);
76
+ }
@@ -0,0 +1,113 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image darkens into a grid of flickering code characters tinted by its colors, then glowing streams of characters fall down the columns at their own speeds, each with a bright head and a fading tail, leaving the incoming image behind
4
+ // Tags: text, digital, rain, reveal
5
+
6
+ // @range(0.02, 0.1) Height of a character, in frame heights
7
+ uniform float cellSize; // = 0.045
8
+ // @range(0.05, 1) Average length of the streams' fading tails, in frame heights
9
+ uniform float trail; // = 0.5
10
+ // @range(0, 1) How much the characters of the outgoing image take its colors, instead of the glow color
11
+ uniform float tint; // = 0.5
12
+ // @color Color of the falling streams and their glow
13
+ uniform vec4 glow; // = vec4(0.2, 1.0, 0.4, 1.0)
14
+
15
+ float hash12(vec2 p) {
16
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
17
+ p3 += dot(p3, p3.yzx + 33.33);
18
+ return fract((p3.x + p3.y) * p3.z);
19
+ }
20
+
21
+ vec4 hash42(vec2 p) {
22
+ vec4 p4 = fract(vec4(p.xyxy) * vec4(0.1031, 0.1030, 0.0973, 0.1099));
23
+ p4 += dot(p4, p4.wzxy + 33.33);
24
+ return fract((p4.xxyz + p4.yzzw) * p4.zywx);
25
+ }
26
+
27
+ // 1 inside a stroke, fading out from 0.3 to 0.6 dot of distance
28
+ vec4 band(vec4 d) {
29
+ return 1.0 - smoothstep(0.3, 0.6, d);
30
+ }
31
+
32
+ // coverage of the character of this cell at this time, drawn on a 5x7 dot grid in a 6x8 cell
33
+ // (local: 0..1 in the cell, from its top left), made of strokes picked by hashes
34
+ float glyph(vec2 cell, float t, vec2 local) {
35
+ vec2 b = local * vec2(6.0, 8.0) - 0.5;
36
+ float x = b.x;
37
+ float y = b.y;
38
+ float d = 0.667 * y;
39
+ // how far outside the spans 0..4, 0..6, 0..3 and 3..6, in dots
40
+ float x04 = abs(x - 2.0) - 2.0;
41
+ float y06 = abs(y - 3.0) - 3.0;
42
+ float y03 = abs(y - 1.5) - 1.5;
43
+ float y36 = abs(y - 4.5) - 1.5;
44
+ vec2 seed = cell + t * vec2(37.0, 61.0);
45
+ // strokes: three bars and a diagonal, the halves of the side verticals,
46
+ // the halves of the middle vertical, the other diagonal and a short bar
47
+ vec4 sa = band(abs(vec4(y, y - 3.0, y - 6.0, x - d))) * band(vec4(x04, x04, x04, y06));
48
+ vec4 sb = band(abs(vec4(x, x, x - 4.0, x - 4.0))) * band(vec4(y03, y36, y03, y36));
49
+ vec4 sc = band(abs(vec4(x - 2.0, x - 2.0, x + d - 4.0, y - 1.0))) * band(vec4(y03, y36, y06, abs(x - 2.0) - 1.0));
50
+ float on = dot(step(0.68, hash42(seed)), sa);
51
+ on += dot(step(0.68, hash42(seed + 41.0)), sb);
52
+ on += dot(step(0.68, hash42(seed + 83.0)), sc);
53
+ return min(on, 1.0);
54
+ }
55
+
56
+ vec4 transition(vec2 uv) {
57
+ float h = max(cellSize, 0.005);
58
+ vec2 dims = vec2(0.75 * h, h);
59
+ // frame coordinates from the top left, in frame heights
60
+ vec2 fp = vec2(uv.x * ratio, 1.0 - uv.y);
61
+ // (shifted by odd fractions of a cell, so that pixel centers don't fall on its lines at usual sizes)
62
+ vec2 grid = fp / dims + vec2(0.389, 0.278);
63
+ vec2 cell = floor(grid);
64
+ vec2 local = grid - cell;
65
+ float rc = hash12(cell + vec2(97.0, 131.0));
66
+
67
+ // each column has its own stream: its start, speed and tail length
68
+ float r1 = hash12(vec2(cell.x, 11.0));
69
+ float r2 = hash12(vec2(cell.x, 23.0));
70
+ float r3 = hash12(vec2(cell.x, 37.0));
71
+ float T = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.5);
72
+ float len = max(trail, 0.01) * (0.5 + r3);
73
+ float u = clamp((T - 0.03 - 0.5 * r1) / (0.3 + 0.12 * r2), 0.0, 1.0);
74
+ // the head falls from above the frame, speeding up a little, until its tail has left the frame
75
+ float head = mix(-0.2, 1.0 + h + len, u * (0.7 + 0.3 * u));
76
+ // how far the head has gone past the cell's top
77
+ float dy = head - (cell.y - 0.278) * h;
78
+
79
+ vec4 a = getFromColor(uv);
80
+ vec4 b = getToColor(uv);
81
+
82
+ // ahead of the stream: the outgoing image darkens into characters tinted by its cell's color,
83
+ // over time and as the head comes near
84
+ vec2 cuv = clamp(vec2((cell.x + 0.111) * dims.x / ratio, 1.0 - (cell.y + 0.222) * h), 0.0, 1.0);
85
+ vec4 ca = getFromColor(cuv);
86
+ float lum = dot(ca.rgb, vec3(0.299, 0.587, 0.114));
87
+ vec3 hue = ca.rgb / max(max(ca.r, max(ca.g, ca.b)), 0.05);
88
+ vec3 ink = mix(glow.rgb * glow.a, hue, tint) * (0.1 + 0.6 * lum);
89
+ float near = smoothstep(-0.15, 0.0, dy);
90
+ float dim = max(smoothstep(0.0, 0.3, T), near);
91
+ float g = max(smoothstep(0.0, 0.2, T - 0.12 * rc), near);
92
+ float passed = step(0.0, dy);
93
+ // the characters change slowly ahead of the stream and fast in it
94
+ float slow = mod(floor(T * 12.0 + rc * 7.0), 32.0);
95
+ float fast = 32.0 + mod(floor(T * 40.0 + rc * 13.0), 32.0);
96
+ float chr = glyph(cell, mix(slow, fast, passed), local);
97
+ vec3 code = a.rgb * (1.0 - 0.8 * dim) + ink * chr * g;
98
+
99
+ // behind the head: bright characters changing fast, fading along the tail, over a shadow that
100
+ // clears in the tail's last two thirds to leave the incoming image
101
+ float fade = clamp(1.0 - dy / len, 0.0, 1.0);
102
+ float shade = 1.0 - smoothstep(0.3 * len, len, dy);
103
+ float hot = 1.0 - smoothstep(h, 3.0 * h, dy);
104
+ vec3 col = mix(glow.rgb * 1.2, vec3(1.0), 0.8 * hot) * glow.a;
105
+ vec3 stream = b.rgb * (1.0 - 0.8 * shade) + col * chr * (fade * (2.0 - fade) + hot * fade);
106
+
107
+ // a soft glow around the head, within its column
108
+ float yy = (head - fp.y) / (1.5 * h);
109
+ float halo = 1.6 * u * (1.0 - u) * exp(-yy * yy) * (1.0 - smoothstep(0.25, 0.5, abs(local.x - 0.5)));
110
+ vec3 rgb = mix(code, stream, passed) + glow.rgb * glow.a * halo;
111
+ // the outgoing image's opacity stays under the tail's shadow, then gives way to the incoming one's
112
+ return vec4(clamp(rgb, 0.0, 1.0), mix(a.a, mix(b.a, a.a, shade), passed));
113
+ }
@@ -0,0 +1,70 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image rises like a theater festoon curtain: cords lift its hem into scalloped swags while the fabric gathers into shaded ruffles, and it is drawn up out of the frame over the incoming image
4
+ // Tags: 3d, fold, vertical
5
+
6
+ // @range(1, 8, 1) Number of swags across a 16:9 frame (fewer in a portrait image)
7
+ uniform float swags; // = 3.0
8
+ // @range(0, 0.3) How low each swag droops between two cords, as a part of the frame's height
9
+ uniform float sag; // = 0.14
10
+ // @range(4, 30, 1) Number of gathered ruffles in the fabric
11
+ uniform float ruffles; // = 14.0
12
+ // @range(0, 1) Depth of the shading on the ruffles and swags, and of the shadow under the hem
13
+ uniform float shading; // = 0.7
14
+
15
+ const float PI = 3.141592653589793;
16
+
17
+ vec4 transition (vec2 uv) {
18
+ float p = progress;
19
+ // the fabric gathers early, then the cords pull it up
20
+ float f = 1.0 - (1.0 - p) * (1.0 - p) * (1.0 - p);
21
+ // the cords start pulling at once and are fastest midway
22
+ float e = mix(p, p * p * (3.0 - 2.0 * p), 0.4);
23
+ float s = sag * f;
24
+ float lift = mix(-0.01, 1.0 + sag + 0.08, e);
25
+ // across a swag, -1 and 1 at the cords
26
+ float n = max(1.0, floor(swags * sqrt(ratio / 1.78) + 0.5)); // fewer swags in portrait
27
+ float u = fract(uv.x * n) * 2.0 - 1.0;
28
+ float bump = 1.0 - u * u;
29
+ float hem = lift - s * bump;
30
+ float aa = 0.002 + 0.004 * f;
31
+ float inside = smoothstep(hem - aa, hem + aa, uv.y);
32
+
33
+ vec4 c = vec4(0.0);
34
+ if (inside > 0.0) {
35
+ // q goes from 0 at the top rod to 1 at the hem; the whole height of fabric is gathered into it
36
+ float h = max(1.0 - max(hem, 0.0), 1e-4);
37
+ float q = clamp((1.0 - uv.y) / h, 0.0, 1.0);
38
+ // ruffles: the fabric bunches where cos(a) > 0, rows parallel to the scalloped hem
39
+ // as the curtain shortens, its ruffles merge so none gets thinner than 2% of the frame
40
+ float m = min(max(1.0, floor(ruffles + 0.5)), h / 0.02);
41
+ float a = 2.0 * PI * m * q;
42
+ // the ruffles puff out most in the middle of each swag
43
+ float g = 0.85 * f * min(1.0, 0.3 + 5.0 * (1.0 - h)) * (0.6 + 0.4 * bump);
44
+ float v = clamp(q + g * sin(a) / (2.0 * PI * m), 0.0, 1.0);
45
+ // the fabric is also pulled in toward the cords near the hem
46
+ float pull = 0.25 * f * q * q * sin(PI * u) / (PI * n);
47
+ c = getFromColor(vec2(uv.x - pull, 1.0 - v));
48
+
49
+ // light from the front and a bit above
50
+ float slope = 2.5 * g * cos(a);
51
+ float diffuse = (1.0 - 0.35 * slope) / sqrt(1.0 + slope * slope);
52
+ float crease = 0.5 + 0.5 * sin(a);
53
+ float light = mix(1.0, diffuse * (1.0 - 0.45 * crease * crease), shading * g);
54
+ // a soft sheen on the crest of each ruffle
55
+ light += 0.18 * shading * g * smoothstep(0.4, 1.0, -cos(a));
56
+ // each swag bulges toward the light in its middle and is pinched dark along the cords
57
+ float depth = f * q * (0.3 + 0.7 * q);
58
+ light *= 1.0 - shading * depth * (0.35 * u * u + 0.5 * exp(-(1.0 - abs(u)) * 14.0));
59
+ // the hem rolls under a little
60
+ light *= 1.0 - 0.35 * shading * f * exp(-(uv.y - hem) * 120.0);
61
+ c.rgb *= light;
62
+ if (inside >= 1.0) return c;
63
+ }
64
+ vec4 to = getToColor(uv);
65
+ // soft shadow of the curtain just under its hem
66
+ float below = max(hem - uv.y, 0.0);
67
+ float shadow = 0.6 * shading * exp(-below * 22.0) * smoothstep(0.0, 0.05, lift) * (1.0 - smoothstep(1.0, 1.06, lift - s));
68
+ to.rgb *= 1.0 - shadow;
69
+ return mix(to, c, inside);
70
+ }
@@ -0,0 +1,92 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image slides away leaving a trail of discrete fading copies of itself, a stroboscopic echo, and the incoming image's echoes converge into place
4
+ // Tags: slide, echo, strobe, directional
5
+
6
+ // @param Direction in which the images slide
7
+ uniform vec2 direction; // = vec2(1.0, 0.0)
8
+ // @range(1, 7, 1) Number of echoes between the two images
9
+ uniform int echoes; // = 4
10
+ // @range(0.05, 0.6) How long the echoes trail behind each image, as a part of the transition
11
+ uniform float trail; // = 0.25
12
+ // @range(0, 1) How fast the echoes of the outgoing image fade out into those of the incoming one
13
+ uniform float decay; // = 0.5
14
+
15
+ // width of the anti-aliased edges, along the slide
16
+ const float EDGE = 0.002;
17
+ // the most echoes, the bound of the loop
18
+ const int MAX_ECHOES = 7;
19
+
20
+ float easeInOut(float t) {
21
+ return t * t * (3.0 - 2.0 * t);
22
+ }
23
+
24
+ // mirror the coordinates back into the frame
25
+ vec2 mirror(vec2 v) {
26
+ return 1.0 - abs(1.0 - mod(v, 2.0));
27
+ }
28
+
29
+ // coverage of the part of the frame past an edge at x, anti-aliased only inside the frame
30
+ float past(float s, float x) {
31
+ return x <= 0.0 ? 1.0 : x >= 1.0 ? 0.0 : clamp((s - x) / EDGE + 0.5, 0.0, 1.0);
32
+ }
33
+
34
+ // the edge between the copies at the time t of the slide
35
+ float edgeAt(float t) {
36
+ return easeInOut(clamp(t, 0.0, 1.0));
37
+ }
38
+
39
+ // step j between the two images, from the edge e0 to the edge e1: the echo of the outgoing image
40
+ // whose trailing edge is e0, fading out toward the incoming image, over the echo of the incoming
41
+ // image whose leading edge is e1
42
+ vec4 echoStep(vec2 uv, float s, vec2 shift, float j, float t0, float lag, float n) {
43
+ float e0 = edgeAt(t0 + j * lag);
44
+ float e1 = edgeAt(t0 + (j + 1.0) * lag);
45
+ vec4 a = getFromColor(mirror(uv - shift * e0));
46
+ vec4 b = getToColor(mirror(uv - shift * (e1 - 1.0)));
47
+ vec4 c = mix(b, a, pow((j + 0.5) / n, 0.5 + 2.0 * clamp(decay, 0.0, 1.0)));
48
+ // each copy casts a soft shadow behind it onto the older ones
49
+ c.rgb *= 1.0 - 0.25 * exp(-max(e1 - s, 0.0) / 0.02) * min((e1 - e0) / 0.02, 1.0);
50
+ return c;
51
+ }
52
+
53
+ vec4 transition(vec2 uv) {
54
+ float dl = length(direction);
55
+ vec2 d = dl > 1e-6 ? direction / dl : vec2(1.0, 0.0);
56
+ // s: position along the slide, from 0 (trailing side) to 1 (leading side)
57
+ float ext = abs(d.x) + abs(d.y);
58
+ vec2 shift = d * ext;
59
+ float s = 0.5 + dot(uv - 0.5, d) / ext;
60
+
61
+ float n = clamp(float(echoes), 1.0, float(MAX_ECHOES));
62
+ float tr = clamp(trail, 0.05, 0.6);
63
+ float lag = tr / n;
64
+ // the incoming image follows the outgoing one tr behind; the copies of both images sit at
65
+ // the times between them, the stroboscopic echoes of the outgoing image trailing behind it
66
+ // and those of the incoming image ahead of it
67
+ float t0 = progress >= 1.0 ? 1.0 : progress * (1.0 + tr) - tr;
68
+ float eIn = edgeAt(t0);
69
+ float eOut = edgeAt(t0 + tr);
70
+
71
+ float wIn = 1.0 - past(s, eIn);
72
+ float wOut = past(s, eOut);
73
+ float wGap = max(1.0 - wIn - wOut, 0.0);
74
+ vec4 c = vec4(0.0);
75
+ if (wGap > 0.0) {
76
+ // the step of this point, and how far it is past the next edge, to anti-alias it
77
+ float jf = 0.0;
78
+ for (int k = 1; k < MAX_ECHOES; k++) {
79
+ float m = float(k);
80
+ if (m >= n) break;
81
+ jf += past(s, edgeAt(t0 + m * lag));
82
+ }
83
+ float j = floor(jf);
84
+ c = echoStep(uv, s, shift, j, t0, lag, n);
85
+ if (jf > j) c = mix(c, echoStep(uv, s, shift, j + 1.0, t0, lag, n), jf - j);
86
+ c *= wGap;
87
+ }
88
+ // the two images on both sides of their echoes
89
+ if (wIn > 0.0) c += wIn * getToColor(mirror(uv - shift * (eIn - 1.0)));
90
+ if (wOut > 0.0) c += wOut * getFromColor(mirror(uv - shift * eOut));
91
+ return c;
92
+ }