gl-transitions 2.0.0 → 2.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 +56 -0
- package/compatibility.json +386 -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/CylinderRoll.glsl +102 -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/LightStreaks.glsl +117 -0
- package/glsl3/PaperTear.glsl +76 -0
- package/glsl3/PixelStretch.glsl +73 -0
- package/glsl3/Prisms.glsl +81 -0
- package/glsl3/Puzzle.glsl +124 -0
- package/glsl3/Refraction.glsl +95 -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/glsl3/WhipSpin.glsl +69 -0
- package/glsl3/WhipTilt.glsl +79 -0
- package/index.js +1 -1
- package/layouts.json +764 -0
- package/llms-full.txt +620 -256
- package/llms.txt +160 -136
- package/msl/ApertureWipe.metal +193 -0
- package/msl/Comb.metal +167 -0
- package/msl/Curtains.metal +207 -0
- package/msl/CylinderRoll.metal +374 -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/LightStreaks.metal +518 -0
- package/msl/PaperTear.metal +373 -0
- package/msl/PixelStretch.metal +337 -0
- package/msl/Prisms.metal +424 -0
- package/msl/Puzzle.metal +632 -0
- package/msl/Refraction.metal +333 -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/msl/WhipSpin.metal +278 -0
- package/msl/WhipTilt.metal +327 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +69 -39
- package/sksl/ApertureWipe.sksl +56 -0
- package/sksl/Comb.sksl +39 -0
- package/sksl/Curtains.sksl +60 -0
- package/sksl/CylinderRoll.sksl +112 -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/LightStreaks.sksl +126 -0
- package/sksl/PaperTear.sksl +82 -0
- package/sksl/PixelStretch.sksl +84 -0
- package/sksl/Prisms.sksl +94 -0
- package/sksl/Puzzle.sksl +134 -0
- package/sksl/Refraction.sksl +103 -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/WhipSpin.sksl +79 -0
- package/sksl/WhipTilt.sksl +90 -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/CylinderRoll.glsl +101 -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/LightStreaks.glsl +116 -0
- package/transitions/PaperTear.glsl +75 -0
- package/transitions/PixelStretch.glsl +72 -0
- package/transitions/Prisms.glsl +80 -0
- package/transitions/Puzzle.glsl +123 -0
- package/transitions/Refraction.glsl +94 -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/transitions/WhipSpin.glsl +68 -0
- package/transitions/WhipTilt.glsl +78 -0
- package/wgsl/ApertureWipe.wgsl +160 -0
- package/wgsl/Comb.wgsl +139 -0
- package/wgsl/Curtains.wgsl +179 -0
- package/wgsl/CylinderRoll.wgsl +330 -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/LightStreaks.wgsl +460 -0
- package/wgsl/PaperTear.wgsl +324 -0
- package/wgsl/PixelStretch.wgsl +298 -0
- package/wgsl/Prisms.wgsl +385 -0
- package/wgsl/Puzzle.wgsl +587 -0
- package/wgsl/Refraction.wgsl +294 -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
- package/wgsl/WhipSpin.wgsl +241 -0
- package/wgsl/WhipTilt.wgsl +291 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A camera aperture opens its turning blades to reveal the incoming image
|
|
4
|
+
// Tags: shape, wipe, iris, rotate
|
|
5
|
+
|
|
6
|
+
#define PI 3.141592653589793
|
|
7
|
+
|
|
8
|
+
// @range(3, 12) Number of blades
|
|
9
|
+
uniform int blades; // = 6
|
|
10
|
+
// @range(-180, 180) How much the blades turn while opening, in degrees
|
|
11
|
+
uniform float rotation; // = 60.0
|
|
12
|
+
// @range(0, 1) How dark the blades are shaded along their edges
|
|
13
|
+
uniform float shadow; // = 0.5
|
|
14
|
+
|
|
15
|
+
const float AA = 0.006;
|
|
16
|
+
|
|
17
|
+
vec4 transition (vec2 uv) {
|
|
18
|
+
// Square pixels, normalized so the frame's corners are at distance 1
|
|
19
|
+
vec2 q = (uv - 0.5) * vec2(ratio, 1.0) / (0.5 * length(vec2(ratio, 1.0)));
|
|
20
|
+
float n = clamp(float(blades), 3.0, 12.0);
|
|
21
|
+
float sector = 2.0 * PI / n;
|
|
22
|
+
float turn = radians(rotation) * progress;
|
|
23
|
+
// Each blade's straight edge is at distance r from the center: the opening is the polygon they enclose
|
|
24
|
+
float r = mix(-AA, 1.0 + AA, progress);
|
|
25
|
+
float dist = -1e3;
|
|
26
|
+
float seam = 0.0;
|
|
27
|
+
for (int i = 0; i < 12; i++) {
|
|
28
|
+
if (float(i) < n) {
|
|
29
|
+
float angle = turn + float(i) * sector;
|
|
30
|
+
float d = dot(q, vec2(cos(angle), sin(angle))) - r;
|
|
31
|
+
float next = dot(q, vec2(cos(angle + sector), sin(angle + sector))) - r;
|
|
32
|
+
dist = max(dist, d);
|
|
33
|
+
// Past its corner, the edge of a blade lies over the next blade and casts a shadow on it
|
|
34
|
+
float s = 1.0 - smoothstep(0.0, 0.12, -d);
|
|
35
|
+
seam = max(seam, (1.0 - smoothstep(0.0, AA, d)) * s * s * smoothstep(0.0, AA, next));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// The blades are also shaded along the opening; the shading fades in as the aperture starts to open
|
|
39
|
+
float rim = 1.0 - smoothstep(0.0, 0.08, dist);
|
|
40
|
+
float shade = shadow * max(rim * rim, seam) * smoothstep(0.0, 0.1, progress);
|
|
41
|
+
vec4 from = getFromColor(uv);
|
|
42
|
+
from.rgb *= 1.0 - shade;
|
|
43
|
+
return mix(from, getToColor(uv), 1.0 - smoothstep(0.0, AA, dist));
|
|
44
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The frame is cut into interleaved strips that slide in opposite directions, each pushing the outgoing image out and the incoming one in
|
|
4
|
+
// Tags: slide, stripes, push, horizontal
|
|
5
|
+
|
|
6
|
+
// @range(2, 40, 1) Number of strips
|
|
7
|
+
uniform int strips; // = 10
|
|
8
|
+
// @param Cut the frame into columns that slide up and down instead
|
|
9
|
+
uniform bool vertical; // = false
|
|
10
|
+
|
|
11
|
+
vec4 transition (vec2 uv) {
|
|
12
|
+
// a: the axis along which the strips slide, b: the axis across them
|
|
13
|
+
float a = vertical ? uv.y : uv.x;
|
|
14
|
+
float b = vertical ? uv.x : uv.y;
|
|
15
|
+
// alternate strips slide in opposite directions
|
|
16
|
+
float dir = mod(floor(b * float(strips)), 2.0) < 0.5 ? 1.0 : -1.0;
|
|
17
|
+
// ease in and out, but keep moving from the first frame
|
|
18
|
+
float t = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.6);
|
|
19
|
+
float fa = a - dir * t;
|
|
20
|
+
if (fa >= 0.0 && fa <= 1.0) {
|
|
21
|
+
return getFromColor(vertical ? vec2(b, fa) : vec2(fa, b));
|
|
22
|
+
}
|
|
23
|
+
float ta = fa + dir;
|
|
24
|
+
return getToColor(vertical ? vec2(b, ta) : vec2(ta, b));
|
|
25
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image parts in the middle like stage curtains, gathering into shaded folds as it is pulled to the sides
|
|
4
|
+
// Tags: split, horizontal, fold, 3d
|
|
5
|
+
|
|
6
|
+
// @range(1, 16, 1) Number of folds in each curtain (fewer in a portrait image)
|
|
7
|
+
uniform float folds; // = 7.0
|
|
8
|
+
// @range(0, 1) Depth of the shading on the folds
|
|
9
|
+
uniform float shading; // = 0.7
|
|
10
|
+
// @range(0, 0.4) Width of each curtain once gathered, relative to the image width
|
|
11
|
+
uniform float bunch; // = 0.12
|
|
12
|
+
// @range(0, 1) How much the bottom of the curtains lags behind the top
|
|
13
|
+
uniform float sway; // = 0.4
|
|
14
|
+
|
|
15
|
+
const float PI = 3.141592653589793;
|
|
16
|
+
|
|
17
|
+
vec4 transition (vec2 uv) {
|
|
18
|
+
// the bottom of the fabric follows the top with a little delay
|
|
19
|
+
float lag = sway * (1.0 - uv.y);
|
|
20
|
+
float p = progress * (1.0 - lag * (1.0 - progress));
|
|
21
|
+
float open = mix(p, p * p * (3.0 - 2.0 * p), 0.75);
|
|
22
|
+
// each curtain hangs from its outer edge, gathers to the bunch width, then leaves the frame
|
|
23
|
+
float edge = -bunch * open * open;
|
|
24
|
+
float w = mix(0.5, bunch, open);
|
|
25
|
+
float x = min(uv.x, 1.0 - uv.x) - edge; // distance to the outer edge of the curtain
|
|
26
|
+
if (x >= w) {
|
|
27
|
+
// soft shadow of the curtain on the stage, fading as the curtain leaves the frame
|
|
28
|
+
vec4 to = getToColor(uv);
|
|
29
|
+
float shadow = 0.4 * exp((w - x) * 25.0) * clamp((edge + w) * 20.0, 0.0, 1.0);
|
|
30
|
+
return vec4(to.rgb * (1.0 - shadow * open), to.a);
|
|
31
|
+
}
|
|
32
|
+
float t = x / w;
|
|
33
|
+
// pleats: the fabric bunches up where cos(a) > 0 and is stretched elsewhere
|
|
34
|
+
float n = max(1.0, floor(folds * min(ratio, 1.0) + 0.5)); // folds keep their size in portrait
|
|
35
|
+
float a = 2.0 * PI * n * t;
|
|
36
|
+
float f = 1.0 - (1.0 - open) * (1.0 - open) * (1.0 - open); // the folds form early
|
|
37
|
+
float gather = 0.92 * f;
|
|
38
|
+
float s = 0.5 * (t + gather * sin(a) / (2.0 * PI * n)); // position in the fabric
|
|
39
|
+
vec4 c = getFromColor(vec2(uv.x < 0.5 ? s : 1.0 - s, uv.y));
|
|
40
|
+
// light comes from the front, a bit from the middle of the stage
|
|
41
|
+
float slope = 3.0 * gather * cos(a) * (uv.x < 0.5 ? 1.0 : -1.0);
|
|
42
|
+
float diffuse = (1.0 + 0.5 * slope) / sqrt(1.25 * (1.0 + slope * slope));
|
|
43
|
+
float crease = 0.5 + 0.5 * sin(a); // the back of each pleat is in the dark
|
|
44
|
+
float light = mix(1.0, diffuse * (1.0 - 0.6 * crease * crease), shading * f);
|
|
45
|
+
return vec4(c.rgb * light, c.a);
|
|
46
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The frame wraps around a drum that rolls up, the outgoing image turning away over its top in a motion blur and the incoming one coming around from below and unrolling flat
|
|
4
|
+
// Tags: 3d, roll, motion-blur, vertical, chromatic
|
|
5
|
+
|
|
6
|
+
// @range(0, 1) How much the frame wraps around the drum
|
|
7
|
+
uniform float curvature; // = 0.8
|
|
8
|
+
// @range(0, 1) Length of the motion blur at full speed
|
|
9
|
+
uniform float blur; // = 0.5
|
|
10
|
+
// @range(0, 1) How much the drum darkens as it turns away
|
|
11
|
+
uniform float shading; // = 0.6
|
|
12
|
+
// @range(0, 1) Amount of RGB split along the roll, growing with speed
|
|
13
|
+
uniform float chroma; // = 0.5
|
|
14
|
+
// @param Roll downward instead, the incoming image coming around from above
|
|
15
|
+
uniform bool downward; // = false
|
|
16
|
+
|
|
17
|
+
const int SAMPLES = 24;
|
|
18
|
+
// the half angle of the drum seen in the frame height, at full curvature
|
|
19
|
+
const float MAX_ANGLE = 1.1;
|
|
20
|
+
// distance from the camera to the drum's axis, in drum radii
|
|
21
|
+
const float DIST = 2.6;
|
|
22
|
+
// how much the horizontal lines arc away from the middle, per frame height squared
|
|
23
|
+
const float ARC = 0.12;
|
|
24
|
+
|
|
25
|
+
float hash(vec2 c) {
|
|
26
|
+
vec2 q = fract(c * vec2(0.1031, 0.1030));
|
|
27
|
+
q += dot(q, q.yx + 33.33);
|
|
28
|
+
return fract((q.x + q.y) * q.x);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// mirrored coordinate, folded back into 0..1
|
|
32
|
+
float fold(float v) {
|
|
33
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// the strip around the drum: the outgoing image, with the incoming one below it (or above)
|
|
37
|
+
vec4 strip(float x, float v) {
|
|
38
|
+
if (downward ? v > 1.0 : v < 0.0) {
|
|
39
|
+
return getToColor(vec2(x, fold(downward ? v - 1.0 : v + 1.0)));
|
|
40
|
+
}
|
|
41
|
+
return getFromColor(vec2(x, fold(v)));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// angle on the drum seen at the projected height c (the drum has a radius of 1)
|
|
45
|
+
float angleAt(float c) {
|
|
46
|
+
c = clamp(c, -0.98 / sqrt(DIST * DIST - 1.0), 0.98 / sqrt(DIST * DIST - 1.0));
|
|
47
|
+
return asin(c * DIST / sqrt(1.0 + c * c)) - atan(c);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
vec4 transition(vec2 uv) {
|
|
51
|
+
float p = progress;
|
|
52
|
+
// ease in, roll fast in the middle, ease out
|
|
53
|
+
float h = 1.0 - abs(2.0 * p - 1.0); // 0 at both ends, 1 in the middle
|
|
54
|
+
float e = 0.5 * h * (0.1 + 0.9 * h * h);
|
|
55
|
+
float roll = p < 0.5 ? e : 1.0 - e;
|
|
56
|
+
// the blur and the RGB split stay low until the peak of the roll
|
|
57
|
+
float h3 = h * h * h;
|
|
58
|
+
float peak = h3 * h3;
|
|
59
|
+
|
|
60
|
+
// the frame wraps around the drum early, and unwraps to flat sooner as the incoming image settles
|
|
61
|
+
float bend = curvature * (p < 0.5 ? h * (2.0 - h) : h * h * (3.0 - 2.0 * h));
|
|
62
|
+
float phi = MAX_ANGLE * bend + 1e-4;
|
|
63
|
+
float arcK = ARC * bend;
|
|
64
|
+
// the height of the frame's edge, projected with perspective
|
|
65
|
+
float edgeY = sin(phi) / (DIST - cos(phi));
|
|
66
|
+
|
|
67
|
+
vec2 n = 2.0 * uv - 1.0;
|
|
68
|
+
// the horizontal lines arc away from the middle, toward the left and right edges
|
|
69
|
+
float xr = n.x * ratio;
|
|
70
|
+
float yn = n.y * (1.0 + arcK * xr * xr);
|
|
71
|
+
float theta = angleAt(yn * edgeY);
|
|
72
|
+
// nearer parts of the drum look wider: the drum is made wide enough to fill the frame's corners
|
|
73
|
+
float thetaCorner = angleAt((1.0 + arcK * ratio * ratio) * edgeY);
|
|
74
|
+
float width = (DIST - 1.0) / (DIST - cos(theta));
|
|
75
|
+
float zoom = (DIST - cos(thetaCorner)) / (DIST - 1.0);
|
|
76
|
+
float x = 0.5 + 0.5 * n.x / (zoom * width);
|
|
77
|
+
// lit from the camera: darker as the surface turns away
|
|
78
|
+
float facing = (DIST * cos(theta) - 1.0)
|
|
79
|
+
/ sqrt(1.0 + DIST * DIST - 2.0 * DIST * cos(theta)) ;
|
|
80
|
+
float light = mix(1.0, clamp(facing, 0.0, 1.0), shading);
|
|
81
|
+
|
|
82
|
+
// position on the strip (the frame height when flat), rolling the outgoing image away
|
|
83
|
+
float v = 0.5 * (theta / phi + 1.0) + (downward ? roll : -roll);
|
|
84
|
+
float len = 0.5 * blur * peak;
|
|
85
|
+
float split = chroma * peak;
|
|
86
|
+
float jitter = hash(uv * 1000.0);
|
|
87
|
+
vec3 color = vec3(0.0);
|
|
88
|
+
vec3 weight = vec3(0.0);
|
|
89
|
+
float alpha = 0.0;
|
|
90
|
+
for (int i = 0; i < SAMPLES; i++) {
|
|
91
|
+
float t = (float(i) + jitter) / float(SAMPLES) - 0.5;
|
|
92
|
+
vec4 img = strip(x, v + t * len);
|
|
93
|
+
// the channels weigh the samples differently along the roll: an RGB split
|
|
94
|
+
vec3 w = vec3(max(1.0 - 4.0 * split * t, 0.0), 1.0, max(1.0 + 4.0 * split * t, 0.0));
|
|
95
|
+
color += img.rgb * img.a * w;
|
|
96
|
+
weight += img.a * w;
|
|
97
|
+
alpha += img.a;
|
|
98
|
+
}
|
|
99
|
+
color = color / max(weight, vec3(1e-5));
|
|
100
|
+
return vec4(color * light, alpha / float(SAMPLES));
|
|
101
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A soft-edged diamond grows from the center to reveal the incoming image
|
|
4
|
+
// Tags: shape, wipe, iris
|
|
5
|
+
|
|
6
|
+
// @param Center of the diamond
|
|
7
|
+
uniform vec2 center; // = vec2(0.5)
|
|
8
|
+
// @range(0, 0.5) Softness of the diamond's edge
|
|
9
|
+
uniform float smoothness; // = 0.03
|
|
10
|
+
|
|
11
|
+
vec4 transition (vec2 uv) {
|
|
12
|
+
// Measured in square pixels, so the diamond is not stretched
|
|
13
|
+
vec2 d = abs(uv - center) * vec2(ratio, 1.0);
|
|
14
|
+
// The diamond covers the frame once it reaches the farthest corner
|
|
15
|
+
vec2 far = max(center, 1.0 - center) * vec2(ratio, 1.0);
|
|
16
|
+
float dist = (d.x + d.y) / (far.x + far.y);
|
|
17
|
+
float s = max(smoothness, 0.001);
|
|
18
|
+
float m = smoothstep(0.0, s, progress * (1.0 + s) - dist);
|
|
19
|
+
return mix(getFromColor(uv), getToColor(uv), m);
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The incoming image appears through a regular 8x8 ordered dither pattern, like a retro computer screen
|
|
4
|
+
// Tags: dissolve, pattern, retro, pixelate
|
|
5
|
+
|
|
6
|
+
// @range(0.002, 0.05) Size of a dither dot, relative to the height
|
|
7
|
+
uniform float dotSize; // = 0.02
|
|
8
|
+
|
|
9
|
+
// Threshold of the 8x8 Bayer matrix at integer cell c, in (0, 1)
|
|
10
|
+
float bayer(vec2 c) {
|
|
11
|
+
float v = 0.0;
|
|
12
|
+
float scale = 16.0;
|
|
13
|
+
for (int i = 0; i < 3; i++) {
|
|
14
|
+
vec2 bit = mod(floor(c), 2.0);
|
|
15
|
+
// a 2x2 step: 0 2 / 3 1, i.e. 2 * (x xor y) + y
|
|
16
|
+
v += scale * (2.0 * abs(bit.x - bit.y) + bit.y);
|
|
17
|
+
c *= 0.5;
|
|
18
|
+
scale *= 0.25;
|
|
19
|
+
}
|
|
20
|
+
return (v + 0.5) / 64.0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
vec4 transition(vec2 uv) {
|
|
24
|
+
vec2 cell = floor(uv * vec2(ratio, 1.0) / dotSize);
|
|
25
|
+
return progress < bayer(cell) ? getFromColor(uv) : getToColor(uv);
|
|
26
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image falls over backward, hinged on its bottom edge, revealing the incoming one behind it
|
|
4
|
+
// Tags: rotate, vertical, 3d
|
|
5
|
+
|
|
6
|
+
// @range(0, 1) Strength of the perspective
|
|
7
|
+
uniform float perspective; // = 0.8
|
|
8
|
+
// @range(0, 1) How much the image darkens as it falls
|
|
9
|
+
uniform float shading; // = 0.7
|
|
10
|
+
|
|
11
|
+
const float PI = 3.141592653589793;
|
|
12
|
+
|
|
13
|
+
vec4 transition (vec2 uv) {
|
|
14
|
+
// it starts slowly, then gravity takes over
|
|
15
|
+
float fall = progress * (0.25 + 0.75 * progress);
|
|
16
|
+
float angle = 0.5 * PI * fall;
|
|
17
|
+
float c = cos(angle), s = sin(angle);
|
|
18
|
+
// a camera in front of the middle of the image goes down to the level of the hinge,
|
|
19
|
+
// so that the image ends edge-on
|
|
20
|
+
float dist = 1.0 / max(perspective, 0.01);
|
|
21
|
+
vec3 eye = vec3(0.5 * ratio, 0.5 * c, -dist);
|
|
22
|
+
vec3 dir = vec3(uv.x * ratio, uv.y, 0.0) - eye;
|
|
23
|
+
// cast a ray onto the plane of the image turned back by angle around its bottom edge
|
|
24
|
+
float den = dir.z * c - dir.y * s;
|
|
25
|
+
if (den > 0.0) {
|
|
26
|
+
float t = (eye.y * s - eye.z * c) / den;
|
|
27
|
+
vec3 hit = eye + t * dir;
|
|
28
|
+
vec2 puv = vec2(hit.x / ratio, hit.y * c + hit.z * s);
|
|
29
|
+
if (t > 0.0 && puv.y > 0.0 && puv.y <= 1.0 && puv.x >= 0.0 && puv.x <= 1.0) {
|
|
30
|
+
vec4 col = getFromColor(puv);
|
|
31
|
+
return vec4(col.rgb * (1.0 - shading * s), col.a);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return getToColor(uv);
|
|
35
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image bulges toward the viewer through a strong fisheye lens, then the incoming one flattens back into place
|
|
4
|
+
// Tags: lens, distort, zoom, blend
|
|
5
|
+
|
|
6
|
+
// @range(0, 1) Strength of the lens at its peak
|
|
7
|
+
uniform float strength; // = 0.8
|
|
8
|
+
|
|
9
|
+
vec4 transition(vec2 uv) {
|
|
10
|
+
// lens amount: grows, peaks in the middle, then relaxes, eased so that
|
|
11
|
+
// the magnification of the center (1 / (1 - k)) changes at an even pace
|
|
12
|
+
float h = smoothstep(0.0, 1.0, 1.0 - abs(2.0 * progress - 1.0));
|
|
13
|
+
float k = 1.0 - pow(max(1.0 - strength, 0.01), h);
|
|
14
|
+
// round lens: aspect-corrected coordinates, 1.0 at the corners
|
|
15
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
16
|
+
vec2 c = (uv - 0.5) * aspect;
|
|
17
|
+
float r = length(c) / length(0.5 * aspect);
|
|
18
|
+
// barrel mapping that keeps the corners in place: the center is magnified,
|
|
19
|
+
// the edges squeezed, and every sample stays inside the image
|
|
20
|
+
vec2 q = 0.5 + (uv - 0.5) * (1.0 - k + k * r * r);
|
|
21
|
+
return mix(getFromColor(q), getToColor(q), smoothstep(0.38, 0.62, progress));
|
|
22
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// 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
|
|
4
|
+
// Tags: dots, pattern, retro
|
|
5
|
+
|
|
6
|
+
// @range(4, 80) Number of dots across the shorter side
|
|
7
|
+
uniform float dots; // = 28.0
|
|
8
|
+
// @range(0, 90) Angle of the dot grid, in degrees
|
|
9
|
+
uniform float angle; // = 45.0
|
|
10
|
+
// @color Color of the paper between the dots
|
|
11
|
+
uniform vec4 paper; // = vec4(1.0, 1.0, 1.0, 1.0)
|
|
12
|
+
|
|
13
|
+
// Dot radius, in cells, of a halftone printing this color (darker is bigger)
|
|
14
|
+
float dotRadius(vec4 c) {
|
|
15
|
+
float shade = 1.0 - dot(c.rgb, vec3(0.299, 0.587, 0.114));
|
|
16
|
+
return mix(0.1, 0.74, sqrt(clamp(shade, 0.0, 1.0))) * c.a;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
vec4 transition(vec2 uv) {
|
|
20
|
+
// the image turns into dots until 0.3, the dots reshape from left to right, then merge back from 0.7
|
|
21
|
+
float h = smoothstep(0.0, 0.3, progress) * (1.0 - smoothstep(0.7, 1.0, progress));
|
|
22
|
+
float t = (progress - 0.3) / 0.4;
|
|
23
|
+
// rotated square grid, in cells
|
|
24
|
+
float a = radians(angle);
|
|
25
|
+
mat2 rot = mat2(cos(a), sin(a), -sin(a), cos(a));
|
|
26
|
+
vec2 scale = vec2(ratio, 1.0) * dots / min(ratio, 1.0);
|
|
27
|
+
vec2 g = rot * ((uv - 0.5) * scale);
|
|
28
|
+
vec2 base = floor(g - 0.5) + 0.5;
|
|
29
|
+
vec4 pixel = progress < 0.5 ? getFromColor(uv) : getToColor(uv);
|
|
30
|
+
// the dots of the 4 nearest cells may overlap this point: keep the one it is deepest in
|
|
31
|
+
float best = 1e3;
|
|
32
|
+
vec4 ink = pixel;
|
|
33
|
+
for (int i = 0; i < 4; i++) {
|
|
34
|
+
vec2 center = base + vec2(mod(float(i), 2.0), floor(float(i) / 2.0));
|
|
35
|
+
vec2 cuv = (center * rot) / scale + 0.5; // inverse rotation
|
|
36
|
+
vec4 cf = getFromColor(cuv);
|
|
37
|
+
vec4 ct = getToColor(cuv);
|
|
38
|
+
float m = smoothstep(0.0, 1.0, clamp(2.5 * t - 1.5 * cuv.x, 0.0, 1.0));
|
|
39
|
+
// at h = 0, the dots cover their whole cell with the image itself
|
|
40
|
+
float r = mix(0.78, mix(dotRadius(cf), dotRadius(ct), m), h);
|
|
41
|
+
float sd = length(g - center) - r;
|
|
42
|
+
if (sd < best) {
|
|
43
|
+
best = sd;
|
|
44
|
+
ink = mix(pixel, mix(cf, ct, m), h);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return mix(paper, ink, 1.0 - smoothstep(-0.06, 0.06, best));
|
|
48
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The image splits into hexagons that spin and shrink away in a wave from the center, uncovering the incoming image
|
|
4
|
+
// Tags: hexagon, tiles, rotate, radial
|
|
5
|
+
|
|
6
|
+
// @range(2, 30) Number of hexagons across the shorter side
|
|
7
|
+
uniform float size; // = 6.0
|
|
8
|
+
|
|
9
|
+
// Distance to the center of a pointy-top hexagon, 0.5 on the edges of a cell
|
|
10
|
+
float hexDist(vec2 p) {
|
|
11
|
+
p = abs(p);
|
|
12
|
+
return max(p.x, dot(p, vec2(0.5, 0.8660254)));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
mat2 rotation(float a) {
|
|
16
|
+
return mat2(cos(a), sin(a), -sin(a), cos(a));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Coverage of a hexagon turned by a and scaled by s inside its cell, with soft edges of width e
|
|
20
|
+
// (unturned at s = 1, it covers its whole cell)
|
|
21
|
+
float hexMask(vec2 local, float s, float a, float e) {
|
|
22
|
+
float r = (0.52 + e) * s;
|
|
23
|
+
return 1.0 - smoothstep(r - e, r, hexDist(rotation(-a) * local));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Where the image is sampled, for a point of a hexagon turned by a and scaled by s
|
|
27
|
+
vec2 hexUv(vec2 uv, vec2 local, vec2 cellToUv, float s, float a) {
|
|
28
|
+
return uv + cellToUv * (rotation(-a) * local / max(s, 0.001) - local);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
vec4 transition(vec2 uv) {
|
|
32
|
+
// nearest hexagon center, on two interleaved rectangular grids (centers 1 apart)
|
|
33
|
+
vec2 toCells = vec2(ratio, 1.0) * size / min(ratio, 1.0);
|
|
34
|
+
vec2 p = (uv - 0.5) * toCells;
|
|
35
|
+
const vec2 grid = vec2(1.0, 1.7320508);
|
|
36
|
+
vec2 a = (floor(p / grid) + 0.5) * grid;
|
|
37
|
+
vec2 b = (floor((p - 0.5 * grid) / grid) + 1.0) * grid;
|
|
38
|
+
vec2 center = dot(p - a, p - a) < dot(p - b, p - b) ? a : b;
|
|
39
|
+
vec2 local = p - center;
|
|
40
|
+
|
|
41
|
+
// each hexagon starts later the further it is from the center
|
|
42
|
+
float d = min(length(center / toCells * vec2(ratio, 1.0)) / (0.5 * length(vec2(ratio, 1.0))), 1.0);
|
|
43
|
+
float t = clamp((progress - 0.6 * d) / 0.4, 0.0, 1.0);
|
|
44
|
+
|
|
45
|
+
// the outgoing hexagon spins (opening gaps at the corners of its cell), shrinks away and darkens,
|
|
46
|
+
// casting a soft shadow on the incoming image
|
|
47
|
+
float s = 1.0 - smoothstep(0.1, 1.0, t);
|
|
48
|
+
float turn = 1.8 * t * (2.0 - t);
|
|
49
|
+
vec4 fromTile = getFromColor(hexUv(uv, local, 1.0 / toCells, s, turn));
|
|
50
|
+
fromTile.rgb *= 1.0 - 0.3 * t;
|
|
51
|
+
vec4 below = getToColor(uv);
|
|
52
|
+
below.rgb *= 1.0 - 0.5 * hexMask(local - vec2(0.06, -0.08) * s, s, turn, 0.2);
|
|
53
|
+
return mix(below, fromTile, hexMask(local, s, turn, 0.03));
|
|
54
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The highlights of the outgoing image flare into long horizontal (or vertical) lens streaks while it smears with motion blur; at the peak the incoming image takes over and its streaks shrink back into its highlights as it sharpens
|
|
4
|
+
// Tags: light, flare, motion-blur, glow
|
|
5
|
+
|
|
6
|
+
// @range(0, 2) Length of the streaks at the peak, in frame widths
|
|
7
|
+
uniform float reach; // = 0.6
|
|
8
|
+
// @range(0, 1) Brightness above which the image flares
|
|
9
|
+
uniform float threshold; // = 0.7
|
|
10
|
+
// @range(0, 4) Brightness of the streaks
|
|
11
|
+
uniform float intensity; // = 1.5
|
|
12
|
+
// @color Tint of the streaks, toward their ends
|
|
13
|
+
uniform vec3 tint; // = vec3(0.45, 0.7, 1.0)
|
|
14
|
+
// @range(0, 0.5) Length of the motion blur at the peak
|
|
15
|
+
uniform float blur; // = 0.1
|
|
16
|
+
// @param Streak and smear vertically instead
|
|
17
|
+
uniform bool vertical; // = false
|
|
18
|
+
|
|
19
|
+
const int BLUR_TAPS = 6;
|
|
20
|
+
// taps on each side of a streak, spaced further and further apart along its falloff
|
|
21
|
+
const int STREAK_TAPS = 11;
|
|
22
|
+
|
|
23
|
+
float hash12(vec2 v) {
|
|
24
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
25
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
26
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// mirror the coordinates back into the frame
|
|
30
|
+
vec2 mirror(vec2 v) {
|
|
31
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// the image on screen: the outgoing one, then the incoming one after a short switch
|
|
35
|
+
vec4 frame(vec2 st, float m) {
|
|
36
|
+
if (m <= 0.0) return getFromColor(st);
|
|
37
|
+
if (m >= 1.0) return getToColor(st);
|
|
38
|
+
return mix(getFromColor(st), getToColor(st), m);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// the light of a pixel: its color above the threshold
|
|
42
|
+
vec3 glow(vec4 c, float knee) {
|
|
43
|
+
float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
44
|
+
return c.rgb * c.a * smoothstep(knee, knee + 0.2, lum);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// one image only, for the blur and streak taps: during the switch, every other tap reads each image
|
|
48
|
+
vec4 light(vec2 st, float m, bool incoming) {
|
|
49
|
+
if (m <= 0.0) return getFromColor(st);
|
|
50
|
+
if (m >= 1.0) return getToColor(st);
|
|
51
|
+
return incoming ? getToColor(st) : getFromColor(st);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
float lightWeight(float m, bool incoming) {
|
|
55
|
+
if (m <= 0.0 || m >= 1.0) return 1.0;
|
|
56
|
+
return incoming ? 2.0 * m : 2.0 * (1.0 - m);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
vec4 transition(vec2 uv) {
|
|
60
|
+
float p = progress;
|
|
61
|
+
// eased in on the outgoing side, and quickly out after the switch so the incoming image lands sharp
|
|
62
|
+
float amount = p < 0.5 ? smoothstep(0.0, 0.5, p) : pow(2.0 - 2.0 * p, 3.0);
|
|
63
|
+
float peak = amount * amount * amount;
|
|
64
|
+
float m = smoothstep(0.44, 0.56, p);
|
|
65
|
+
vec2 axis = vertical ? vec2(0.0, 1.0) : vec2(1.0, 0.0);
|
|
66
|
+
// a small shift of the taps, under their spacing, blends their copies into a smooth smear;
|
|
67
|
+
// hashed by integer cell so that every GPU computes the same shift
|
|
68
|
+
float jitter = hash12(floor(uv * vec2(ratio, 1.0) * 997.0)) - 0.5;
|
|
69
|
+
|
|
70
|
+
// the image smears along the streaks (a tent filter)
|
|
71
|
+
float smear = blur * amount;
|
|
72
|
+
vec3 base = vec3(0.0);
|
|
73
|
+
float alpha = 0.0;
|
|
74
|
+
float total = 0.0;
|
|
75
|
+
for (int i = 0; i < BLUR_TAPS; i++) {
|
|
76
|
+
float t = (float(i) + 0.5 + jitter) / float(BLUR_TAPS) - 0.5;
|
|
77
|
+
float w = 1.0 - abs(t);
|
|
78
|
+
total += w;
|
|
79
|
+
bool incoming = mod(float(i), 2.0) > 0.5;
|
|
80
|
+
w *= lightWeight(m, incoming);
|
|
81
|
+
vec4 c = light(mirror(uv + axis * t * smear), m, incoming);
|
|
82
|
+
base += w * c.rgb * c.a;
|
|
83
|
+
alpha += w * c.a;
|
|
84
|
+
}
|
|
85
|
+
base /= total;
|
|
86
|
+
alpha /= total;
|
|
87
|
+
|
|
88
|
+
// the streaks: the light above the threshold, spread along the axis with an exponential falloff
|
|
89
|
+
float falloff = 0.25 * reach * amount;
|
|
90
|
+
float knee = mix(threshold, 0.8 * threshold, peak);
|
|
91
|
+
vec3 streak = glow(frame(uv, m), knee);
|
|
92
|
+
float weights = 1.0;
|
|
93
|
+
for (int k = 1; k <= STREAK_TAPS; k++) {
|
|
94
|
+
// the distance in units of the falloff, and the stretch of the streak this tap stands for
|
|
95
|
+
float d = exp(0.14 * (float(k) + 0.8 * jitter)) - 1.0;
|
|
96
|
+
float span = 0.14 * (d + 1.0);
|
|
97
|
+
// white at the source, tinted along the streak, red fading first so the tails turn blue and violet
|
|
98
|
+
vec3 hue = mix(vec3(1.0), tint, smoothstep(0.0, 0.8, d));
|
|
99
|
+
hue *= exp(-d * vec3(0.6, 0.2, -0.15));
|
|
100
|
+
float w = exp(-d) * span * 4.0;
|
|
101
|
+
bool incoming = mod(float(k), 2.0) > 0.5;
|
|
102
|
+
vec4 ahead = light(mirror(uv + axis * d * falloff), m, incoming);
|
|
103
|
+
vec4 behind = light(mirror(uv - axis * d * falloff), m, !incoming);
|
|
104
|
+
streak += w * hue * (glow(ahead, knee) * lightWeight(m, incoming) + glow(behind, knee) * lightWeight(m, !incoming));
|
|
105
|
+
weights += 2.0 * w;
|
|
106
|
+
}
|
|
107
|
+
streak *= intensity * amount * (0.6 + 2.4 * peak) * 2.0 / weights;
|
|
108
|
+
// compressed, so that bright skies never flatten into white
|
|
109
|
+
streak = 0.85 * (1.0 - exp(-streak));
|
|
110
|
+
|
|
111
|
+
// a lift of the exposure at the peak, then the streaks screened on top (premultiplied colors)
|
|
112
|
+
base = min(base * (1.0 + 0.2 * peak), vec3(alpha));
|
|
113
|
+
vec3 color = base + streak - base * streak;
|
|
114
|
+
float a = alpha + max(streak.r, max(streak.g, streak.b)) * (1.0 - alpha);
|
|
115
|
+
return vec4(clamp(color / max(a, 1e-5), 0.0, 1.0), a);
|
|
116
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image tears in two along a ragged line, and the halves are pulled apart to reveal the incoming one
|
|
4
|
+
// Tags: split, horizontal, shadow
|
|
5
|
+
|
|
6
|
+
// @range(0, 0.3) How far the tear wanders from the middle, relative to the image height
|
|
7
|
+
uniform float roughness; // = 0.12
|
|
8
|
+
// @range(0, 0.5) How much the top of each half leans away first, so that the tear opens from the top
|
|
9
|
+
uniform float tilt; // = 0.1
|
|
10
|
+
// @range(0, 0.05) Width of the white torn edge, relative to the image height
|
|
11
|
+
uniform float rim; // = 0.012
|
|
12
|
+
// @color Color of the paper fibers on the torn edges
|
|
13
|
+
uniform vec4 paper; // = vec4(1.0, 0.98, 0.94, 1.0)
|
|
14
|
+
// @color Color of the shadow cast on the incoming image
|
|
15
|
+
uniform vec4 shadow; // = vec4(0.0, 0.0, 0.0, 0.35)
|
|
16
|
+
|
|
17
|
+
float tri (float x) {
|
|
18
|
+
return abs(fract(x) - 0.5) - 0.25;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// horizontal position of the tear at height y: smooth meanders...
|
|
22
|
+
float meander (float y) {
|
|
23
|
+
return 0.5 * ratio + roughness * (0.5 * sin(y * 4.7 + 1.3) + 0.25 * sin(y * 11.3 + 4.1));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ...and sharp jags
|
|
27
|
+
float tear (float y) {
|
|
28
|
+
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)));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// width of the torn edge along it, so that the fibers look uneven
|
|
32
|
+
float fibers (float y, float seed) {
|
|
33
|
+
return rim * (0.7 + 0.3 * sin(y * 37.0 + seed) + 0.4 * tri(y * 83.0 + seed));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// the left half (or the mirrored right half) slides out, its top leaning away first:
|
|
37
|
+
// from a point on screen to the point of the paper (the frame edges stay covered)
|
|
38
|
+
vec2 unfold (vec2 q, float away, float lean) {
|
|
39
|
+
return vec2(q.x + away + lean * q.y, q.y);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// a torn half over the background, with its fibers and an anti-aliased edge
|
|
43
|
+
// e: distance past the torn edge, limit: how far the fibers reach, aa: edge softness
|
|
44
|
+
vec4 torn (vec4 bg, vec4 col, float e, float limit, float aa) {
|
|
45
|
+
vec4 c = vec4(mix(col.rgb, paper.rgb, clamp(0.5 + e / aa, 0.0, 1.0) * paper.a), col.a);
|
|
46
|
+
return mix(bg, c, clamp(0.5 - (e - limit) / aa, 0.0, 1.0));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
vec4 transition (vec2 uv) {
|
|
50
|
+
float p = progress;
|
|
51
|
+
float away = p * p * (0.5 * ratio + 0.1 + roughness + 2.0 * rim); // far enough to leave the frame
|
|
52
|
+
float lean = tilt * p * (2.0 - p);
|
|
53
|
+
float fiber = smoothstep(0.0, 0.15, p); // no torn edge on the intact image
|
|
54
|
+
float aa = 0.002 * fiber + 1e-6;
|
|
55
|
+
vec2 q = vec2(uv.x * ratio, uv.y);
|
|
56
|
+
vec2 l = unfold(q, away, lean);
|
|
57
|
+
vec2 r = unfold(vec2(ratio - q.x, q.y), away, lean);
|
|
58
|
+
float el = l.x - tear(l.y); // > 0 right of the left half's torn edge
|
|
59
|
+
float er = r.x - (ratio - tear(r.y)); // > 0 left of the right half's torn edge
|
|
60
|
+
// soft shadow of the two halves on the incoming image, cast toward the right
|
|
61
|
+
vec2 sq = q - vec2(0.01, 0.0);
|
|
62
|
+
float dl = unfold(sq, away, lean).x - meander(sq.y);
|
|
63
|
+
float dr = unfold(vec2(ratio - sq.x, sq.y), away, lean).x - (ratio - meander(sq.y));
|
|
64
|
+
vec4 to = getToColor(uv);
|
|
65
|
+
float sh = shadow.a * (1.0 - smoothstep(-0.02, 0.08, min(dl, dr)));
|
|
66
|
+
vec4 c = vec4(mix(to.rgb, shadow.rgb, sh), to.a);
|
|
67
|
+
// the image stops at the tear; the bare paper fibers stick out a little beyond it
|
|
68
|
+
if (r.x >= 0.0) {
|
|
69
|
+
c = torn(c, getFromColor(vec2(1.0 - r.x / ratio, r.y)), er, fibers(r.y, 2.0) * 1.5 * fiber, aa);
|
|
70
|
+
}
|
|
71
|
+
if (l.x >= 0.0) {
|
|
72
|
+
c = torn(c, getFromColor(vec2(l.x / ratio, l.y)), el, fibers(l.y, 0.0) * fiber, aa);
|
|
73
|
+
}
|
|
74
|
+
return c;
|
|
75
|
+
}
|