gl-transitions 3.0.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 +64 -0
- package/compatibility.json +359 -11
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/BookFlip.glsl +124 -21
- package/glsl3/Clothesline.glsl +217 -0
- package/glsl3/ComicPanels.glsl +174 -0
- package/glsl3/Cube.glsl +105 -52
- 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/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/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/WaterDrop.glsl +69 -13
- package/glsl3/WaveWipe.glsl +154 -0
- package/index.js +1 -1
- package/layouts.json +991 -19
- package/llms-full.txt +791 -403
- package/llms.txt +219 -197
- package/msl/BookFlip.metal +575 -114
- package/msl/Clothesline.metal +828 -0
- package/msl/ComicPanels.metal +959 -0
- package/msl/Cube.metal +466 -170
- 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/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/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/WaterDrop.metal +258 -49
- package/msl/WaveWipe.metal +618 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +97 -51
- package/sksl/BookFlip.sksl +117 -20
- package/sksl/Clothesline.sksl +217 -0
- package/sksl/ComicPanels.sksl +176 -0
- package/sksl/Cube.sksl +99 -46
- 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/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/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/WaterDrop.sksl +64 -10
- package/sksl/WaveWipe.sksl +165 -0
- package/sksl/index.js +1 -1
- package/transitions/BookFlip.glsl +124 -21
- package/transitions/Clothesline.glsl +216 -0
- package/transitions/ComicPanels.glsl +173 -0
- package/transitions/Cube.glsl +105 -52
- 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/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/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/WaterDrop.glsl +69 -13
- package/transitions/WaveWipe.glsl +153 -0
- package/wgsl/BookFlip.wgsl +552 -105
- package/wgsl/Clothesline.wgsl +756 -0
- package/wgsl/ComicPanels.wgsl +886 -0
- package/wgsl/Cube.wgsl +461 -156
- 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/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/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/WaterDrop.wgsl +251 -49
- package/wgsl/WaveWipe.wgsl +581 -0
package/glsl3/GridFlip.glsl
CHANGED
|
@@ -1,77 +1,172 @@
|
|
|
1
1
|
// GridFlip — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/GridFlip.glsl
|
|
2
2
|
// License: MIT
|
|
3
3
|
// Author: TimDonselaar
|
|
4
|
-
// Description: The image splits into a grid of
|
|
5
|
-
// Tags: grid, tiles, flip
|
|
4
|
+
// Description: The image splits into a grid of cards that lift apart and turn over in perspective one after another, each one showing its part of the incoming image on its back
|
|
5
|
+
// Tags: grid, tiles, flip, 3d
|
|
6
6
|
// ported by gre from https://gist.github.com/TimDonselaar/9bcd1c4b5934ba60087bdb55c2ea92e5
|
|
7
7
|
|
|
8
8
|
// @param Number of tiles (columns, rows)
|
|
9
9
|
uniform ivec2 size; // = ivec2(4)
|
|
10
|
+
// @range(0, 0.4) Part of the transition at the start and at the end during which the gaps between the tiles open and close
|
|
10
11
|
uniform float pause; // = 0.1
|
|
12
|
+
// @range(0, 0.4) Width of the gaps between the tiles, as a part of a tile's shorter side
|
|
11
13
|
uniform float dividerWidth; // = 0.05
|
|
12
14
|
// @color Color behind the tiles
|
|
13
15
|
uniform vec4 bgcolor; // = vec4(0.0, 0.0, 0.0, 1.0)
|
|
16
|
+
// @range(0, 1) How much the order of the flips is shuffled, from a diagonal wave across the grid to random
|
|
14
17
|
uniform float randomness; // = 0.1
|
|
15
|
-
|
|
16
|
-
float
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
const float PI = 3.141592653589793;
|
|
20
|
+
// width of the anti-aliased edges, as a part of the frame's height
|
|
21
|
+
const float EDGE = 0.0012;
|
|
22
|
+
// distance of the eye from each tile, in tile sizes
|
|
23
|
+
const float EYE = 2.2;
|
|
24
|
+
// part of the flips during which the last tile waits for its turn
|
|
25
|
+
const float STAGGER = 0.55;
|
|
26
|
+
// light direction (x, y over z): from the upper left, in front of the frame
|
|
27
|
+
const vec2 LIGHT = vec2(-0.45, 0.3);
|
|
28
|
+
|
|
29
|
+
float hash12(vec2 v) {
|
|
30
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
31
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
32
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
18
33
|
}
|
|
19
34
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
float top = rectangleSize.y * (rectanglePos.y + 1.0);
|
|
24
|
-
float bottom = rectangleSize.y * rectanglePos.y;
|
|
25
|
-
float left = rectangleSize.x * rectanglePos.x;
|
|
26
|
-
float right = rectangleSize.x * (rectanglePos.x + 1.0);
|
|
27
|
-
float minX = min(abs(p.x - left), abs(p.x - right));
|
|
28
|
-
float minY = min(abs(p.y - top), abs(p.y - bottom));
|
|
29
|
-
return min(minX, minY);
|
|
35
|
+
// eased turn: smooth start and landing, without lingering at either end
|
|
36
|
+
float easeInOut(float t) {
|
|
37
|
+
return mix(t, t * t * (3.0 - 2.0 * t), 0.7);
|
|
30
38
|
}
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
40
|
+
// time the gaps take to open and to close
|
|
41
|
+
float pausePart() {
|
|
42
|
+
return clamp(pause, 0.05, 0.4);
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
45
|
+
// the turn of a tile, 0 showing the outgoing image to 1 showing the incoming one,
|
|
46
|
+
// at q the progress of the flips and with stagger the delay of the last tile
|
|
47
|
+
float flipTime(vec2 cell, vec2 grid, float q, float stagger) {
|
|
48
|
+
// a diagonal wave from the top left corner, shuffled by randomness
|
|
49
|
+
float wave = (cell.x + (grid.y - 1.0 - cell.y)) / max(grid.x + grid.y - 2.0, 1.0);
|
|
50
|
+
float order = mix(wave, hash12(cell + 7.31), clamp(randomness, 0.0, 1.0));
|
|
51
|
+
return easeInOut(clamp((q - order * stagger) / (1.0 - stagger), 0.0, 1.0));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// how open the gaps are: they open at the start and close at the end
|
|
55
|
+
float gapAmount() {
|
|
56
|
+
float pp = pausePart();
|
|
57
|
+
return smoothstep(0.0, pp, progress) * (1.0 - smoothstep(1.0 - pp, 1.0, progress));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// coverage of a signed distance (positive inside) with an edge of width e
|
|
61
|
+
float aa(float d, float e) {
|
|
62
|
+
return clamp(d / max(2.0 * e, 1e-6) + 0.5, 0.0, 1.0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
float boxShadow(vec2 p, vec2 halfSize, float blur) {
|
|
66
|
+
vec2 d = abs(p) - halfSize;
|
|
67
|
+
float dist = length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
|
68
|
+
return 1.0 - smoothstep(-blur, blur, dist);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
vec4 transition(vec2 uv) {
|
|
72
|
+
vec2 grid = max(vec2(size), 1.0);
|
|
73
|
+
vec2 frame = vec2(ratio, 1.0);
|
|
74
|
+
vec2 tileSize = frame / grid;
|
|
75
|
+
vec2 cell = clamp(floor(uv * grid), vec2(0.0), grid - 1.0);
|
|
76
|
+
vec2 pos = uv * frame;
|
|
77
|
+
float gapOpen = gapAmount();
|
|
78
|
+
float minSide = min(tileSize.x, tileSize.y);
|
|
79
|
+
float gap = clamp(dividerWidth, 0.0, 0.4) * minSide * gapOpen;
|
|
80
|
+
vec2 halfTile = 0.5 * tileSize - gap;
|
|
81
|
+
float eye = EYE * max(tileSize.x, tileSize.y);
|
|
82
|
+
// the flips start while the gaps finish opening, and end while they start closing
|
|
83
|
+
float pp = 0.6 * pausePart();
|
|
84
|
+
float q = clamp((progress - pp) / (1.0 - 2.0 * pp), 0.0, 1.0);
|
|
85
|
+
// a single tile takes all the time to turn
|
|
86
|
+
float stagger = grid.x * grid.y > 1.5 ? STAGGER : 0.0;
|
|
87
|
+
|
|
88
|
+
// the two nearest layers of the tiles that cover this point
|
|
89
|
+
vec4 c1 = vec4(0.0);
|
|
90
|
+
vec4 c2 = vec4(0.0);
|
|
91
|
+
float m1 = 0.0;
|
|
92
|
+
float m2 = 0.0;
|
|
93
|
+
float z1 = 1e9;
|
|
94
|
+
float z2 = 1e9;
|
|
95
|
+
bool rest1 = true;
|
|
96
|
+
bool rest2 = true;
|
|
97
|
+
float shadowBg = 0.0;
|
|
98
|
+
float shadowFlip = 0.0;
|
|
99
|
+
|
|
100
|
+
for (int j = -1; j <= 1; j++) {
|
|
101
|
+
for (int i = -1; i <= 1; i++) {
|
|
102
|
+
vec2 nc = cell + vec2(float(i), float(j));
|
|
103
|
+
if (nc.x < 0.0 || nc.y < 0.0 || nc.x > grid.x - 1.0 || nc.y > grid.y - 1.0) continue;
|
|
104
|
+
float t = flipTime(nc, grid, q, stagger);
|
|
105
|
+
float a = PI * t;
|
|
106
|
+
float ca = cos(a);
|
|
107
|
+
float sa = sin(a);
|
|
108
|
+
bool rest = t <= 0.0 || t >= 1.0;
|
|
109
|
+
if (rest) {
|
|
110
|
+
ca = t <= 0.0 ? 1.0 : -1.0;
|
|
111
|
+
sa = 0.0;
|
|
112
|
+
}
|
|
113
|
+
vec2 center = (nc + 0.5) * tileSize;
|
|
114
|
+
vec2 q = pos - center;
|
|
115
|
+
|
|
116
|
+
// shadows on the background: the tiles float a little above it, and higher while they turn
|
|
117
|
+
float lift = 0.05 * gapOpen * minSide + 0.35 * halfTile.x * sa;
|
|
118
|
+
vec2 shOffset = -LIGHT * lift;
|
|
119
|
+
vec2 shHalf = vec2(halfTile.x * abs(ca) + 0.5 * lift, halfTile.y);
|
|
120
|
+
float sh = boxShadow(q - shOffset, shHalf, 0.01 * minSide + 0.5 * lift);
|
|
121
|
+
shadowBg = 1.0 - (1.0 - shadowBg) * (1.0 - 0.45 * gapOpen * sh);
|
|
122
|
+
shadowFlip = max(shadowFlip, 0.45 * sa * sa * sh);
|
|
123
|
+
|
|
124
|
+
// ray from the eye in front of the tile's center, through this point, to the turned tile
|
|
125
|
+
// the tile turns around its vertical axis: its local x axis is (ca, 0, -sa), its normal (sa, 0, ca)
|
|
126
|
+
float den = eye * ca - q.x * sa;
|
|
127
|
+
if (abs(den) < 1e-6) continue;
|
|
128
|
+
float s = eye * ca / den;
|
|
129
|
+
if (s <= 0.0) continue;
|
|
130
|
+
vec3 hit = vec3(s * q.x, s * q.y, eye * (1.0 - s));
|
|
131
|
+
float u = hit.x * ca - hit.z * sa;
|
|
132
|
+
// the edges seen on screen, to anti-alias them
|
|
133
|
+
float xa = halfTile.x * ca * eye / (eye + halfTile.x * sa);
|
|
134
|
+
float xb = -halfTile.x * ca * eye / (eye - halfTile.x * sa);
|
|
135
|
+
float dx = min(q.x - min(xa, xb), max(xa, xb) - q.x);
|
|
136
|
+
float dy = (halfTile.y - abs(hit.y)) / s;
|
|
137
|
+
// soft edges, except where the tiles touch each other
|
|
138
|
+
float e = max(min(EDGE, gap), EDGE * min(8.0 * sa, 1.0));
|
|
139
|
+
float m = aa(min(dx, dy), e);
|
|
140
|
+
if (m <= 0.0) continue;
|
|
141
|
+
|
|
142
|
+
// the front shows the outgoing image, the back the incoming one, seen from behind
|
|
143
|
+
bool front = ca > 0.0;
|
|
144
|
+
vec2 src = (center + vec2(front ? u : -u, hit.y)) / frame;
|
|
145
|
+
vec4 col = front ? getFromColor(src) : getToColor(src);
|
|
146
|
+
if (!rest) {
|
|
147
|
+
// lit from the upper left: the turning side facing the light brightens a little, the other darkens
|
|
148
|
+
float nx = front ? sa : -sa;
|
|
149
|
+
float lit = abs(ca) + nx * LIGHT.x;
|
|
150
|
+
col.rgb *= mix(0.35, 1.0, clamp(lit, 0.0, 1.0)) + 0.25 * max(lit - 1.0, 0.0);
|
|
151
|
+
// a thin bright rim on the edges of the turning card
|
|
152
|
+
col.rgb += 0.12 * sa * (1.0 - smoothstep(0.0, 3.0 * EDGE, min(dx, dy)));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (s < z1) {
|
|
156
|
+
c2 = c1; m2 = m1; z2 = z1; rest2 = rest1;
|
|
157
|
+
c1 = col; m1 = m; z1 = s; rest1 = rest;
|
|
158
|
+
} else if (s < z2) {
|
|
159
|
+
c2 = col; m2 = m; z2 = s; rest2 = rest;
|
|
160
|
+
}
|
|
74
161
|
}
|
|
75
|
-
return mix(bgcolor, getToColor(p), a);
|
|
76
162
|
}
|
|
163
|
+
|
|
164
|
+
// the flipping tiles cast their shadows on the background and on the tiles lying still
|
|
165
|
+
vec4 color = bgcolor;
|
|
166
|
+
color.rgb *= 1.0 - clamp(max(shadowBg, shadowFlip), 0.0, 1.0);
|
|
167
|
+
if (rest2) c2.rgb *= 1.0 - shadowFlip;
|
|
168
|
+
if (rest1) c1.rgb *= 1.0 - shadowFlip;
|
|
169
|
+
color = mix(color, c2, m2);
|
|
170
|
+
color = mix(color, c1, m1);
|
|
171
|
+
return color;
|
|
77
172
|
}
|
package/glsl3/HeartWipe.glsl
CHANGED
|
@@ -1,19 +1,79 @@
|
|
|
1
1
|
// HeartWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/HeartWipe.glsl
|
|
2
2
|
// Author: gre
|
|
3
3
|
// License: MIT
|
|
4
|
-
// Description: A heart
|
|
4
|
+
// Description: A heart grows from the center with a little heartbeat to reveal the incoming image
|
|
5
5
|
// Tags: shape, wipe, heart
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
// @param Center of the heart
|
|
8
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
9
|
+
// @range(0, 0.1) Softness of the heart's edge
|
|
10
|
+
uniform float smoothness; // = 0.006
|
|
11
|
+
// @range(0, 1) Strength of the heartbeat throb as the heart grows
|
|
12
|
+
uniform float pulse; // = 0.5
|
|
13
|
+
// @color Color of the soft light glowing along the heart's edge
|
|
14
|
+
uniform vec3 glowColor; // = vec3(1.0, 0.85, 0.9)
|
|
15
|
+
// @range(0, 1) Strength of the glow (0 for a clean edge)
|
|
16
|
+
uniform float glow; // = 0.3
|
|
17
|
+
|
|
18
|
+
// The heart shape: tip at (0, 0), notch at (0, 1), lobes are circles of radius sqrt(2)/4
|
|
19
|
+
// centered at (+-0.25, 0.75), tangent to the lines y = |x|. HEART_O is its center.
|
|
20
|
+
#define HEART_O vec2(0.0, 0.55)
|
|
21
|
+
#define LOBE vec2(0.25, 0.75)
|
|
22
|
+
#define LOBE_R 0.35355339
|
|
23
|
+
|
|
24
|
+
float dot2(vec2 v) { return dot(v, v); }
|
|
25
|
+
|
|
26
|
+
// Exact signed distance to the heart
|
|
27
|
+
float sdHeart(vec2 p) {
|
|
28
|
+
p.x = abs(p.x);
|
|
29
|
+
if (p.x + p.y > 1.0) return sqrt(dot2(p - LOBE)) - LOBE_R;
|
|
30
|
+
return sqrt(min(dot2(p - vec2(0.0, 1.0)), dot2(p - 0.5 * max(p.x + p.y, 0.0)))) * sign(p.x - p.y);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Scale of the smallest heart (centered on HEART_O) that contains p: the heart is the union of a
|
|
34
|
+
// lobe disk and the triangle |x| <= y, |x| + y <= 1, both convex around HEART_O, so the boundary
|
|
35
|
+
// along a ray is the farthest of their exits.
|
|
36
|
+
float heartScale(vec2 p) {
|
|
37
|
+
float l = length(p);
|
|
38
|
+
if (l < 1e-6) return 0.0;
|
|
39
|
+
vec2 d = vec2(abs(p.x), p.y) / l;
|
|
40
|
+
vec2 m = HEART_O - LOBE;
|
|
41
|
+
float b = dot(m, d);
|
|
42
|
+
float tDisk = -b + sqrt(b * b - dot2(m) + LOBE_R * LOBE_R);
|
|
43
|
+
float tSide = d.x > d.y ? HEART_O.y / (d.x - d.y) : 1e6;
|
|
44
|
+
float tTop = d.x + d.y > 0.0 ? (1.0 - HEART_O.y) / (d.x + d.y) : 1e6;
|
|
45
|
+
return l / max(tDisk, min(tSide, tTop));
|
|
12
46
|
}
|
|
47
|
+
|
|
13
48
|
vec4 transition (vec2 uv) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
49
|
+
vec4 a = getFromColor(uv);
|
|
50
|
+
vec4 b = getToColor(uv);
|
|
51
|
+
vec2 asp = vec2(ratio, 1.0);
|
|
52
|
+
vec2 c = center * asp;
|
|
53
|
+
// Scale at which the heart covers the whole frame: the corners, plus the point of the top edge
|
|
54
|
+
// in line with the notch (the only concave part of the heart)
|
|
55
|
+
float cx = clamp(center.x, 0.0, 1.0) * ratio;
|
|
56
|
+
float full = max(
|
|
57
|
+
max(max(heartScale(vec2(0.0, 0.0) - c), heartScale(vec2(ratio, 0.0) - c)),
|
|
58
|
+
max(heartScale(vec2(0.0, 1.0) - c), heartScale(vec2(ratio, 1.0) - c))),
|
|
59
|
+
heartScale(vec2(cx, 1.0) - c));
|
|
60
|
+
float sm = max(smoothness, 0.001);
|
|
61
|
+
// Margin so the soft edge is past the frame at progress = 1
|
|
62
|
+
full += 4.0 * sm;
|
|
63
|
+
|
|
64
|
+
// Eased growth with two heartbeats riding on it: the heart surges, then almost stops
|
|
65
|
+
float p = progress;
|
|
66
|
+
float e = p * p * (2.0 - p);
|
|
67
|
+
float env = max(sin(3.14159265 * p), 0.0);
|
|
68
|
+
float beat = sin(6.28318531 * 2.0 * p) * env * env;
|
|
69
|
+
float s = full * clamp(e + 0.09 * pulse * beat, 0.0, 1.0);
|
|
70
|
+
if (s <= 0.0) return a;
|
|
71
|
+
|
|
72
|
+
vec2 q = uv * asp - c;
|
|
73
|
+
float d = s * sdHeart(q / s + HEART_O);
|
|
74
|
+
float m = smoothstep(0.0, sm, -d);
|
|
75
|
+
vec4 col = mix(a, b, m);
|
|
76
|
+
// Soft light just outside the edge, faded in and out with the transition (adds no alpha)
|
|
77
|
+
float light = exp(-max(d, 0.0) / (0.008 + sm)) * (1.0 - m) * glow * min(1.0, 4.0 * env);
|
|
78
|
+
return col + vec4(glowColor * light, 0.0);
|
|
19
79
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// InsideCube — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/InsideCube.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The camera stands inside a cube: the outgoing image covers the wall in front of it and the view turns toward the next inner wall, so the outgoing image swings away in perspective as the incoming one turns into view, the walls darkening into the shaded inner corner between them
|
|
5
|
+
// Tags: 3d, cube, rotate, perspective, directional
|
|
6
|
+
|
|
7
|
+
// @param Direction the view turns toward, snapped to its main axis (left, right, up or down): the incoming image is on the wall on that side
|
|
8
|
+
uniform vec2 direction; // = vec2(1.0, 0.0)
|
|
9
|
+
// @range(60, 120) Field of view along the turn, in degrees: at 90 the camera stays at the center of the cube, a wider view makes the walls recede more
|
|
10
|
+
uniform float fov; // = 90.0
|
|
11
|
+
// @range(0, 1) How much the walls darken as they turn away, and the shadow in the inner corners of the cube
|
|
12
|
+
uniform float shading; // = 0.6
|
|
13
|
+
// @color Color of the other faces of the cube, seen where the two walls leave the frame uncovered during the turn
|
|
14
|
+
uniform vec4 background; // = vec4(0.09, 0.09, 0.1, 1.0)
|
|
15
|
+
|
|
16
|
+
const float PI = 3.141592653589793;
|
|
17
|
+
// width of the anti-aliased edges, in frame heights
|
|
18
|
+
const float EDGE = 0.002;
|
|
19
|
+
|
|
20
|
+
vec4 premultiply(vec4 c) {
|
|
21
|
+
return vec4(c.rgb * c.a, c.a);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// shadow of a concave edge of the cube, at a distance dist from it
|
|
25
|
+
float cornerShadow(float dist, float size) {
|
|
26
|
+
float k = 1.0 - smoothstep(0.0, size, dist);
|
|
27
|
+
return k * k;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// the image on a wall at the point l of the wall, in frame heights from its center (l.x along
|
|
31
|
+
// the turn, l.y across), premultiplied; s and vertical undo the mirroring and the swap of axes
|
|
32
|
+
// that transition() applies to the frame coordinates
|
|
33
|
+
vec4 wallColor(vec2 l, bool incoming, bool vertical, float s) {
|
|
34
|
+
vec2 h = vec2(l.x * s, l.y);
|
|
35
|
+
vec2 p = vertical ? h.yx : h;
|
|
36
|
+
vec2 st = clamp(p / vec2(ratio, 1.0) + 0.5, 0.0, 1.0);
|
|
37
|
+
return premultiply(incoming ? getToColor(st) : getFromColor(st));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
vec4 transition(vec2 uv) {
|
|
41
|
+
bool vertical = abs(direction.y) > abs(direction.x);
|
|
42
|
+
float s = (vertical ? direction.y : direction.x) < 0.0 ? -1.0 : 1.0;
|
|
43
|
+
// q.x: along the turn, toward the incoming wall; q.y: across; in frame heights
|
|
44
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
45
|
+
vec2 q = vertical ? p.yx : p;
|
|
46
|
+
q.x *= s;
|
|
47
|
+
// half sizes of a wall along and across the turn
|
|
48
|
+
float A = vertical ? 0.5 : 0.5 * ratio;
|
|
49
|
+
float B = vertical ? 0.5 * ratio : 0.5;
|
|
50
|
+
// focal length: a wall exactly fills the frame when seen square from that distance
|
|
51
|
+
// (below about 53 degrees the camera would stand outside the cube)
|
|
52
|
+
float F = A / tan(radians(clamp(fov, 55.0, 170.0)) * 0.5);
|
|
53
|
+
|
|
54
|
+
float e = smoothstep(0.0, 1.0, progress);
|
|
55
|
+
float th = 0.5 * PI * e;
|
|
56
|
+
float c = cos(th);
|
|
57
|
+
float sn = sin(th);
|
|
58
|
+
float amount = max(sin(PI * e), 0.0); // 0 at both ends, so the images are untouched there
|
|
59
|
+
float aa = EDGE * min(1.0, 40.0 * amount) + 1e-6;
|
|
60
|
+
float shadow = shading * min(1.0, 4.0 * amount);
|
|
61
|
+
|
|
62
|
+
// in the plane of the turn (a: along, z: depth), the outgoing wall is z = F, a in [-A, A],
|
|
63
|
+
// the incoming wall is a = A, z in [F - 2A, F]; the camera starts in front of the center of
|
|
64
|
+
// the first one and ends in front of the center of the second one
|
|
65
|
+
vec2 cam = (A - F) * e * vec2(1.0, -1.0);
|
|
66
|
+
vec2 d = vec2(q.x * c + F * sn, F * c - q.x * sn);
|
|
67
|
+
|
|
68
|
+
// the inner corner between the two walls projects to a line across the frame
|
|
69
|
+
vec2 P = vec2(A, F) - cam;
|
|
70
|
+
float sc = F * (P.x * c - P.y * sn) / max(P.x * sn + P.y * c, 1e-6);
|
|
71
|
+
|
|
72
|
+
// outgoing wall
|
|
73
|
+
float tf = d.y > 1e-6 ? (F - cam.y) / d.y : 1e6;
|
|
74
|
+
float af = cam.x + tf * d.x;
|
|
75
|
+
vec2 lf = vec2(af, q.y * tf);
|
|
76
|
+
// incoming wall
|
|
77
|
+
float ti = d.x > 1e-6 ? (A - cam.x) / d.x : 1e6;
|
|
78
|
+
float ai = (F - A) - (cam.y + ti * d.y);
|
|
79
|
+
vec2 li = vec2(ai, q.y * ti);
|
|
80
|
+
|
|
81
|
+
// each wall darkens as it turns away from the view, and toward the concave edges
|
|
82
|
+
float size = 0.8 * min(A, B);
|
|
83
|
+
float edgeF = cornerShadow(A - af, size) + 0.5 * cornerShadow(B - abs(lf.y), size);
|
|
84
|
+
float edgeI = cornerShadow(ai + A, size) + 0.5 * cornerShadow(B - abs(li.y), size);
|
|
85
|
+
float shadeF = (1.0 - shading * 0.8 * (1.0 - c)) * (1.0 - 0.7 * shadow * min(edgeF, 1.0));
|
|
86
|
+
float shadeI = (1.0 - shading * 0.8 * (1.0 - sn)) * (1.0 - 0.7 * shadow * min(edgeI, 1.0));
|
|
87
|
+
|
|
88
|
+
// how much of the pixel each wall covers, from distances on screen in frame heights: split at
|
|
89
|
+
// the corner line, cut across by the edges of the walls (lb = q.y * t), and at their far
|
|
90
|
+
// edges (along the wall, a moves F * t / d.depth times faster than q.x)
|
|
91
|
+
float wF = clamp(0.5 + (sc - q.x) / aa, 0.0, 1.0);
|
|
92
|
+
float covF = wF * clamp(0.5 + (B / tf - abs(q.y)) / aa, 0.0, 1.0)
|
|
93
|
+
* clamp(0.5 + (af + A) * d.y / (tf * F * aa), 0.0, 1.0);
|
|
94
|
+
float covI = (1.0 - wF) * clamp(0.5 + (B / ti - abs(q.y)) / aa, 0.0, 1.0)
|
|
95
|
+
* clamp(0.5 + (A - ai) * d.x / (ti * F * aa), 0.0, 1.0);
|
|
96
|
+
// only sample the walls that show in this pixel
|
|
97
|
+
vec4 colF = covF > 0.0 ? wallColor(lf, false, vertical, s) : vec4(0.0);
|
|
98
|
+
vec4 colI = covI > 0.0 ? wallColor(li, true, vertical, s) : vec4(0.0);
|
|
99
|
+
colF.rgb *= shadeF;
|
|
100
|
+
colI.rgb *= shadeI;
|
|
101
|
+
|
|
102
|
+
// the other faces of the cube, with the same shadow along their edges with the two walls
|
|
103
|
+
vec4 bg = premultiply(background);
|
|
104
|
+
float cov = covF + covI;
|
|
105
|
+
if (cov < 1.0) {
|
|
106
|
+
// where the ray meets the floor or the ceiling, never beyond the walls
|
|
107
|
+
float tb = min(B / max(abs(q.y), 1e-6), min(tf, ti));
|
|
108
|
+
vec2 fl = cam + tb * d;
|
|
109
|
+
float edgeB = cornerShadow(F - fl.y, size) + cornerShadow(A - fl.x, size);
|
|
110
|
+
bg.rgb *= 1.0 - 0.5 * shadow * min(edgeB, 1.0);
|
|
111
|
+
}
|
|
112
|
+
vec4 col = colF * covF + colI * covI + bg * (1.0 - cov);
|
|
113
|
+
return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
|
|
114
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// KeyholeWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/KeyholeWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// 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
|
|
5
|
+
// Tags: shape, wipe, keyhole, iris, reveal
|
|
6
|
+
|
|
7
|
+
// @param Center of the keyhole
|
|
8
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
9
|
+
// @range(0, 1) Strength of the bevelled rim around the keyhole and the shadow inside it (0 for a clean cut)
|
|
10
|
+
uniform float rim; // = 0.6
|
|
11
|
+
// @range(0, 0.05) Softness of the keyhole's edge
|
|
12
|
+
uniform float smoothness; // = 0.002
|
|
13
|
+
|
|
14
|
+
// The keyhole, in its own units (0.85 tall, from y = -0.4 to 0.45): a round head on top of a slot
|
|
15
|
+
// that widens downward.
|
|
16
|
+
#define HEAD vec2(0.0, 0.2)
|
|
17
|
+
#define HEAD_R 0.25
|
|
18
|
+
#define SLOT_Y -0.17
|
|
19
|
+
const float SLOT_HE = 0.23;
|
|
20
|
+
const float SLOT_TOP = 0.085;
|
|
21
|
+
const float SLOT_BOTTOM = 0.165;
|
|
22
|
+
const float SLOT_ROUND = 0.025;
|
|
23
|
+
// height of the point the keyhole grows around, in its head
|
|
24
|
+
const float GROW_Y = 0.1;
|
|
25
|
+
// widths of the bevel and of the rim's shadows, in keyhole units
|
|
26
|
+
const float BEVEL = 0.028;
|
|
27
|
+
const float SHADE = 0.05;
|
|
28
|
+
|
|
29
|
+
float dot2(vec2 v) { return dot(v, v); }
|
|
30
|
+
|
|
31
|
+
// Signed distance to the slot, a trapezoid with rounded corners
|
|
32
|
+
float sdSlot(vec2 p) {
|
|
33
|
+
p.y -= SLOT_Y;
|
|
34
|
+
float r1 = SLOT_BOTTOM - SLOT_ROUND;
|
|
35
|
+
float r2 = SLOT_TOP - SLOT_ROUND;
|
|
36
|
+
float he = SLOT_HE - SLOT_ROUND;
|
|
37
|
+
vec2 k1 = vec2(r2, he);
|
|
38
|
+
vec2 k2 = vec2(r2 - r1, 2.0 * he);
|
|
39
|
+
p.x = abs(p.x);
|
|
40
|
+
vec2 ca = vec2(p.x - min(p.x, p.y < 0.0 ? r1 : r2), abs(p.y) - he);
|
|
41
|
+
vec2 cb = p - k1 + k2 * clamp(dot(k1 - p, k2) / dot2(k2), 0.0, 1.0);
|
|
42
|
+
float s = (cb.x < 0.0 && ca.y < 0.0) ? -1.0 : 1.0;
|
|
43
|
+
return s * sqrt(min(dot2(ca), dot2(cb))) - SLOT_ROUND;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
float sdKeyhole(vec2 p) {
|
|
47
|
+
return min(length(p - HEAD) - HEAD_R, sdSlot(p));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Scale at which the keyhole's head, a disk, reaches the point p (seen from the growth point):
|
|
51
|
+
// the root of |p - s h| = s HEAD_R, h being the head's center
|
|
52
|
+
float reach(vec2 p) {
|
|
53
|
+
vec2 h = HEAD - vec2(0.0, GROW_Y);
|
|
54
|
+
float k = HEAD_R * HEAD_R - dot2(h);
|
|
55
|
+
float b = dot(p, h);
|
|
56
|
+
return (sqrt(b * b + k * dot2(p)) - b) / k;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
vec4 transition (vec2 uv) {
|
|
60
|
+
vec4 a = getFromColor(uv);
|
|
61
|
+
vec4 b = getToColor(uv);
|
|
62
|
+
vec2 asp = vec2(ratio, 1.0);
|
|
63
|
+
vec2 c = center * asp;
|
|
64
|
+
float sm = max(smoothness, 0.0005);
|
|
65
|
+
|
|
66
|
+
// The keyhole grows around a point of its head, at the center. It covers the frame (grown by a
|
|
67
|
+
// margin, so the soft edge is past it) once its head, a disk, reaches the frame's corners.
|
|
68
|
+
vec2 o = c;
|
|
69
|
+
vec2 lo = -o - 2.5 * sm;
|
|
70
|
+
vec2 hi = asp - o + 2.5 * sm;
|
|
71
|
+
float full = max(max(reach(lo), reach(hi)), max(reach(vec2(lo.x, hi.y)), reach(vec2(hi.x, lo.y))));
|
|
72
|
+
|
|
73
|
+
// The keyhole grows linearly until it fills the frame
|
|
74
|
+
float p = progress;
|
|
75
|
+
float s = full * p;
|
|
76
|
+
if (s <= 0.0) return a;
|
|
77
|
+
|
|
78
|
+
vec2 q = (uv * asp - o) / s + vec2(0.0, GROW_Y);
|
|
79
|
+
float d = sdKeyhole(q);
|
|
80
|
+
// the soft edge is just inside the outline, so a tiny keyhole shows nothing
|
|
81
|
+
float hole = 1.0 - smoothstep(-sm, sm, d * s + sm);
|
|
82
|
+
|
|
83
|
+
float fade = smoothstep(0.0, 0.08, p) * (1.0 - smoothstep(0.7, 1.0, p));
|
|
84
|
+
float rimA = rim * fade;
|
|
85
|
+
if (rimA > 0.0) {
|
|
86
|
+
// Plate around the hole: a bevel lit from above going down into the hole, and a soft shadow
|
|
87
|
+
// on its rim
|
|
88
|
+
vec2 e = vec2(0.002, 0.0);
|
|
89
|
+
vec2 n = vec2(sdKeyhole(q + e) - sdKeyhole(q - e), sdKeyhole(q + e.yx) - sdKeyhole(q - e.yx));
|
|
90
|
+
float lit = -dot(n / max(length(n), 1e-6), vec2(-0.35, 0.94));
|
|
91
|
+
float bevel = 1.0 - smoothstep(0.0, BEVEL, d);
|
|
92
|
+
float shade = exp(-max(d, 0.0) / SHADE);
|
|
93
|
+
a.rgb *= 1.0 - rimA * (0.35 * shade + bevel * 0.4 * max(-lit, 0.0));
|
|
94
|
+
a.rgb += rimA * bevel * bevel * 0.3 * max(lit, 0.0) * a.a;
|
|
95
|
+
|
|
96
|
+
// Inside the hole: the plate's thickness shades the incoming image under the top of the rim,
|
|
97
|
+
// with a softer vignette all around the edge
|
|
98
|
+
float wall = smoothstep(-0.03, 0.03, sdKeyhole(q + vec2(0.0, 0.05)));
|
|
99
|
+
float vign = exp(min(d, 0.0) / SHADE);
|
|
100
|
+
b.rgb *= 1.0 - rimA * (0.5 * wall + 0.3 * vign);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return mix(a, b, hole);
|
|
104
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// LedWall — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/LedWall.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// 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
|
|
5
|
+
// Tags: dots, glow, grid, wave
|
|
6
|
+
|
|
7
|
+
// @range(6, 80) Number of diodes across the shorter side
|
|
8
|
+
uniform float cells; // = 24.0
|
|
9
|
+
// @range(0, 1) Strength of the glow bleeding from the diodes into the dark panel
|
|
10
|
+
uniform float glow; // = 0.6
|
|
11
|
+
// @range(0, 1) Brightness of the flash of each diode as it switches
|
|
12
|
+
uniform float flash; // = 0.7
|
|
13
|
+
// @range(0, 0.5) How much the picture zooms in while it is a screen
|
|
14
|
+
uniform float zoom; // = 0.15
|
|
15
|
+
// @param Each diode is made of red, green and blue sub-diodes
|
|
16
|
+
uniform bool triads; // = false
|
|
17
|
+
// @param Direction in which the refresh wave sweeps across the screen
|
|
18
|
+
uniform vec2 direction; // = vec2(1.0, 0.0)
|
|
19
|
+
// @color Color of the panel between the diodes
|
|
20
|
+
uniform vec4 panel; // = vec4(0.02, 0.02, 0.025, 1.0)
|
|
21
|
+
|
|
22
|
+
// radius of a lit diode, in cells
|
|
23
|
+
const float RADIUS = 0.36;
|
|
24
|
+
// width of the soft edge of the diodes, in cells
|
|
25
|
+
const float EDGE = 0.05;
|
|
26
|
+
|
|
27
|
+
float hash12(vec2 p) {
|
|
28
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
29
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
30
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// folds uv back into 0..1, so the frame stays filled
|
|
34
|
+
vec2 mirrored(vec2 v) {
|
|
35
|
+
vec2 m = mod(v, 2.0);
|
|
36
|
+
return mix(m, 2.0 - m, step(1.0, m));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 1 inside a disc of radius r, with a soft edge
|
|
40
|
+
float disc(float d, float r) {
|
|
41
|
+
return 1.0 - smoothstep(r - EDGE, r + EDGE, d);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
vec4 transition(vec2 uv) {
|
|
45
|
+
// how much the picture is a screen: it resolves into diodes until 0.3, and back from 0.7
|
|
46
|
+
float led = smoothstep(0.0, 0.3, progress) * (1.0 - smoothstep(0.7, 1.0, progress));
|
|
47
|
+
float z = 1.0 + max(zoom, 0.0) * smoothstep(0.0, 0.45, progress) * (1.0 - smoothstep(0.55, 1.0, progress));
|
|
48
|
+
vec2 p = 0.5 + (uv - 0.5) / z;
|
|
49
|
+
|
|
50
|
+
// the grid of diodes, in cells, with a diode at the center of the frame
|
|
51
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
52
|
+
vec2 toCells = aspect * max(cells, 1.0) / min(ratio, 1.0);
|
|
53
|
+
vec2 q = (p - 0.5) * toCells;
|
|
54
|
+
vec2 id = floor(q + 0.5);
|
|
55
|
+
vec2 local = q - id;
|
|
56
|
+
vec2 side = vec2(local.x < 0.0 ? -1.0 : 1.0, local.y < 0.0 ? -1.0 : 1.0);
|
|
57
|
+
|
|
58
|
+
// the refresh wave runs along dir, from 0 to 1 across the frame
|
|
59
|
+
vec2 dir = length(direction) > 1e-4 ? normalize(direction) : vec2(1.0, 0.0);
|
|
60
|
+
float extent = abs(dir.x) * ratio + abs(dir.y);
|
|
61
|
+
|
|
62
|
+
vec4 own = vec4(0.0);
|
|
63
|
+
float ownSwitch = 0.0;
|
|
64
|
+
vec4 halo = vec4(0.0);
|
|
65
|
+
float haloWeight = 0.0;
|
|
66
|
+
// this diode and the three nearest ones, whose glow reaches this point
|
|
67
|
+
for (int i = 0; i < 4; i++) {
|
|
68
|
+
// without glow, only this diode matters
|
|
69
|
+
if (i > 0 && glow * led <= 0.0) break;
|
|
70
|
+
vec2 o = vec2(mod(float(i), 2.0), floor(float(i) / 2.0)) * side;
|
|
71
|
+
vec2 c = id + o;
|
|
72
|
+
vec2 cuv = c / toCells + 0.5;
|
|
73
|
+
// where the diode is seen in the frame, so that the wave crosses the visible screen
|
|
74
|
+
float s = clamp(dot((cuv - 0.5) * z * aspect, dir) / extent + 0.5, 0.0, 1.0);
|
|
75
|
+
float when = 0.2 + 0.52 * s + 0.05 * (hash12(c + 71.0) - 0.5);
|
|
76
|
+
float sw = smoothstep(when - 0.012, when + 0.012, progress);
|
|
77
|
+
// the diode blinks off just before it switches, then pops bright
|
|
78
|
+
float x = (progress - when) / 0.018;
|
|
79
|
+
float pop = exp(-x * x) - 0.5 * exp(-(x + 1.6) * (x + 1.6));
|
|
80
|
+
vec2 suv = mirrored(cuv);
|
|
81
|
+
vec4 col = mix(getFromColor(suv), getToColor(suv), sw);
|
|
82
|
+
col.rgb = col.rgb * (1.0 + 1.4 * flash * pop) + 0.2 * flash * max(pop, 0.0);
|
|
83
|
+
if (i == 0) {
|
|
84
|
+
own = col;
|
|
85
|
+
ownSwitch = sw;
|
|
86
|
+
}
|
|
87
|
+
float d = length(local - o);
|
|
88
|
+
float w = 0.9 * glow * exp(-6.0 * max(d - RADIUS, 0.0)) * (1.0 + 0.8 * flash * max(pop, 0.0));
|
|
89
|
+
// the neighbors fade out where the next ones in the other direction take over, so the glow has no seam
|
|
90
|
+
if (o.x != 0.0) w *= smoothstep(0.0, 0.2, abs(local.x));
|
|
91
|
+
if (o.y != 0.0) w *= smoothstep(0.0, 0.2, abs(local.y));
|
|
92
|
+
halo += w * col;
|
|
93
|
+
haloWeight += w;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// the plain picture, switched along with its diode
|
|
97
|
+
vec4 plain = mix(getFromColor(p), getToColor(p), ownSwitch);
|
|
98
|
+
float d = length(local);
|
|
99
|
+
// the diodes cover their whole cell with the plain picture when led = 0: the dark panel
|
|
100
|
+
// shows up first between them, then they light up with the color of their center
|
|
101
|
+
float r = mix(0.8, RADIUS, smoothstep(0.0, 0.6, led));
|
|
102
|
+
vec4 gap = vec4(panel.rgb, panel.a * own.a);
|
|
103
|
+
if (haloWeight > 0.0) {
|
|
104
|
+
gap = mix(gap, halo / haloWeight, clamp(haloWeight * led, 0.0, 1.0));
|
|
105
|
+
}
|
|
106
|
+
vec4 body = own;
|
|
107
|
+
if (triads) {
|
|
108
|
+
// three sub-diodes on the panel, red at the top, green and blue below
|
|
109
|
+
vec3 sub = vec3(
|
|
110
|
+
disc(length(local - vec2(0.0, 0.15)), 0.2),
|
|
111
|
+
disc(length(local - vec2(-0.13, -0.075)), 0.2),
|
|
112
|
+
disc(length(local - vec2(0.13, -0.075)), 0.2));
|
|
113
|
+
float m = max(sub.r, max(sub.g, sub.b));
|
|
114
|
+
body = vec4(gap.rgb * (1.0 - m) + own.rgb * 1.5 * sub, mix(gap.a, own.a, m));
|
|
115
|
+
// the sub-diodes reach out to 0.4 cells
|
|
116
|
+
r = max(r, 0.45);
|
|
117
|
+
} else {
|
|
118
|
+
// brighter at the core of the diode
|
|
119
|
+
float k = clamp(d / RADIUS, 0.0, 1.0);
|
|
120
|
+
body.rgb *= 0.8 + 0.45 * (1.0 - k * k);
|
|
121
|
+
}
|
|
122
|
+
// the color of the center spreads from it over the diode
|
|
123
|
+
float lit = smoothstep(0.0, 0.8, led);
|
|
124
|
+
body = mix(plain, body, lit * mix(1.0, lit, smoothstep(0.0, 0.7, d)));
|
|
125
|
+
vec4 color = mix(gap, body, disc(d, r));
|
|
126
|
+
return clamp(color, 0.0, 1.0);
|
|
127
|
+
}
|