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
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// ComicPanels — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ComicPanels.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The frame splits into slanted comic-book panels with gutters and ink borders; one after another in reading order, each panel lifts off the page with a zoom kick and a drop shadow and punches over to the incoming image, then the gutters close up over the full incoming image
|
|
5
|
+
// Tags: comic, panels, grid, zoom
|
|
6
|
+
|
|
7
|
+
// @range(0, 0.1) Width of the gutters between the panels, as a part of the frame's height
|
|
8
|
+
uniform float gutter; // = 0.03
|
|
9
|
+
// @color Color of the gutters and of the page's margin
|
|
10
|
+
uniform vec4 gutterColor; // = vec4(1.0, 1.0, 1.0, 1.0)
|
|
11
|
+
// @color Color of the ink borders around the panels
|
|
12
|
+
uniform vec4 borderColor; // = vec4(0.0, 0.0, 0.0, 1.0)
|
|
13
|
+
// @range(0, 100, 1) Changes the layout of the panels
|
|
14
|
+
uniform float seed; // = 0.0
|
|
15
|
+
|
|
16
|
+
const float PI = 3.141592653589793;
|
|
17
|
+
// width of the ink borders, as a part of the frame's height
|
|
18
|
+
const float INK = 0.005;
|
|
19
|
+
// width of the anti-aliased edges, as a part of the frame's height
|
|
20
|
+
const float EDGE = 0.0012;
|
|
21
|
+
// part of the transition taken by each panel's punch
|
|
22
|
+
const float PUNCH = 0.3;
|
|
23
|
+
// the first panel's punch starts at START, the last one ends at END
|
|
24
|
+
const float START = 0.05;
|
|
25
|
+
const float END = 0.97;
|
|
26
|
+
// number of spikes of the burst that brings the incoming image into a panel
|
|
27
|
+
const float SPIKES = 11.0;
|
|
28
|
+
|
|
29
|
+
float hash(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);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// number of panels in row r (0 is the top row)
|
|
36
|
+
float cols(float r) {
|
|
37
|
+
float h = hash(vec2(r * 7.0 + 3.0, seed * 1.37 + 11.0));
|
|
38
|
+
float n = h < 0.15 ? 1.0 : (h < 0.6 ? 2.0 : 3.0);
|
|
39
|
+
// the middle row is never a single panel, a narrow frame takes at most 2 panels per row
|
|
40
|
+
if (r == 1.0) n = max(n, 2.0);
|
|
41
|
+
if (ratio < 0.8) n = min(n, 2.0);
|
|
42
|
+
return n;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// signed distance of p (x from 0 to ratio, y from 0 at the top to 1) below the gutter k between the rows
|
|
46
|
+
// (0 is the top of the frame, 3 its bottom)
|
|
47
|
+
float rowDist(float k, vec2 p) {
|
|
48
|
+
if (k < 0.5) return p.y;
|
|
49
|
+
if (k > 2.5) return p.y - 1.0;
|
|
50
|
+
float y = (k + (hash(vec2(k * 5.0 + 1.0, seed * 1.37)) - 0.5) * 0.35) / 3.0;
|
|
51
|
+
float s = (hash(vec2(k * 9.0 + 4.0, seed * 1.37 + 5.0)) - 0.5) * 0.24;
|
|
52
|
+
return (p.y - y - s * (p.x / ratio - 0.5)) / sqrt(1.0 + s * s / (ratio * ratio));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// signed distance of p right of the gutter j of row r, which has n panels (0 is the left of the frame, n its right)
|
|
56
|
+
float colDist(float r, float j, float n, vec2 p) {
|
|
57
|
+
if (j < 0.5) return p.x;
|
|
58
|
+
if (j > n - 0.5) return p.x - ratio;
|
|
59
|
+
float x = (j + (hash(vec2(r * 3.0 + j * 13.0, seed * 1.37 + 2.0)) - 0.5) * 0.45) / n;
|
|
60
|
+
float s = (hash(vec2(r * 11.0 + j * 5.0, seed * 1.37 + 7.0)) - 0.5) * 0.5;
|
|
61
|
+
return (p.x - ratio * (x + s * (p.y - 0.5))) / sqrt(1.0 + ratio * ratio * s * s);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// signed distance to the edges of panel c of row r, positive inside
|
|
65
|
+
float panelDist(float r, float c, float n, vec2 p) {
|
|
66
|
+
return min(min(rowDist(r, p), -rowDist(r + 1.0, p)), min(colDist(r, c, n, p), -colDist(r, c + 1.0, n, p)));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// a point inside panel c of row r, as far from its top as from its bottom and from its left as from its right
|
|
70
|
+
vec2 panelCenter(float r, float c, float n) {
|
|
71
|
+
// the sums of the distances to the opposite edges are linear: find where they are 0
|
|
72
|
+
float y0 = rowDist(r, vec2(0.5 * ratio, 0.0)) + rowDist(r + 1.0, vec2(0.5 * ratio, 0.0));
|
|
73
|
+
float y1 = rowDist(r, vec2(0.5 * ratio, 1.0)) + rowDist(r + 1.0, vec2(0.5 * ratio, 1.0));
|
|
74
|
+
float y = y0 / (y0 - y1);
|
|
75
|
+
float x0 = colDist(r, c, n, vec2(0.0, y)) + colDist(r, c + 1.0, n, vec2(0.0, y));
|
|
76
|
+
float x1 = colDist(r, c, n, vec2(1.0, y)) + colDist(r, c + 1.0, n, vec2(1.0, y));
|
|
77
|
+
return vec2(x0 / (x0 - x1), y);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// the panel's punch, 0 to 1: panel k of the n panels of the page, in reading order
|
|
81
|
+
float panelTime(float k, float total) {
|
|
82
|
+
float t0 = START + (END - START - PUNCH) * k / max(total - 1.0, 1.0);
|
|
83
|
+
return clamp((progress - t0) / PUNCH, 0.0, 1.0);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// how high the panel is lifted off the page: a quick rise, a slower settle
|
|
87
|
+
float lift(float t) {
|
|
88
|
+
float u = 1.0 - (1.0 - t) * (1.0 - t);
|
|
89
|
+
return sin(PI * u);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// the panel's image at the page point p: the outgoing one until the incoming one bursts out of the panel's center
|
|
93
|
+
// in a jagged star with an ink outline
|
|
94
|
+
vec4 panelImage(vec2 p, vec2 center, float t) {
|
|
95
|
+
float k = lift(t);
|
|
96
|
+
// the image zooms in with the kick, then settles
|
|
97
|
+
vec2 q = center + (p - center) / (1.0 + 0.1 * k);
|
|
98
|
+
vec2 uv = vec2(q.x / ratio, 1.0 - q.y);
|
|
99
|
+
if (t <= 0.0) return getFromColor(uv);
|
|
100
|
+
if (t >= 1.0) return getToColor(uv);
|
|
101
|
+
vec2 v = p - center;
|
|
102
|
+
float a = (atan(v.y, v.x + 1e-6) + PI) / (2.0 * PI) * SPIKES + center.x * 7.0;
|
|
103
|
+
float i = floor(a);
|
|
104
|
+
// the spikes, of uneven lengths
|
|
105
|
+
// (the spike index wraps around so that the star has no seam where the angle wraps)
|
|
106
|
+
float spike = (1.0 - abs(2.0 * (a - i) - 1.0)) * (0.5 + 0.5 * hash(vec2(mod(i, SPIKES), center.y * 13.0 + seed)));
|
|
107
|
+
// large enough to cover the widest panel, a whole row of a wide frame
|
|
108
|
+
float burst = 1.5 * max(1.0, ratio / 1.8) * smoothstep(0.06, 0.42, t);
|
|
109
|
+
float d = length(v) - burst * (0.62 + 0.38 * spike);
|
|
110
|
+
float w = 1.4 * INK;
|
|
111
|
+
vec4 c = mix(getToColor(uv), borderColor, smoothstep(-w - EDGE, -w + EDGE, d));
|
|
112
|
+
return mix(c, getFromColor(uv), smoothstep(-EDGE, EDGE, d));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// the panel drawn over color: its gutter edge at g from its edges, its ink border inside it
|
|
116
|
+
vec4 drawPanel(vec4 color, vec4 img, float d, float g, float ink, float fade) {
|
|
117
|
+
vec4 c = mix(borderColor, img, mix(1.0, smoothstep(g + ink - EDGE, g + ink + EDGE, d), fade));
|
|
118
|
+
return mix(color, c, mix(1.0, smoothstep(g - EDGE, g + EDGE, d), fade));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
vec4 transition(vec2 uv) {
|
|
122
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
123
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
124
|
+
vec2 p = vec2(uv.x * ratio, 1.0 - uv.y);
|
|
125
|
+
|
|
126
|
+
// the gutters open at the start and close over the incoming image at the end
|
|
127
|
+
float open = smoothstep(0.0, 0.14, progress) * (1.0 - smoothstep(0.8, 1.0, progress));
|
|
128
|
+
float g = 0.5 * gutter * open;
|
|
129
|
+
float ink = INK * open;
|
|
130
|
+
// the edges come in gently instead of popping in at half coverage
|
|
131
|
+
float fade = clamp(open * 6.0, 0.0, 1.0);
|
|
132
|
+
|
|
133
|
+
float n0 = cols(0.0);
|
|
134
|
+
float n1 = cols(1.0);
|
|
135
|
+
float n2 = cols(2.0);
|
|
136
|
+
float total = n0 + n1 + n2;
|
|
137
|
+
|
|
138
|
+
// the panel under the point, on the page
|
|
139
|
+
float r = rowDist(1.0, p) < 0.0 ? 0.0 : (rowDist(2.0, p) < 0.0 ? 1.0 : 2.0);
|
|
140
|
+
float n = r == 0.0 ? n0 : (r == 1.0 ? n1 : n2);
|
|
141
|
+
float c = colDist(r, 1.0, n, p) < 0.0 ? 0.0 : (colDist(r, 2.0, n, p) < 0.0 || n < 2.5 ? 1.0 : 2.0);
|
|
142
|
+
c = min(c, n - 1.0);
|
|
143
|
+
float first = r == 0.0 ? 0.0 : (r == 1.0 ? n0 : n0 + n1);
|
|
144
|
+
float t = panelTime(first + c, total);
|
|
145
|
+
|
|
146
|
+
vec4 color = gutterColor;
|
|
147
|
+
if (t <= 0.0 || t >= 1.0) {
|
|
148
|
+
color = drawPanel(color, panelImage(p, panelCenter(r, c, n), t), panelDist(r, c, n, p), g, ink, fade);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// the panels lifted off the page, the later ones on top: at most 4 of them punch at once
|
|
152
|
+
float spacing = (END - START - PUNCH) / max(total - 1.0, 1.0);
|
|
153
|
+
// (with a margin, so that a panel at the very end of its punch is not missed to rounding)
|
|
154
|
+
float kFirst = floor((progress - START - PUNCH) / spacing - 0.01) + 1.0;
|
|
155
|
+
for (int i = 0; i < 4; i++) {
|
|
156
|
+
float pk = kFirst + float(i);
|
|
157
|
+
if (pk < 0.0 || pk > total - 0.5) continue;
|
|
158
|
+
float pt = panelTime(pk, total);
|
|
159
|
+
if (pt <= 0.0 || pt >= 1.0) continue;
|
|
160
|
+
float pr = pk < n0 ? 0.0 : (pk < n0 + n1 ? 1.0 : 2.0);
|
|
161
|
+
float pn = pr == 0.0 ? n0 : (pr == 1.0 ? n1 : n2);
|
|
162
|
+
float pc = pk - (pr == 0.0 ? 0.0 : (pr == 1.0 ? n0 : n0 + n1));
|
|
163
|
+
float k = lift(pt);
|
|
164
|
+
vec2 center = panelCenter(pr, pc, pn);
|
|
165
|
+
float s = 1.0 + 0.08 * k;
|
|
166
|
+
// its soft shadow on the page, down and to the right
|
|
167
|
+
vec2 sq = center + (p - vec2(0.012, 0.018) * k - center) / s;
|
|
168
|
+
float sd = panelDist(pr, pc, pn, sq) - g;
|
|
169
|
+
color.rgb *= 1.0 - 0.4 * k * fade * smoothstep(-0.02, 0.01, sd);
|
|
170
|
+
vec2 q = center + (p - center) / s;
|
|
171
|
+
color = drawPanel(color, panelImage(q, center, pt), panelDist(pr, pc, pn, q), g, ink, 1.0);
|
|
172
|
+
}
|
|
173
|
+
return color;
|
|
174
|
+
}
|
package/glsl3/Cube.glsl
CHANGED
|
@@ -1,71 +1,124 @@
|
|
|
1
1
|
// Cube — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Cube.glsl
|
|
2
2
|
// Author: gre
|
|
3
3
|
// License: MIT
|
|
4
|
-
// Description: The two images are faces of a
|
|
4
|
+
// Description: The two images are faces of a box that turns a quarter turn in perspective, the outgoing face darkening as it turns away, above a reflective floor
|
|
5
5
|
// Tags: 3d, cube, rotate, reflection
|
|
6
6
|
// @range(0, 1) Amount of perspective
|
|
7
7
|
uniform float persp; // = 0.7
|
|
8
|
+
// @range(0, 1) How far the camera pulls back mid-turn, as a part of the frame
|
|
8
9
|
uniform float unzoom; // = 0.3
|
|
9
10
|
// @range(0, 1) Strength of the reflection
|
|
10
11
|
uniform float reflection; // = 0.4
|
|
12
|
+
// @range(0, 20) Gap between the box and its reflection, as a percentage of the frame height
|
|
11
13
|
uniform float floating; // = 3.0
|
|
14
|
+
// @range(0, 1) How much the faces darken as they turn away, and the shadow on the floor
|
|
15
|
+
uniform float shading; // = 0.5
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
bool inBounds (vec2 p) {
|
|
18
|
-
return all(lessThan(vec2(0.0), p)) && all(lessThan(p, vec2(1.0)));
|
|
19
|
-
}
|
|
17
|
+
const float PI = 3.141592653589793;
|
|
18
|
+
// width of the anti-aliased edges, as a part of the frame's height at the box's front
|
|
19
|
+
const float EDGE = 0.002;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
// the ray (eye, dir) in the box's frame, the box turned by (c, s) around its vertical axis:
|
|
22
|
+
// returns (distance along the ray, horizontal position on the face, height, face) with face 0 for
|
|
23
|
+
// the outgoing image's face, 1 for the incoming one's, and a negative distance where it misses
|
|
24
|
+
vec4 hitBox(vec3 eye, vec3 dir, float w, float c, float s) {
|
|
25
|
+
vec2 pivot = vec2(0.5 * w);
|
|
26
|
+
vec2 e = eye.xz - pivot;
|
|
27
|
+
vec2 o = vec2(e.x * c + e.y * s, -e.x * s + e.y * c) + pivot;
|
|
28
|
+
vec2 d = vec2(dir.x * c + dir.z * s, -dir.x * s + dir.z * c);
|
|
29
|
+
// the side faces seen from outside: the box spans [0, w] on x and z
|
|
30
|
+
vec2 inv = 1.0 / vec2(d.x < 0.0 ? min(d.x, -1e-6) : max(d.x, 1e-6), d.y < 0.0 ? min(d.y, -1e-6) : max(d.y, 1e-6));
|
|
31
|
+
vec2 t0 = (vec2(0.0) - o) * inv;
|
|
32
|
+
vec2 t1 = (vec2(w) - o) * inv;
|
|
33
|
+
vec2 tn = min(t0, t1);
|
|
34
|
+
vec2 tf = max(t0, t1);
|
|
35
|
+
float tin = max(tn.x, tn.y);
|
|
36
|
+
if (tin <= 0.0 || tin > min(tf.x, tf.y)) return vec4(-1.0);
|
|
37
|
+
vec2 hit = o + tin * d;
|
|
38
|
+
float y = eye.y + tin * dir.y;
|
|
39
|
+
if (y < 0.0 || y > 1.0) return vec4(-1.0);
|
|
40
|
+
// the face first entered: z = 0 is the outgoing face, x = 0 the incoming one, the others are hidden
|
|
41
|
+
if (tn.y >= tn.x) {
|
|
42
|
+
if (d.y <= 0.0) return vec4(-1.0);
|
|
43
|
+
return vec4(tin, hit.x / w, y, 0.0);
|
|
27
44
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
c += mix(vec4(0.0), getToColor(pto), reflection * mix(1.0, 0.0, pto.y));
|
|
31
|
-
}
|
|
32
|
-
return c;
|
|
45
|
+
if (d.x <= 0.0) return vec4(-1.0);
|
|
46
|
+
return vec4(tin, 1.0 - hit.y / w, y, 1.0);
|
|
33
47
|
}
|
|
34
48
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
float
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* vec2(0.5 / distance(center, 0.5) * (center<0.5 ? 1.0 : -1.0), 1.0)
|
|
46
|
-
+ vec2(center<0.5 ? 0.0 : 1.0, 0.0)
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
+
vec4 transition(vec2 uv) {
|
|
50
|
+
float w = ratio;
|
|
51
|
+
// the turn starts and ends softly
|
|
52
|
+
float turn = progress * progress * (3.0 - 2.0 * progress);
|
|
53
|
+
float a = 0.5 * PI * turn;
|
|
54
|
+
float c = cos(a), s = sin(a);
|
|
55
|
+
if (progress >= 1.0) { c = 0.0; s = 1.0; }
|
|
56
|
+
// 0 at both ends, for exact images and hard edges there
|
|
57
|
+
float motion = sin(PI * clamp(progress, 0.0, 1.0));
|
|
58
|
+
float zoom = 1.0 + max(unzoom, 0.0) * motion;
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
float
|
|
52
|
-
|
|
53
|
-
vec2
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
|
|
60
|
+
// the front of the box is the screen: the camera keeps it framed, pulling back mid-turn
|
|
61
|
+
float dist = 0.8 * max(w, 1.0) / clamp(persp, 0.01, 1.0);
|
|
62
|
+
vec3 eye = vec3(0.5 * w, 0.5, -dist);
|
|
63
|
+
vec2 sp = (uv - 0.5) * zoom + 0.5;
|
|
64
|
+
vec3 dir = vec3(sp.x * w, sp.y, 0.0) - eye;
|
|
65
|
+
|
|
66
|
+
// pixel footprint on the screen plane, for the anti-aliased edges
|
|
67
|
+
float px = EDGE * zoom * min(10.0 * motion, 1.0);
|
|
68
|
+
float shade0 = 1.0 - shading * (1.0 - c);
|
|
69
|
+
float shade1 = 1.0 - shading * (1.0 - s);
|
|
70
|
+
|
|
71
|
+
// the box in front, premultiplied
|
|
72
|
+
vec4 front = vec4(0.0);
|
|
73
|
+
vec4 b = hitBox(eye, dir, w, c, s);
|
|
74
|
+
if (b.x > 0.0) {
|
|
75
|
+
vec4 img = b.w < 0.5 ? getFromColor(vec2(b.y, b.z)) : getToColor(vec2(b.y, b.z));
|
|
76
|
+
float m = 1.0;
|
|
77
|
+
if (px > 0.0) {
|
|
78
|
+
// the silhouette: top, bottom and the outer vertical edge of the face, seen foreshortened
|
|
79
|
+
float e = px * b.x;
|
|
80
|
+
vec3 n = b.w < 0.5 ? vec3(s, 0.0, -c) : vec3(-c, 0.0, -s);
|
|
81
|
+
float fore = max(abs(dot(n, normalize(dir))), 0.05);
|
|
82
|
+
float edge = b.w < 0.5 ? 1.0 - b.y : b.y;
|
|
83
|
+
m = clamp(min(b.z, 1.0 - b.z) / e, 0.0, 1.0)
|
|
84
|
+
* clamp(edge * w * fore / e, 0.0, 1.0);
|
|
85
|
+
}
|
|
86
|
+
// where the box covers the pixel, nothing behind it shows: the exact image at both ends
|
|
87
|
+
if (m >= 1.0 && img.a >= 1.0) {
|
|
88
|
+
return vec4(img.rgb * (b.w < 0.5 ? shade0 : shade1), img.a);
|
|
89
|
+
}
|
|
90
|
+
front = vec4(img.rgb * (b.w < 0.5 ? shade0 : shade1) * img.a, img.a) * m;
|
|
66
91
|
}
|
|
67
|
-
|
|
68
|
-
|
|
92
|
+
|
|
93
|
+
// the floor, h below the box, premultiplied; it fades in and out with the motion
|
|
94
|
+
vec4 ground = vec4(0.0);
|
|
95
|
+
float h = 0.005 * max(floating, 0.0);
|
|
96
|
+
if (dir.y < 0.0 && motion > 0.0) {
|
|
97
|
+
float tf = -(eye.y + h) / dir.y;
|
|
98
|
+
vec3 f = eye + tf * dir;
|
|
99
|
+
// the reflection: the same ray mirrored by the floor, fading with the height on the box
|
|
100
|
+
vec3 meye = vec3(eye.x, -2.0 * h - eye.y, eye.z);
|
|
101
|
+
vec3 mdir = vec3(dir.x, -dir.y, dir.z);
|
|
102
|
+
vec4 r = hitBox(meye, mdir, w, c, s);
|
|
103
|
+
if (r.x > 0.0) {
|
|
104
|
+
vec4 img = r.w < 0.5 ? getFromColor(vec2(r.y, r.z)) : getToColor(vec2(r.y, r.z));
|
|
105
|
+
float k = clamp(reflection, 0.0, 1.0) * (1.0 - r.z) * (1.0 - r.z);
|
|
106
|
+
ground = vec4(img.rgb * (r.w < 0.5 ? shade0 : shade1) * img.a, img.a) * k;
|
|
107
|
+
}
|
|
108
|
+
// the contact shadow around the box, softer as it floats higher
|
|
109
|
+
vec2 q = f.xz - vec2(0.5 * w);
|
|
110
|
+
vec2 l = vec2(q.x * c + q.y * s, -q.x * s + q.y * c);
|
|
111
|
+
float soft = 0.03 + 1.5 * h;
|
|
112
|
+
float sh = shading * 0.7 * exp(-length(max(abs(l) - vec2(0.5 * w), 0.0)) / soft);
|
|
113
|
+
// only as opaque as the bottom of the nearest face
|
|
114
|
+
vec2 bl = l + vec2(0.5 * w);
|
|
115
|
+
sh *= l.y < l.x
|
|
116
|
+
? getFromColor(vec2(clamp(bl.x / w, 0.0, 1.0), 0.0)).a
|
|
117
|
+
: getToColor(vec2(clamp(1.0 - bl.y / w, 0.0, 1.0), 0.0)).a;
|
|
118
|
+
ground = ground * (1.0 - sh) + vec4(0.0, 0.0, 0.0, sh);
|
|
119
|
+
ground *= min(6.0 * motion, 1.0);
|
|
69
120
|
}
|
|
70
|
-
|
|
121
|
+
|
|
122
|
+
vec4 color = front + ground * (1.0 - front.a);
|
|
123
|
+
return color.a > 0.0 ? vec4(color.rgb / color.a, color.a) : vec4(0.0);
|
|
71
124
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// CurtainRise — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CurtainRise.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image rises like a theater festoon curtain: cords lift its hem into scalloped swags while the fabric gathers into shaded ruffles, and it is drawn up out of the frame over the incoming image
|
|
5
|
+
// Tags: 3d, fold, vertical
|
|
6
|
+
|
|
7
|
+
// @range(1, 8, 1) Number of swags across a 16:9 frame (fewer in a portrait image)
|
|
8
|
+
uniform float swags; // = 3.0
|
|
9
|
+
// @range(0, 0.3) How low each swag droops between two cords, as a part of the frame's height
|
|
10
|
+
uniform float sag; // = 0.14
|
|
11
|
+
// @range(4, 30, 1) Number of gathered ruffles in the fabric
|
|
12
|
+
uniform float ruffles; // = 14.0
|
|
13
|
+
// @range(0, 1) Depth of the shading on the ruffles and swags, and of the shadow under the hem
|
|
14
|
+
uniform float shading; // = 0.7
|
|
15
|
+
|
|
16
|
+
const float PI = 3.141592653589793;
|
|
17
|
+
|
|
18
|
+
vec4 transition (vec2 uv) {
|
|
19
|
+
float p = progress;
|
|
20
|
+
// the fabric gathers early, then the cords pull it up
|
|
21
|
+
float f = 1.0 - (1.0 - p) * (1.0 - p) * (1.0 - p);
|
|
22
|
+
// the cords start pulling at once and are fastest midway
|
|
23
|
+
float e = mix(p, p * p * (3.0 - 2.0 * p), 0.4);
|
|
24
|
+
float s = sag * f;
|
|
25
|
+
float lift = mix(-0.01, 1.0 + sag + 0.08, e);
|
|
26
|
+
// across a swag, -1 and 1 at the cords
|
|
27
|
+
float n = max(1.0, floor(swags * sqrt(ratio / 1.78) + 0.5)); // fewer swags in portrait
|
|
28
|
+
float u = fract(uv.x * n) * 2.0 - 1.0;
|
|
29
|
+
float bump = 1.0 - u * u;
|
|
30
|
+
float hem = lift - s * bump;
|
|
31
|
+
float aa = 0.002 + 0.004 * f;
|
|
32
|
+
float inside = smoothstep(hem - aa, hem + aa, uv.y);
|
|
33
|
+
|
|
34
|
+
vec4 c = vec4(0.0);
|
|
35
|
+
if (inside > 0.0) {
|
|
36
|
+
// q goes from 0 at the top rod to 1 at the hem; the whole height of fabric is gathered into it
|
|
37
|
+
float h = max(1.0 - max(hem, 0.0), 1e-4);
|
|
38
|
+
float q = clamp((1.0 - uv.y) / h, 0.0, 1.0);
|
|
39
|
+
// ruffles: the fabric bunches where cos(a) > 0, rows parallel to the scalloped hem
|
|
40
|
+
// as the curtain shortens, its ruffles merge so none gets thinner than 2% of the frame
|
|
41
|
+
float m = min(max(1.0, floor(ruffles + 0.5)), h / 0.02);
|
|
42
|
+
float a = 2.0 * PI * m * q;
|
|
43
|
+
// the ruffles puff out most in the middle of each swag
|
|
44
|
+
float g = 0.85 * f * min(1.0, 0.3 + 5.0 * (1.0 - h)) * (0.6 + 0.4 * bump);
|
|
45
|
+
float v = clamp(q + g * sin(a) / (2.0 * PI * m), 0.0, 1.0);
|
|
46
|
+
// the fabric is also pulled in toward the cords near the hem
|
|
47
|
+
float pull = 0.25 * f * q * q * sin(PI * u) / (PI * n);
|
|
48
|
+
c = getFromColor(vec2(uv.x - pull, 1.0 - v));
|
|
49
|
+
|
|
50
|
+
// light from the front and a bit above
|
|
51
|
+
float slope = 2.5 * g * cos(a);
|
|
52
|
+
float diffuse = (1.0 - 0.35 * slope) / sqrt(1.0 + slope * slope);
|
|
53
|
+
float crease = 0.5 + 0.5 * sin(a);
|
|
54
|
+
float light = mix(1.0, diffuse * (1.0 - 0.45 * crease * crease), shading * g);
|
|
55
|
+
// a soft sheen on the crest of each ruffle
|
|
56
|
+
light += 0.18 * shading * g * smoothstep(0.4, 1.0, -cos(a));
|
|
57
|
+
// each swag bulges toward the light in its middle and is pinched dark along the cords
|
|
58
|
+
float depth = f * q * (0.3 + 0.7 * q);
|
|
59
|
+
light *= 1.0 - shading * depth * (0.35 * u * u + 0.5 * exp(-(1.0 - abs(u)) * 14.0));
|
|
60
|
+
// the hem rolls under a little
|
|
61
|
+
light *= 1.0 - 0.35 * shading * f * exp(-(uv.y - hem) * 120.0);
|
|
62
|
+
c.rgb *= light;
|
|
63
|
+
if (inside >= 1.0) return c;
|
|
64
|
+
}
|
|
65
|
+
vec4 to = getToColor(uv);
|
|
66
|
+
// soft shadow of the curtain just under its hem
|
|
67
|
+
float below = max(hem - uv.y, 0.0);
|
|
68
|
+
float shadow = 0.6 * shading * exp(-below * 22.0) * smoothstep(0.0, 0.05, lift) * (1.0 - smoothstep(1.0, 1.06, lift - s));
|
|
69
|
+
to.rgb *= 1.0 - shadow;
|
|
70
|
+
return mix(to, c, inside);
|
|
71
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// DominoFall — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/DominoFall.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image is cut into standing slats that topple backward like dominoes in a chain reaction across the frame, each one leaning onto the next and knocking it over, until they all lie flat and reveal the incoming image
|
|
5
|
+
// Tags: 3d, stripes, rotate
|
|
6
|
+
|
|
7
|
+
// @range(2, 40, 1) Number of slats
|
|
8
|
+
uniform int count; // = 12
|
|
9
|
+
// @param The chain runs from right to left instead of left to right
|
|
10
|
+
uniform bool reverse; // = false
|
|
11
|
+
// @range(0.05, 1) Part of a slat's fall after which it knocks the next one: lower runs the chain faster, with more slats falling at once
|
|
12
|
+
uniform float knock; // = 0.2
|
|
13
|
+
// @range(0, 1) How far each slat's top leans sideways onto the next one, as a part of a slat's width
|
|
14
|
+
uniform float lean; // = 0.8
|
|
15
|
+
// @range(0, 1) Strength of the perspective
|
|
16
|
+
uniform float perspective; // = 0.8
|
|
17
|
+
// @range(0, 1) How much the slats darken as they fall, and the shadows they cast
|
|
18
|
+
uniform float shading; // = 0.6
|
|
19
|
+
|
|
20
|
+
const float PI = 3.141592653589793;
|
|
21
|
+
// width of the anti-aliased edges, as a part of the frame's height
|
|
22
|
+
const float EDGE = 0.0015;
|
|
23
|
+
|
|
24
|
+
float knockPart() {
|
|
25
|
+
return clamp(knock, 0.05, 1.0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// the fall of slat j, 0 standing to 1 lying flat
|
|
29
|
+
float fallTime(float j, float n) {
|
|
30
|
+
if (progress >= 1.0) return 1.0;
|
|
31
|
+
float k = knockPart();
|
|
32
|
+
// each slat falls during d and knocks the next one after k * d
|
|
33
|
+
float d = 1.0 / (1.0 + (n - 1.0) * k);
|
|
34
|
+
return clamp((progress - j * k * d) / d, 0.0, 1.0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// the slat's angle: it starts with the push of the previous one, then gravity takes over
|
|
38
|
+
float fallAngle(float t) {
|
|
39
|
+
return 0.5 * PI * t * (0.2 + 0.8 * t);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// where slat j is seen at the point (xc, y) of the frame: (x across the slat, height on it, its fall, its angle),
|
|
43
|
+
// with a negative fall where it is not seen (its height can exceed 1, above its top)
|
|
44
|
+
vec4 slatPoint(float j, float n, float w, float xc, float y) {
|
|
45
|
+
vec4 none = vec4(0.0, 0.0, -1.0, 0.0);
|
|
46
|
+
if (j < 0.0 || j > n - 1.0) return none;
|
|
47
|
+
float t = fallTime(j, n);
|
|
48
|
+
if (t >= 1.0) return none;
|
|
49
|
+
float a = fallAngle(t);
|
|
50
|
+
float c = cos(a), s = sin(a);
|
|
51
|
+
// a camera in front of the slat goes down to the level of the hinge as the slat falls,
|
|
52
|
+
// so that the slat ends edge-on
|
|
53
|
+
vec3 eye = vec3((j + 0.5) * w, 0.5 * c, -1.0 / max(perspective, 0.01));
|
|
54
|
+
vec3 dir = vec3(xc, y, 0.0) - eye;
|
|
55
|
+
// cast a ray onto the slat turned back by a around its bottom edge
|
|
56
|
+
float den = dir.z * c - dir.y * s;
|
|
57
|
+
if (den <= 0.0) return none;
|
|
58
|
+
float r = (eye.y * s - eye.z * c) / den;
|
|
59
|
+
vec3 hit = eye + r * dir;
|
|
60
|
+
float h = hit.y * c + hit.z * s;
|
|
61
|
+
if (r <= 0.0 || h < 0.0) return none;
|
|
62
|
+
// the top leans sideways toward the next slat until it touches it
|
|
63
|
+
float side = clamp(lean, 0.0, 1.0) * w * min(t / knockPart(), 1.0) * h;
|
|
64
|
+
return vec4(hit.x - side - j * w, h, t, a);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// draws slat j, seen at pt, over color; front is where the next slat, which may stand in front of it, is seen
|
|
68
|
+
vec4 drawSlat(vec4 color, float j, vec4 pt, vec4 front, float w) {
|
|
69
|
+
float t = pt.z;
|
|
70
|
+
if (t < 0.0) return color;
|
|
71
|
+
float s = sin(pt.w);
|
|
72
|
+
float d = min(pt.x, w - pt.x);
|
|
73
|
+
float m;
|
|
74
|
+
if (t <= 0.0) {
|
|
75
|
+
// standing still: the slats tile the frame exactly
|
|
76
|
+
m = d >= 0.0 && pt.y <= 1.0 ? 1.0 : 0.0;
|
|
77
|
+
} else {
|
|
78
|
+
// anti-aliased edges, widened as the slat is seen narrower and shorter
|
|
79
|
+
float e = EDGE * min(10.0 * t, 1.0) * (1.0 + max(perspective, 0.0) * pt.y * s);
|
|
80
|
+
m = clamp(d / e + 0.5, 0.0, 1.0) * clamp((1.0 - pt.y) * max(cos(pt.w), 0.05) / e + 0.5, 0.0, 1.0);
|
|
81
|
+
}
|
|
82
|
+
if (m <= 0.0) return color;
|
|
83
|
+
float sx = (j * w + clamp(pt.x, 0.0, w)) / ratio;
|
|
84
|
+
vec4 img = getFromColor(vec2(reverse ? 1.0 - sx : sx, min(pt.y, 1.0)));
|
|
85
|
+
// darker as it falls away, more toward its top
|
|
86
|
+
float shade = 1.0 - shading * s * (0.4 + 0.6 * pt.y);
|
|
87
|
+
// the next slat, less fallen and so in front, shades the one leaning onto it along its edge, up to its top
|
|
88
|
+
if (front.z >= 0.0 && front.z < t && front.x < 0.0) {
|
|
89
|
+
float reach = clamp(1.0 - (front.y - 1.0) / 0.05, 0.0, 1.0);
|
|
90
|
+
shade *= 1.0 - 0.6 * shading * exp(front.x / (0.15 * w)) * reach;
|
|
91
|
+
}
|
|
92
|
+
img.rgb *= shade;
|
|
93
|
+
return mix(color, img, m);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
vec4 transition (vec2 uv) {
|
|
97
|
+
float n = float(count < 1 ? 1 : count);
|
|
98
|
+
float w = ratio / n;
|
|
99
|
+
// x along the chain, in frame heights
|
|
100
|
+
float xc = (reverse ? 1.0 - uv.x : uv.x) * ratio;
|
|
101
|
+
float col = clamp(floor(xc / w), 0.0, n - 1.0);
|
|
102
|
+
|
|
103
|
+
vec4 color = getToColor(uv);
|
|
104
|
+
// the contact shadow of the falling slat on the floor
|
|
105
|
+
float t0 = fallTime(col, n);
|
|
106
|
+
color.rgb *= 1.0 - 2.4 * shading * t0 * (1.0 - t0) * exp(-40.0 * uv.y);
|
|
107
|
+
|
|
108
|
+
// the slats are seen narrower as they fall, and their tops lean over the next column at most:
|
|
109
|
+
// the slat before this column, behind, then the one of this column
|
|
110
|
+
vec4 cur = slatPoint(col, n, w, xc, uv.y);
|
|
111
|
+
color = drawSlat(color, col - 1.0, slatPoint(col - 1.0, n, w, xc, uv.y), cur, w);
|
|
112
|
+
color = drawSlat(color, col, cur, slatPoint(col + 1.0, n, w, xc, uv.y), w);
|
|
113
|
+
return color;
|
|
114
|
+
}
|