gl-transitions 2.0.0 → 2.1.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 +40 -0
- package/compatibility.json +290 -0
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/ApertureWipe.glsl +45 -0
- package/glsl3/Comb.glsl +26 -0
- package/glsl3/Curtains.glsl +47 -0
- package/glsl3/DiamondWipe.glsl +21 -0
- package/glsl3/DitherDissolve.glsl +27 -0
- package/glsl3/FallOver.glsl +36 -0
- package/glsl3/Fisheye.glsl +23 -0
- package/glsl3/Halftone.glsl +49 -0
- package/glsl3/Honeycomb.glsl +55 -0
- package/glsl3/PaperTear.glsl +76 -0
- package/glsl3/Prisms.glsl +81 -0
- package/glsl3/Puzzle.glsl +124 -0
- package/glsl3/Shred.glsl +67 -0
- package/glsl3/SpiralWipe.glsl +41 -0
- package/glsl3/Tunnel.glsl +42 -0
- package/glsl3/TvRoll.glsl +43 -0
- package/glsl3/TvTurnOff.glsl +47 -0
- package/glsl3/WhipPan.glsl +50 -0
- package/index.js +1 -1
- package/layouts.json +528 -0
- package/llms-full.txt +520 -256
- package/llms.txt +154 -136
- package/msl/ApertureWipe.metal +193 -0
- package/msl/Comb.metal +167 -0
- package/msl/Curtains.metal +207 -0
- package/msl/DiamondWipe.metal +123 -0
- package/msl/DitherDissolve.metal +157 -0
- package/msl/FallOver.metal +192 -0
- package/msl/Fisheye.metal +121 -0
- package/msl/Halftone.metal +230 -0
- package/msl/Honeycomb.metal +263 -0
- package/msl/PaperTear.metal +373 -0
- package/msl/Prisms.metal +424 -0
- package/msl/Puzzle.metal +632 -0
- package/msl/Shred.metal +294 -0
- package/msl/SpiralWipe.metal +196 -0
- package/msl/Tunnel.metal +207 -0
- package/msl/TvRoll.metal +205 -0
- package/msl/TvTurnOff.metal +238 -0
- package/msl/WhipPan.metal +218 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +52 -34
- package/sksl/ApertureWipe.sksl +56 -0
- package/sksl/Comb.sksl +39 -0
- package/sksl/Curtains.sksl +60 -0
- package/sksl/DiamondWipe.sksl +34 -0
- package/sksl/DitherDissolve.sksl +39 -0
- package/sksl/FallOver.sksl +49 -0
- package/sksl/Fisheye.sksl +36 -0
- package/sksl/Halftone.sksl +61 -0
- package/sksl/Honeycomb.sksl +64 -0
- package/sksl/PaperTear.sksl +82 -0
- package/sksl/Prisms.sksl +94 -0
- package/sksl/Puzzle.sksl +134 -0
- package/sksl/Shred.sksl +79 -0
- package/sksl/SpiralWipe.sksl +51 -0
- package/sksl/Tunnel.sksl +55 -0
- package/sksl/TvRoll.sksl +55 -0
- package/sksl/TvTurnOff.sksl +59 -0
- package/sksl/WhipPan.sksl +62 -0
- package/sksl/index.js +1 -1
- package/transitions/ApertureWipe.glsl +44 -0
- package/transitions/Comb.glsl +25 -0
- package/transitions/Curtains.glsl +46 -0
- package/transitions/DiamondWipe.glsl +20 -0
- package/transitions/DitherDissolve.glsl +26 -0
- package/transitions/FallOver.glsl +35 -0
- package/transitions/Fisheye.glsl +22 -0
- package/transitions/Halftone.glsl +48 -0
- package/transitions/Honeycomb.glsl +54 -0
- package/transitions/PaperTear.glsl +75 -0
- package/transitions/Prisms.glsl +80 -0
- package/transitions/Puzzle.glsl +123 -0
- package/transitions/Shred.glsl +66 -0
- package/transitions/SpiralWipe.glsl +40 -0
- package/transitions/Tunnel.glsl +41 -0
- package/transitions/TvRoll.glsl +42 -0
- package/transitions/TvTurnOff.glsl +46 -0
- package/transitions/WhipPan.glsl +49 -0
- package/wgsl/ApertureWipe.wgsl +160 -0
- package/wgsl/Comb.wgsl +139 -0
- package/wgsl/Curtains.wgsl +179 -0
- package/wgsl/DiamondWipe.wgsl +94 -0
- package/wgsl/DitherDissolve.wgsl +123 -0
- package/wgsl/FallOver.wgsl +164 -0
- package/wgsl/Fisheye.wgsl +93 -0
- package/wgsl/Halftone.wgsl +196 -0
- package/wgsl/Honeycomb.wgsl +222 -0
- package/wgsl/PaperTear.wgsl +324 -0
- package/wgsl/Prisms.wgsl +385 -0
- package/wgsl/Puzzle.wgsl +587 -0
- package/wgsl/Shred.wgsl +259 -0
- package/wgsl/SpiralWipe.wgsl +165 -0
- package/wgsl/Tunnel.wgsl +177 -0
- package/wgsl/TvRoll.wgsl +165 -0
- package/wgsl/TvTurnOff.wgsl +196 -0
- package/wgsl/WhipPan.wgsl +177 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// ApertureWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ApertureWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: A camera aperture opens its turning blades to reveal the incoming image
|
|
5
|
+
// Tags: shape, wipe, iris, rotate
|
|
6
|
+
|
|
7
|
+
#define PI 3.141592653589793
|
|
8
|
+
|
|
9
|
+
// @range(3, 12) Number of blades
|
|
10
|
+
uniform int blades; // = 6
|
|
11
|
+
// @range(-180, 180) How much the blades turn while opening, in degrees
|
|
12
|
+
uniform float rotation; // = 60.0
|
|
13
|
+
// @range(0, 1) How dark the blades are shaded along their edges
|
|
14
|
+
uniform float shadow; // = 0.5
|
|
15
|
+
|
|
16
|
+
const float AA = 0.006;
|
|
17
|
+
|
|
18
|
+
vec4 transition (vec2 uv) {
|
|
19
|
+
// Square pixels, normalized so the frame's corners are at distance 1
|
|
20
|
+
vec2 q = (uv - 0.5) * vec2(ratio, 1.0) / (0.5 * length(vec2(ratio, 1.0)));
|
|
21
|
+
float n = clamp(float(blades), 3.0, 12.0);
|
|
22
|
+
float sector = 2.0 * PI / n;
|
|
23
|
+
float turn = radians(rotation) * progress;
|
|
24
|
+
// Each blade's straight edge is at distance r from the center: the opening is the polygon they enclose
|
|
25
|
+
float r = mix(-AA, 1.0 + AA, progress);
|
|
26
|
+
float dist = -1e3;
|
|
27
|
+
float seam = 0.0;
|
|
28
|
+
for (int i = 0; i < 12; i++) {
|
|
29
|
+
if (float(i) < n) {
|
|
30
|
+
float angle = turn + float(i) * sector;
|
|
31
|
+
float d = dot(q, vec2(cos(angle), sin(angle))) - r;
|
|
32
|
+
float next = dot(q, vec2(cos(angle + sector), sin(angle + sector))) - r;
|
|
33
|
+
dist = max(dist, d);
|
|
34
|
+
// Past its corner, the edge of a blade lies over the next blade and casts a shadow on it
|
|
35
|
+
float s = 1.0 - smoothstep(0.0, 0.12, -d);
|
|
36
|
+
seam = max(seam, (1.0 - smoothstep(0.0, AA, d)) * s * s * smoothstep(0.0, AA, next));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// The blades are also shaded along the opening; the shading fades in as the aperture starts to open
|
|
40
|
+
float rim = 1.0 - smoothstep(0.0, 0.08, dist);
|
|
41
|
+
float shade = shadow * max(rim * rim, seam) * smoothstep(0.0, 0.1, progress);
|
|
42
|
+
vec4 from = getFromColor(uv);
|
|
43
|
+
from.rgb *= 1.0 - shade;
|
|
44
|
+
return mix(from, getToColor(uv), 1.0 - smoothstep(0.0, AA, dist));
|
|
45
|
+
}
|
package/glsl3/Comb.glsl
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Comb — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Comb.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The frame is cut into interleaved strips that slide in opposite directions, each pushing the outgoing image out and the incoming one in
|
|
5
|
+
// Tags: slide, stripes, push, horizontal
|
|
6
|
+
|
|
7
|
+
// @range(2, 40, 1) Number of strips
|
|
8
|
+
uniform int strips; // = 10
|
|
9
|
+
// @param Cut the frame into columns that slide up and down instead
|
|
10
|
+
uniform bool vertical; // = false
|
|
11
|
+
|
|
12
|
+
vec4 transition (vec2 uv) {
|
|
13
|
+
// a: the axis along which the strips slide, b: the axis across them
|
|
14
|
+
float a = vertical ? uv.y : uv.x;
|
|
15
|
+
float b = vertical ? uv.x : uv.y;
|
|
16
|
+
// alternate strips slide in opposite directions
|
|
17
|
+
float dir = mod(floor(b * float(strips)), 2.0) < 0.5 ? 1.0 : -1.0;
|
|
18
|
+
// ease in and out, but keep moving from the first frame
|
|
19
|
+
float t = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.6);
|
|
20
|
+
float fa = a - dir * t;
|
|
21
|
+
if (fa >= 0.0 && fa <= 1.0) {
|
|
22
|
+
return getFromColor(vertical ? vec2(b, fa) : vec2(fa, b));
|
|
23
|
+
}
|
|
24
|
+
float ta = fa + dir;
|
|
25
|
+
return getToColor(vertical ? vec2(b, ta) : vec2(ta, b));
|
|
26
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Curtains — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Curtains.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image parts in the middle like stage curtains, gathering into shaded folds as it is pulled to the sides
|
|
5
|
+
// Tags: split, horizontal, fold, 3d
|
|
6
|
+
|
|
7
|
+
// @range(1, 16, 1) Number of folds in each curtain (fewer in a portrait image)
|
|
8
|
+
uniform float folds; // = 7.0
|
|
9
|
+
// @range(0, 1) Depth of the shading on the folds
|
|
10
|
+
uniform float shading; // = 0.7
|
|
11
|
+
// @range(0, 0.4) Width of each curtain once gathered, relative to the image width
|
|
12
|
+
uniform float bunch; // = 0.12
|
|
13
|
+
// @range(0, 1) How much the bottom of the curtains lags behind the top
|
|
14
|
+
uniform float sway; // = 0.4
|
|
15
|
+
|
|
16
|
+
const float PI = 3.141592653589793;
|
|
17
|
+
|
|
18
|
+
vec4 transition (vec2 uv) {
|
|
19
|
+
// the bottom of the fabric follows the top with a little delay
|
|
20
|
+
float lag = sway * (1.0 - uv.y);
|
|
21
|
+
float p = progress * (1.0 - lag * (1.0 - progress));
|
|
22
|
+
float open = mix(p, p * p * (3.0 - 2.0 * p), 0.75);
|
|
23
|
+
// each curtain hangs from its outer edge, gathers to the bunch width, then leaves the frame
|
|
24
|
+
float edge = -bunch * open * open;
|
|
25
|
+
float w = mix(0.5, bunch, open);
|
|
26
|
+
float x = min(uv.x, 1.0 - uv.x) - edge; // distance to the outer edge of the curtain
|
|
27
|
+
if (x >= w) {
|
|
28
|
+
// soft shadow of the curtain on the stage, fading as the curtain leaves the frame
|
|
29
|
+
vec4 to = getToColor(uv);
|
|
30
|
+
float shadow = 0.4 * exp((w - x) * 25.0) * clamp((edge + w) * 20.0, 0.0, 1.0);
|
|
31
|
+
return vec4(to.rgb * (1.0 - shadow * open), to.a);
|
|
32
|
+
}
|
|
33
|
+
float t = x / w;
|
|
34
|
+
// pleats: the fabric bunches up where cos(a) > 0 and is stretched elsewhere
|
|
35
|
+
float n = max(1.0, floor(folds * min(ratio, 1.0) + 0.5)); // folds keep their size in portrait
|
|
36
|
+
float a = 2.0 * PI * n * t;
|
|
37
|
+
float f = 1.0 - (1.0 - open) * (1.0 - open) * (1.0 - open); // the folds form early
|
|
38
|
+
float gather = 0.92 * f;
|
|
39
|
+
float s = 0.5 * (t + gather * sin(a) / (2.0 * PI * n)); // position in the fabric
|
|
40
|
+
vec4 c = getFromColor(vec2(uv.x < 0.5 ? s : 1.0 - s, uv.y));
|
|
41
|
+
// light comes from the front, a bit from the middle of the stage
|
|
42
|
+
float slope = 3.0 * gather * cos(a) * (uv.x < 0.5 ? 1.0 : -1.0);
|
|
43
|
+
float diffuse = (1.0 + 0.5 * slope) / sqrt(1.25 * (1.0 + slope * slope));
|
|
44
|
+
float crease = 0.5 + 0.5 * sin(a); // the back of each pleat is in the dark
|
|
45
|
+
float light = mix(1.0, diffuse * (1.0 - 0.6 * crease * crease), shading * f);
|
|
46
|
+
return vec4(c.rgb * light, c.a);
|
|
47
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// DiamondWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/DiamondWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: A soft-edged diamond grows from the center to reveal the incoming image
|
|
5
|
+
// Tags: shape, wipe, iris
|
|
6
|
+
|
|
7
|
+
// @param Center of the diamond
|
|
8
|
+
uniform vec2 center; // = vec2(0.5)
|
|
9
|
+
// @range(0, 0.5) Softness of the diamond's edge
|
|
10
|
+
uniform float smoothness; // = 0.03
|
|
11
|
+
|
|
12
|
+
vec4 transition (vec2 uv) {
|
|
13
|
+
// Measured in square pixels, so the diamond is not stretched
|
|
14
|
+
vec2 d = abs(uv - center) * vec2(ratio, 1.0);
|
|
15
|
+
// The diamond covers the frame once it reaches the farthest corner
|
|
16
|
+
vec2 far = max(center, 1.0 - center) * vec2(ratio, 1.0);
|
|
17
|
+
float dist = (d.x + d.y) / (far.x + far.y);
|
|
18
|
+
float s = max(smoothness, 0.001);
|
|
19
|
+
float m = smoothstep(0.0, s, progress * (1.0 + s) - dist);
|
|
20
|
+
return mix(getFromColor(uv), getToColor(uv), m);
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// DitherDissolve — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/DitherDissolve.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The incoming image appears through a regular 8x8 ordered dither pattern, like a retro computer screen
|
|
5
|
+
// Tags: dissolve, pattern, retro, pixelate
|
|
6
|
+
|
|
7
|
+
// @range(0.002, 0.05) Size of a dither dot, relative to the height
|
|
8
|
+
uniform float dotSize; // = 0.02
|
|
9
|
+
|
|
10
|
+
// Threshold of the 8x8 Bayer matrix at integer cell c, in (0, 1)
|
|
11
|
+
float bayer(vec2 c) {
|
|
12
|
+
float v = 0.0;
|
|
13
|
+
float scale = 16.0;
|
|
14
|
+
for (int i = 0; i < 3; i++) {
|
|
15
|
+
vec2 bit = mod(floor(c), 2.0);
|
|
16
|
+
// a 2x2 step: 0 2 / 3 1, i.e. 2 * (x xor y) + y
|
|
17
|
+
v += scale * (2.0 * abs(bit.x - bit.y) + bit.y);
|
|
18
|
+
c *= 0.5;
|
|
19
|
+
scale *= 0.25;
|
|
20
|
+
}
|
|
21
|
+
return (v + 0.5) / 64.0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
vec4 transition(vec2 uv) {
|
|
25
|
+
vec2 cell = floor(uv * vec2(ratio, 1.0) / dotSize);
|
|
26
|
+
return progress < bayer(cell) ? getFromColor(uv) : getToColor(uv);
|
|
27
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// FallOver — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/FallOver.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image falls over backward, hinged on its bottom edge, revealing the incoming one behind it
|
|
5
|
+
// Tags: rotate, vertical, 3d
|
|
6
|
+
|
|
7
|
+
// @range(0, 1) Strength of the perspective
|
|
8
|
+
uniform float perspective; // = 0.8
|
|
9
|
+
// @range(0, 1) How much the image darkens as it falls
|
|
10
|
+
uniform float shading; // = 0.7
|
|
11
|
+
|
|
12
|
+
const float PI = 3.141592653589793;
|
|
13
|
+
|
|
14
|
+
vec4 transition (vec2 uv) {
|
|
15
|
+
// it starts slowly, then gravity takes over
|
|
16
|
+
float fall = progress * (0.25 + 0.75 * progress);
|
|
17
|
+
float angle = 0.5 * PI * fall;
|
|
18
|
+
float c = cos(angle), s = sin(angle);
|
|
19
|
+
// a camera in front of the middle of the image goes down to the level of the hinge,
|
|
20
|
+
// so that the image ends edge-on
|
|
21
|
+
float dist = 1.0 / max(perspective, 0.01);
|
|
22
|
+
vec3 eye = vec3(0.5 * ratio, 0.5 * c, -dist);
|
|
23
|
+
vec3 dir = vec3(uv.x * ratio, uv.y, 0.0) - eye;
|
|
24
|
+
// cast a ray onto the plane of the image turned back by angle around its bottom edge
|
|
25
|
+
float den = dir.z * c - dir.y * s;
|
|
26
|
+
if (den > 0.0) {
|
|
27
|
+
float t = (eye.y * s - eye.z * c) / den;
|
|
28
|
+
vec3 hit = eye + t * dir;
|
|
29
|
+
vec2 puv = vec2(hit.x / ratio, hit.y * c + hit.z * s);
|
|
30
|
+
if (t > 0.0 && puv.y > 0.0 && puv.y <= 1.0 && puv.x >= 0.0 && puv.x <= 1.0) {
|
|
31
|
+
vec4 col = getFromColor(puv);
|
|
32
|
+
return vec4(col.rgb * (1.0 - shading * s), col.a);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return getToColor(uv);
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Fisheye — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Fisheye.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image bulges toward the viewer through a strong fisheye lens, then the incoming one flattens back into place
|
|
5
|
+
// Tags: lens, distort, zoom, blend
|
|
6
|
+
|
|
7
|
+
// @range(0, 1) Strength of the lens at its peak
|
|
8
|
+
uniform float strength; // = 0.8
|
|
9
|
+
|
|
10
|
+
vec4 transition(vec2 uv) {
|
|
11
|
+
// lens amount: grows, peaks in the middle, then relaxes, eased so that
|
|
12
|
+
// the magnification of the center (1 / (1 - k)) changes at an even pace
|
|
13
|
+
float h = smoothstep(0.0, 1.0, 1.0 - abs(2.0 * progress - 1.0));
|
|
14
|
+
float k = 1.0 - pow(max(1.0 - strength, 0.01), h);
|
|
15
|
+
// round lens: aspect-corrected coordinates, 1.0 at the corners
|
|
16
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
17
|
+
vec2 c = (uv - 0.5) * aspect;
|
|
18
|
+
float r = length(c) / length(0.5 * aspect);
|
|
19
|
+
// barrel mapping that keeps the corners in place: the center is magnified,
|
|
20
|
+
// the edges squeezed, and every sample stays inside the image
|
|
21
|
+
vec2 q = 0.5 + (uv - 0.5) * (1.0 - k + k * r * r);
|
|
22
|
+
return mix(getFromColor(q), getToColor(q), smoothstep(0.38, 0.62, progress));
|
|
23
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Halftone — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Halftone.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The image breaks into printed halftone dots whose size follows its shades, the dots reshape into the incoming image, then merge back into it
|
|
5
|
+
// Tags: dots, pattern, retro
|
|
6
|
+
|
|
7
|
+
// @range(4, 80) Number of dots across the shorter side
|
|
8
|
+
uniform float dots; // = 28.0
|
|
9
|
+
// @range(0, 90) Angle of the dot grid, in degrees
|
|
10
|
+
uniform float angle; // = 45.0
|
|
11
|
+
// @color Color of the paper between the dots
|
|
12
|
+
uniform vec4 paper; // = vec4(1.0, 1.0, 1.0, 1.0)
|
|
13
|
+
|
|
14
|
+
// Dot radius, in cells, of a halftone printing this color (darker is bigger)
|
|
15
|
+
float dotRadius(vec4 c) {
|
|
16
|
+
float shade = 1.0 - dot(c.rgb, vec3(0.299, 0.587, 0.114));
|
|
17
|
+
return mix(0.1, 0.74, sqrt(clamp(shade, 0.0, 1.0))) * c.a;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
vec4 transition(vec2 uv) {
|
|
21
|
+
// the image turns into dots until 0.3, the dots reshape from left to right, then merge back from 0.7
|
|
22
|
+
float h = smoothstep(0.0, 0.3, progress) * (1.0 - smoothstep(0.7, 1.0, progress));
|
|
23
|
+
float t = (progress - 0.3) / 0.4;
|
|
24
|
+
// rotated square grid, in cells
|
|
25
|
+
float a = radians(angle);
|
|
26
|
+
mat2 rot = mat2(cos(a), sin(a), -sin(a), cos(a));
|
|
27
|
+
vec2 scale = vec2(ratio, 1.0) * dots / min(ratio, 1.0);
|
|
28
|
+
vec2 g = rot * ((uv - 0.5) * scale);
|
|
29
|
+
vec2 base = floor(g - 0.5) + 0.5;
|
|
30
|
+
vec4 pixel = progress < 0.5 ? getFromColor(uv) : getToColor(uv);
|
|
31
|
+
// the dots of the 4 nearest cells may overlap this point: keep the one it is deepest in
|
|
32
|
+
float best = 1e3;
|
|
33
|
+
vec4 ink = pixel;
|
|
34
|
+
for (int i = 0; i < 4; i++) {
|
|
35
|
+
vec2 center = base + vec2(mod(float(i), 2.0), floor(float(i) / 2.0));
|
|
36
|
+
vec2 cuv = (center * rot) / scale + 0.5; // inverse rotation
|
|
37
|
+
vec4 cf = getFromColor(cuv);
|
|
38
|
+
vec4 ct = getToColor(cuv);
|
|
39
|
+
float m = smoothstep(0.0, 1.0, clamp(2.5 * t - 1.5 * cuv.x, 0.0, 1.0));
|
|
40
|
+
// at h = 0, the dots cover their whole cell with the image itself
|
|
41
|
+
float r = mix(0.78, mix(dotRadius(cf), dotRadius(ct), m), h);
|
|
42
|
+
float sd = length(g - center) - r;
|
|
43
|
+
if (sd < best) {
|
|
44
|
+
best = sd;
|
|
45
|
+
ink = mix(pixel, mix(cf, ct, m), h);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return mix(paper, ink, 1.0 - smoothstep(-0.06, 0.06, best));
|
|
49
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Honeycomb — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Honeycomb.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The image splits into hexagons that spin and shrink away in a wave from the center, uncovering the incoming image
|
|
5
|
+
// Tags: hexagon, tiles, rotate, radial
|
|
6
|
+
|
|
7
|
+
// @range(2, 30) Number of hexagons across the shorter side
|
|
8
|
+
uniform float size; // = 6.0
|
|
9
|
+
|
|
10
|
+
// Distance to the center of a pointy-top hexagon, 0.5 on the edges of a cell
|
|
11
|
+
float hexDist(vec2 p) {
|
|
12
|
+
p = abs(p);
|
|
13
|
+
return max(p.x, dot(p, vec2(0.5, 0.8660254)));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
mat2 rotation(float a) {
|
|
17
|
+
return mat2(cos(a), sin(a), -sin(a), cos(a));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Coverage of a hexagon turned by a and scaled by s inside its cell, with soft edges of width e
|
|
21
|
+
// (unturned at s = 1, it covers its whole cell)
|
|
22
|
+
float hexMask(vec2 local, float s, float a, float e) {
|
|
23
|
+
float r = (0.52 + e) * s;
|
|
24
|
+
return 1.0 - smoothstep(r - e, r, hexDist(rotation(-a) * local));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Where the image is sampled, for a point of a hexagon turned by a and scaled by s
|
|
28
|
+
vec2 hexUv(vec2 uv, vec2 local, vec2 cellToUv, float s, float a) {
|
|
29
|
+
return uv + cellToUv * (rotation(-a) * local / max(s, 0.001) - local);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
vec4 transition(vec2 uv) {
|
|
33
|
+
// nearest hexagon center, on two interleaved rectangular grids (centers 1 apart)
|
|
34
|
+
vec2 toCells = vec2(ratio, 1.0) * size / min(ratio, 1.0);
|
|
35
|
+
vec2 p = (uv - 0.5) * toCells;
|
|
36
|
+
const vec2 grid = vec2(1.0, 1.7320508);
|
|
37
|
+
vec2 a = (floor(p / grid) + 0.5) * grid;
|
|
38
|
+
vec2 b = (floor((p - 0.5 * grid) / grid) + 1.0) * grid;
|
|
39
|
+
vec2 center = dot(p - a, p - a) < dot(p - b, p - b) ? a : b;
|
|
40
|
+
vec2 local = p - center;
|
|
41
|
+
|
|
42
|
+
// each hexagon starts later the further it is from the center
|
|
43
|
+
float d = min(length(center / toCells * vec2(ratio, 1.0)) / (0.5 * length(vec2(ratio, 1.0))), 1.0);
|
|
44
|
+
float t = clamp((progress - 0.6 * d) / 0.4, 0.0, 1.0);
|
|
45
|
+
|
|
46
|
+
// the outgoing hexagon spins (opening gaps at the corners of its cell), shrinks away and darkens,
|
|
47
|
+
// casting a soft shadow on the incoming image
|
|
48
|
+
float s = 1.0 - smoothstep(0.1, 1.0, t);
|
|
49
|
+
float turn = 1.8 * t * (2.0 - t);
|
|
50
|
+
vec4 fromTile = getFromColor(hexUv(uv, local, 1.0 / toCells, s, turn));
|
|
51
|
+
fromTile.rgb *= 1.0 - 0.3 * t;
|
|
52
|
+
vec4 below = getToColor(uv);
|
|
53
|
+
below.rgb *= 1.0 - 0.5 * hexMask(local - vec2(0.06, -0.08) * s, s, turn, 0.2);
|
|
54
|
+
return mix(below, fromTile, hexMask(local, s, turn, 0.03));
|
|
55
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// PaperTear — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/PaperTear.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image tears in two along a ragged line, and the halves are pulled apart to reveal the incoming one
|
|
5
|
+
// Tags: split, horizontal, shadow
|
|
6
|
+
|
|
7
|
+
// @range(0, 0.3) How far the tear wanders from the middle, relative to the image height
|
|
8
|
+
uniform float roughness; // = 0.12
|
|
9
|
+
// @range(0, 0.5) How much the top of each half leans away first, so that the tear opens from the top
|
|
10
|
+
uniform float tilt; // = 0.1
|
|
11
|
+
// @range(0, 0.05) Width of the white torn edge, relative to the image height
|
|
12
|
+
uniform float rim; // = 0.012
|
|
13
|
+
// @color Color of the paper fibers on the torn edges
|
|
14
|
+
uniform vec4 paper; // = vec4(1.0, 0.98, 0.94, 1.0)
|
|
15
|
+
// @color Color of the shadow cast on the incoming image
|
|
16
|
+
uniform vec4 shadow; // = vec4(0.0, 0.0, 0.0, 0.35)
|
|
17
|
+
|
|
18
|
+
float tri (float x) {
|
|
19
|
+
return abs(fract(x) - 0.5) - 0.25;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// horizontal position of the tear at height y: smooth meanders...
|
|
23
|
+
float meander (float y) {
|
|
24
|
+
return 0.5 * ratio + roughness * (0.5 * sin(y * 4.7 + 1.3) + 0.25 * sin(y * 11.3 + 4.1));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ...and sharp jags
|
|
28
|
+
float tear (float y) {
|
|
29
|
+
return meander(y) + roughness * (0.1 * sin(y * 29.0 + 0.7) + 0.35 * tri(y * 19.0 + sin(y * 7.0)) + 0.12 * tri(y * 47.0 + 0.6 * sin(y * 13.0)));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// width of the torn edge along it, so that the fibers look uneven
|
|
33
|
+
float fibers (float y, float seed) {
|
|
34
|
+
return rim * (0.7 + 0.3 * sin(y * 37.0 + seed) + 0.4 * tri(y * 83.0 + seed));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// the left half (or the mirrored right half) slides out, its top leaning away first:
|
|
38
|
+
// from a point on screen to the point of the paper (the frame edges stay covered)
|
|
39
|
+
vec2 unfold (vec2 q, float away, float lean) {
|
|
40
|
+
return vec2(q.x + away + lean * q.y, q.y);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// a torn half over the background, with its fibers and an anti-aliased edge
|
|
44
|
+
// e: distance past the torn edge, limit: how far the fibers reach, aa: edge softness
|
|
45
|
+
vec4 torn (vec4 bg, vec4 col, float e, float limit, float aa) {
|
|
46
|
+
vec4 c = vec4(mix(col.rgb, paper.rgb, clamp(0.5 + e / aa, 0.0, 1.0) * paper.a), col.a);
|
|
47
|
+
return mix(bg, c, clamp(0.5 - (e - limit) / aa, 0.0, 1.0));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
vec4 transition (vec2 uv) {
|
|
51
|
+
float p = progress;
|
|
52
|
+
float away = p * p * (0.5 * ratio + 0.1 + roughness + 2.0 * rim); // far enough to leave the frame
|
|
53
|
+
float lean = tilt * p * (2.0 - p);
|
|
54
|
+
float fiber = smoothstep(0.0, 0.15, p); // no torn edge on the intact image
|
|
55
|
+
float aa = 0.002 * fiber + 1e-6;
|
|
56
|
+
vec2 q = vec2(uv.x * ratio, uv.y);
|
|
57
|
+
vec2 l = unfold(q, away, lean);
|
|
58
|
+
vec2 r = unfold(vec2(ratio - q.x, q.y), away, lean);
|
|
59
|
+
float el = l.x - tear(l.y); // > 0 right of the left half's torn edge
|
|
60
|
+
float er = r.x - (ratio - tear(r.y)); // > 0 left of the right half's torn edge
|
|
61
|
+
// soft shadow of the two halves on the incoming image, cast toward the right
|
|
62
|
+
vec2 sq = q - vec2(0.01, 0.0);
|
|
63
|
+
float dl = unfold(sq, away, lean).x - meander(sq.y);
|
|
64
|
+
float dr = unfold(vec2(ratio - sq.x, sq.y), away, lean).x - (ratio - meander(sq.y));
|
|
65
|
+
vec4 to = getToColor(uv);
|
|
66
|
+
float sh = shadow.a * (1.0 - smoothstep(-0.02, 0.08, min(dl, dr)));
|
|
67
|
+
vec4 c = vec4(mix(to.rgb, shadow.rgb, sh), to.a);
|
|
68
|
+
// the image stops at the tear; the bare paper fibers stick out a little beyond it
|
|
69
|
+
if (r.x >= 0.0) {
|
|
70
|
+
c = torn(c, getFromColor(vec2(1.0 - r.x / ratio, r.y)), er, fibers(r.y, 2.0) * 1.5 * fiber, aa);
|
|
71
|
+
}
|
|
72
|
+
if (l.x >= 0.0) {
|
|
73
|
+
c = torn(c, getFromColor(vec2(l.x / ratio, l.y)), el, fibers(l.y, 0.0) * fiber, aa);
|
|
74
|
+
}
|
|
75
|
+
return c;
|
|
76
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Prisms — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Prisms.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The frame is cut into 3D prisms that turn in a cascade, like a rotating billboard, from the outgoing image on one face to the incoming one on the next
|
|
5
|
+
// Tags: 3d, rotate, stripes
|
|
6
|
+
|
|
7
|
+
// @range(2, 40, 1) Number of prisms
|
|
8
|
+
uniform int slats; // = 8
|
|
9
|
+
// @range(0, 0.9) Delay of the last prism's turn, as a part of the transition
|
|
10
|
+
uniform float stagger; // = 0.45
|
|
11
|
+
// @range(0, 4) Amount of perspective
|
|
12
|
+
uniform float perspective; // = 1.0
|
|
13
|
+
// @range(0, 1) How much the faces darken as they turn away
|
|
14
|
+
uniform float shading; // = 0.6
|
|
15
|
+
// @param Cut the frame into horizontal prisms instead
|
|
16
|
+
uniform bool horizontal; // = false
|
|
17
|
+
// @color Color seen where the turning prisms leave the frame uncovered
|
|
18
|
+
uniform vec4 backColor; // = vec4(0.0, 0.0, 0.0, 1.0)
|
|
19
|
+
|
|
20
|
+
const float PI = 3.141592653589793;
|
|
21
|
+
// width of the anti-aliased edges, in frame heights
|
|
22
|
+
const float EDGE = 0.002;
|
|
23
|
+
|
|
24
|
+
vec4 transition (vec2 uv) {
|
|
25
|
+
float n = float(slats);
|
|
26
|
+
// a: the axis across the prisms, b: the axis they turn around
|
|
27
|
+
float a = horizontal ? uv.y : uv.x;
|
|
28
|
+
float b = horizontal ? uv.x : uv.y;
|
|
29
|
+
// the prisms' half width in frame heights, and the perspective from their depth
|
|
30
|
+
float hw = 0.5 / n * (horizontal ? 1.0 : ratio);
|
|
31
|
+
float k = min(perspective * hw, 0.5);
|
|
32
|
+
float bScale = horizontal ? ratio : 1.0;
|
|
33
|
+
// a turning prism is wider than its strip: keep the two nearest faces
|
|
34
|
+
vec4 near1 = vec4(0.0), near2 = vec4(0.0);
|
|
35
|
+
float cover1 = 0.0, cover2 = 0.0;
|
|
36
|
+
float z1 = -2.0, z2 = -2.0;
|
|
37
|
+
for (int d = -1; d <= 1; d++) {
|
|
38
|
+
float i = floor(a * n) + float(d);
|
|
39
|
+
if (i < 0.0 || i > n - 1.0) continue;
|
|
40
|
+
// each prism turns after a delay that grows across the frame, left to right or top to bottom
|
|
41
|
+
float order = (horizontal ? n - 1.0 - i : i) / (n - 1.0);
|
|
42
|
+
float t = clamp((progress - stagger * order) / (1.0 - stagger), 0.0, 1.0);
|
|
43
|
+
t = mix(t, t * t * (3.0 - 2.0 * t), 0.7);
|
|
44
|
+
float c = cos(0.5 * PI * t);
|
|
45
|
+
float s = sin(0.5 * PI * t);
|
|
46
|
+
// soft edges while turning (sharp at rest, to keep the first and last frames exact)
|
|
47
|
+
float edge = EDGE * min(1.0, 20.0 * s * c) + 1e-6;
|
|
48
|
+
// x: position across the strip, -1 to 1; the prism's square section has its faces at distance 1
|
|
49
|
+
float x = 2.0 * (a * n - i) - 1.0;
|
|
50
|
+
for (int f = 0; f < 2; f++) {
|
|
51
|
+
// f = 0: the outgoing face turning away, f = 1: the incoming face turning in
|
|
52
|
+
float cf = f == 0 ? c : s;
|
|
53
|
+
if (cf < 1e-4) continue;
|
|
54
|
+
// u: position on the face, z: depth (1 for a face at rest)
|
|
55
|
+
float u = f == 0 ? (x + s) / c : (x - c) / s;
|
|
56
|
+
float z = f == 0 ? u * s + c : s - u * c;
|
|
57
|
+
if (abs(u) > 1.0 || z <= z2) continue;
|
|
58
|
+
// nearer parts look bigger
|
|
59
|
+
float scale = 1.0 - k * (z - 1.0);
|
|
60
|
+
float y = (b - 0.5) * scale + 0.5;
|
|
61
|
+
if (y < 0.0 || y > 1.0) continue;
|
|
62
|
+
// soften the outer edges only: the faces meet at the prism's corner
|
|
63
|
+
float outer = f == 0 ? 1.0 + u : 1.0 - u;
|
|
64
|
+
float cover = clamp(outer * hw * cf / edge, 0.0, 1.0)
|
|
65
|
+
* clamp(min(y, 1.0 - y) * bScale / scale / edge, 0.0, 1.0);
|
|
66
|
+
float sa = (i + 0.5 + 0.5 * u) / n;
|
|
67
|
+
vec2 p = horizontal ? vec2(y, sa) : vec2(sa, y);
|
|
68
|
+
vec4 img = f == 0 ? getFromColor(p) : getToColor(p);
|
|
69
|
+
// lit from the front and the incoming side: the outgoing face darkens as it turns away
|
|
70
|
+
float lambert = clamp(f == 0 ? c - 0.6 * s : s + 0.6 * c, 0.0, 1.0);
|
|
71
|
+
vec4 color = vec4(img.rgb * mix(1.0 - shading, 1.0, lambert), img.a);
|
|
72
|
+
if (z > z1) {
|
|
73
|
+
near2 = near1; cover2 = cover1; z2 = z1;
|
|
74
|
+
near1 = color; cover1 = cover; z1 = z;
|
|
75
|
+
} else {
|
|
76
|
+
near2 = color; cover2 = cover; z2 = z;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return mix(mix(backColor, near2, cover2), near1, cover1);
|
|
81
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Puzzle — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Puzzle.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The image is cut into jigsaw puzzle pieces that lift one after another and fall away, revealing the incoming image
|
|
5
|
+
// Tags: tiles, shadow, rotate, fragments
|
|
6
|
+
|
|
7
|
+
// @range(2, 12) Number of pieces across the shorter side
|
|
8
|
+
uniform float pieces; // = 5.0
|
|
9
|
+
// @range(0, 1) Darkness of the shadows of the lifted pieces
|
|
10
|
+
uniform float shadow; // = 0.6
|
|
11
|
+
|
|
12
|
+
// Hash of a cell, without sin, in [0, 1)
|
|
13
|
+
float hash(vec2 c) {
|
|
14
|
+
vec2 p = fract(c * vec2(0.1031, 0.1030));
|
|
15
|
+
p += dot(p, p.yx + 33.33);
|
|
16
|
+
return fract((p.x + p.y) * p.x);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
float boxDist(vec2 p, vec2 halfSize) {
|
|
20
|
+
vec2 q = abs(p) - halfSize;
|
|
21
|
+
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Signed distance of a point, relative to the center of piece c, to that piece (cell units).
|
|
25
|
+
// Each edge has a knob (a round head on a neck): a tab for one piece, a blank for its neighbor; border edges are flat.
|
|
26
|
+
float pieceDist(vec2 p, vec2 c, vec2 grid, float aspect) {
|
|
27
|
+
vec2 halfSize = vec2(0.5 * aspect, 0.5);
|
|
28
|
+
float d = boxDist(p, halfSize);
|
|
29
|
+
float tabs = 1e3;
|
|
30
|
+
for (int e = 0; e < 4; e++) {
|
|
31
|
+
// right, left, top, bottom: the edge key is the cell on its left or below
|
|
32
|
+
vec2 dir = e == 0 ? vec2(1.0, 0.0) : e == 1 ? vec2(-1.0, 0.0) : e == 2 ? vec2(0.0, 1.0) : vec2(0.0, -1.0);
|
|
33
|
+
vec2 key = c + min(dir, 0.0);
|
|
34
|
+
vec2 next = c + dir;
|
|
35
|
+
if (next.x >= 0.0 && next.y >= 0.0 && next.x < grid.x && next.y < grid.y) {
|
|
36
|
+
float h = hash(key + (e < 2 ? vec2(0.0) : vec2(71.0, 37.0)));
|
|
37
|
+
// the knob points right or up from the key cell when h < 0.5
|
|
38
|
+
bool tab = (h < 0.5) == (dir.x + dir.y > 0.0);
|
|
39
|
+
vec2 out1 = dir * (tab ? 1.0 : -1.0);
|
|
40
|
+
vec2 along = vec2(abs(dir.y), abs(dir.x));
|
|
41
|
+
vec2 edge = dir * halfSize + along * (fract(h * 2.0) - 0.5) * 0.16;
|
|
42
|
+
float k = min(
|
|
43
|
+
length(p - edge - out1 * 0.15) - 0.125,
|
|
44
|
+
boxDist(p - edge - out1 * 0.06, abs(dir) * 0.08 + along * 0.085));
|
|
45
|
+
if (tab) tabs = min(tabs, k);
|
|
46
|
+
else d = max(d, -k);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return min(d, tabs);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
vec4 transition(vec2 uv) {
|
|
53
|
+
// a grid of nearly square cells that fits the frame exactly
|
|
54
|
+
float rows = ratio < 1.0 ? floor(pieces / ratio + 0.5) : pieces;
|
|
55
|
+
float cols = ratio < 1.0 ? pieces : floor(pieces * ratio + 0.5);
|
|
56
|
+
vec2 grid = vec2(cols, rows);
|
|
57
|
+
float aspect = ratio * rows / cols;
|
|
58
|
+
vec2 g = uv * grid;
|
|
59
|
+
vec2 cell = floor(g);
|
|
60
|
+
|
|
61
|
+
const float aa = 0.01; // soft edges, in cells
|
|
62
|
+
float boardSum = 0.0;
|
|
63
|
+
float allSum = 0.0;
|
|
64
|
+
// the two top moving pieces under this point
|
|
65
|
+
float prio1 = -1.0, prio2 = -1.0, cov1 = 0.0, cov2 = 0.0, shade1 = 1.0, shade2 = 1.0;
|
|
66
|
+
vec2 uv1 = uv, uv2 = uv;
|
|
67
|
+
float shadowAll = 0.0;
|
|
68
|
+
float seam = 1.0;
|
|
69
|
+
for (int i = 0; i < 9; i++) {
|
|
70
|
+
vec2 c = cell + vec2(mod(float(i), 3.0), floor(float(i) / 3.0)) - 1.0;
|
|
71
|
+
if (c.x < 0.0 || c.y < 0.0 || c.x >= cols || c.y >= rows) continue;
|
|
72
|
+
vec2 center = c + 0.5;
|
|
73
|
+
vec2 local = (g - center) * vec2(aspect, 1.0);
|
|
74
|
+
float h = hash(c + vec2(13.0, 7.0));
|
|
75
|
+
// diagonal order from the top left, a little shuffled
|
|
76
|
+
float diag = (c.x / max(cols - 1.0, 1.0) + (rows - 1.0 - c.y) / max(rows - 1.0, 1.0)) * 0.5;
|
|
77
|
+
float delay = (diag + 1.2 * (h - 0.5) * diag * (1.0 - diag)) * 0.6;
|
|
78
|
+
float t = clamp((progress - delay) / 0.4, 0.0, 1.0);
|
|
79
|
+
|
|
80
|
+
// where the piece was: the board keeps the outgoing image where pieces are still in place
|
|
81
|
+
float d0 = pieceDist(local, c, grid, aspect);
|
|
82
|
+
float w = 1.0 - smoothstep(-aa, aa, d0);
|
|
83
|
+
allSum += w;
|
|
84
|
+
if (t <= 0.0) {
|
|
85
|
+
boardSum += w;
|
|
86
|
+
seam = min(seam, abs(d0));
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
// lift, then fall away: shrink, spin, drift down and darken
|
|
90
|
+
float lift = smoothstep(0.0, 0.25, t);
|
|
91
|
+
float fall = clamp((t - 0.2) / 0.8, 0.0, 1.0);
|
|
92
|
+
fall *= fall;
|
|
93
|
+
float s = max(1.0 - fall, 0.001);
|
|
94
|
+
float a = (h - 0.5) * 3.0 * fall;
|
|
95
|
+
vec2 off = vec2(0.0, -1.2 * fall);
|
|
96
|
+
mat2 rot = mat2(cos(a), -sin(a), sin(a), cos(a));
|
|
97
|
+
vec2 pl = rot * (local - off) / s;
|
|
98
|
+
float dp = pieceDist(pl, c, grid, aspect);
|
|
99
|
+
float cov = (1.0 - smoothstep(-aa, aa, dp * s)) * min(s * 20.0, 1.0); // fades when tiny
|
|
100
|
+
// darker when falling, and on its edges when lifted
|
|
101
|
+
float shade = (1.0 - 0.5 * fall) * (1.0 - 0.3 * lift * (1.0 - smoothstep(0.0, 0.035, -dp)));
|
|
102
|
+
vec2 puv = (center + pl / vec2(aspect, 1.0)) / grid;
|
|
103
|
+
// soft shadow, offset to the bottom right while lifted
|
|
104
|
+
vec2 sl = rot * (local - off - vec2(0.08, -0.1) * lift) / s;
|
|
105
|
+
float sh = (1.0 - smoothstep(-0.05, 0.12, pieceDist(sl, c, grid, aspect) * s)) * lift * (1.0 - fall) * shadow;
|
|
106
|
+
// the hole it leaves is in its shadow too
|
|
107
|
+
shadowAll = max(shadowAll, max(sh, w * lift * (1.0 - smoothstep(0.2, 0.5, t)) * shadow));
|
|
108
|
+
float prio = delay;
|
|
109
|
+
if (cov > 0.0 && prio > prio1) {
|
|
110
|
+
prio2 = prio1; cov2 = cov1; uv2 = uv1; shade2 = shade1;
|
|
111
|
+
prio1 = prio; cov1 = cov; uv1 = puv; shade1 = shade;
|
|
112
|
+
} else if (cov > 0.0 && prio > prio2) {
|
|
113
|
+
prio2 = prio; cov2 = cov; uv2 = puv; shade2 = shade;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
vec4 base = mix(getToColor(uv), getFromColor(uv), boardSum / max(allSum, 0.001));
|
|
117
|
+
// the cuts show on the board as the transition starts
|
|
118
|
+
base.rgb *= (1.0 - shadowAll) * (1.0 - 0.4 * smoothstep(0.0, 0.1, progress) * (1.0 - smoothstep(0.0, 0.015, seam)));
|
|
119
|
+
vec4 p2 = getFromColor(uv2);
|
|
120
|
+
p2.rgb *= shade2;
|
|
121
|
+
vec4 p1 = getFromColor(uv1);
|
|
122
|
+
p1.rgb *= shade1;
|
|
123
|
+
return mix(mix(base, p2, cov2), p1, cov1);
|
|
124
|
+
}
|