gl-transitions 3.2.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 (76) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/compatibility.json +210 -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/EchoSlide.glsl +93 -0
  7. package/glsl3/GeometricCollage.glsl +241 -0
  8. package/glsl3/HingedSquares.glsl +121 -0
  9. package/glsl3/HorizontalHold.glsl +62 -0
  10. package/glsl3/LayoutGrid.glsl +147 -0
  11. package/glsl3/ProjectorThrow.glsl +75 -0
  12. package/glsl3/Reassemble.glsl +156 -0
  13. package/glsl3/Shockwave.glsl +103 -0
  14. package/glsl3/ShoreWash.glsl +150 -0
  15. package/glsl3/ShutterWipe.glsl +68 -0
  16. package/glsl3/StopMotion.glsl +118 -0
  17. package/glsl3/Vaporize.glsl +125 -0
  18. package/index.js +1 -1
  19. package/layouts.json +493 -0
  20. package/llms-full.txt +647 -434
  21. package/llms.txt +238 -225
  22. package/msl/CardDeal.metal +539 -0
  23. package/msl/EchoSlide.metal +438 -0
  24. package/msl/GeometricCollage.metal +1188 -0
  25. package/msl/HingedSquares.metal +564 -0
  26. package/msl/HorizontalHold.metal +286 -0
  27. package/msl/LayoutGrid.metal +544 -0
  28. package/msl/ProjectorThrow.metal +313 -0
  29. package/msl/Reassemble.metal +667 -0
  30. package/msl/Shockwave.metal +256 -0
  31. package/msl/ShoreWash.metal +538 -0
  32. package/msl/ShutterWipe.metal +286 -0
  33. package/msl/StopMotion.metal +551 -0
  34. package/msl/Vaporize.metal +462 -0
  35. package/package.json +1 -1
  36. package/skills/gl-transitions/references/catalog.md +70 -32
  37. package/sksl/CardDeal.sksl +156 -0
  38. package/sksl/EchoSlide.sksl +99 -0
  39. package/sksl/GeometricCollage.sksl +242 -0
  40. package/sksl/HingedSquares.sksl +124 -0
  41. package/sksl/HorizontalHold.sksl +74 -0
  42. package/sksl/LayoutGrid.sksl +156 -0
  43. package/sksl/ProjectorThrow.sksl +85 -0
  44. package/sksl/Reassemble.sksl +166 -0
  45. package/sksl/Shockwave.sksl +116 -0
  46. package/sksl/ShoreWash.sksl +159 -0
  47. package/sksl/ShutterWipe.sksl +80 -0
  48. package/sksl/StopMotion.sksl +126 -0
  49. package/sksl/Vaporize.sksl +134 -0
  50. package/sksl/index.js +1 -1
  51. package/transitions/CardDeal.glsl +145 -0
  52. package/transitions/EchoSlide.glsl +92 -0
  53. package/transitions/GeometricCollage.glsl +240 -0
  54. package/transitions/HingedSquares.glsl +120 -0
  55. package/transitions/HorizontalHold.glsl +61 -0
  56. package/transitions/LayoutGrid.glsl +146 -0
  57. package/transitions/ProjectorThrow.glsl +74 -0
  58. package/transitions/Reassemble.glsl +155 -0
  59. package/transitions/Shockwave.glsl +102 -0
  60. package/transitions/ShoreWash.glsl +149 -0
  61. package/transitions/ShutterWipe.glsl +67 -0
  62. package/transitions/StopMotion.glsl +117 -0
  63. package/transitions/Vaporize.glsl +124 -0
  64. package/wgsl/CardDeal.wgsl +496 -0
  65. package/wgsl/EchoSlide.wgsl +386 -0
  66. package/wgsl/GeometricCollage.wgsl +1075 -0
  67. package/wgsl/HingedSquares.wgsl +506 -0
  68. package/wgsl/HorizontalHold.wgsl +243 -0
  69. package/wgsl/LayoutGrid.wgsl +495 -0
  70. package/wgsl/ProjectorThrow.wgsl +274 -0
  71. package/wgsl/Reassemble.wgsl +609 -0
  72. package/wgsl/Shockwave.wgsl +226 -0
  73. package/wgsl/ShoreWash.wgsl +492 -0
  74. package/wgsl/ShutterWipe.wgsl +252 -0
  75. package/wgsl/StopMotion.wgsl +496 -0
  76. package/wgsl/Vaporize.wgsl +420 -0
@@ -0,0 +1,242 @@
1
+ // GeometricCollage — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/GeometricCollage.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The incoming image arrives cut into a geometric poster of quarter discs, half discs, triangles and their complements: piece after piece swings in around a corner of its cell, a flat plate of color just ahead of it, and lands flat with a soft paper shadow
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform int cells;
16
+
17
+ uniform float stagger;
18
+
19
+ uniform int plates;
20
+
21
+ uniform vec4 color1;
22
+
23
+ uniform vec4 color2;
24
+
25
+ uniform vec4 color3;
26
+
27
+ uniform float shadow;
28
+
29
+ const float PI = 3.141592653589793;
30
+
31
+ const float DUR = 0.24;
32
+ const float GAP = 0.07;
33
+ const float LEAD = 0.06;
34
+
35
+ const float SETTLE = 0.8;
36
+
37
+ const float EDGE = 0.002;
38
+
39
+ float hash12(vec2 v) {
40
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
41
+ v3 += dot(v3, v3.yzx + 33.33);
42
+ return fract((v3.x + v3.y) * v3.z);
43
+ }
44
+
45
+ vec2 orient(vec2 l, float k) {
46
+ vec2 c = l - 0.5;
47
+ if (k < 0.5) return l;
48
+ if (k < 1.5) return vec2(-c.y, c.x) + 0.5;
49
+ if (k < 2.5) return 0.5 - c;
50
+ return vec2(c.y, -c.x) + 0.5;
51
+ }
52
+
53
+ vec2 pivotCorner(float k) {
54
+ if (k < 0.5) return vec2(0.0, 0.0);
55
+ if (k < 1.5) return vec2(0.0, 1.0);
56
+ if (k < 2.5) return vec2(1.0, 1.0);
57
+ return vec2(1.0, 0.0);
58
+ }
59
+
60
+ float shapeDist(vec2 o, float type) {
61
+ if (type < 0.5) return length(o) - 1.0;
62
+ if (type < 1.5) return length(o - vec2(0.5, 0.0)) - 0.5;
63
+ return (o.x + o.y - 1.0) * 0.70710678;
64
+ }
65
+
66
+ float pieceDist(vec2 l, vec2 cell, float piece) {
67
+ float k = floor(hash12(cell + 1.7) * 4.0);
68
+
69
+ float sd = shapeDist(orient(l, k), mod(cell.x + 2.0 * cell.y + 1.0, 3.0));
70
+ return piece > 0.5 ? -sd : sd;
71
+ }
72
+
73
+ float boxDist(vec2 l) {
74
+ return min(min(l.x, l.y), min(1.0 - l.x, 1.0 - l.y));
75
+ }
76
+
77
+ float easeOutCubic(float t) {
78
+ float u = 1.0 - clamp(t, 0.0, 1.0);
79
+ return 1.0 - u * u * u;
80
+ }
81
+
82
+ float lift(float t) {
83
+ return 1.0 - smoothstep(0.3, 1.0, t);
84
+ }
85
+
86
+ float spread() {
87
+ return (1.0 - DUR - GAP - LEAD - 0.02) * clamp(stagger, 0.0, 1.0);
88
+ }
89
+ float swing() {
90
+ return 1.0 - GAP - LEAD - 0.02 - spread();
91
+ }
92
+
93
+ float startTime(vec2 cell, vec2 n) {
94
+ float order = (cell.x + (n.y - 1.0 - cell.y)) / max(n.x + n.y - 2.0, 1.0);
95
+ order = clamp(order * 0.75 + 0.25 * hash12(cell + 4.4), 0.0, 1.0);
96
+ return LEAD + spread() * order;
97
+ }
98
+
99
+ vec3 swingPoint(vec2 p, vec2 cell, vec2 cs, float piece, float t) {
100
+ vec2 pc = pivotCorner(floor(hash12(cell + 1.7) * 4.0));
101
+
102
+ vec2 piv = (cell + (piece < 0.5 ? pc : 1.0 - pc)) * cs;
103
+ float sgn = hash12(cell + vec2(piece * 3.3, 5.2)) < 0.5 ? -1.0 : 1.0;
104
+
105
+ float s = smoothstep(0.0, 0.45, t) * (1.0 + 0.1 * lift(t));
106
+
107
+ float a = sgn * 0.5 * PI * (1.0 - easeOutCubic(t / SETTLE));
108
+ float ca = cos(a), sa = sin(a);
109
+ vec2 d = p - piv;
110
+ d = vec2(ca * d.x + sa * d.y, -sa * d.x + ca * d.y) / max(s, 0.001);
111
+ return vec3((piv + d) / cs - cell, s);
112
+ }
113
+
114
+ vec3 layerCover(vec2 p, vec2 cell, vec2 cs, float piece, float t) {
115
+ vec3 q = swingPoint(p, cell, cs, piece, t);
116
+ if (q.z < 0.01) return vec3(0.0);
117
+ float e = EDGE / (min(cs.x, cs.y) * q.z);
118
+ float m = clamp(boxDist(q.xy) / e + 0.5, 0.0, 1.0) * clamp(-pieceDist(q.xy, cell, piece) / e + 0.5, 0.0, 1.0);
119
+ return vec3(m, clamp(q.xy, 0.0, 1.0));
120
+ }
121
+
122
+ float layerShadow(vec2 p, vec2 cell, vec2 cs, float piece, float t) {
123
+ float h = lift(t);
124
+ vec3 q = swingPoint(p - vec2(0.07, -0.1) * h * cs.y, cell, cs, piece, t);
125
+ if (q.z < 0.01) return 0.0;
126
+ float soft = 0.02 + 0.05 * h;
127
+ return h * (1.0 - smoothstep(-soft, soft, pieceDist(q.xy, cell, piece))) * smoothstep(-soft, soft, boxDist(q.xy));
128
+ }
129
+
130
+ vec4 plateColor(vec2 cell, float piece) {
131
+ float c = mod(floor(hash12(cell * 1.3 + 0.7) * 3.0) + piece, 3.0);
132
+ return c < 0.5 ? color1 : c < 1.5 ? color2 : color3;
133
+ }
134
+
135
+ vec4 premultiplied(vec4 c) {
136
+ return vec4(c.rgb * c.a, c.a);
137
+ }
138
+
139
+ vec4 transition(vec2 uv) {
140
+ float kc = float(cells < 1 ? 1 : cells);
141
+ vec2 n = ratio >= 1.0 ? vec2(max(1.0, floor(ratio * kc + 0.5)), kc) : vec2(kc, max(1.0, floor(kc / ratio + 0.5)));
142
+ vec2 cs = vec2(ratio, 1.0) / n;
143
+ vec2 p = uv * vec2(ratio, 1.0);
144
+ vec2 cell0 = floor(p / cs);
145
+ float sw = swing();
146
+
147
+
148
+
149
+ vec2 l0 = p / cs - cell0;
150
+ float t00 = startTime(cell0, n);
151
+ float sd0 = pieceDist(l0, cell0, 0.0);
152
+ float e0 = EDGE / min(cs.x, cs.y);
153
+ float landed = (progress >= t00 + sw ? clamp(-sd0 / e0 + 0.5, 0.0, 1.0) : 0.0)
154
+ + (progress >= t00 + GAP + sw ? clamp(sd0 / e0 + 0.5, 0.0, 1.0) : 0.0);
155
+
156
+
157
+ vec4 top = vec4(-1.0, 0.0, 0.0, 0.0);
158
+ vec4 topPos = vec4(0.0);
159
+ vec4 und = vec4(-1.0, 0.0, 0.0, 0.0);
160
+ vec4 undPos = vec4(0.0);
161
+ for (int dy = -1; dy <= 1; dy++) {
162
+ for (int dx = -1; dx <= 1; dx++) {
163
+ vec2 cell = cell0 + vec2(float(dx), float(dy));
164
+ if (cell.x < 0.0 || cell.y < 0.0 || cell.x >= n.x || cell.y >= n.y) continue;
165
+ float tc = startTime(cell, n);
166
+ for (int pc = 0; pc < 2; pc++) {
167
+ float piece = float(pc);
168
+ float t0 = tc + GAP * piece;
169
+
170
+ float tp = (progress - t0) / sw;
171
+ for (int ly = 0; ly < 2; ly++) {
172
+ float isPlate = ly == 0 ? 1.0 : 0.0;
173
+ if (isPlate > 0.5 && !(plates != 0)) continue;
174
+ float ts = t0 - LEAD * isPlate;
175
+ float t = (progress - ts) / sw;
176
+
177
+ if (t <= 0.0 || tp >= 1.0 || (isPlate > 0.5 && tp >= SETTLE)) continue;
178
+ vec3 L = layerCover(p, cell, cs, piece, min(t, 1.0));
179
+ if (isPlate > 0.5) L.x *= 1.0 - smoothstep(SETTLE - 0.1, SETTLE, tp);
180
+ if (L.x <= 0.0) continue;
181
+ vec4 cur = vec4(ts, L.x, isPlate, piece);
182
+ vec4 curPos = vec4(cell, L.yz);
183
+ if (ts > top.x) {
184
+ und = top;
185
+ undPos = topPos;
186
+ top = cur;
187
+ topPos = curPos;
188
+ } else if (ts > und.x) {
189
+ und = cur;
190
+ undPos = curPos;
191
+ }
192
+ }
193
+ }
194
+ }
195
+ }
196
+
197
+ if (top.z < 0.5 && und.x < 0.0 && topPos.x == cell0.x && topPos.y == cell0.y) {
198
+ landed = top.y < 1.0 ? landed / (1.0 - top.y) : 1.0;
199
+ }
200
+ vec4 c = mix(premultiplied(getFromColor(uv)), premultiplied(getToColor(uv)), clamp(landed, 0.0, 1.0));
201
+ if (und.x >= 0.0) {
202
+ vec4 uc = und.z > 0.5 ? plateColor(undPos.xy, und.w) : getToColor((undPos.xy + undPos.zw) * cs / vec2(ratio, 1.0));
203
+ c = mix(c, premultiplied(uc), und.y);
204
+ }
205
+ if (top.x >= 0.0) {
206
+ vec4 tc = top.z > 0.5 ? plateColor(topPos.xy, top.w) : getToColor((topPos.xy + topPos.zw) * cs / vec2(ratio, 1.0));
207
+ c = mix(c, premultiplied(tc), top.y);
208
+ }
209
+
210
+
211
+ float sh = 0.0;
212
+ if (shadow > 0.0) {
213
+ for (int dy = -1; dy <= 1; dy++) {
214
+ for (int dx = -1; dx <= 1; dx++) {
215
+ vec2 cell = cell0 + vec2(float(dx), float(dy));
216
+ if (cell.x < 0.0 || cell.y < 0.0 || cell.x >= n.x || cell.y >= n.y) continue;
217
+ float tc = startTime(cell, n);
218
+ for (int pc = 0; pc < 2; pc++) {
219
+ float piece = float(pc);
220
+ float t0 = tc + GAP * piece;
221
+ float tp = (progress - t0) / sw;
222
+ for (int ly = 0; ly < 2; ly++) {
223
+ float isPlate = ly == 0 ? 1.0 : 0.0;
224
+ if (isPlate > 0.5 && (!(plates != 0) || tp >= SETTLE)) continue;
225
+ float ts = t0 - LEAD * isPlate;
226
+ float t = (progress - ts) / sw;
227
+ if (ts <= top.x || t <= 0.0 || t >= 1.0) continue;
228
+ sh = max(sh, layerShadow(p, cell, cs, piece, t));
229
+ }
230
+ }
231
+ }
232
+ }
233
+ }
234
+ c.rgb *= 1.0 - 0.7 * clamp(shadow, 0.0, 1.0) * sh;
235
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
236
+ }
237
+
238
+ half4 main(float2 _coord) {
239
+ vec2 _uv = _coord / _resolution;
240
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
241
+ return half4(_c.rgb * _c.a, _c.a);
242
+ }
@@ -0,0 +1,124 @@
1
+ // HingedSquares — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/HingedSquares.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The image is cut into squares that turn in alternate directions while staying hinged at their corners, so the sheet opens into a checkerboard of diamonds showing the incoming image; those diamonds then turn back into place and close the sheet
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform int cells;
16
+
17
+ uniform float shading;
18
+
19
+ uniform float zoom;
20
+
21
+ const float PI = 3.141592653589793;
22
+
23
+ const float EDGE = 0.0012;
24
+
25
+ vec2 rot(vec2 v, vec2 cs) {
26
+ return vec2(cs.x * v.x + cs.y * v.y, -cs.y * v.x + cs.x * v.y);
27
+ }
28
+
29
+ vec2 node(float i) {
30
+ return vec2(mod(i, 2.0), floor(i * 0.5));
31
+ }
32
+
33
+ float parity(vec2 n) {
34
+ return mod(n.x + n.y, 2.0) < 0.5 ? 1.0 : -1.0;
35
+ }
36
+
37
+ vec4 nearest(vec2 w, vec2 g, float spacing, vec2 off, vec2 cs) {
38
+ vec4 best = vec4(0.0, 0.0, 1e5, 0.0);
39
+ for (int i = 0; i < 4; i++) {
40
+ vec2 n = g + node(float(i));
41
+ vec2 l = rot(w - (n + off) * spacing, vec2(cs.x, parity(n) * cs.y));
42
+ vec2 q = abs(l) - 0.5;
43
+ float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
44
+ if (d < best.z) best = vec4(l, d, float(i));
45
+ }
46
+ return best;
47
+ }
48
+
49
+ vec3 gap(vec2 w, vec2 g, float spacing, vec2 off, vec2 cs) {
50
+ vec3 best = vec3(0.0, 0.0, 0.0);
51
+ float r = 1e5;
52
+ for (int i = 0; i < 4; i++) {
53
+ vec2 n = g + node(float(i));
54
+ vec2 v = w - (n + off) * spacing;
55
+ vec2 h = parity(n) > 0.0 ? cs.yx : cs;
56
+
57
+ float ri = abs(v.x) * h.y + abs(v.y) * h.x;
58
+ if (ri < r) {
59
+ r = ri;
60
+ best = vec3(rot(v, vec2(0.7071068, parity(n) * 0.7071068)), float(i));
61
+ }
62
+ }
63
+ return best;
64
+ }
65
+
66
+ vec2 toUV(vec2 c, float n) {
67
+ vec2 uv = c / (n * vec2(ratio, 1.0)) + 0.5;
68
+ return abs(mod(uv + 1.0, 2.0) - 1.0);
69
+ }
70
+
71
+ vec4 transition(vec2 uv) {
72
+ if (progress <= 0.0) return getFromColor(uv);
73
+ if (progress >= 1.0) return getToColor(uv);
74
+ float n = max(float(cells), 1.0);
75
+ float e = progress * progress * (3.0 - 2.0 * progress);
76
+ float a = 0.5 * PI * e;
77
+
78
+ float th = min(a, 0.5 * PI - a);
79
+
80
+ vec2 cs = vec2(cos(th), sin(th));
81
+ float spacing = cs.x + cs.y;
82
+ float scale = n * mix(1.0, spacing, clamp(zoom, 0.0, 1.0));
83
+ vec2 w = (uv - 0.5) * vec2(ratio, 1.0) * scale;
84
+ bool first = a < 0.25 * PI;
85
+ vec2 offF = first ? vec2(0.0) : vec2(0.5);
86
+ vec2 offB = vec2(0.5) - offF;
87
+ vec2 gF = floor(w / spacing - offF);
88
+ vec2 gB = floor(w / spacing - offB);
89
+
90
+ vec4 f = nearest(w, gF, spacing, offF, cs);
91
+ vec3 b = gap(w, gB, spacing, offB, cs);
92
+ vec2 nf = gF + node(f.w);
93
+ vec2 nb = gB + node(b.z);
94
+ vec2 uvF = toUV(nf + offF + f.xy, n);
95
+ vec2 uvB = toUV(nb + offB + b.xy, n);
96
+ vec4 colF = first ? getFromColor(uvF) : getToColor(uvF);
97
+ vec4 colB = first ? getToColor(uvB) : getFromColor(uvB);
98
+
99
+
100
+ float depth = clamp(shading, 0.0, 1.0) * sin(4.0 * th);
101
+
102
+ if (depth > 0.0) {
103
+ vec2 ws = w - vec2(0.12, -0.12) * depth;
104
+ vec4 sh = nearest(ws, floor(ws / spacing - offF), spacing, offF, cs);
105
+ colB.rgb *= 1.0 - 0.75 * depth * (1.0 - smoothstep(-0.12, 0.25, sh.z));
106
+ }
107
+
108
+ vec2 side = abs(f.x) > abs(f.y) ? vec2(sign(f.x), 0.0) : vec2(0.0, sign(f.y));
109
+ float facing = dot(rot(side, vec2(cs.x, -parity(nf) * cs.y)), vec2(-0.7071, 0.7071));
110
+ float rim = smoothstep(-0.07, -0.01, f.z);
111
+ colF.rgb *= 1.0 + 0.35 * depth * rim * facing;
112
+
113
+
114
+ float aa = EDGE * scale;
115
+ float seal = aa * (1.0 - smoothstep(0.0, 3.0 * aa, cs.y));
116
+ float cover = 1.0 - smoothstep(-aa, aa, f.z - seal);
117
+ return mix(colB, colF, cover);
118
+ }
119
+
120
+ half4 main(float2 _coord) {
121
+ vec2 _uv = _coord / _resolution;
122
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
123
+ return half4(_c.rgb * _c.a, _c.a);
124
+ }
@@ -0,0 +1,74 @@
1
+ // HorizontalHold — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/HorizontalHold.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The picture loses its horizontal hold like an old TV: it shears into diagonal bands that slide sideways and wrap around, separated by a slanted blanking bar that carries the incoming image in, then the shear straightens, wobbles and locks
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform int slips;
16
+
17
+ uniform float shear;
18
+
19
+ uniform float barWidth;
20
+
21
+ uniform vec4 barColor;
22
+
23
+ float slipCount() {
24
+ return max(float(slips), 1.0);
25
+ }
26
+
27
+ vec4 stream(float x, float y, float unsync) {
28
+ float period = 1.0 + barWidth;
29
+ float n = floor(x / period);
30
+ float xm = x - n * period;
31
+ vec2 q = vec2(min(xm, 1.0), y);
32
+ vec4 c = n >= floor(0.5 * slipCount() + 0.5) ? getToColor(q) : getFromColor(q);
33
+
34
+ float d = min(xm, 1.0 - xm);
35
+
36
+ float g = max(1.0 - d / 0.05, 0.0);
37
+ c.rgb += 0.3 * unsync * g * g * c.a;
38
+ float soft = min(0.012 * unsync, 0.5 * barWidth) + 1e-5;
39
+ return mix(barColor, c, clamp(d / soft, 0.0, 1.0));
40
+ }
41
+
42
+ vec4 transition(vec2 uv) {
43
+ float period = 1.0 + barWidth;
44
+
45
+ float t = min(progress / 0.88, 1.0);
46
+ float err = 16.0 * t * t * (1.0 - t) * (1.0 - t);
47
+ float slip = t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
48
+
49
+ float u = clamp((progress - 0.74) / 0.26, 0.0, 1.0);
50
+ float lock = u * (1.0 - u) * (1.0 - u);
51
+ float tilt = -0.5 * max(shear, 0.5) * lock * sin(9.42478 * u);
52
+ float unsync = min(err + 3.0 * lock, 1.0);
53
+
54
+ float ripple = 0.012 * sin(uv.y * 9.0 + progress * 40.0) + 0.005 * sin(uv.y * 31.0 - progress * 70.0);
55
+ float x = uv.x + period * (slipCount() * slip + shear * err * (1.0 - uv.y) + tilt * (1.0 - uv.y)) + err * ripple;
56
+
57
+ float blur = 0.002 * err * slipCount();
58
+ vec4 c = stream(x, uv.y, unsync);
59
+ if (blur > 0.0) {
60
+ for (int i = 0; i < 4; i++) {
61
+ c += stream(x + blur * (float(i) - 1.5), uv.y, unsync);
62
+ }
63
+ c /= 5.0;
64
+ }
65
+
66
+ c.rgb *= 1.0 - unsync * (0.1 + 0.08 * sin(uv.y * 480.0));
67
+ return c;
68
+ }
69
+
70
+ half4 main(float2 _coord) {
71
+ vec2 _uv = _coord / _resolution;
72
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
73
+ return half4(_c.rgb * _c.a, _c.a);
74
+ }
@@ -0,0 +1,156 @@
1
+ // LayoutGrid — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/LayoutGrid.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The frame splits into an asymmetric magazine grid as paper gutters open between the panels; panel after panel in reading order, the incoming image pushes the outgoing one out of its panel from a different side, a colored accent band between them, then the gutters close over the full incoming image
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform float gutter;
16
+
17
+ uniform float overlap;
18
+
19
+ uniform float band;
20
+
21
+ uniform float shadow;
22
+
23
+ uniform vec4 paper;
24
+
25
+ uniform vec4 accent;
26
+
27
+ const int PANELS = 6;
28
+
29
+ const float OPEN = 0.28;
30
+
31
+ const float START = 0.1;
32
+
33
+ const float EDGE = 0.0025;
34
+
35
+ vec4 panelRect(int i, bool portrait) {
36
+ if (portrait) {
37
+ if (i == 0) return vec4(0.0, 0.68, 0.62, 1.0);
38
+ if (i == 1) return vec4(0.62, 0.68, 1.0, 1.0);
39
+ if (i == 2) return vec4(0.0, 0.36, 1.0, 0.68);
40
+ if (i == 3) return vec4(0.0, 0.0, 0.46, 0.36);
41
+ if (i == 4) return vec4(0.46, 0.17, 1.0, 0.36);
42
+ return vec4(0.46, 0.0, 1.0, 0.17);
43
+ }
44
+ if (i == 0) return vec4(0.0, 0.42, 0.4, 1.0);
45
+ if (i == 1) return vec4(0.4, 0.64, 1.0, 1.0);
46
+ if (i == 2) return vec4(0.4, 0.0, 0.7, 0.64);
47
+ if (i == 3) return vec4(0.7, 0.32, 1.0, 0.64);
48
+ if (i == 4) return vec4(0.7, 0.0, 1.0, 0.32);
49
+ return vec4(0.0, 0.0, 0.4, 0.42);
50
+ }
51
+
52
+ vec2 panelDir(int i, bool portrait) {
53
+ if (portrait) {
54
+ if (i == 0) return vec2(1.0, 0.0);
55
+ if (i == 1) return vec2(0.0, -1.0);
56
+ if (i == 2) return vec2(-1.0, 0.0);
57
+ if (i == 3) return vec2(0.0, 1.0);
58
+ if (i == 4) return vec2(1.0, 0.0);
59
+ return vec2(-1.0, 0.0);
60
+ }
61
+ if (i == 0) return vec2(0.0, -1.0);
62
+ if (i == 1) return vec2(-1.0, 0.0);
63
+ if (i == 2) return vec2(0.0, 1.0);
64
+ if (i == 3) return vec2(1.0, 0.0);
65
+ if (i == 4) return vec2(-1.0, 0.0);
66
+ return vec2(1.0, 0.0);
67
+ }
68
+
69
+ float easeInOut(float t) {
70
+ return t < 0.5 ? 4.0 * t * t * t : 1.0 - 4.0 * (1.0 - t) * (1.0 - t) * (1.0 - t);
71
+ }
72
+
73
+ float span1(float x, float lo, float hi, float aa) {
74
+ return smoothstep(lo - aa, lo + aa, x) * (1.0 - smoothstep(hi - aa, hi + aa, x));
75
+ }
76
+
77
+ float boxDist(vec2 p, vec2 lo, vec2 hi) {
78
+ vec2 d = abs(p - 0.5 * (lo + hi)) - 0.5 * (hi - lo);
79
+ return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
80
+ }
81
+
82
+ vec4 transition(vec2 uv) {
83
+ if (progress <= 0.0) return getFromColor(uv);
84
+ if (progress >= 1.0) return getToColor(uv);
85
+
86
+ bool portrait = ratio < 1.0;
87
+
88
+ vec2 aspect = vec2(ratio, 1.0) / min(ratio, 1.0);
89
+ vec2 p = uv * aspect;
90
+
91
+ float open = smoothstep(0.0, OPEN, progress) * (1.0 - smoothstep(1.0 - OPEN, 1.0, progress));
92
+ float g = gutter * open;
93
+ float ov = clamp(overlap, 0.0, 0.9);
94
+
95
+ float span = (1.0 - 2.0 * START) / (1.0 + float(PANELS - 1) * (1.0 - ov));
96
+
97
+ vec4 color = vec4(0.0);
98
+ float cover = 0.0;
99
+ float shade = 0.0;
100
+ for (int i = 0; i < PANELS; i++) {
101
+ vec4 r = panelRect(i, portrait);
102
+ vec2 lo = r.xy * aspect + 0.5 * g;
103
+ vec2 hi = r.zw * aspect - 0.5 * g;
104
+
105
+ lo = mix(lo, vec2(-1.0), step(r.xy, vec2(0.0)));
106
+ hi = mix(hi, aspect + 1.0, step(vec2(1.0), r.zw));
107
+ float t = clamp((progress - START - float(i) * span * (1.0 - ov)) / span, 0.0, 1.0);
108
+
109
+ float lift = 1.0 + 1.2 * sin(3.141592653589793 * t);
110
+
111
+ float sd = boxDist(p - vec2(0.2, -0.35) * g * lift, lo, hi);
112
+ shade = max(shade, (1.0 - smoothstep(-0.2 * g, 0.6 * g * lift + 1e-4, sd)) / sqrt(lift));
113
+
114
+ float inside = span1(p.x, lo.x, hi.x, EDGE) * span1(p.y, lo.y, hi.y, EDGE);
115
+ if (inside > 0.0) {
116
+ vec2 dir = panelDir(i, portrait);
117
+ vec4 c;
118
+ if (t <= 0.0) {
119
+ c = getFromColor(uv);
120
+ } else if (t >= 1.0) {
121
+ c = getToColor(uv);
122
+ } else {
123
+ float e = easeInOut(t);
124
+
125
+ float len = abs(dot(r.zw - r.xy, dir));
126
+ float w = band * len;
127
+ vec2 q = uv - dir * e * (len + w);
128
+
129
+ float a = dot(q - (dir.x + dir.y < 0.0 ? r.zw : r.xy), dir);
130
+
131
+ float af = a * abs(dot(aspect, dir));
132
+ float wf = w * abs(dot(aspect, dir));
133
+ float fromW = smoothstep(-EDGE, 0.0, af);
134
+ float toW = 1.0 - smoothstep(-wf, -wf + EDGE, af);
135
+
136
+ float bandShade = 1.0 - shadow * 0.5 * (1.0 - smoothstep(-wf, -wf + 0.35 * wf + 1e-4, af));
137
+ vec4 b = vec4(accent.rgb * bandShade, accent.a);
138
+
139
+ c = mix(b, getFromColor(clamp(q, r.xy, r.zw)), fromW);
140
+ c = mix(c, getToColor(clamp(q + dir * (len + w), r.xy, r.zw)), toW);
141
+ }
142
+ color += c * inside;
143
+ cover += inside;
144
+ }
145
+ }
146
+ color /= max(cover, 1.0);
147
+ cover = min(cover, 1.0);
148
+ vec4 bg = vec4(paper.rgb * (1.0 - shadow * shade * open), paper.a);
149
+ return color + bg * (1.0 - cover);
150
+ }
151
+
152
+ half4 main(float2 _coord) {
153
+ vec2 _uv = _coord / _resolution;
154
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
155
+ return half4(_c.rgb * _c.a, _c.a);
156
+ }
@@ -0,0 +1,85 @@
1
+ // ProjectorThrow — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ProjectorThrow.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The lights go down on the outgoing image and a projector throws the incoming one onto it: a small, blurred, keystoned picture of light lands on the scene, tinted by the colors it falls on, then grows, comes into focus and squares up until it fills the frame as the scene beneath it fades away
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform float darkness;
16
+
17
+ uniform float keystone;
18
+
19
+ uniform float blur;
20
+
21
+ vec2 mirror(vec2 v) {
22
+ return 1.0 - abs(1.0 - mod(v, 2.0));
23
+ }
24
+
25
+ vec4 projected(vec2 q, vec2 r) {
26
+ vec4 c = vec4(0.0);
27
+ for (int i = 0; i < 8; i++) {
28
+ float a = float(i) * 2.39996;
29
+ vec2 o = sqrt((float(i) + 0.5) / 8.0) * vec2(cos(a), sin(a));
30
+ vec4 t = getToColor(mirror(q + o * r));
31
+ c += vec4(t.rgb * t.a, t.a);
32
+ }
33
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a / 8.0) : vec4(0.0);
34
+ }
35
+
36
+ vec4 transition(vec2 uv) {
37
+ float p = progress;
38
+ if (p <= 0.0) return getFromColor(uv);
39
+ if (p >= 1.0) return getToColor(uv);
40
+ vec4 from = getFromColor(uv);
41
+
42
+
43
+ float on = smoothstep(0.06, 0.26, p);
44
+ float ambient = 1.0 - darkness * smoothstep(0.0, 0.2, p);
45
+
46
+ float g = smoothstep(0.02, 1.0, p);
47
+ float focus = 1.0 - smoothstep(0.15, 0.85, p);
48
+ float size = mix(0.32, 1.0, g * (0.6 + 0.4 * g));
49
+ float k = keystone * (1.0 - g);
50
+ float cy = mix(0.58, 0.5, g);
51
+
52
+
53
+ float y = (uv.y - cy) / size + 0.5;
54
+ float wy = max(1.0 - 0.5 * k + k * y, 0.05);
55
+ vec2 q = vec2((uv.x - 0.5) / (size * wy) + 0.5, y * (1.0 + 0.5 * k) / wy);
56
+
57
+
58
+ float e = min((0.5 * size * wy - abs(uv.x - 0.5)) * ratio, size * min(y, 1.0 - y));
59
+ float soft = 0.0015 + 0.035 * focus;
60
+ float cov = mix(smoothstep(-soft, soft, e), 1.0, smoothstep(0.9, 1.0, p));
61
+
62
+ float halo = 0.15 * focus * on * exp(-24.0 * max(-e, 0.0)) * (1.0 - cov);
63
+
64
+
65
+ vec2 d = q - 0.5;
66
+ float gain = on * mix(1.25, 1.0, g) * (1.0 + focus * (0.15 - 1.2 * dot(d, d)));
67
+
68
+ vec2 r = blur * focus / (size * wy) * vec2(1.0 / ratio, (1.0 - 0.25 * k * k) / wy);
69
+ vec4 pic = projected(q, r);
70
+ vec3 light = pic.rgb * gain * cov + halo;
71
+
72
+
73
+
74
+ float screen = smoothstep(0.35, 0.95, p);
75
+ vec3 surface = mix(from.rgb, vec3(1.0), 0.35 + 0.65 * screen);
76
+ vec3 col = from.rgb * ambient * (1.0 - cov * screen) + surface * light;
77
+
78
+ return vec4(col, mix(max(from.a, pic.a * cov * on), pic.a, cov * screen));
79
+ }
80
+
81
+ half4 main(float2 _coord) {
82
+ vec2 _uv = _coord / _resolution;
83
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
84
+ return half4(_c.rgb * _c.a, _c.a);
85
+ }