gl-transitions 2.3.0 → 2.4.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 +12 -0
- package/compatibility.json +64 -0
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/ColorPanelWipe.glsl +75 -0
- package/glsl3/EyeBlink.glsl +83 -0
- package/glsl3/Gallery.glsl +133 -0
- package/glsl3/VhsTracking.glsl +127 -0
- package/index.js +1 -1
- package/layouts.json +169 -0
- package/llms-full.txt +423 -354
- package/llms.txt +189 -185
- package/msl/ColorPanelWipe.metal +314 -0
- package/msl/EyeBlink.metal +355 -0
- package/msl/Gallery.metal +813 -0
- package/msl/VhsTracking.metal +514 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +26 -14
- package/sksl/ColorPanelWipe.sksl +85 -0
- package/sksl/EyeBlink.sksl +94 -0
- package/sksl/Gallery.sksl +139 -0
- package/sksl/VhsTracking.sksl +138 -0
- package/sksl/index.js +1 -1
- package/transitions/ColorPanelWipe.glsl +74 -0
- package/transitions/EyeBlink.glsl +82 -0
- package/transitions/Gallery.glsl +132 -0
- package/transitions/VhsTracking.glsl +126 -0
- package/wgsl/ColorPanelWipe.wgsl +274 -0
- package/wgsl/EyeBlink.wgsl +308 -0
- package/wgsl/Gallery.wgsl +741 -0
- package/wgsl/VhsTracking.wgsl +462 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// ColorPanelWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ColorPanelWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: Solid color panels, slightly staggered, sweep across and cover the frame, then sweep off the far side and reveal the incoming image
|
|
5
|
+
// Tags: wipe, panels, color, slanted, motion-graphics
|
|
6
|
+
|
|
7
|
+
// @param Direction the panels sweep toward
|
|
8
|
+
uniform vec2 direction; // = vec2(1.0, 0.0)
|
|
9
|
+
// @range(1, 3, 1) Number of panels
|
|
10
|
+
uniform int panels; // = 3
|
|
11
|
+
// @color Color of the first panel
|
|
12
|
+
uniform vec4 color1; // = vec4(0.98, 0.76, 0.22, 1.0)
|
|
13
|
+
// @color Color of the second panel
|
|
14
|
+
uniform vec4 color2; // = vec4(0.93, 0.33, 0.36, 1.0)
|
|
15
|
+
// @color Color of the third panel
|
|
16
|
+
uniform vec4 color3; // = vec4(0.16, 0.2, 0.42, 1.0)
|
|
17
|
+
// @range(0, 1) Delay between the panels, relative to the sweep of one panel (at 0, they move as one and only the last shows)
|
|
18
|
+
uniform float stagger; // = 0.35
|
|
19
|
+
// @range(-1, 1) Slant of the panels' edges
|
|
20
|
+
uniform float skew; // = 0.25
|
|
21
|
+
|
|
22
|
+
// the frame is fully covered from cut - hold to cut + hold, where the image switches
|
|
23
|
+
const float cut = 0.46;
|
|
24
|
+
const float hold = 0.01;
|
|
25
|
+
// half width of the antialiased edges, in frame heights
|
|
26
|
+
const float aa = 0.0015;
|
|
27
|
+
|
|
28
|
+
// a short acceleration, a fast sweep, and a long settle
|
|
29
|
+
float ease(float t) {
|
|
30
|
+
float s = clamp(t, 0.0, 1.0);
|
|
31
|
+
float u = 1.0 - s * s * (3.0 - 2.0 * s);
|
|
32
|
+
return 1.0 - u * u * u;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// how much of x a panel between the edges back and front covers
|
|
36
|
+
float cover(float x, float back, float front) {
|
|
37
|
+
return smoothstep(back - aa, back + aa, x) * (1.0 - smoothstep(front - aa, front + aa, x));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
vec4 transition(vec2 uv) {
|
|
41
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
42
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
43
|
+
float k = clamp(skew, -1.0, 1.0);
|
|
44
|
+
// position along the sweep, slanted across it, in frame heights across the edges
|
|
45
|
+
vec2 a = (dir + k * vec2(-dir.y, dir.x)) / sqrt(1.0 + k * k);
|
|
46
|
+
float x = dot(p, a);
|
|
47
|
+
// half extent of the frame along x
|
|
48
|
+
float e = 0.5 * (abs(a.x) * ratio + abs(a.y));
|
|
49
|
+
float start = -e - 2.0 * aa;
|
|
50
|
+
float span = 2.0 * (e + 2.0 * aa);
|
|
51
|
+
|
|
52
|
+
int n = panels < 1 ? 1 : panels > 3 ? 3 : panels;
|
|
53
|
+
float m = float(n - 1);
|
|
54
|
+
float st = clamp(stagger, 0.0, 1.0);
|
|
55
|
+
// durations of a panel's sweep in and out
|
|
56
|
+
vec2 d = vec2(cut - hold, 1.0 - cut - hold) / (1.0 + m * st);
|
|
57
|
+
|
|
58
|
+
// the first panel enters first and leaves last: the outgoing image is ahead of it, the incoming one behind it
|
|
59
|
+
// (both are sampled, so that no texture read sits in a branch that differs between pixels)
|
|
60
|
+
float front0 = start + span * ease(progress / d.x);
|
|
61
|
+
float back0 = start + span * ease((progress - 1.0 + d.y) / d.y);
|
|
62
|
+
vec4 c = mix(getToColor(uv), getFromColor(uv), step(0.5 * (front0 + back0), x));
|
|
63
|
+
c = mix(c, color1, cover(x, back0, front0));
|
|
64
|
+
|
|
65
|
+
// each next panel covers the ones before it, enters after them and leaves before them
|
|
66
|
+
for (int i = 1; i < 3; i++) {
|
|
67
|
+
if (i < n) {
|
|
68
|
+
vec2 t = float(i) * st * d;
|
|
69
|
+
float front = start + span * ease((progress - t.x) / d.x);
|
|
70
|
+
float back = start + span * ease((progress - 1.0 + d.y + t.y) / d.y);
|
|
71
|
+
c = mix(c, i == 1 ? color2 : color3, cover(x, back, front));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return c.a > 0.0 ? c : vec4(0.0);
|
|
75
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// EyeBlink — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/EyeBlink.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: Curved eyelids close from the top and bottom over the outgoing image, which blurs and dims, then open on the incoming image as it comes back into focus, as if the viewer blinked
|
|
5
|
+
// Tags: blink, eye, blur, shape
|
|
6
|
+
|
|
7
|
+
// @range(0, 1) How much the image blurs and dims while the eyes are closed
|
|
8
|
+
uniform float blur; // = 0.5
|
|
9
|
+
// @range(0.01, 0.3) Width of the soft shadow along the rim of the eyelids
|
|
10
|
+
uniform float softness; // = 0.12
|
|
11
|
+
// @range(1, 2, 1) Number of blinks: 1, or 2 for a quick double blink (the cut happens on the first one)
|
|
12
|
+
uniform int blinks; // = 1
|
|
13
|
+
// @color Color of the eyelids
|
|
14
|
+
uniform vec4 color; // = vec4(0.03, 0.02, 0.02, 1.0)
|
|
15
|
+
|
|
16
|
+
const int TAPS = 16;
|
|
17
|
+
// how much the eyelids curve: the opening is widest at the center and the corners close first
|
|
18
|
+
const float CURVE = 0.25;
|
|
19
|
+
// where the eyelids meet, below the middle: the upper lid travels further than the lower one
|
|
20
|
+
const float MEET = 0.44;
|
|
21
|
+
|
|
22
|
+
vec2 mirror(vec2 v) {
|
|
23
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// a blink fully closed at c (held for 2 * hold): the lids close over wc before it
|
|
27
|
+
// and open over wo after it, slower, like a real blink
|
|
28
|
+
float lidBlink(float t, float c, float wc, float wo, float hold) {
|
|
29
|
+
return 1.0 - smoothstep(hold, t < c ? wc : wo, abs(t - c));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
vec4 image(vec2 uv, bool incoming) {
|
|
33
|
+
vec4 c = incoming ? getToColor(uv) : getFromColor(uv);
|
|
34
|
+
return vec4(c.rgb * c.a, c.a);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
vec4 transition(vec2 uv) {
|
|
38
|
+
bool two = blinks > 1;
|
|
39
|
+
// the moment the eyes are fully closed, when the images are swapped
|
|
40
|
+
float cut = two ? 0.3 : 0.42;
|
|
41
|
+
// how closed the eyes are: 0 open, 1 closed
|
|
42
|
+
float closed = two
|
|
43
|
+
? max(lidBlink(progress, cut, 0.26, 0.26, 0.015), lidBlink(progress, 0.7, 0.14, 0.24, 0.01))
|
|
44
|
+
: lidBlink(progress, cut, 0.36, 0.5, 0.02);
|
|
45
|
+
bool incoming = progress >= cut;
|
|
46
|
+
|
|
47
|
+
// the rim of each eyelid is an arc; fully open, even its corners clear the frame by the widest shadow
|
|
48
|
+
float soft = clamp(softness, 0.001, 0.3);
|
|
49
|
+
float x = 2.0 * uv.x - 1.0;
|
|
50
|
+
float rim = (1.0 - closed) * (1.31 + CURVE) - CURVE * x * x;
|
|
51
|
+
// distance inside the opening from the nearest lid, as a share of that lid's travel
|
|
52
|
+
float y = uv.y - MEET;
|
|
53
|
+
float d = rim - max(y / (1.0 - MEET), -y / MEET);
|
|
54
|
+
// the lid fills beyond its rim, with a soft shadow falling inside the opening
|
|
55
|
+
float s = 1.0 - smoothstep(0.0, soft, d);
|
|
56
|
+
float lid = s * s;
|
|
57
|
+
if (lid >= 1.0) return color;
|
|
58
|
+
|
|
59
|
+
// how out of focus and dim the view is: it peaks at the cut, follows the lids, and clears at both ends
|
|
60
|
+
float f = progress < cut ? progress / cut : (1.0 - progress) / (1.0 - cut);
|
|
61
|
+
f = clamp(f, 0.0, 1.0);
|
|
62
|
+
f = max(f * (2.0 - f), closed) * blur;
|
|
63
|
+
|
|
64
|
+
vec4 c;
|
|
65
|
+
if (f <= 0.0) {
|
|
66
|
+
c = incoming ? getToColor(uv) : getFromColor(uv);
|
|
67
|
+
} else {
|
|
68
|
+
// a disc of taps along a golden-angle spiral, premultiplied
|
|
69
|
+
float r = 0.025 * f;
|
|
70
|
+
c = vec4(0.0);
|
|
71
|
+
for (int i = 0; i < TAPS; i++) {
|
|
72
|
+
float k = float(i) + 0.5;
|
|
73
|
+
float a = 2.39996 * k;
|
|
74
|
+
vec2 o = sqrt(k / float(TAPS)) * vec2(cos(a), sin(a)) * r;
|
|
75
|
+
c += image(mirror(uv + o * vec2(1.0 / ratio, 1.0)), incoming);
|
|
76
|
+
}
|
|
77
|
+
c /= float(TAPS);
|
|
78
|
+
c = c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
79
|
+
// less light reaches the eye as it closes
|
|
80
|
+
c.rgb *= 1.0 - 0.35 * f;
|
|
81
|
+
}
|
|
82
|
+
return mix(c, color, lid);
|
|
83
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Gallery — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Gallery.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The camera pulls back from the outgoing image to show it as a slide hanging in a row on a wall in perspective, the row glides along as each slide turns away from the center, and the camera moves back in on the incoming slide until it fills the frame
|
|
5
|
+
// Tags: 3d, perspective, gallery, slide, reflection, directional
|
|
6
|
+
|
|
7
|
+
// @param Way the row moves: 1 brings the incoming slide in from the right, -1 from the left
|
|
8
|
+
uniform float direction; // = 1.0
|
|
9
|
+
// @range(0, 1) How much the slides turn as they leave the center
|
|
10
|
+
uniform float tilt; // = 0.6
|
|
11
|
+
// @range(0, 1) Space between two slides, in slide widths
|
|
12
|
+
uniform float gap; // = 0.15
|
|
13
|
+
// @range(0.2, 3) How far the camera pulls back
|
|
14
|
+
uniform float zoom; // = 2.0
|
|
15
|
+
// @range(0, 1) Strength of the reflection of the slides on the floor
|
|
16
|
+
uniform float reflection; // = 0.3
|
|
17
|
+
// @color Color of the wall and the floor around the slides
|
|
18
|
+
uniform vec4 background; // = vec4(0.07, 0.07, 0.08, 1.0)
|
|
19
|
+
|
|
20
|
+
const float FOCAL = 1.6; // distance from the camera to a slide when it fills the frame
|
|
21
|
+
const float MAX_ANGLE = 1.4; // turn of a side slide at tilt = 1, in radians
|
|
22
|
+
const float NEIGHBOUR = 0.3; // how visible the repeats beyond the two images are
|
|
23
|
+
const float AA = 0.002; // width of the antialiased slide edges, in frame heights
|
|
24
|
+
|
|
25
|
+
vec4 premultiply(vec4 c) {
|
|
26
|
+
return vec4(c.rgb * c.a, c.a);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// how far slide k sits from the center of the view, in slides, clamped to one slide on each side
|
|
30
|
+
float offset(float k, float camQ, float spacing) {
|
|
31
|
+
return clamp((k * spacing - camQ) / spacing, -1.0, 1.0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// the ray o + t d against slide k of the row (a plane turned around its vertical axis):
|
|
35
|
+
// returns (u, v, t, coverage), coverage antialiased over aa frame heights at the slide's edges
|
|
36
|
+
vec4 slideHit(vec3 o, vec3 d, float k, float s, float camQ, float spacing, float aa) {
|
|
37
|
+
// a side slide turns away from the center: its outer edge goes back into the wall
|
|
38
|
+
float a = -s * MAX_ANGLE * tilt * offset(k, camQ, spacing);
|
|
39
|
+
vec3 c = vec3(s * k * spacing, 0.0, 0.0);
|
|
40
|
+
vec3 tg = vec3(cos(a), 0.0, sin(a)); // along the slide, left to right
|
|
41
|
+
vec3 n = vec3(-tg.z, 0.0, tg.x);
|
|
42
|
+
float dn = dot(d, n);
|
|
43
|
+
if (abs(dn) < 1e-5) return vec4(0.0, 0.0, -1.0, 0.0);
|
|
44
|
+
float t = dot(c - o, n) / dn;
|
|
45
|
+
vec3 q = o + d * t - c;
|
|
46
|
+
float lx = dot(q, tg) + 0.5 * ratio;
|
|
47
|
+
float ly = q.y + 0.5;
|
|
48
|
+
// distances to the edges on screen: along the slide, how fast its local x moves with the screen x
|
|
49
|
+
float jx = abs(t * (tg.x - dot(d, tg) * n.x / dn));
|
|
50
|
+
float ex = min(lx, ratio - lx) / max(jx, 1e-6);
|
|
51
|
+
float ey = min(ly, 1.0 - ly) / max(t, 1e-6);
|
|
52
|
+
float cov = t > 0.0 ? clamp(0.5 + min(ex, ey) / aa, 0.0, 1.0) : 0.0;
|
|
53
|
+
return vec4(lx / ratio, ly, t, cov);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// the premultiplied color of slide k where the ray hit it; the row is from (k = 0), to (k = 1),
|
|
57
|
+
// and faint repeats beyond them on their own side; refl > 0 is the strength of its reflection
|
|
58
|
+
vec4 slideColor(vec4 h, float k, float camQ, float spacing, float refl, vec4 bg) {
|
|
59
|
+
if (h.w <= 0.0) return vec4(0.0);
|
|
60
|
+
vec2 st = clamp(h.xy, 0.0, 1.0);
|
|
61
|
+
vec4 c = premultiply(k < 0.5 ? getFromColor(st) : getToColor(st));
|
|
62
|
+
// turned away from the light as it turns away from the center
|
|
63
|
+
c.rgb *= 1.0 - 0.3 * tilt * abs(offset(k, camQ, spacing));
|
|
64
|
+
if (k < -0.5 || k > 1.5) c = mix(bg, c, NEIGHBOUR);
|
|
65
|
+
// the reflection fades out below the bottom of the slide
|
|
66
|
+
float f = refl > 0.0 ? refl * (1.0 - smoothstep(0.0, 0.6, st.y)) : 1.0;
|
|
67
|
+
return c * (h.w * f);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// how much the slides cover along the ray, whatever their images' alpha
|
|
71
|
+
float sceneCover(vec3 o, vec3 d, float s, float camQ, float spacing, float aa) {
|
|
72
|
+
float kc = floor(s * (o.x + d.x * o.z / -d.z) / spacing + 0.5);
|
|
73
|
+
float w0 = slideHit(o, d, kc - 1.0, s, camQ, spacing, aa).w;
|
|
74
|
+
float w1 = slideHit(o, d, kc, s, camQ, spacing, aa).w;
|
|
75
|
+
float w2 = slideHit(o, d, kc + 1.0, s, camQ, spacing, aa).w;
|
|
76
|
+
return 1.0 - (1.0 - w0) * (1.0 - w1) * (1.0 - w2);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// the slides seen along the ray, composited back to front (premultiplied)
|
|
80
|
+
vec4 scene(vec3 o, vec3 d, float s, float camQ, float spacing, float aa, float refl, vec4 bg) {
|
|
81
|
+
// the slide in front of which the ray crosses the wall, and its two neighbours
|
|
82
|
+
float wallQ = s * (o.x + d.x * o.z / -d.z);
|
|
83
|
+
float kc = floor(wallQ / spacing + 0.5);
|
|
84
|
+
vec4 h0 = slideHit(o, d, kc - 1.0, s, camQ, spacing, aa);
|
|
85
|
+
vec4 h1 = slideHit(o, d, kc, s, camQ, spacing, aa);
|
|
86
|
+
vec4 h2 = slideHit(o, d, kc + 1.0, s, camQ, spacing, aa);
|
|
87
|
+
vec4 c0 = slideColor(h0, kc - 1.0, camQ, spacing, refl, bg);
|
|
88
|
+
vec4 c1 = slideColor(h1, kc, camQ, spacing, refl, bg);
|
|
89
|
+
vec4 c2 = slideColor(h2, kc + 1.0, camQ, spacing, refl, bg);
|
|
90
|
+
float t0 = h0.w > 0.0 ? h0.z : 1e6;
|
|
91
|
+
float t1 = h1.w > 0.0 ? h1.z : 1e6;
|
|
92
|
+
float t2 = h2.w > 0.0 ? h2.z : 1e6;
|
|
93
|
+
// sort far to near: t0 >= t1 >= t2
|
|
94
|
+
vec4 tc;
|
|
95
|
+
float tt;
|
|
96
|
+
if (t0 < t1) { tc = c0; c0 = c1; c1 = tc; tt = t0; t0 = t1; t1 = tt; }
|
|
97
|
+
if (t1 < t2) { tc = c1; c1 = c2; c2 = tc; tt = t1; t1 = t2; t2 = tt; }
|
|
98
|
+
if (t0 < t1) { tc = c0; c0 = c1; c1 = tc; }
|
|
99
|
+
vec4 col = c0;
|
|
100
|
+
col = c1 + col * (1.0 - c1.a);
|
|
101
|
+
col = c2 + col * (1.0 - c2.a);
|
|
102
|
+
return col;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
vec4 transition(vec2 uv) {
|
|
106
|
+
float p = progress;
|
|
107
|
+
float s = direction < 0.0 ? -1.0 : 1.0;
|
|
108
|
+
float spacing = ratio * (1.0 + gap);
|
|
109
|
+
// the camera pulls back, glides along the row, and moves back in
|
|
110
|
+
float back = smoothstep(0.0, 0.42, p) * (1.0 - smoothstep(0.58, 1.0, p));
|
|
111
|
+
float m = clamp((p - 0.18) / 0.64, 0.0, 1.0);
|
|
112
|
+
float glide = m * m * m * (m * (m * 6.0 - 15.0) + 10.0);
|
|
113
|
+
float camQ = spacing * glide;
|
|
114
|
+
vec3 o = vec3(s * camQ, 0.0, FOCAL * (1.0 + zoom * back));
|
|
115
|
+
vec3 d = vec3((uv - 0.5) * vec2(ratio, 1.0), -FOCAL);
|
|
116
|
+
float amount = min(1.0, 40.0 * back);
|
|
117
|
+
float aa = max(AA * amount, 1e-6);
|
|
118
|
+
vec4 bg = premultiply(background);
|
|
119
|
+
|
|
120
|
+
vec4 col = scene(o, d, s, camQ, spacing, aa, 0.0, bg);
|
|
121
|
+
if (col.a < 1.0) {
|
|
122
|
+
vec4 under = bg;
|
|
123
|
+
// the floor, below the slides, reflects them
|
|
124
|
+
if (d.y < 0.0 && reflection > 0.0) {
|
|
125
|
+
vec4 r = scene(vec3(o.x, -1.0 - o.y, o.z), vec3(d.x, -d.y, d.z), s, camQ, spacing, aa, reflection, bg);
|
|
126
|
+
under = r + bg * (1.0 - r.a);
|
|
127
|
+
}
|
|
128
|
+
// the wall shows around the slides, and only fades in behind their transparent parts,
|
|
129
|
+
// so that the images keep their own alpha at the start and the end
|
|
130
|
+
col += under * (mix(1.0, amount, sceneCover(o, d, s, camQ, spacing, aa)) * (1.0 - col.a));
|
|
131
|
+
}
|
|
132
|
+
return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
|
|
133
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// VhsTracking — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/VhsTracking.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// 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
|
|
5
|
+
// Tags: retro, glitch, noise, tape, scanlines
|
|
6
|
+
|
|
7
|
+
// @range(1, 4, 1) Number of noise bands rolling down (the first one carries the cut)
|
|
8
|
+
uniform int bands; // = 3
|
|
9
|
+
// @range(0, 1) Amount of snow and tearing in the bands
|
|
10
|
+
uniform float noise; // = 0.6
|
|
11
|
+
// @range(0, 1) How far the color smears to the right of the picture
|
|
12
|
+
uniform float bleed; // = 0.5
|
|
13
|
+
// @range(0, 1) How much the lines wobble sideways
|
|
14
|
+
uniform float wobble; // = 0.5
|
|
15
|
+
|
|
16
|
+
const float LINES = 220.0; // tape lines over the frame height
|
|
17
|
+
const float FRAMES = 40.0; // the noise changes this many times over the transition
|
|
18
|
+
const float BAND = 0.11; // half height of the main band
|
|
19
|
+
const float STRIP = 0.06; // height of the jittering strip at the bottom
|
|
20
|
+
const int TAPS = 6;
|
|
21
|
+
|
|
22
|
+
float hash12(vec2 v) {
|
|
23
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
24
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
25
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
vec2 mirror(vec2 v) {
|
|
29
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// the tape image on the outgoing (or, once re-recorded, incoming) side, premultiplied
|
|
33
|
+
vec4 tape(vec2 p, bool fresh) {
|
|
34
|
+
p = mirror(p);
|
|
35
|
+
vec4 c = fresh ? getToColor(p) : getFromColor(p);
|
|
36
|
+
return vec4(c.rgb * c.a, c.a);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
float luma(vec3 c) {
|
|
40
|
+
return dot(c, vec3(0.299, 0.587, 0.114));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// how dense a band centered at y = c of half height w is on line y, with ragged edges
|
|
44
|
+
float bandDensity(float y, float c, float w, float jitter) {
|
|
45
|
+
float d = abs(y - c) / w + 0.35 * jitter;
|
|
46
|
+
return 1.0 - smoothstep(0.0, 1.0, d);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
vec4 transition(vec2 uv) {
|
|
50
|
+
// the effects build up quickly and settle at the end: exactly 0 at both ends
|
|
51
|
+
float h = clamp(2.5 * (1.0 - abs(2.0 * progress - 1.0)), 0.0, 1.0);
|
|
52
|
+
float env = h * h * (3.0 - 2.0 * h);
|
|
53
|
+
// a short dropout flash when the main band crosses the middle of the frame
|
|
54
|
+
float f = clamp(1.0 - abs(progress - 0.5) / 0.04, 0.0, 1.0);
|
|
55
|
+
float flash = f * f * (3.0 - 2.0 * f);
|
|
56
|
+
|
|
57
|
+
float frame = floor(progress * FRAMES);
|
|
58
|
+
float line = floor(uv.y * LINES);
|
|
59
|
+
float jitter = hash12(vec2(line, frame + 7.0)) - 0.5;
|
|
60
|
+
|
|
61
|
+
// the main band rolls from above the frame to below it; the incoming image is above it
|
|
62
|
+
float c0 = mix(1.0 + 1.2 * BAND, -1.2 * BAND, progress);
|
|
63
|
+
// (the cut is ragged, line by line)
|
|
64
|
+
bool fresh = uv.y > c0 + 0.8 * BAND * jitter;
|
|
65
|
+
float dens = bandDensity(uv.y, c0, BAND, jitter);
|
|
66
|
+
float tear = 1.0 - smoothstep(0.0, 1.0, abs(uv.y - c0) / (2.5 * BAND));
|
|
67
|
+
// thinner and weaker bands roll faster, wrapping around the frame
|
|
68
|
+
for (int i = 1; i < 4; i++) {
|
|
69
|
+
if (i < bands) {
|
|
70
|
+
float k = float(i);
|
|
71
|
+
float w = BAND * (0.35 + 0.2 * hash12(vec2(k, 3.0)));
|
|
72
|
+
float speed = 1.3 + 0.9 * k;
|
|
73
|
+
float cy = -w + (1.0 + 2.0 * w) * fract(hash12(vec2(k, 5.0)) - speed * progress);
|
|
74
|
+
dens = max(dens, 0.6 * bandDensity(uv.y, cy, w, jitter));
|
|
75
|
+
tear = max(tear, 0.5 * (1.0 - smoothstep(0.0, 1.0, abs(uv.y - cy) / (2.5 * w))));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
dens *= env;
|
|
79
|
+
tear *= env;
|
|
80
|
+
|
|
81
|
+
// horizontal displacement of the line: a slow wobble, a fine jitter and the tearing
|
|
82
|
+
float rowTear = hash12(vec2(floor(uv.y * LINES * 0.5), frame + 31.0)) - 0.5;
|
|
83
|
+
float dx = wobble * env * (0.006 * sin(uv.y * 7.0 + progress * 23.0) + 0.004 * jitter);
|
|
84
|
+
dx += (0.3 + 0.7 * noise) * tear * 0.18 * rowTear;
|
|
85
|
+
// the head-switching strip at the bottom: lines skewed sideways and jittering
|
|
86
|
+
float strip = env * (1.0 - smoothstep(0.0, STRIP, uv.y));
|
|
87
|
+
dx += strip * (0.03 + 0.06 * (1.0 - uv.y / STRIP)) * (0.6 + 0.8 * hash12(vec2(frame, 41.0)));
|
|
88
|
+
vec2 q = vec2(uv.x + dx, uv.y);
|
|
89
|
+
|
|
90
|
+
vec4 c = tape(q, fresh);
|
|
91
|
+
if (c.a <= 0.0) return vec4(0.0);
|
|
92
|
+
// chroma bleed: the color is smeared to the right of the luma
|
|
93
|
+
float len = bleed * (0.02 + 0.05 * dens) * env;
|
|
94
|
+
vec4 avg = c;
|
|
95
|
+
if (len > 0.0) {
|
|
96
|
+
avg = vec4(0.0);
|
|
97
|
+
for (int i = 0; i < TAPS; i++) {
|
|
98
|
+
float u = (float(i) + 0.5) / float(TAPS);
|
|
99
|
+
avg += tape(q - vec2(len * (0.4 + u), 0.0), fresh);
|
|
100
|
+
}
|
|
101
|
+
avg /= float(TAPS);
|
|
102
|
+
}
|
|
103
|
+
vec3 chroma = (avg.rgb - luma(avg.rgb)) / max(avg.a, 1e-5);
|
|
104
|
+
vec3 rgb = luma(c.rgb) + chroma * c.a; // premultiplied by c.a
|
|
105
|
+
// the signal fades and loses color under the bands
|
|
106
|
+
rgb = mix(rgb, vec3(luma(rgb)), 0.6 * dens);
|
|
107
|
+
|
|
108
|
+
// snow: short white streaks on the tape lines, denser in the bands
|
|
109
|
+
// (the streaks of each line start at a random offset so they never line up vertically)
|
|
110
|
+
vec2 cell = vec2(floor(uv.x * LINES * 0.3 * ratio + 40.0 * jitter), line);
|
|
111
|
+
float n = hash12(cell + frame * vec2(37.0, 17.0));
|
|
112
|
+
float amount = clamp(noise * max(1.3 * dens, 0.8 * strip) + 0.35 * flash, 0.0, 1.0);
|
|
113
|
+
float snow = amount > 0.0 ? smoothstep(1.0 - amount, 1.0 - 0.6 * amount, n) : 0.0;
|
|
114
|
+
snow *= 0.55 + 0.45 * hash12(cell.yx + frame);
|
|
115
|
+
// and a finer sparkle between them
|
|
116
|
+
float g = hash12(vec2(floor(uv.x * LINES * ratio), line) + frame * vec2(13.0, 29.0));
|
|
117
|
+
snow = max(snow, amount > 0.0 ? 0.7 * smoothstep(1.0 - 0.4 * amount, 1.0, g) : 0.0);
|
|
118
|
+
// and a few dark specks
|
|
119
|
+
float dark = g < 0.1 * amount ? 1.0 : 0.0;
|
|
120
|
+
// the dropout: whole stretches of a few lines go white
|
|
121
|
+
float group = floor(uv.y * LINES / 3.0);
|
|
122
|
+
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)));
|
|
123
|
+
rgb *= 1.0 - 0.5 * dark;
|
|
124
|
+
rgb += (clamp(snow + drop + 0.12 * flash, 0.0, 1.0)) * (c.a - rgb);
|
|
125
|
+
|
|
126
|
+
return vec4(clamp(rgb / c.a, 0.0, 1.0), c.a);
|
|
127
|
+
}
|