gl-transitions 3.1.0 → 3.2.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 +16 -0
- package/compatibility.json +96 -0
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/CircleBurst.glsl +77 -0
- package/glsl3/CodeRain.glsl +114 -0
- package/glsl3/CurtainRise.glsl +71 -0
- package/glsl3/GravityLens.glsl +66 -0
- package/glsl3/RingSpin.glsl +112 -0
- package/glsl3/SpotlightWipe.glsl +63 -0
- package/index.js +1 -1
- package/layouts.json +231 -0
- package/llms-full.txt +521 -422
- package/llms.txt +225 -219
- package/msl/CircleBurst.metal +351 -0
- package/msl/CodeRain.metal +451 -0
- package/msl/CurtainRise.metal +263 -0
- package/msl/GravityLens.metal +236 -0
- package/msl/RingSpin.metal +474 -0
- package/msl/SpotlightWipe.metal +217 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +31 -19
- package/sksl/CircleBurst.sksl +84 -0
- package/sksl/CodeRain.sksl +124 -0
- package/sksl/CurtainRise.sksl +84 -0
- package/sksl/GravityLens.sksl +77 -0
- package/sksl/RingSpin.sksl +121 -0
- package/sksl/SpotlightWipe.sksl +74 -0
- package/sksl/index.js +1 -1
- package/transitions/CircleBurst.glsl +76 -0
- package/transitions/CodeRain.glsl +113 -0
- package/transitions/CurtainRise.glsl +70 -0
- package/transitions/GravityLens.glsl +65 -0
- package/transitions/RingSpin.glsl +111 -0
- package/transitions/SpotlightWipe.glsl +62 -0
- package/wgsl/CircleBurst.wgsl +310 -0
- package/wgsl/CodeRain.wgsl +415 -0
- package/wgsl/CurtainRise.wgsl +235 -0
- package/wgsl/GravityLens.wgsl +206 -0
- package/wgsl/RingSpin.wgsl +426 -0
- package/wgsl/SpotlightWipe.wgsl +186 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// CircleBurst — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CircleBurst.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: Discs of three solid colors burst out of a point one after another, each covering the last, then a hole bursts open from the same point in the last one to reveal the incoming image
|
|
5
|
+
// Tags: circle, burst, color, reveal, motion-graphics
|
|
6
|
+
|
|
7
|
+
// @param Point the discs burst out of, in texture coordinates
|
|
8
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
9
|
+
// @color Color of the first disc
|
|
10
|
+
uniform vec4 color1; // = vec4(0.99, 0.79, 0.29, 1.0)
|
|
11
|
+
// @color Color of the second disc
|
|
12
|
+
uniform vec4 color2; // = vec4(0.95, 0.38, 0.33, 1.0)
|
|
13
|
+
// @color Color of the third disc, which opens onto the incoming image
|
|
14
|
+
uniform vec4 color3; // = vec4(0.13, 0.15, 0.3, 1.0)
|
|
15
|
+
// @range(0, 1) Delay between the discs, relative to the burst of one disc (at 0, they burst as one: a single circle opens onto the incoming image)
|
|
16
|
+
uniform float stagger; // = 0.3
|
|
17
|
+
|
|
18
|
+
// half width of the antialiased edges, in frame heights
|
|
19
|
+
const float AA = 0.0015;
|
|
20
|
+
// width and opacity of the soft shadow each disc casts on what is under it
|
|
21
|
+
const float SW = 0.03;
|
|
22
|
+
const float SO = 0.32;
|
|
23
|
+
|
|
24
|
+
// local progress of a layer starting at s and lasting d
|
|
25
|
+
float phase(float s, float d) {
|
|
26
|
+
return clamp((progress - s) / d, 0.0, 1.0);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// radius of the edge of a layer at local progress t: it bursts out of just before the point and
|
|
30
|
+
// leaves the frame still moving, its shadow last
|
|
31
|
+
float radius(float t, float R) {
|
|
32
|
+
float u = 1.0 - t;
|
|
33
|
+
return mix(-SW - AA, R, mix(t, 1.0 - u * u * u, 0.8));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// fold texture coordinates back into the frame
|
|
37
|
+
vec2 mirror(vec2 v) {
|
|
38
|
+
return 1.0 - abs(1.0 - mod(abs(v), 2.0));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// a layer of color c and radius r laid over p (premultiplied), with its shadow around it, at distance x
|
|
42
|
+
vec4 layer(vec4 p, vec4 c, float r, float x) {
|
|
43
|
+
float k = smoothstep(r - AA, r + AA, x);
|
|
44
|
+
float s = SO * c.a * k * (1.0 - smoothstep(0.0, SW, x - r));
|
|
45
|
+
p = p * (1.0 - s) + vec4(0.0, 0.0, 0.0, s);
|
|
46
|
+
k = c.a * (1.0 - k);
|
|
47
|
+
return p * (1.0 - k) + vec4(c.rgb, 1.0) * k;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
vec4 transition(vec2 uv) {
|
|
51
|
+
vec2 asp = vec2(ratio, 1.0);
|
|
52
|
+
float x = length((uv - center) * asp);
|
|
53
|
+
// past the farthest corner, with room for the shadows
|
|
54
|
+
float R = length(max(center, 1.0 - center) * asp) + SW + AA;
|
|
55
|
+
float k = clamp(stagger, 0.0, 1.0);
|
|
56
|
+
float d = 1.0 / (1.0 + 3.0 * k);
|
|
57
|
+
|
|
58
|
+
// the outgoing image is pushed in by the first burst
|
|
59
|
+
float t = phase(0.0, d);
|
|
60
|
+
vec4 a = getFromColor(mirror(center + (uv - center) / (1.0 + 0.06 * t * (2.0 - t))));
|
|
61
|
+
vec4 p = vec4(a.rgb * a.a, a.a);
|
|
62
|
+
p = layer(p, color1, radius(t, R), x);
|
|
63
|
+
p = layer(p, color2, radius(phase(k * d, d), R), x);
|
|
64
|
+
float r = radius(phase(2.0 * k * d, d), R);
|
|
65
|
+
p = layer(p, color3, r, x);
|
|
66
|
+
|
|
67
|
+
// the hole in the last disc shows the incoming image, which pops in slightly zoomed, overshoots
|
|
68
|
+
// and settles, shaded along the hole's rim as much as the disc around it is wide
|
|
69
|
+
t = phase(3.0 * k * d, d);
|
|
70
|
+
float h = radius(t, R);
|
|
71
|
+
float u = 1.0 - t;
|
|
72
|
+
vec4 b = getToColor(mirror(center + (uv - center) / (1.0 + 0.14 * u * u * (1.0 - 2.4 * t))));
|
|
73
|
+
float s = SO * color3.a * clamp((r - h) / SW, 0.0, 1.0) * (1.0 - smoothstep(0.0, SW, h - x));
|
|
74
|
+
vec4 q = vec4(b.rgb * b.a * (1.0 - s), b.a * (1.0 - s) + s);
|
|
75
|
+
p = mix(p, q, 1.0 - smoothstep(h - AA, h + AA, x));
|
|
76
|
+
return p.a > 0.0 ? vec4(p.rgb / p.a, p.a) : vec4(0.0);
|
|
77
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// CodeRain — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CodeRain.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image darkens into a grid of flickering code characters tinted by its colors, then glowing streams of characters fall down the columns at their own speeds, each with a bright head and a fading tail, leaving the incoming image behind
|
|
5
|
+
// Tags: text, digital, rain, reveal
|
|
6
|
+
|
|
7
|
+
// @range(0.02, 0.1) Height of a character, in frame heights
|
|
8
|
+
uniform float cellSize; // = 0.045
|
|
9
|
+
// @range(0.05, 1) Average length of the streams' fading tails, in frame heights
|
|
10
|
+
uniform float trail; // = 0.5
|
|
11
|
+
// @range(0, 1) How much the characters of the outgoing image take its colors, instead of the glow color
|
|
12
|
+
uniform float tint; // = 0.5
|
|
13
|
+
// @color Color of the falling streams and their glow
|
|
14
|
+
uniform vec4 glow; // = vec4(0.2, 1.0, 0.4, 1.0)
|
|
15
|
+
|
|
16
|
+
float hash12(vec2 p) {
|
|
17
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
18
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
19
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
vec4 hash42(vec2 p) {
|
|
23
|
+
vec4 p4 = fract(vec4(p.xyxy) * vec4(0.1031, 0.1030, 0.0973, 0.1099));
|
|
24
|
+
p4 += dot(p4, p4.wzxy + 33.33);
|
|
25
|
+
return fract((p4.xxyz + p4.yzzw) * p4.zywx);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 1 inside a stroke, fading out from 0.3 to 0.6 dot of distance
|
|
29
|
+
vec4 band(vec4 d) {
|
|
30
|
+
return 1.0 - smoothstep(0.3, 0.6, d);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// coverage of the character of this cell at this time, drawn on a 5x7 dot grid in a 6x8 cell
|
|
34
|
+
// (local: 0..1 in the cell, from its top left), made of strokes picked by hashes
|
|
35
|
+
float glyph(vec2 cell, float t, vec2 local) {
|
|
36
|
+
vec2 b = local * vec2(6.0, 8.0) - 0.5;
|
|
37
|
+
float x = b.x;
|
|
38
|
+
float y = b.y;
|
|
39
|
+
float d = 0.667 * y;
|
|
40
|
+
// how far outside the spans 0..4, 0..6, 0..3 and 3..6, in dots
|
|
41
|
+
float x04 = abs(x - 2.0) - 2.0;
|
|
42
|
+
float y06 = abs(y - 3.0) - 3.0;
|
|
43
|
+
float y03 = abs(y - 1.5) - 1.5;
|
|
44
|
+
float y36 = abs(y - 4.5) - 1.5;
|
|
45
|
+
vec2 seed = cell + t * vec2(37.0, 61.0);
|
|
46
|
+
// strokes: three bars and a diagonal, the halves of the side verticals,
|
|
47
|
+
// the halves of the middle vertical, the other diagonal and a short bar
|
|
48
|
+
vec4 sa = band(abs(vec4(y, y - 3.0, y - 6.0, x - d))) * band(vec4(x04, x04, x04, y06));
|
|
49
|
+
vec4 sb = band(abs(vec4(x, x, x - 4.0, x - 4.0))) * band(vec4(y03, y36, y03, y36));
|
|
50
|
+
vec4 sc = band(abs(vec4(x - 2.0, x - 2.0, x + d - 4.0, y - 1.0))) * band(vec4(y03, y36, y06, abs(x - 2.0) - 1.0));
|
|
51
|
+
float on = dot(step(0.68, hash42(seed)), sa);
|
|
52
|
+
on += dot(step(0.68, hash42(seed + 41.0)), sb);
|
|
53
|
+
on += dot(step(0.68, hash42(seed + 83.0)), sc);
|
|
54
|
+
return min(on, 1.0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
vec4 transition(vec2 uv) {
|
|
58
|
+
float h = max(cellSize, 0.005);
|
|
59
|
+
vec2 dims = vec2(0.75 * h, h);
|
|
60
|
+
// frame coordinates from the top left, in frame heights
|
|
61
|
+
vec2 fp = vec2(uv.x * ratio, 1.0 - uv.y);
|
|
62
|
+
// (shifted by odd fractions of a cell, so that pixel centers don't fall on its lines at usual sizes)
|
|
63
|
+
vec2 grid = fp / dims + vec2(0.389, 0.278);
|
|
64
|
+
vec2 cell = floor(grid);
|
|
65
|
+
vec2 local = grid - cell;
|
|
66
|
+
float rc = hash12(cell + vec2(97.0, 131.0));
|
|
67
|
+
|
|
68
|
+
// each column has its own stream: its start, speed and tail length
|
|
69
|
+
float r1 = hash12(vec2(cell.x, 11.0));
|
|
70
|
+
float r2 = hash12(vec2(cell.x, 23.0));
|
|
71
|
+
float r3 = hash12(vec2(cell.x, 37.0));
|
|
72
|
+
float T = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.5);
|
|
73
|
+
float len = max(trail, 0.01) * (0.5 + r3);
|
|
74
|
+
float u = clamp((T - 0.03 - 0.5 * r1) / (0.3 + 0.12 * r2), 0.0, 1.0);
|
|
75
|
+
// the head falls from above the frame, speeding up a little, until its tail has left the frame
|
|
76
|
+
float head = mix(-0.2, 1.0 + h + len, u * (0.7 + 0.3 * u));
|
|
77
|
+
// how far the head has gone past the cell's top
|
|
78
|
+
float dy = head - (cell.y - 0.278) * h;
|
|
79
|
+
|
|
80
|
+
vec4 a = getFromColor(uv);
|
|
81
|
+
vec4 b = getToColor(uv);
|
|
82
|
+
|
|
83
|
+
// ahead of the stream: the outgoing image darkens into characters tinted by its cell's color,
|
|
84
|
+
// over time and as the head comes near
|
|
85
|
+
vec2 cuv = clamp(vec2((cell.x + 0.111) * dims.x / ratio, 1.0 - (cell.y + 0.222) * h), 0.0, 1.0);
|
|
86
|
+
vec4 ca = getFromColor(cuv);
|
|
87
|
+
float lum = dot(ca.rgb, vec3(0.299, 0.587, 0.114));
|
|
88
|
+
vec3 hue = ca.rgb / max(max(ca.r, max(ca.g, ca.b)), 0.05);
|
|
89
|
+
vec3 ink = mix(glow.rgb * glow.a, hue, tint) * (0.1 + 0.6 * lum);
|
|
90
|
+
float near = smoothstep(-0.15, 0.0, dy);
|
|
91
|
+
float dim = max(smoothstep(0.0, 0.3, T), near);
|
|
92
|
+
float g = max(smoothstep(0.0, 0.2, T - 0.12 * rc), near);
|
|
93
|
+
float passed = step(0.0, dy);
|
|
94
|
+
// the characters change slowly ahead of the stream and fast in it
|
|
95
|
+
float slow = mod(floor(T * 12.0 + rc * 7.0), 32.0);
|
|
96
|
+
float fast = 32.0 + mod(floor(T * 40.0 + rc * 13.0), 32.0);
|
|
97
|
+
float chr = glyph(cell, mix(slow, fast, passed), local);
|
|
98
|
+
vec3 code = a.rgb * (1.0 - 0.8 * dim) + ink * chr * g;
|
|
99
|
+
|
|
100
|
+
// behind the head: bright characters changing fast, fading along the tail, over a shadow that
|
|
101
|
+
// clears in the tail's last two thirds to leave the incoming image
|
|
102
|
+
float fade = clamp(1.0 - dy / len, 0.0, 1.0);
|
|
103
|
+
float shade = 1.0 - smoothstep(0.3 * len, len, dy);
|
|
104
|
+
float hot = 1.0 - smoothstep(h, 3.0 * h, dy);
|
|
105
|
+
vec3 col = mix(glow.rgb * 1.2, vec3(1.0), 0.8 * hot) * glow.a;
|
|
106
|
+
vec3 stream = b.rgb * (1.0 - 0.8 * shade) + col * chr * (fade * (2.0 - fade) + hot * fade);
|
|
107
|
+
|
|
108
|
+
// a soft glow around the head, within its column
|
|
109
|
+
float yy = (head - fp.y) / (1.5 * h);
|
|
110
|
+
float halo = 1.6 * u * (1.0 - u) * exp(-yy * yy) * (1.0 - smoothstep(0.25, 0.5, abs(local.x - 0.5)));
|
|
111
|
+
vec3 rgb = mix(code, stream, passed) + glow.rgb * glow.a * halo;
|
|
112
|
+
// the outgoing image's opacity stays under the tail's shadow, then gives way to the incoming one's
|
|
113
|
+
return vec4(clamp(rgb, 0.0, 1.0), mix(a.a, mix(b.a, a.a, shade), passed));
|
|
114
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// CurtainRise — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CurtainRise.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image rises like a theater festoon curtain: cords lift its hem into scalloped swags while the fabric gathers into shaded ruffles, and it is drawn up out of the frame over the incoming image
|
|
5
|
+
// Tags: 3d, fold, vertical
|
|
6
|
+
|
|
7
|
+
// @range(1, 8, 1) Number of swags across a 16:9 frame (fewer in a portrait image)
|
|
8
|
+
uniform float swags; // = 3.0
|
|
9
|
+
// @range(0, 0.3) How low each swag droops between two cords, as a part of the frame's height
|
|
10
|
+
uniform float sag; // = 0.14
|
|
11
|
+
// @range(4, 30, 1) Number of gathered ruffles in the fabric
|
|
12
|
+
uniform float ruffles; // = 14.0
|
|
13
|
+
// @range(0, 1) Depth of the shading on the ruffles and swags, and of the shadow under the hem
|
|
14
|
+
uniform float shading; // = 0.7
|
|
15
|
+
|
|
16
|
+
const float PI = 3.141592653589793;
|
|
17
|
+
|
|
18
|
+
vec4 transition (vec2 uv) {
|
|
19
|
+
float p = progress;
|
|
20
|
+
// the fabric gathers early, then the cords pull it up
|
|
21
|
+
float f = 1.0 - (1.0 - p) * (1.0 - p) * (1.0 - p);
|
|
22
|
+
// the cords start pulling at once and are fastest midway
|
|
23
|
+
float e = mix(p, p * p * (3.0 - 2.0 * p), 0.4);
|
|
24
|
+
float s = sag * f;
|
|
25
|
+
float lift = mix(-0.01, 1.0 + sag + 0.08, e);
|
|
26
|
+
// across a swag, -1 and 1 at the cords
|
|
27
|
+
float n = max(1.0, floor(swags * sqrt(ratio / 1.78) + 0.5)); // fewer swags in portrait
|
|
28
|
+
float u = fract(uv.x * n) * 2.0 - 1.0;
|
|
29
|
+
float bump = 1.0 - u * u;
|
|
30
|
+
float hem = lift - s * bump;
|
|
31
|
+
float aa = 0.002 + 0.004 * f;
|
|
32
|
+
float inside = smoothstep(hem - aa, hem + aa, uv.y);
|
|
33
|
+
|
|
34
|
+
vec4 c = vec4(0.0);
|
|
35
|
+
if (inside > 0.0) {
|
|
36
|
+
// q goes from 0 at the top rod to 1 at the hem; the whole height of fabric is gathered into it
|
|
37
|
+
float h = max(1.0 - max(hem, 0.0), 1e-4);
|
|
38
|
+
float q = clamp((1.0 - uv.y) / h, 0.0, 1.0);
|
|
39
|
+
// ruffles: the fabric bunches where cos(a) > 0, rows parallel to the scalloped hem
|
|
40
|
+
// as the curtain shortens, its ruffles merge so none gets thinner than 2% of the frame
|
|
41
|
+
float m = min(max(1.0, floor(ruffles + 0.5)), h / 0.02);
|
|
42
|
+
float a = 2.0 * PI * m * q;
|
|
43
|
+
// the ruffles puff out most in the middle of each swag
|
|
44
|
+
float g = 0.85 * f * min(1.0, 0.3 + 5.0 * (1.0 - h)) * (0.6 + 0.4 * bump);
|
|
45
|
+
float v = clamp(q + g * sin(a) / (2.0 * PI * m), 0.0, 1.0);
|
|
46
|
+
// the fabric is also pulled in toward the cords near the hem
|
|
47
|
+
float pull = 0.25 * f * q * q * sin(PI * u) / (PI * n);
|
|
48
|
+
c = getFromColor(vec2(uv.x - pull, 1.0 - v));
|
|
49
|
+
|
|
50
|
+
// light from the front and a bit above
|
|
51
|
+
float slope = 2.5 * g * cos(a);
|
|
52
|
+
float diffuse = (1.0 - 0.35 * slope) / sqrt(1.0 + slope * slope);
|
|
53
|
+
float crease = 0.5 + 0.5 * sin(a);
|
|
54
|
+
float light = mix(1.0, diffuse * (1.0 - 0.45 * crease * crease), shading * g);
|
|
55
|
+
// a soft sheen on the crest of each ruffle
|
|
56
|
+
light += 0.18 * shading * g * smoothstep(0.4, 1.0, -cos(a));
|
|
57
|
+
// each swag bulges toward the light in its middle and is pinched dark along the cords
|
|
58
|
+
float depth = f * q * (0.3 + 0.7 * q);
|
|
59
|
+
light *= 1.0 - shading * depth * (0.35 * u * u + 0.5 * exp(-(1.0 - abs(u)) * 14.0));
|
|
60
|
+
// the hem rolls under a little
|
|
61
|
+
light *= 1.0 - 0.35 * shading * f * exp(-(uv.y - hem) * 120.0);
|
|
62
|
+
c.rgb *= light;
|
|
63
|
+
if (inside >= 1.0) return c;
|
|
64
|
+
}
|
|
65
|
+
vec4 to = getToColor(uv);
|
|
66
|
+
// soft shadow of the curtain just under its hem
|
|
67
|
+
float below = max(hem - uv.y, 0.0);
|
|
68
|
+
float shadow = 0.6 * shading * exp(-below * 22.0) * smoothstep(0.0, 0.05, lift) * (1.0 - smoothstep(1.0, 1.06, lift - s));
|
|
69
|
+
to.rgb *= 1.0 - shadow;
|
|
70
|
+
return mix(to, c, inside);
|
|
71
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// GravityLens — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/GravityLens.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: A black disk appears and grows, bending the outgoing image around it like a heavy mass bends light: the image is stretched into a bright ring at the disk's edge and swallowed until the frame is black, then the disk shrinks back, unbending the incoming image
|
|
5
|
+
// Tags: distort, lens, space, circular, dark
|
|
6
|
+
|
|
7
|
+
// Center of the disk
|
|
8
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
9
|
+
// @range(0, 1.5) How strongly the light bends: radius of the lensed ring beyond the disk's edge, in disk radii
|
|
10
|
+
uniform float strength; // = 0.6
|
|
11
|
+
// @range(0, 1) Brightness of the lensed ring and of the thin ring of light hugging the disk's edge
|
|
12
|
+
uniform float glow; // = 0.6
|
|
13
|
+
// @color Color of the disk
|
|
14
|
+
uniform vec4 hole; // = vec4(0.0, 0.0, 0.0, 1.0)
|
|
15
|
+
|
|
16
|
+
// how far past the farthest corner the disk grows, so the frame is fully covered for a brief moment
|
|
17
|
+
const float OVERSHOOT = 0.12;
|
|
18
|
+
// moment the frame is black: the swallow takes a little longer than the release
|
|
19
|
+
const float PEAK = 0.55;
|
|
20
|
+
// half width of the antialiased edge of the disk, in frame heights
|
|
21
|
+
const float AA = 0.002;
|
|
22
|
+
// tint of the light piled up around the disk
|
|
23
|
+
const vec3 WARM = vec3(1.0, 0.86, 0.68);
|
|
24
|
+
|
|
25
|
+
// fold the coordinates back into the frame, so the image stays filled without smearing its border
|
|
26
|
+
vec2 mirrored(vec2 v) {
|
|
27
|
+
vec2 m = mod(v, 2.0);
|
|
28
|
+
return mix(m, 2.0 - m, step(1.0, m));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
vec4 transition(vec2 uv) {
|
|
32
|
+
// the disk grows with an accelerating swallow, then shrinks back a little faster: exactly 0 at both ends
|
|
33
|
+
bool swallowing = progress < PEAK;
|
|
34
|
+
float u = swallowing ? progress / PEAK : (1.0 - progress) / (1.0 - PEAK);
|
|
35
|
+
float u2 = u * u;
|
|
36
|
+
float k = u2 * (0.6 + 0.4 * u2);
|
|
37
|
+
|
|
38
|
+
// measured in frame heights, so the disk is round
|
|
39
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
40
|
+
vec2 far = max(center, 1.0 - center) * aspect;
|
|
41
|
+
float rh = length(far) * (1.0 + OVERSHOOT) * k;
|
|
42
|
+
// radius where the light coming from right behind the disk shows up as a ring
|
|
43
|
+
float re = rh * (1.0 + max(strength, 0.0));
|
|
44
|
+
|
|
45
|
+
vec2 d = (uv - center) * aspect;
|
|
46
|
+
float r = max(length(d), 1e-5);
|
|
47
|
+
// a point mass deflects the light by an angle falling off as 1/r
|
|
48
|
+
vec2 q = mirrored(center + d * (1.0 - re * re / (r * r)) / aspect);
|
|
49
|
+
vec4 c = swallowing ? getFromColor(q) : getToColor(q);
|
|
50
|
+
// the shading fades in with the disk, so it is exactly 0 at both ends
|
|
51
|
+
float amount = smoothstep(0.0, 0.04, rh);
|
|
52
|
+
// the second, flipped image squeezed between the ring and the disk is dimmer
|
|
53
|
+
float inner = clamp((r - rh) / (re - rh + 1e-4), 0.0, 1.0);
|
|
54
|
+
c.rgb *= 1.0 - 0.7 * amount * (1.0 - inner * inner * (3.0 - 2.0 * inner));
|
|
55
|
+
|
|
56
|
+
// light piles up into a ring where the image is most stretched, and into a thin ring hugging the edge
|
|
57
|
+
float g = max(glow, 0.0) * amount;
|
|
58
|
+
float einstein = (r - re) / (0.3 * (re - rh) + 0.01);
|
|
59
|
+
float photon = max(r - rh, 0.0) / (0.006 + 0.012 * rh);
|
|
60
|
+
float light = g * (0.7 * exp(-einstein * einstein) + 1.6 * exp(-photon * photon));
|
|
61
|
+
c.rgb = min(c.rgb * (1.0 + light) + WARM * (0.35 * light * c.a), vec3(1.0));
|
|
62
|
+
|
|
63
|
+
// antialiased horizon, kept inside the disk so it vanishes with it
|
|
64
|
+
float cov = clamp((rh - r) / (2.0 * AA), 0.0, 1.0);
|
|
65
|
+
return mix(c, hole, cov);
|
|
66
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// RingSpin — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/RingSpin.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The frame is cut into concentric rings that spin like the dials of a combination lock, in alternating directions and blurred with speed, one after another from the center outward; each ring overshoots a little and locks into place on the incoming image
|
|
5
|
+
// Tags: rotate, circle, rings, motion-blur
|
|
6
|
+
|
|
7
|
+
// @range(2, 12, 1) Number of rings, from the center to the farthest corner
|
|
8
|
+
uniform int rings; // = 6
|
|
9
|
+
// @param Square rings, like nested frames, instead of round ones
|
|
10
|
+
uniform bool square; // = false
|
|
11
|
+
// @range(1, 3, 1) Full turns made by each ring
|
|
12
|
+
uniform int turns; // = 1
|
|
13
|
+
// @range(0, 0.8) Delay between the first ring and the last one, as a part of the transition
|
|
14
|
+
uniform float stagger; // = 0.5
|
|
15
|
+
// @range(0, 1) Amount of angular motion blur while the rings spin fast
|
|
16
|
+
uniform float blur; // = 0.6
|
|
17
|
+
// @range(0, 1) Size of the overshoot when a ring locks
|
|
18
|
+
uniform float settle; // = 0.5
|
|
19
|
+
|
|
20
|
+
const float PI = 3.141592653589793;
|
|
21
|
+
// part of a ring's time spent overshooting and coming back
|
|
22
|
+
const float SETTLE = 0.2;
|
|
23
|
+
// half width of the gaps between the rings, width of their rims and of the anti-aliased edges, in frame heights
|
|
24
|
+
const float GAP = 0.0035;
|
|
25
|
+
const float RIM = 0.012;
|
|
26
|
+
const float EDGE = 0.0015;
|
|
27
|
+
|
|
28
|
+
vec2 mirrorUV(vec2 v) {
|
|
29
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
vec2 rotate(vec2 v, float a) {
|
|
33
|
+
float c = cos(a), s = sin(a);
|
|
34
|
+
return vec2(c * v.x + s * v.y, c * v.y - s * v.x);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// the delay between two rings, kept shorter than the time a ring moves so that the motion never pauses
|
|
38
|
+
float ringDelay(float n) {
|
|
39
|
+
float m = max(n - 1.0, 1.0);
|
|
40
|
+
return min(clamp(stagger, 0.0, 0.8) / m, 0.7 / (1.0 + 0.7 * m));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// local time of ring i: 0 until it starts, 1 once it is locked
|
|
44
|
+
float ringTime(float i, float n) {
|
|
45
|
+
float d = ringDelay(n);
|
|
46
|
+
return progress >= 1.0 ? 1.0 : clamp((progress - d * i) / (1.0 - d * (n - 1.0)), 0.0, 1.0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// how much a ring is moving, which opens the gaps around it
|
|
50
|
+
float activity(float i, float n) {
|
|
51
|
+
float t = ringTime(i, n);
|
|
52
|
+
return smoothstep(0.0, 0.08, t) * (1.0 - smoothstep(0.88, 1.0, t));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// the ring's angle at its time t: it speeds up, reaches `total` a little fast, overshoots and springs back
|
|
56
|
+
float spin(float t, float total) {
|
|
57
|
+
float amp = 0.1 * settle * sign(total);
|
|
58
|
+
float stopT = 1.0 - SETTLE;
|
|
59
|
+
// speed at the stop, matched with the start of the overshoot
|
|
60
|
+
float v1 = amp * PI * stopT / (total * SETTLE);
|
|
61
|
+
float u = clamp(t / stopT, 0.0, 1.0);
|
|
62
|
+
float b = clamp((t - stopT) / SETTLE, 0.0, 1.0);
|
|
63
|
+
return total * (u * u * (3.0 - 2.0 * u) + v1 * (u * u * u - u * u)) + amp * sin(PI * b) * (1.0 - b) * (1.0 - b);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
vec4 transition(vec2 uv) {
|
|
67
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
68
|
+
vec2 c = (uv - 0.5) * aspect;
|
|
69
|
+
float r = square ? max(abs(c.x), abs(c.y)) : length(c);
|
|
70
|
+
float n = clamp(float(rings), 1.0, 12.0);
|
|
71
|
+
float w = (square ? 0.5 * max(ratio, 1.0) : length(0.5 * aspect)) / n;
|
|
72
|
+
float f = r / w;
|
|
73
|
+
float i = min(floor(f), n - 1.0);
|
|
74
|
+
float t = ringTime(i, n);
|
|
75
|
+
|
|
76
|
+
vec4 col;
|
|
77
|
+
if (t <= 0.0) col = getFromColor(uv);
|
|
78
|
+
else if (t >= 1.0) col = getToColor(uv);
|
|
79
|
+
else {
|
|
80
|
+
float total = 2.0 * PI * max(float(turns), 1.0) * (mod(i, 2.0) < 0.5 ? 1.0 : -1.0);
|
|
81
|
+
float a = spin(t, total);
|
|
82
|
+
// angular speed per unit of progress, without the small overshoot; the blur spans what the ring
|
|
83
|
+
// travels in about a frame, at most a short arc so that the 8 taps stay close together
|
|
84
|
+
float u = min(t / (1.0 - SETTLE), 1.0);
|
|
85
|
+
float omega = abs(total) * 6.0 * u * (1.0 - u) / ((1.0 - SETTLE) * (1.0 - ringDelay(n) * (n - 1.0)));
|
|
86
|
+
float span = blur * min(omega * 0.015, 0.1 / max(r, 0.01));
|
|
87
|
+
// the incoming image takes over at full speed, hidden by the blur; the whole turns bring it back upright
|
|
88
|
+
float m = smoothstep(0.3, 0.5, t);
|
|
89
|
+
col = vec4(0.0);
|
|
90
|
+
float ws = 0.0;
|
|
91
|
+
for (int k = 0; k < 8; k++) {
|
|
92
|
+
float x = float(k) / 7.0 - 0.5;
|
|
93
|
+
vec2 q = mirrorUV(rotate(c, a + span * x) / aspect + 0.5);
|
|
94
|
+
vec4 s = mix(getFromColor(q), getToColor(q), m);
|
|
95
|
+
col += (1.0 - abs(x)) * s;
|
|
96
|
+
ws += 1.0 - abs(x);
|
|
97
|
+
}
|
|
98
|
+
col /= ws;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// the nearest boundary between two rings, open while one of them moves: a dark gap
|
|
102
|
+
// with a bevelled rim on each side, lit from the top left
|
|
103
|
+
float bj = clamp(floor(f + 0.5), 1.0, max(n - 1.0, 1.0));
|
|
104
|
+
float act = n > 1.5 ? max(activity(bj - 1.0, n), activity(bj, n)) : 0.0;
|
|
105
|
+
float d = (f - bj) * w;
|
|
106
|
+
vec2 nr = square ? (abs(c.x) > abs(c.y) ? vec2(sign(c.x), 0.0) : vec2(0.0, sign(c.y))) : c / max(r, 1e-4);
|
|
107
|
+
// the outer ring's inner rim faces the center, the inner ring's outer rim faces away from it
|
|
108
|
+
float light = -sign(d) * dot(nr, vec2(-0.6, 0.8)) * (1.0 - smoothstep(GAP, GAP + RIM, abs(d))) * act;
|
|
109
|
+
col.rgb = light > 0.0 ? mix(col.rgb, vec3(col.a), 0.35 * light) : col.rgb * (1.0 + 0.45 * light);
|
|
110
|
+
col.rgb *= 1.0 - 0.85 * act * (1.0 - smoothstep(GAP - EDGE, GAP + EDGE, abs(d)));
|
|
111
|
+
return col;
|
|
112
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// SpotlightWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SpotlightWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The stage lights go down on the outgoing image and a soft oval spotlight searches across it along a curved path, comes to rest and lights the incoming image inside it, then widens until the stage lights come back up on the incoming image
|
|
5
|
+
// Tags: light, spotlight, stage, iris, reveal
|
|
6
|
+
|
|
7
|
+
// @param Point where the spotlight comes to rest and opens from
|
|
8
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
9
|
+
// @range(0.08, 0.45) Width of the spotlight while it searches, in frame heights
|
|
10
|
+
uniform float size; // = 0.3
|
|
11
|
+
// @range(0, 1) How dark the stage gets around the spotlight
|
|
12
|
+
uniform float darkness; // = 0.85
|
|
13
|
+
// @color Tint of the spotlight
|
|
14
|
+
uniform vec3 warmth; // = vec3(1.0, 0.93, 0.8)
|
|
15
|
+
|
|
16
|
+
// height of the oval over its width: a cone of light hitting a stage seen at an angle
|
|
17
|
+
const float FLAT = 0.72;
|
|
18
|
+
// distance to the spotlight's center, in oval radii, inside which the incoming image is fully lit
|
|
19
|
+
const float LIT = 0.74;
|
|
20
|
+
|
|
21
|
+
// a point of the curved path the spotlight searches along, from the lower left to its resting point
|
|
22
|
+
vec2 path(float t, vec2 c) {
|
|
23
|
+
vec2 a = vec2(0.08, 0.3);
|
|
24
|
+
vec2 b = vec2(0.35, 1.15);
|
|
25
|
+
vec2 d = vec2(1.05, 0.95);
|
|
26
|
+
float s = 1.0 - t;
|
|
27
|
+
return s * s * s * a + 3.0 * s * s * t * b + 3.0 * s * t * t * d + t * t * t * c;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
vec4 transition(vec2 uv) {
|
|
31
|
+
vec2 asp = vec2(ratio, 1.0);
|
|
32
|
+
float p = progress;
|
|
33
|
+
|
|
34
|
+
// the spotlight slides along its path and eases to rest, its last few steps overlapping the start
|
|
35
|
+
// of its widening so the motion never stops
|
|
36
|
+
float t = clamp(p / 0.5, 0.0, 1.0);
|
|
37
|
+
t = t * t * (3.0 - 2.0 * t);
|
|
38
|
+
vec2 c = path(t, center);
|
|
39
|
+
|
|
40
|
+
// it widens until its lit core covers the farthest corner of the frame
|
|
41
|
+
vec2 far = max(center, 1.0 - center) * asp;
|
|
42
|
+
float full = length(vec2(far.x, far.y / FLAT)) / LIT;
|
|
43
|
+
float g = smoothstep(0.44, 1.0, p);
|
|
44
|
+
float radius = mix(0.5 * size, full, g * (0.3 + 0.7 * g));
|
|
45
|
+
|
|
46
|
+
// distance to the spotlight's center, 1 on the oval's edge
|
|
47
|
+
vec2 q = (uv - c) * asp;
|
|
48
|
+
float r = length(vec2(q.x, q.y / FLAT)) / radius;
|
|
49
|
+
|
|
50
|
+
// light of the spotlight: a flat core, a soft penumbra, a slightly brighter rim and a faint spill
|
|
51
|
+
float core = 1.0 - smoothstep(0.72, 1.08, r);
|
|
52
|
+
float ring = (r - 0.9) / 0.09;
|
|
53
|
+
float spot = max(core * (1.0 - 0.1 * r * r), 0.12 * (1.0 - smoothstep(0.9, 2.4, r))) + 0.16 * exp(-ring * ring);
|
|
54
|
+
|
|
55
|
+
// the stage lights go down at the start and come back up at the end
|
|
56
|
+
float s = darkness * smoothstep(0.0, 0.18, p) * (1.0 - smoothstep(0.72, 1.0, p));
|
|
57
|
+
vec3 light = 1.0 - s + s * spot * warmth;
|
|
58
|
+
|
|
59
|
+
// as it comes to rest, the spotlight lights the incoming image inside it
|
|
60
|
+
float lit = smoothstep(0.42, 0.58, p) * (1.0 - smoothstep(LIT, 1.0, r));
|
|
61
|
+
vec4 col = mix(getFromColor(uv), getToColor(uv), lit);
|
|
62
|
+
return vec4(col.rgb * light, col.a);
|
|
63
|
+
}
|