gl-transitions 2.3.0 → 2.5.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 +308 -0
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/ArrowWipe.glsl +100 -0
- package/glsl3/BlockSlide.glsl +87 -0
- package/glsl3/CellDissolve.glsl +91 -0
- package/glsl3/ColorPanelWipe.glsl +75 -0
- package/glsl3/Crumple.glsl +173 -0
- package/glsl3/EyeBlink.glsl +83 -0
- package/glsl3/Gallery.glsl +133 -0
- package/glsl3/HeatHaze.glsl +79 -0
- package/glsl3/Hologram.glsl +97 -0
- package/glsl3/LiquidFill.glsl +102 -0
- package/glsl3/PlasmaDissolve.glsl +51 -0
- package/glsl3/RingsWipe.glsl +106 -0
- package/glsl3/SawtoothWipe.glsl +73 -0
- package/glsl3/SnakeBlockWipe.glsl +40 -0
- package/glsl3/Snapshot.glsl +86 -0
- package/glsl3/Sphere.glsl +95 -0
- package/glsl3/SpiralBlockWipe.glsl +65 -0
- package/glsl3/VhsTracking.glsl +127 -0
- package/glsl3/Vortex.glsl +106 -0
- package/index.js +1 -1
- package/layouts.json +787 -18
- package/llms-full.txt +675 -354
- package/llms.txt +204 -185
- package/msl/ArrowWipe.metal +391 -0
- package/msl/BlockSlide.metal +418 -0
- package/msl/CellDissolve.metal +374 -0
- package/msl/ColorPanelWipe.metal +314 -0
- package/msl/Crumple.metal +766 -0
- package/msl/EyeBlink.metal +355 -0
- package/msl/Gallery.metal +813 -0
- package/msl/HeatHaze.metal +320 -0
- package/msl/Hologram.metal +380 -0
- package/msl/LiquidFill.metal +373 -0
- package/msl/PlasmaDissolve.metal +178 -0
- package/msl/RingsWipe.metal +437 -0
- package/msl/SawtoothWipe.metal +310 -0
- package/msl/SnakeBlockWipe.metal +216 -0
- package/msl/Snapshot.metal +321 -0
- package/msl/Sphere.metal +345 -0
- package/msl/SpiralBlockWipe.metal +281 -0
- package/msl/VhsTracking.metal +514 -0
- package/msl/Vortex.metal +522 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +84 -38
- package/sksl/ArrowWipe.sksl +111 -0
- package/sksl/BlockSlide.sksl +99 -0
- package/sksl/CellDissolve.sksl +103 -0
- package/sksl/ColorPanelWipe.sksl +85 -0
- package/sksl/Crumple.sksl +179 -0
- package/sksl/EyeBlink.sksl +94 -0
- package/sksl/Gallery.sksl +139 -0
- package/sksl/HeatHaze.sksl +90 -0
- package/sksl/Hologram.sksl +108 -0
- package/sksl/LiquidFill.sksl +113 -0
- package/sksl/PlasmaDissolve.sksl +64 -0
- package/sksl/RingsWipe.sksl +115 -0
- package/sksl/SawtoothWipe.sksl +83 -0
- package/sksl/SnakeBlockWipe.sksl +53 -0
- package/sksl/Snapshot.sksl +98 -0
- package/sksl/Sphere.sksl +108 -0
- package/sksl/SpiralBlockWipe.sksl +76 -0
- package/sksl/VhsTracking.sksl +138 -0
- package/sksl/Vortex.sksl +116 -0
- package/sksl/index.js +1 -1
- package/transitions/ArrowWipe.glsl +99 -0
- package/transitions/BlockSlide.glsl +86 -0
- package/transitions/CellDissolve.glsl +90 -0
- package/transitions/ColorPanelWipe.glsl +74 -0
- package/transitions/Crumple.glsl +172 -0
- package/transitions/EyeBlink.glsl +82 -0
- package/transitions/Gallery.glsl +132 -0
- package/transitions/HeatHaze.glsl +78 -0
- package/transitions/Hologram.glsl +96 -0
- package/transitions/LiquidFill.glsl +101 -0
- package/transitions/PlasmaDissolve.glsl +50 -0
- package/transitions/RingsWipe.glsl +105 -0
- package/transitions/SawtoothWipe.glsl +72 -0
- package/transitions/SnakeBlockWipe.glsl +39 -0
- package/transitions/Snapshot.glsl +85 -0
- package/transitions/Sphere.glsl +94 -0
- package/transitions/SpiralBlockWipe.glsl +64 -0
- package/transitions/VhsTracking.glsl +126 -0
- package/transitions/Vortex.glsl +105 -0
- package/wgsl/ArrowWipe.wgsl +352 -0
- package/wgsl/BlockSlide.wgsl +384 -0
- package/wgsl/CellDissolve.wgsl +323 -0
- package/wgsl/ColorPanelWipe.wgsl +274 -0
- package/wgsl/Crumple.wgsl +709 -0
- package/wgsl/EyeBlink.wgsl +308 -0
- package/wgsl/Gallery.wgsl +741 -0
- package/wgsl/HeatHaze.wgsl +282 -0
- package/wgsl/Hologram.wgsl +339 -0
- package/wgsl/LiquidFill.wgsl +339 -0
- package/wgsl/PlasmaDissolve.wgsl +149 -0
- package/wgsl/RingsWipe.wgsl +394 -0
- package/wgsl/SawtoothWipe.wgsl +279 -0
- package/wgsl/SnakeBlockWipe.wgsl +188 -0
- package/wgsl/Snapshot.wgsl +287 -0
- package/wgsl/Sphere.wgsl +316 -0
- package/wgsl/SpiralBlockWipe.wgsl +250 -0
- package/wgsl/VhsTracking.wgsl +462 -0
- package/wgsl/Vortex.wgsl +463 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A camera flash freezes the outgoing image into a printed photo with a white border, which shrinks, tilts and drops out of the frame, revealing the incoming image behind it
|
|
4
|
+
// Tags: photo, flash, scale, rotate, fall, shadow
|
|
5
|
+
|
|
6
|
+
// @range(0, 1) How much the photo turns as it drops
|
|
7
|
+
uniform float tilt; // = 0.35
|
|
8
|
+
// @range(0, 0.15) Width of the photo's border, relative to the frame height
|
|
9
|
+
uniform float border; // = 0.04
|
|
10
|
+
// @range(0, 1) Strength of the camera flash
|
|
11
|
+
uniform float flash; // = 0.85
|
|
12
|
+
// @range(0, 1) Darkness of the soft shadow the photo casts on the incoming image
|
|
13
|
+
uniform float shadow; // = 0.45
|
|
14
|
+
// @color Color of the photo's border
|
|
15
|
+
uniform vec4 borderColor; // = vec4(0.96, 0.94, 0.89, 1.0)
|
|
16
|
+
|
|
17
|
+
const float SHRINK = 0.24; // how much smaller the photo gets before it drops
|
|
18
|
+
const float RADIUS = 0.008; // corner radius of the photo, in frame heights
|
|
19
|
+
const float AA = 0.0015; // width of the antialiased edges, in frame heights
|
|
20
|
+
|
|
21
|
+
// signed distance to a rounded box of half size b and corner radius r
|
|
22
|
+
float roundedBox(vec2 q, vec2 b, float r) {
|
|
23
|
+
vec2 d = abs(q) - b + r;
|
|
24
|
+
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
vec4 premultiply(vec4 c) {
|
|
28
|
+
return vec4(c.rgb * c.a, c.a);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
vec4 transition(vec2 uv) {
|
|
32
|
+
float p = progress;
|
|
33
|
+
vec2 asp = vec2(ratio, 1.0);
|
|
34
|
+
vec2 q = (uv - 0.5) * asp;
|
|
35
|
+
vec2 halfImage = 0.5 * asp;
|
|
36
|
+
vec2 halfCard = halfImage + border;
|
|
37
|
+
|
|
38
|
+
// the photo shrinks right after the flash, then falls with gravity, turning as it goes
|
|
39
|
+
float k = smoothstep(0.05, 0.4, p);
|
|
40
|
+
float t = clamp((p - 0.3) / 0.7, 0.0, 1.0);
|
|
41
|
+
float fall = t * t;
|
|
42
|
+
float s = 1.0 - SHRINK * k;
|
|
43
|
+
float a = -tilt * (0.12 * k + 0.88 * fall);
|
|
44
|
+
// fall far enough for the turned photo and its shadow to be out of the frame at the end
|
|
45
|
+
float bound = (abs(sin(tilt)) * halfCard.x + abs(cos(tilt)) * halfCard.y) * (1.0 - SHRINK);
|
|
46
|
+
// it is lifted a little toward the viewer before it falls
|
|
47
|
+
float lift = 0.035 * k * (1.0 - fall);
|
|
48
|
+
vec2 center = vec2(0.08 * fall, lift - (0.5 + bound + 0.1) * fall);
|
|
49
|
+
|
|
50
|
+
float rad = RADIUS * k;
|
|
51
|
+
|
|
52
|
+
float ca = cos(a), sa = sin(a);
|
|
53
|
+
mat2 unrotate = mat2(ca, -sa, sa, ca);
|
|
54
|
+
|
|
55
|
+
// the incoming image, already behind the photo, in its soft shadow
|
|
56
|
+
vec4 col = getToColor(uv);
|
|
57
|
+
float sh = shadow * k;
|
|
58
|
+
if (sh > 0.0) {
|
|
59
|
+
vec2 rs = unrotate * (q - center - vec2(0.012, -0.022) * k) / s;
|
|
60
|
+
float ds = roundedBox(rs, halfCard, rad) * s;
|
|
61
|
+
float blur = 0.035 * s;
|
|
62
|
+
col.rgb *= 1.0 - sh * (1.0 - smoothstep(-blur, blur, ds));
|
|
63
|
+
}
|
|
64
|
+
col = premultiply(col);
|
|
65
|
+
|
|
66
|
+
// the photo: the outgoing image, framed by its border
|
|
67
|
+
vec2 r = unrotate * (q - center) / s;
|
|
68
|
+
float dCard = roundedBox(r, halfCard, rad) * s;
|
|
69
|
+
float dImage = roundedBox(r, halfImage, 0.0) * s;
|
|
70
|
+
// the edges are pushed out by one antialiasing width, so the photo covers the full frame at the start
|
|
71
|
+
float cardCover = clamp(1.5 - dCard / AA, 0.0, 1.0);
|
|
72
|
+
float imageCover = clamp(1.5 - dImage / AA, 0.0, 1.0);
|
|
73
|
+
// the image replaces what is behind it, while the border is laid over the incoming image, which shows through a translucent border
|
|
74
|
+
vec4 photo = premultiply(getFromColor(clamp(r / asp + 0.5, 0.0, 1.0)));
|
|
75
|
+
vec4 paper = premultiply(borderColor);
|
|
76
|
+
vec4 card = mix(paper + col * (1.0 - paper.a), photo, imageCover);
|
|
77
|
+
col = mix(col, card, cardCover);
|
|
78
|
+
if (col.a <= 0.0) return vec4(0.0);
|
|
79
|
+
col.rgb /= col.a;
|
|
80
|
+
|
|
81
|
+
// the flash only adds light: a quick bloom to white that fades as the photo comes out
|
|
82
|
+
float f = flash * smoothstep(0.0, 0.05, p) * (1.0 - smoothstep(0.05, 0.3, p));
|
|
83
|
+
col.rgb = 1.0 - (1.0 - col.rgb) * (1.0 - f);
|
|
84
|
+
return col;
|
|
85
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image wraps itself onto a shaded ball that shrinks and rolls away, revealing the incoming image under its shadow
|
|
4
|
+
// Tags: 3d, sphere, roll, wrap, shape
|
|
5
|
+
|
|
6
|
+
// @param Direction the ball rolls away toward
|
|
7
|
+
uniform vec2 direction; // = vec2(1.0, 0.0)
|
|
8
|
+
// @range(0.1, 0.5) Radius of the ball once wrapped, relative to the shorter side of the frame
|
|
9
|
+
uniform float size; // = 0.3
|
|
10
|
+
// @range(0, 1) Strength of the light and shading on the ball
|
|
11
|
+
uniform float shading; // = 0.6
|
|
12
|
+
// @range(0, 1) Darkness of the soft shadow the ball casts on the incoming image
|
|
13
|
+
uniform float shadow; // = 0.5
|
|
14
|
+
|
|
15
|
+
const float PI = 3.14159265;
|
|
16
|
+
// half width of the antialiased ball edge, in frame heights
|
|
17
|
+
const float AA = 0.0015;
|
|
18
|
+
// toward the light, from the top left
|
|
19
|
+
const vec3 LIGHT = vec3(-0.5, 0.6, 1.0) / 1.2689;
|
|
20
|
+
|
|
21
|
+
vec4 transition(vec2 uv) {
|
|
22
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
23
|
+
vec4 b = getToColor(uv);
|
|
24
|
+
if (progress >= 1.0) return b;
|
|
25
|
+
|
|
26
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
27
|
+
vec2 side = vec2(-dir.y, dir.x);
|
|
28
|
+
// measured in square pixels, so the ball is round
|
|
29
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
30
|
+
float shorter = min(ratio, 1.0);
|
|
31
|
+
float r0 = clamp(size, 0.1, 0.5) * shorter;
|
|
32
|
+
|
|
33
|
+
// the image curves into a ball (infinite radius: exactly flat at the start), then the
|
|
34
|
+
// ball shrinks while rolling away until it and its shadow have left the frame
|
|
35
|
+
float w = clamp(progress / 0.45, 0.0, 1.0);
|
|
36
|
+
w = 1.0 - (1.0 - w) * (1.0 - w);
|
|
37
|
+
float away = smoothstep(0.3, 1.0, progress);
|
|
38
|
+
away *= away;
|
|
39
|
+
float wrapped = r0 / max(w, 1e-4);
|
|
40
|
+
float radius = wrapped * mix(1.0, 0.5, away);
|
|
41
|
+
// the image is pulled tighter as it wraps, so that it ends up covering the whole ball
|
|
42
|
+
// (its shortest half extent reaches around to the back)
|
|
43
|
+
float tight = mix(1.0, min(1.0, 0.48 * shorter / (PI * r0)), w * w);
|
|
44
|
+
float paper = radius * tight;
|
|
45
|
+
// half extent of the frame along the direction
|
|
46
|
+
float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
|
|
47
|
+
// far enough that the ball (0.5 * r0 by then) and its shadow (within 0.9 * r0 of it) have left
|
|
48
|
+
float full = e + 1.1 * r0 + 2.0 * AA;
|
|
49
|
+
float travel = away * full;
|
|
50
|
+
vec2 center = dir * travel;
|
|
51
|
+
// rolling without slipping: the integral of dtravel / radius while the radius shrinks
|
|
52
|
+
float angle = -2.0 * full * log(1.0 - 0.5 * away) / wrapped;
|
|
53
|
+
|
|
54
|
+
vec2 d = p - center;
|
|
55
|
+
float r = length(d);
|
|
56
|
+
|
|
57
|
+
// soft shadow on the incoming image, below and to the right of the ball (light from the top left)
|
|
58
|
+
vec2 sd = d - vec2(0.25, -0.3) * radius * w;
|
|
59
|
+
float sh = shadow * w * (1.0 - smoothstep(0.6 * radius, 1.4 * radius, length(sd)));
|
|
60
|
+
vec4 bg = vec4(b.rgb * b.a * (1.0 - sh), b.a);
|
|
61
|
+
|
|
62
|
+
vec4 ball = vec4(0.0);
|
|
63
|
+
float cover = 1.0 - smoothstep(radius - AA, radius + AA, r);
|
|
64
|
+
if (cover > 0.0) {
|
|
65
|
+
// normal of the visible point of the ball (no squared radius, which overflows when it is huge)
|
|
66
|
+
vec2 nd = d / radius;
|
|
67
|
+
vec3 n = vec3(nd, sqrt(max(1.0 - dot(nd, nd), 0.0)));
|
|
68
|
+
// undo the roll: rotate around the axis across the direction
|
|
69
|
+
float u = dot(n.xy, dir);
|
|
70
|
+
float s = dot(n.xy, side);
|
|
71
|
+
float cu = cos(angle), su = sin(angle);
|
|
72
|
+
vec3 q = vec3(u * cu - n.z * su, s, u * su + n.z * cu);
|
|
73
|
+
// the image is wrapped around the ball from its front point, distances kept along the surface
|
|
74
|
+
float lq = length(q.xy);
|
|
75
|
+
float arc = atan(lq, q.z) * paper;
|
|
76
|
+
vec2 img = lq > 0.0 ? (q.x * dir + q.y * side) / lq * arc : vec2(0.0);
|
|
77
|
+
vec2 iuv = img / vec2(ratio, 1.0) + 0.5;
|
|
78
|
+
// distance to the edge of the image, antialiased like the ball's outline
|
|
79
|
+
vec2 edge = min(iuv, 1.0 - iuv) * vec2(ratio, 1.0);
|
|
80
|
+
float inside = cover * smoothstep(-AA, AA, min(edge.x, edge.y));
|
|
81
|
+
if (inside > 0.0) {
|
|
82
|
+
vec4 c = getFromColor(clamp(iuv, 0.0, 1.0));
|
|
83
|
+
float diff = max(dot(n, LIGHT), 0.0);
|
|
84
|
+
float spec = pow(max(reflect(-LIGHT, n).z, 0.0), 24.0);
|
|
85
|
+
float k = shading * w;
|
|
86
|
+
vec3 lit = c.rgb * mix(1.0, 0.25 + 0.85 * diff, k) + 0.35 * k * spec;
|
|
87
|
+
ball = vec4(clamp(lit, 0.0, 1.0) * c.a, c.a) * inside;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// the ball over the incoming image, premultiplied so transparent images do not bleed their color
|
|
92
|
+
vec4 c = ball + bg * (1.0 - ball.a);
|
|
93
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
94
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: Square blocks switch to the incoming image one after another along a rectangular spiral, from the border inward or from the center outward
|
|
4
|
+
// Tags: wipe, grid, blocks, spiral
|
|
5
|
+
|
|
6
|
+
// @param Number of blocks (columns, rows)
|
|
7
|
+
uniform ivec2 grid; // = ivec2(8, 6)
|
|
8
|
+
// @param Spiral from the top left corner inward; false spirals from the center outward, ending at the top left corner
|
|
9
|
+
uniform bool inward; // = true
|
|
10
|
+
// @param Turn clockwise; false turns counterclockwise
|
|
11
|
+
uniform bool clockwise; // = true
|
|
12
|
+
// @range(0, 0.5) Duration of each block's fade, as a fraction of the transition
|
|
13
|
+
uniform float smoothness; // = 0.05
|
|
14
|
+
|
|
15
|
+
// Position of the cell c (from the top left corner) along the spiral that runs clockwise
|
|
16
|
+
// from the top left corner of a n.x by n.y grid inward, from 0 to n.x * n.y - 1
|
|
17
|
+
float spiralIndex(vec2 c, vec2 n) {
|
|
18
|
+
// ring: distance to the border, in cells
|
|
19
|
+
float k = min(min(c.x, c.y), min(n.x - 1.0 - c.x, n.y - 1.0 - c.y));
|
|
20
|
+
// size of the ring, and the cell's position in it
|
|
21
|
+
vec2 s = n - 2.0 * k;
|
|
22
|
+
vec2 l = c - k;
|
|
23
|
+
// the outer rings come first
|
|
24
|
+
float before = n.x * n.y - s.x * s.y;
|
|
25
|
+
float along;
|
|
26
|
+
if (l.y == 0.0) along = l.x; // top side, to the right
|
|
27
|
+
else if (l.x == s.x - 1.0) along = s.x - 1.0 + l.y; // right side, down
|
|
28
|
+
else if (l.y == s.y - 1.0) along = 2.0 * s.x + s.y - 3.0 - l.x; // bottom side, to the left
|
|
29
|
+
else along = 2.0 * (s.x - 1.0) + 2.0 * (s.y - 1.0) - l.y; // left side, up
|
|
30
|
+
return before + along;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
vec4 transition(vec2 uv) {
|
|
34
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
35
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
36
|
+
|
|
37
|
+
vec2 n = max(vec2(grid), vec2(1.0));
|
|
38
|
+
// the cell, counted from the top left corner
|
|
39
|
+
vec2 c = min(floor(vec2(uv.x, 1.0 - uv.y) * n), n - 1.0);
|
|
40
|
+
// the transposed spiral turns the other way from the same corner; walking the spiral
|
|
41
|
+
// outward reverses it too
|
|
42
|
+
if (clockwise != inward) {
|
|
43
|
+
c = c.yx;
|
|
44
|
+
n = n.yx;
|
|
45
|
+
}
|
|
46
|
+
float count = n.x * n.y;
|
|
47
|
+
float i = spiralIndex(c, n);
|
|
48
|
+
if (!inward) i = count - 1.0 - i;
|
|
49
|
+
|
|
50
|
+
// the blocks switch one after another, each one fading in over w blocks of time, the first
|
|
51
|
+
// fade starting at 0 and the last ending at 1; without fade, block i switches at (i + 0.5) / count
|
|
52
|
+
float w = max(smoothness, 0.0) * count;
|
|
53
|
+
float o = max(0.5 * (1.0 - w), 0.0);
|
|
54
|
+
float x = progress * (count - 1.0 + 2.0 * o + w) - i - o;
|
|
55
|
+
float m = w > 0.0 ? smoothstep(0.0, w, x) : step(0.0, x);
|
|
56
|
+
|
|
57
|
+
if (m <= 0.0) return getFromColor(uv);
|
|
58
|
+
if (m >= 1.0) return getToColor(uv);
|
|
59
|
+
vec4 a = getFromColor(uv);
|
|
60
|
+
vec4 b = getToColor(uv);
|
|
61
|
+
// mixed premultiplied, so transparent images do not bleed their color
|
|
62
|
+
vec4 col = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
|
|
63
|
+
return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
|
|
64
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: Tape-tracking bands of white snow roll down the frame, tearing the lines around them, with smeared color, wobbling lines, a jittering strip at the bottom and a dropout flash, as the incoming image is recorded over the outgoing one under the densest band
|
|
4
|
+
// Tags: retro, glitch, noise, tape, scanlines
|
|
5
|
+
|
|
6
|
+
// @range(1, 4, 1) Number of noise bands rolling down (the first one carries the cut)
|
|
7
|
+
uniform int bands; // = 3
|
|
8
|
+
// @range(0, 1) Amount of snow and tearing in the bands
|
|
9
|
+
uniform float noise; // = 0.6
|
|
10
|
+
// @range(0, 1) How far the color smears to the right of the picture
|
|
11
|
+
uniform float bleed; // = 0.5
|
|
12
|
+
// @range(0, 1) How much the lines wobble sideways
|
|
13
|
+
uniform float wobble; // = 0.5
|
|
14
|
+
|
|
15
|
+
const float LINES = 220.0; // tape lines over the frame height
|
|
16
|
+
const float FRAMES = 40.0; // the noise changes this many times over the transition
|
|
17
|
+
const float BAND = 0.11; // half height of the main band
|
|
18
|
+
const float STRIP = 0.06; // height of the jittering strip at the bottom
|
|
19
|
+
const int TAPS = 6;
|
|
20
|
+
|
|
21
|
+
float hash12(vec2 v) {
|
|
22
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
23
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
24
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
vec2 mirror(vec2 v) {
|
|
28
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// the tape image on the outgoing (or, once re-recorded, incoming) side, premultiplied
|
|
32
|
+
vec4 tape(vec2 p, bool fresh) {
|
|
33
|
+
p = mirror(p);
|
|
34
|
+
vec4 c = fresh ? getToColor(p) : getFromColor(p);
|
|
35
|
+
return vec4(c.rgb * c.a, c.a);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
float luma(vec3 c) {
|
|
39
|
+
return dot(c, vec3(0.299, 0.587, 0.114));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// how dense a band centered at y = c of half height w is on line y, with ragged edges
|
|
43
|
+
float bandDensity(float y, float c, float w, float jitter) {
|
|
44
|
+
float d = abs(y - c) / w + 0.35 * jitter;
|
|
45
|
+
return 1.0 - smoothstep(0.0, 1.0, d);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
vec4 transition(vec2 uv) {
|
|
49
|
+
// the effects build up quickly and settle at the end: exactly 0 at both ends
|
|
50
|
+
float h = clamp(2.5 * (1.0 - abs(2.0 * progress - 1.0)), 0.0, 1.0);
|
|
51
|
+
float env = h * h * (3.0 - 2.0 * h);
|
|
52
|
+
// a short dropout flash when the main band crosses the middle of the frame
|
|
53
|
+
float f = clamp(1.0 - abs(progress - 0.5) / 0.04, 0.0, 1.0);
|
|
54
|
+
float flash = f * f * (3.0 - 2.0 * f);
|
|
55
|
+
|
|
56
|
+
float frame = floor(progress * FRAMES);
|
|
57
|
+
float line = floor(uv.y * LINES);
|
|
58
|
+
float jitter = hash12(vec2(line, frame + 7.0)) - 0.5;
|
|
59
|
+
|
|
60
|
+
// the main band rolls from above the frame to below it; the incoming image is above it
|
|
61
|
+
float c0 = mix(1.0 + 1.2 * BAND, -1.2 * BAND, progress);
|
|
62
|
+
// (the cut is ragged, line by line)
|
|
63
|
+
bool fresh = uv.y > c0 + 0.8 * BAND * jitter;
|
|
64
|
+
float dens = bandDensity(uv.y, c0, BAND, jitter);
|
|
65
|
+
float tear = 1.0 - smoothstep(0.0, 1.0, abs(uv.y - c0) / (2.5 * BAND));
|
|
66
|
+
// thinner and weaker bands roll faster, wrapping around the frame
|
|
67
|
+
for (int i = 1; i < 4; i++) {
|
|
68
|
+
if (i < bands) {
|
|
69
|
+
float k = float(i);
|
|
70
|
+
float w = BAND * (0.35 + 0.2 * hash12(vec2(k, 3.0)));
|
|
71
|
+
float speed = 1.3 + 0.9 * k;
|
|
72
|
+
float cy = -w + (1.0 + 2.0 * w) * fract(hash12(vec2(k, 5.0)) - speed * progress);
|
|
73
|
+
dens = max(dens, 0.6 * bandDensity(uv.y, cy, w, jitter));
|
|
74
|
+
tear = max(tear, 0.5 * (1.0 - smoothstep(0.0, 1.0, abs(uv.y - cy) / (2.5 * w))));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
dens *= env;
|
|
78
|
+
tear *= env;
|
|
79
|
+
|
|
80
|
+
// horizontal displacement of the line: a slow wobble, a fine jitter and the tearing
|
|
81
|
+
float rowTear = hash12(vec2(floor(uv.y * LINES * 0.5), frame + 31.0)) - 0.5;
|
|
82
|
+
float dx = wobble * env * (0.006 * sin(uv.y * 7.0 + progress * 23.0) + 0.004 * jitter);
|
|
83
|
+
dx += (0.3 + 0.7 * noise) * tear * 0.18 * rowTear;
|
|
84
|
+
// the head-switching strip at the bottom: lines skewed sideways and jittering
|
|
85
|
+
float strip = env * (1.0 - smoothstep(0.0, STRIP, uv.y));
|
|
86
|
+
dx += strip * (0.03 + 0.06 * (1.0 - uv.y / STRIP)) * (0.6 + 0.8 * hash12(vec2(frame, 41.0)));
|
|
87
|
+
vec2 q = vec2(uv.x + dx, uv.y);
|
|
88
|
+
|
|
89
|
+
vec4 c = tape(q, fresh);
|
|
90
|
+
if (c.a <= 0.0) return vec4(0.0);
|
|
91
|
+
// chroma bleed: the color is smeared to the right of the luma
|
|
92
|
+
float len = bleed * (0.02 + 0.05 * dens) * env;
|
|
93
|
+
vec4 avg = c;
|
|
94
|
+
if (len > 0.0) {
|
|
95
|
+
avg = vec4(0.0);
|
|
96
|
+
for (int i = 0; i < TAPS; i++) {
|
|
97
|
+
float u = (float(i) + 0.5) / float(TAPS);
|
|
98
|
+
avg += tape(q - vec2(len * (0.4 + u), 0.0), fresh);
|
|
99
|
+
}
|
|
100
|
+
avg /= float(TAPS);
|
|
101
|
+
}
|
|
102
|
+
vec3 chroma = (avg.rgb - luma(avg.rgb)) / max(avg.a, 1e-5);
|
|
103
|
+
vec3 rgb = luma(c.rgb) + chroma * c.a; // premultiplied by c.a
|
|
104
|
+
// the signal fades and loses color under the bands
|
|
105
|
+
rgb = mix(rgb, vec3(luma(rgb)), 0.6 * dens);
|
|
106
|
+
|
|
107
|
+
// snow: short white streaks on the tape lines, denser in the bands
|
|
108
|
+
// (the streaks of each line start at a random offset so they never line up vertically)
|
|
109
|
+
vec2 cell = vec2(floor(uv.x * LINES * 0.3 * ratio + 40.0 * jitter), line);
|
|
110
|
+
float n = hash12(cell + frame * vec2(37.0, 17.0));
|
|
111
|
+
float amount = clamp(noise * max(1.3 * dens, 0.8 * strip) + 0.35 * flash, 0.0, 1.0);
|
|
112
|
+
float snow = amount > 0.0 ? smoothstep(1.0 - amount, 1.0 - 0.6 * amount, n) : 0.0;
|
|
113
|
+
snow *= 0.55 + 0.45 * hash12(cell.yx + frame);
|
|
114
|
+
// and a finer sparkle between them
|
|
115
|
+
float g = hash12(vec2(floor(uv.x * LINES * ratio), line) + frame * vec2(13.0, 29.0));
|
|
116
|
+
snow = max(snow, amount > 0.0 ? 0.7 * smoothstep(1.0 - 0.4 * amount, 1.0, g) : 0.0);
|
|
117
|
+
// and a few dark specks
|
|
118
|
+
float dark = g < 0.1 * amount ? 1.0 : 0.0;
|
|
119
|
+
// the dropout: whole stretches of a few lines go white
|
|
120
|
+
float group = floor(uv.y * LINES / 3.0);
|
|
121
|
+
float drop = step(1.0 - 0.15 * flash, hash12(vec2(group, floor(uv.x * 6.0 + 5.0 * hash12(vec2(group, frame))) + frame * 7.0)));
|
|
122
|
+
rgb *= 1.0 - 0.5 * dark;
|
|
123
|
+
rgb += (clamp(snow + drop + 0.12 * flash, 0.0, 1.0)) * (c.a - rgb);
|
|
124
|
+
|
|
125
|
+
return vec4(clamp(rgb / c.a, 0.0, 1.0), c.a);
|
|
126
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image breaks into hundreds of small squares that a tornado carries away along a spiral around the center, from the eye outward, uncovering the incoming image
|
|
4
|
+
// Tags: tiles, spiral, rotation, shatter
|
|
5
|
+
|
|
6
|
+
// @range(4, 40, 1) Number of rows of squares
|
|
7
|
+
uniform int grid; // = 24
|
|
8
|
+
// Center of the tornado
|
|
9
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
10
|
+
// @range(-4, 4) Turns each square makes around the center as it flies away (negative turns clockwise)
|
|
11
|
+
uniform float spin; // = 1.0
|
|
12
|
+
// @range(0, 1) How randomly the squares leave: 0 from the center outward, 1 in any order
|
|
13
|
+
uniform float randomness; // = 0.2
|
|
14
|
+
|
|
15
|
+
// the squares leave in GROUPS waves, each one flying for DURATION of the transition
|
|
16
|
+
const int GROUPS = 24;
|
|
17
|
+
const float DURATION = 0.25;
|
|
18
|
+
// half width of the antialiased edge of the squares, in frame heights
|
|
19
|
+
const float AA = 0.0015;
|
|
20
|
+
const float TAU = 6.2831853;
|
|
21
|
+
|
|
22
|
+
float hash(vec2 n) {
|
|
23
|
+
return fract(sin(dot(n, vec2(12.9898, 78.233))) * 43758.5453);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// the wave a square (by its cell index) leaves with
|
|
27
|
+
int groupOf(vec2 n, float h, vec2 c, float maxR) {
|
|
28
|
+
// only the very corners leave last
|
|
29
|
+
float r = min(length((n + 0.5) * h - c) / (0.85 * maxR), 1.0);
|
|
30
|
+
float key = clamp(mix(r * sqrt(r), hash(n), clamp(randomness, 0.0, 1.0)), 0.0, 0.9999);
|
|
31
|
+
return int(floor(key * float(GROUPS)));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// local time of a wave's flight, 0 before it leaves, 1 once it has vanished
|
|
35
|
+
float flight(int g) {
|
|
36
|
+
float delay = float(g) / float(GROUPS) * (1.0 - DURATION);
|
|
37
|
+
return clamp((progress - delay) / DURATION, 0.0, 1.0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
vec4 premultiplied(vec4 c) {
|
|
41
|
+
return vec4(c.rgb * c.a, c.a);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
vec4 transition(vec2 uv) {
|
|
45
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
46
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
47
|
+
|
|
48
|
+
// measured in square pixels, so the squares stay square
|
|
49
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
50
|
+
vec2 p = uv * aspect;
|
|
51
|
+
vec2 c = center * aspect;
|
|
52
|
+
float maxR = max(max(length(c), length(c - vec2(ratio, 0.0))), max(length(c - vec2(0.0, 1.0)), length(c - aspect)));
|
|
53
|
+
float h = 1.0 / float(grid < 1 ? 1 : grid);
|
|
54
|
+
// how far a square is pushed away from the center by the end of its flight
|
|
55
|
+
float reach = 0.7 * maxR;
|
|
56
|
+
|
|
57
|
+
// the incoming image, under the squares that have not left yet
|
|
58
|
+
vec2 n0 = floor(p / h);
|
|
59
|
+
vec4 col = flight(groupOf(n0, h, c, maxR)) <= 0.0 ? premultiplied(getFromColor(uv)) : premultiplied(getToColor(uv));
|
|
60
|
+
|
|
61
|
+
// the flying squares, painted from the last wave to leave (lowest) to the first (highest)
|
|
62
|
+
for (int k = 0; k < GROUPS; k++) {
|
|
63
|
+
int g = GROUPS - 1 - k;
|
|
64
|
+
float s = flight(g);
|
|
65
|
+
if (s <= 0.0 || s >= 1.0) continue;
|
|
66
|
+
float e = s * s;
|
|
67
|
+
// like in a tornado, the squares near the eye (the first to leave) spin much faster than
|
|
68
|
+
// the outer ones; all of them orbit before they are flung out
|
|
69
|
+
float angle = spin * TAU * e * 2.0 / (1.0 + 6.0 * float(g) / float(GROUPS));
|
|
70
|
+
float push = reach * e * s;
|
|
71
|
+
// the squares lift toward the viewer, then shrink away
|
|
72
|
+
float size = (1.0 + 0.35 * sin(3.1415927 * s)) * (1.0 - s * s * s);
|
|
73
|
+
float ca = cos(angle);
|
|
74
|
+
float sa = sin(angle);
|
|
75
|
+
mat2 rot = mat2(ca, sa, -sa, ca);
|
|
76
|
+
// undo the wave's spiral to guess which square lands here, then test its neighbors exactly
|
|
77
|
+
vec2 u = (p - c) * rot;
|
|
78
|
+
float ru = length(u);
|
|
79
|
+
vec2 guess = c + (ru > 0.0 ? u / ru : vec2(0.0)) * max(ru - push, 0.0);
|
|
80
|
+
vec2 ng = floor(guess / h);
|
|
81
|
+
for (int j = -1; j <= 1; j++) {
|
|
82
|
+
for (int i = -1; i <= 1; i++) {
|
|
83
|
+
vec2 n = ng + vec2(float(i), float(j));
|
|
84
|
+
if (groupOf(n, h, c, maxR) != g) continue;
|
|
85
|
+
vec2 home = (n + 0.5) * h;
|
|
86
|
+
vec2 rel = home - c;
|
|
87
|
+
float rr = length(rel);
|
|
88
|
+
vec2 dir = rr > 0.0 ? rel / rr : vec2(0.0);
|
|
89
|
+
vec2 pos = c + rot * (dir * (rr + push));
|
|
90
|
+
// each square also tumbles on itself
|
|
91
|
+
float tumble = angle + (hash(n + 17.0) - 0.5) * 3.0 * e * sign(spin);
|
|
92
|
+
float ct = cos(tumble);
|
|
93
|
+
float st = sin(tumble);
|
|
94
|
+
vec2 d = ((p - pos) * mat2(ct, st, -st, ct)) / max(size, 1e-4);
|
|
95
|
+
float edge = 0.5 * h - max(abs(d.x), abs(d.y));
|
|
96
|
+
float cov = clamp(edge * size / (2.0 * AA) + 0.5, 0.0, 1.0);
|
|
97
|
+
vec2 src = home + d;
|
|
98
|
+
if (cov <= 0.0 || src.x < 0.0 || src.y < 0.0 || src.x > ratio || src.y > 1.0) continue;
|
|
99
|
+
vec4 piece = premultiplied(getFromColor(src / aspect)) * cov;
|
|
100
|
+
col = piece + col * (1.0 - piece.a);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
|
|
105
|
+
}
|