gl-transitions 2.5.0 → 3.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 +97 -0
- package/README.md +16 -1
- package/compatibility.json +383 -149
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/BandWipe.glsl +67 -0
- package/glsl3/BookFlip.glsl +124 -21
- package/glsl3/BowTie.glsl +1 -1
- package/glsl3/Clothesline.glsl +217 -0
- package/glsl3/ComicPanels.glsl +174 -0
- package/glsl3/Cube.glsl +105 -52
- package/glsl3/DirectionalWipe.glsl +1 -1
- 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/GlintDissolve.glsl +125 -0
- package/glsl3/GlitterDissolve.glsl +171 -0
- package/glsl3/GridFlip.glsl +151 -56
- package/glsl3/HeartWipe.glsl +71 -11
- package/glsl3/InsetWipe.glsl +58 -0
- package/glsl3/InsideCube.glsl +114 -0
- package/glsl3/KeyholeWipe.glsl +104 -0
- package/glsl3/LedWall.glsl +127 -0
- package/glsl3/LightningFlash.glsl +200 -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/Shatter.glsl +231 -35
- package/glsl3/SketchDissolve.glsl +100 -0
- package/glsl3/SlotReels.glsl +118 -0
- package/glsl3/SplitFlap.glsl +124 -0
- package/glsl3/Swirl.glsl +52 -21
- package/glsl3/TruchetWipe.glsl +80 -0
- package/glsl3/Tumble.glsl +113 -0
- package/glsl3/WarpSpeed.glsl +120 -0
- package/glsl3/WaterDrop.glsl +69 -13
- package/glsl3/WaveWipe.glsl +154 -0
- package/index.js +1 -1
- package/layouts.json +1158 -193
- package/llms-full.txt +865 -540
- package/llms.txt +219 -204
- package/msl/BandWipe.metal +353 -0
- package/msl/BookFlip.metal +575 -114
- package/msl/BowTie.metal +1 -1
- package/msl/Clothesline.metal +828 -0
- package/msl/ComicPanels.metal +959 -0
- package/msl/Cube.metal +466 -170
- package/msl/DirectionalWipe.metal +1 -1
- 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/GlintDissolve.metal +558 -0
- package/msl/GlitterDissolve.metal +637 -0
- package/msl/GridFlip.metal +548 -191
- package/msl/HeartWipe.metal +230 -58
- package/msl/InsetWipe.metal +232 -0
- package/msl/InsideCube.metal +537 -0
- package/msl/KeyholeWipe.metal +370 -0
- package/msl/LedWall.metal +437 -0
- package/msl/LightningFlash.metal +1038 -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/Shatter.metal +1136 -160
- package/msl/SketchDissolve.metal +446 -0
- package/msl/SlotReels.metal +436 -0
- package/msl/SplitFlap.metal +589 -0
- package/msl/Swirl.metal +144 -77
- package/msl/TruchetWipe.metal +285 -0
- package/msl/Tumble.metal +466 -0
- package/msl/WarpSpeed.metal +549 -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 +119 -74
- package/sksl/BandWipe.sksl +77 -0
- package/sksl/BookFlip.sksl +117 -20
- package/sksl/BowTie.sksl +1 -1
- package/sksl/Clothesline.sksl +217 -0
- package/sksl/ComicPanels.sksl +176 -0
- package/sksl/Cube.sksl +99 -46
- package/sksl/DirectionalWipe.sksl +1 -1
- 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/GlintDissolve.sksl +136 -0
- package/sksl/GlitterDissolve.sksl +175 -0
- package/sksl/GridFlip.sksl +141 -52
- package/sksl/HeartWipe.sksl +60 -11
- package/sksl/InsetWipe.sksl +70 -0
- package/sksl/InsideCube.sksl +123 -0
- package/sksl/KeyholeWipe.sksl +109 -0
- package/sksl/LedWall.sksl +137 -0
- package/sksl/LightningFlash.sksl +202 -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/Shatter.sksl +218 -33
- package/sksl/SketchDissolve.sksl +111 -0
- package/sksl/SlotReels.sksl +127 -0
- package/sksl/SplitFlap.sksl +131 -0
- package/sksl/Swirl.sksl +49 -20
- package/sksl/TruchetWipe.sksl +92 -0
- package/sksl/Tumble.sksl +122 -0
- package/sksl/WarpSpeed.sksl +131 -0
- package/sksl/WaterDrop.sksl +64 -10
- package/sksl/WaveWipe.sksl +165 -0
- package/sksl/index.js +1 -1
- package/transitions/BandWipe.glsl +66 -0
- package/transitions/BookFlip.glsl +124 -21
- package/transitions/BowTie.glsl +1 -1
- package/transitions/Clothesline.glsl +216 -0
- package/transitions/ComicPanels.glsl +173 -0
- package/transitions/Cube.glsl +105 -52
- package/transitions/DirectionalWipe.glsl +1 -1
- 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/GlintDissolve.glsl +124 -0
- package/transitions/GlitterDissolve.glsl +170 -0
- package/transitions/GridFlip.glsl +151 -56
- package/transitions/HeartWipe.glsl +71 -11
- package/transitions/InsetWipe.glsl +57 -0
- package/transitions/InsideCube.glsl +113 -0
- package/transitions/KeyholeWipe.glsl +103 -0
- package/transitions/LedWall.glsl +126 -0
- package/transitions/LightningFlash.glsl +199 -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/Shatter.glsl +231 -35
- package/transitions/SketchDissolve.glsl +99 -0
- package/transitions/SlotReels.glsl +117 -0
- package/transitions/SplitFlap.glsl +123 -0
- package/transitions/Swirl.glsl +52 -21
- package/transitions/TruchetWipe.glsl +79 -0
- package/transitions/Tumble.glsl +112 -0
- package/transitions/WarpSpeed.glsl +119 -0
- package/transitions/WaterDrop.glsl +69 -13
- package/transitions/WaveWipe.glsl +153 -0
- package/wgsl/BandWipe.wgsl +319 -0
- package/wgsl/BookFlip.wgsl +552 -105
- package/wgsl/BowTie.wgsl +1 -1
- package/wgsl/Clothesline.wgsl +756 -0
- package/wgsl/ComicPanels.wgsl +886 -0
- package/wgsl/Cube.wgsl +461 -156
- package/wgsl/DirectionalWipe.wgsl +1 -1
- 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/GlintDissolve.wgsl +519 -0
- package/wgsl/GlitterDissolve.wgsl +582 -0
- package/wgsl/GridFlip.wgsl +523 -188
- package/wgsl/HeartWipe.wgsl +225 -55
- package/wgsl/InsetWipe.wgsl +200 -0
- package/wgsl/InsideCube.wgsl +496 -0
- package/wgsl/KeyholeWipe.wgsl +337 -0
- package/wgsl/LedWall.wgsl +397 -0
- package/wgsl/LightningFlash.wgsl +964 -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/Shatter.wgsl +1091 -148
- package/wgsl/SketchDissolve.wgsl +409 -0
- package/wgsl/SlotReels.wgsl +391 -0
- package/wgsl/SplitFlap.wgsl +533 -0
- package/wgsl/Swirl.wgsl +138 -77
- package/wgsl/TruchetWipe.wgsl +255 -0
- package/wgsl/Tumble.wgsl +424 -0
- package/wgsl/WarpSpeed.wgsl +497 -0
- package/wgsl/WaterDrop.wgsl +251 -49
- package/wgsl/WaveWipe.wgsl +581 -0
- package/glsl3/BlockDissolve.glsl +0 -16
- package/glsl3/BowTieVertical.glsl +0 -117
- package/glsl3/Box.glsl +0 -33
- package/glsl3/LinearBlur.glsl +0 -30
- package/glsl3/MosaicBlend.glsl +0 -21
- package/glsl3/MosaicFade.glsl +0 -20
- package/glsl3/RotateFade.glsl +0 -22
- package/glsl3/ScaleIn.glsl +0 -18
- package/glsl3/WipeDown.glsl +0 -12
- package/glsl3/WipeLeft.glsl +0 -12
- package/glsl3/WipeRight.glsl +0 -12
- package/glsl3/WipeUp.glsl +0 -12
- package/msl/BlockDissolve.metal +0 -108
- package/msl/BowTieVertical.metal +0 -375
- package/msl/Box.metal +0 -204
- package/msl/LinearBlur.metal +0 -169
- package/msl/MosaicBlend.metal +0 -136
- package/msl/MosaicFade.metal +0 -137
- package/msl/RotateFade.metal +0 -116
- package/msl/ScaleIn.metal +0 -111
- package/msl/WipeDown.metal +0 -105
- package/msl/WipeLeft.metal +0 -105
- package/msl/WipeRight.metal +0 -105
- package/msl/WipeUp.metal +0 -105
- package/sksl/BlockDissolve.sksl +0 -29
- package/sksl/BowTieVertical.sksl +0 -130
- package/sksl/Box.sksl +0 -47
- package/sksl/LinearBlur.sksl +0 -44
- package/sksl/MosaicBlend.sksl +0 -34
- package/sksl/MosaicFade.sksl +0 -33
- package/sksl/RotateFade.sksl +0 -34
- package/sksl/ScaleIn.sksl +0 -32
- package/sksl/WipeDown.sksl +0 -26
- package/sksl/WipeLeft.sksl +0 -26
- package/sksl/WipeRight.sksl +0 -26
- package/sksl/WipeUp.sksl +0 -26
- package/transitions/BlockDissolve.glsl +0 -15
- package/transitions/BowTieVertical.glsl +0 -116
- package/transitions/Box.glsl +0 -32
- package/transitions/LinearBlur.glsl +0 -29
- package/transitions/MosaicBlend.glsl +0 -20
- package/transitions/MosaicFade.glsl +0 -19
- package/transitions/RotateFade.glsl +0 -21
- package/transitions/ScaleIn.glsl +0 -17
- package/transitions/WipeDown.glsl +0 -11
- package/transitions/WipeLeft.glsl +0 -11
- package/transitions/WipeRight.glsl +0 -11
- package/transitions/WipeUp.glsl +0 -11
- package/wgsl/BlockDissolve.wgsl +0 -78
- package/wgsl/BowTieVertical.wgsl +0 -331
- package/wgsl/Box.wgsl +0 -176
- package/wgsl/LinearBlur.wgsl +0 -131
- package/wgsl/MosaicBlend.wgsl +0 -108
- package/wgsl/MosaicFade.wgsl +0 -107
- package/wgsl/RotateFade.wgsl +0 -85
- package/wgsl/ScaleIn.wgsl +0 -79
- package/wgsl/WipeDown.wgsl +0 -77
- package/wgsl/WipeLeft.wgsl +0 -77
- package/wgsl/WipeRight.wgsl +0 -77
- package/wgsl/WipeUp.wgsl +0 -77
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A keyhole grows steadily from the center until the incoming image fills the frame, its bevelled rim and inner shadow making it read as a hole cut in a plate
|
|
4
|
+
// Tags: shape, wipe, keyhole, iris, reveal
|
|
5
|
+
|
|
6
|
+
// @param Center of the keyhole
|
|
7
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
8
|
+
// @range(0, 1) Strength of the bevelled rim around the keyhole and the shadow inside it (0 for a clean cut)
|
|
9
|
+
uniform float rim; // = 0.6
|
|
10
|
+
// @range(0, 0.05) Softness of the keyhole's edge
|
|
11
|
+
uniform float smoothness; // = 0.002
|
|
12
|
+
|
|
13
|
+
// The keyhole, in its own units (0.85 tall, from y = -0.4 to 0.45): a round head on top of a slot
|
|
14
|
+
// that widens downward.
|
|
15
|
+
#define HEAD vec2(0.0, 0.2)
|
|
16
|
+
#define HEAD_R 0.25
|
|
17
|
+
#define SLOT_Y -0.17
|
|
18
|
+
const float SLOT_HE = 0.23;
|
|
19
|
+
const float SLOT_TOP = 0.085;
|
|
20
|
+
const float SLOT_BOTTOM = 0.165;
|
|
21
|
+
const float SLOT_ROUND = 0.025;
|
|
22
|
+
// height of the point the keyhole grows around, in its head
|
|
23
|
+
const float GROW_Y = 0.1;
|
|
24
|
+
// widths of the bevel and of the rim's shadows, in keyhole units
|
|
25
|
+
const float BEVEL = 0.028;
|
|
26
|
+
const float SHADE = 0.05;
|
|
27
|
+
|
|
28
|
+
float dot2(vec2 v) { return dot(v, v); }
|
|
29
|
+
|
|
30
|
+
// Signed distance to the slot, a trapezoid with rounded corners
|
|
31
|
+
float sdSlot(vec2 p) {
|
|
32
|
+
p.y -= SLOT_Y;
|
|
33
|
+
float r1 = SLOT_BOTTOM - SLOT_ROUND;
|
|
34
|
+
float r2 = SLOT_TOP - SLOT_ROUND;
|
|
35
|
+
float he = SLOT_HE - SLOT_ROUND;
|
|
36
|
+
vec2 k1 = vec2(r2, he);
|
|
37
|
+
vec2 k2 = vec2(r2 - r1, 2.0 * he);
|
|
38
|
+
p.x = abs(p.x);
|
|
39
|
+
vec2 ca = vec2(p.x - min(p.x, p.y < 0.0 ? r1 : r2), abs(p.y) - he);
|
|
40
|
+
vec2 cb = p - k1 + k2 * clamp(dot(k1 - p, k2) / dot2(k2), 0.0, 1.0);
|
|
41
|
+
float s = (cb.x < 0.0 && ca.y < 0.0) ? -1.0 : 1.0;
|
|
42
|
+
return s * sqrt(min(dot2(ca), dot2(cb))) - SLOT_ROUND;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
float sdKeyhole(vec2 p) {
|
|
46
|
+
return min(length(p - HEAD) - HEAD_R, sdSlot(p));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Scale at which the keyhole's head, a disk, reaches the point p (seen from the growth point):
|
|
50
|
+
// the root of |p - s h| = s HEAD_R, h being the head's center
|
|
51
|
+
float reach(vec2 p) {
|
|
52
|
+
vec2 h = HEAD - vec2(0.0, GROW_Y);
|
|
53
|
+
float k = HEAD_R * HEAD_R - dot2(h);
|
|
54
|
+
float b = dot(p, h);
|
|
55
|
+
return (sqrt(b * b + k * dot2(p)) - b) / k;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
vec4 transition (vec2 uv) {
|
|
59
|
+
vec4 a = getFromColor(uv);
|
|
60
|
+
vec4 b = getToColor(uv);
|
|
61
|
+
vec2 asp = vec2(ratio, 1.0);
|
|
62
|
+
vec2 c = center * asp;
|
|
63
|
+
float sm = max(smoothness, 0.0005);
|
|
64
|
+
|
|
65
|
+
// The keyhole grows around a point of its head, at the center. It covers the frame (grown by a
|
|
66
|
+
// margin, so the soft edge is past it) once its head, a disk, reaches the frame's corners.
|
|
67
|
+
vec2 o = c;
|
|
68
|
+
vec2 lo = -o - 2.5 * sm;
|
|
69
|
+
vec2 hi = asp - o + 2.5 * sm;
|
|
70
|
+
float full = max(max(reach(lo), reach(hi)), max(reach(vec2(lo.x, hi.y)), reach(vec2(hi.x, lo.y))));
|
|
71
|
+
|
|
72
|
+
// The keyhole grows linearly until it fills the frame
|
|
73
|
+
float p = progress;
|
|
74
|
+
float s = full * p;
|
|
75
|
+
if (s <= 0.0) return a;
|
|
76
|
+
|
|
77
|
+
vec2 q = (uv * asp - o) / s + vec2(0.0, GROW_Y);
|
|
78
|
+
float d = sdKeyhole(q);
|
|
79
|
+
// the soft edge is just inside the outline, so a tiny keyhole shows nothing
|
|
80
|
+
float hole = 1.0 - smoothstep(-sm, sm, d * s + sm);
|
|
81
|
+
|
|
82
|
+
float fade = smoothstep(0.0, 0.08, p) * (1.0 - smoothstep(0.7, 1.0, p));
|
|
83
|
+
float rimA = rim * fade;
|
|
84
|
+
if (rimA > 0.0) {
|
|
85
|
+
// Plate around the hole: a bevel lit from above going down into the hole, and a soft shadow
|
|
86
|
+
// on its rim
|
|
87
|
+
vec2 e = vec2(0.002, 0.0);
|
|
88
|
+
vec2 n = vec2(sdKeyhole(q + e) - sdKeyhole(q - e), sdKeyhole(q + e.yx) - sdKeyhole(q - e.yx));
|
|
89
|
+
float lit = -dot(n / max(length(n), 1e-6), vec2(-0.35, 0.94));
|
|
90
|
+
float bevel = 1.0 - smoothstep(0.0, BEVEL, d);
|
|
91
|
+
float shade = exp(-max(d, 0.0) / SHADE);
|
|
92
|
+
a.rgb *= 1.0 - rimA * (0.35 * shade + bevel * 0.4 * max(-lit, 0.0));
|
|
93
|
+
a.rgb += rimA * bevel * bevel * 0.3 * max(lit, 0.0) * a.a;
|
|
94
|
+
|
|
95
|
+
// Inside the hole: the plate's thickness shades the incoming image under the top of the rim,
|
|
96
|
+
// with a softer vignette all around the edge
|
|
97
|
+
float wall = smoothstep(-0.03, 0.03, sdKeyhole(q + vec2(0.0, 0.05)));
|
|
98
|
+
float vign = exp(min(d, 0.0) / SHADE);
|
|
99
|
+
b.rgb *= 1.0 - rimA * (0.5 * wall + 0.3 * vign);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return mix(a, b, hole);
|
|
103
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The picture zooms into a giant LED screen of round glowing diodes on a dark panel; a refresh wave sweeps across it, each diode flicking with a bright pop as it switches to the incoming image, then the diodes melt back into the plain picture
|
|
4
|
+
// Tags: dots, glow, grid, wave
|
|
5
|
+
|
|
6
|
+
// @range(6, 80) Number of diodes across the shorter side
|
|
7
|
+
uniform float cells; // = 24.0
|
|
8
|
+
// @range(0, 1) Strength of the glow bleeding from the diodes into the dark panel
|
|
9
|
+
uniform float glow; // = 0.6
|
|
10
|
+
// @range(0, 1) Brightness of the flash of each diode as it switches
|
|
11
|
+
uniform float flash; // = 0.7
|
|
12
|
+
// @range(0, 0.5) How much the picture zooms in while it is a screen
|
|
13
|
+
uniform float zoom; // = 0.15
|
|
14
|
+
// @param Each diode is made of red, green and blue sub-diodes
|
|
15
|
+
uniform bool triads; // = false
|
|
16
|
+
// @param Direction in which the refresh wave sweeps across the screen
|
|
17
|
+
uniform vec2 direction; // = vec2(1.0, 0.0)
|
|
18
|
+
// @color Color of the panel between the diodes
|
|
19
|
+
uniform vec4 panel; // = vec4(0.02, 0.02, 0.025, 1.0)
|
|
20
|
+
|
|
21
|
+
// radius of a lit diode, in cells
|
|
22
|
+
const float RADIUS = 0.36;
|
|
23
|
+
// width of the soft edge of the diodes, in cells
|
|
24
|
+
const float EDGE = 0.05;
|
|
25
|
+
|
|
26
|
+
float hash12(vec2 p) {
|
|
27
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
28
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
29
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// folds uv back into 0..1, so the frame stays filled
|
|
33
|
+
vec2 mirrored(vec2 v) {
|
|
34
|
+
vec2 m = mod(v, 2.0);
|
|
35
|
+
return mix(m, 2.0 - m, step(1.0, m));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 1 inside a disc of radius r, with a soft edge
|
|
39
|
+
float disc(float d, float r) {
|
|
40
|
+
return 1.0 - smoothstep(r - EDGE, r + EDGE, d);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
vec4 transition(vec2 uv) {
|
|
44
|
+
// how much the picture is a screen: it resolves into diodes until 0.3, and back from 0.7
|
|
45
|
+
float led = smoothstep(0.0, 0.3, progress) * (1.0 - smoothstep(0.7, 1.0, progress));
|
|
46
|
+
float z = 1.0 + max(zoom, 0.0) * smoothstep(0.0, 0.45, progress) * (1.0 - smoothstep(0.55, 1.0, progress));
|
|
47
|
+
vec2 p = 0.5 + (uv - 0.5) / z;
|
|
48
|
+
|
|
49
|
+
// the grid of diodes, in cells, with a diode at the center of the frame
|
|
50
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
51
|
+
vec2 toCells = aspect * max(cells, 1.0) / min(ratio, 1.0);
|
|
52
|
+
vec2 q = (p - 0.5) * toCells;
|
|
53
|
+
vec2 id = floor(q + 0.5);
|
|
54
|
+
vec2 local = q - id;
|
|
55
|
+
vec2 side = vec2(local.x < 0.0 ? -1.0 : 1.0, local.y < 0.0 ? -1.0 : 1.0);
|
|
56
|
+
|
|
57
|
+
// the refresh wave runs along dir, from 0 to 1 across the frame
|
|
58
|
+
vec2 dir = length(direction) > 1e-4 ? normalize(direction) : vec2(1.0, 0.0);
|
|
59
|
+
float extent = abs(dir.x) * ratio + abs(dir.y);
|
|
60
|
+
|
|
61
|
+
vec4 own = vec4(0.0);
|
|
62
|
+
float ownSwitch = 0.0;
|
|
63
|
+
vec4 halo = vec4(0.0);
|
|
64
|
+
float haloWeight = 0.0;
|
|
65
|
+
// this diode and the three nearest ones, whose glow reaches this point
|
|
66
|
+
for (int i = 0; i < 4; i++) {
|
|
67
|
+
// without glow, only this diode matters
|
|
68
|
+
if (i > 0 && glow * led <= 0.0) break;
|
|
69
|
+
vec2 o = vec2(mod(float(i), 2.0), floor(float(i) / 2.0)) * side;
|
|
70
|
+
vec2 c = id + o;
|
|
71
|
+
vec2 cuv = c / toCells + 0.5;
|
|
72
|
+
// where the diode is seen in the frame, so that the wave crosses the visible screen
|
|
73
|
+
float s = clamp(dot((cuv - 0.5) * z * aspect, dir) / extent + 0.5, 0.0, 1.0);
|
|
74
|
+
float when = 0.2 + 0.52 * s + 0.05 * (hash12(c + 71.0) - 0.5);
|
|
75
|
+
float sw = smoothstep(when - 0.012, when + 0.012, progress);
|
|
76
|
+
// the diode blinks off just before it switches, then pops bright
|
|
77
|
+
float x = (progress - when) / 0.018;
|
|
78
|
+
float pop = exp(-x * x) - 0.5 * exp(-(x + 1.6) * (x + 1.6));
|
|
79
|
+
vec2 suv = mirrored(cuv);
|
|
80
|
+
vec4 col = mix(getFromColor(suv), getToColor(suv), sw);
|
|
81
|
+
col.rgb = col.rgb * (1.0 + 1.4 * flash * pop) + 0.2 * flash * max(pop, 0.0);
|
|
82
|
+
if (i == 0) {
|
|
83
|
+
own = col;
|
|
84
|
+
ownSwitch = sw;
|
|
85
|
+
}
|
|
86
|
+
float d = length(local - o);
|
|
87
|
+
float w = 0.9 * glow * exp(-6.0 * max(d - RADIUS, 0.0)) * (1.0 + 0.8 * flash * max(pop, 0.0));
|
|
88
|
+
// the neighbors fade out where the next ones in the other direction take over, so the glow has no seam
|
|
89
|
+
if (o.x != 0.0) w *= smoothstep(0.0, 0.2, abs(local.x));
|
|
90
|
+
if (o.y != 0.0) w *= smoothstep(0.0, 0.2, abs(local.y));
|
|
91
|
+
halo += w * col;
|
|
92
|
+
haloWeight += w;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// the plain picture, switched along with its diode
|
|
96
|
+
vec4 plain = mix(getFromColor(p), getToColor(p), ownSwitch);
|
|
97
|
+
float d = length(local);
|
|
98
|
+
// the diodes cover their whole cell with the plain picture when led = 0: the dark panel
|
|
99
|
+
// shows up first between them, then they light up with the color of their center
|
|
100
|
+
float r = mix(0.8, RADIUS, smoothstep(0.0, 0.6, led));
|
|
101
|
+
vec4 gap = vec4(panel.rgb, panel.a * own.a);
|
|
102
|
+
if (haloWeight > 0.0) {
|
|
103
|
+
gap = mix(gap, halo / haloWeight, clamp(haloWeight * led, 0.0, 1.0));
|
|
104
|
+
}
|
|
105
|
+
vec4 body = own;
|
|
106
|
+
if (triads) {
|
|
107
|
+
// three sub-diodes on the panel, red at the top, green and blue below
|
|
108
|
+
vec3 sub = vec3(
|
|
109
|
+
disc(length(local - vec2(0.0, 0.15)), 0.2),
|
|
110
|
+
disc(length(local - vec2(-0.13, -0.075)), 0.2),
|
|
111
|
+
disc(length(local - vec2(0.13, -0.075)), 0.2));
|
|
112
|
+
float m = max(sub.r, max(sub.g, sub.b));
|
|
113
|
+
body = vec4(gap.rgb * (1.0 - m) + own.rgb * 1.5 * sub, mix(gap.a, own.a, m));
|
|
114
|
+
// the sub-diodes reach out to 0.4 cells
|
|
115
|
+
r = max(r, 0.45);
|
|
116
|
+
} else {
|
|
117
|
+
// brighter at the core of the diode
|
|
118
|
+
float k = clamp(d / RADIUS, 0.0, 1.0);
|
|
119
|
+
body.rgb *= 0.8 + 0.45 * (1.0 - k * k);
|
|
120
|
+
}
|
|
121
|
+
// the color of the center spreads from it over the diode
|
|
122
|
+
float lit = smoothstep(0.0, 0.8, led);
|
|
123
|
+
body = mix(plain, body, lit * mix(1.0, lit, smoothstep(0.0, 0.7, d)));
|
|
124
|
+
vec4 color = mix(gap, body, disc(d, r));
|
|
125
|
+
return clamp(color, 0.0, 1.0);
|
|
126
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: Forked lightning bolts crack down from the top of the frame, the screen flashes white in a few stuttering strobes, and the incoming image appears lit by the last flickers as they fade out
|
|
4
|
+
// Tags: light, flash, weather, strobe
|
|
5
|
+
|
|
6
|
+
// @range(1, 3, 1) Number of bolts: the main one strikes the ground, the others fork out higher in the sky
|
|
7
|
+
uniform int bolts; // = 2
|
|
8
|
+
// @range(0, 1) Where the main bolt strikes, from the left (0) to the right (1) of the frame
|
|
9
|
+
uniform float strike; // = 0.55
|
|
10
|
+
// @range(0, 100, 1) Changes the shape of the bolts
|
|
11
|
+
uniform float seed; // = 0.0
|
|
12
|
+
// @color Color of the light, added to the images
|
|
13
|
+
uniform vec3 color; // = vec3(0.75, 0.85, 1.0)
|
|
14
|
+
// @range(0, 1) Size and brightness of the glow around the bolts
|
|
15
|
+
uniform float glow; // = 0.5
|
|
16
|
+
// @range(1, 4, 1) Number of strobes; the images switch during the brightest one
|
|
17
|
+
uniform int flashes; // = 3
|
|
18
|
+
|
|
19
|
+
// the bolts crack down until this time, then the strobes start
|
|
20
|
+
const float LEADER = 0.3;
|
|
21
|
+
|
|
22
|
+
float hash(vec2 p) {
|
|
23
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
24
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
25
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// a value noise that is linear between its cells: a jagged polyline, centered on 0
|
|
29
|
+
float jag(float s, float k) {
|
|
30
|
+
float i = floor(s);
|
|
31
|
+
return mix(hash(vec2(i, k)), hash(vec2(i + 1.0, k)), fract(s)) - 0.5;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// the zigzag of a bolt around its straight line, at height y (narrower in a portrait frame)
|
|
35
|
+
float zigzag(float y, float k) {
|
|
36
|
+
return min(ratio, 1.0) * (0.15 * jag(y * 5.0, k) + 0.06 * jag(y * 13.0, k + 1.0) + 0.03 * jag(y * 31.0, k + 2.0) + 0.012 * jag(y * 67.0, k + 3.0));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// the x of a bolt at height y: from x0 at the top (y = 1) to x1 at its end (y = y1),
|
|
40
|
+
// given z0 and z1, its zigzag at both ends
|
|
41
|
+
float boltX(float y, float x0, float x1, float y1, float z0, float z1, float k) {
|
|
42
|
+
float t = (1.0 - y) / (1.0 - y1);
|
|
43
|
+
return mix(x0 - z0, x1 - z1, t) + zigzag(y, k);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// the x of a branch at height y: it leaves its bolt at (xb, yb), where its own zigzag is zb,
|
|
47
|
+
// and drifts sideways by dir per unit of height
|
|
48
|
+
float branchX(float y, float xb, float yb, float zb, float dir, float k) {
|
|
49
|
+
return xb + dir * (yb - y) + 0.6 * (zigzag(y, k) - zb);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// distance to a curve x = f(y), knowing its x and its slope at the pixel's height,
|
|
53
|
+
// and how far above or below its ends the pixel is; the slope only corrects the distance
|
|
54
|
+
// close to the curve, so the glow farther away does not streak along the zigzags
|
|
55
|
+
float curveDist(vec2 q, float x, float slope, float outside) {
|
|
56
|
+
float dx = abs(q.x - x);
|
|
57
|
+
float d = dx * mix(inversesqrt(1.0 + slope * slope), 1.0, smoothstep(0.0, 0.08, dx));
|
|
58
|
+
return length(vec2(d, max(outside, 0.0)));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// a strobe at time t0: a quick rise, a plateau of length hold, then a decay
|
|
62
|
+
float pulse(float p, float t0, float hold, float decay) {
|
|
63
|
+
float x = p - t0;
|
|
64
|
+
if (x < 0.0) return smoothstep(-0.012, 0.0, x);
|
|
65
|
+
return exp(-max(x - hold, 0.0) / decay);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
vec4 transition(vec2 uv) {
|
|
69
|
+
float p = progress;
|
|
70
|
+
vec2 q = vec2(uv.x * ratio, uv.y);
|
|
71
|
+
// (seeds far apart, so that neighboring seeds share no hash keys)
|
|
72
|
+
float k0 = floor(seed) * 61.0;
|
|
73
|
+
int nb = bolts < 1 ? 1 : (bolts > 3 ? 3 : bolts);
|
|
74
|
+
int nf = flashes < 1 ? 1 : (flashes > 4 ? 4 : flashes);
|
|
75
|
+
// the images switch during the brightest strobe, the second one (or the only one)
|
|
76
|
+
int cut = nf > 1 ? 1 : 0;
|
|
77
|
+
|
|
78
|
+
// the strobes, a bit irregular; the bolts are lit by all of them, the screen mostly by the brightest
|
|
79
|
+
float flash = 0.0;
|
|
80
|
+
float lit = 0.0;
|
|
81
|
+
float tCut = LEADER;
|
|
82
|
+
float tLast = LEADER;
|
|
83
|
+
float t = LEADER;
|
|
84
|
+
for (int i = 0; i < 4; i++) {
|
|
85
|
+
if (i < nf) {
|
|
86
|
+
bool isCut = i == cut;
|
|
87
|
+
float amp = isCut ? 1.0 : (i < cut ? 0.55 : 0.7 * pow(0.75, float(i - cut - 1)));
|
|
88
|
+
float s = amp * pulse(p, t, isCut ? 0.025 : 0.004, isCut ? 0.03 : 0.022);
|
|
89
|
+
flash = max(flash, s);
|
|
90
|
+
lit = max(lit, pulse(p, t, 0.01, 0.045));
|
|
91
|
+
if (isCut) tCut = t;
|
|
92
|
+
tLast = t;
|
|
93
|
+
t += (isCut ? 0.12 : 0.08) + 0.04 * hash(vec2(float(i), k0 + 5.0));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// the stutter: the light jumps from one level to another a few times per strobe
|
|
97
|
+
float stutter = mix(0.7, 1.0, hash(vec2(floor(p * 70.0), k0 + 9.0)));
|
|
98
|
+
flash *= stutter;
|
|
99
|
+
// the brightest strobe whites the screen out while the images switch
|
|
100
|
+
float whiteout = pulse(p, tCut, 0.025, 0.02);
|
|
101
|
+
// then a few last flickers, fading out
|
|
102
|
+
float tail = p > tLast ? exp(-(p - tLast) / 0.1) * smoothstep(0.03, 0.06, p - tLast) : 0.0;
|
|
103
|
+
flash = max(flash, 0.35 * tail * step(0.45, hash(vec2(floor(p * 40.0), k0 + 13.0))));
|
|
104
|
+
|
|
105
|
+
// the bolts crack down in a few jumps while faintly lit, then light up with the strobes and go out
|
|
106
|
+
float grow = clamp(p / LEADER, 0.0, 1.0);
|
|
107
|
+
grow = (floor(grow * 7.0) + smoothstep(0.0, 1.0, fract(grow * 7.0))) / 7.0;
|
|
108
|
+
float faint = 0.5 * mix(0.6, 1.0, hash(vec2(floor(p * 50.0), k0 + 11.0)));
|
|
109
|
+
float boltLight = p < LEADER ? faint * smoothstep(0.0, 0.06, p) : max(lit * stutter, faint * exp(-(p - LEADER) / 0.12));
|
|
110
|
+
boltLight = max(boltLight, 0.6 * flash * tail);
|
|
111
|
+
boltLight *= 1.0 - smoothstep(tLast + 0.1, tLast + 0.3, p);
|
|
112
|
+
|
|
113
|
+
// the bolts: the main one strikes the ground at strike, the others stop in the sky
|
|
114
|
+
float core = 0.0;
|
|
115
|
+
float halo = 0.0;
|
|
116
|
+
float near = 10.0;
|
|
117
|
+
bool lightsOn = boltLight > 0.0 || flash > 0.0;
|
|
118
|
+
for (int b = 0; b < 3; b++) {
|
|
119
|
+
if (b < nb && lightsOn) {
|
|
120
|
+
float fb = float(b);
|
|
121
|
+
float kb = k0 + fb * 17.0;
|
|
122
|
+
float x1 = strike * ratio;
|
|
123
|
+
float y1 = -0.05;
|
|
124
|
+
float bright = 1.0;
|
|
125
|
+
if (b > 0) {
|
|
126
|
+
// the second bolt goes to the roomier side, the third to the other side if there is room there
|
|
127
|
+
float roomy = strike < 0.5 ? 1.0 : -1.0;
|
|
128
|
+
bool cramped = min(strike, 1.0 - strike) < 0.25;
|
|
129
|
+
float side = b == 1 || cramped ? roomy : -roomy;
|
|
130
|
+
float dist = b == 2 && cramped ? 0.5 : 0.22;
|
|
131
|
+
x1 = clamp(x1 + side * ratio * (dist + 0.12 * hash(vec2(fb, kb))), 0.08 * ratio, 0.92 * ratio);
|
|
132
|
+
y1 = 0.25 + 0.25 * hash(vec2(fb, kb + 1.0));
|
|
133
|
+
bright = 0.7;
|
|
134
|
+
}
|
|
135
|
+
float x0 = clamp(x1 + (hash(vec2(fb, kb + 2.0)) - 0.5) * 0.5 * min(ratio, 1.0), 0.1 * ratio, 0.9 * ratio);
|
|
136
|
+
// the tip of the bolt while it cracks down
|
|
137
|
+
float tip = mix(1.02, y1, grow);
|
|
138
|
+
// (the slope is measured over a few pixels, so it changes smoothly at the corners)
|
|
139
|
+
float e = 0.01;
|
|
140
|
+
float z0 = zigzag(1.0, kb);
|
|
141
|
+
float z1 = zigzag(y1, kb);
|
|
142
|
+
float x = boltX(q.y, x0, x1, y1, z0, z1, kb);
|
|
143
|
+
float slope = (boltX(q.y + e, x0, x1, y1, z0, z1, kb) - boltX(q.y - e, x0, x1, y1, z0, z1, kb)) / (2.0 * e);
|
|
144
|
+
float d = curveDist(q, x, slope, max(max(y1, tip) - q.y, q.y - 1.05));
|
|
145
|
+
near = min(near, d);
|
|
146
|
+
float w = 0.003 * mix(1.0, 0.7, fb / 2.0);
|
|
147
|
+
core += bright * exp(-d * d / (w * w));
|
|
148
|
+
halo += bright * (0.7 * exp(-d * 24.0) + 0.25 * exp(-d * 6.0));
|
|
149
|
+
// three branches, leaving the bolt on either side and fading toward their ends
|
|
150
|
+
for (int j = 0; j < 3; j++) {
|
|
151
|
+
float fj = float(j);
|
|
152
|
+
float kj = kb + 3.0 + fj * 5.0;
|
|
153
|
+
float tb = 0.12 + 0.2 * fj + 0.15 * hash(vec2(fj, kj));
|
|
154
|
+
float yb = mix(1.0, y1, tb);
|
|
155
|
+
float len = (0.3 + 0.25 * hash(vec2(fj, kj + 1.0))) * (1.0 - tb) * (1.0 - y1);
|
|
156
|
+
float dir = (j == 1 ? -1.0 : 1.0) * (0.2 + 0.45 * hash(vec2(fj, kj + 2.0))) * min(ratio, 1.0);
|
|
157
|
+
float xb = boltX(yb, x0, x1, y1, z0, z1, kb);
|
|
158
|
+
float zb = zigzag(yb, kj);
|
|
159
|
+
float bx = branchX(q.y, xb, yb, zb, dir, kj);
|
|
160
|
+
float bs = (branchX(q.y + e, xb, yb, zb, dir, kj) - branchX(q.y - e, xb, yb, zb, dir, kj)) / (2.0 * e);
|
|
161
|
+
float bd = curveDist(q, bx, bs, max(max(yb - len, tip) - q.y, q.y - yb));
|
|
162
|
+
near = min(near, bd);
|
|
163
|
+
float along = clamp((yb - q.y) / len, 0.0, 1.0);
|
|
164
|
+
float fade = bright * (1.0 - 0.8 * along);
|
|
165
|
+
float bw = w * mix(0.8, 0.4, along);
|
|
166
|
+
core += fade * exp(-bd * bd / (bw * bw));
|
|
167
|
+
halo += fade * 0.6 * (0.7 * exp(-bd * 24.0) + 0.25 * exp(-bd * 6.0));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// the outgoing image gives way to the incoming one at the brightest strobe, hidden by it
|
|
173
|
+
float m = smoothstep(tCut, tCut + 0.025, p);
|
|
174
|
+
vec4 c = vec4(0.0);
|
|
175
|
+
if (m < 1.0) {
|
|
176
|
+
vec4 a = getFromColor(uv);
|
|
177
|
+
c += (1.0 - m) * vec4(a.rgb * a.a, a.a);
|
|
178
|
+
}
|
|
179
|
+
if (m > 0.0) {
|
|
180
|
+
vec4 a = getToColor(uv);
|
|
181
|
+
c += m * vec4(a.rgb * a.a, a.a);
|
|
182
|
+
}
|
|
183
|
+
if (c.a <= 0.0) return vec4(0.0);
|
|
184
|
+
vec3 col = c.rgb / c.a;
|
|
185
|
+
|
|
186
|
+
// the effect fades in at the start and is gone at the end
|
|
187
|
+
float live = smoothstep(0.0, 0.03, p) * (1.0 - smoothstep(0.85, 1.0, p));
|
|
188
|
+
// the sky darkens a little as the storm builds, then the strobes overexpose the image,
|
|
189
|
+
// more around the bolts, and the bolts glow over it
|
|
190
|
+
float dim = 0.4 * smoothstep(0.0, LEADER, p) * (1.0 - smoothstep(tCut, tLast + 0.15, p));
|
|
191
|
+
float f = flash * mix(0.6 + 0.4 * exp(-near * 4.0), 1.0, smoothstep(0.6, 1.0, flash));
|
|
192
|
+
col *= 1.0 - dim * live;
|
|
193
|
+
col = col * (1.0 + 2.5 * f * live) + color * (1.1 * f * live);
|
|
194
|
+
float g = 0.4 + 1.2 * glow;
|
|
195
|
+
vec3 light = mix(color, vec3(1.0), 0.75) * min(core, 1.5) * 1.6 + color * g * halo;
|
|
196
|
+
col += light * boltLight * live;
|
|
197
|
+
col = mix(col, vec3(1.0), 0.92 * whiteout * live);
|
|
198
|
+
return vec4(clamp(col, 0.0, 1.0), c.a);
|
|
199
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: Two sets of fine concentric rings, centered on two points that drift toward each other, overlay the image and interfere into a shifting moire of wide bands; the bands open onto the incoming image and widen until it fills the frame, while the thin dark and light ring lines fade away
|
|
4
|
+
// Tags: moire, rings, interference, pattern, graphic, reveal
|
|
5
|
+
|
|
6
|
+
// @range(10, 80) Number of rings per frame height in each set
|
|
7
|
+
uniform float density; // = 36.0
|
|
8
|
+
// @range(1, 8) How many moire bands the rings make at the start; they get fewer and wider as the centers come together
|
|
9
|
+
uniform float bands; // = 3.0
|
|
10
|
+
// @range(-1, 1) How far the two centers turn around each other, in turns
|
|
11
|
+
uniform float drift; // = 0.25
|
|
12
|
+
// @range(0, 1) Strength of the ring lines drawn over the image
|
|
13
|
+
uniform float lines; // = 0.5
|
|
14
|
+
|
|
15
|
+
const float PI = 3.141592653589793;
|
|
16
|
+
// half width of the antialiased edges, in frame heights
|
|
17
|
+
const float AA = 0.0012;
|
|
18
|
+
// half width of a ring line, in ring spacings
|
|
19
|
+
const float LINE = 0.1;
|
|
20
|
+
// widest antialiased edge of the bands, in bands, which also sets when they start and finish
|
|
21
|
+
// opening
|
|
22
|
+
const float EDGE = 0.05;
|
|
23
|
+
// angle of the line between the two centers at the start, in radians
|
|
24
|
+
const float START = 0.35;
|
|
25
|
+
// strength of the ring lines at lines = 1, so the image always shows through them
|
|
26
|
+
const float INK = 0.7;
|
|
27
|
+
|
|
28
|
+
// coverage of the ring lines at radius r, box-filtered over the antialiasing width, and
|
|
29
|
+
// faded to their mean coverage when the rings get too fine to resolve
|
|
30
|
+
float ringLines(float r, float f) {
|
|
31
|
+
float q = abs(fract(r * f + 0.5) - 0.5);
|
|
32
|
+
float aa = AA * f;
|
|
33
|
+
float c = clamp((LINE - q) / (2.0 * aa) + 0.5, 0.0, 1.0);
|
|
34
|
+
return mix(c, 2.0 * LINE, clamp(10.0 * aa - 0.5, 0.0, 1.0));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
vec4 transition(vec2 uv) {
|
|
38
|
+
vec4 a = getFromColor(uv);
|
|
39
|
+
vec4 b = getToColor(uv);
|
|
40
|
+
if (progress <= 0.0) return a;
|
|
41
|
+
if (progress >= 1.0) return b;
|
|
42
|
+
|
|
43
|
+
float t = progress * progress * (3.0 - 2.0 * progress);
|
|
44
|
+
float f = max(density, 1.0);
|
|
45
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
46
|
+
|
|
47
|
+
// the two centers turn around the middle of the frame and come together
|
|
48
|
+
float ang = 2.0 * PI * drift * t + START;
|
|
49
|
+
float k = max(bands, 1.0) * (1.0 - 0.75 * t);
|
|
50
|
+
vec2 axis = vec2(cos(ang), sin(ang)) * 0.5 * k / f;
|
|
51
|
+
float r1 = length(p - axis);
|
|
52
|
+
float r2 = length(p + axis);
|
|
53
|
+
// the second set is slightly finer than the first, which bends the bands into curves
|
|
54
|
+
float f2 = f + 1.2 * k;
|
|
55
|
+
|
|
56
|
+
// the beat of the two ring sets: wide bands where their rings line up, at this distance
|
|
57
|
+
// from the middle of the nearest band, in bands
|
|
58
|
+
float beat = abs(fract(f2 * r2 - f * r1 + 0.5) - 0.5);
|
|
59
|
+
// the bands open from their middles and widen until they cover the frame
|
|
60
|
+
// with an edge antialiased from the analytic gradient of the beat
|
|
61
|
+
vec2 grad = f2 * (p + axis) / max(r2, AA) - f * (p - axis) / max(r1, AA);
|
|
62
|
+
float s = min(AA * length(grad) + 0.004, EDGE);
|
|
63
|
+
float w = mix(-EDGE, 0.5 + EDGE, t);
|
|
64
|
+
float m = 1.0 - smoothstep(w - s, w + s, beat);
|
|
65
|
+
|
|
66
|
+
vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
|
|
67
|
+
|
|
68
|
+
// the thin lines of both sets, dark over the outgoing image and light over the incoming
|
|
69
|
+
// one, fade in and out
|
|
70
|
+
float o = INK * clamp(lines, 0.0, 1.0) * sin(PI * t);
|
|
71
|
+
float l = 1.0 - (1.0 - o * ringLines(r1, f)) * (1.0 - o * ringLines(r2, f2));
|
|
72
|
+
c.rgb = mix(c.rgb, vec3(c.a * m), l);
|
|
73
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
74
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image is a sheet of paper that folds in half in 3D along a vertical crease, then in half again along a horizontal one, its lit and shaded faces turning to show the back of the paper, and the small folded packet flies off the frame, leaving its shadow on the incoming image underneath
|
|
4
|
+
// Tags: paper, fold, 3d, shadow
|
|
5
|
+
|
|
6
|
+
// @param Direction the folded packet flies off toward
|
|
7
|
+
uniform vec2 direction; // = vec2(1.0, 0.5)
|
|
8
|
+
// @range(0, 1) How much the sheet tilts and recedes while it folds, so that the folds are seen in 3D
|
|
9
|
+
uniform float tilt; // = 0.6
|
|
10
|
+
// @range(0, 1) How much the faces darken as they turn away from the light, and the shadows they cast
|
|
11
|
+
uniform float shading; // = 0.6
|
|
12
|
+
// @color Color of the back of the paper, through which the print faintly shows
|
|
13
|
+
uniform vec4 paper; // = vec4(0.95, 0.94, 0.9, 1.0)
|
|
14
|
+
|
|
15
|
+
const float PI = 3.141592653589793;
|
|
16
|
+
// width of the anti-aliased edges, as a part of the frame's height
|
|
17
|
+
const float EDGE = 0.0015;
|
|
18
|
+
// how much the print shows through the back of the paper
|
|
19
|
+
const float SHOW = 0.1;
|
|
20
|
+
// width of the shaded crease, in frame heights
|
|
21
|
+
const float CREASE = 0.02;
|
|
22
|
+
// direction of the light, from the top left and the front
|
|
23
|
+
const vec3 LIGHT = vec3(-0.3995, 0.4494, 0.799);
|
|
24
|
+
|
|
25
|
+
vec4 front(vec2 st) {
|
|
26
|
+
return getFromColor(st / vec2(ratio, 1.0));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
vec4 back(vec2 st) {
|
|
30
|
+
vec4 c = front(st);
|
|
31
|
+
return vec4(mix(paper.rgb, c.rgb, SHOW), c.a * paper.a);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// the face of the packet's top layer: the image itself during the first fold, then the back
|
|
35
|
+
// of the right half, laid mirrored over the left half
|
|
36
|
+
vec4 topFace(vec2 st, bool second) {
|
|
37
|
+
return second ? back(vec2(ratio - st.x, st.y)) : front(st);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// distance inside the rectangle [0, h] x [0, k] (negative outside)
|
|
41
|
+
float inside(vec2 p, float h, float k) {
|
|
42
|
+
return min(min(p.x, h - p.x), min(p.y, k - p.y));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// The sheet in its own frame: a flat part [0, h] x [0, k] lying at z = 0 and a flap of the same
|
|
46
|
+
// size hinged on its edge x = h, turned toward the viewer so that it lies along `along`, with the
|
|
47
|
+
// normal n. During the second fold, x and y are swapped so that the crease is always along y.
|
|
48
|
+
// Where the ray o + t * v meets the flap's plane: (t, distance from the hinge, y), t < 0 if never.
|
|
49
|
+
vec3 hitFlap(vec3 o, vec3 v, float h, vec3 n, vec3 along) {
|
|
50
|
+
float den = dot(n, v);
|
|
51
|
+
if (abs(den) < 1e-5) return vec3(-1.0, 0.0, 0.0);
|
|
52
|
+
vec3 hinge = vec3(h, 0.0, 0.0);
|
|
53
|
+
float t = dot(n, hinge - o) / den;
|
|
54
|
+
vec3 q = o + t * v;
|
|
55
|
+
return vec3(t, dot(q - hinge, along), q.y);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// how much the point q is shaded, lit by l: by the flap, and by the flat part once it lifts
|
|
59
|
+
// above the incoming image
|
|
60
|
+
float shadowAt(vec3 q, vec3 l, float h, float k, vec3 n, vec3 along) {
|
|
61
|
+
float sh = 0.0;
|
|
62
|
+
if (q.z < -1e-4) {
|
|
63
|
+
float soft = 0.004 - 0.4 * q.z;
|
|
64
|
+
sh = smoothstep(-soft, soft, inside(q.xy - q.z / l.z * l.xy, h, k));
|
|
65
|
+
}
|
|
66
|
+
vec3 hit = hitFlap(q, l, h, n, along);
|
|
67
|
+
if (hit.x > 0.0) {
|
|
68
|
+
float height = hit.x * l.z;
|
|
69
|
+
float soft = 0.004 + 0.3 * height;
|
|
70
|
+
// the flap's shadow appears as it lifts and vanishes as it lands
|
|
71
|
+
sh = max(sh, min(4.0 * n.x * n.x, 1.0) * smoothstep(-soft, soft, inside(hit.yz, h, k)) / (1.0 + 3.0 * height));
|
|
72
|
+
}
|
|
73
|
+
return sh;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// a vector of the frame into the frame of the sheet, turned by yaw (around y), pitch (around x)
|
|
77
|
+
// and spin (around z), each given as (cos, sin)
|
|
78
|
+
vec3 toSheet(vec3 v, vec2 yaw, vec2 pitch, vec2 spin) {
|
|
79
|
+
v = vec3(yaw.x * v.x + yaw.y * v.z, v.y, yaw.x * v.z - yaw.y * v.x);
|
|
80
|
+
v = vec3(v.x, pitch.x * v.y + pitch.y * v.z, pitch.x * v.z - pitch.y * v.y);
|
|
81
|
+
return vec3(spin.x * v.x + spin.y * v.y, spin.x * v.y - spin.y * v.x, v.z);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
vec4 transition(vec2 uv) {
|
|
85
|
+
float w = ratio;
|
|
86
|
+
float shade = clamp(shading, 0.0, 1.0);
|
|
87
|
+
// the two folds, one right after the other, then the flight of the packet
|
|
88
|
+
float s = 2.0 * smoothstep(0.0, 0.62, progress);
|
|
89
|
+
bool second = s > 1.0;
|
|
90
|
+
float x = second ? s - 1.0 : s;
|
|
91
|
+
float a = PI * mix(x, x * x * (3.0 - 2.0 * x), 0.6);
|
|
92
|
+
float f = clamp((progress - 0.5) / 0.47, 0.0, 1.0);
|
|
93
|
+
|
|
94
|
+
// the sheet tilts and recedes while it folds, so that the folds are seen in 3D, and lies flat
|
|
95
|
+
// again as the packet flies off
|
|
96
|
+
float turn = clamp(tilt, 0.0, 1.0) * (smoothstep(0.0, 0.25, progress) - smoothstep(0.4, 0.8, progress));
|
|
97
|
+
vec2 yaw = vec2(cos(0.45 * turn), sin(0.45 * turn));
|
|
98
|
+
vec2 pitch = vec2(cos(0.55 * turn), -sin(0.55 * turn));
|
|
99
|
+
float dist = 2.5 * max(w, 1.0);
|
|
100
|
+
float recede = dist * 0.35 * turn;
|
|
101
|
+
|
|
102
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
103
|
+
// the point of the sheet held in the middle of the frame slides to the middle of the packet
|
|
104
|
+
vec2 c = vec2(0.5 * w - 0.25 * w * min(s, 1.0), 0.5 - 0.25 * max(s - 1.0, 0.0));
|
|
105
|
+
// far enough for the packet and its shadow to leave the frame
|
|
106
|
+
float reach = 0.5 * (abs(dir.x) * w + abs(dir.y)) + length(vec2(0.25 * w, 0.25)) + 0.4;
|
|
107
|
+
float lift = 0.3 * smoothstep(0.0, 0.5, f);
|
|
108
|
+
float turned = (dir.x < 0.0 ? 0.7 : -0.7) * f * f;
|
|
109
|
+
vec2 spin = vec2(cos(turned), sin(turned));
|
|
110
|
+
|
|
111
|
+
// the eye, the ray toward the point of the frame and the light, in the frame of the sheet,
|
|
112
|
+
// where the sheet lies on the plane z = 0 and the incoming image on z = -lift
|
|
113
|
+
vec3 center = vec3(vec2(0.5 * w, 0.5) + dir * reach * f * f, -recede);
|
|
114
|
+
vec3 eye = vec3(0.5 * w, 0.5, dist);
|
|
115
|
+
vec3 e = toSheet(eye - center, yaw, pitch, spin) + vec3(c, 0.0);
|
|
116
|
+
vec3 d = toSheet(vec3(uv.x * w, uv.y, 0.0) - eye, yaw, pitch, spin);
|
|
117
|
+
vec3 l = toSheet(LIGHT, yaw, pitch, spin);
|
|
118
|
+
if (second) {
|
|
119
|
+
e.xy = e.yx;
|
|
120
|
+
d.xy = d.yx;
|
|
121
|
+
l.xy = l.yx;
|
|
122
|
+
}
|
|
123
|
+
float h = second ? 0.5 : 0.5 * w;
|
|
124
|
+
float k = second ? 0.5 * w : 1.0;
|
|
125
|
+
float creased = sin(a);
|
|
126
|
+
vec3 n = vec3(-creased, 0.0, cos(a));
|
|
127
|
+
vec3 along = vec3(cos(a), 0.0, creased);
|
|
128
|
+
|
|
129
|
+
vec4 col = getToColor(uv);
|
|
130
|
+
if (d.z < 0.0) {
|
|
131
|
+
vec3 g = e + d * (e.z + lift) / -d.z;
|
|
132
|
+
// the shadow fades as the packet flies higher
|
|
133
|
+
col.rgb *= 1.0 - 0.7 * shade * (1.0 - f * f) * shadowAt(g, l, h, k, n, along);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// the flat part
|
|
137
|
+
float t = d.z < 0.0 ? e.z / -d.z : -1.0;
|
|
138
|
+
vec3 p = e + t * d;
|
|
139
|
+
float m = clamp(inside(p.xy, h, k) / (EDGE * t) + 1.0, 0.0, 1.0);
|
|
140
|
+
if (t > 0.0 && m > 0.0) {
|
|
141
|
+
vec4 img = topFace(second ? p.yx : p.xy, second);
|
|
142
|
+
float sh = shadowAt(p, l, h, k, n, along);
|
|
143
|
+
img.rgb *= (1.0 - 0.7 * shade * sh) * (1.0 - 0.5 * shade * creased * exp(-abs(h - p.x) / CREASE));
|
|
144
|
+
col = mix(col, img, m);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// the flap
|
|
148
|
+
vec3 hit = hitFlap(e, d, h, n, along);
|
|
149
|
+
if (hit.x > 0.0) {
|
|
150
|
+
float r = hit.y;
|
|
151
|
+
// edges seen at a grazing angle are narrower on screen
|
|
152
|
+
float dr = dot(along, normalize(d));
|
|
153
|
+
float fore = sqrt(max(1.0 - dr * dr, 0.0025));
|
|
154
|
+
float mf = clamp(min(min(r, h - r) * fore, min(hit.z, k - hit.z)) / (EDGE * hit.x) + 1.0, 0.0, 1.0);
|
|
155
|
+
if (mf > 0.0) {
|
|
156
|
+
bool up = dot(n, e - vec3(h, 0.0, 0.0)) > 0.0;
|
|
157
|
+
vec2 st = vec2(h + r, hit.z);
|
|
158
|
+
if (second) st = st.yx;
|
|
159
|
+
vec4 img = up ? topFace(st, second) : back(st);
|
|
160
|
+
// lit by the light, relative to the sheet lying flat
|
|
161
|
+
float lit = dot(up ? n : -n, l) - l.z;
|
|
162
|
+
img.rgb *= max(1.0 + 0.6 * shade * lit, 0.0) * (1.0 - 0.5 * shade * creased * exp(-abs(r) / CREASE));
|
|
163
|
+
col = mix(col, img, mf);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return col;
|
|
167
|
+
}
|