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.
- package/CHANGELOG.md +46 -0
- package/compatibility.json +306 -0
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/CardDeal.glsl +146 -0
- package/glsl3/CircleBurst.glsl +77 -0
- package/glsl3/CodeRain.glsl +114 -0
- package/glsl3/CurtainRise.glsl +71 -0
- package/glsl3/EchoSlide.glsl +93 -0
- package/glsl3/GeometricCollage.glsl +241 -0
- package/glsl3/GravityLens.glsl +66 -0
- package/glsl3/HingedSquares.glsl +121 -0
- package/glsl3/HorizontalHold.glsl +62 -0
- package/glsl3/LayoutGrid.glsl +147 -0
- package/glsl3/ProjectorThrow.glsl +75 -0
- package/glsl3/Reassemble.glsl +156 -0
- package/glsl3/RingSpin.glsl +112 -0
- package/glsl3/Shockwave.glsl +103 -0
- package/glsl3/ShoreWash.glsl +150 -0
- package/glsl3/ShutterWipe.glsl +68 -0
- package/glsl3/SpotlightWipe.glsl +63 -0
- package/glsl3/StopMotion.glsl +118 -0
- package/glsl3/Vaporize.glsl +125 -0
- package/index.js +1 -1
- package/layouts.json +725 -1
- package/llms-full.txt +734 -422
- package/llms.txt +238 -219
- package/msl/CardDeal.metal +539 -0
- package/msl/CircleBurst.metal +351 -0
- package/msl/CodeRain.metal +451 -0
- package/msl/CurtainRise.metal +263 -0
- package/msl/EchoSlide.metal +438 -0
- package/msl/GeometricCollage.metal +1188 -0
- package/msl/GravityLens.metal +236 -0
- package/msl/HingedSquares.metal +564 -0
- package/msl/HorizontalHold.metal +286 -0
- package/msl/LayoutGrid.metal +544 -0
- package/msl/ProjectorThrow.metal +313 -0
- package/msl/Reassemble.metal +667 -0
- package/msl/RingSpin.metal +474 -0
- package/msl/Shockwave.metal +256 -0
- package/msl/ShoreWash.metal +538 -0
- package/msl/ShutterWipe.metal +286 -0
- package/msl/SpotlightWipe.metal +217 -0
- package/msl/StopMotion.metal +551 -0
- package/msl/Vaporize.metal +462 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +94 -44
- package/sksl/CardDeal.sksl +156 -0
- package/sksl/CircleBurst.sksl +84 -0
- package/sksl/CodeRain.sksl +124 -0
- package/sksl/CurtainRise.sksl +84 -0
- package/sksl/EchoSlide.sksl +99 -0
- package/sksl/GeometricCollage.sksl +242 -0
- package/sksl/GravityLens.sksl +77 -0
- package/sksl/HingedSquares.sksl +124 -0
- package/sksl/HorizontalHold.sksl +74 -0
- package/sksl/LayoutGrid.sksl +156 -0
- package/sksl/ProjectorThrow.sksl +85 -0
- package/sksl/Reassemble.sksl +166 -0
- package/sksl/RingSpin.sksl +121 -0
- package/sksl/Shockwave.sksl +116 -0
- package/sksl/ShoreWash.sksl +159 -0
- package/sksl/ShutterWipe.sksl +80 -0
- package/sksl/SpotlightWipe.sksl +74 -0
- package/sksl/StopMotion.sksl +126 -0
- package/sksl/Vaporize.sksl +134 -0
- package/sksl/index.js +1 -1
- package/transitions/CardDeal.glsl +145 -0
- package/transitions/CircleBurst.glsl +76 -0
- package/transitions/CodeRain.glsl +113 -0
- package/transitions/CurtainRise.glsl +70 -0
- package/transitions/EchoSlide.glsl +92 -0
- package/transitions/GeometricCollage.glsl +240 -0
- package/transitions/GravityLens.glsl +65 -0
- package/transitions/HingedSquares.glsl +120 -0
- package/transitions/HorizontalHold.glsl +61 -0
- package/transitions/LayoutGrid.glsl +146 -0
- package/transitions/ProjectorThrow.glsl +74 -0
- package/transitions/Reassemble.glsl +155 -0
- package/transitions/RingSpin.glsl +111 -0
- package/transitions/Shockwave.glsl +102 -0
- package/transitions/ShoreWash.glsl +149 -0
- package/transitions/ShutterWipe.glsl +67 -0
- package/transitions/SpotlightWipe.glsl +62 -0
- package/transitions/StopMotion.glsl +117 -0
- package/transitions/Vaporize.glsl +124 -0
- package/wgsl/CardDeal.wgsl +496 -0
- package/wgsl/CircleBurst.wgsl +310 -0
- package/wgsl/CodeRain.wgsl +415 -0
- package/wgsl/CurtainRise.wgsl +235 -0
- package/wgsl/EchoSlide.wgsl +386 -0
- package/wgsl/GeometricCollage.wgsl +1075 -0
- package/wgsl/GravityLens.wgsl +206 -0
- package/wgsl/HingedSquares.wgsl +506 -0
- package/wgsl/HorizontalHold.wgsl +243 -0
- package/wgsl/LayoutGrid.wgsl +495 -0
- package/wgsl/ProjectorThrow.wgsl +274 -0
- package/wgsl/Reassemble.wgsl +609 -0
- package/wgsl/RingSpin.wgsl +426 -0
- package/wgsl/Shockwave.wgsl +226 -0
- package/wgsl/ShoreWash.wgsl +492 -0
- package/wgsl/ShutterWipe.wgsl +252 -0
- package/wgsl/SpotlightWipe.wgsl +186 -0
- package/wgsl/StopMotion.wgsl +496 -0
- package/wgsl/Vaporize.wgsl +420 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// 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
|
|
4
|
+
// Tags: geometric, shapes, collage, rotate, color
|
|
5
|
+
|
|
6
|
+
// @range(1, 5, 1) Number of cells along the short side of the frame, the long side gets as many as keep them about square
|
|
7
|
+
uniform int cells; // = 2
|
|
8
|
+
// @range(0, 1) How spread out in time the pieces arrive: 0 swings them all in together, 1 lands them one after another
|
|
9
|
+
uniform float stagger; // = 1.0
|
|
10
|
+
// @param Show a flat plate of color swinging in just ahead of each piece
|
|
11
|
+
uniform bool plates; // = true
|
|
12
|
+
// @color First plate color
|
|
13
|
+
uniform vec4 color1; // = vec4(0.89, 0.22, 0.17, 1.0)
|
|
14
|
+
// @color Second plate color
|
|
15
|
+
uniform vec4 color2; // = vec4(0.97, 0.77, 0.15, 1.0)
|
|
16
|
+
// @color Third plate color
|
|
17
|
+
uniform vec4 color3; // = vec4(0.14, 0.32, 0.66, 1.0)
|
|
18
|
+
// @range(0, 1) Darkness of the shadows the pieces cast while they swing in
|
|
19
|
+
uniform float shadow; // = 0.6
|
|
20
|
+
|
|
21
|
+
const float PI = 3.141592653589793;
|
|
22
|
+
// shortest duration of the swing of one layer, delay of a cell's second piece, lead of a plate over its piece
|
|
23
|
+
const float DUR = 0.24;
|
|
24
|
+
const float GAP = 0.07;
|
|
25
|
+
const float LEAD = 0.06;
|
|
26
|
+
// part of a swing after which a layer has turned into place, and only comes down flat onto the paper
|
|
27
|
+
const float SETTLE = 0.8;
|
|
28
|
+
// width of the anti-aliased edges, in frame heights
|
|
29
|
+
const float EDGE = 0.002;
|
|
30
|
+
|
|
31
|
+
float hash12(vec2 v) {
|
|
32
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
33
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
34
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// the cell's layout seen from its first piece: the local point turned by k quarter turns around the cell center
|
|
38
|
+
vec2 orient(vec2 l, float k) {
|
|
39
|
+
vec2 c = l - 0.5;
|
|
40
|
+
if (k < 0.5) return l;
|
|
41
|
+
if (k < 1.5) return vec2(-c.y, c.x) + 0.5;
|
|
42
|
+
if (k < 2.5) return 0.5 - c;
|
|
43
|
+
return vec2(c.y, -c.x) + 0.5;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// the cell corner that orient(., k) maps to the corner (0, 0): the first piece's pivot
|
|
47
|
+
vec2 pivotCorner(float k) {
|
|
48
|
+
if (k < 0.5) return vec2(0.0, 0.0);
|
|
49
|
+
if (k < 1.5) return vec2(0.0, 1.0);
|
|
50
|
+
if (k < 2.5) return vec2(1.0, 1.0);
|
|
51
|
+
return vec2(1.0, 0.0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// signed distance (in cell units) to the cell's first piece, negative inside; the second piece is its complement
|
|
55
|
+
float shapeDist(vec2 o, float type) {
|
|
56
|
+
if (type < 0.5) return length(o) - 1.0; // quarter disc around the pivot
|
|
57
|
+
if (type < 1.5) return length(o - vec2(0.5, 0.0)) - 0.5; // half disc on an edge
|
|
58
|
+
return (o.x + o.y - 1.0) * 0.70710678; // triangle
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// signed distance (in cell units) to a piece of a cell at the local point l, negative inside
|
|
62
|
+
float pieceDist(vec2 l, vec2 cell, float piece) {
|
|
63
|
+
float k = floor(hash12(cell + 1.7) * 4.0);
|
|
64
|
+
// cells side by side never share a shape
|
|
65
|
+
float sd = shapeDist(orient(l, k), mod(cell.x + 2.0 * cell.y + 1.0, 3.0));
|
|
66
|
+
return piece > 0.5 ? -sd : sd;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
float boxDist(vec2 l) {
|
|
70
|
+
return min(min(l.x, l.y), min(1.0 - l.x, 1.0 - l.y));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
float easeOutCubic(float t) {
|
|
74
|
+
float u = 1.0 - clamp(t, 0.0, 1.0);
|
|
75
|
+
return 1.0 - u * u * u;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// how high a layer floats above the paper along its swing, 0 once landed
|
|
79
|
+
float lift(float t) {
|
|
80
|
+
return 1.0 - smoothstep(0.3, 1.0, t);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// the time over which the cells start one after another, and the duration of a swing, which gets
|
|
84
|
+
// longer when the cells start closer together, so that the last piece always lands just before the end
|
|
85
|
+
float spread() {
|
|
86
|
+
return (1.0 - DUR - GAP - LEAD - 0.02) * clamp(stagger, 0.0, 1.0);
|
|
87
|
+
}
|
|
88
|
+
float swing() {
|
|
89
|
+
return 1.0 - GAP - LEAD - 0.02 - spread();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// when the first piece of a cell starts to swing in; the second one starts GAP later, and a plate LEAD before its piece
|
|
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
|
+
// the local point in the cell of a swinging layer at its local time t (0 < t < 1), seen at the frame point p,
|
|
100
|
+
// and its scale
|
|
101
|
+
vec3 swingPoint(vec2 p, vec2 cell, vec2 cs, float piece, float t) {
|
|
102
|
+
vec2 pc = pivotCorner(floor(hash12(cell + 1.7) * 4.0));
|
|
103
|
+
// the first piece turns around its pivot corner, its complement around the opposite one
|
|
104
|
+
vec2 piv = (cell + (piece < 0.5 ? pc : 1.0 - pc)) * cs;
|
|
105
|
+
float sgn = hash12(cell + vec2(piece * 3.3, 5.2)) < 0.5 ? -1.0 : 1.0;
|
|
106
|
+
// grows out of the corner while it swings a quarter turn into place, a bit bigger while it floats
|
|
107
|
+
float s = smoothstep(0.0, 0.45, t) * (1.0 + 0.1 * lift(t));
|
|
108
|
+
// the swing settles first, then the layer comes down flat onto the paper
|
|
109
|
+
float a = sgn * 0.5 * PI * (1.0 - easeOutCubic(t / SETTLE));
|
|
110
|
+
float ca = cos(a), sa = sin(a);
|
|
111
|
+
vec2 d = p - piv;
|
|
112
|
+
d = vec2(ca * d.x + sa * d.y, -sa * d.x + ca * d.y) / max(s, 0.001);
|
|
113
|
+
return vec3((piv + d) / cs - cell, s);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// the coverage of a swinging layer and its local point in the cell
|
|
117
|
+
vec3 layerCover(vec2 p, vec2 cell, vec2 cs, float piece, float t) {
|
|
118
|
+
vec3 q = swingPoint(p, cell, cs, piece, t);
|
|
119
|
+
if (q.z < 0.01) return vec3(0.0);
|
|
120
|
+
float e = EDGE / (min(cs.x, cs.y) * q.z);
|
|
121
|
+
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);
|
|
122
|
+
return vec3(m, clamp(q.xy, 0.0, 1.0));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// the coverage of the soft shadow of a swinging layer: it falls down and to the right, further away the higher it floats
|
|
126
|
+
float layerShadow(vec2 p, vec2 cell, vec2 cs, float piece, float t) {
|
|
127
|
+
float h = lift(t);
|
|
128
|
+
vec3 q = swingPoint(p - vec2(0.07, -0.1) * h * cs.y, cell, cs, piece, t);
|
|
129
|
+
if (q.z < 0.01) return 0.0;
|
|
130
|
+
float soft = 0.02 + 0.05 * h;
|
|
131
|
+
return h * (1.0 - smoothstep(-soft, soft, pieceDist(q.xy, cell, piece))) * smoothstep(-soft, soft, boxDist(q.xy));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
vec4 plateColor(vec2 cell, float piece) {
|
|
135
|
+
float c = mod(floor(hash12(cell * 1.3 + 0.7) * 3.0) + piece, 3.0);
|
|
136
|
+
return c < 0.5 ? color1 : c < 1.5 ? color2 : color3;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
vec4 premultiplied(vec4 c) {
|
|
140
|
+
return vec4(c.rgb * c.a, c.a);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
vec4 transition(vec2 uv) {
|
|
144
|
+
float kc = float(cells < 1 ? 1 : cells);
|
|
145
|
+
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)));
|
|
146
|
+
vec2 cs = vec2(ratio, 1.0) / n;
|
|
147
|
+
vec2 p = uv * vec2(ratio, 1.0);
|
|
148
|
+
vec2 cell0 = floor(p / cs);
|
|
149
|
+
float sw = swing();
|
|
150
|
+
|
|
151
|
+
// the paper: the outgoing image, where the pieces that have landed show the incoming one. They lie flat side by side
|
|
152
|
+
// and tile the frame exactly, with hard cell edges and anti-aliased edges between the two pieces of a cell
|
|
153
|
+
vec2 l0 = p / cs - cell0;
|
|
154
|
+
float t00 = startTime(cell0, n);
|
|
155
|
+
float sd0 = pieceDist(l0, cell0, 0.0);
|
|
156
|
+
float e0 = EDGE / min(cs.x, cs.y);
|
|
157
|
+
float landed = (progress >= t00 + sw ? clamp(-sd0 / e0 + 0.5, 0.0, 1.0) : 0.0)
|
|
158
|
+
+ (progress >= t00 + GAP + sw ? clamp(sd0 / e0 + 0.5, 0.0, 1.0) : 0.0);
|
|
159
|
+
// the layers still in the air, and the plates not yet covered by their pieces: the top one at p and the one
|
|
160
|
+
// under it by start time, as (start, coverage, plate, piece) and (cell, local point)
|
|
161
|
+
vec4 top = vec4(-1.0, 0.0, 0.0, 0.0);
|
|
162
|
+
vec4 topPos = vec4(0.0);
|
|
163
|
+
vec4 und = vec4(-1.0, 0.0, 0.0, 0.0);
|
|
164
|
+
vec4 undPos = vec4(0.0);
|
|
165
|
+
for (int dy = -1; dy <= 1; dy++) {
|
|
166
|
+
for (int dx = -1; dx <= 1; dx++) {
|
|
167
|
+
vec2 cell = cell0 + vec2(float(dx), float(dy));
|
|
168
|
+
if (cell.x < 0.0 || cell.y < 0.0 || cell.x >= n.x || cell.y >= n.y) continue;
|
|
169
|
+
float tc = startTime(cell, n);
|
|
170
|
+
for (int pc = 0; pc < 2; pc++) {
|
|
171
|
+
float piece = float(pc);
|
|
172
|
+
float t0 = tc + GAP * piece;
|
|
173
|
+
// how far the piece is in its swing
|
|
174
|
+
float tp = (progress - t0) / sw;
|
|
175
|
+
for (int ly = 0; ly < 2; ly++) {
|
|
176
|
+
float isPlate = ly == 0 ? 1.0 : 0.0;
|
|
177
|
+
if (isPlate > 0.5 && !plates) continue;
|
|
178
|
+
float ts = t0 - LEAD * isPlate;
|
|
179
|
+
float t = (progress - ts) / sw;
|
|
180
|
+
// a landed piece is part of the paper, and its plate fades out under it once it has turned into place
|
|
181
|
+
if (t <= 0.0 || tp >= 1.0 || (isPlate > 0.5 && tp >= SETTLE)) continue;
|
|
182
|
+
vec3 L = layerCover(p, cell, cs, piece, min(t, 1.0));
|
|
183
|
+
if (isPlate > 0.5) L.x *= 1.0 - smoothstep(SETTLE - 0.1, SETTLE, tp);
|
|
184
|
+
if (L.x <= 0.0) continue;
|
|
185
|
+
vec4 cur = vec4(ts, L.x, isPlate, piece);
|
|
186
|
+
vec4 curPos = vec4(cell, L.yz);
|
|
187
|
+
if (ts > top.x) {
|
|
188
|
+
und = top;
|
|
189
|
+
undPos = topPos;
|
|
190
|
+
top = cur;
|
|
191
|
+
topPos = curPos;
|
|
192
|
+
} else if (ts > und.x) {
|
|
193
|
+
und = cur;
|
|
194
|
+
undPos = curPos;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// a piece coming down next to its landed complement does not overlap it along their common edge: their coverages add up
|
|
201
|
+
if (top.z < 0.5 && und.x < 0.0 && topPos.x == cell0.x && topPos.y == cell0.y) {
|
|
202
|
+
landed = top.y < 1.0 ? landed / (1.0 - top.y) : 1.0;
|
|
203
|
+
}
|
|
204
|
+
vec4 c = mix(premultiplied(getFromColor(uv)), premultiplied(getToColor(uv)), clamp(landed, 0.0, 1.0));
|
|
205
|
+
if (und.x >= 0.0) {
|
|
206
|
+
vec4 uc = und.z > 0.5 ? plateColor(undPos.xy, und.w) : getToColor((undPos.xy + undPos.zw) * cs / vec2(ratio, 1.0));
|
|
207
|
+
c = mix(c, premultiplied(uc), und.y);
|
|
208
|
+
}
|
|
209
|
+
if (top.x >= 0.0) {
|
|
210
|
+
vec4 tc = top.z > 0.5 ? plateColor(topPos.xy, top.w) : getToColor((topPos.xy + topPos.zw) * cs / vec2(ratio, 1.0));
|
|
211
|
+
c = mix(c, premultiplied(tc), top.y);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// the soft shadows of the layers floating above the top one
|
|
215
|
+
float sh = 0.0;
|
|
216
|
+
if (shadow > 0.0) {
|
|
217
|
+
for (int dy = -1; dy <= 1; dy++) {
|
|
218
|
+
for (int dx = -1; dx <= 1; dx++) {
|
|
219
|
+
vec2 cell = cell0 + vec2(float(dx), float(dy));
|
|
220
|
+
if (cell.x < 0.0 || cell.y < 0.0 || cell.x >= n.x || cell.y >= n.y) continue;
|
|
221
|
+
float tc = startTime(cell, n);
|
|
222
|
+
for (int pc = 0; pc < 2; pc++) {
|
|
223
|
+
float piece = float(pc);
|
|
224
|
+
float t0 = tc + GAP * piece;
|
|
225
|
+
float tp = (progress - t0) / sw;
|
|
226
|
+
for (int ly = 0; ly < 2; ly++) {
|
|
227
|
+
float isPlate = ly == 0 ? 1.0 : 0.0;
|
|
228
|
+
if (isPlate > 0.5 && (!plates || tp >= SETTLE)) continue;
|
|
229
|
+
float ts = t0 - LEAD * isPlate;
|
|
230
|
+
float t = (progress - ts) / sw;
|
|
231
|
+
if (ts <= top.x || t <= 0.0 || t >= 1.0) continue;
|
|
232
|
+
sh = max(sh, layerShadow(p, cell, cs, piece, t));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
c.rgb *= 1.0 - 0.7 * clamp(shadow, 0.0, 1.0) * sh;
|
|
239
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
240
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A black disk appears and grows, bending the outgoing image around it like a heavy mass bends light: the image is stretched into a bright ring at the disk's edge and swallowed until the frame is black, then the disk shrinks back, unbending the incoming image
|
|
4
|
+
// Tags: distort, lens, space, circular, dark
|
|
5
|
+
|
|
6
|
+
// Center of the disk
|
|
7
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
8
|
+
// @range(0, 1.5) How strongly the light bends: radius of the lensed ring beyond the disk's edge, in disk radii
|
|
9
|
+
uniform float strength; // = 0.6
|
|
10
|
+
// @range(0, 1) Brightness of the lensed ring and of the thin ring of light hugging the disk's edge
|
|
11
|
+
uniform float glow; // = 0.6
|
|
12
|
+
// @color Color of the disk
|
|
13
|
+
uniform vec4 hole; // = vec4(0.0, 0.0, 0.0, 1.0)
|
|
14
|
+
|
|
15
|
+
// how far past the farthest corner the disk grows, so the frame is fully covered for a brief moment
|
|
16
|
+
const float OVERSHOOT = 0.12;
|
|
17
|
+
// moment the frame is black: the swallow takes a little longer than the release
|
|
18
|
+
const float PEAK = 0.55;
|
|
19
|
+
// half width of the antialiased edge of the disk, in frame heights
|
|
20
|
+
const float AA = 0.002;
|
|
21
|
+
// tint of the light piled up around the disk
|
|
22
|
+
const vec3 WARM = vec3(1.0, 0.86, 0.68);
|
|
23
|
+
|
|
24
|
+
// fold the coordinates back into the frame, so the image stays filled without smearing its border
|
|
25
|
+
vec2 mirrored(vec2 v) {
|
|
26
|
+
vec2 m = mod(v, 2.0);
|
|
27
|
+
return mix(m, 2.0 - m, step(1.0, m));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
vec4 transition(vec2 uv) {
|
|
31
|
+
// the disk grows with an accelerating swallow, then shrinks back a little faster: exactly 0 at both ends
|
|
32
|
+
bool swallowing = progress < PEAK;
|
|
33
|
+
float u = swallowing ? progress / PEAK : (1.0 - progress) / (1.0 - PEAK);
|
|
34
|
+
float u2 = u * u;
|
|
35
|
+
float k = u2 * (0.6 + 0.4 * u2);
|
|
36
|
+
|
|
37
|
+
// measured in frame heights, so the disk is round
|
|
38
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
39
|
+
vec2 far = max(center, 1.0 - center) * aspect;
|
|
40
|
+
float rh = length(far) * (1.0 + OVERSHOOT) * k;
|
|
41
|
+
// radius where the light coming from right behind the disk shows up as a ring
|
|
42
|
+
float re = rh * (1.0 + max(strength, 0.0));
|
|
43
|
+
|
|
44
|
+
vec2 d = (uv - center) * aspect;
|
|
45
|
+
float r = max(length(d), 1e-5);
|
|
46
|
+
// a point mass deflects the light by an angle falling off as 1/r
|
|
47
|
+
vec2 q = mirrored(center + d * (1.0 - re * re / (r * r)) / aspect);
|
|
48
|
+
vec4 c = swallowing ? getFromColor(q) : getToColor(q);
|
|
49
|
+
// the shading fades in with the disk, so it is exactly 0 at both ends
|
|
50
|
+
float amount = smoothstep(0.0, 0.04, rh);
|
|
51
|
+
// the second, flipped image squeezed between the ring and the disk is dimmer
|
|
52
|
+
float inner = clamp((r - rh) / (re - rh + 1e-4), 0.0, 1.0);
|
|
53
|
+
c.rgb *= 1.0 - 0.7 * amount * (1.0 - inner * inner * (3.0 - 2.0 * inner));
|
|
54
|
+
|
|
55
|
+
// light piles up into a ring where the image is most stretched, and into a thin ring hugging the edge
|
|
56
|
+
float g = max(glow, 0.0) * amount;
|
|
57
|
+
float einstein = (r - re) / (0.3 * (re - rh) + 0.01);
|
|
58
|
+
float photon = max(r - rh, 0.0) / (0.006 + 0.012 * rh);
|
|
59
|
+
float light = g * (0.7 * exp(-einstein * einstein) + 1.6 * exp(-photon * photon));
|
|
60
|
+
c.rgb = min(c.rgb * (1.0 + light) + WARM * (0.35 * light * c.a), vec3(1.0));
|
|
61
|
+
|
|
62
|
+
// antialiased horizon, kept inside the disk so it vanishes with it
|
|
63
|
+
float cov = clamp((rh - r) / (2.0 * AA), 0.0, 1.0);
|
|
64
|
+
return mix(c, hole, cov);
|
|
65
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// 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
|
|
4
|
+
// Tags: grid, tiles, geometric, rotate
|
|
5
|
+
|
|
6
|
+
// @range(1, 20, 1) Number of squares across the height of the frame
|
|
7
|
+
uniform int cells; // = 5
|
|
8
|
+
// @range(0, 1) Strength of the bevel on the turning squares and of the soft shadow they cast into the gaps
|
|
9
|
+
uniform float shading; // = 0.6
|
|
10
|
+
// @range(0, 1) How much the view zooms out to keep the opening sheet in frame (0: the sheet grows past the frame edges)
|
|
11
|
+
uniform float zoom; // = 0.5
|
|
12
|
+
|
|
13
|
+
const float PI = 3.141592653589793;
|
|
14
|
+
// half width of the anti-aliased edges, as a part of the frame's height
|
|
15
|
+
const float EDGE = 0.0012;
|
|
16
|
+
|
|
17
|
+
// turns v clockwise by the angle whose cosine and sine are cs
|
|
18
|
+
vec2 rot(vec2 v, vec2 cs) {
|
|
19
|
+
return vec2(cs.x * v.x + cs.y * v.y, -cs.y * v.x + cs.x * v.y);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// one of the 4 lattice nodes around a point
|
|
23
|
+
vec2 node(float i) {
|
|
24
|
+
return vec2(mod(i, 2.0), floor(i * 0.5));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// alternate squares turn in opposite directions
|
|
28
|
+
float parity(vec2 n) {
|
|
29
|
+
return mod(n.x + n.y, 2.0) < 0.5 ? 1.0 : -1.0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// The square nearest to w among the 4 around the cell g of a hinged lattice of unit squares
|
|
33
|
+
// centered at (n + off) * spacing, each turned by +-the angle of cs:
|
|
34
|
+
// returns its local coordinates, the signed distance to it and its node index.
|
|
35
|
+
vec4 nearest(vec2 w, vec2 g, float spacing, vec2 off, vec2 cs) {
|
|
36
|
+
vec4 best = vec4(0.0, 0.0, 1e5, 0.0);
|
|
37
|
+
for (int i = 0; i < 4; i++) {
|
|
38
|
+
vec2 n = g + node(float(i));
|
|
39
|
+
vec2 l = rot(w - (n + off) * spacing, vec2(cs.x, parity(n) * cs.y));
|
|
40
|
+
vec2 q = abs(l) - 0.5;
|
|
41
|
+
float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
|
|
42
|
+
if (d < best.z) best = vec4(l, d, float(i));
|
|
43
|
+
}
|
|
44
|
+
return best;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// The gap of that lattice around w: a rhombus of unit sides centered at a node of the other
|
|
48
|
+
// lattice, with half diagonals cs.x and cs.y. Returns the local coordinates of the piece of the
|
|
49
|
+
// other image it shows, held at 45 degrees, and its node index.
|
|
50
|
+
vec3 gap(vec2 w, vec2 g, float spacing, vec2 off, vec2 cs) {
|
|
51
|
+
vec3 best = vec3(0.0, 0.0, 0.0);
|
|
52
|
+
float r = 1e5;
|
|
53
|
+
for (int i = 0; i < 4; i++) {
|
|
54
|
+
vec2 n = g + node(float(i));
|
|
55
|
+
vec2 v = w - (n + off) * spacing;
|
|
56
|
+
vec2 h = parity(n) > 0.0 ? cs.yx : cs;
|
|
57
|
+
// inside the rhombus when |v.x| / h.x + |v.y| / h.y < 1, scaled by h.x * h.y to avoid dividing by 0
|
|
58
|
+
float ri = abs(v.x) * h.y + abs(v.y) * h.x;
|
|
59
|
+
if (ri < r) {
|
|
60
|
+
r = ri;
|
|
61
|
+
best = vec3(rot(v, vec2(0.7071068, parity(n) * 0.7071068)), float(i));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return best;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// lattice coordinates (in squares, centered) to a mirrored texture uv that stays in the frame
|
|
68
|
+
vec2 toUV(vec2 c, float n) {
|
|
69
|
+
vec2 uv = c / (n * vec2(ratio, 1.0)) + 0.5;
|
|
70
|
+
return abs(mod(uv + 1.0, 2.0) - 1.0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
vec4 transition(vec2 uv) {
|
|
74
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
75
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
76
|
+
float n = max(float(cells), 1.0);
|
|
77
|
+
float e = progress * progress * (3.0 - 2.0 * progress);
|
|
78
|
+
float a = 0.5 * PI * e;
|
|
79
|
+
// turn of the squares in front: 0 to 45 degrees for the outgoing ones, then 45 to 0 for the incoming ones
|
|
80
|
+
float th = min(a, 0.5 * PI - a);
|
|
81
|
+
// the hinged lattice spreads while it opens
|
|
82
|
+
vec2 cs = vec2(cos(th), sin(th));
|
|
83
|
+
float spacing = cs.x + cs.y;
|
|
84
|
+
float scale = n * mix(1.0, spacing, clamp(zoom, 0.0, 1.0));
|
|
85
|
+
vec2 w = (uv - 0.5) * vec2(ratio, 1.0) * scale;
|
|
86
|
+
bool first = a < 0.25 * PI;
|
|
87
|
+
vec2 offF = first ? vec2(0.0) : vec2(0.5);
|
|
88
|
+
vec2 offB = vec2(0.5) - offF;
|
|
89
|
+
vec2 gF = floor(w / spacing - offF);
|
|
90
|
+
vec2 gB = floor(w / spacing - offB);
|
|
91
|
+
// front: the turning squares; back: the pieces of the other image held at 45 degrees in the gaps
|
|
92
|
+
vec4 f = nearest(w, gF, spacing, offF, cs);
|
|
93
|
+
vec3 b = gap(w, gB, spacing, offB, cs);
|
|
94
|
+
vec2 nf = gF + node(f.w);
|
|
95
|
+
vec2 nb = gB + node(b.z);
|
|
96
|
+
vec2 uvF = toUV(nf + offF + f.xy, n);
|
|
97
|
+
vec2 uvB = toUV(nb + offB + b.xy, n);
|
|
98
|
+
vec4 colF = first ? getFromColor(uvF) : getToColor(uvF);
|
|
99
|
+
vec4 colB = first ? getToColor(uvB) : getFromColor(uvB);
|
|
100
|
+
|
|
101
|
+
// relief: none when the sheet is closed or fully open, strongest in between
|
|
102
|
+
float depth = clamp(shading, 0.0, 1.0) * sin(4.0 * th);
|
|
103
|
+
// soft shadow cast by the front squares toward the lower right
|
|
104
|
+
if (depth > 0.0) {
|
|
105
|
+
vec2 ws = w - vec2(0.12, -0.12) * depth;
|
|
106
|
+
vec4 sh = nearest(ws, floor(ws / spacing - offF), spacing, offF, cs);
|
|
107
|
+
colB.rgb *= 1.0 - 0.75 * depth * (1.0 - smoothstep(-0.12, 0.25, sh.z));
|
|
108
|
+
}
|
|
109
|
+
// bevel lit from the upper left, along each square's nearest side
|
|
110
|
+
vec2 side = abs(f.x) > abs(f.y) ? vec2(sign(f.x), 0.0) : vec2(0.0, sign(f.y));
|
|
111
|
+
float facing = dot(rot(side, vec2(cs.x, -parity(nf) * cs.y)), vec2(-0.7071, 0.7071));
|
|
112
|
+
float rim = smoothstep(-0.07, -0.01, f.z);
|
|
113
|
+
colF.rgb *= 1.0 + 0.35 * depth * rim * facing;
|
|
114
|
+
|
|
115
|
+
// anti-aliased edges; the squares overlap a little to hide the gaps until they are a few pixels wide
|
|
116
|
+
float aa = EDGE * scale;
|
|
117
|
+
float seal = aa * (1.0 - smoothstep(0.0, 3.0 * aa, cs.y));
|
|
118
|
+
float cover = 1.0 - smoothstep(-aa, aa, f.z - seal);
|
|
119
|
+
return mix(colB, colF, cover);
|
|
120
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// 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
|
|
4
|
+
// Tags: retro, horizontal, shear, scanlines
|
|
5
|
+
|
|
6
|
+
// @range(2, 6, 1) Number of times the picture slips sideways before it locks
|
|
7
|
+
uniform int slips; // = 3
|
|
8
|
+
// @range(0, 4) How far the lines lag from top to bottom at the worst of the tearing, in picture widths
|
|
9
|
+
uniform float shear; // = 1.25
|
|
10
|
+
// @range(0, 0.5) Width of the blanking bar between the copies of the picture
|
|
11
|
+
uniform float barWidth; // = 0.14
|
|
12
|
+
// @color Color of the blanking bar
|
|
13
|
+
uniform vec4 barColor; // = vec4(0.02, 0.02, 0.03, 1.0)
|
|
14
|
+
|
|
15
|
+
float slipCount() {
|
|
16
|
+
return max(float(slips), 1.0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// The picture stream at x: outgoing copies, then incoming ones, with a bar between them
|
|
20
|
+
vec4 stream(float x, float y, float unsync) {
|
|
21
|
+
float period = 1.0 + barWidth;
|
|
22
|
+
float n = floor(x / period);
|
|
23
|
+
float xm = x - n * period;
|
|
24
|
+
vec2 q = vec2(min(xm, 1.0), y);
|
|
25
|
+
vec4 c = n >= floor(0.5 * slipCount() + 0.5) ? getToColor(q) : getFromColor(q);
|
|
26
|
+
// distance to the nearest bar, negative inside it
|
|
27
|
+
float d = min(xm, 1.0 - xm);
|
|
28
|
+
// the picture overshoots to white next to the bar
|
|
29
|
+
float g = max(1.0 - d / 0.05, 0.0);
|
|
30
|
+
c.rgb += 0.3 * unsync * g * g * c.a;
|
|
31
|
+
float soft = min(0.012 * unsync, 0.5 * barWidth) + 1e-5;
|
|
32
|
+
return mix(barColor, c, clamp(d / soft, 0.0, 1.0));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
vec4 transition(vec2 uv) {
|
|
36
|
+
float period = 1.0 + barWidth;
|
|
37
|
+
// the sync error grows then fades; the slip is its integral, a whole number of periods
|
|
38
|
+
float t = min(progress / 0.88, 1.0);
|
|
39
|
+
float err = 16.0 * t * t * (1.0 - t) * (1.0 - t);
|
|
40
|
+
float slip = t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
|
|
41
|
+
// the hold overshoots and wobbles before it locks
|
|
42
|
+
float u = clamp((progress - 0.74) / 0.26, 0.0, 1.0);
|
|
43
|
+
float lock = u * (1.0 - u) * (1.0 - u);
|
|
44
|
+
float tilt = -0.5 * max(shear, 0.5) * lock * sin(9.42478 * u);
|
|
45
|
+
float unsync = min(err + 3.0 * lock, 1.0);
|
|
46
|
+
// lines lower in the frame lag behind, and ripple a little
|
|
47
|
+
float ripple = 0.012 * sin(uv.y * 9.0 + progress * 40.0) + 0.005 * sin(uv.y * 31.0 - progress * 70.0);
|
|
48
|
+
float x = uv.x + period * (slipCount() * slip + shear * err * (1.0 - uv.y) + tilt * (1.0 - uv.y)) + err * ripple;
|
|
49
|
+
// the slip smears the picture sideways
|
|
50
|
+
float blur = 0.002 * err * slipCount();
|
|
51
|
+
vec4 c = stream(x, uv.y, unsync);
|
|
52
|
+
if (blur > 0.0) {
|
|
53
|
+
for (int i = 0; i < 4; i++) {
|
|
54
|
+
c += stream(x + blur * (float(i) - 1.5), uv.y, unsync);
|
|
55
|
+
}
|
|
56
|
+
c /= 5.0;
|
|
57
|
+
}
|
|
58
|
+
// the unsynced picture dims and shows its scanlines
|
|
59
|
+
c.rgb *= 1.0 - unsync * (0.1 + 0.08 * sin(uv.y * 480.0));
|
|
60
|
+
return c;
|
|
61
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// 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
|
|
4
|
+
// Tags: grid, panels, magazine, push, slide, layout
|
|
5
|
+
|
|
6
|
+
// @range(0, 0.08) Width of the gutters at their widest, as a part of the frame's shorter side
|
|
7
|
+
uniform float gutter; // = 0.04
|
|
8
|
+
// @range(0, 0.9) How much the panels' pushes overlap in time (0 pushes them one strictly after another, 0.9 almost all together)
|
|
9
|
+
uniform float overlap; // = 0.55
|
|
10
|
+
// @range(0, 0.6) Length of the accent band between the two images, as a part of the panel's length along its push
|
|
11
|
+
uniform float band; // = 0.22
|
|
12
|
+
// @range(0, 1) Darkness of the soft shadows the panels cast on the paper and the incoming image casts on the band
|
|
13
|
+
uniform float shadow; // = 0.4
|
|
14
|
+
// @color Color of the paper seen in the gutters
|
|
15
|
+
uniform vec4 paper; // = vec4(0.96, 0.95, 0.91, 1.0)
|
|
16
|
+
// @color Color of the accent band between the outgoing and incoming images
|
|
17
|
+
uniform vec4 accent; // = vec4(0.93, 0.27, 0.2, 1.0)
|
|
18
|
+
|
|
19
|
+
const int PANELS = 6;
|
|
20
|
+
// the gutters open over [0, OPEN] and close over [1 - OPEN, 1]
|
|
21
|
+
const float OPEN = 0.28;
|
|
22
|
+
// the first push starts at START, the last one ends at 1 - START
|
|
23
|
+
const float START = 0.1;
|
|
24
|
+
// width of the antialiased edges, as a part of the frame's shorter side
|
|
25
|
+
const float EDGE = 0.0025;
|
|
26
|
+
|
|
27
|
+
// panel i of the layout: xy its bottom-left corner, zw its top-right corner, in uv; panels in reading order
|
|
28
|
+
vec4 panelRect(int i, bool portrait) {
|
|
29
|
+
if (portrait) {
|
|
30
|
+
if (i == 0) return vec4(0.0, 0.68, 0.62, 1.0);
|
|
31
|
+
if (i == 1) return vec4(0.62, 0.68, 1.0, 1.0);
|
|
32
|
+
if (i == 2) return vec4(0.0, 0.36, 1.0, 0.68);
|
|
33
|
+
if (i == 3) return vec4(0.0, 0.0, 0.46, 0.36);
|
|
34
|
+
if (i == 4) return vec4(0.46, 0.17, 1.0, 0.36);
|
|
35
|
+
return vec4(0.46, 0.0, 1.0, 0.17);
|
|
36
|
+
}
|
|
37
|
+
if (i == 0) return vec4(0.0, 0.42, 0.4, 1.0);
|
|
38
|
+
if (i == 1) return vec4(0.4, 0.64, 1.0, 1.0);
|
|
39
|
+
if (i == 2) return vec4(0.4, 0.0, 0.7, 0.64);
|
|
40
|
+
if (i == 3) return vec4(0.7, 0.32, 1.0, 0.64);
|
|
41
|
+
if (i == 4) return vec4(0.7, 0.0, 1.0, 0.32);
|
|
42
|
+
return vec4(0.0, 0.0, 0.4, 0.42);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// direction the outgoing image of panel i is pushed toward (the incoming one enters from the opposite side)
|
|
46
|
+
vec2 panelDir(int i, bool portrait) {
|
|
47
|
+
if (portrait) {
|
|
48
|
+
if (i == 0) return vec2(1.0, 0.0);
|
|
49
|
+
if (i == 1) return vec2(0.0, -1.0);
|
|
50
|
+
if (i == 2) return vec2(-1.0, 0.0);
|
|
51
|
+
if (i == 3) return vec2(0.0, 1.0);
|
|
52
|
+
if (i == 4) return vec2(1.0, 0.0);
|
|
53
|
+
return vec2(-1.0, 0.0);
|
|
54
|
+
}
|
|
55
|
+
if (i == 0) return vec2(0.0, -1.0);
|
|
56
|
+
if (i == 1) return vec2(-1.0, 0.0);
|
|
57
|
+
if (i == 2) return vec2(0.0, 1.0);
|
|
58
|
+
if (i == 3) return vec2(1.0, 0.0);
|
|
59
|
+
if (i == 4) return vec2(-1.0, 0.0);
|
|
60
|
+
return vec2(1.0, 0.0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
float easeInOut(float t) {
|
|
64
|
+
return t < 0.5 ? 4.0 * t * t * t : 1.0 - 4.0 * (1.0 - t) * (1.0 - t) * (1.0 - t);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// coverage of the interval [lo, hi] at x, with antialiased ends: the coverages of adjacent intervals add up to 1
|
|
68
|
+
float span1(float x, float lo, float hi, float aa) {
|
|
69
|
+
return smoothstep(lo - aa, lo + aa, x) * (1.0 - smoothstep(hi - aa, hi + aa, x));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// signed distance from p to the box [lo, hi]
|
|
73
|
+
float boxDist(vec2 p, vec2 lo, vec2 hi) {
|
|
74
|
+
vec2 d = abs(p - 0.5 * (lo + hi)) - 0.5 * (hi - lo);
|
|
75
|
+
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
vec4 transition(vec2 uv) {
|
|
79
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
80
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
81
|
+
|
|
82
|
+
bool portrait = ratio < 1.0;
|
|
83
|
+
// frame coordinates, in shorter sides
|
|
84
|
+
vec2 aspect = vec2(ratio, 1.0) / min(ratio, 1.0);
|
|
85
|
+
vec2 p = uv * aspect;
|
|
86
|
+
// the gutters open then close, 0 at both ends
|
|
87
|
+
float open = smoothstep(0.0, OPEN, progress) * (1.0 - smoothstep(1.0 - OPEN, 1.0, progress));
|
|
88
|
+
float g = gutter * open;
|
|
89
|
+
float ov = clamp(overlap, 0.0, 0.9);
|
|
90
|
+
// duration of a push, the pushes starting one after another over [START, 1 - START]
|
|
91
|
+
float span = (1.0 - 2.0 * START) / (1.0 + float(PANELS - 1) * (1.0 - ov));
|
|
92
|
+
|
|
93
|
+
vec4 color = vec4(0.0);
|
|
94
|
+
float cover = 0.0;
|
|
95
|
+
float shade = 0.0;
|
|
96
|
+
for (int i = 0; i < PANELS; i++) {
|
|
97
|
+
vec4 r = panelRect(i, portrait);
|
|
98
|
+
vec2 lo = r.xy * aspect + 0.5 * g;
|
|
99
|
+
vec2 hi = r.zw * aspect - 0.5 * g;
|
|
100
|
+
// no gutter along the frame's border: the panels there run past it
|
|
101
|
+
lo = mix(lo, vec2(-1.0), step(r.xy, vec2(0.0)));
|
|
102
|
+
hi = mix(hi, aspect + 1.0, step(vec2(1.0), r.zw));
|
|
103
|
+
float t = clamp((progress - START - float(i) * span * (1.0 - ov)) / span, 0.0, 1.0);
|
|
104
|
+
// the panel being pushed lifts off the paper: its shadow grows longer and softer
|
|
105
|
+
float lift = 1.0 + 1.2 * sin(3.141592653589793 * t);
|
|
106
|
+
// soft drop shadow down and to the right on the paper
|
|
107
|
+
float sd = boxDist(p - vec2(0.2, -0.35) * g * lift, lo, hi);
|
|
108
|
+
shade = max(shade, (1.0 - smoothstep(-0.2 * g, 0.6 * g * lift + 1e-4, sd)) / sqrt(lift));
|
|
109
|
+
// separable coverage, so that the panels of the grid add up to exactly 1 once the gutters close
|
|
110
|
+
float inside = span1(p.x, lo.x, hi.x, EDGE) * span1(p.y, lo.y, hi.y, EDGE);
|
|
111
|
+
if (inside > 0.0) {
|
|
112
|
+
vec2 dir = panelDir(i, portrait);
|
|
113
|
+
vec4 c;
|
|
114
|
+
if (t <= 0.0) {
|
|
115
|
+
c = getFromColor(uv);
|
|
116
|
+
} else if (t >= 1.0) {
|
|
117
|
+
c = getToColor(uv);
|
|
118
|
+
} else {
|
|
119
|
+
float e = easeInOut(t);
|
|
120
|
+
// a train slides along dir through the panel: outgoing image, accent band, incoming image
|
|
121
|
+
float len = abs(dot(r.zw - r.xy, dir));
|
|
122
|
+
float w = band * len;
|
|
123
|
+
vec2 q = uv - dir * e * (len + w);
|
|
124
|
+
// position along dir from the outgoing image's trailing edge (inside it when >= 0)
|
|
125
|
+
float a = dot(q - (dir.x + dir.y < 0.0 ? r.zw : r.xy), dir);
|
|
126
|
+
// the same in frame units, for antialiasing
|
|
127
|
+
float af = a * abs(dot(aspect, dir));
|
|
128
|
+
float wf = w * abs(dot(aspect, dir));
|
|
129
|
+
float fromW = smoothstep(-EDGE, 0.0, af);
|
|
130
|
+
float toW = 1.0 - smoothstep(-wf, -wf + EDGE, af);
|
|
131
|
+
// the incoming image's leading edge casts a soft shadow on the band
|
|
132
|
+
float bandShade = 1.0 - shadow * 0.5 * (1.0 - smoothstep(-wf, -wf + 0.35 * wf + 1e-4, af));
|
|
133
|
+
vec4 b = vec4(accent.rgb * bandShade, accent.a);
|
|
134
|
+
// the antialiased ends of the images are sampled inside the panel
|
|
135
|
+
c = mix(b, getFromColor(clamp(q, r.xy, r.zw)), fromW);
|
|
136
|
+
c = mix(c, getToColor(clamp(q + dir * (len + w), r.xy, r.zw)), toW);
|
|
137
|
+
}
|
|
138
|
+
color += c * inside;
|
|
139
|
+
cover += inside;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
color /= max(cover, 1.0);
|
|
143
|
+
cover = min(cover, 1.0);
|
|
144
|
+
vec4 bg = vec4(paper.rgb * (1.0 - shadow * shade * open), paper.a);
|
|
145
|
+
return color + bg * (1.0 - cover);
|
|
146
|
+
}
|