gl-transitions 2.0.0 → 2.2.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 +56 -0
- package/compatibility.json +386 -0
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/ApertureWipe.glsl +45 -0
- package/glsl3/Comb.glsl +26 -0
- package/glsl3/Curtains.glsl +47 -0
- package/glsl3/CylinderRoll.glsl +102 -0
- package/glsl3/DiamondWipe.glsl +21 -0
- package/glsl3/DitherDissolve.glsl +27 -0
- package/glsl3/FallOver.glsl +36 -0
- package/glsl3/Fisheye.glsl +23 -0
- package/glsl3/Halftone.glsl +49 -0
- package/glsl3/Honeycomb.glsl +55 -0
- package/glsl3/LightStreaks.glsl +117 -0
- package/glsl3/PaperTear.glsl +76 -0
- package/glsl3/PixelStretch.glsl +73 -0
- package/glsl3/Prisms.glsl +81 -0
- package/glsl3/Puzzle.glsl +124 -0
- package/glsl3/Refraction.glsl +95 -0
- package/glsl3/Shred.glsl +67 -0
- package/glsl3/SpiralWipe.glsl +41 -0
- package/glsl3/Tunnel.glsl +42 -0
- package/glsl3/TvRoll.glsl +43 -0
- package/glsl3/TvTurnOff.glsl +47 -0
- package/glsl3/WhipPan.glsl +50 -0
- package/glsl3/WhipSpin.glsl +69 -0
- package/glsl3/WhipTilt.glsl +79 -0
- package/index.js +1 -1
- package/layouts.json +764 -0
- package/llms-full.txt +620 -256
- package/llms.txt +160 -136
- package/msl/ApertureWipe.metal +193 -0
- package/msl/Comb.metal +167 -0
- package/msl/Curtains.metal +207 -0
- package/msl/CylinderRoll.metal +374 -0
- package/msl/DiamondWipe.metal +123 -0
- package/msl/DitherDissolve.metal +157 -0
- package/msl/FallOver.metal +192 -0
- package/msl/Fisheye.metal +121 -0
- package/msl/Halftone.metal +230 -0
- package/msl/Honeycomb.metal +263 -0
- package/msl/LightStreaks.metal +518 -0
- package/msl/PaperTear.metal +373 -0
- package/msl/PixelStretch.metal +337 -0
- package/msl/Prisms.metal +424 -0
- package/msl/Puzzle.metal +632 -0
- package/msl/Refraction.metal +333 -0
- package/msl/Shred.metal +294 -0
- package/msl/SpiralWipe.metal +196 -0
- package/msl/Tunnel.metal +207 -0
- package/msl/TvRoll.metal +205 -0
- package/msl/TvTurnOff.metal +238 -0
- package/msl/WhipPan.metal +218 -0
- package/msl/WhipSpin.metal +278 -0
- package/msl/WhipTilt.metal +327 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +69 -39
- package/sksl/ApertureWipe.sksl +56 -0
- package/sksl/Comb.sksl +39 -0
- package/sksl/Curtains.sksl +60 -0
- package/sksl/CylinderRoll.sksl +112 -0
- package/sksl/DiamondWipe.sksl +34 -0
- package/sksl/DitherDissolve.sksl +39 -0
- package/sksl/FallOver.sksl +49 -0
- package/sksl/Fisheye.sksl +36 -0
- package/sksl/Halftone.sksl +61 -0
- package/sksl/Honeycomb.sksl +64 -0
- package/sksl/LightStreaks.sksl +126 -0
- package/sksl/PaperTear.sksl +82 -0
- package/sksl/PixelStretch.sksl +84 -0
- package/sksl/Prisms.sksl +94 -0
- package/sksl/Puzzle.sksl +134 -0
- package/sksl/Refraction.sksl +103 -0
- package/sksl/Shred.sksl +79 -0
- package/sksl/SpiralWipe.sksl +51 -0
- package/sksl/Tunnel.sksl +55 -0
- package/sksl/TvRoll.sksl +55 -0
- package/sksl/TvTurnOff.sksl +59 -0
- package/sksl/WhipPan.sksl +62 -0
- package/sksl/WhipSpin.sksl +79 -0
- package/sksl/WhipTilt.sksl +90 -0
- package/sksl/index.js +1 -1
- package/transitions/ApertureWipe.glsl +44 -0
- package/transitions/Comb.glsl +25 -0
- package/transitions/Curtains.glsl +46 -0
- package/transitions/CylinderRoll.glsl +101 -0
- package/transitions/DiamondWipe.glsl +20 -0
- package/transitions/DitherDissolve.glsl +26 -0
- package/transitions/FallOver.glsl +35 -0
- package/transitions/Fisheye.glsl +22 -0
- package/transitions/Halftone.glsl +48 -0
- package/transitions/Honeycomb.glsl +54 -0
- package/transitions/LightStreaks.glsl +116 -0
- package/transitions/PaperTear.glsl +75 -0
- package/transitions/PixelStretch.glsl +72 -0
- package/transitions/Prisms.glsl +80 -0
- package/transitions/Puzzle.glsl +123 -0
- package/transitions/Refraction.glsl +94 -0
- package/transitions/Shred.glsl +66 -0
- package/transitions/SpiralWipe.glsl +40 -0
- package/transitions/Tunnel.glsl +41 -0
- package/transitions/TvRoll.glsl +42 -0
- package/transitions/TvTurnOff.glsl +46 -0
- package/transitions/WhipPan.glsl +49 -0
- package/transitions/WhipSpin.glsl +68 -0
- package/transitions/WhipTilt.glsl +78 -0
- package/wgsl/ApertureWipe.wgsl +160 -0
- package/wgsl/Comb.wgsl +139 -0
- package/wgsl/Curtains.wgsl +179 -0
- package/wgsl/CylinderRoll.wgsl +330 -0
- package/wgsl/DiamondWipe.wgsl +94 -0
- package/wgsl/DitherDissolve.wgsl +123 -0
- package/wgsl/FallOver.wgsl +164 -0
- package/wgsl/Fisheye.wgsl +93 -0
- package/wgsl/Halftone.wgsl +196 -0
- package/wgsl/Honeycomb.wgsl +222 -0
- package/wgsl/LightStreaks.wgsl +460 -0
- package/wgsl/PaperTear.wgsl +324 -0
- package/wgsl/PixelStretch.wgsl +298 -0
- package/wgsl/Prisms.wgsl +385 -0
- package/wgsl/Puzzle.wgsl +587 -0
- package/wgsl/Refraction.wgsl +294 -0
- package/wgsl/Shred.wgsl +259 -0
- package/wgsl/SpiralWipe.wgsl +165 -0
- package/wgsl/Tunnel.wgsl +177 -0
- package/wgsl/TvRoll.wgsl +165 -0
- package/wgsl/TvTurnOff.wgsl +196 -0
- package/wgsl/WhipPan.wgsl +177 -0
- package/wgsl/WhipSpin.wgsl +241 -0
- package/wgsl/WhipTilt.wgsl +291 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A line sweeps across the frame and drags the outgoing image's pixels behind it as long streaks, which shorten as it goes and reveal the incoming image
|
|
4
|
+
// Tags: smear, streaks, directional, chromatic
|
|
5
|
+
|
|
6
|
+
// @param Direction in which the line sweeps
|
|
7
|
+
uniform vec2 direction; // = vec2(1.0, 0.0)
|
|
8
|
+
// @range(0, 1) Length of the streaks at the middle of the sweep, as a part of the frame
|
|
9
|
+
uniform float stretch; // = 0.45
|
|
10
|
+
// @range(0, 1) Amount of RGB split along the streaks
|
|
11
|
+
uniform float chroma; // = 0.5
|
|
12
|
+
// @range(0, 0.2) Softness of the line and of the streaks' ends, as a part of the frame
|
|
13
|
+
uniform float softness; // = 0.03
|
|
14
|
+
// @range(0, 1) How much the streaks jitter, each row at its own length
|
|
15
|
+
uniform float jitter; // = 0.5
|
|
16
|
+
|
|
17
|
+
float hash(float n) {
|
|
18
|
+
n = fract(n * 0.1031);
|
|
19
|
+
n *= n + 33.33;
|
|
20
|
+
n *= n + n;
|
|
21
|
+
return fract(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// smooth max with a compact support: exactly max(x, y) when they are k apart
|
|
25
|
+
float smax(float x, float y, float k) {
|
|
26
|
+
float h = max(k - abs(x - y), 0.0) / k;
|
|
27
|
+
return max(x, y) + h * h * k * 0.25;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// position s along the sweep (0 to 1 across the frame) to a frame coordinate
|
|
31
|
+
vec2 at(vec2 uv, float s0, float s, vec2 d, float ext) {
|
|
32
|
+
return clamp(uv + d * (s - s0) * ext, 0.0, 1.0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
vec4 transition(vec2 uv) {
|
|
36
|
+
vec2 d = normalize(direction + vec2(1e-6, 0.0));
|
|
37
|
+
// ext: length of the frame along the sweep, in uv units
|
|
38
|
+
float ext = abs(d.x) + abs(d.y);
|
|
39
|
+
float s = 0.5 + dot(uv - 0.5, d) / ext;
|
|
40
|
+
// rows across the streaks (about one per pixel line), in frame heights
|
|
41
|
+
vec2 n = vec2(-d.y, d.x);
|
|
42
|
+
float t = dot((uv - 0.5) * vec2(ratio, 1.0), n);
|
|
43
|
+
float row = floor(t * 540.0);
|
|
44
|
+
float clump = floor(t * 60.0);
|
|
45
|
+
float rnd = 0.6 * hash(row + 17.0) + 0.4 * hash(clump + 311.0);
|
|
46
|
+
|
|
47
|
+
float p = progress;
|
|
48
|
+
float k = softness + 1e-4;
|
|
49
|
+
// the line starts and ends at rest just beyond the frame, past its soft edge, so both ends are exact;
|
|
50
|
+
// it enters at once and slows down a little toward the end
|
|
51
|
+
float margin = k + 0.002;
|
|
52
|
+
float a = mix(-margin, 1.0 + margin, mix(p, p * p * (3.0 - 2.0 * p), 0.5));
|
|
53
|
+
|
|
54
|
+
// the streaks are longest when the line crosses the middle and vanish as it reaches the edges,
|
|
55
|
+
// so they never repeat the frame's own border (often dark, or letterboxing)
|
|
56
|
+
float h = clamp(4.0 * a * (1.0 - a), 0.0, 1.0);
|
|
57
|
+
float len = stretch * h * (1.0 - 0.6 * jitter * rnd);
|
|
58
|
+
float split = 0.02 * chroma * h;
|
|
59
|
+
|
|
60
|
+
// ahead of the line the outgoing image is intact; behind it, each pixel repeats the pixel at the line
|
|
61
|
+
vec4 fr = getFromColor(at(uv, s, smax(s, a + split, k), d, ext));
|
|
62
|
+
vec4 fg = getFromColor(at(uv, s, smax(s, a, k), d, ext));
|
|
63
|
+
vec4 fb = getFromColor(at(uv, s, smax(s, a - split, k), d, ext));
|
|
64
|
+
vec4 streak = vec4(fr.r, fg.g, fb.b, fg.a);
|
|
65
|
+
// a faint flicker along the streaks
|
|
66
|
+
float behind = step(s, a);
|
|
67
|
+
streak.rgb *= 1.0 + 0.06 * jitter * h * (hash(row * 3.0 + 5.0) - 0.5) * behind;
|
|
68
|
+
|
|
69
|
+
// past the end of its streak, each row shows the incoming image as it is
|
|
70
|
+
float w = smoothstep(len - k, len + k, a - s);
|
|
71
|
+
return mix(streak, getToColor(uv), w);
|
|
72
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The frame is cut into 3D prisms that turn in a cascade, like a rotating billboard, from the outgoing image on one face to the incoming one on the next
|
|
4
|
+
// Tags: 3d, rotate, stripes
|
|
5
|
+
|
|
6
|
+
// @range(2, 40, 1) Number of prisms
|
|
7
|
+
uniform int slats; // = 8
|
|
8
|
+
// @range(0, 0.9) Delay of the last prism's turn, as a part of the transition
|
|
9
|
+
uniform float stagger; // = 0.45
|
|
10
|
+
// @range(0, 4) Amount of perspective
|
|
11
|
+
uniform float perspective; // = 1.0
|
|
12
|
+
// @range(0, 1) How much the faces darken as they turn away
|
|
13
|
+
uniform float shading; // = 0.6
|
|
14
|
+
// @param Cut the frame into horizontal prisms instead
|
|
15
|
+
uniform bool horizontal; // = false
|
|
16
|
+
// @color Color seen where the turning prisms leave the frame uncovered
|
|
17
|
+
uniform vec4 backColor; // = vec4(0.0, 0.0, 0.0, 1.0)
|
|
18
|
+
|
|
19
|
+
const float PI = 3.141592653589793;
|
|
20
|
+
// width of the anti-aliased edges, in frame heights
|
|
21
|
+
const float EDGE = 0.002;
|
|
22
|
+
|
|
23
|
+
vec4 transition (vec2 uv) {
|
|
24
|
+
float n = float(slats);
|
|
25
|
+
// a: the axis across the prisms, b: the axis they turn around
|
|
26
|
+
float a = horizontal ? uv.y : uv.x;
|
|
27
|
+
float b = horizontal ? uv.x : uv.y;
|
|
28
|
+
// the prisms' half width in frame heights, and the perspective from their depth
|
|
29
|
+
float hw = 0.5 / n * (horizontal ? 1.0 : ratio);
|
|
30
|
+
float k = min(perspective * hw, 0.5);
|
|
31
|
+
float bScale = horizontal ? ratio : 1.0;
|
|
32
|
+
// a turning prism is wider than its strip: keep the two nearest faces
|
|
33
|
+
vec4 near1 = vec4(0.0), near2 = vec4(0.0);
|
|
34
|
+
float cover1 = 0.0, cover2 = 0.0;
|
|
35
|
+
float z1 = -2.0, z2 = -2.0;
|
|
36
|
+
for (int d = -1; d <= 1; d++) {
|
|
37
|
+
float i = floor(a * n) + float(d);
|
|
38
|
+
if (i < 0.0 || i > n - 1.0) continue;
|
|
39
|
+
// each prism turns after a delay that grows across the frame, left to right or top to bottom
|
|
40
|
+
float order = (horizontal ? n - 1.0 - i : i) / (n - 1.0);
|
|
41
|
+
float t = clamp((progress - stagger * order) / (1.0 - stagger), 0.0, 1.0);
|
|
42
|
+
t = mix(t, t * t * (3.0 - 2.0 * t), 0.7);
|
|
43
|
+
float c = cos(0.5 * PI * t);
|
|
44
|
+
float s = sin(0.5 * PI * t);
|
|
45
|
+
// soft edges while turning (sharp at rest, to keep the first and last frames exact)
|
|
46
|
+
float edge = EDGE * min(1.0, 20.0 * s * c) + 1e-6;
|
|
47
|
+
// x: position across the strip, -1 to 1; the prism's square section has its faces at distance 1
|
|
48
|
+
float x = 2.0 * (a * n - i) - 1.0;
|
|
49
|
+
for (int f = 0; f < 2; f++) {
|
|
50
|
+
// f = 0: the outgoing face turning away, f = 1: the incoming face turning in
|
|
51
|
+
float cf = f == 0 ? c : s;
|
|
52
|
+
if (cf < 1e-4) continue;
|
|
53
|
+
// u: position on the face, z: depth (1 for a face at rest)
|
|
54
|
+
float u = f == 0 ? (x + s) / c : (x - c) / s;
|
|
55
|
+
float z = f == 0 ? u * s + c : s - u * c;
|
|
56
|
+
if (abs(u) > 1.0 || z <= z2) continue;
|
|
57
|
+
// nearer parts look bigger
|
|
58
|
+
float scale = 1.0 - k * (z - 1.0);
|
|
59
|
+
float y = (b - 0.5) * scale + 0.5;
|
|
60
|
+
if (y < 0.0 || y > 1.0) continue;
|
|
61
|
+
// soften the outer edges only: the faces meet at the prism's corner
|
|
62
|
+
float outer = f == 0 ? 1.0 + u : 1.0 - u;
|
|
63
|
+
float cover = clamp(outer * hw * cf / edge, 0.0, 1.0)
|
|
64
|
+
* clamp(min(y, 1.0 - y) * bScale / scale / edge, 0.0, 1.0);
|
|
65
|
+
float sa = (i + 0.5 + 0.5 * u) / n;
|
|
66
|
+
vec2 p = horizontal ? vec2(y, sa) : vec2(sa, y);
|
|
67
|
+
vec4 img = f == 0 ? getFromColor(p) : getToColor(p);
|
|
68
|
+
// lit from the front and the incoming side: the outgoing face darkens as it turns away
|
|
69
|
+
float lambert = clamp(f == 0 ? c - 0.6 * s : s + 0.6 * c, 0.0, 1.0);
|
|
70
|
+
vec4 color = vec4(img.rgb * mix(1.0 - shading, 1.0, lambert), img.a);
|
|
71
|
+
if (z > z1) {
|
|
72
|
+
near2 = near1; cover2 = cover1; z2 = z1;
|
|
73
|
+
near1 = color; cover1 = cover; z1 = z;
|
|
74
|
+
} else {
|
|
75
|
+
near2 = color; cover2 = cover; z2 = z;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return mix(mix(backColor, near2, cover2), near1, cover1);
|
|
80
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The image is cut into jigsaw puzzle pieces that lift one after another and fall away, revealing the incoming image
|
|
4
|
+
// Tags: tiles, shadow, rotate, fragments
|
|
5
|
+
|
|
6
|
+
// @range(2, 12) Number of pieces across the shorter side
|
|
7
|
+
uniform float pieces; // = 5.0
|
|
8
|
+
// @range(0, 1) Darkness of the shadows of the lifted pieces
|
|
9
|
+
uniform float shadow; // = 0.6
|
|
10
|
+
|
|
11
|
+
// Hash of a cell, without sin, in [0, 1)
|
|
12
|
+
float hash(vec2 c) {
|
|
13
|
+
vec2 p = fract(c * vec2(0.1031, 0.1030));
|
|
14
|
+
p += dot(p, p.yx + 33.33);
|
|
15
|
+
return fract((p.x + p.y) * p.x);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
float boxDist(vec2 p, vec2 halfSize) {
|
|
19
|
+
vec2 q = abs(p) - halfSize;
|
|
20
|
+
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Signed distance of a point, relative to the center of piece c, to that piece (cell units).
|
|
24
|
+
// Each edge has a knob (a round head on a neck): a tab for one piece, a blank for its neighbor; border edges are flat.
|
|
25
|
+
float pieceDist(vec2 p, vec2 c, vec2 grid, float aspect) {
|
|
26
|
+
vec2 halfSize = vec2(0.5 * aspect, 0.5);
|
|
27
|
+
float d = boxDist(p, halfSize);
|
|
28
|
+
float tabs = 1e3;
|
|
29
|
+
for (int e = 0; e < 4; e++) {
|
|
30
|
+
// right, left, top, bottom: the edge key is the cell on its left or below
|
|
31
|
+
vec2 dir = e == 0 ? vec2(1.0, 0.0) : e == 1 ? vec2(-1.0, 0.0) : e == 2 ? vec2(0.0, 1.0) : vec2(0.0, -1.0);
|
|
32
|
+
vec2 key = c + min(dir, 0.0);
|
|
33
|
+
vec2 next = c + dir;
|
|
34
|
+
if (next.x >= 0.0 && next.y >= 0.0 && next.x < grid.x && next.y < grid.y) {
|
|
35
|
+
float h = hash(key + (e < 2 ? vec2(0.0) : vec2(71.0, 37.0)));
|
|
36
|
+
// the knob points right or up from the key cell when h < 0.5
|
|
37
|
+
bool tab = (h < 0.5) == (dir.x + dir.y > 0.0);
|
|
38
|
+
vec2 out1 = dir * (tab ? 1.0 : -1.0);
|
|
39
|
+
vec2 along = vec2(abs(dir.y), abs(dir.x));
|
|
40
|
+
vec2 edge = dir * halfSize + along * (fract(h * 2.0) - 0.5) * 0.16;
|
|
41
|
+
float k = min(
|
|
42
|
+
length(p - edge - out1 * 0.15) - 0.125,
|
|
43
|
+
boxDist(p - edge - out1 * 0.06, abs(dir) * 0.08 + along * 0.085));
|
|
44
|
+
if (tab) tabs = min(tabs, k);
|
|
45
|
+
else d = max(d, -k);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return min(d, tabs);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
vec4 transition(vec2 uv) {
|
|
52
|
+
// a grid of nearly square cells that fits the frame exactly
|
|
53
|
+
float rows = ratio < 1.0 ? floor(pieces / ratio + 0.5) : pieces;
|
|
54
|
+
float cols = ratio < 1.0 ? pieces : floor(pieces * ratio + 0.5);
|
|
55
|
+
vec2 grid = vec2(cols, rows);
|
|
56
|
+
float aspect = ratio * rows / cols;
|
|
57
|
+
vec2 g = uv * grid;
|
|
58
|
+
vec2 cell = floor(g);
|
|
59
|
+
|
|
60
|
+
const float aa = 0.01; // soft edges, in cells
|
|
61
|
+
float boardSum = 0.0;
|
|
62
|
+
float allSum = 0.0;
|
|
63
|
+
// the two top moving pieces under this point
|
|
64
|
+
float prio1 = -1.0, prio2 = -1.0, cov1 = 0.0, cov2 = 0.0, shade1 = 1.0, shade2 = 1.0;
|
|
65
|
+
vec2 uv1 = uv, uv2 = uv;
|
|
66
|
+
float shadowAll = 0.0;
|
|
67
|
+
float seam = 1.0;
|
|
68
|
+
for (int i = 0; i < 9; i++) {
|
|
69
|
+
vec2 c = cell + vec2(mod(float(i), 3.0), floor(float(i) / 3.0)) - 1.0;
|
|
70
|
+
if (c.x < 0.0 || c.y < 0.0 || c.x >= cols || c.y >= rows) continue;
|
|
71
|
+
vec2 center = c + 0.5;
|
|
72
|
+
vec2 local = (g - center) * vec2(aspect, 1.0);
|
|
73
|
+
float h = hash(c + vec2(13.0, 7.0));
|
|
74
|
+
// diagonal order from the top left, a little shuffled
|
|
75
|
+
float diag = (c.x / max(cols - 1.0, 1.0) + (rows - 1.0 - c.y) / max(rows - 1.0, 1.0)) * 0.5;
|
|
76
|
+
float delay = (diag + 1.2 * (h - 0.5) * diag * (1.0 - diag)) * 0.6;
|
|
77
|
+
float t = clamp((progress - delay) / 0.4, 0.0, 1.0);
|
|
78
|
+
|
|
79
|
+
// where the piece was: the board keeps the outgoing image where pieces are still in place
|
|
80
|
+
float d0 = pieceDist(local, c, grid, aspect);
|
|
81
|
+
float w = 1.0 - smoothstep(-aa, aa, d0);
|
|
82
|
+
allSum += w;
|
|
83
|
+
if (t <= 0.0) {
|
|
84
|
+
boardSum += w;
|
|
85
|
+
seam = min(seam, abs(d0));
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
// lift, then fall away: shrink, spin, drift down and darken
|
|
89
|
+
float lift = smoothstep(0.0, 0.25, t);
|
|
90
|
+
float fall = clamp((t - 0.2) / 0.8, 0.0, 1.0);
|
|
91
|
+
fall *= fall;
|
|
92
|
+
float s = max(1.0 - fall, 0.001);
|
|
93
|
+
float a = (h - 0.5) * 3.0 * fall;
|
|
94
|
+
vec2 off = vec2(0.0, -1.2 * fall);
|
|
95
|
+
mat2 rot = mat2(cos(a), -sin(a), sin(a), cos(a));
|
|
96
|
+
vec2 pl = rot * (local - off) / s;
|
|
97
|
+
float dp = pieceDist(pl, c, grid, aspect);
|
|
98
|
+
float cov = (1.0 - smoothstep(-aa, aa, dp * s)) * min(s * 20.0, 1.0); // fades when tiny
|
|
99
|
+
// darker when falling, and on its edges when lifted
|
|
100
|
+
float shade = (1.0 - 0.5 * fall) * (1.0 - 0.3 * lift * (1.0 - smoothstep(0.0, 0.035, -dp)));
|
|
101
|
+
vec2 puv = (center + pl / vec2(aspect, 1.0)) / grid;
|
|
102
|
+
// soft shadow, offset to the bottom right while lifted
|
|
103
|
+
vec2 sl = rot * (local - off - vec2(0.08, -0.1) * lift) / s;
|
|
104
|
+
float sh = (1.0 - smoothstep(-0.05, 0.12, pieceDist(sl, c, grid, aspect) * s)) * lift * (1.0 - fall) * shadow;
|
|
105
|
+
// the hole it leaves is in its shadow too
|
|
106
|
+
shadowAll = max(shadowAll, max(sh, w * lift * (1.0 - smoothstep(0.2, 0.5, t)) * shadow));
|
|
107
|
+
float prio = delay;
|
|
108
|
+
if (cov > 0.0 && prio > prio1) {
|
|
109
|
+
prio2 = prio1; cov2 = cov1; uv2 = uv1; shade2 = shade1;
|
|
110
|
+
prio1 = prio; cov1 = cov; uv1 = puv; shade1 = shade;
|
|
111
|
+
} else if (cov > 0.0 && prio > prio2) {
|
|
112
|
+
prio2 = prio; cov2 = cov; uv2 = puv; shade2 = shade;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
vec4 base = mix(getToColor(uv), getFromColor(uv), boardSum / max(allSum, 0.001));
|
|
116
|
+
// the cuts show on the board as the transition starts
|
|
117
|
+
base.rgb *= (1.0 - shadowAll) * (1.0 - 0.4 * smoothstep(0.0, 0.1, progress) * (1.0 - smoothstep(0.0, 0.015, seam)));
|
|
118
|
+
vec4 p2 = getFromColor(uv2);
|
|
119
|
+
p2.rgb *= shade2;
|
|
120
|
+
vec4 p1 = getFromColor(uv1);
|
|
121
|
+
p1.rgb *= shade1;
|
|
122
|
+
return mix(mix(base, p2, cov2), p1, cov1);
|
|
123
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The frame is seen through flowing liquid glass that bends the outgoing image more and more, with rainbow fringes, flares up as the incoming image takes over, then calms down and clears
|
|
4
|
+
// Tags: distortion, refraction, chromatic-aberration, glow
|
|
5
|
+
|
|
6
|
+
// @range(0, 0.3) How far the glass bends the image at the peak
|
|
7
|
+
uniform float strength; // = 0.15
|
|
8
|
+
// @range(0.5, 8) Size of the flowing waves: higher makes smaller waves
|
|
9
|
+
uniform float scale; // = 2.5
|
|
10
|
+
// @range(0, 1) Spread of the rainbow fringes
|
|
11
|
+
uniform float dispersion; // = 0.5
|
|
12
|
+
// @range(0, 3) Brightness of the flare at the peak
|
|
13
|
+
uniform float brightness; // = 1.0
|
|
14
|
+
|
|
15
|
+
// the wavelengths sampled from red to violet
|
|
16
|
+
const int TAPS = 7;
|
|
17
|
+
|
|
18
|
+
// the glass surface: smooth waves of a few sizes, warped into each other and flowing over time
|
|
19
|
+
float surface(vec2 q, float t) {
|
|
20
|
+
q += 0.45 * vec2(sin(1.3 * q.y + 0.9 * t), sin(1.1 * q.x - 1.2 * t));
|
|
21
|
+
float h = sin(q.x + 0.6 * t) * sin(1.2 * q.y - 0.8 * t);
|
|
22
|
+
h += 0.5 * sin(dot(q, vec2(1.6, -1.2)) + 1.4 * t);
|
|
23
|
+
h += 0.3 * sin(dot(q, vec2(-1.1, 2.9)) - 1.9 * t + 1.7 * sin(0.9 * q.x));
|
|
24
|
+
h += 0.15 * sin(dot(q, vec2(4.3, 3.1)) + 2.6 * t);
|
|
25
|
+
return h;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// a hash without sin, to jitter the wavelengths from pixel to pixel
|
|
29
|
+
float hash12(vec2 v) {
|
|
30
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
31
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
32
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// mirror the coordinates back into the frame
|
|
36
|
+
vec2 mirror(vec2 v) {
|
|
37
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// rough spectral response of a wavelength w (0 = red, 1 = violet), in RGB
|
|
41
|
+
vec3 spectrum(float w) {
|
|
42
|
+
vec3 c = vec3(
|
|
43
|
+
1.0 - smoothstep(0.0, 0.55, w) + 0.35 * smoothstep(0.75, 1.0, w),
|
|
44
|
+
1.0 - abs(2.0 * w - 1.0) * 1.2,
|
|
45
|
+
smoothstep(0.45, 1.0, w)
|
|
46
|
+
);
|
|
47
|
+
return clamp(c, 0.0, 1.0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
vec4 transition(vec2 uv) {
|
|
51
|
+
float p = progress;
|
|
52
|
+
// 0 at both ends, 1 in the middle: the glass builds up slowly, then calms down
|
|
53
|
+
float h = 1.0 - abs(2.0 * p - 1.0);
|
|
54
|
+
float amount = h * h * (2.0 - h);
|
|
55
|
+
|
|
56
|
+
// the glass refracts along the slope of its surface
|
|
57
|
+
vec2 q = (uv - 0.5) * vec2(ratio, 1.0) * scale;
|
|
58
|
+
float t = 3.0 * p;
|
|
59
|
+
float e = 0.01;
|
|
60
|
+
vec2 slope = vec2(
|
|
61
|
+
surface(q + vec2(e, 0.0), t) - surface(q - vec2(e, 0.0), t),
|
|
62
|
+
surface(q + vec2(0.0, e), t) - surface(q - vec2(0.0, e), t)
|
|
63
|
+
) / (2.0 * e);
|
|
64
|
+
vec2 offset = slope * strength * amount / scale;
|
|
65
|
+
// the switch to the incoming image, around the peak: it appears through the glass's waves,
|
|
66
|
+
// the crests first, then the troughs
|
|
67
|
+
float wave = clamp(0.5 * surface(q, t), -1.0, 1.0);
|
|
68
|
+
float m = smoothstep(-0.015, 0.015, p - 0.5 + 0.1 * wave);
|
|
69
|
+
|
|
70
|
+
// each wavelength bends a little differently: red the least, violet the most
|
|
71
|
+
vec3 color = vec3(0.0);
|
|
72
|
+
vec3 weights = vec3(0.0);
|
|
73
|
+
float alpha = 0.0;
|
|
74
|
+
// jittered wavelengths blend the fringes into a continuous rainbow
|
|
75
|
+
float jitter = hash12(uv * vec2(ratio, 1.0) * 1000.0) - 0.5;
|
|
76
|
+
for (int i = 0; i < TAPS; i++) {
|
|
77
|
+
float w = float(i) / float(TAPS - 1);
|
|
78
|
+
float wj = (float(i) + jitter) / float(TAPS - 1);
|
|
79
|
+
vec2 st = mirror(uv + offset * (1.0 + dispersion * (wj - 0.5) * 1.6));
|
|
80
|
+
vec4 c = mix(getFromColor(st), getToColor(st), m);
|
|
81
|
+
vec3 s = spectrum(w);
|
|
82
|
+
color += s * c.rgb * c.a;
|
|
83
|
+
weights += s;
|
|
84
|
+
alpha += c.a;
|
|
85
|
+
}
|
|
86
|
+
alpha /= float(TAPS);
|
|
87
|
+
color = color / weights / max(alpha, 1e-5);
|
|
88
|
+
|
|
89
|
+
// a flare at the peak: the image is pushed toward an overexposed white
|
|
90
|
+
float flare = 2.0 * brightness * pow(h, 8.0);
|
|
91
|
+
color = color * (1.0 + flare) / (1.0 + flare * color);
|
|
92
|
+
color += 0.1 * flare * dot(color, vec3(0.3333));
|
|
93
|
+
return vec4(clamp(color, 0.0, 1.0), alpha);
|
|
94
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image is cut into paper strips that drop away at uneven speeds, tilting as they fall, revealing the incoming image
|
|
4
|
+
// Tags: slices, stripes, vertical, shadow
|
|
5
|
+
|
|
6
|
+
// @range(4, 60, 1) Number of strips
|
|
7
|
+
uniform int strips; // = 20
|
|
8
|
+
// @range(0, 0.8) Spread of the strips' start times, as a part of the transition
|
|
9
|
+
uniform float stagger; // = 0.4
|
|
10
|
+
// @range(0, 0.3) Largest tilt of a falling strip, in radians
|
|
11
|
+
uniform float tilt; // = 0.1
|
|
12
|
+
// @range(0, 1) Darkness of the strips' cut edges and of their shadow
|
|
13
|
+
uniform float shadow; // = 0.5
|
|
14
|
+
|
|
15
|
+
// a deterministic random value in [0, 1) for each strip
|
|
16
|
+
float hash (float n) {
|
|
17
|
+
n = fract(n * 0.1031);
|
|
18
|
+
n *= n + 33.33;
|
|
19
|
+
n *= n + n;
|
|
20
|
+
return fract(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
vec4 transition (vec2 uv) {
|
|
24
|
+
float n = float(strips);
|
|
25
|
+
float w = ratio / n; // strip width, in frame heights
|
|
26
|
+
vec2 q = vec2(uv.x * ratio, uv.y);
|
|
27
|
+
vec4 color = getToColor(uv);
|
|
28
|
+
float cover = -1.0;
|
|
29
|
+
float shade = 0.0;
|
|
30
|
+
// narrow strips tilt less, so that they only reach over their neighbours
|
|
31
|
+
float maxTilt = min(tilt, 2.0 * w);
|
|
32
|
+
for (int d = -3; d <= 3; d++) {
|
|
33
|
+
float i = floor(uv.x * n) + float(d);
|
|
34
|
+
if (i < 0.0 || i > n - 1.0) continue;
|
|
35
|
+
// about one strip in five starts right away
|
|
36
|
+
float delay = stagger * max(0.0, 1.25 * hash(i + 1.0) - 0.25);
|
|
37
|
+
float speed = 1.0 + 0.5 * hash(i + 71.0);
|
|
38
|
+
float t = clamp((progress - delay) / (1.0 - delay), 0.0, 1.0);
|
|
39
|
+
// a pull then a fall that speeds up, long enough to leave the frame
|
|
40
|
+
float fall = (0.4 * t + 0.6 * t * t) * (1.0 + w * (0.5 + tilt)) * speed;
|
|
41
|
+
float angle = maxTilt * (2.0 * hash(i + 37.0) - 1.0) * t;
|
|
42
|
+
// the strips are cut apart as they start moving
|
|
43
|
+
float lift = min(1.0, 8.0 * t);
|
|
44
|
+
float gap = 0.06 * w * lift;
|
|
45
|
+
// position in the strip's own frame, relative to its center
|
|
46
|
+
vec2 v = q - vec2((i + 0.5) * w, 0.5 - fall);
|
|
47
|
+
float ca = cos(angle), sa = sin(angle);
|
|
48
|
+
vec2 l = vec2(ca * v.x + sa * v.y, ca * v.y - sa * v.x);
|
|
49
|
+
vec2 edge = vec2(0.5 * w - gap, 0.5) - abs(l);
|
|
50
|
+
// a soft shadow, cast down and right by the moving strip
|
|
51
|
+
vec2 so = abs(l - lift * vec2(0.15 * w, -0.25 * w)) - vec2(0.5 * w - gap, 0.5);
|
|
52
|
+
shade = max(shade, lift * (1.0 - smoothstep(0.0, 0.5 * w, max(so.x, so.y))));
|
|
53
|
+
if (min(edge.x, edge.y) >= 0.0 && fall > cover) {
|
|
54
|
+
vec2 p = vec2((i + 0.5) * w + l.x, 0.5 + l.y);
|
|
55
|
+
vec4 img = getFromColor(vec2(p.x / ratio, p.y));
|
|
56
|
+
// darker cut edges
|
|
57
|
+
float cut = lift * (1.0 - smoothstep(0.0, 0.25 * w, edge.x));
|
|
58
|
+
color = vec4(img.rgb * (1.0 - 0.5 * shadow * cut), img.a);
|
|
59
|
+
cover = fall;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (cover < 0.0) {
|
|
63
|
+
color = vec4(color.rgb * (1.0 - 0.6 * shadow * shade), color.a);
|
|
64
|
+
}
|
|
65
|
+
return color;
|
|
66
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A spiral arm winds out from the center and widens to reveal the incoming image
|
|
4
|
+
// Tags: shape, wipe, radial
|
|
5
|
+
|
|
6
|
+
#define PI 3.141592653589793
|
|
7
|
+
|
|
8
|
+
// @range(2, 8) Number of turns of the spiral
|
|
9
|
+
uniform float turns; // = 3.0
|
|
10
|
+
// @range(0, 0.5) Softness of the arm's edges
|
|
11
|
+
uniform float smoothness; // = 0.05
|
|
12
|
+
// @param Wind clockwise; false winds counterclockwise
|
|
13
|
+
uniform bool clockwise; // = true
|
|
14
|
+
|
|
15
|
+
// Coverage of the arm turn at position s (in turns along the spiral), d away from its middle line
|
|
16
|
+
float arm (float s, float d) {
|
|
17
|
+
// The tip reaches the frame's corners at 60% of the transition, and the whole arm widens until the end
|
|
18
|
+
float end = -0.5 + (turns + 0.5) / 0.6;
|
|
19
|
+
float tip = mix(-0.5, end, progress);
|
|
20
|
+
s = max(s, -0.5);
|
|
21
|
+
float width = sqrt(clamp((tip - s) / max(end - s, 0.001), 0.0, 1.0));
|
|
22
|
+
// Edge softness in arm widths, at least a pixel wide
|
|
23
|
+
float e = smoothness + 0.005 * turns;
|
|
24
|
+
return smoothstep(0.0, e, width * (0.5 + e) - d);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
vec4 transition (vec2 uv) {
|
|
28
|
+
// Square pixels, normalized so the frame's corners are at distance 1
|
|
29
|
+
vec2 q = (uv - 0.5) * vec2(ratio, 1.0) / (0.5 * length(vec2(ratio, 1.0)));
|
|
30
|
+
// Fraction of a turn, starting at the top
|
|
31
|
+
float a = dot(q, q) < 1e-12 ? 0.0 : atan(q.x, q.y) / (2.0 * PI);
|
|
32
|
+
a = fract(clockwise ? a : -a);
|
|
33
|
+
// Radius in turns of the spiral, and the arm turn the point is in
|
|
34
|
+
float w = length(q) * turns - a;
|
|
35
|
+
float n = floor(w);
|
|
36
|
+
float f = w - n;
|
|
37
|
+
// The arm turns around it can overlap it near the edges
|
|
38
|
+
float m = max(arm(n + a, abs(f - 0.5)), max(arm(n + 1.0 + a, 1.5 - f), arm(n - 1.0 + a, f + 0.5)));
|
|
39
|
+
return mix(getFromColor(uv), getToColor(uv), m);
|
|
40
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The camera flies down a tunnel lined with the outgoing image toward the incoming one, which opens at its far end and grows to fill the frame
|
|
4
|
+
// Tags: zoom, 3d, warp, radial
|
|
5
|
+
|
|
6
|
+
// @range(0.5, 10) How far and fast the camera flies down the tunnel
|
|
7
|
+
uniform float speed; // = 6.0
|
|
8
|
+
// @range(-2, 2) How much the walls spiral as they rush by
|
|
9
|
+
uniform float twist; // = 0.5
|
|
10
|
+
|
|
11
|
+
vec2 rotate(vec2 v, float a) {
|
|
12
|
+
float c = cos(a);
|
|
13
|
+
float s = sin(a);
|
|
14
|
+
return vec2(c * v.x - s * v.y, s * v.x + c * v.y);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
vec4 transition(vec2 uv) {
|
|
18
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
19
|
+
vec2 c = (uv - 0.5) * aspect;
|
|
20
|
+
float r = length(c);
|
|
21
|
+
// A tube as wide as the frame's corners runs from the camera to an end wall
|
|
22
|
+
// at depth `far`; the outgoing image is projected onto it from the starting
|
|
23
|
+
// point of view, so it looks flat at first. The camera flies to one unit
|
|
24
|
+
// before the end wall, where the incoming image hangs.
|
|
25
|
+
float R = length(0.5 * aspect);
|
|
26
|
+
float far = 1.0 + speed;
|
|
27
|
+
// the distance to the end wall shrinks geometrically, so the end grows evenly
|
|
28
|
+
float e = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.7);
|
|
29
|
+
float d = pow(far, 1.0 - e);
|
|
30
|
+
float t = far - d; // distance flown
|
|
31
|
+
// the end wall covers the center of the view, the tube's walls the rest
|
|
32
|
+
float k = r * d < R ? d / far : R / (R + t * r); // image scale at that point
|
|
33
|
+
float a = twist * min(t * r / R, t / d); // spiral, continuous at the end wall
|
|
34
|
+
vec4 walls = getFromColor(0.5 + rotate(c * k, a) / aspect);
|
|
35
|
+
walls.rgb *= 0.4 + 0.6 * sqrt(k); // darker where the walls are close
|
|
36
|
+
// the incoming image opens in the end wall
|
|
37
|
+
float open = smoothstep(0.0, 0.6, progress);
|
|
38
|
+
vec2 q = 0.5 + (uv - 0.5) * d / max(open, 1e-4);
|
|
39
|
+
vec2 inside = step(0.0, q) * step(q, vec2(1.0));
|
|
40
|
+
return mix(walls, getToColor(q), inside.x * inside.y * step(r * d, R));
|
|
41
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image rolls faster and faster, like an old TV losing its vertical hold, then the roll slows down and locks on the incoming image
|
|
4
|
+
// Tags: retro, vertical, scanlines
|
|
5
|
+
|
|
6
|
+
// @range(1, 8) Number of frames that roll by
|
|
7
|
+
uniform int rolls; // = 3
|
|
8
|
+
// @range(0, 0.5) Height of the bar between the frames
|
|
9
|
+
uniform float barHeight; // = 0.12
|
|
10
|
+
// @color Color of the bar between the frames
|
|
11
|
+
uniform vec4 barColor; // = vec4(0.0, 0.0, 0.0, 1.0)
|
|
12
|
+
|
|
13
|
+
// The rolling picture at a vertical position y, in frames of height 1 + barHeight
|
|
14
|
+
vec4 picture(vec2 uv, float y, float m) {
|
|
15
|
+
float period = 1.0 + barHeight;
|
|
16
|
+
y = mod(y, period);
|
|
17
|
+
if (y > 1.0) return barColor;
|
|
18
|
+
vec2 q = vec2(uv.x, y);
|
|
19
|
+
return mix(getFromColor(q), getToColor(q), m);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
vec4 transition(vec2 uv) {
|
|
23
|
+
float period = 1.0 + barHeight;
|
|
24
|
+
// smooth start and stop: the picture locks again after a whole number of frames
|
|
25
|
+
float s = progress * progress * (3.0 - 2.0 * progress);
|
|
26
|
+
float offset = period * fract(float(rolls) * s);
|
|
27
|
+
float speed = 4.0 * progress * (1.0 - progress); // 0 at both ends, 1 in the middle
|
|
28
|
+
float m = smoothstep(0.42, 0.58, progress); // the channel changes at full speed
|
|
29
|
+
// the horizontal sync wobbles a little
|
|
30
|
+
vec2 p = uv + vec2(0.004 * speed * sin(uv.y * 9.0 + progress * 30.0), 0.0);
|
|
31
|
+
// vertical motion blur
|
|
32
|
+
vec4 c = vec4(0.0);
|
|
33
|
+
for (int i = 0; i < 5; i++) {
|
|
34
|
+
c += picture(p, p.y + offset - 0.0015 * float(rolls) * speed * float(i), m);
|
|
35
|
+
}
|
|
36
|
+
c /= 5.0;
|
|
37
|
+
// scanlines and a flickering brightness
|
|
38
|
+
float scan = 0.5 + 0.5 * sin(uv.y * 400.0);
|
|
39
|
+
float flicker = 0.08 * (0.5 + 0.5 * sin(progress * 97.0));
|
|
40
|
+
c.rgb *= 1.0 - speed * (0.08 * scan + flicker);
|
|
41
|
+
return c;
|
|
42
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image collapses into a glowing line and a dot, like an old TV turned off, then the incoming image powers on from the dot
|
|
4
|
+
// Tags: retro, vertical, flash
|
|
5
|
+
|
|
6
|
+
// @color Color of the switched-off screen
|
|
7
|
+
uniform vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0)
|
|
8
|
+
// @range(0, 2) Strength of the glow around the line and the dot
|
|
9
|
+
uniform float glow; // = 1.0
|
|
10
|
+
|
|
11
|
+
vec4 getColor(vec2 uv, bool isFrom) {
|
|
12
|
+
return isFrom ? getFromColor(uv) : getToColor(uv);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// The screen at a time t of its power-off: 0 is the full image, 1 is off
|
|
16
|
+
vec4 screen(vec2 uv, float t, bool isFrom) {
|
|
17
|
+
float collapse = smoothstep(0.0, 0.4, t); // the image squeezes into a line
|
|
18
|
+
float shrink = smoothstep(0.3, 0.65, t); // the line shrinks into a dot
|
|
19
|
+
float fade = 0.4 * smoothstep(0.75, 1.0, t); // the dot dims
|
|
20
|
+
float radius = 0.01 * (1.0 - fade);
|
|
21
|
+
// half size of the picture, in height units (x is scaled by ratio)
|
|
22
|
+
vec2 size = vec2(mix(0.5 * ratio, radius, shrink), mix(0.5, radius, collapse));
|
|
23
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
24
|
+
vec2 q = clamp(0.5 + 0.5 * p / size, 0.0, 1.0);
|
|
25
|
+
vec4 c = getColor(q, isFrom);
|
|
26
|
+
// the squeezed picture gets brighter and burns to white
|
|
27
|
+
float white = smoothstep(0.4, 1.0, collapse);
|
|
28
|
+
vec4 light = vec4(mix(min(c.rgb * (1.0 + 2.0 * collapse), 1.0), vec3(1.0), white), c.a);
|
|
29
|
+
// soft edges, outside the picture so that t = 0 is the exact image
|
|
30
|
+
vec2 d = abs(p) - size;
|
|
31
|
+
float dist = length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
|
32
|
+
float inside = clamp(1.0 - dist / 0.004, 0.0, 1.0);
|
|
33
|
+
// a glow around the line, tinted by the center of the picture, then warm white around the dot
|
|
34
|
+
vec4 mid = getColor(vec2(0.5), isFrom);
|
|
35
|
+
vec4 halo = vec4(mix(mix(mid.rgb, vec3(1.0), 0.7), vec3(1.0, 0.92, 0.8), shrink), mid.a);
|
|
36
|
+
float h = 1.0 - exp(-2.0 * glow * white * exp(-max(dist, 0.0) / (0.02 + 0.04 * shrink)));
|
|
37
|
+
vec4 col = mix(color, halo, h * (1.0 - fade));
|
|
38
|
+
return mix(col, light, inside * (1.0 - fade));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
vec4 transition(vec2 uv) {
|
|
42
|
+
if (progress < 0.5) {
|
|
43
|
+
return screen(uv, 2.0 * progress, true);
|
|
44
|
+
}
|
|
45
|
+
return screen(uv, 2.0 - 2.0 * progress, false);
|
|
46
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A fast camera pan that streaks both images with motion blur, the incoming one arriving from the opposite side
|
|
4
|
+
// Tags: slide, motion-blur, directional
|
|
5
|
+
|
|
6
|
+
// @param Direction in which the images move
|
|
7
|
+
uniform vec2 direction; // = vec2(-1.0, 0.0)
|
|
8
|
+
// @range(0, 1) Length of the motion blur at full speed
|
|
9
|
+
uniform float blur; // = 0.4
|
|
10
|
+
|
|
11
|
+
const int SAMPLES = 24;
|
|
12
|
+
|
|
13
|
+
// The panned strip: the outgoing image, then the incoming one behind it
|
|
14
|
+
vec4 strip(vec2 q, vec2 d) {
|
|
15
|
+
vec2 qt = q + d;
|
|
16
|
+
// which side of the seam between the two images (works for diagonals too)
|
|
17
|
+
if (dot(q - 0.5, -d) < 0.5 * dot(d, d)) {
|
|
18
|
+
return getFromColor(clamp(q, 0.0, 1.0));
|
|
19
|
+
}
|
|
20
|
+
return getToColor(clamp(qt, 0.0, 1.0));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
float rand(vec2 co) {
|
|
24
|
+
return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
vec4 transition(vec2 uv) {
|
|
28
|
+
vec2 d = sign(direction);
|
|
29
|
+
// ease in and out: slow start, whip in the middle, slow landing
|
|
30
|
+
float p = progress;
|
|
31
|
+
float h = 1.0 - abs(2.0 * p - 1.0); // 0 at both ends, 1 in the middle
|
|
32
|
+
// mostly cubic, with a bit of linear so that it starts moving at once
|
|
33
|
+
float e = 0.5 * h * (0.1 + 0.9 * h * h);
|
|
34
|
+
float pos = p < 0.5 ? e : 1.0 - e;
|
|
35
|
+
float len = blur * h * (0.1 + 2.7 * h * h) / 2.8; // follows the speed
|
|
36
|
+
|
|
37
|
+
vec2 q = uv - d * pos;
|
|
38
|
+
// average along the motion, jittered to hide the sample steps
|
|
39
|
+
float jitter = rand(uv);
|
|
40
|
+
vec3 color = vec3(0.0);
|
|
41
|
+
float alpha = 0.0;
|
|
42
|
+
for (int i = 0; i < SAMPLES; i++) {
|
|
43
|
+
float t = (float(i) + jitter) / float(SAMPLES) - 0.5;
|
|
44
|
+
vec4 c = strip(q + d * t * len, d);
|
|
45
|
+
color += c.rgb * c.a;
|
|
46
|
+
alpha += c.a;
|
|
47
|
+
}
|
|
48
|
+
return vec4(color / max(alpha, 1e-5), alpha / float(SAMPLES));
|
|
49
|
+
}
|