gl-transitions 2.2.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 +64 -0
- package/compatibility.json +464 -0
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/Accordion.glsl +85 -0
- package/glsl3/Ascii.glsl +124 -0
- package/glsl3/BlockCover.glsl +87 -0
- package/glsl3/BloomDissolve.glsl +110 -0
- package/glsl3/BokehDissolve.glsl +123 -0
- package/glsl3/BrushWipe.glsl +100 -0
- package/glsl3/CameraShake.glsl +98 -0
- package/glsl3/CardSwipe.glsl +81 -0
- package/glsl3/ColorPanelWipe.glsl +75 -0
- package/glsl3/CurvedWipe.glsl +52 -0
- package/glsl3/Disintegrate.glsl +112 -0
- package/glsl3/EyeBlink.glsl +83 -0
- package/glsl3/FilmDissolve.glsl +49 -0
- package/glsl3/FilmStrip.glsl +105 -0
- package/glsl3/FlameWipe.glsl +154 -0
- package/glsl3/Gallery.glsl +133 -0
- package/glsl3/GooeyWipe.glsl +97 -0
- package/glsl3/InkBleed.glsl +96 -0
- package/glsl3/LensFlare.glsl +125 -0
- package/glsl3/LightRays.glsl +106 -0
- package/glsl3/LightWipe.glsl +89 -0
- package/glsl3/PhotoDevelop.glsl +59 -0
- package/glsl3/PlusWipe.glsl +38 -0
- package/glsl3/PopIn.glsl +57 -0
- package/glsl3/SmokeDissolve.glsl +102 -0
- package/glsl3/SplatterWipe.glsl +154 -0
- package/glsl3/StretchSlide.glsl +62 -0
- package/glsl3/VhsTracking.glsl +127 -0
- package/glsl3/WedgeWipe.glsl +35 -0
- package/index.js +1 -1
- package/layouts.json +1091 -17
- package/llms-full.txt +774 -304
- package/llms.txt +189 -160
- package/msl/Accordion.metal +421 -0
- package/msl/Ascii.metal +567 -0
- package/msl/BlockCover.metal +403 -0
- package/msl/BloomDissolve.metal +416 -0
- package/msl/BokehDissolve.metal +447 -0
- package/msl/BrushWipe.metal +488 -0
- package/msl/CameraShake.metal +393 -0
- package/msl/CardSwipe.metal +342 -0
- package/msl/ColorPanelWipe.metal +314 -0
- package/msl/CurvedWipe.metal +229 -0
- package/msl/Disintegrate.metal +468 -0
- package/msl/EyeBlink.metal +355 -0
- package/msl/FilmDissolve.metal +199 -0
- package/msl/FilmStrip.metal +429 -0
- package/msl/FlameWipe.metal +575 -0
- package/msl/Gallery.metal +813 -0
- package/msl/GooeyWipe.metal +398 -0
- package/msl/InkBleed.metal +409 -0
- package/msl/LensFlare.metal +455 -0
- package/msl/LightRays.metal +427 -0
- package/msl/LightWipe.metal +321 -0
- package/msl/PhotoDevelop.metal +245 -0
- package/msl/PlusWipe.metal +199 -0
- package/msl/PopIn.metal +245 -0
- package/msl/SmokeDissolve.metal +400 -0
- package/msl/SplatterWipe.metal +677 -0
- package/msl/StretchSlide.metal +243 -0
- package/msl/VhsTracking.metal +514 -0
- package/msl/WedgeWipe.metal +154 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +115 -39
- package/sksl/Accordion.sksl +94 -0
- package/sksl/Ascii.sksl +131 -0
- package/sksl/BlockCover.sksl +96 -0
- package/sksl/BloomDissolve.sksl +119 -0
- package/sksl/BokehDissolve.sksl +132 -0
- package/sksl/BrushWipe.sksl +109 -0
- package/sksl/CameraShake.sksl +108 -0
- package/sksl/CardSwipe.sksl +93 -0
- package/sksl/ColorPanelWipe.sksl +85 -0
- package/sksl/CurvedWipe.sksl +64 -0
- package/sksl/Disintegrate.sksl +117 -0
- package/sksl/EyeBlink.sksl +94 -0
- package/sksl/FilmDissolve.sksl +60 -0
- package/sksl/FilmStrip.sksl +114 -0
- package/sksl/FlameWipe.sksl +162 -0
- package/sksl/Gallery.sksl +139 -0
- package/sksl/GooeyWipe.sksl +109 -0
- package/sksl/InkBleed.sksl +109 -0
- package/sksl/LensFlare.sksl +135 -0
- package/sksl/LightRays.sksl +115 -0
- package/sksl/LightWipe.sksl +97 -0
- package/sksl/PhotoDevelop.sksl +72 -0
- package/sksl/PlusWipe.sksl +50 -0
- package/sksl/PopIn.sksl +69 -0
- package/sksl/SmokeDissolve.sksl +115 -0
- package/sksl/SplatterWipe.sksl +161 -0
- package/sksl/StretchSlide.sksl +74 -0
- package/sksl/VhsTracking.sksl +138 -0
- package/sksl/WedgeWipe.sksl +46 -0
- package/sksl/index.js +1 -1
- package/transitions/Accordion.glsl +84 -0
- package/transitions/Ascii.glsl +123 -0
- package/transitions/BlockCover.glsl +86 -0
- package/transitions/BloomDissolve.glsl +109 -0
- package/transitions/BokehDissolve.glsl +122 -0
- package/transitions/BrushWipe.glsl +99 -0
- package/transitions/CameraShake.glsl +97 -0
- package/transitions/CardSwipe.glsl +80 -0
- package/transitions/ColorPanelWipe.glsl +74 -0
- package/transitions/CurvedWipe.glsl +51 -0
- package/transitions/Disintegrate.glsl +111 -0
- package/transitions/EyeBlink.glsl +82 -0
- package/transitions/FilmDissolve.glsl +48 -0
- package/transitions/FilmStrip.glsl +104 -0
- package/transitions/FlameWipe.glsl +153 -0
- package/transitions/Gallery.glsl +132 -0
- package/transitions/GooeyWipe.glsl +96 -0
- package/transitions/InkBleed.glsl +95 -0
- package/transitions/LensFlare.glsl +124 -0
- package/transitions/LightRays.glsl +105 -0
- package/transitions/LightWipe.glsl +88 -0
- package/transitions/PhotoDevelop.glsl +58 -0
- package/transitions/PlusWipe.glsl +37 -0
- package/transitions/PopIn.glsl +56 -0
- package/transitions/SmokeDissolve.glsl +101 -0
- package/transitions/SplatterWipe.glsl +153 -0
- package/transitions/StretchSlide.glsl +61 -0
- package/transitions/VhsTracking.glsl +126 -0
- package/transitions/WedgeWipe.glsl +34 -0
- package/wgsl/Accordion.wgsl +376 -0
- package/wgsl/Ascii.wgsl +519 -0
- package/wgsl/BlockCover.wgsl +352 -0
- package/wgsl/BloomDissolve.wgsl +372 -0
- package/wgsl/BokehDissolve.wgsl +409 -0
- package/wgsl/BrushWipe.wgsl +443 -0
- package/wgsl/CameraShake.wgsl +348 -0
- package/wgsl/CardSwipe.wgsl +308 -0
- package/wgsl/ColorPanelWipe.wgsl +274 -0
- package/wgsl/CurvedWipe.wgsl +198 -0
- package/wgsl/Disintegrate.wgsl +426 -0
- package/wgsl/EyeBlink.wgsl +308 -0
- package/wgsl/FilmDissolve.wgsl +169 -0
- package/wgsl/FilmStrip.wgsl +381 -0
- package/wgsl/FlameWipe.wgsl +531 -0
- package/wgsl/Gallery.wgsl +741 -0
- package/wgsl/GooeyWipe.wgsl +353 -0
- package/wgsl/InkBleed.wgsl +366 -0
- package/wgsl/LensFlare.wgsl +406 -0
- package/wgsl/LightRays.wgsl +380 -0
- package/wgsl/LightWipe.wgsl +277 -0
- package/wgsl/PhotoDevelop.wgsl +213 -0
- package/wgsl/PlusWipe.wgsl +165 -0
- package/wgsl/PopIn.wgsl +213 -0
- package/wgsl/SmokeDissolve.wgsl +363 -0
- package/wgsl/SplatterWipe.wgsl +613 -0
- package/wgsl/StretchSlide.wgsl +213 -0
- package/wgsl/VhsTracking.wgsl +462 -0
- package/wgsl/WedgeWipe.wgsl +126 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// CameraShake — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CameraShake.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The camera jolts violently in random directions, with motion blur and color fringes along each jolt; the cut happens at the peak of the shake, which then settles on the incoming image
|
|
5
|
+
// Tags: shake, camera, motion-blur, chromatic, impact
|
|
6
|
+
|
|
7
|
+
// @range(0, 1) How far the camera jolts (and rolls) at the peak of the shake
|
|
8
|
+
uniform float strength; // = 0.5
|
|
9
|
+
// @range(4, 32) Number of jolts over the transition
|
|
10
|
+
uniform float jolts; // = 12.0
|
|
11
|
+
// @range(0, 1) Length of the motion blur along each jolt
|
|
12
|
+
uniform float blur; // = 0.5
|
|
13
|
+
// @range(0, 1) How far the color channels split apart along each jolt
|
|
14
|
+
uniform float split; // = 0.5
|
|
15
|
+
|
|
16
|
+
const int TAPS = 10;
|
|
17
|
+
|
|
18
|
+
float hash12(vec2 v) {
|
|
19
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
20
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
21
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
vec2 mirror(vec2 v) {
|
|
25
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// the camera position at jolt key k: offset (x, y) and roll, each in -1..1
|
|
29
|
+
vec3 jolt(float k) {
|
|
30
|
+
// successive jolts go in nearly opposite directions
|
|
31
|
+
float a = 2.4 * k + 1.2 * hash12(vec2(k, 11.0));
|
|
32
|
+
float m = 0.55 + 0.45 * hash12(vec2(k, 23.0));
|
|
33
|
+
return vec3(m * cos(a), m * sin(a), 2.0 * hash12(vec2(k, 37.0)) - 1.0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// how strong the shake is at time t: it builds up quickly, peaks around the cut, then settles
|
|
37
|
+
float envelope(float t) {
|
|
38
|
+
float h = clamp(1.6 * (1.0 - abs(2.0 * t - 1.0)), 0.0, 1.0);
|
|
39
|
+
return h * h * (3.0 - 2.0 * h);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// the image seen by the camera at time t (in progress units), premultiplied
|
|
43
|
+
vec4 shot(vec2 uv, float t, bool incoming) {
|
|
44
|
+
float env = envelope(t);
|
|
45
|
+
// a key every 1/jolts, one of them exactly at the cut
|
|
46
|
+
float s = (t - 0.5) * jolts;
|
|
47
|
+
float k = floor(s);
|
|
48
|
+
float g = 1.0 - (s - k);
|
|
49
|
+
float e = 1.0 - g * g * g; // snaps to the next key, then holds
|
|
50
|
+
vec3 j = mix(jolt(k), jolt(k + 1.0), e) * env;
|
|
51
|
+
float omax = 0.14 * strength * env;
|
|
52
|
+
float rmax = 0.07 * strength * env;
|
|
53
|
+
vec2 off = j.xy * omax;
|
|
54
|
+
float roll = j.z * rmax;
|
|
55
|
+
// zoom in just enough that the frame edges never show, for any offset and roll up to these
|
|
56
|
+
float zoom = (cos(rmax) + sin(rmax) * max(ratio, 1.0 / ratio)) / (1.0 - 2.0 * omax);
|
|
57
|
+
vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
|
|
58
|
+
q = mat2(cos(roll), sin(roll), -sin(roll), cos(roll)) * q / zoom;
|
|
59
|
+
vec2 p = mirror(q / vec2(ratio, 1.0) + 0.5 + off);
|
|
60
|
+
vec4 c = incoming ? getToColor(p) : getFromColor(p);
|
|
61
|
+
return vec4(c.rgb * c.a, c.a);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
vec4 transition(vec2 uv) {
|
|
65
|
+
// the exposure follows the shake: no blur at the very ends
|
|
66
|
+
float open = envelope(progress);
|
|
67
|
+
float shutter = 0.8 * blur / jolts * open;
|
|
68
|
+
float lag = 0.2 * split / jolts * open;
|
|
69
|
+
// each channel, premultiplied, and its alpha
|
|
70
|
+
vec2 sumR = vec2(0.0);
|
|
71
|
+
vec2 sumG = vec2(0.0);
|
|
72
|
+
vec2 sumB = vec2(0.0);
|
|
73
|
+
float wsum = 0.0;
|
|
74
|
+
for (int i = 0; i < TAPS; i++) {
|
|
75
|
+
float u = (float(i) + 0.5) / float(TAPS) - 0.5;
|
|
76
|
+
float t = progress + u * shutter;
|
|
77
|
+
// the trails fade out at both ends of the exposure
|
|
78
|
+
float w = 1.0 - 1.4 * abs(u);
|
|
79
|
+
// the cut happens during the exposure: the channels of a tap show the same image
|
|
80
|
+
bool incoming = t >= 0.5;
|
|
81
|
+
// red leads and blue trails the motion, so they split by the speed of the jolt
|
|
82
|
+
vec4 r = shot(uv, t + lag, incoming);
|
|
83
|
+
vec4 c = shot(uv, t, incoming);
|
|
84
|
+
vec4 b = shot(uv, t - lag, incoming);
|
|
85
|
+
sumR += w * r.ra;
|
|
86
|
+
sumG += w * c.ga;
|
|
87
|
+
sumB += w * b.ba;
|
|
88
|
+
wsum += w;
|
|
89
|
+
}
|
|
90
|
+
float alpha = (sumR.y + sumG.y + sumB.y) / (3.0 * wsum);
|
|
91
|
+
if (alpha <= 0.0) return vec4(0.0);
|
|
92
|
+
vec3 color = vec3(
|
|
93
|
+
sumR.x / max(sumR.y, 1e-5),
|
|
94
|
+
sumG.x / max(sumG.y, 1e-5),
|
|
95
|
+
sumB.x / max(sumB.y, 1e-5)
|
|
96
|
+
);
|
|
97
|
+
return vec4(color, alpha);
|
|
98
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// CardSwipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CardSwipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image is flicked off like the top card of a stack, swinging around a point below it as it flies out, while the incoming card behind it grows to fill the frame
|
|
5
|
+
// Tags: card, swipe, stack, rotate, slide, directional
|
|
6
|
+
|
|
7
|
+
// @param Direction in which the outgoing card is flicked
|
|
8
|
+
uniform vec2 direction; // = vec2(1.0, 0.25)
|
|
9
|
+
// @range(0, 1) How much the outgoing card swings as it flies out
|
|
10
|
+
uniform float rotation; // = 0.5
|
|
11
|
+
// @range(0, 0.5) How much smaller the incoming card starts
|
|
12
|
+
uniform float depth; // = 0.15
|
|
13
|
+
// @color Color seen around the incoming card while it is smaller than the frame
|
|
14
|
+
uniform vec4 backColor; // = vec4(0.06, 0.06, 0.07, 1.0)
|
|
15
|
+
|
|
16
|
+
const float RADIUS = 0.045; // corner radius of the cards, in frame heights
|
|
17
|
+
const float AA = 0.002; // width of the antialiased card edges
|
|
18
|
+
|
|
19
|
+
// signed distance to a rounded box of half size b and corner radius r
|
|
20
|
+
float roundedBox(vec2 q, vec2 b, float r) {
|
|
21
|
+
vec2 d = abs(q) - b + r;
|
|
22
|
+
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
vec4 premultiply(vec4 c) {
|
|
26
|
+
return vec4(c.rgb * c.a, c.a);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
vec4 transition(vec2 uv) {
|
|
30
|
+
float dl = length(direction);
|
|
31
|
+
vec2 d = dl > 1e-6 ? direction / dl : vec2(0.970143, 0.242536);
|
|
32
|
+
vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
|
|
33
|
+
vec2 b = vec2(0.5 * ratio, 0.5);
|
|
34
|
+
float p = progress;
|
|
35
|
+
|
|
36
|
+
// the incoming card, behind: grows from a smaller card to the full frame,
|
|
37
|
+
// and its corners straighten as it fills it
|
|
38
|
+
float h = clamp((p - 0.2) / 0.8, 0.0, 1.0);
|
|
39
|
+
float g = h * h * (3.0 - 2.0 * h);
|
|
40
|
+
float k = 1.0 - g;
|
|
41
|
+
float sc = 1.0 - depth * k;
|
|
42
|
+
float rb = RADIUS * min(1.0, 12.0 * k);
|
|
43
|
+
float db = roundedBox(q, b * sc, rb);
|
|
44
|
+
float cb = clamp(0.5 - db / max(AA * min(1.0, 40.0 * k), 1e-6), 0.0, 1.0);
|
|
45
|
+
vec4 tc = getToColor(clamp(0.5 + (uv - 0.5) / sc, 0.0, 1.0));
|
|
46
|
+
// still in the shade of the top card at first
|
|
47
|
+
tc.rgb *= 1.0 - 0.35 * k * k;
|
|
48
|
+
// the cards are opaque: each one replaces what is behind it, keeping its image's alpha
|
|
49
|
+
vec4 col = mix(premultiply(backColor), premultiply(tc), cb);
|
|
50
|
+
|
|
51
|
+
// the outgoing card, on top: swings around a point below it as it is flicked away
|
|
52
|
+
float t = clamp(p / 0.75, 0.0, 1.0);
|
|
53
|
+
float lift = smoothstep(0.0, 0.15, p);
|
|
54
|
+
float u = min(t / 0.7, 1.0);
|
|
55
|
+
float swing = u * u * (3.0 - 2.0 * u);
|
|
56
|
+
// it tilts toward the side it is flicked to
|
|
57
|
+
float a = (d.x < 0.0 ? 1.3 : -1.3) * rotation * swing;
|
|
58
|
+
vec2 pivot = vec2(0.0, -1.1);
|
|
59
|
+
// where the swing alone takes the center of the card, to throw it far enough
|
|
60
|
+
float ca = cos(a), sa = sin(a);
|
|
61
|
+
vec2 swung = pivot + mat2(ca, sa, -sa, ca) * -pivot;
|
|
62
|
+
float far = 2.0 * length(b) + length(swung) + 0.3;
|
|
63
|
+
vec2 shift = d * far * t * t * (0.4 + 0.6 * t);
|
|
64
|
+
mat2 unrotate = mat2(ca, -sa, sa, ca);
|
|
65
|
+
vec2 r = unrotate * (q - shift - pivot) + pivot;
|
|
66
|
+
float rf = RADIUS * lift;
|
|
67
|
+
|
|
68
|
+
// its soft shadow on the card behind, cast down and away as it lifts
|
|
69
|
+
float sh = 0.6 * lift * (1.0 - t);
|
|
70
|
+
if (sh > 0.0) {
|
|
71
|
+
vec2 rs = unrotate * (q - (0.03 * d + vec2(0.0, -0.03)) * lift - shift - pivot) + pivot;
|
|
72
|
+
float ds = roundedBox(rs, b, rf);
|
|
73
|
+
col.rgb *= 1.0 - sh * (1.0 - smoothstep(-0.05, 0.08, ds));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
float df = roundedBox(r, b, rf);
|
|
77
|
+
float cf = clamp(0.5 - df / max(AA * min(1.0, 40.0 * lift), 1e-6), 0.0, 1.0);
|
|
78
|
+
vec4 fc = getFromColor(clamp(r / vec2(ratio, 1.0) + 0.5, 0.0, 1.0));
|
|
79
|
+
col = mix(col, premultiply(fc), cf);
|
|
80
|
+
return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
|
|
81
|
+
}
|
|
@@ -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,52 @@
|
|
|
1
|
+
// CurvedWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CurvedWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image is pulled away by its middle: the wipe edge bulges into a smooth curve that leads the way, then flattens as it reaches the far side
|
|
5
|
+
// Tags: wipe, curve, directional, shadow
|
|
6
|
+
|
|
7
|
+
// @param Direction the edge moves toward
|
|
8
|
+
uniform vec2 direction; // = vec2(0.0, 1.0)
|
|
9
|
+
// @range(0, 1) How far the middle of the edge leads its sides
|
|
10
|
+
uniform float curvature; // = 0.6
|
|
11
|
+
// @range(0, 0.2) Softness of the edge
|
|
12
|
+
uniform float smoothness; // = 0.02
|
|
13
|
+
// @color Color of the soft shadow the lifted edge casts on the incoming image (its alpha is its strength; 0 for none)
|
|
14
|
+
uniform vec4 shadow; // = vec4(0.0, 0.0, 0.0, 0.4)
|
|
15
|
+
|
|
16
|
+
const float PI = 3.141592653589793;
|
|
17
|
+
|
|
18
|
+
// a gentle ease in and out, which does not linger at the ends
|
|
19
|
+
float ease (float t) {
|
|
20
|
+
return 0.5 * (t + t * t * (3.0 - 2.0 * t));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
vec4 transition (vec2 uv) {
|
|
24
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(0.0, 1.0);
|
|
25
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
26
|
+
// half extents of the frame along the direction and across it
|
|
27
|
+
float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
|
|
28
|
+
float w = 0.5 * (abs(dir.y) * ratio + abs(dir.x));
|
|
29
|
+
vec2 across = vec2(-dir.y, dir.x);
|
|
30
|
+
float d = dot(p, dir);
|
|
31
|
+
// where the pixel is across the frame, from -1 to 1 (on a diagonal, these are the corners); it is the same
|
|
32
|
+
// all along the direction, so the edge is a single curve, centered on the middle of the frame
|
|
33
|
+
float x = clamp(dot(p, across) / w, -1.0, 1.0);
|
|
34
|
+
float s = max(smoothness, 0.001);
|
|
35
|
+
// each point of the edge runs on its own clock: the middle runs ahead and slows down at the far side,
|
|
36
|
+
// where the sides catch up with it; the lead keeps the curve's shape alike on wide and narrow frames
|
|
37
|
+
float k = clamp(curvature, 0.0, 1.0) * min(1.0, w / e) * (1.0 - x * x);
|
|
38
|
+
float t = progress + k * progress * (1.0 - progress);
|
|
39
|
+
float travel = 2.0 * (e + s);
|
|
40
|
+
float edge = -e - s + travel * ease(t);
|
|
41
|
+
float side = -e - s + travel * ease(progress);
|
|
42
|
+
float m = 1.0 - smoothstep(-s, s, d - edge);
|
|
43
|
+
// the more the edge is lifted, the wider and softer the shadow it casts on the incoming image
|
|
44
|
+
float lift = edge - side;
|
|
45
|
+
float spread = 0.012 + 0.25 * lift;
|
|
46
|
+
// it falls behind the edge only, on the incoming image, cast by the outgoing image at the edge
|
|
47
|
+
vec4 to = getToColor(uv);
|
|
48
|
+
vec2 caster = clamp((p + (edge - d) * dir) / vec2(ratio, 1.0) + 0.5, 0.0, 1.0);
|
|
49
|
+
float sh = shadow.a * sin(PI * progress) * exp(-max(edge - d, 0.0) / spread) * m * getFromColor(caster).a * to.a;
|
|
50
|
+
to.rgb = mix(to.rgb, shadow.rgb, sh);
|
|
51
|
+
return mix(getFromColor(uv), to, m);
|
|
52
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Disintegrate — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Disintegrate.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image crumbles into fine dust from one side, its grains blown away by the wind and fading out, revealing the incoming image underneath
|
|
5
|
+
// Tags: particles, dust, wind, directional
|
|
6
|
+
|
|
7
|
+
// @range(0.0075, 0.03) Size of the dust grains, in frame heights
|
|
8
|
+
uniform float particleSize; // = 0.008
|
|
9
|
+
// @param Direction in which the wind blows the dust
|
|
10
|
+
uniform vec2 direction; // = vec2(1.0, -0.15)
|
|
11
|
+
// @range(0, 1) How far the dust flies and scatters before it fades out
|
|
12
|
+
uniform float spread; // = 0.75
|
|
13
|
+
|
|
14
|
+
// the grains a pixel looks back to, along the wind: every grain up to 16 cells away,
|
|
15
|
+
// one in 2 up to 32 cells, one in 4 up to 64 cells (only those stay visible that far,
|
|
16
|
+
// so the dust thins out as it flies): 35 candidates, without unrolling a long loop
|
|
17
|
+
const int NEAR = 17;
|
|
18
|
+
const int CANDIDATES = 35;
|
|
19
|
+
// part of the transition during which a grain flies, from its release to its fade-out
|
|
20
|
+
const float LIFE = 0.45;
|
|
21
|
+
|
|
22
|
+
float hash12(vec2 p) {
|
|
23
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
24
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
25
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// smooth value noise, between -1 and 1
|
|
29
|
+
float noise(vec2 p) {
|
|
30
|
+
vec2 i = floor(p);
|
|
31
|
+
vec2 f = fract(p);
|
|
32
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
33
|
+
float a = hash12(i);
|
|
34
|
+
float b = hash12(i + vec2(1.0, 0.0));
|
|
35
|
+
float c = hash12(i + vec2(0.0, 1.0));
|
|
36
|
+
float d = hash12(i + vec2(1.0, 1.0));
|
|
37
|
+
return 2.0 * mix(mix(a, b, f.x), mix(c, d, f.x), f.y) - 1.0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// the grains' sideways drift, in gusts along the wind, between -1 and 1: it depends only
|
|
41
|
+
// on where a grain comes from along the wind, so that a pixel knows which row to look in
|
|
42
|
+
float gust(float x) {
|
|
43
|
+
float i = floor(x);
|
|
44
|
+
float f = fract(x);
|
|
45
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
46
|
+
return 2.0 * mix(hash12(vec2(i, 7.0)), hash12(vec2(i + 1.0, 7.0)), f) - 1.0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// when the grain at this center (in cells) is released, from the downwind side first,
|
|
50
|
+
// along a ragged front
|
|
51
|
+
float release(vec2 center, float h, float halfLength, float s) {
|
|
52
|
+
float front = 1.0 - (center.x + halfLength) / (2.0 * halfLength) + 0.14 * noise(center * s * 6.0) + 0.08 * (h - 0.5);
|
|
53
|
+
return clamp((front + 0.12) / 1.24, 0.0, 1.0) * (1.0 - LIFE);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
vec4 transition(vec2 uv) {
|
|
57
|
+
vec2 d = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
58
|
+
vec2 n = vec2(-d.y, d.x);
|
|
59
|
+
// grid of grains aligned with the wind: x along it, y across it, in cells
|
|
60
|
+
vec2 fp = (uv - 0.5) * vec2(ratio, 1.0);
|
|
61
|
+
float s = particleSize;
|
|
62
|
+
vec2 g = vec2(dot(fp, d), dot(fp, n)) / s;
|
|
63
|
+
float halfLength = 0.5 * (ratio * abs(d.x) + abs(d.y)) / s;
|
|
64
|
+
// the longest flight, in cells (at most 60, within the 64 cells looked back to)
|
|
65
|
+
float reach = min(spread * 0.45 / s, 60.0);
|
|
66
|
+
float px = floor(g.x);
|
|
67
|
+
|
|
68
|
+
// this pixel's own grain: once it has left, the incoming image shows through
|
|
69
|
+
vec2 own = floor(g);
|
|
70
|
+
vec4 under = progress > release(own + 0.5, hash12(own), halfLength, s) ? getToColor(uv) : getFromColor(uv);
|
|
71
|
+
vec2 grainUV = vec2(0.5);
|
|
72
|
+
float cover = 0.0;
|
|
73
|
+
for (int i = 0; i < CANDIDATES; i++) {
|
|
74
|
+
// the column of the candidate grain
|
|
75
|
+
float fi = float(i);
|
|
76
|
+
float cx = px - fi;
|
|
77
|
+
if (i >= NEAR + 9) {
|
|
78
|
+
cx = floor(px / 4.0) * 4.0 - 4.0 * (fi - float(NEAR + 9) + 8.0);
|
|
79
|
+
} else if (i >= NEAR) {
|
|
80
|
+
cx = floor(px / 2.0) * 2.0 - 2.0 * (fi - float(NEAR) + 8.0);
|
|
81
|
+
}
|
|
82
|
+
// how far the grain stays visible (in cells): further when its column is a multiple
|
|
83
|
+
// of 2, and of 4, as far as the pixels look back to
|
|
84
|
+
float visible = mod(cx, 4.0) < 0.5 ? 63.0 : mod(cx, 2.0) < 0.5 ? 31.0 : 15.0;
|
|
85
|
+
float drift = 0.3 * gust(cx * s * 4.0);
|
|
86
|
+
// the row the grain comes from: its sideways drift is known from its column and how
|
|
87
|
+
// far it has flown to get here
|
|
88
|
+
vec2 cell = vec2(cx, floor(g.y - drift * (g.x - cx - 0.5)));
|
|
89
|
+
vec2 center = cell + 0.5;
|
|
90
|
+
vec2 cuv = (center.x * d + center.y * n) * s / vec2(ratio, 1.0) + 0.5;
|
|
91
|
+
if (cuv.x < 0.0 || cuv.x > 1.0 || cuv.y < 0.0 || cuv.y > 1.0) continue;
|
|
92
|
+
float h = hash12(cell);
|
|
93
|
+
float t = (progress - release(center, h, halfLength, s)) / LIFE;
|
|
94
|
+
if (t <= 0.0 || t >= 1.0) continue;
|
|
95
|
+
float r2 = fract(h * 13.7);
|
|
96
|
+
// the grain speeds up, drifts sideways, shrinks and fades out
|
|
97
|
+
float travel = reach * (0.4 + 0.6 * r2) * t * (0.2 + 0.8 * t);
|
|
98
|
+
// it first fills its cell, then crumbles to a smaller speck
|
|
99
|
+
float crumble = smoothstep(0.0, 0.25, t);
|
|
100
|
+
vec2 pos = center + vec2(travel + (fract(h * 71.1) - 0.5) * 0.3 * crumble, drift * travel);
|
|
101
|
+
vec2 local = abs(g - pos);
|
|
102
|
+
float size = mix(0.5, 0.3 * (1.0 - 0.5 * t) * (0.6 + 0.4 * h), crumble);
|
|
103
|
+
float feather = 0.001 + 0.12 * crumble;
|
|
104
|
+
float a = (1.0 - smoothstep(size - feather, size, max(local.x, local.y))) * (1.0 - smoothstep(0.15, 1.0, t))
|
|
105
|
+
* (1.0 - smoothstep(0.6 * visible, visible, travel));
|
|
106
|
+
if (a > cover) {
|
|
107
|
+
cover = a;
|
|
108
|
+
grainUV = cuv;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return mix(under, getFromColor(grainUV), cover);
|
|
112
|
+
}
|
|
@@ -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,49 @@
|
|
|
1
|
+
// FilmDissolve — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/FilmDissolve.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: A cross-dissolve blended in linear light, as light adds up on film: the frame keeps its brightness all the way through and the highlights of each image shine through the other
|
|
5
|
+
// Tags: dissolve, fade, blend, light
|
|
6
|
+
|
|
7
|
+
// @range(0, 1) Extra light where the two images overlap at mid-dissolve, softly rolled off so it never clips
|
|
8
|
+
uniform float overlap; // = 0.25
|
|
9
|
+
// @range(0, 1) Easing of the dissolve: 0 is linear, 1 eases in and out
|
|
10
|
+
uniform float smoothness; // = 0.5
|
|
11
|
+
|
|
12
|
+
// sRGB to linear light (the exact piecewise curve)
|
|
13
|
+
vec3 toLinear(vec3 c) {
|
|
14
|
+
vec3 lo = c / 12.92;
|
|
15
|
+
vec3 hi = pow((c + 0.055) / 1.055, vec3(2.4));
|
|
16
|
+
return mix(lo, hi, vec3(greaterThan(c, vec3(0.04045))));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// linear light back to sRGB
|
|
20
|
+
vec3 toSrgb(vec3 c) {
|
|
21
|
+
vec3 lo = c * 12.92;
|
|
22
|
+
vec3 hi = 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055;
|
|
23
|
+
return mix(lo, hi, vec3(greaterThan(c, vec3(0.0031308))));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
vec4 transition(vec2 uv) {
|
|
27
|
+
vec4 a = getFromColor(uv);
|
|
28
|
+
vec4 b = getToColor(uv);
|
|
29
|
+
if (progress <= 0.0) return a;
|
|
30
|
+
if (progress >= 1.0) return b;
|
|
31
|
+
|
|
32
|
+
float t = mix(progress, smoothstep(0.0, 1.0, progress), smoothness);
|
|
33
|
+
|
|
34
|
+
// premultiplied linear light
|
|
35
|
+
vec3 la = toLinear(clamp(a.rgb, 0.0, 1.0)) * a.a;
|
|
36
|
+
vec3 lb = toLinear(clamp(b.rgb, 0.0, 1.0)) * b.a;
|
|
37
|
+
vec3 base = mix(la, lb, t);
|
|
38
|
+
float alpha = mix(a.a, b.a, t);
|
|
39
|
+
|
|
40
|
+
// the overlap: each image stays brighter for longer, as in an additive dissolve,
|
|
41
|
+
// rolled off toward full exposure so that bright areas glow instead of clipping
|
|
42
|
+
float extra = overlap * min(t, 1.0 - t);
|
|
43
|
+
vec3 excess = extra * (la + lb);
|
|
44
|
+
vec3 room = max(vec3(alpha) - base, vec3(1e-5));
|
|
45
|
+
vec3 color = base + room * (1.0 - exp(-excess / room));
|
|
46
|
+
|
|
47
|
+
if (alpha <= 0.0) return vec4(0.0);
|
|
48
|
+
return vec4(toSrgb(clamp(color / alpha, 0.0, 1.0)), alpha);
|
|
49
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// FilmStrip — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/FilmStrip.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The picture slips like film in a projector gate: it shrinks to show the sprocket holes, the strip runs down with motion blur and a slight weave, then the incoming frame lands in place
|
|
5
|
+
// Tags: retro, vertical, motion-blur, film
|
|
6
|
+
|
|
7
|
+
// @range(1, 6, 1) Number of frames that slip by
|
|
8
|
+
uniform int frames; // = 2
|
|
9
|
+
// @range(0, 0.4) How much the picture shrinks during the slip, showing the film's edges
|
|
10
|
+
uniform float shrink; // = 0.2
|
|
11
|
+
// @range(0, 1) Length of the motion blur at full speed
|
|
12
|
+
uniform float blur; // = 0.5
|
|
13
|
+
// @range(0, 1) Amount of horizontal weave and vertical jitter
|
|
14
|
+
uniform float weave; // = 0.5
|
|
15
|
+
// @color Color of the film around the pictures and of the line between frames
|
|
16
|
+
uniform vec4 filmColor; // = vec4(0.06, 0.05, 0.05, 1.0)
|
|
17
|
+
// @color Color of the light through the sprocket holes
|
|
18
|
+
uniform vec4 holeColor; // = vec4(0.96, 0.93, 0.85, 1.0)
|
|
19
|
+
|
|
20
|
+
// height of the line between two frames, in frame heights
|
|
21
|
+
const float FRAME_LINE = 0.08;
|
|
22
|
+
// sprocket holes per frame
|
|
23
|
+
const float HOLES = 4.0;
|
|
24
|
+
const int SAMPLES = 16;
|
|
25
|
+
|
|
26
|
+
// a fine, evenly spread dither pattern over small cells of the frame
|
|
27
|
+
float dither(vec2 cell) {
|
|
28
|
+
return fract(52.9829189 * fract(dot(cell, vec2(0.06711056, 0.00583715))));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// the film at (x, y): x across it (0 to 1 over the picture), y along it from the start of frame
|
|
32
|
+
// number base, in frame heights; holes fades the sprocket holes in
|
|
33
|
+
vec4 film(float x, float y, float base, float n, float aa, float holeX, vec2 holeSize, float holes) {
|
|
34
|
+
float pitch = 1.0 + FRAME_LINE;
|
|
35
|
+
float jy = floor(y / pitch);
|
|
36
|
+
float j = base + jy;
|
|
37
|
+
float fy = y - jy * pitch;
|
|
38
|
+
vec4 c = filmColor;
|
|
39
|
+
if (x >= 0.0 && x <= 1.0 && fy <= 1.0) {
|
|
40
|
+
vec2 q = vec2(x, fy);
|
|
41
|
+
c = j < n ? getFromColor(q) : getToColor(q);
|
|
42
|
+
}
|
|
43
|
+
// soft edges for the picture during the slip (none at rest, where it fills the frame)
|
|
44
|
+
float inside = min(min(x, 1.0 - x) * ratio, min(fy, 1.0 - fy));
|
|
45
|
+
c = mix(filmColor, c, clamp(inside / aa + 0.5, 0.0, 1.0));
|
|
46
|
+
// the sprocket holes, in the margins on both sides, in frame heights
|
|
47
|
+
float hy = mod(y, pitch / HOLES) - 0.5 * pitch / HOLES;
|
|
48
|
+
float hx = (abs(x - 0.5) - holeX) * ratio;
|
|
49
|
+
vec2 dd = abs(vec2(hx, hy)) - holeSize + 0.3 * holeSize.x;
|
|
50
|
+
float sd = length(max(dd, 0.0)) + min(max(dd.x, dd.y), 0.0) - 0.3 * holeSize.x;
|
|
51
|
+
return mix(c, holeColor, clamp(0.5 - sd / aa, 0.0, 1.0) * holes);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
vec4 transition(vec2 uv) {
|
|
55
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
56
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
57
|
+
float n = max(float(frames), 1.0);
|
|
58
|
+
float pitch = 1.0 + FRAME_LINE;
|
|
59
|
+
float p = progress;
|
|
60
|
+
// the picture shrinks first, slips, then grows back
|
|
61
|
+
float env = smoothstep(0.0, 0.3, p) * (1.0 - smoothstep(0.7, 1.0, p));
|
|
62
|
+
float k = 1.0 - shrink * env;
|
|
63
|
+
// the slip, in frames: smooth start and landing
|
|
64
|
+
float x0 = clamp((p - 0.15) / 0.7, 0.0, 1.0);
|
|
65
|
+
float slip = x0 * x0 * x0 * (x0 * (x0 * 6.0 - 15.0) + 10.0);
|
|
66
|
+
float speed = 30.0 * x0 * x0 * (1.0 - x0) * (1.0 - x0) / 0.7; // d(slip)/d(progress), up to ~2.7
|
|
67
|
+
// weave and jitter, only while the film moves
|
|
68
|
+
float wob = weave * env;
|
|
69
|
+
// (the weave stays within the film's margin)
|
|
70
|
+
float dx = wob * smoothstep(0.0, 0.1, shrink) * (0.006 * sin(p * 47.0) + 0.004 * sin(p * 113.0 + 1.3));
|
|
71
|
+
float dy = wob * 0.012 * sin(p * 71.0 + 0.4) * (1.0 - speed / 2.7);
|
|
72
|
+
|
|
73
|
+
// the frames slipped by so far: whole frames, and the position within the current one
|
|
74
|
+
float frameSlip = slip * n;
|
|
75
|
+
float base = floor(frameSlip);
|
|
76
|
+
float x = (uv.x - 0.5) / k + 0.5 + dx;
|
|
77
|
+
float y = (uv.y - 0.5) / k + 0.5 + dy + (frameSlip - base) * pitch;
|
|
78
|
+
// anti-aliasing width, in frame heights: none at rest or without margin
|
|
79
|
+
float aa = 0.002 * min(1.0, 10.0 * env) * min(1.0, 20.0 * shrink) + 1e-4;
|
|
80
|
+
// the holes sit in the middle of the margin the shrinking picture shows
|
|
81
|
+
float margin = 0.5 * shrink / max(1.0 - shrink, 0.01);
|
|
82
|
+
float holeX = 0.5 + 0.5 * margin;
|
|
83
|
+
vec2 holeSize = vec2(0.28 * margin * ratio, 0.11 * pitch / HOLES);
|
|
84
|
+
float holes = smoothstep(0.0, 0.02, margin);
|
|
85
|
+
|
|
86
|
+
// motion blur along the strip, dithered to hide the steps
|
|
87
|
+
float len = blur * 0.06 * speed * n;
|
|
88
|
+
vec4 color = vec4(0.0);
|
|
89
|
+
if (len < 1e-5) {
|
|
90
|
+
color = film(x, y, base, n, aa, holeX, holeSize, holes);
|
|
91
|
+
} else {
|
|
92
|
+
// averaged with premultiplied colors, so transparent parts don't darken the others
|
|
93
|
+
float jitter = dither(floor(uv * vec2(ratio, 1.0) * 540.0));
|
|
94
|
+
for (int i = 0; i < SAMPLES; i++) {
|
|
95
|
+
float t = (float(i) + jitter) / float(SAMPLES) - 0.5;
|
|
96
|
+
vec4 c = film(x, y + t * len, base, n, aa, holeX, holeSize, holes);
|
|
97
|
+
color += vec4(c.rgb * c.a, c.a);
|
|
98
|
+
}
|
|
99
|
+
color /= float(SAMPLES);
|
|
100
|
+
color.rgb = color.a > 0.0 ? color.rgb / color.a : vec3(0.0);
|
|
101
|
+
}
|
|
102
|
+
// the projector's light flickers a little while the film runs
|
|
103
|
+
color.rgb *= 1.0 - 0.08 * wob * (0.5 + 0.5 * sin(p * 157.0));
|
|
104
|
+
return color;
|
|
105
|
+
}
|