gl-transitions 3.0.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 +80 -0
- package/compatibility.json +455 -11
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/BookFlip.glsl +124 -21
- package/glsl3/CircleBurst.glsl +77 -0
- package/glsl3/Clothesline.glsl +217 -0
- package/glsl3/CodeRain.glsl +114 -0
- package/glsl3/ComicPanels.glsl +174 -0
- package/glsl3/Cube.glsl +105 -52
- package/glsl3/CurtainRise.glsl +71 -0
- package/glsl3/DominoFall.glsl +114 -0
- package/glsl3/Doorway.glsl +74 -38
- package/glsl3/Drape.glsl +186 -0
- package/glsl3/DuotoneFade.glsl +58 -0
- package/glsl3/FacetedGlass.glsl +137 -0
- package/glsl3/FrostWipe.glsl +176 -0
- package/glsl3/Funnel.glsl +71 -0
- package/glsl3/GlitterDissolve.glsl +171 -0
- package/glsl3/GravityLens.glsl +66 -0
- package/glsl3/GridFlip.glsl +151 -56
- package/glsl3/HeartWipe.glsl +71 -11
- package/glsl3/InsideCube.glsl +114 -0
- package/glsl3/KeyholeWipe.glsl +104 -0
- package/glsl3/LedWall.glsl +127 -0
- package/glsl3/MoireWipe.glsl +75 -0
- package/glsl3/PaperFold.glsl +168 -0
- package/glsl3/PuzzleCube.glsl +205 -0
- package/glsl3/RibbonTwist.glsl +53 -0
- package/glsl3/RingSpin.glsl +112 -0
- package/glsl3/Shatter.glsl +231 -35
- package/glsl3/SketchDissolve.glsl +100 -0
- package/glsl3/SlotReels.glsl +118 -0
- package/glsl3/SplitFlap.glsl +124 -0
- package/glsl3/SpotlightWipe.glsl +63 -0
- package/glsl3/Swirl.glsl +52 -21
- package/glsl3/TruchetWipe.glsl +80 -0
- package/glsl3/Tumble.glsl +113 -0
- package/glsl3/WaterDrop.glsl +69 -13
- package/glsl3/WaveWipe.glsl +154 -0
- package/index.js +1 -1
- package/layouts.json +1232 -29
- package/llms-full.txt +890 -403
- package/llms.txt +225 -197
- package/msl/BookFlip.metal +575 -114
- package/msl/CircleBurst.metal +351 -0
- package/msl/Clothesline.metal +828 -0
- package/msl/CodeRain.metal +451 -0
- package/msl/ComicPanels.metal +959 -0
- package/msl/Cube.metal +466 -170
- package/msl/CurtainRise.metal +263 -0
- package/msl/DominoFall.metal +510 -0
- package/msl/Doorway.metal +350 -124
- package/msl/Drape.metal +767 -0
- package/msl/DuotoneFade.metal +218 -0
- package/msl/FacetedGlass.metal +529 -0
- package/msl/FrostWipe.metal +677 -0
- package/msl/Funnel.metal +276 -0
- package/msl/GlitterDissolve.metal +637 -0
- package/msl/GravityLens.metal +236 -0
- package/msl/GridFlip.metal +548 -191
- package/msl/HeartWipe.metal +230 -58
- package/msl/InsideCube.metal +537 -0
- package/msl/KeyholeWipe.metal +370 -0
- package/msl/LedWall.metal +437 -0
- package/msl/MoireWipe.metal +252 -0
- package/msl/PaperFold.metal +762 -0
- package/msl/PuzzleCube.metal +1179 -0
- package/msl/RibbonTwist.metal +235 -0
- package/msl/RingSpin.metal +474 -0
- package/msl/Shatter.metal +1136 -160
- package/msl/SketchDissolve.metal +446 -0
- package/msl/SlotReels.metal +436 -0
- package/msl/SplitFlap.metal +589 -0
- package/msl/SpotlightWipe.metal +217 -0
- package/msl/Swirl.metal +144 -77
- package/msl/TruchetWipe.metal +285 -0
- package/msl/Tumble.metal +466 -0
- package/msl/WaterDrop.metal +258 -49
- package/msl/WaveWipe.metal +618 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +115 -57
- package/sksl/BookFlip.sksl +117 -20
- package/sksl/CircleBurst.sksl +84 -0
- package/sksl/Clothesline.sksl +217 -0
- package/sksl/CodeRain.sksl +124 -0
- package/sksl/ComicPanels.sksl +176 -0
- package/sksl/Cube.sksl +99 -46
- package/sksl/CurtainRise.sksl +84 -0
- package/sksl/DominoFall.sksl +122 -0
- package/sksl/Doorway.sksl +65 -35
- package/sksl/Drape.sksl +192 -0
- package/sksl/DuotoneFade.sksl +71 -0
- package/sksl/FacetedGlass.sksl +148 -0
- package/sksl/FrostWipe.sksl +183 -0
- package/sksl/Funnel.sksl +83 -0
- package/sksl/GlitterDissolve.sksl +175 -0
- package/sksl/GravityLens.sksl +77 -0
- package/sksl/GridFlip.sksl +141 -52
- package/sksl/HeartWipe.sksl +60 -11
- package/sksl/InsideCube.sksl +123 -0
- package/sksl/KeyholeWipe.sksl +109 -0
- package/sksl/LedWall.sksl +137 -0
- package/sksl/MoireWipe.sksl +85 -0
- package/sksl/PaperFold.sksl +170 -0
- package/sksl/PuzzleCube.sksl +203 -0
- package/sksl/RibbonTwist.sksl +66 -0
- package/sksl/RingSpin.sksl +121 -0
- package/sksl/Shatter.sksl +218 -33
- package/sksl/SketchDissolve.sksl +111 -0
- package/sksl/SlotReels.sksl +127 -0
- package/sksl/SplitFlap.sksl +131 -0
- package/sksl/SpotlightWipe.sksl +74 -0
- package/sksl/Swirl.sksl +49 -20
- package/sksl/TruchetWipe.sksl +92 -0
- package/sksl/Tumble.sksl +122 -0
- package/sksl/WaterDrop.sksl +64 -10
- package/sksl/WaveWipe.sksl +165 -0
- package/sksl/index.js +1 -1
- package/transitions/BookFlip.glsl +124 -21
- package/transitions/CircleBurst.glsl +76 -0
- package/transitions/Clothesline.glsl +216 -0
- package/transitions/CodeRain.glsl +113 -0
- package/transitions/ComicPanels.glsl +173 -0
- package/transitions/Cube.glsl +105 -52
- package/transitions/CurtainRise.glsl +70 -0
- package/transitions/DominoFall.glsl +113 -0
- package/transitions/Doorway.glsl +74 -38
- package/transitions/Drape.glsl +185 -0
- package/transitions/DuotoneFade.glsl +57 -0
- package/transitions/FacetedGlass.glsl +136 -0
- package/transitions/FrostWipe.glsl +175 -0
- package/transitions/Funnel.glsl +70 -0
- package/transitions/GlitterDissolve.glsl +170 -0
- package/transitions/GravityLens.glsl +65 -0
- package/transitions/GridFlip.glsl +151 -56
- package/transitions/HeartWipe.glsl +71 -11
- package/transitions/InsideCube.glsl +113 -0
- package/transitions/KeyholeWipe.glsl +103 -0
- package/transitions/LedWall.glsl +126 -0
- package/transitions/MoireWipe.glsl +74 -0
- package/transitions/PaperFold.glsl +167 -0
- package/transitions/PuzzleCube.glsl +204 -0
- package/transitions/RibbonTwist.glsl +52 -0
- package/transitions/RingSpin.glsl +111 -0
- package/transitions/Shatter.glsl +231 -35
- package/transitions/SketchDissolve.glsl +99 -0
- package/transitions/SlotReels.glsl +117 -0
- package/transitions/SplitFlap.glsl +123 -0
- package/transitions/SpotlightWipe.glsl +62 -0
- package/transitions/Swirl.glsl +52 -21
- package/transitions/TruchetWipe.glsl +79 -0
- package/transitions/Tumble.glsl +112 -0
- package/transitions/WaterDrop.glsl +69 -13
- package/transitions/WaveWipe.glsl +153 -0
- package/wgsl/BookFlip.wgsl +552 -105
- package/wgsl/CircleBurst.wgsl +310 -0
- package/wgsl/Clothesline.wgsl +756 -0
- package/wgsl/CodeRain.wgsl +415 -0
- package/wgsl/ComicPanels.wgsl +886 -0
- package/wgsl/Cube.wgsl +461 -156
- package/wgsl/CurtainRise.wgsl +235 -0
- package/wgsl/DominoFall.wgsl +461 -0
- package/wgsl/Doorway.wgsl +333 -117
- package/wgsl/Drape.wgsl +715 -0
- package/wgsl/DuotoneFade.wgsl +185 -0
- package/wgsl/FacetedGlass.wgsl +476 -0
- package/wgsl/FrostWipe.wgsl +617 -0
- package/wgsl/Funnel.wgsl +248 -0
- package/wgsl/GlitterDissolve.wgsl +582 -0
- package/wgsl/GravityLens.wgsl +206 -0
- package/wgsl/GridFlip.wgsl +523 -188
- package/wgsl/HeartWipe.wgsl +225 -55
- package/wgsl/InsideCube.wgsl +496 -0
- package/wgsl/KeyholeWipe.wgsl +337 -0
- package/wgsl/LedWall.wgsl +397 -0
- package/wgsl/MoireWipe.wgsl +222 -0
- package/wgsl/PaperFold.wgsl +700 -0
- package/wgsl/PuzzleCube.wgsl +1087 -0
- package/wgsl/RibbonTwist.wgsl +206 -0
- package/wgsl/RingSpin.wgsl +426 -0
- package/wgsl/Shatter.wgsl +1091 -148
- package/wgsl/SketchDissolve.wgsl +409 -0
- package/wgsl/SlotReels.wgsl +391 -0
- package/wgsl/SplitFlap.wgsl +533 -0
- package/wgsl/SpotlightWipe.wgsl +186 -0
- package/wgsl/Swirl.wgsl +138 -77
- package/wgsl/TruchetWipe.wgsl +255 -0
- package/wgsl/Tumble.wgsl +424 -0
- package/wgsl/WaterDrop.wgsl +251 -49
- package/wgsl/WaveWipe.wgsl +581 -0
|
@@ -1,36 +1,139 @@
|
|
|
1
1
|
// Author: hong
|
|
2
2
|
// License: MIT
|
|
3
|
-
// Description: The outgoing image
|
|
3
|
+
// Description: The right half of the outgoing image is a book page that turns over from right to left on the spine at the middle of the frame, curling near its free edge, its back bringing the left half of the incoming image
|
|
4
4
|
// Tags: page, flip, 3d
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
// @range(0, 1) Strength of the perspective: the page grows as it lifts toward the viewer
|
|
7
|
+
uniform float perspective; // = 0.5
|
|
8
|
+
// @range(0, 1) How much the page darkens as it turns away from the light, and the shadows it casts
|
|
9
|
+
uniform float shading; // = 0.6
|
|
10
|
+
// @range(0, 1) How much the page bends near its free edge, which trails behind as it turns
|
|
11
|
+
uniform float curl; // = 0.5
|
|
12
|
+
|
|
13
|
+
const float PI = 3.141592653589793;
|
|
14
|
+
// width of the anti-aliased edges, as a part of the frame's height
|
|
15
|
+
const float EDGE = 0.0015;
|
|
16
|
+
// part of the page's width that curls
|
|
17
|
+
const float CURL_PART = 0.45;
|
|
18
|
+
// direction of the light, in (x, height toward the viewer)
|
|
19
|
+
const vec2 LIGHT = vec2(-0.447214, 0.894427);
|
|
20
|
+
|
|
21
|
+
float cross2(vec2 a, vec2 b) {
|
|
22
|
+
return a.x * b.y - a.y * b.x;
|
|
9
23
|
}
|
|
10
24
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
float
|
|
14
|
-
return
|
|
25
|
+
// the page's angle, 0 lying on the right to PI lying on the left: eased, but never at rest
|
|
26
|
+
float pageAngle() {
|
|
27
|
+
float p = clamp(progress, 0.0, 1.0);
|
|
28
|
+
return PI * p * (0.35 + p * (1.95 - 1.3 * p));
|
|
15
29
|
}
|
|
16
30
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
// The page is seen in a cross-section across the spine, in (x, height toward the viewer) from the spine:
|
|
32
|
+
// a straight part at angle a from the spine, then, when k is not 0, an arc of curvature k centered on c up to its free edge,
|
|
33
|
+
// extruded along y. Returns the nearest point of the page hit by the ray from eye along dir:
|
|
34
|
+
// (ray length, distance along the page, angle there), with a negative ray length when it is missed.
|
|
35
|
+
vec3 hitPage(vec2 eye, vec2 dir, float a, float k, float straight, vec2 c, float w) {
|
|
36
|
+
vec3 best = vec3(-1.0, 0.0, 0.0);
|
|
37
|
+
vec2 d = vec2(cos(a), sin(a));
|
|
38
|
+
// the straight part
|
|
39
|
+
float den = cross2(d, dir);
|
|
40
|
+
if (abs(den) > 1e-7) {
|
|
41
|
+
float u = cross2(eye, dir) / den;
|
|
42
|
+
float t = cross2(eye, d) / den;
|
|
43
|
+
if (t > 0.0 && u >= 0.0 && u <= straight) best = vec3(t, u, a);
|
|
44
|
+
}
|
|
45
|
+
if (k != 0.0) {
|
|
46
|
+
float r = 1.0 / k;
|
|
47
|
+
vec2 oc = eye - c;
|
|
48
|
+
float qa = dot(dir, dir);
|
|
49
|
+
float qb = dot(oc, dir);
|
|
50
|
+
float disc = qb * qb - qa * (dot(oc, oc) - r * r);
|
|
51
|
+
if (disc >= 0.0) {
|
|
52
|
+
float sq = sqrt(disc);
|
|
53
|
+
for (int i = 0; i < 2; i++) {
|
|
54
|
+
float t = (-qb + (i == 0 ? -sq : sq)) / qa;
|
|
55
|
+
if (t > 0.0 && (best.x < 0.0 || t < best.x)) {
|
|
56
|
+
// (sin(b), -cos(b)) where b is the angle of the page at that point
|
|
57
|
+
vec2 v = (oc + t * dir) * k;
|
|
58
|
+
float db = atan(v.x, -v.y) - a;
|
|
59
|
+
db -= 2.0 * PI * floor((db + PI) / (2.0 * PI));
|
|
60
|
+
float s = db / k;
|
|
61
|
+
if (s >= 0.0 && s <= w - straight) best = vec3(t, straight + s, a + db);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return best;
|
|
21
67
|
}
|
|
22
68
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
69
|
+
// the point of the curled part of the page where its angle is b
|
|
70
|
+
vec2 curlPoint(vec2 c, float k, float b) {
|
|
71
|
+
return c + vec2(sin(b), -cos(b)) / k;
|
|
26
72
|
}
|
|
27
73
|
|
|
28
|
-
vec4 transition (vec2
|
|
29
|
-
float
|
|
74
|
+
vec4 transition (vec2 uv) {
|
|
75
|
+
float a = pageAngle();
|
|
76
|
+
float lift = sin(a);
|
|
77
|
+
// half the frame's width: the page's width
|
|
78
|
+
float w = 0.5 * ratio;
|
|
79
|
+
float x = uv.x * ratio - w;
|
|
80
|
+
// the viewer is above the spine, the page lifting toward it
|
|
81
|
+
float dist = w * (1.0 + 1.5 / max(perspective, 0.01));
|
|
82
|
+
vec2 eye = vec2(0.0, dist);
|
|
83
|
+
vec2 dir = vec2(x, -dist);
|
|
84
|
+
|
|
85
|
+
// the shape of the page: straight, then curled with its free edge trailing behind (a negative curvature)
|
|
86
|
+
vec2 d = vec2(cos(a), sin(a));
|
|
87
|
+
float k = -clamp(curl, 0.0, 1.0) * lift / (CURL_PART * w);
|
|
88
|
+
if (abs(k) * CURL_PART * w <= 1e-4) k = 0.0;
|
|
89
|
+
float straight = k != 0.0 ? (1.0 - CURL_PART) * w : w;
|
|
90
|
+
vec2 c = straight * d + vec2(-d.y, d.x) / (k != 0.0 ? k : 1.0);
|
|
91
|
+
vec2 bend = straight * d;
|
|
92
|
+
vec2 middle = k != 0.0 ? curlPoint(c, k, a + 0.5 * k * (w - straight)) : bend;
|
|
93
|
+
vec2 edge = k != 0.0 ? curlPoint(c, k, a + k * (w - straight)) : bend;
|
|
30
94
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
95
|
+
// anti-aliased edges, only once the page has left the frame's plane, so that it covers it exactly at both ends
|
|
96
|
+
float aa = EDGE * min(20.0 * lift, 1.0);
|
|
97
|
+
vec4 img = vec4(0.0);
|
|
98
|
+
float m = 0.0;
|
|
99
|
+
vec3 hit = hitPage(eye, dir, a, k, straight, c, w);
|
|
100
|
+
if (hit.x > 0.0) {
|
|
101
|
+
float t = hit.x;
|
|
102
|
+
float u = hit.y;
|
|
103
|
+
float b = hit.z;
|
|
104
|
+
vec2 pt = eye + t * dir;
|
|
105
|
+
// the height on the page, magnified as it comes closer (its top and bottom edges are out of the frame)
|
|
106
|
+
float y = clamp(0.5 + (uv.y - 0.5) * t, 0.0, 1.0);
|
|
107
|
+
// near its free edge, the distance to it on the screen
|
|
108
|
+
float edgeX = edge.x * dist / max(dist - edge.y, 1e-4);
|
|
109
|
+
m = aa > 0.0 && u > (k != 0.0 ? straight : 0.5 * w) ? clamp(abs(x - edgeX) / aa, 0.0, 1.0) : 1.0;
|
|
110
|
+
vec2 normal = vec2(-sin(b), cos(b));
|
|
111
|
+
bool front = dot(normal, eye - pt) > 0.0;
|
|
112
|
+
img = front
|
|
113
|
+
? getFromColor(vec2(clamp(w + u, w, ratio) / ratio, y))
|
|
114
|
+
: getToColor(vec2(clamp(w - u, 0.0, w) / ratio, y));
|
|
115
|
+
// lit from the upper left: brighter as it turns toward the light, darker as it turns away, with a soft crease along the spine
|
|
116
|
+
float diffuse = max(dot(front ? normal : -normal, LIGHT), 0.0) / LIGHT.y;
|
|
117
|
+
float shade = mix(1.0, 0.25 + 0.75 * diffuse, shading);
|
|
118
|
+
shade *= 1.0 - 0.35 * shading * lift * exp(-u / (0.04 * w));
|
|
119
|
+
img.rgb *= shade;
|
|
120
|
+
if (m >= 1.0) return img;
|
|
35
121
|
}
|
|
122
|
+
|
|
123
|
+
// the pages beneath: the outgoing image on the left, the incoming one on the right
|
|
124
|
+
vec4 color = x < 0.0 ? getFromColor(uv) : getToColor(uv);
|
|
125
|
+
// the lifted page shades them, the more it hides of the sky (and so the more near the spine and its free edge)
|
|
126
|
+
vec2 toEdge = edge - vec2(x, 0.0);
|
|
127
|
+
float cosEdge = toEdge.x / max(length(toEdge), 1e-6);
|
|
128
|
+
float blocked = 0.5 * abs((x < 0.0 ? 1.0 : -1.0) - cosEdge);
|
|
129
|
+
float shadow = blocked * blocked * (3.0 - 2.0 * blocked);
|
|
130
|
+
// and casts a shadow, the light coming from the upper left, softer as the page is higher
|
|
131
|
+
float slope = -LIGHT.x / LIGHT.y;
|
|
132
|
+
vec3 reach = vec3(bend.x, middle.x, edge.x) + slope * vec3(bend.y, middle.y, edge.y);
|
|
133
|
+
float lo = min(0.0, min(reach.x, min(reach.y, reach.z)));
|
|
134
|
+
float hi = max(0.0, max(reach.x, max(reach.y, reach.z)));
|
|
135
|
+
float soft = max(0.25 * edge.y, 1e-5);
|
|
136
|
+
shadow = max(0.5 * shadow, 0.85 * clamp(min(x - lo, hi - x) / soft + 0.5, 0.0, 1.0) * min(4.0 * lift, 1.0));
|
|
137
|
+
color.rgb *= 1.0 - shading * shadow;
|
|
138
|
+
return mix(color, img, m);
|
|
36
139
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// 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
|
|
4
|
+
// Tags: circle, burst, color, reveal, motion-graphics
|
|
5
|
+
|
|
6
|
+
// @param Point the discs burst out of, in texture coordinates
|
|
7
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
8
|
+
// @color Color of the first disc
|
|
9
|
+
uniform vec4 color1; // = vec4(0.99, 0.79, 0.29, 1.0)
|
|
10
|
+
// @color Color of the second disc
|
|
11
|
+
uniform vec4 color2; // = vec4(0.95, 0.38, 0.33, 1.0)
|
|
12
|
+
// @color Color of the third disc, which opens onto the incoming image
|
|
13
|
+
uniform vec4 color3; // = vec4(0.13, 0.15, 0.3, 1.0)
|
|
14
|
+
// @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)
|
|
15
|
+
uniform float stagger; // = 0.3
|
|
16
|
+
|
|
17
|
+
// half width of the antialiased edges, in frame heights
|
|
18
|
+
const float AA = 0.0015;
|
|
19
|
+
// width and opacity of the soft shadow each disc casts on what is under it
|
|
20
|
+
const float SW = 0.03;
|
|
21
|
+
const float SO = 0.32;
|
|
22
|
+
|
|
23
|
+
// local progress of a layer starting at s and lasting d
|
|
24
|
+
float phase(float s, float d) {
|
|
25
|
+
return clamp((progress - s) / d, 0.0, 1.0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// radius of the edge of a layer at local progress t: it bursts out of just before the point and
|
|
29
|
+
// leaves the frame still moving, its shadow last
|
|
30
|
+
float radius(float t, float R) {
|
|
31
|
+
float u = 1.0 - t;
|
|
32
|
+
return mix(-SW - AA, R, mix(t, 1.0 - u * u * u, 0.8));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// fold texture coordinates back into the frame
|
|
36
|
+
vec2 mirror(vec2 v) {
|
|
37
|
+
return 1.0 - abs(1.0 - mod(abs(v), 2.0));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// a layer of color c and radius r laid over p (premultiplied), with its shadow around it, at distance x
|
|
41
|
+
vec4 layer(vec4 p, vec4 c, float r, float x) {
|
|
42
|
+
float k = smoothstep(r - AA, r + AA, x);
|
|
43
|
+
float s = SO * c.a * k * (1.0 - smoothstep(0.0, SW, x - r));
|
|
44
|
+
p = p * (1.0 - s) + vec4(0.0, 0.0, 0.0, s);
|
|
45
|
+
k = c.a * (1.0 - k);
|
|
46
|
+
return p * (1.0 - k) + vec4(c.rgb, 1.0) * k;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
vec4 transition(vec2 uv) {
|
|
50
|
+
vec2 asp = vec2(ratio, 1.0);
|
|
51
|
+
float x = length((uv - center) * asp);
|
|
52
|
+
// past the farthest corner, with room for the shadows
|
|
53
|
+
float R = length(max(center, 1.0 - center) * asp) + SW + AA;
|
|
54
|
+
float k = clamp(stagger, 0.0, 1.0);
|
|
55
|
+
float d = 1.0 / (1.0 + 3.0 * k);
|
|
56
|
+
|
|
57
|
+
// the outgoing image is pushed in by the first burst
|
|
58
|
+
float t = phase(0.0, d);
|
|
59
|
+
vec4 a = getFromColor(mirror(center + (uv - center) / (1.0 + 0.06 * t * (2.0 - t))));
|
|
60
|
+
vec4 p = vec4(a.rgb * a.a, a.a);
|
|
61
|
+
p = layer(p, color1, radius(t, R), x);
|
|
62
|
+
p = layer(p, color2, radius(phase(k * d, d), R), x);
|
|
63
|
+
float r = radius(phase(2.0 * k * d, d), R);
|
|
64
|
+
p = layer(p, color3, r, x);
|
|
65
|
+
|
|
66
|
+
// the hole in the last disc shows the incoming image, which pops in slightly zoomed, overshoots
|
|
67
|
+
// and settles, shaded along the hole's rim as much as the disc around it is wide
|
|
68
|
+
t = phase(3.0 * k * d, d);
|
|
69
|
+
float h = radius(t, R);
|
|
70
|
+
float u = 1.0 - t;
|
|
71
|
+
vec4 b = getToColor(mirror(center + (uv - center) / (1.0 + 0.14 * u * u * (1.0 - 2.4 * t))));
|
|
72
|
+
float s = SO * color3.a * clamp((r - h) / SW, 0.0, 1.0) * (1.0 - smoothstep(0.0, SW, h - x));
|
|
73
|
+
vec4 q = vec4(b.rgb * b.a * (1.0 - s), b.a * (1.0 - s) + s);
|
|
74
|
+
p = mix(p, q, 1.0 - smoothstep(h - AA, h + AA, x));
|
|
75
|
+
return p.a > 0.0 ? vec4(p.rgb / p.a, p.a) : vec4(0.0);
|
|
76
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The camera pulls back to show the outgoing image as a print hung by two clothespins on a line in front of a wall, the line is pulled sideways and carries it away while the incoming print slides in, both prints swinging and tilting like hanging paper, then the camera moves back in on the incoming print until it fills the frame
|
|
4
|
+
// Tags: 3d, perspective, slide, swing, paper, directional
|
|
5
|
+
|
|
6
|
+
// @param Way the line is pulled: 1 brings the incoming print in from the right, -1 from the left
|
|
7
|
+
uniform float direction; // = 1.0
|
|
8
|
+
// @range(0, 1) How much the prints swing and tilt as the line moves
|
|
9
|
+
uniform float sway; // = 0.5
|
|
10
|
+
// @range(0.4, 0.95) Size of the prints when the camera is farthest, as a part of the frame
|
|
11
|
+
uniform float size; // = 0.72
|
|
12
|
+
// @color Color of the wall behind the line
|
|
13
|
+
uniform vec4 background; // = vec4(0.86, 0.84, 0.8, 1.0)
|
|
14
|
+
// @color Color of the line
|
|
15
|
+
uniform vec4 lineColor; // = vec4(0.42, 0.34, 0.26, 1.0)
|
|
16
|
+
// @color Color of the clothespins
|
|
17
|
+
uniform vec4 pinColor; // = vec4(0.84, 0.68, 0.47, 1.0)
|
|
18
|
+
|
|
19
|
+
const float FOCAL = 2.0; // distance from the camera to a print when it fills the frame
|
|
20
|
+
const float GAP = 0.35; // space between two prints on the line, in frame heights
|
|
21
|
+
const float WALL = 0.14; // distance from the line to the wall behind it
|
|
22
|
+
const float ROPE = 0.0055; // half thickness of the line
|
|
23
|
+
const vec2 PIN = vec2(0.021, 0.072); // half size of a clothespin
|
|
24
|
+
const float PIN_Y = -0.01; // center of a clothespin below the top edge of its print
|
|
25
|
+
const float AA = 0.0015; // width of the antialiased edges, in frame heights
|
|
26
|
+
const vec3 LIGHT = vec3(-0.28, 0.48, 0.83); // toward the light: above, a bit on the left, in front
|
|
27
|
+
const float PIN_X = 0.32; // clothespins from the center of their print, in print widths
|
|
28
|
+
const int STEPS = 32; // steps of the swing simulation over the whole transition
|
|
29
|
+
|
|
30
|
+
// the line moves between these progress values
|
|
31
|
+
const float SLIDE_START = 0.1;
|
|
32
|
+
const float SLIDE_END = 0.86;
|
|
33
|
+
|
|
34
|
+
vec4 premultiply(vec4 c) {
|
|
35
|
+
return vec4(c.rgb * c.a, c.a);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// time of the line's move at p, from 0 to 1
|
|
39
|
+
float slideTime(float p) {
|
|
40
|
+
return clamp((p - SLIDE_START) / (SLIDE_END - SLIDE_START), 0.0, 1.0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// part of its travel done (smootherstep of the time)
|
|
44
|
+
float slideAmount(float u) {
|
|
45
|
+
return u * u * u * (u * (u * 6.0 - 15.0) + 10.0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// acceleration of the travel at p, per progress squared
|
|
49
|
+
float slideAccel(float p) {
|
|
50
|
+
float u = slideTime(p);
|
|
51
|
+
float dur = SLIDE_END - SLIDE_START;
|
|
52
|
+
return 60.0 * u * (1.0 - u) * (1.0 - 2.0 * u) / (dur * dur);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// the sideways swing of the prints' bottoms, along the travel: a damped pendulum driven by the
|
|
56
|
+
// line's acceleration, lagging behind it at the start and overshooting at the stop
|
|
57
|
+
float swing(float p) {
|
|
58
|
+
const float OMEGA = 10.0; // about 1.6 swings over the transition
|
|
59
|
+
const float DAMP = 0.28;
|
|
60
|
+
const float STEP = 1.0 / float(STEPS);
|
|
61
|
+
float x = 0.0;
|
|
62
|
+
float v = 0.0;
|
|
63
|
+
// fixed steps, the last one cut at p, so that every frame follows the same curve
|
|
64
|
+
for (int i = 0; i < STEPS; i++) {
|
|
65
|
+
float t0 = float(i) * STEP;
|
|
66
|
+
float dt = clamp(p - t0, 0.0, STEP);
|
|
67
|
+
float a = slideAccel(t0 + 0.5 * dt) - OMEGA * OMEGA * x - 2.0 * DAMP * OMEGA * v;
|
|
68
|
+
v += a * dt;
|
|
69
|
+
x += v * dt;
|
|
70
|
+
}
|
|
71
|
+
// it settles as the camera moves back in
|
|
72
|
+
return x * (1.0 - smoothstep(0.7, 1.0, p));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// signed distance to a rounded box of half size b and corner radius r
|
|
76
|
+
float roundedBox(vec2 q, vec2 b, float r) {
|
|
77
|
+
vec2 d = abs(q) - b + r;
|
|
78
|
+
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// the point (u across, v down from the top edge) where the ray o + t d meets the plane of a print
|
|
82
|
+
// hanging from (cx, 0.5, 0) and swung back by psi around its top edge, and t
|
|
83
|
+
vec3 printHit(vec3 o, vec3 d, float cx, float psi) {
|
|
84
|
+
vec3 dn = vec3(0.0, -cos(psi), -sin(psi));
|
|
85
|
+
vec3 n = vec3(0.0, sin(psi), -cos(psi));
|
|
86
|
+
vec3 p0 = vec3(cx, 0.5, 0.0);
|
|
87
|
+
float t = dot(p0 - o, n) / dot(d, n);
|
|
88
|
+
vec3 q = o + d * t - p0;
|
|
89
|
+
return vec3(q.x, dot(q, dn), t);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// the bottom of the print bends sideways by bend frame heights
|
|
93
|
+
float bendShift(float v, float bend) {
|
|
94
|
+
float h = clamp(v, 0.0, 1.0);
|
|
95
|
+
return bend * h * (0.6 + 0.4 * h);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// signed distance to the paper (negative inside), in frame heights
|
|
99
|
+
float paperDist(vec2 uv, float bend) {
|
|
100
|
+
vec2 q = abs(vec2(uv.x - bendShift(uv.y, bend), uv.y - 0.5)) - vec2(0.5 * ratio, 0.5);
|
|
101
|
+
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// signed distance to the two clothespins of a print
|
|
105
|
+
float pinDist(vec2 uv) {
|
|
106
|
+
vec2 q = vec2(abs(uv.x) - PIN_X * ratio, uv.y - PIN_Y);
|
|
107
|
+
return roundedBox(q, PIN, 0.012);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// the print hanging at cx over col (premultiplied), then its clothespins
|
|
111
|
+
vec4 drawPrint(vec4 col, vec3 h, bool isFrom, float bend, float psi, float aa, float vis) {
|
|
112
|
+
vec2 lp = h.xy;
|
|
113
|
+
float d = paperDist(lp, bend);
|
|
114
|
+
float cov = clamp(0.5 - d / (h.z * aa), 0.0, 1.0);
|
|
115
|
+
if (cov > 0.0) {
|
|
116
|
+
vec2 st = clamp(vec2((lp.x - bendShift(lp.y, bend)) / ratio + 0.5, 1.0 - lp.y), 0.0, 1.0);
|
|
117
|
+
vec4 c = premultiply(isFrom ? getFromColor(st) : getToColor(st));
|
|
118
|
+
// the paper darkens as it swings back and bends, and under the clothespins
|
|
119
|
+
float shade = 1.0 - 1.2 * abs(sin(psi)) * lp.y - 0.35 * abs(bend) * lp.y;
|
|
120
|
+
float ps = pinDist(lp - vec2(0.006, 0.01));
|
|
121
|
+
shade -= 0.35 * vis * (1.0 - smoothstep(-0.004, 0.012, ps));
|
|
122
|
+
c.rgb *= clamp(shade, 0.0, 1.0);
|
|
123
|
+
col = c * cov + col * (1.0 - c.a * cov);
|
|
124
|
+
}
|
|
125
|
+
return col;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
vec4 drawPins(vec4 col, vec3 h, float aa, float vis) {
|
|
129
|
+
vec2 lp = h.xy;
|
|
130
|
+
float d = pinDist(lp);
|
|
131
|
+
float cov = vis * clamp(0.5 - d / (h.z * aa), 0.0, 1.0);
|
|
132
|
+
if (cov > 0.0) {
|
|
133
|
+
// rounded wood, with the steel spring across it
|
|
134
|
+
float k = clamp((abs(lp.x) - PIN_X * ratio) / PIN.x, -1.0, 1.0);
|
|
135
|
+
vec3 c = pinColor.rgb * (0.62 + 0.45 * sqrt(1.0 - k * k));
|
|
136
|
+
float y = lp.y - PIN_Y;
|
|
137
|
+
float spring = 1.0 - smoothstep(0.004, 0.007, abs(y + 0.02));
|
|
138
|
+
c = mix(c, vec3(0.3, 0.31, 0.33) * (0.6 + 0.8 * sqrt(1.0 - k * k)), spring);
|
|
139
|
+
// the groove that grips the paper
|
|
140
|
+
c *= 1.0 - 0.3 * (1.0 - smoothstep(0.002, 0.005, abs(y - 0.012)));
|
|
141
|
+
vec4 pc = premultiply(vec4(c, pinColor.a));
|
|
142
|
+
col = pc * cov + col * (1.0 - pc.a * cov);
|
|
143
|
+
}
|
|
144
|
+
return col;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
vec4 transition(vec2 uv) {
|
|
148
|
+
float p = progress;
|
|
149
|
+
float s = direction < 0.0 ? -1.0 : 1.0;
|
|
150
|
+
float sw = clamp(sway, 0.0, 1.0);
|
|
151
|
+
|
|
152
|
+
// the camera pulls back, then moves back in on the incoming print
|
|
153
|
+
float back = smoothstep(0.0, 0.3, p) * (1.0 - smoothstep(0.6, 1.0, p));
|
|
154
|
+
float zoom = mix(1.0, clamp(size, 0.1, 1.0), back);
|
|
155
|
+
float vis = smoothstep(0.0, 0.35, back);
|
|
156
|
+
vec3 o = vec3(0.0, 0.05 * back, FOCAL / zoom);
|
|
157
|
+
vec3 d = vec3((uv - 0.5) * vec2(ratio, 1.0), -FOCAL);
|
|
158
|
+
float aa = max(AA * min(1.0, 40.0 * back), 1e-6);
|
|
159
|
+
|
|
160
|
+
// the line carries the prints along
|
|
161
|
+
float u = slideTime(p);
|
|
162
|
+
float m = slideAmount(u);
|
|
163
|
+
float speed = 16.0 * u * u * (1.0 - u) * (1.0 - u);
|
|
164
|
+
float spacing = ratio + GAP;
|
|
165
|
+
float cFrom = -s * spacing * m;
|
|
166
|
+
float cTo = s * spacing * (1.0 - m);
|
|
167
|
+
// the bottoms lag behind and overshoot, and swing back in the wind of the move
|
|
168
|
+
float bend = s * 0.65 * sw * swing(p);
|
|
169
|
+
float psi = 0.45 * sw * speed;
|
|
170
|
+
|
|
171
|
+
vec3 hf = printHit(o, d, cFrom, psi);
|
|
172
|
+
vec3 ht = printHit(o, d, cTo, psi);
|
|
173
|
+
|
|
174
|
+
// the wall, seen around the prints (only behind their transparent parts at the ends),
|
|
175
|
+
// with the soft shadows of the prints, the pins and the line
|
|
176
|
+
vec4 col = premultiply(background);
|
|
177
|
+
float cover = max(
|
|
178
|
+
clamp(0.5 - paperDist(hf.xy, bend) / (hf.z * aa), 0.0, 1.0),
|
|
179
|
+
clamp(0.5 - paperDist(ht.xy, bend) / (ht.z * aa), 0.0, 1.0));
|
|
180
|
+
col *= mix(1.0, back, cover);
|
|
181
|
+
if (back > 0.0) {
|
|
182
|
+
vec3 w = o + d * ((o.z + WALL) / FOCAL);
|
|
183
|
+
vec3 sf = printHit(w, LIGHT, cFrom, psi);
|
|
184
|
+
vec3 st = printHit(w, LIGHT, cTo, psi);
|
|
185
|
+
float blur = 0.025;
|
|
186
|
+
float sh = 1.0 - smoothstep(-blur, blur, min(paperDist(sf.xy, bend), paperDist(st.xy, bend)));
|
|
187
|
+
sh = max(sh, 1.0 - smoothstep(-0.012, 0.02, min(pinDist(sf.xy), pinDist(st.xy))));
|
|
188
|
+
float ry = w.y + LIGHT.y * (WALL / LIGHT.z) - (0.5 - 0.012);
|
|
189
|
+
sh = max(sh, 0.8 * (1.0 - smoothstep(0.0, 0.012, abs(ry))));
|
|
190
|
+
// and a soft falloff of the light away from the top left
|
|
191
|
+
float fall = 0.1 * clamp(length(w.xy - vec2(-0.4 * ratio, 0.6)) / (1.2 * ratio + 0.6), 0.0, 1.0);
|
|
192
|
+
col.rgb *= (1.0 - 0.42 * vis * sh) * (1.0 - fall * vis);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
col = drawPrint(col, hf, true, bend, psi, aa, vis);
|
|
196
|
+
col = drawPrint(col, ht, false, bend, psi, aa, vis);
|
|
197
|
+
|
|
198
|
+
// the line, in front of the top of the prints
|
|
199
|
+
if (vis > 0.0) {
|
|
200
|
+
float tl = (o.z - 0.004) / FOCAL;
|
|
201
|
+
float ly = o.y + d.y * tl - (0.5 - 0.012);
|
|
202
|
+
float lc = vis * clamp(0.5 - (abs(ly) - ROPE) / (tl * aa), 0.0, 1.0);
|
|
203
|
+
if (lc > 0.0) {
|
|
204
|
+
float k = clamp(ly / ROPE, -1.0, 1.0);
|
|
205
|
+
// twisted strands, carried along with the line, lit from above
|
|
206
|
+
float lx = o.x + d.x * tl + s * spacing * m;
|
|
207
|
+
float strand = 0.88 + 0.12 * sin((lx + ly * 0.6) * 360.0);
|
|
208
|
+
vec3 c = lineColor.rgb * (0.7 + 0.45 * sqrt(1.0 - k * k) + 0.15 * k) * strand;
|
|
209
|
+
vec4 lcp = premultiply(vec4(c, lineColor.a));
|
|
210
|
+
col = lcp * lc + col * (1.0 - lcp.a * lc);
|
|
211
|
+
}
|
|
212
|
+
col = drawPins(col, hf, aa, vis);
|
|
213
|
+
col = drawPins(col, ht, aa, vis);
|
|
214
|
+
}
|
|
215
|
+
return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
|
|
216
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// 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
|
|
4
|
+
// Tags: text, digital, rain, reveal
|
|
5
|
+
|
|
6
|
+
// @range(0.02, 0.1) Height of a character, in frame heights
|
|
7
|
+
uniform float cellSize; // = 0.045
|
|
8
|
+
// @range(0.05, 1) Average length of the streams' fading tails, in frame heights
|
|
9
|
+
uniform float trail; // = 0.5
|
|
10
|
+
// @range(0, 1) How much the characters of the outgoing image take its colors, instead of the glow color
|
|
11
|
+
uniform float tint; // = 0.5
|
|
12
|
+
// @color Color of the falling streams and their glow
|
|
13
|
+
uniform vec4 glow; // = vec4(0.2, 1.0, 0.4, 1.0)
|
|
14
|
+
|
|
15
|
+
float hash12(vec2 p) {
|
|
16
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
17
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
18
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
vec4 hash42(vec2 p) {
|
|
22
|
+
vec4 p4 = fract(vec4(p.xyxy) * vec4(0.1031, 0.1030, 0.0973, 0.1099));
|
|
23
|
+
p4 += dot(p4, p4.wzxy + 33.33);
|
|
24
|
+
return fract((p4.xxyz + p4.yzzw) * p4.zywx);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 1 inside a stroke, fading out from 0.3 to 0.6 dot of distance
|
|
28
|
+
vec4 band(vec4 d) {
|
|
29
|
+
return 1.0 - smoothstep(0.3, 0.6, d);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// coverage of the character of this cell at this time, drawn on a 5x7 dot grid in a 6x8 cell
|
|
33
|
+
// (local: 0..1 in the cell, from its top left), made of strokes picked by hashes
|
|
34
|
+
float glyph(vec2 cell, float t, vec2 local) {
|
|
35
|
+
vec2 b = local * vec2(6.0, 8.0) - 0.5;
|
|
36
|
+
float x = b.x;
|
|
37
|
+
float y = b.y;
|
|
38
|
+
float d = 0.667 * y;
|
|
39
|
+
// how far outside the spans 0..4, 0..6, 0..3 and 3..6, in dots
|
|
40
|
+
float x04 = abs(x - 2.0) - 2.0;
|
|
41
|
+
float y06 = abs(y - 3.0) - 3.0;
|
|
42
|
+
float y03 = abs(y - 1.5) - 1.5;
|
|
43
|
+
float y36 = abs(y - 4.5) - 1.5;
|
|
44
|
+
vec2 seed = cell + t * vec2(37.0, 61.0);
|
|
45
|
+
// strokes: three bars and a diagonal, the halves of the side verticals,
|
|
46
|
+
// the halves of the middle vertical, the other diagonal and a short bar
|
|
47
|
+
vec4 sa = band(abs(vec4(y, y - 3.0, y - 6.0, x - d))) * band(vec4(x04, x04, x04, y06));
|
|
48
|
+
vec4 sb = band(abs(vec4(x, x, x - 4.0, x - 4.0))) * band(vec4(y03, y36, y03, y36));
|
|
49
|
+
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));
|
|
50
|
+
float on = dot(step(0.68, hash42(seed)), sa);
|
|
51
|
+
on += dot(step(0.68, hash42(seed + 41.0)), sb);
|
|
52
|
+
on += dot(step(0.68, hash42(seed + 83.0)), sc);
|
|
53
|
+
return min(on, 1.0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
vec4 transition(vec2 uv) {
|
|
57
|
+
float h = max(cellSize, 0.005);
|
|
58
|
+
vec2 dims = vec2(0.75 * h, h);
|
|
59
|
+
// frame coordinates from the top left, in frame heights
|
|
60
|
+
vec2 fp = vec2(uv.x * ratio, 1.0 - uv.y);
|
|
61
|
+
// (shifted by odd fractions of a cell, so that pixel centers don't fall on its lines at usual sizes)
|
|
62
|
+
vec2 grid = fp / dims + vec2(0.389, 0.278);
|
|
63
|
+
vec2 cell = floor(grid);
|
|
64
|
+
vec2 local = grid - cell;
|
|
65
|
+
float rc = hash12(cell + vec2(97.0, 131.0));
|
|
66
|
+
|
|
67
|
+
// each column has its own stream: its start, speed and tail length
|
|
68
|
+
float r1 = hash12(vec2(cell.x, 11.0));
|
|
69
|
+
float r2 = hash12(vec2(cell.x, 23.0));
|
|
70
|
+
float r3 = hash12(vec2(cell.x, 37.0));
|
|
71
|
+
float T = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.5);
|
|
72
|
+
float len = max(trail, 0.01) * (0.5 + r3);
|
|
73
|
+
float u = clamp((T - 0.03 - 0.5 * r1) / (0.3 + 0.12 * r2), 0.0, 1.0);
|
|
74
|
+
// the head falls from above the frame, speeding up a little, until its tail has left the frame
|
|
75
|
+
float head = mix(-0.2, 1.0 + h + len, u * (0.7 + 0.3 * u));
|
|
76
|
+
// how far the head has gone past the cell's top
|
|
77
|
+
float dy = head - (cell.y - 0.278) * h;
|
|
78
|
+
|
|
79
|
+
vec4 a = getFromColor(uv);
|
|
80
|
+
vec4 b = getToColor(uv);
|
|
81
|
+
|
|
82
|
+
// ahead of the stream: the outgoing image darkens into characters tinted by its cell's color,
|
|
83
|
+
// over time and as the head comes near
|
|
84
|
+
vec2 cuv = clamp(vec2((cell.x + 0.111) * dims.x / ratio, 1.0 - (cell.y + 0.222) * h), 0.0, 1.0);
|
|
85
|
+
vec4 ca = getFromColor(cuv);
|
|
86
|
+
float lum = dot(ca.rgb, vec3(0.299, 0.587, 0.114));
|
|
87
|
+
vec3 hue = ca.rgb / max(max(ca.r, max(ca.g, ca.b)), 0.05);
|
|
88
|
+
vec3 ink = mix(glow.rgb * glow.a, hue, tint) * (0.1 + 0.6 * lum);
|
|
89
|
+
float near = smoothstep(-0.15, 0.0, dy);
|
|
90
|
+
float dim = max(smoothstep(0.0, 0.3, T), near);
|
|
91
|
+
float g = max(smoothstep(0.0, 0.2, T - 0.12 * rc), near);
|
|
92
|
+
float passed = step(0.0, dy);
|
|
93
|
+
// the characters change slowly ahead of the stream and fast in it
|
|
94
|
+
float slow = mod(floor(T * 12.0 + rc * 7.0), 32.0);
|
|
95
|
+
float fast = 32.0 + mod(floor(T * 40.0 + rc * 13.0), 32.0);
|
|
96
|
+
float chr = glyph(cell, mix(slow, fast, passed), local);
|
|
97
|
+
vec3 code = a.rgb * (1.0 - 0.8 * dim) + ink * chr * g;
|
|
98
|
+
|
|
99
|
+
// behind the head: bright characters changing fast, fading along the tail, over a shadow that
|
|
100
|
+
// clears in the tail's last two thirds to leave the incoming image
|
|
101
|
+
float fade = clamp(1.0 - dy / len, 0.0, 1.0);
|
|
102
|
+
float shade = 1.0 - smoothstep(0.3 * len, len, dy);
|
|
103
|
+
float hot = 1.0 - smoothstep(h, 3.0 * h, dy);
|
|
104
|
+
vec3 col = mix(glow.rgb * 1.2, vec3(1.0), 0.8 * hot) * glow.a;
|
|
105
|
+
vec3 stream = b.rgb * (1.0 - 0.8 * shade) + col * chr * (fade * (2.0 - fade) + hot * fade);
|
|
106
|
+
|
|
107
|
+
// a soft glow around the head, within its column
|
|
108
|
+
float yy = (head - fp.y) / (1.5 * h);
|
|
109
|
+
float halo = 1.6 * u * (1.0 - u) * exp(-yy * yy) * (1.0 - smoothstep(0.25, 0.5, abs(local.x - 0.5)));
|
|
110
|
+
vec3 rgb = mix(code, stream, passed) + glow.rgb * glow.a * halo;
|
|
111
|
+
// the outgoing image's opacity stays under the tail's shadow, then gives way to the incoming one's
|
|
112
|
+
return vec4(clamp(rgb, 0.0, 1.0), mix(a.a, mix(b.a, a.a, shade), passed));
|
|
113
|
+
}
|