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,85 @@
|
|
|
1
|
+
// ColorPanelWipe — 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
|
+
|
|
6
|
+
uniform shader _from;
|
|
7
|
+
uniform shader _to;
|
|
8
|
+
uniform float2 _resolution;
|
|
9
|
+
uniform float progress;
|
|
10
|
+
uniform float ratio;
|
|
11
|
+
|
|
12
|
+
vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
13
|
+
vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
14
|
+
|
|
15
|
+
uniform vec2 direction;
|
|
16
|
+
|
|
17
|
+
uniform int panels;
|
|
18
|
+
|
|
19
|
+
uniform vec4 color1;
|
|
20
|
+
|
|
21
|
+
uniform vec4 color2;
|
|
22
|
+
|
|
23
|
+
uniform vec4 color3;
|
|
24
|
+
|
|
25
|
+
uniform float stagger;
|
|
26
|
+
|
|
27
|
+
uniform float skew;
|
|
28
|
+
|
|
29
|
+
const float cut = 0.46;
|
|
30
|
+
const float hold = 0.01;
|
|
31
|
+
|
|
32
|
+
const float aa = 0.0015;
|
|
33
|
+
|
|
34
|
+
float ease(float t) {
|
|
35
|
+
float s = clamp(t, 0.0, 1.0);
|
|
36
|
+
float u = 1.0 - s * s * (3.0 - 2.0 * s);
|
|
37
|
+
return 1.0 - u * u * u;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
float cover(float x, float back, float front) {
|
|
41
|
+
return smoothstep(back - aa, back + aa, x) * (1.0 - smoothstep(front - aa, front + aa, x));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
vec4 transition(vec2 uv) {
|
|
45
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
46
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
47
|
+
float k = clamp(skew, -1.0, 1.0);
|
|
48
|
+
|
|
49
|
+
vec2 a = (dir + k * vec2(-dir.y, dir.x)) / sqrt(1.0 + k * k);
|
|
50
|
+
float x = dot(p, a);
|
|
51
|
+
|
|
52
|
+
float e = 0.5 * (abs(a.x) * ratio + abs(a.y));
|
|
53
|
+
float start = -e - 2.0 * aa;
|
|
54
|
+
float span = 2.0 * (e + 2.0 * aa);
|
|
55
|
+
|
|
56
|
+
int n = panels < 1 ? 1 : panels > 3 ? 3 : panels;
|
|
57
|
+
float m = float(n - 1);
|
|
58
|
+
float st = clamp(stagger, 0.0, 1.0);
|
|
59
|
+
|
|
60
|
+
vec2 d = vec2(cut - hold, 1.0 - cut - hold) / (1.0 + m * st);
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
float front0 = start + span * ease(progress / d.x);
|
|
65
|
+
float back0 = start + span * ease((progress - 1.0 + d.y) / d.y);
|
|
66
|
+
vec4 c = mix(getToColor(uv), getFromColor(uv), step(0.5 * (front0 + back0), x));
|
|
67
|
+
c = mix(c, color1, cover(x, back0, front0));
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
for (int i = 1; i < 3; i++) {
|
|
71
|
+
if (i < n) {
|
|
72
|
+
vec2 t = float(i) * st * d;
|
|
73
|
+
float front = start + span * ease((progress - t.x) / d.x);
|
|
74
|
+
float back = start + span * ease((progress - 1.0 + d.y + t.y) / d.y);
|
|
75
|
+
c = mix(c, i == 1 ? color2 : color3, cover(x, back, front));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return c.a > 0.0 ? c : vec4(0.0);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
half4 main(float2 _coord) {
|
|
82
|
+
vec2 _uv = _coord / _resolution;
|
|
83
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
84
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
85
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// EyeBlink — 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
|
+
|
|
6
|
+
uniform shader _from;
|
|
7
|
+
uniform shader _to;
|
|
8
|
+
uniform float2 _resolution;
|
|
9
|
+
uniform float progress;
|
|
10
|
+
uniform float ratio;
|
|
11
|
+
|
|
12
|
+
vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
13
|
+
vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
14
|
+
|
|
15
|
+
uniform float blur;
|
|
16
|
+
|
|
17
|
+
uniform float softness;
|
|
18
|
+
|
|
19
|
+
uniform int blinks;
|
|
20
|
+
|
|
21
|
+
uniform vec4 color;
|
|
22
|
+
|
|
23
|
+
const int TAPS = 16;
|
|
24
|
+
|
|
25
|
+
const float CURVE = 0.25;
|
|
26
|
+
|
|
27
|
+
const float MEET = 0.44;
|
|
28
|
+
|
|
29
|
+
vec2 mirror(vec2 v) {
|
|
30
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
float lidBlink(float t, float c, float wc, float wo, float hold) {
|
|
34
|
+
return 1.0 - smoothstep(hold, t < c ? wc : wo, abs(t - c));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
vec4 image(vec2 uv, bool incoming) {
|
|
38
|
+
vec4 c = incoming ? getToColor(uv) : getFromColor(uv);
|
|
39
|
+
return vec4(c.rgb * c.a, c.a);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
vec4 transition(vec2 uv) {
|
|
43
|
+
bool two = blinks > 1;
|
|
44
|
+
|
|
45
|
+
float cut = two ? 0.3 : 0.42;
|
|
46
|
+
|
|
47
|
+
float closed = two
|
|
48
|
+
? max(lidBlink(progress, cut, 0.26, 0.26, 0.015), lidBlink(progress, 0.7, 0.14, 0.24, 0.01))
|
|
49
|
+
: lidBlink(progress, cut, 0.36, 0.5, 0.02);
|
|
50
|
+
bool incoming = progress >= cut;
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
float soft = clamp(softness, 0.001, 0.3);
|
|
54
|
+
float x = 2.0 * uv.x - 1.0;
|
|
55
|
+
float rim = (1.0 - closed) * (1.31 + CURVE) - CURVE * x * x;
|
|
56
|
+
|
|
57
|
+
float y = uv.y - MEET;
|
|
58
|
+
float d = rim - max(y / (1.0 - MEET), -y / MEET);
|
|
59
|
+
|
|
60
|
+
float s = 1.0 - smoothstep(0.0, soft, d);
|
|
61
|
+
float lid = s * s;
|
|
62
|
+
if (lid >= 1.0) return color;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
float f = progress < cut ? progress / cut : (1.0 - progress) / (1.0 - cut);
|
|
66
|
+
f = clamp(f, 0.0, 1.0);
|
|
67
|
+
f = max(f * (2.0 - f), closed) * blur;
|
|
68
|
+
|
|
69
|
+
vec4 c;
|
|
70
|
+
if (f <= 0.0) {
|
|
71
|
+
c = incoming ? getToColor(uv) : getFromColor(uv);
|
|
72
|
+
} else {
|
|
73
|
+
|
|
74
|
+
float r = 0.025 * f;
|
|
75
|
+
c = vec4(0.0);
|
|
76
|
+
for (int i = 0; i < TAPS; i++) {
|
|
77
|
+
float k = float(i) + 0.5;
|
|
78
|
+
float a = 2.39996 * k;
|
|
79
|
+
vec2 o = sqrt(k / float(TAPS)) * vec2(cos(a), sin(a)) * r;
|
|
80
|
+
c += image(mirror(uv + o * vec2(1.0 / ratio, 1.0)), incoming);
|
|
81
|
+
}
|
|
82
|
+
c /= float(TAPS);
|
|
83
|
+
c = c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
84
|
+
|
|
85
|
+
c.rgb *= 1.0 - 0.35 * f;
|
|
86
|
+
}
|
|
87
|
+
return mix(c, color, lid);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
half4 main(float2 _coord) {
|
|
91
|
+
vec2 _uv = _coord / _resolution;
|
|
92
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
93
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
94
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Gallery — 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
|
+
|
|
6
|
+
uniform shader _from;
|
|
7
|
+
uniform shader _to;
|
|
8
|
+
uniform float2 _resolution;
|
|
9
|
+
uniform float progress;
|
|
10
|
+
uniform float ratio;
|
|
11
|
+
|
|
12
|
+
vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
13
|
+
vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
14
|
+
|
|
15
|
+
uniform float direction;
|
|
16
|
+
|
|
17
|
+
uniform float tilt;
|
|
18
|
+
|
|
19
|
+
uniform float gap;
|
|
20
|
+
|
|
21
|
+
uniform float zoom;
|
|
22
|
+
|
|
23
|
+
uniform float reflection;
|
|
24
|
+
|
|
25
|
+
uniform vec4 background;
|
|
26
|
+
|
|
27
|
+
const float FOCAL = 1.6;
|
|
28
|
+
const float MAX_ANGLE = 1.4;
|
|
29
|
+
const float NEIGHBOUR = 0.3;
|
|
30
|
+
const float AA = 0.002;
|
|
31
|
+
|
|
32
|
+
vec4 premultiply(vec4 c) {
|
|
33
|
+
return vec4(c.rgb * c.a, c.a);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
float offset(float k, float camQ, float spacing) {
|
|
37
|
+
return clamp((k * spacing - camQ) / spacing, -1.0, 1.0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
vec4 slideHit(vec3 o, vec3 d, float k, float s, float camQ, float spacing, float aa) {
|
|
41
|
+
|
|
42
|
+
float a = -s * MAX_ANGLE * tilt * offset(k, camQ, spacing);
|
|
43
|
+
vec3 c = vec3(s * k * spacing, 0.0, 0.0);
|
|
44
|
+
vec3 tg = vec3(cos(a), 0.0, sin(a));
|
|
45
|
+
vec3 n = vec3(-tg.z, 0.0, tg.x);
|
|
46
|
+
float dn = dot(d, n);
|
|
47
|
+
if (abs(dn) < 1e-5) return vec4(0.0, 0.0, -1.0, 0.0);
|
|
48
|
+
float t = dot(c - o, n) / dn;
|
|
49
|
+
vec3 q = o + d * t - c;
|
|
50
|
+
float lx = dot(q, tg) + 0.5 * ratio;
|
|
51
|
+
float ly = q.y + 0.5;
|
|
52
|
+
|
|
53
|
+
float jx = abs(t * (tg.x - dot(d, tg) * n.x / dn));
|
|
54
|
+
float ex = min(lx, ratio - lx) / max(jx, 1e-6);
|
|
55
|
+
float ey = min(ly, 1.0 - ly) / max(t, 1e-6);
|
|
56
|
+
float cov = t > 0.0 ? clamp(0.5 + min(ex, ey) / aa, 0.0, 1.0) : 0.0;
|
|
57
|
+
return vec4(lx / ratio, ly, t, cov);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
vec4 slideColor(vec4 h, float k, float camQ, float spacing, float refl, vec4 bg) {
|
|
61
|
+
if (h.w <= 0.0) return vec4(0.0);
|
|
62
|
+
vec2 st = clamp(h.xy, 0.0, 1.0);
|
|
63
|
+
vec4 c = premultiply(k < 0.5 ? getFromColor(st) : getToColor(st));
|
|
64
|
+
|
|
65
|
+
c.rgb *= 1.0 - 0.3 * tilt * abs(offset(k, camQ, spacing));
|
|
66
|
+
if (k < -0.5 || k > 1.5) c = mix(bg, c, NEIGHBOUR);
|
|
67
|
+
|
|
68
|
+
float f = refl > 0.0 ? refl * (1.0 - smoothstep(0.0, 0.6, st.y)) : 1.0;
|
|
69
|
+
return c * (h.w * f);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
float sceneCover(vec3 o, vec3 d, float s, float camQ, float spacing, float aa) {
|
|
73
|
+
float kc = floor(s * (o.x + d.x * o.z / -d.z) / spacing + 0.5);
|
|
74
|
+
float w0 = slideHit(o, d, kc - 1.0, s, camQ, spacing, aa).w;
|
|
75
|
+
float w1 = slideHit(o, d, kc, s, camQ, spacing, aa).w;
|
|
76
|
+
float w2 = slideHit(o, d, kc + 1.0, s, camQ, spacing, aa).w;
|
|
77
|
+
return 1.0 - (1.0 - w0) * (1.0 - w1) * (1.0 - w2);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
vec4 scene(vec3 o, vec3 d, float s, float camQ, float spacing, float aa, float refl, vec4 bg) {
|
|
81
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
129
|
+
|
|
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
|
+
}
|
|
134
|
+
|
|
135
|
+
half4 main(float2 _coord) {
|
|
136
|
+
vec2 _uv = _coord / _resolution;
|
|
137
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
138
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
139
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// VhsTracking — 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
|
+
|
|
6
|
+
uniform shader _from;
|
|
7
|
+
uniform shader _to;
|
|
8
|
+
uniform float2 _resolution;
|
|
9
|
+
uniform float progress;
|
|
10
|
+
uniform float ratio;
|
|
11
|
+
|
|
12
|
+
vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
13
|
+
vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
14
|
+
|
|
15
|
+
uniform int bands;
|
|
16
|
+
|
|
17
|
+
uniform float noise;
|
|
18
|
+
|
|
19
|
+
uniform float bleed;
|
|
20
|
+
|
|
21
|
+
uniform float wobble;
|
|
22
|
+
|
|
23
|
+
const float LINES = 220.0;
|
|
24
|
+
const float FRAMES = 40.0;
|
|
25
|
+
const float BAND = 0.11;
|
|
26
|
+
const float STRIP = 0.06;
|
|
27
|
+
const int TAPS = 6;
|
|
28
|
+
|
|
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
|
+
vec2 mirror(vec2 v) {
|
|
36
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
vec4 tape(vec2 p, bool fresh) {
|
|
40
|
+
p = mirror(p);
|
|
41
|
+
vec4 c = fresh ? getToColor(p) : getFromColor(p);
|
|
42
|
+
return vec4(c.rgb * c.a, c.a);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
float luma(vec3 c) {
|
|
46
|
+
return dot(c, vec3(0.299, 0.587, 0.114));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
float bandDensity(float y, float c, float w, float jitter) {
|
|
50
|
+
float d = abs(y - c) / w + 0.35 * jitter;
|
|
51
|
+
return 1.0 - smoothstep(0.0, 1.0, d);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
vec4 transition(vec2 uv) {
|
|
55
|
+
|
|
56
|
+
float h = clamp(2.5 * (1.0 - abs(2.0 * progress - 1.0)), 0.0, 1.0);
|
|
57
|
+
float env = h * h * (3.0 - 2.0 * h);
|
|
58
|
+
|
|
59
|
+
float f = clamp(1.0 - abs(progress - 0.5) / 0.04, 0.0, 1.0);
|
|
60
|
+
float flash = f * f * (3.0 - 2.0 * f);
|
|
61
|
+
|
|
62
|
+
float frame = floor(progress * FRAMES);
|
|
63
|
+
float line = floor(uv.y * LINES);
|
|
64
|
+
float jitter = hash12(vec2(line, frame + 7.0)) - 0.5;
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
float c0 = mix(1.0 + 1.2 * BAND, -1.2 * BAND, progress);
|
|
68
|
+
|
|
69
|
+
bool fresh = uv.y > c0 + 0.8 * BAND * jitter;
|
|
70
|
+
float dens = bandDensity(uv.y, c0, BAND, jitter);
|
|
71
|
+
float tear = 1.0 - smoothstep(0.0, 1.0, abs(uv.y - c0) / (2.5 * BAND));
|
|
72
|
+
|
|
73
|
+
for (int i = 1; i < 4; i++) {
|
|
74
|
+
if (i < bands) {
|
|
75
|
+
float k = float(i);
|
|
76
|
+
float w = BAND * (0.35 + 0.2 * hash12(vec2(k, 3.0)));
|
|
77
|
+
float speed = 1.3 + 0.9 * k;
|
|
78
|
+
float cy = -w + (1.0 + 2.0 * w) * fract(hash12(vec2(k, 5.0)) - speed * progress);
|
|
79
|
+
dens = max(dens, 0.6 * bandDensity(uv.y, cy, w, jitter));
|
|
80
|
+
tear = max(tear, 0.5 * (1.0 - smoothstep(0.0, 1.0, abs(uv.y - cy) / (2.5 * w))));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
dens *= env;
|
|
84
|
+
tear *= env;
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
float rowTear = hash12(vec2(floor(uv.y * LINES * 0.5), frame + 31.0)) - 0.5;
|
|
88
|
+
float dx = wobble * env * (0.006 * sin(uv.y * 7.0 + progress * 23.0) + 0.004 * jitter);
|
|
89
|
+
dx += (0.3 + 0.7 * noise) * tear * 0.18 * rowTear;
|
|
90
|
+
|
|
91
|
+
float strip = env * (1.0 - smoothstep(0.0, STRIP, uv.y));
|
|
92
|
+
dx += strip * (0.03 + 0.06 * (1.0 - uv.y / STRIP)) * (0.6 + 0.8 * hash12(vec2(frame, 41.0)));
|
|
93
|
+
vec2 q = vec2(uv.x + dx, uv.y);
|
|
94
|
+
|
|
95
|
+
vec4 c = tape(q, fresh);
|
|
96
|
+
if (c.a <= 0.0) return vec4(0.0);
|
|
97
|
+
|
|
98
|
+
float len = bleed * (0.02 + 0.05 * dens) * env;
|
|
99
|
+
vec4 avg = c;
|
|
100
|
+
if (len > 0.0) {
|
|
101
|
+
avg = vec4(0.0);
|
|
102
|
+
for (int i = 0; i < TAPS; i++) {
|
|
103
|
+
float u = (float(i) + 0.5) / float(TAPS);
|
|
104
|
+
avg += tape(q - vec2(len * (0.4 + u), 0.0), fresh);
|
|
105
|
+
}
|
|
106
|
+
avg /= float(TAPS);
|
|
107
|
+
}
|
|
108
|
+
vec3 chroma = (avg.rgb - luma(avg.rgb)) / max(avg.a, 1e-5);
|
|
109
|
+
vec3 rgb = luma(c.rgb) + chroma * c.a;
|
|
110
|
+
|
|
111
|
+
rgb = mix(rgb, vec3(luma(rgb)), 0.6 * dens);
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
vec2 cell = vec2(floor(uv.x * LINES * 0.3 * ratio + 40.0 * jitter), line);
|
|
116
|
+
float n = hash12(cell + frame * vec2(37.0, 17.0));
|
|
117
|
+
float amount = clamp(noise * max(1.3 * dens, 0.8 * strip) + 0.35 * flash, 0.0, 1.0);
|
|
118
|
+
float snow = amount > 0.0 ? smoothstep(1.0 - amount, 1.0 - 0.6 * amount, n) : 0.0;
|
|
119
|
+
snow *= 0.55 + 0.45 * hash12(cell.yx + frame);
|
|
120
|
+
|
|
121
|
+
float g = hash12(vec2(floor(uv.x * LINES * ratio), line) + frame * vec2(13.0, 29.0));
|
|
122
|
+
snow = max(snow, amount > 0.0 ? 0.7 * smoothstep(1.0 - 0.4 * amount, 1.0, g) : 0.0);
|
|
123
|
+
|
|
124
|
+
float dark = g < 0.1 * amount ? 1.0 : 0.0;
|
|
125
|
+
|
|
126
|
+
float group = floor(uv.y * LINES / 3.0);
|
|
127
|
+
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)));
|
|
128
|
+
rgb *= 1.0 - 0.5 * dark;
|
|
129
|
+
rgb += (clamp(snow + drop + 0.12 * flash, 0.0, 1.0)) * (c.a - rgb);
|
|
130
|
+
|
|
131
|
+
return vec4(clamp(rgb / c.a, 0.0, 1.0), c.a);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
half4 main(float2 _coord) {
|
|
135
|
+
vec2 _uv = _coord / _resolution;
|
|
136
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
137
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
138
|
+
}
|