gl-transitions 2.2.0 → 2.3.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 +52 -0
- package/compatibility.json +400 -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/CurvedWipe.glsl +52 -0
- package/glsl3/Disintegrate.glsl +112 -0
- package/glsl3/FilmDissolve.glsl +49 -0
- package/glsl3/FilmStrip.glsl +105 -0
- package/glsl3/FlameWipe.glsl +154 -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/WedgeWipe.glsl +35 -0
- package/index.js +1 -1
- package/layouts.json +945 -40
- package/llms-full.txt +705 -304
- package/llms.txt +185 -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/CurvedWipe.metal +229 -0
- package/msl/Disintegrate.metal +468 -0
- package/msl/FilmDissolve.metal +199 -0
- package/msl/FilmStrip.metal +429 -0
- package/msl/FlameWipe.metal +575 -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/WedgeWipe.metal +154 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +100 -36
- 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/CurvedWipe.sksl +64 -0
- package/sksl/Disintegrate.sksl +117 -0
- package/sksl/FilmDissolve.sksl +60 -0
- package/sksl/FilmStrip.sksl +114 -0
- package/sksl/FlameWipe.sksl +162 -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/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/CurvedWipe.glsl +51 -0
- package/transitions/Disintegrate.glsl +111 -0
- package/transitions/FilmDissolve.glsl +48 -0
- package/transitions/FilmStrip.glsl +104 -0
- package/transitions/FlameWipe.glsl +153 -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/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/CurvedWipe.wgsl +198 -0
- package/wgsl/Disintegrate.wgsl +426 -0
- package/wgsl/FilmDissolve.wgsl +169 -0
- package/wgsl/FilmStrip.wgsl +381 -0
- package/wgsl/FlameWipe.wgsl +531 -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/WedgeWipe.wgsl +126 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: Soft, glossy blobs of liquid pop up over the outgoing image, swell and melt into each other, revealing the incoming image until they cover the whole frame
|
|
4
|
+
// Tags: blob, liquid, organic, reveal
|
|
5
|
+
|
|
6
|
+
// @range(2, 12, 1) Number of blobs across the frame
|
|
7
|
+
uniform float blobs; // = 5.0
|
|
8
|
+
// @range(0, 1) How smoothly neighbouring blobs melt into each other
|
|
9
|
+
uniform float smoothness; // = 0.5
|
|
10
|
+
// @color Color of the glossy highlight on the rim of the blobs (its alpha is its strength)
|
|
11
|
+
uniform vec4 highlight; // = vec4(1.0, 1.0, 1.0, 0.7)
|
|
12
|
+
// @color Color of the soft shadow that the blobs cast on the outgoing image
|
|
13
|
+
uniform vec4 shadow; // = vec4(0.0, 0.0, 0.0, 0.3)
|
|
14
|
+
|
|
15
|
+
float hash (vec2 p) {
|
|
16
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
17
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
18
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
vec2 fold (vec2 p) {
|
|
22
|
+
return 1.0 - abs(1.0 - mod(p, 2.0));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// signed distance to the blob of a grid cell (in cells), its center returned in .yz
|
|
26
|
+
vec3 blob (vec2 cell, float rStart, float rEnd) {
|
|
27
|
+
vec2 c = cell + 0.5 + 0.7 * (vec2(hash(cell + 0.5), hash(cell + 41.3)) - 0.5);
|
|
28
|
+
float t0 = 0.02 + 0.43 * hash(cell + 17.9); // when it pops up
|
|
29
|
+
float s = clamp((progress - t0) / (1.0 - t0), 0.0, 1.0);
|
|
30
|
+
// it pops up fast with a little wobble, then swells slowly
|
|
31
|
+
float pop = clamp((progress - t0) / 0.12, 0.0, 1.0);
|
|
32
|
+
pop = 1.0 - (1.0 - pop) * (1.0 - pop) * (1.0 - pop);
|
|
33
|
+
float r = mix(rStart, 0.18, pop) + (rEnd - 0.18) * s * sqrt(s);
|
|
34
|
+
r += 0.05 * sin(pop * 9.0) * (1.0 - s) * pop;
|
|
35
|
+
return vec3(r, c);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
vec4 transition (vec2 uv) {
|
|
39
|
+
float n = max(1.0, floor(blobs + 0.5));
|
|
40
|
+
float cellSize = max(ratio, 1.0) / n;
|
|
41
|
+
vec2 q = vec2(uv.x * ratio, uv.y) / cellSize; // in cells
|
|
42
|
+
vec2 base = floor(q);
|
|
43
|
+
float k = 0.02 + 0.25 * smoothness; // melting distance, in cells
|
|
44
|
+
float w = 0.16; // width of the rounded rim, in cells
|
|
45
|
+
// a blob starts far enough below the surface not to show (the union of 49 blobs bulges by up to k * log(49)),
|
|
46
|
+
// and ends up covering the whole of its cell (its center is at most 0.85 * sqrt(2) cells away) and its rim
|
|
47
|
+
float rStart = -(0.03 + 4.0 * k);
|
|
48
|
+
float rEnd = 0.85 * sqrt(2.0) + w + 0.05;
|
|
49
|
+
// smooth union (log-sum-exp, computed online) of the blobs around, with its gradient;
|
|
50
|
+
// blobs further than 3 cells away weigh less than exp(-7) and are left out
|
|
51
|
+
float m = 1e3; // distance to the nearest blob
|
|
52
|
+
float sum = 0.0;
|
|
53
|
+
vec2 grad = vec2(0.0);
|
|
54
|
+
float rNear = 0.0; // radius of the nearest blob
|
|
55
|
+
for (int j = -3; j <= 3; j++) {
|
|
56
|
+
for (int i = -3; i <= 3; i++) {
|
|
57
|
+
vec3 b = blob(base + vec2(float(i), float(j)), rStart, rEnd);
|
|
58
|
+
vec2 dq = q - b.yz;
|
|
59
|
+
float l = length(dq);
|
|
60
|
+
float dist = l - b.x;
|
|
61
|
+
vec2 g = dq / max(l, 1e-4);
|
|
62
|
+
if (dist < m) {
|
|
63
|
+
float scale = exp((dist - m) / k);
|
|
64
|
+
sum = sum * scale + 1.0;
|
|
65
|
+
grad = grad * scale + g;
|
|
66
|
+
m = dist;
|
|
67
|
+
rNear = b.x;
|
|
68
|
+
} else {
|
|
69
|
+
float wt = exp((m - dist) / k);
|
|
70
|
+
sum += wt;
|
|
71
|
+
grad += wt * g;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
float d = m - k * log(sum); // < 0 inside the goo
|
|
76
|
+
grad /= sum;
|
|
77
|
+
float aa = 0.012 * n / 5.0;
|
|
78
|
+
float inside = 1.0 - smoothstep(-aa, aa, d);
|
|
79
|
+
// a rounded, glossy surface near the edge, flat further inside; the goo settles flat at the end
|
|
80
|
+
float h = clamp(-d / w, 0.0, 1.0);
|
|
81
|
+
float settle = 1.0 - smoothstep(0.45, 0.85, progress);
|
|
82
|
+
float tilt = (1.0 - h) * (1.0 - h) * settle;
|
|
83
|
+
vec3 nrm = normalize(vec3(grad * tilt * 3.0, 1.0));
|
|
84
|
+
vec3 halfway = normalize(vec3(-0.35, 0.45, 1.0) + vec3(0.0, 0.0, 1.0));
|
|
85
|
+
float spec = pow(max(dot(nrm, halfway), 0.0), 200.0) * settle;
|
|
86
|
+
// thick, opaque goo: darker toward its edge, more so on the side away from the light
|
|
87
|
+
float shade = 1.0 - tilt * (0.25 + 0.3 * clamp(dot(grad, vec2(0.6, -0.8)) + 0.3, 0.0, 1.0));
|
|
88
|
+
vec4 to = getToColor(fold(uv - grad * tilt * 0.01 * cellSize / vec2(ratio, 1.0)));
|
|
89
|
+
float t2 = tilt * tilt;
|
|
90
|
+
float gloss = 0.3 * t2 * t2; // a thin bright line right on the rim
|
|
91
|
+
to.rgb = mix(to.rgb * shade, highlight.rgb, clamp(spec + gloss, 0.0, 1.0) * highlight.a);
|
|
92
|
+
vec4 from = getFromColor(uv);
|
|
93
|
+
float sh = shadow.a * (1.0 - smoothstep(0.0, 0.15, d + 0.03)) * smoothstep(0.0, 0.3, rNear);
|
|
94
|
+
from.rgb = mix(from.rgb, shadow.rgb, sh);
|
|
95
|
+
return mix(from, to, inside);
|
|
96
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The incoming image spreads over the outgoing one like drops of ink in water, blooming from a few points with curling, wispy edges and a darker rim, until it fills the frame
|
|
4
|
+
// Tags: ink, organic, fluid, noise
|
|
5
|
+
|
|
6
|
+
// @range(1, 8, 1) Number of ink drops
|
|
7
|
+
uniform float drops; // = 4.0
|
|
8
|
+
// @range(0, 1) How far the curling tendrils reach out of the blooms
|
|
9
|
+
uniform float tendrils; // = 0.7
|
|
10
|
+
// @range(0, 1) How dark the rim of ink at the front of the blooms is
|
|
11
|
+
uniform float rim; // = 0.5
|
|
12
|
+
// @param Random seed for the drop positions and the swirls
|
|
13
|
+
uniform float seed; // = 3.0
|
|
14
|
+
|
|
15
|
+
float hash (vec2 p) {
|
|
16
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
17
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
18
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
float vnoise (vec2 p) {
|
|
22
|
+
vec2 i = floor(p);
|
|
23
|
+
vec2 f = fract(p);
|
|
24
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
25
|
+
return mix(
|
|
26
|
+
mix(hash(i), hash(i + vec2(1.0, 0.0)), f.x),
|
|
27
|
+
mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), f.x),
|
|
28
|
+
f.y
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
float fbm (vec2 p) {
|
|
33
|
+
float v = 0.0;
|
|
34
|
+
float a = 0.5;
|
|
35
|
+
for (int i = 0; i < 4; i++) {
|
|
36
|
+
v += a * vnoise(p);
|
|
37
|
+
p = mat2(1.6, 1.2, -1.2, 1.6) * p + 7.3;
|
|
38
|
+
a *= 0.5;
|
|
39
|
+
}
|
|
40
|
+
return v / 0.9375;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
vec2 fold (vec2 p) {
|
|
44
|
+
return 1.0 - abs(1.0 - mod(p, 2.0));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
vec4 transition (vec2 uv) {
|
|
48
|
+
float p = progress;
|
|
49
|
+
vec2 q = vec2(uv.x * ratio, uv.y);
|
|
50
|
+
// swirls: noise warped twice by itself, drifting as the ink spreads
|
|
51
|
+
vec2 o = vec2(seed * 3.1, seed * 1.7);
|
|
52
|
+
vec2 sq = q * 2.2 + o;
|
|
53
|
+
vec2 w1 = vec2(fbm(sq + vec2(0.0, 0.6 * p)), fbm(sq + vec2(5.2, 1.3) - vec2(0.5 * p, 0.0)));
|
|
54
|
+
vec2 w2 = vec2(fbm(sq + 3.0 * w1 + vec2(1.7, 9.2)), fbm(sq + 3.0 * w1 + vec2(8.3, 2.8)));
|
|
55
|
+
float swirl = fbm(sq * 0.8 + 2.5 * w2) - 0.5; // marbled, curling pattern
|
|
56
|
+
vec2 flow = w2 - 0.5;
|
|
57
|
+
float amp = 0.05 + 0.35 * tendrils;
|
|
58
|
+
float n = clamp(floor(drops + 0.5), 1.0, 8.0);
|
|
59
|
+
float rimW = 0.1;
|
|
60
|
+
float feather = 0.05; // soft, diluted ink around the front
|
|
61
|
+
float margin = 1.2 * amp + rimW + 0.08; // how far the swirls can pull the front back
|
|
62
|
+
float f = -1e3; // > 0 inside the ink
|
|
63
|
+
float fs = -1e3; // the same, only for the drops already fallen, which fades their haze in
|
|
64
|
+
for (int i = 0; i < 8; i++) {
|
|
65
|
+
float fi = float(i);
|
|
66
|
+
if (fi < n) {
|
|
67
|
+
vec2 hs = vec2(fi * 7.13 + seed, fi * 3.71 - seed);
|
|
68
|
+
vec2 c = vec2(mix(0.15, 0.85, hash(hs)) * ratio, mix(0.15, 0.85, hash(hs + 19.7)));
|
|
69
|
+
float start = 0.2 * fi / n;
|
|
70
|
+
float s = clamp((p - start) / (1.0 - start), 0.0, 1.0);
|
|
71
|
+
// distance to the farthest corner: each bloom alone covers the frame in the end
|
|
72
|
+
vec2 m = max(c, vec2(ratio, 1.0) - c);
|
|
73
|
+
float far = length(m) + margin;
|
|
74
|
+
float s3 = s * s * s;
|
|
75
|
+
float r = (far + 0.02) * s * (0.35 + 0.65 * s3 * s3) - 0.02;
|
|
76
|
+
// a drop starts round, then its front curls more and more as it spreads
|
|
77
|
+
float reach = amp * min(1.0, max(r, 0.0) * 5.0);
|
|
78
|
+
float g = r - length(q - c + 1.3 * reach * flow) + reach * 0.9 * swirl;
|
|
79
|
+
f = max(f, g);
|
|
80
|
+
fs = max(fs, g - 0.15 * (1.0 - min(1.0, s * 12.0)));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
float aa = 0.003;
|
|
84
|
+
float inside = smoothstep(-aa, aa, f);
|
|
85
|
+
// feathered wisps of diluted ink, streaked along the swirls, ahead of the front
|
|
86
|
+
float wisp = 1.0 - smoothstep(0.0, 0.08, abs(fbm(sq * 2.0 + 5.0 * w2) - 0.5));
|
|
87
|
+
float soft = smoothstep(-feather, 0.0, fs) * (0.35 + 0.4 * wisp);
|
|
88
|
+
float haze = 0.35 * wisp * (1.0 - smoothstep(0.0, 0.1, -fs));
|
|
89
|
+
float cover = max(inside, max(soft, haze));
|
|
90
|
+
// the ink is denser, and still moving, close to its front
|
|
91
|
+
float edge = 1.0 - smoothstep(0.0, rimW, f);
|
|
92
|
+
vec4 to = getToColor(fold(uv - 0.015 * edge * flow / vec2(ratio, 1.0)));
|
|
93
|
+
to.rgb = mix(to.rgb, to.rgb * to.rgb * 0.7, rim * edge);
|
|
94
|
+
return mix(getFromColor(uv), to, cover);
|
|
95
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A bright light sweeps across the frame and flares the lens: a long thin horizontal streak, a glowing core and a trail of colored ghost reflections; at its peak the incoming image spreads out from the light under its glare
|
|
4
|
+
// Tags: light, flare, glow, streak
|
|
5
|
+
|
|
6
|
+
// @range(-90, 90) Angle of the path of the light, in degrees (0 sweeps from left to right)
|
|
7
|
+
uniform float angle; // = -12.0
|
|
8
|
+
// @range(-0.5, 0.5) How far above the center of the frame the light passes
|
|
9
|
+
uniform float height; // = 0.18
|
|
10
|
+
// @range(0, 2) Brightness of the flare
|
|
11
|
+
uniform float intensity; // = 1.0
|
|
12
|
+
// @color Color of the streak and of the glare
|
|
13
|
+
uniform vec3 color; // = vec3(0.35, 0.6, 1.0)
|
|
14
|
+
|
|
15
|
+
const int BLOOM_TAPS = 12;
|
|
16
|
+
const int GHOSTS = 6;
|
|
17
|
+
|
|
18
|
+
// mirror the coordinates back into the frame
|
|
19
|
+
vec2 mirror(vec2 v) {
|
|
20
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
vec4 premultiplied(vec4 c) {
|
|
24
|
+
return vec4(c.rgb * c.a, c.a);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// the image on screen (premultiplied): the outgoing one, then the incoming one after the cut
|
|
28
|
+
vec4 frame(vec2 st, float m) {
|
|
29
|
+
if (m <= 0.0) return premultiplied(getFromColor(st));
|
|
30
|
+
if (m >= 1.0) return premultiplied(getToColor(st));
|
|
31
|
+
return mix(premultiplied(getFromColor(st)), premultiplied(getToColor(st)), m);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// the light of a pixel (premultiplied): its color above a knee
|
|
35
|
+
vec3 highlight(vec4 c) {
|
|
36
|
+
float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
37
|
+
return c.rgb * smoothstep(0.55, 0.95, lum);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
vec4 transition(vec2 uv) {
|
|
41
|
+
float p = progress;
|
|
42
|
+
if (p <= 0.0) return getFromColor(uv);
|
|
43
|
+
if (p >= 1.0) return getToColor(uv);
|
|
44
|
+
|
|
45
|
+
// 0 at both ends, 1 at the peak
|
|
46
|
+
float env = 4.0 * p * (1.0 - p);
|
|
47
|
+
float peak = pow(env, 24.0);
|
|
48
|
+
// frame coordinates, centered, with square units
|
|
49
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
50
|
+
vec2 q = (uv - 0.5) * aspect;
|
|
51
|
+
float r = radians(angle);
|
|
52
|
+
vec2 dir = vec2(cos(r), -sin(r));
|
|
53
|
+
vec2 normal = vec2(-dir.y, dir.x);
|
|
54
|
+
// the light crosses the frame, slowing down as it passes the middle
|
|
55
|
+
float t = p - 0.5;
|
|
56
|
+
float travel = 0.5 * (abs(dir.x) * ratio + abs(dir.y)) + 0.3;
|
|
57
|
+
float along = travel * (2.0 * t) * (0.55 + 1.8 * t * t);
|
|
58
|
+
vec2 src = dir * along + normal * height;
|
|
59
|
+
|
|
60
|
+
vec2 d = q - src;
|
|
61
|
+
float dist = length(d);
|
|
62
|
+
float k = intensity * env;
|
|
63
|
+
|
|
64
|
+
// the cut, under the glare: the incoming image spreads out from the light in a soft circle,
|
|
65
|
+
// slower as the flare gets dimmer so that it still reads as intended
|
|
66
|
+
float cut = mix(0.2, 0.06, clamp(intensity, 0.0, 1.0));
|
|
67
|
+
float s = clamp((p - 0.5 + cut) / (2.0 * cut), 0.0, 1.0);
|
|
68
|
+
float soft = 0.3;
|
|
69
|
+
float reach = 0.5 * length(aspect) + length(src) + soft;
|
|
70
|
+
float front = s * (reach + soft);
|
|
71
|
+
float m = smoothstep(front, front - soft, dist);
|
|
72
|
+
vec4 base = frame(uv, m);
|
|
73
|
+
|
|
74
|
+
// the anamorphic streak: long and thin, always horizontal, white at the center and tinted along
|
|
75
|
+
float ax = abs(d.x);
|
|
76
|
+
float ay = abs(d.y);
|
|
77
|
+
float thin = exp(-ay * 140.0) * exp(-ax * 0.7);
|
|
78
|
+
float wide = exp(-ay * 30.0) * exp(-ax * 1.6);
|
|
79
|
+
vec3 tint = color;
|
|
80
|
+
vec3 streak = (thin * mix(vec3(1.0), tint, smoothstep(0.0, 0.3, ax)) + 0.5 * wide * tint) * 3.0;
|
|
81
|
+
|
|
82
|
+
// the core and its halo
|
|
83
|
+
vec3 core = vec3(1.0, 0.97, 0.92) * exp(-dist * dist * 600.0) * 3.0 + mix(vec3(1.0), tint, 0.5) * exp(-dist * 7.0) * 0.6;
|
|
84
|
+
|
|
85
|
+
// ghosts on the line from the light through the center of the frame
|
|
86
|
+
vec3 ghosts = vec3(0.0);
|
|
87
|
+
for (int i = 0; i < GHOSTS; i++) {
|
|
88
|
+
float fi = float(i);
|
|
89
|
+
float f = -0.45 + 0.42 * fi + 0.08 * sin(fi * 2.3);
|
|
90
|
+
vec2 g = -src * f;
|
|
91
|
+
float size = 0.025 + 0.06 * fract(fi * 0.618 + 0.2);
|
|
92
|
+
float gd = length(q - g) / size;
|
|
93
|
+
// a soft disc with a brighter rim
|
|
94
|
+
float disc = smoothstep(1.0, 0.8, gd) * (0.35 + 0.65 * smoothstep(0.4, 0.95, gd));
|
|
95
|
+
vec3 hue = mix(tint, vec3(1.0, 0.65, 0.35), fract(fi * 0.53));
|
|
96
|
+
hue = mix(hue, vec3(0.5, 1.0, 0.6), step(4.5, fi) * 0.6);
|
|
97
|
+
ghosts += disc * hue * 0.45;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// the highlights of the image bloom at the peak
|
|
101
|
+
vec3 bloom = vec3(0.0);
|
|
102
|
+
if (peak > 1e-3) {
|
|
103
|
+
float radius = 0.06 * env;
|
|
104
|
+
for (int i = 0; i < BLOOM_TAPS; i++) {
|
|
105
|
+
float fi = float(i);
|
|
106
|
+
float a = fi * 2.39996;
|
|
107
|
+
float rr = radius * sqrt((fi + 0.5) / float(BLOOM_TAPS));
|
|
108
|
+
vec2 o = vec2(cos(a), sin(a)) * rr / aspect;
|
|
109
|
+
bloom += highlight(frame(mirror(uv + o), m));
|
|
110
|
+
}
|
|
111
|
+
bloom /= float(BLOOM_TAPS);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// at the peak, the glare: a wide halo around the light and a light veil over the frame, to hide the cut
|
|
115
|
+
vec3 glare = mix(vec3(1.0), tint, 0.5) * peak * (0.45 + 2.2 * exp(-dist * 3.0));
|
|
116
|
+
|
|
117
|
+
vec3 light = k * (streak + core + ghosts) + intensity * (bloom * 2.5 * peak + glare);
|
|
118
|
+
light = 1.0 - exp(-light);
|
|
119
|
+
|
|
120
|
+
// screened over the image; the flare only shows on the image, so transparency is kept
|
|
121
|
+
vec3 c = base.rgb + light * base.a - base.rgb * light;
|
|
122
|
+
if (base.a <= 0.0) return vec4(0.0);
|
|
123
|
+
return vec4(clamp(c / base.a, 0.0, 1.0), base.a);
|
|
124
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: Shafts of light burst from the highlights of the outgoing image and stream outward from a slowly drifting center; at their peak the incoming image takes over and its own rays shrink back into its highlights
|
|
4
|
+
// Tags: light, glow, rays, radial
|
|
5
|
+
|
|
6
|
+
// @param Point the rays stream away from, at the middle of the transition
|
|
7
|
+
uniform vec2 center; // = vec2(0.5, 0.6)
|
|
8
|
+
// @range(0, 0.5) How far the center drifts during the transition, from left to right
|
|
9
|
+
uniform float drift; // = 0.15
|
|
10
|
+
// @range(0, 1) Length of the rays at the peak, as a fraction of their distance to the center
|
|
11
|
+
uniform float reach; // = 0.6
|
|
12
|
+
// @range(0, 0.8) Brightness above which the image casts rays
|
|
13
|
+
uniform float threshold; // = 0.65
|
|
14
|
+
// @range(0, 4) Brightness of the rays
|
|
15
|
+
uniform float intensity; // = 1.5
|
|
16
|
+
// @color Tint of the rays, toward their ends
|
|
17
|
+
uniform vec3 tint; // = vec3(1.0, 0.82, 0.55)
|
|
18
|
+
|
|
19
|
+
const int TAPS = 20;
|
|
20
|
+
// number of shafts around the center
|
|
21
|
+
const float SHAFTS = 23.0;
|
|
22
|
+
const float PI = 3.141592653589793;
|
|
23
|
+
|
|
24
|
+
float hash12(vec2 v) {
|
|
25
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
26
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
27
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// smooth noise around the center, wrapping over a full turn (t in 0..1)
|
|
31
|
+
float shaftNoise(float t, float n, float seed) {
|
|
32
|
+
float x = t * n;
|
|
33
|
+
float i = floor(x);
|
|
34
|
+
float f = x - i;
|
|
35
|
+
float a = hash12(vec2(mod(i, n), seed));
|
|
36
|
+
float b = hash12(vec2(mod(i + 1.0, n), seed));
|
|
37
|
+
return mix(a, b, f * f * (3.0 - 2.0 * f));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// mirror the coordinates back into the frame
|
|
41
|
+
vec2 mirror(vec2 v) {
|
|
42
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// the light of a pixel (premultiplied): its color above the threshold
|
|
46
|
+
vec3 glow(vec4 c, float knee) {
|
|
47
|
+
float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
48
|
+
return c.rgb * c.a * smoothstep(knee, knee + 0.2, lum);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// the light at a ray tap: one image, or both during the short switch
|
|
52
|
+
vec3 light(vec2 st, float knee, float m) {
|
|
53
|
+
if (m <= 0.0) return glow(getFromColor(st), knee);
|
|
54
|
+
if (m >= 1.0) return glow(getToColor(st), knee);
|
|
55
|
+
return mix(glow(getFromColor(st), knee), glow(getToColor(st), knee), m);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
vec4 transition(vec2 uv) {
|
|
59
|
+
float p = progress;
|
|
60
|
+
// the rays grow on the outgoing image, and shrink back into the incoming one
|
|
61
|
+
float amount = p < 0.5 ? smoothstep(0.0, 0.5, p) : 1.0 - smoothstep(0.5, 1.0, p);
|
|
62
|
+
float peak = amount * amount * amount;
|
|
63
|
+
float m = smoothstep(0.46, 0.54, p);
|
|
64
|
+
vec4 fromColor = getFromColor(uv);
|
|
65
|
+
vec4 toColor = getToColor(uv);
|
|
66
|
+
if (amount <= 0.0) return m < 0.5 ? fromColor : toColor;
|
|
67
|
+
|
|
68
|
+
// the rays stream away from a center drifting slowly across the frame
|
|
69
|
+
vec2 origin = center + vec2(drift * (p - 0.5), 0.0);
|
|
70
|
+
float len = reach * amount;
|
|
71
|
+
// more and more of the image catches the light as the rays grow
|
|
72
|
+
float knee = mix(threshold, 0.75 * threshold, peak);
|
|
73
|
+
// a small shift of the taps, under their spacing, blends them into smooth shafts;
|
|
74
|
+
// hashed by integer cell so that every GPU computes the same shift
|
|
75
|
+
float jitter = hash12(floor(uv * vec2(ratio, 1.0) * 997.0));
|
|
76
|
+
|
|
77
|
+
// the light gathered on the way to the center, fading with the distance it travels
|
|
78
|
+
vec3 rays = vec3(0.0);
|
|
79
|
+
float total = 0.0;
|
|
80
|
+
for (int i = 0; i < TAPS; i++) {
|
|
81
|
+
float s = (float(i) + jitter) / float(TAPS);
|
|
82
|
+
float w = exp(-2.0 * s);
|
|
83
|
+
// warm white near the sources, tinted further along the rays
|
|
84
|
+
vec3 hue = mix(vec3(1.0), tint, smoothstep(0.0, 0.6, s));
|
|
85
|
+
rays += w * hue * light(mirror(mix(uv, origin, s * len)), knee, m);
|
|
86
|
+
total += w;
|
|
87
|
+
}
|
|
88
|
+
// the light breaks into shafts of different strengths, slowly turning
|
|
89
|
+
vec2 d = (uv - origin) * vec2(ratio, 1.0);
|
|
90
|
+
// atan is undefined at the center itself
|
|
91
|
+
float turn = length(d) > 1e-6 ? atan(d.y, d.x) / (2.0 * PI) + 0.5 : 0.0;
|
|
92
|
+
float shafts = 0.6 * shaftNoise(fract(turn + 0.03 * p), SHAFTS, 1.0) + 0.4 * shaftNoise(fract(turn - 0.05 * p), 2.0 * SHAFTS + 1.0, 7.0);
|
|
93
|
+
// merged back into a soft glow close to the center, where the shafts would meet in a point
|
|
94
|
+
rays *= mix(1.0, mix(0.2, 1.6, smoothstep(0.15, 0.85, shafts)), smoothstep(0.0, 0.3, length(d)));
|
|
95
|
+
rays *= intensity * amount * (1.0 + 3.0 * peak) / total;
|
|
96
|
+
// compressed, so that bright areas never flatten into white
|
|
97
|
+
rays = 0.9 * (1.0 - exp(-rays));
|
|
98
|
+
|
|
99
|
+
// the image stays sharp, with a slight lift of the exposure at the peak; the rays are screened
|
|
100
|
+
// on top of its colors and add nothing to its alpha
|
|
101
|
+
vec4 c = mix(vec4(fromColor.rgb * fromColor.a, fromColor.a), vec4(toColor.rgb * toColor.a, toColor.a), m);
|
|
102
|
+
if (c.a <= 0.0) return vec4(0.0);
|
|
103
|
+
vec3 base = min(c.rgb / c.a * (1.0 + 0.2 * peak), 1.0);
|
|
104
|
+
return vec4(base + rays - base * rays, c.a);
|
|
105
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A band of intense light sweeps across the frame like a glint on glass, blooming the highlights of both images, and leaves the incoming image behind it
|
|
4
|
+
// Tags: wipe, light, glow, glint
|
|
5
|
+
|
|
6
|
+
// @param Direction the band of light moves toward
|
|
7
|
+
uniform vec2 direction; // = vec2(1.0, -0.35)
|
|
8
|
+
// @range(0.005, 0.2) Width of the bright core of the band, in frame heights
|
|
9
|
+
uniform float width; // = 0.04
|
|
10
|
+
// @range(0, 3) Brightness of the light
|
|
11
|
+
uniform float intensity; // = 1.2
|
|
12
|
+
// @color Tint of the light, toward the edges of the band (its core burns white)
|
|
13
|
+
uniform vec3 color; // = vec3(1.0, 0.86, 0.66)
|
|
14
|
+
|
|
15
|
+
const int TAPS = 12;
|
|
16
|
+
|
|
17
|
+
// mirror the coordinates back into the frame
|
|
18
|
+
vec2 mirror(vec2 v) {
|
|
19
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// a gentle ease in and out, which does not linger at the ends
|
|
23
|
+
float ease(float t) {
|
|
24
|
+
return 0.5 * (t + t * t * (3.0 - 2.0 * t));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// the image on screen at a point: the outgoing one ahead of the switch, the incoming one behind it
|
|
28
|
+
// (both always sampled, so that no texture read sits in a branch that differs between pixels)
|
|
29
|
+
vec4 frame(vec2 st, float m) {
|
|
30
|
+
return mix(getFromColor(st), getToColor(st), m);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// the light of a pixel (premultiplied): its color above a soft knee
|
|
34
|
+
vec3 highlight(vec4 c) {
|
|
35
|
+
float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
36
|
+
return c.rgb * c.a * smoothstep(0.45, 1.0, lum);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
vec4 transition(vec2 uv) {
|
|
40
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
41
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
42
|
+
// half extent of the frame along the direction
|
|
43
|
+
float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
|
|
44
|
+
float w = max(width, 0.001);
|
|
45
|
+
float s = 0.35 * w;
|
|
46
|
+
// the band starts and ends outside of the frame, with the switch out of sight
|
|
47
|
+
float margin = s + 2.0 * w;
|
|
48
|
+
float pos = -e - margin + 2.0 * (e + margin) * ease(progress);
|
|
49
|
+
// signed distance to the middle of the band: < 0 has been swept
|
|
50
|
+
float d = dot(p, dir) - pos;
|
|
51
|
+
float m = 1.0 - smoothstep(-s, s, d);
|
|
52
|
+
|
|
53
|
+
// the light ignites as it enters and dies away as it leaves: exactly none at both ends
|
|
54
|
+
float env = smoothstep(0.0, 0.2, progress) * (1.0 - smoothstep(0.8, 1.0, progress));
|
|
55
|
+
// a hot core, a thinner glint trailing behind it, and a wide soft halo
|
|
56
|
+
float core = exp(-d * d / (w * w));
|
|
57
|
+
float g = (d + 2.2 * w) / (0.3 * w);
|
|
58
|
+
float glint = 0.45 * exp(-g * g);
|
|
59
|
+
float halo = 0.35 * exp(-abs(d) / (5.0 * w));
|
|
60
|
+
float band = (core + glint + halo) * env * intensity;
|
|
61
|
+
// the moving glint itself, where the highlights bloom
|
|
62
|
+
float glow = (core + glint) * env * intensity;
|
|
63
|
+
|
|
64
|
+
vec4 c = frame(uv, m);
|
|
65
|
+
|
|
66
|
+
// the highlights near the band bloom along it: taps across the band, sampled where the band is brightest
|
|
67
|
+
vec3 bloom = vec3(0.0);
|
|
68
|
+
// spread over the band, short enough that its taps blend into a smooth glow
|
|
69
|
+
float spread = min(3.0 * w, 0.12);
|
|
70
|
+
for (int i = 0; i < TAPS; i++) {
|
|
71
|
+
float t = (float(i) + 0.5) / float(TAPS) * 2.0 - 1.0;
|
|
72
|
+
vec2 st = mirror((p + dir * (t * spread)) / vec2(ratio, 1.0) + 0.5);
|
|
73
|
+
// the image on screen where the tap reads, on the same side of the switch
|
|
74
|
+
float dq = dot((st - 0.5) * vec2(ratio, 1.0), dir) - pos;
|
|
75
|
+
bloom += (1.0 - abs(t)) * highlight(frame(st, 1.0 - smoothstep(-s, s, dq)));
|
|
76
|
+
}
|
|
77
|
+
// the sum of the tent weights
|
|
78
|
+
bloom /= 0.5 * float(TAPS);
|
|
79
|
+
|
|
80
|
+
// white at the heart of the core, tinted toward the edges of the band
|
|
81
|
+
vec3 hue = mix(color, vec3(1.0), core * core);
|
|
82
|
+
float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
83
|
+
// the light lifts the image, the bright parts more: exposure that rolls off softly to white, never clipping
|
|
84
|
+
vec3 light = hue * band * (0.3 + 0.9 * lum) + hue * bloom * glow * 4.0 + hue * core * env * intensity * 1.6;
|
|
85
|
+
vec3 rgb = 1.0 - (1.0 - c.rgb) * exp(-light);
|
|
86
|
+
// light adds to the image, not to its alpha
|
|
87
|
+
return vec4(rgb, c.a);
|
|
88
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image washes out to a blank cream card, then the incoming image develops on it like an instant photo: shadows first, faint and tinted, then its contrast and colors come up and it settles
|
|
4
|
+
// Tags: fade, color, photo, retro
|
|
5
|
+
|
|
6
|
+
// @color Color of the blank card between the two images
|
|
7
|
+
uniform vec4 card; // = vec4(0.93, 0.91, 0.85, 1.0)
|
|
8
|
+
// @range(0, 1) How long the outgoing image takes to wash out (from 10% to 70% of the transition)
|
|
9
|
+
uniform float wash; // = 0.35
|
|
10
|
+
// @range(0, 1) Strength of the cyan and magenta cast while the image develops
|
|
11
|
+
uniform float tint; // = 0.8
|
|
12
|
+
|
|
13
|
+
vec3 saturation(vec3 c, float s) {
|
|
14
|
+
float lum = dot(c, vec3(0.2126, 0.7152, 0.0722));
|
|
15
|
+
return mix(vec3(lum), c, s);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
vec4 transition(vec2 uv) {
|
|
19
|
+
vec4 a = getFromColor(uv);
|
|
20
|
+
vec4 b = getToColor(uv);
|
|
21
|
+
float p = progress;
|
|
22
|
+
if (p <= 0.0) return a;
|
|
23
|
+
if (p >= 1.0) return b;
|
|
24
|
+
|
|
25
|
+
// the card only shows where the images are: it takes the alpha of the outgoing image, then the incoming one's
|
|
26
|
+
float split = mix(0.1, 0.7, clamp(wash, 0.0, 1.0));
|
|
27
|
+
float cardAlpha = card.a * mix(a.a, b.a, smoothstep(0.6 * split, split + 0.1, p));
|
|
28
|
+
vec3 cardColor = card.rgb * cardAlpha;
|
|
29
|
+
|
|
30
|
+
// the outgoing image fades and loses its contrast into the card, its lights first
|
|
31
|
+
float w = smoothstep(0.0, split, p);
|
|
32
|
+
float fromLum = dot(a.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
33
|
+
float wl = clamp(w * (1.0 + 0.5 * fromLum), 0.0, 1.0);
|
|
34
|
+
vec3 washed = mix(a.rgb, mix(vec3(fromLum), a.rgb, 0.4), w) * a.a;
|
|
35
|
+
vec3 outgoing = mix(washed, cardColor, wl);
|
|
36
|
+
float outAlpha = mix(a.a, cardAlpha, wl);
|
|
37
|
+
|
|
38
|
+
// development of the incoming image: quick at first, then slowly settling
|
|
39
|
+
float x = clamp((p - split) / max(1.0 - split, 1e-3), 0.0, 1.0);
|
|
40
|
+
float d = 1.0 - pow(1.0 - x, 1.5);
|
|
41
|
+
float lum = dot(b.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
42
|
+
// the shadows develop first, the highlights last
|
|
43
|
+
float dev = clamp((d - 0.45 * lum) / 0.55, 0.0, 1.0);
|
|
44
|
+
dev = dev * dev * (3.0 - 2.0 * dev);
|
|
45
|
+
// low contrast and nearly no colors at first, with a cast: cyan in the shadows, magenta in the lights
|
|
46
|
+
float early = 1.0 - smoothstep(0.2, 0.95, d);
|
|
47
|
+
vec3 tinted = saturation(b.rgb, smoothstep(0.3, 1.0, d));
|
|
48
|
+
tinted = mix(vec3(0.6), tinted, mix(0.55, 1.0, d));
|
|
49
|
+
vec3 tone = mix(vec3(-0.2, 0.06, 0.1), vec3(0.12, -0.1, 0.06), smoothstep(0.15, 0.6, lum));
|
|
50
|
+
tinted += tone * tint * early;
|
|
51
|
+
vec3 incoming = mix(cardColor, clamp(tinted, 0.0, 1.0) * b.a, dev);
|
|
52
|
+
float inAlpha = mix(cardAlpha, b.a, dev);
|
|
53
|
+
|
|
54
|
+
vec3 color = p < split ? outgoing : incoming;
|
|
55
|
+
float alpha = p < split ? outAlpha : inAlpha;
|
|
56
|
+
if (alpha <= 0.0) return vec4(0.0);
|
|
57
|
+
return vec4(clamp(color / alpha, 0.0, 1.0), alpha);
|
|
58
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A plus-shaped cross grows from the center and widens its arms until the incoming image fills the frame
|
|
4
|
+
// Tags: shape, wipe, cross, plus
|
|
5
|
+
|
|
6
|
+
// @range(0, 0.1) Softness of the cross's edge
|
|
7
|
+
uniform float smoothness; // = 0.01
|
|
8
|
+
// @param Close four corner rectangles in toward the middle instead
|
|
9
|
+
uniform bool reverse; // = false
|
|
10
|
+
|
|
11
|
+
float boxDist (vec2 p, vec2 halfSize) {
|
|
12
|
+
vec2 d = abs(p) - halfSize;
|
|
13
|
+
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 1 inside the cross at time t, 0 outside
|
|
17
|
+
float plus (vec2 q, float t, float s) {
|
|
18
|
+
vec2 frame = vec2(0.5 * ratio, 0.5);
|
|
19
|
+
float k = min(frame.x, frame.y);
|
|
20
|
+
// The arms start equally thick, then widen with the frame's proportions,
|
|
21
|
+
// so the four corners left uncovered vanish together
|
|
22
|
+
vec2 halfWidth = k * t + (frame - k) * t * t;
|
|
23
|
+
// The arms reach out at the same speed in every direction
|
|
24
|
+
float halfLength = 3.0 * max(frame.x, frame.y) * t;
|
|
25
|
+
float d = min(boxDist(q, vec2(halfLength, halfWidth.y)), boxDist(q, vec2(halfWidth.x, halfLength)));
|
|
26
|
+
// The soft edge slides from outside to inside the cross, so nothing shows at
|
|
27
|
+
// t = 0 and everything at t = 1, whatever the softness
|
|
28
|
+
return 1.0 - smoothstep(0.0, s, d + s * (1.0 - t));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
vec4 transition (vec2 uv) {
|
|
32
|
+
// Measured in square pixels, so the cross is not stretched
|
|
33
|
+
vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
|
|
34
|
+
float s = max(smoothness, 0.001);
|
|
35
|
+
float m = reverse ? 1.0 - plus(q, 1.0 - progress, s) : plus(q, progress, s);
|
|
36
|
+
return mix(getFromColor(uv), getToColor(uv), m);
|
|
37
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The incoming image pops in as a rounded card over the outgoing one, with an elastic overshoot: too big, a bit small, then it settles into the full frame as its corners square off
|
|
4
|
+
// Tags: pop, scale, zoom, elastic, bounce, shadow
|
|
5
|
+
|
|
6
|
+
// @param Point of the frame the incoming image pops from
|
|
7
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
8
|
+
// @range(0, 1.5) How far the card overshoots (too big, then a bit small) before it settles
|
|
9
|
+
uniform float bounce; // = 1.0
|
|
10
|
+
// @range(0, 0.5) Corner radius of the card while it pops, relative to its shorter side
|
|
11
|
+
uniform float corner; // = 0.12
|
|
12
|
+
// @range(0, 1) Darkness of the drop shadow the card casts on the outgoing image
|
|
13
|
+
uniform float shadow; // = 0.5
|
|
14
|
+
|
|
15
|
+
const float PI = 3.141592653589793;
|
|
16
|
+
|
|
17
|
+
// signed distance to a rounded box of half size b and corner radius r
|
|
18
|
+
float roundedBox(vec2 p, vec2 b, float r) {
|
|
19
|
+
vec2 q = abs(p) - b + r;
|
|
20
|
+
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
vec4 transition(vec2 uv) {
|
|
24
|
+
float t = progress;
|
|
25
|
+
// scale of the card: an ease-out, plus a damped spring that overshoots and lands exactly at t = 1
|
|
26
|
+
float easeOut = 1.0 - (1.0 - t) * (1.0 - t) * (1.0 - t);
|
|
27
|
+
float spring = 1.0 - exp(-1.5 * t) * cos(2.5 * PI * t) * (1.0 - t);
|
|
28
|
+
float s = mix(easeOut, spring, bounce);
|
|
29
|
+
|
|
30
|
+
// the card is the incoming frame scaled by s around the center, in aspect-corrected space
|
|
31
|
+
vec2 asp = vec2(ratio, 1.0);
|
|
32
|
+
float side = min(ratio, 1.0);
|
|
33
|
+
vec2 cardCenter = center + (0.5 - center) * s;
|
|
34
|
+
vec2 halfSize = 0.5 * s * asp;
|
|
35
|
+
float r = corner * s * side * (1.0 - t);
|
|
36
|
+
float aa = 0.002;
|
|
37
|
+
// the edge is pushed out by one antialiasing width, so at t = 1 the card covers the whole frame
|
|
38
|
+
float d = roundedBox((uv - cardCenter) * asp, halfSize, r) - aa;
|
|
39
|
+
float cover = clamp(0.5 - d / aa, 0.0, 1.0) * smoothstep(0.0, 0.08, t);
|
|
40
|
+
|
|
41
|
+
// drop shadow on the outgoing image, offset down and blurred, growing with the card
|
|
42
|
+
float k = min(s, 1.0) * side;
|
|
43
|
+
float blur = 0.05 * k + 1e-4;
|
|
44
|
+
vec2 offset = vec2(0.0, -0.03 * k);
|
|
45
|
+
float ds = roundedBox((uv - cardCenter - offset) * asp, halfSize, r);
|
|
46
|
+
float shade = shadow * (1.0 - smoothstep(-blur, blur, ds)) * smoothstep(0.0, 0.15, t);
|
|
47
|
+
|
|
48
|
+
vec4 a = getFromColor(uv);
|
|
49
|
+
// the shadow darkens the outgoing image, it does not change its alpha (no shadow on transparent areas)
|
|
50
|
+
a.rgb *= 1.0 - shade;
|
|
51
|
+
// clamped: only the antialiased rim, one pixel or two outside the card, reads past the edge
|
|
52
|
+
vec4 b = getToColor(clamp((uv - center) / max(s, 1e-4) + center, 0.0, 1.0));
|
|
53
|
+
// blend premultiplied, then back to straight alpha
|
|
54
|
+
vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), cover);
|
|
55
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
56
|
+
}
|