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
package/glsl3/Doorway.glsl
CHANGED
|
@@ -1,55 +1,91 @@
|
|
|
1
1
|
// Doorway — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Doorway.glsl
|
|
2
2
|
// Author: gre
|
|
3
3
|
// License: MIT
|
|
4
|
-
// Description: The outgoing image opens like double doors as the incoming one comes forward, with a floor reflection
|
|
4
|
+
// Description: The outgoing image opens like double doors swinging toward the viewer, as the incoming one comes forward from the dark room behind, with a floor reflection
|
|
5
5
|
// Tags: doors, 3d, reflection
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
// @range(0, 1) Strength of the floor reflection under the incoming image
|
|
7
8
|
uniform float reflection; // = 0.4
|
|
8
|
-
// @
|
|
9
|
+
// @range(0, 1) Amount of perspective on the swinging doors
|
|
9
10
|
uniform float perspective; // = 0.4
|
|
11
|
+
// @range(1, 10) How far back the incoming image starts (1: no distance)
|
|
10
12
|
uniform float depth; // = 3
|
|
11
13
|
|
|
12
|
-
const
|
|
13
|
-
const vec2 boundMin = vec2(0.0, 0.0);
|
|
14
|
-
const vec2 boundMax = vec2(1.0, 1.0);
|
|
14
|
+
const float PI = 3.141592653589793;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// cast the view ray of screen point x (aspect units, the frame is 0..w) onto a leaf of
|
|
17
|
+
// width w/2 hinged on the left edge and turned toward the viewer by angle a.
|
|
18
|
+
// The eye is at (w/2, 0.5, -eye) and the frame at z = 0; returns (t, distance along the leaf)
|
|
19
|
+
// where t scales the ray so that t = 1 is the frame plane
|
|
20
|
+
vec2 leafHit (float x, float w, float eye, float a) {
|
|
21
|
+
float c = cos(a), s = sin(a);
|
|
22
|
+
float t = (eye * c - 0.5 * w * s) / (s * (x - 0.5 * w) + eye * c);
|
|
23
|
+
vec2 hit = vec2(0.5 * w + t * (x - 0.5 * w), eye * (t - 1.0));
|
|
24
|
+
return vec2(t, hit.x * c - hit.y * s);
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
// screen x of a point (x, z) seen from the eye
|
|
28
|
+
float project (vec2 p, float w, float eye) {
|
|
29
|
+
return 0.5 * w + (p.x - 0.5 * w) * eye / (eye + p.y);
|
|
22
30
|
}
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
pto = project(pto);
|
|
27
|
-
if (inBounds(pto)) {
|
|
28
|
-
c += mix(black, getToColor(pto), reflection * mix(1.0, 0.0, pto.y));
|
|
29
|
-
}
|
|
30
|
-
return c;
|
|
32
|
+
float easeInOut (float t) {
|
|
33
|
+
return t < 0.5 ? 4.0 * t * t * t : 1.0 - 4.0 * (1.0 - t) * (1.0 - t) * (1.0 - t);
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
vec4
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
pto = (p + vec2(-0.5, -0.5)) * vec2(size, size) + vec2(0.5, 0.5);
|
|
46
|
-
if (inBounds(pfr)) {
|
|
47
|
-
return getFromColor(pfr);
|
|
48
|
-
}
|
|
49
|
-
else if (inBounds(pto)) {
|
|
50
|
-
return getToColor(pto);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
return bgColor(p, pto);
|
|
36
|
+
// the room behind: the incoming image coming forward, and its reflection on the floor
|
|
37
|
+
vec4 room (vec2 uv, float x, float edgeL, float edgeR, float close, float dolly) {
|
|
38
|
+
float size = mix(max(depth, 1.0), 1.0, dolly);
|
|
39
|
+
vec2 p = (uv - 0.5) * size + 0.5;
|
|
40
|
+
// soft border while it is far, exactly sharp once it fills the frame
|
|
41
|
+
float soft = 0.004 * (size - 1.0) + 1e-6;
|
|
42
|
+
vec2 m = smoothstep(-soft, soft, p) * smoothstep(-soft, soft, 1.0 - p);
|
|
43
|
+
vec4 c = getToColor(clamp(p, 0.0, 1.0)) * (m.x * m.y);
|
|
44
|
+
if (p.y < 0.0) {
|
|
45
|
+
vec2 r = vec2(p.x, -1.2 * p.y - 0.02);
|
|
46
|
+
float f = reflection * (1.0 - r.y) * m.x * smoothstep(0.0, 0.01, r.y);
|
|
47
|
+
c += getToColor(clamp(r, 0.0, 1.0)) * f * (1.0 - m.y);
|
|
54
48
|
}
|
|
49
|
+
// the lit room spills its light through the opening, and the leaves cast soft shadows
|
|
50
|
+
// along their edges; both settle as the doors open
|
|
51
|
+
float wl = 0.03 + 0.12 * close;
|
|
52
|
+
float shadow = (1.0 - smoothstep(0.0, wl, x - edgeL)) + (1.0 - smoothstep(0.0, wl, edgeR - x));
|
|
53
|
+
float light = (1.0 + 0.6 * close * close) * (1.0 - 0.7 * close * min(shadow, 1.0));
|
|
54
|
+
return vec4(min(c.rgb * light, vec3(c.a)), c.a);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
vec4 transition (vec2 uv) {
|
|
58
|
+
float w = ratio;
|
|
59
|
+
float x = uv.x * w;
|
|
60
|
+
// camera distance: the leaves always stay in front of it
|
|
61
|
+
float eye = max(w, 1.0) * (0.5 + 0.2 / max(perspective, 0.01));
|
|
62
|
+
// the leaves swing until their free edges have just left the frame
|
|
63
|
+
float swing = progress * progress * (3.0 - 2.0 * progress);
|
|
64
|
+
float a = min(atan(2.0 * eye / w) + 0.1, 0.5 * PI) * swing;
|
|
65
|
+
float dolly = mix(easeInOut(progress), progress, 0.3);
|
|
66
|
+
// the free edge of the left leaf, front and back of its thickness, as (x, z)
|
|
67
|
+
float hw = 0.5 * w;
|
|
68
|
+
vec2 front = hw * vec2(cos(a), -sin(a));
|
|
69
|
+
float thick = 0.02 * w * (1.0 - smoothstep(0.8, 1.0, swing));
|
|
70
|
+
float edgeL = project(front, w, eye);
|
|
71
|
+
float backL = project(front + thick * vec2(sin(a), cos(a)), w, eye);
|
|
72
|
+
float close = 1.0 - swing;
|
|
73
|
+
vec4 back = room(uv, x, backL, w - backL, close, dolly);
|
|
74
|
+
// the leaf on this side of the frame (each one stays in its own half)
|
|
75
|
+
bool left = x < hw;
|
|
76
|
+
float lx = left ? x : w - x;
|
|
77
|
+
vec2 hit = leafHit(lx, w, eye, a);
|
|
78
|
+
float s = clamp(hit.y, 0.0, hw);
|
|
79
|
+
// the ray meets the leaf nearer to the eye, where it looks bigger
|
|
80
|
+
float v = 0.5 + (uv.y - 0.5) * hit.x;
|
|
81
|
+
vec4 leaf = getFromColor(clamp(vec2(left ? s / w : 1.0 - s / w, v), 0.0, 1.0));
|
|
82
|
+
// turned away from the light, and darker toward the free edge as the opening deepens
|
|
83
|
+
leaf.rgb *= 1.0 - 0.5 * (1.0 - cos(a)) - 0.25 * sin(a) * (s / hw);
|
|
84
|
+
// the edge of the leaf catches the light coming from the room
|
|
85
|
+
vec4 side = getFromColor(clamp(vec2(left ? 0.499 : 0.501, v), 0.0, 1.0));
|
|
86
|
+
side.rgb = min(side.rgb * 1.5, vec3(side.a));
|
|
87
|
+
// sharp at both ends, so that nothing of the doors is left at the start and the end
|
|
88
|
+
float aa = 0.003 * min(1.0, 20.0 * min(a, close)) + 1e-6;
|
|
89
|
+
vec4 c = mix(back, side, smoothstep(-aa, aa, backL - lx));
|
|
90
|
+
return mix(c, leaf, smoothstep(-aa, aa, edgeL - lx));
|
|
55
91
|
}
|
package/glsl3/Drape.glsl
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Drape — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Drape.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image hangs like a sheet of fabric that is let go at the top: it collapses into soft, uneven folds that hide one another as the cloth bunches up and slides down out of the frame, revealing the incoming image behind it
|
|
5
|
+
// Tags: fabric, fold, vertical, 3d, shadow
|
|
6
|
+
|
|
7
|
+
// @range(1, 16, 1) Number of folds across the cloth (fewer in a portrait image)
|
|
8
|
+
uniform float folds; // = 6.0
|
|
9
|
+
// @range(0, 1) Depth of the folds and of their shading
|
|
10
|
+
uniform float depth; // = 0.7
|
|
11
|
+
// @range(0, 1) How much the cloth sways sideways as it falls
|
|
12
|
+
uniform float sway; // = 0.4
|
|
13
|
+
// @range(0, 1) Strength of the soft shadow cast by the cloth on the incoming image
|
|
14
|
+
uniform float shadow; // = 0.5
|
|
15
|
+
|
|
16
|
+
const float PI = 3.141592653589793;
|
|
17
|
+
const int STEPS = 24;
|
|
18
|
+
const float DEPTH = 0.8; // height of the deepest folds, times the fold width
|
|
19
|
+
|
|
20
|
+
// folds a coordinate back into 0..1, mirroring the image at its edges
|
|
21
|
+
vec2 mirror(vec2 v) {
|
|
22
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// integer-free hash of an integer cell, smoothed into a 1D value noise in 0..1
|
|
26
|
+
float hash11(float p) {
|
|
27
|
+
p = fract(p * 0.1031);
|
|
28
|
+
p *= p + 33.33;
|
|
29
|
+
p *= p + p;
|
|
30
|
+
return fract(p);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
float noise1(float x) {
|
|
34
|
+
float i = floor(x);
|
|
35
|
+
float f = x - i;
|
|
36
|
+
return mix(hash11(i), hash11(i + 1.0), f * f * (3.0 - 2.0 * f));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// height of the top edge above x, sagging in the middle (m: see cloth)
|
|
40
|
+
float topEdge(float x, vec4 m) {
|
|
41
|
+
float c = 2.0 * x - 1.0;
|
|
42
|
+
return m.y - 0.08 * m.x * (1.0 - c * c);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// how far the sides are pulled in at the height sy, more so at the bunched top
|
|
46
|
+
float sidePull(float sy, float gT) {
|
|
47
|
+
return 0.035 * gT * (0.3 + 0.7 * clamp(sy, 0.0, 1.0));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// height of the cloth at the point (x, y) of the screen plane, toward the viewer,
|
|
51
|
+
// or -1 where there is no cloth. Also gives the cloth's own coordinates and fold phase.
|
|
52
|
+
// m: how far the folds have formed (0 at rest), height of the top edge, height of the hem, sideways swing
|
|
53
|
+
vec4 cloth(vec2 p, vec4 m, float foldN) {
|
|
54
|
+
float gT = m.x;
|
|
55
|
+
float botY = m.z;
|
|
56
|
+
float x = p.x - m.w;
|
|
57
|
+
float top = topEdge(x, m);
|
|
58
|
+
float sy = (p.y - botY) / max(top - botY, 1e-4); // 0 at the hem, 1 at the top edge
|
|
59
|
+
float pull = sidePull(sy, gT);
|
|
60
|
+
float xc = (x - pull) / (1.0 - 2.0 * pull);
|
|
61
|
+
// uneven folds: their width, depth and course along the cloth all wander
|
|
62
|
+
float wander = (noise1(0.5 * foldN * xc + 2.5 * sy + 5.3) - 0.5) * 2.4 * (1.0 - sy);
|
|
63
|
+
float ph = 2.0 * PI * (foldN * xc + 0.6 * noise1(0.7 * foldN * xc + 1.7)) + wander;
|
|
64
|
+
float d = 0.15 + 0.85 * noise1(1.1 * foldN * xc + 1.4 * sy + 7.0);
|
|
65
|
+
// deepest near the bunched top, relaxing toward the hem
|
|
66
|
+
float amp = DEPTH * depth * gT * (0.3 + 0.7 * sy * sqrt(max(sy, 0.0))) / max(foldN, 2.0);
|
|
67
|
+
// the free sides of the cloth hang flat
|
|
68
|
+
float w = 0.6 / foldN;
|
|
69
|
+
amp *= smoothstep(0.0, w, xc) * smoothstep(0.0, w, 1.0 - xc);
|
|
70
|
+
float prof = 0.5 - 0.5 * cos(ph); // 1 on a ridge, 0 in a valley
|
|
71
|
+
// small sagging creases where the fabric piles up under the top edge
|
|
72
|
+
float dt = (1.0 - sy) * (top - botY);
|
|
73
|
+
float crease = exp(-30.0 * dt) * (0.5 + 0.5 * sin(80.0 * dt + 0.7 * ph));
|
|
74
|
+
bool on = sy >= 0.0 && sy <= 1.0 && xc >= 0.0 && xc <= 1.0;
|
|
75
|
+
return on ? vec4(amp * (d * prof + 0.15 * crease), xc, sy, ph) : vec4(-1.0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
vec4 transition (vec2 uv) {
|
|
79
|
+
float t = progress;
|
|
80
|
+
// the top edge falls first and the hem follows later: the cloth collapses as it slides down
|
|
81
|
+
float topY = 1.0 - 1.06 * t * (0.35 + 0.65 * t);
|
|
82
|
+
float botY = -0.75 * t * t * t;
|
|
83
|
+
// the folds form as soon as the top is let go
|
|
84
|
+
float f = 1.0 - (1.0 - t) * (1.0 - t) * (1.0 - t);
|
|
85
|
+
float foldN = max(1.0, floor(folds * min(ratio, 1.0) + 0.5));
|
|
86
|
+
float shiftX = sway * 0.035 * sin(2.0 * PI * t) * f;
|
|
87
|
+
// the cloth is seen a little from the left and from above: ridges hide the valleys behind them
|
|
88
|
+
vec2 view = vec2(0.75 + 0.5 * sway * sin(PI * t) * f, -0.35);
|
|
89
|
+
float zMax = 1.15 * DEPTH * depth * f / max(foldN, 2.0); // a single fold is no deeper than two
|
|
90
|
+
vec4 m = vec4(f, topY, botY, shiftX);
|
|
91
|
+
// march from the front toward the screen plane, the first point inside the cloth is visible
|
|
92
|
+
float zA = zMax; // last step in front of the cloth
|
|
93
|
+
float zB = 0.0; // first step inside it
|
|
94
|
+
bool found = false;
|
|
95
|
+
float dA = 0.0;
|
|
96
|
+
float dB = 0.0;
|
|
97
|
+
bool onA = false; // whether the last step in front was over the cloth (else the ray came in through its edge)
|
|
98
|
+
for (int i = 0; i < STEPS; i++) {
|
|
99
|
+
if (!found) {
|
|
100
|
+
float z = max(zMax * (1.0 - float(i) / float(STEPS - 1)), 0.0);
|
|
101
|
+
vec4 s = cloth(uv - view * z, m, foldN);
|
|
102
|
+
float dz = s.x - z;
|
|
103
|
+
if (s.x >= 0.0 && dz >= 0.0) {
|
|
104
|
+
found = true;
|
|
105
|
+
zB = z;
|
|
106
|
+
dB = dz;
|
|
107
|
+
} else {
|
|
108
|
+
zA = z;
|
|
109
|
+
dA = dz;
|
|
110
|
+
onA = s.x >= 0.0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
float zHit = zB;
|
|
115
|
+
if (found && zA > zB) {
|
|
116
|
+
if (onA) {
|
|
117
|
+
// crossed the surface: refine between the last two steps
|
|
118
|
+
zHit = mix(zA, zB, dA / (dA - dB));
|
|
119
|
+
} else {
|
|
120
|
+
// came in through the top edge: find where the ray first meets the cloth,
|
|
121
|
+
// on its surface or through the edge (then it sees the inside of the fold)
|
|
122
|
+
float za = zA;
|
|
123
|
+
for (int j = 0; j < 5; j++) {
|
|
124
|
+
float zm = 0.5 * (za + zHit);
|
|
125
|
+
if (cloth(uv - view * zm, m, foldN).x >= zm) zHit = zm;
|
|
126
|
+
else za = zm;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
vec2 hp = uv - view * zHit;
|
|
131
|
+
vec4 hit = found ? cloth(hp, m, foldN) : vec4(-1.0);
|
|
132
|
+
if (found && hit.x < 0.0) {
|
|
133
|
+
zHit = zB;
|
|
134
|
+
hp = uv - view * zB;
|
|
135
|
+
hit = cloth(hp, m, foldN);
|
|
136
|
+
}
|
|
137
|
+
vec4 col = vec4(0.0);
|
|
138
|
+
float cover = 0.0;
|
|
139
|
+
if (hit.x >= 0.0) {
|
|
140
|
+
float xc = hit.y;
|
|
141
|
+
float sy = hit.z;
|
|
142
|
+
float ph = hit.w;
|
|
143
|
+
// the fabric is gathered: more of it goes into the slopes of the folds
|
|
144
|
+
float slope = PI * zMax * foldN;
|
|
145
|
+
// (capped so that the texture never runs backwards where the folds bunch up)
|
|
146
|
+
float mu = min(0.25 * slope * slope / (1.0 + 0.25 * slope * slope), 0.5);
|
|
147
|
+
float u = xc - mu * sin(2.0 * ph) / (4.0 * PI * foldN);
|
|
148
|
+
// and pushed together under the top edge
|
|
149
|
+
float h = max(topY - botY, 1e-4);
|
|
150
|
+
float comp = max(1.0 - h, 0.0);
|
|
151
|
+
float v = sy * (1.0 - comp) + comp * sy * sy * sy;
|
|
152
|
+
vec4 tex = getFromColor(mirror(vec2(u, v)));
|
|
153
|
+
float span = topEdge(hp.x - shiftX, m) - botY; // local height of the cloth
|
|
154
|
+
// surface normal from the height of the cloth around the visible point
|
|
155
|
+
float e = 0.002;
|
|
156
|
+
float hx = cloth(hp + vec2(e, 0.0), m, foldN).x;
|
|
157
|
+
float hy = cloth(hp + vec2(0.0, e), m, foldN).x;
|
|
158
|
+
float hx0 = hx >= 0.0 ? hx : hit.x;
|
|
159
|
+
float hy0 = hy >= 0.0 ? hy : hit.x;
|
|
160
|
+
vec3 nrm = normalize(vec3(-(hx0 - hit.x) / e, -(hy0 - hit.x) / e, 1.0));
|
|
161
|
+
vec3 light = normalize(vec3(-0.45, 0.35, 1.0));
|
|
162
|
+
float diffuse = mix(1.0, max(dot(nrm, light), 0.0) / light.z, min(1.0, 3.0 * f));
|
|
163
|
+
// soft ambient occlusion in the valleys, deeper where the folds are deep
|
|
164
|
+
float valley = 1.0 - (0.5 - 0.5 * cos(ph));
|
|
165
|
+
float ao = 1.0 - 0.6 * depth * f * valley * valley * (0.35 + 0.65 * sy);
|
|
166
|
+
// the rolled top edge gets less light
|
|
167
|
+
float rim = exp(-(1.0 - sy) * span * 70.0) * 0.35 * f;
|
|
168
|
+
// below the surface, the ray sees the shaded inside of a fold through the top edge
|
|
169
|
+
float under = max(hit.x - zHit, 0.0);
|
|
170
|
+
float back = min(1.0, under / max(0.1 * zMax, 1e-6));
|
|
171
|
+
tex.rgb *= diffuse * ao * (1.0 - rim) * (1.0 - 0.6 * back);
|
|
172
|
+
col = tex;
|
|
173
|
+
// anti-aliased outline, sharp at rest so the first frame is exact
|
|
174
|
+
float aa = 0.003 * f;
|
|
175
|
+
float inside = min((1.0 - sy) * span - view.y * under, min(xc, 1.0 - xc));
|
|
176
|
+
cover = aa > 0.0 ? clamp(inside / aa, 0.0, 1.0) : 1.0;
|
|
177
|
+
if (cover >= 1.0) return col;
|
|
178
|
+
}
|
|
179
|
+
// soft shadow of the cloth, held a little away from the incoming image, gone once it has left
|
|
180
|
+
vec4 to = getToColor(uv);
|
|
181
|
+
float x = uv.x - shiftX;
|
|
182
|
+
float pull = sidePull((uv.y - botY) / max(topEdge(x, m) - botY, 1e-4), f);
|
|
183
|
+
float outside = max(uv.y - topEdge(x, m), max(-x, x - 1.0) - pull);
|
|
184
|
+
float sh = shadow * exp(-max(outside, 0.0) * 16.0) * f * clamp(8.0 * (1.0 - t), 0.0, 1.0);
|
|
185
|
+
return mix(vec4(to.rgb * (1.0 - 0.8 * sh), to.a), col, cover);
|
|
186
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// DuotoneFade — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/DuotoneFade.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image is printed in two inks, shadows first, as a bold high-contrast duotone; the incoming image is printed over it in the same two inks, its dark tones landing before its highlights, then its own colors come back, highlights first
|
|
5
|
+
// Tags: color, duotone, print, poster, gradient-map, luminance
|
|
6
|
+
|
|
7
|
+
// @color Ink printed in the shadows (its alpha is its strength)
|
|
8
|
+
uniform vec4 shadowInk; // = vec4(0.11, 0.09, 0.46, 1.0)
|
|
9
|
+
// @color Ink printed in the highlights (its alpha is its strength)
|
|
10
|
+
uniform vec4 highlightInk; // = vec4(1.0, 0.45, 0.62, 1.0)
|
|
11
|
+
// @range(0, 1) How hard the tones are pushed apart toward the two inks
|
|
12
|
+
uniform float contrast; // = 0.6
|
|
13
|
+
// @range(0, 1) Amount of print grain in the inks and along the handoff
|
|
14
|
+
uniform float grain; // = 0.4
|
|
15
|
+
|
|
16
|
+
float dfHash(vec2 v) {
|
|
17
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
18
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
19
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
float dfLuma(vec4 c) {
|
|
23
|
+
return clamp(dot(c.rgb, vec3(0.299, 0.587, 0.114)), 0.0, 1.0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
vec4 transition(vec2 uv) {
|
|
27
|
+
vec4 a = getFromColor(uv);
|
|
28
|
+
vec4 b = getToColor(uv);
|
|
29
|
+
float la = dfLuma(a);
|
|
30
|
+
float lb = dfLuma(b);
|
|
31
|
+
// fixed print grain, in cells of about 1/360 of the shorter side
|
|
32
|
+
vec2 q = uv * 360.0 * vec2(max(ratio, 1.0), max(1.0 / ratio, 1.0));
|
|
33
|
+
float g = dfHash(floor(q)) - 0.5;
|
|
34
|
+
|
|
35
|
+
// the inks land on the outgoing image (shadows first), then lift off the incoming one (highlights first)
|
|
36
|
+
float inks = smoothstep(0.0, 0.35, progress);
|
|
37
|
+
float lift = smoothstep(0.65, 1.0, progress);
|
|
38
|
+
float amount = min(
|
|
39
|
+
clamp(inks * 1.35 - 0.35 * la, 0.0, 1.0),
|
|
40
|
+
clamp((1.0 - lift) * 1.35 - 0.35 * lb, 0.0, 1.0)
|
|
41
|
+
);
|
|
42
|
+
amount = amount * amount * (3.0 - 2.0 * amount);
|
|
43
|
+
|
|
44
|
+
// the incoming image is printed over the outgoing one, darkest tones first, along a grainy edge
|
|
45
|
+
float x = smoothstep(0.25, 0.75, progress) * 1.6 - 0.3;
|
|
46
|
+
float t = lb + 0.2 * grain * g;
|
|
47
|
+
float s = smoothstep(t - 0.15, t + 0.15, x);
|
|
48
|
+
|
|
49
|
+
// gradient map on luminance, with the tones pushed toward the two inks
|
|
50
|
+
float c = 0.4 * contrast;
|
|
51
|
+
float tone = smoothstep(c + 0.03, 1.03 - c, mix(la, lb, s) + 0.08 * grain * g);
|
|
52
|
+
vec4 ink = mix(shadowInk, highlightInk, tone);
|
|
53
|
+
|
|
54
|
+
// the images are blended with premultiplied alpha, and where neither is drawn nothing is printed
|
|
55
|
+
vec4 base = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), s);
|
|
56
|
+
if (base.a <= 0.0) return vec4(0.0);
|
|
57
|
+
return vec4(mix(base.rgb / base.a, ink.rgb, amount * ink.a), base.a);
|
|
58
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// FacetedGlass — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/FacetedGlass.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The frame is seen through a pane of irregular cut-glass facets, each one showing its own shifted, zoomed and tilted view of the image, with bright beveled edges and thin dark seams; the facets turn to the incoming image one by one, then the glass flattens out and clears
|
|
5
|
+
// Tags: glass, refraction, facets, voronoi, distortion
|
|
6
|
+
|
|
7
|
+
// @range(2, 20) Number of facets across the height of the frame
|
|
8
|
+
uniform float facets; // = 5.0
|
|
9
|
+
// @range(0, 0.3) How far each facet shifts its view of the image at the peak
|
|
10
|
+
uniform float refraction; // = 0.1
|
|
11
|
+
// @range(0, 1) Strength of the highlights and shadows along the beveled edges, and of the glint as each facet turns
|
|
12
|
+
uniform float bevel; // = 0.6
|
|
13
|
+
// @color Color of the light caught by the bevels
|
|
14
|
+
uniform vec4 highlight; // = vec4(1.0, 0.98, 0.92, 1.0)
|
|
15
|
+
// @param Random seed: another value gives other facets, turning in another order
|
|
16
|
+
uniform float seed; // = 0.0
|
|
17
|
+
|
|
18
|
+
// half width of the antialiased seams, in frame heights
|
|
19
|
+
const float AA = 0.0015;
|
|
20
|
+
|
|
21
|
+
vec2 hash22(vec2 p) {
|
|
22
|
+
vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
|
|
23
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
24
|
+
return fract((p3.xx + p3.yz) * p3.zy);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// mirror the coordinates back into the frame
|
|
28
|
+
vec2 mirror(vec2 v) {
|
|
29
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
vec4 transition(vec2 uv) {
|
|
33
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
34
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
35
|
+
|
|
36
|
+
// 0 at both ends, 1 in the middle: the glass builds up, then flattens out
|
|
37
|
+
float h = 1.0 - abs(2.0 * progress - 1.0);
|
|
38
|
+
float amount = h * h * (3.0 - 2.0 * h);
|
|
39
|
+
|
|
40
|
+
float n = max(facets, 1.0);
|
|
41
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
42
|
+
// measured in square pixels, so the facets are not stretched
|
|
43
|
+
vec2 p = uv * aspect * n;
|
|
44
|
+
vec2 i = floor(p);
|
|
45
|
+
vec2 f = p - i;
|
|
46
|
+
vec2 offset = vec2(17.31, 41.97) * seed;
|
|
47
|
+
// width of the bevels, in facet sizes
|
|
48
|
+
float bw = 0.18 * amount;
|
|
49
|
+
|
|
50
|
+
// nearest facet center
|
|
51
|
+
vec2 mg = vec2(0.0);
|
|
52
|
+
vec2 mr = vec2(0.0);
|
|
53
|
+
float md = 8.0;
|
|
54
|
+
for (int y = -1; y <= 1; y++) {
|
|
55
|
+
for (int x = -1; x <= 1; x++) {
|
|
56
|
+
vec2 g = vec2(float(x), float(y));
|
|
57
|
+
vec2 r = g + 0.1 + 0.8 * hash22(i + g + offset) - f;
|
|
58
|
+
float d = dot(r, r);
|
|
59
|
+
if (d < md) {
|
|
60
|
+
md = d;
|
|
61
|
+
mr = r;
|
|
62
|
+
mg = g;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// distance to the nearest facet edge, and the direction toward the edges, blended
|
|
68
|
+
// between neighboring edges near the corners so the bevel lighting turns smoothly
|
|
69
|
+
float edge = 8.0;
|
|
70
|
+
vec2 normal = vec2(0.0);
|
|
71
|
+
for (int y = -2; y <= 2; y++) {
|
|
72
|
+
for (int x = -2; x <= 2; x++) {
|
|
73
|
+
vec2 g = mg + vec2(float(x), float(y));
|
|
74
|
+
vec2 r = g + 0.1 + 0.8 * hash22(i + g + offset) - f;
|
|
75
|
+
vec2 dr = r - mr;
|
|
76
|
+
if (dot(dr, dr) > 0.00001) {
|
|
77
|
+
vec2 dn = normalize(dr);
|
|
78
|
+
float e = dot(0.5 * (mr + r), dn);
|
|
79
|
+
edge = min(edge, e);
|
|
80
|
+
float w = max(1.0 - e / bw, 0.0);
|
|
81
|
+
normal += dn * w * w;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
float nl = length(normal);
|
|
86
|
+
normal = nl > 0.0 ? normal / nl : vec2(0.0);
|
|
87
|
+
|
|
88
|
+
// the facet's own random cut: a shift, a zoom and a tilt
|
|
89
|
+
vec2 id = i + mg + offset;
|
|
90
|
+
vec2 h1 = hash22(id + 31.7);
|
|
91
|
+
vec2 h2 = hash22(id + 59.3);
|
|
92
|
+
vec2 h3 = hash22(id + 97.1);
|
|
93
|
+
float angle = 6.2831853 * h1.x;
|
|
94
|
+
vec2 dir = vec2(cos(angle), sin(angle));
|
|
95
|
+
vec2 shift = dir * (0.4 + 0.6 * h1.y) * refraction;
|
|
96
|
+
float zoom = (h2.x - 0.5) * 6.0 * refraction;
|
|
97
|
+
float tilt = (h2.y - 0.5) * 2.0 * refraction;
|
|
98
|
+
|
|
99
|
+
// from the facet center to the pixel, in frame heights
|
|
100
|
+
vec2 q = -mr / n;
|
|
101
|
+
vec2 view = -q * zoom + vec2(-q.y, q.x) * sin(tilt) + q * (cos(tilt) - 1.0);
|
|
102
|
+
|
|
103
|
+
// the bevel along the facet's edge: 1 on the edge, 0 inside
|
|
104
|
+
float bv = 1.0 - smoothstep(0.0, bw, edge);
|
|
105
|
+
bv *= bv;
|
|
106
|
+
// the bevel bends the image outward, more strongly than the flat facet
|
|
107
|
+
vec2 bend = normal * bv * 0.4 * refraction;
|
|
108
|
+
|
|
109
|
+
// the facet turns to the incoming image at its own time, and its view turns over with it
|
|
110
|
+
float start = 0.15 + 0.5 * h3.x;
|
|
111
|
+
float m = smoothstep(start, start + 0.2, progress);
|
|
112
|
+
vec2 d = amount * (view + bend);
|
|
113
|
+
vec2 s = amount * shift;
|
|
114
|
+
vec4 ca = getFromColor(mirror(uv + (s + d) / aspect));
|
|
115
|
+
vec4 cb = getToColor(mirror(uv + (d - s) / aspect));
|
|
116
|
+
// mixed premultiplied, so transparent images do not bleed their color
|
|
117
|
+
vec4 c = mix(vec4(ca.rgb * ca.a, ca.a), vec4(cb.rgb * cb.a, cb.a), m);
|
|
118
|
+
|
|
119
|
+
// light from the top left: each flat facet catches it a little differently
|
|
120
|
+
vec2 light = normalize(vec2(-0.6, 0.8));
|
|
121
|
+
vec2 slope = dir * (0.4 + 0.6 * h1.y);
|
|
122
|
+
float facetLight = 0.12 * amount * dot(slope, light);
|
|
123
|
+
// the bevels catch it strongly on one side and shade the other
|
|
124
|
+
float lit = dot(normal, light);
|
|
125
|
+
float k = clamp(bevel, 0.0, 1.0);
|
|
126
|
+
float glow = k * bv * max(lit, 0.0) * 1.1 * amount;
|
|
127
|
+
float shade = k * bv * max(-lit, 0.0) * 0.6 * amount;
|
|
128
|
+
// a glint as the facet turns over
|
|
129
|
+
float turn = sin(3.14159265 * m);
|
|
130
|
+
glow += k * 0.15 * amount * turn * turn;
|
|
131
|
+
// thin dark seams between the facets
|
|
132
|
+
float seam = 0.6 * amount * (1.0 - smoothstep(0.0, 2.0 * AA, edge / n - 0.5 * AA));
|
|
133
|
+
|
|
134
|
+
c.rgb *= (1.0 + facetLight) * (1.0 - shade) * (1.0 - seam);
|
|
135
|
+
c.rgb += highlight.rgb * highlight.a * glow * c.a;
|
|
136
|
+
return c.a > 0.0 ? vec4(clamp(c.rgb / c.a, 0.0, 1.0), c.a) : vec4(0.0);
|
|
137
|
+
}
|