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