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/sksl/Doorway.sksl
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Doorway — 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
|
|
|
6
6
|
uniform shader _from;
|
|
7
7
|
uniform shader _to;
|
|
@@ -15,50 +15,80 @@ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y)
|
|
|
15
15
|
uniform float reflection;
|
|
16
16
|
|
|
17
17
|
uniform float perspective;
|
|
18
|
+
|
|
18
19
|
uniform float depth;
|
|
19
20
|
|
|
20
|
-
const
|
|
21
|
-
const vec2 boundMin = vec2(0.0, 0.0);
|
|
22
|
-
const vec2 boundMax = vec2(1.0, 1.0);
|
|
21
|
+
const float PI = 3.141592653589793;
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
vec2 leafHit (float x, float w, float eye, float a) {
|
|
24
|
+
float c = cos(a), s = sin(a);
|
|
25
|
+
float t = (eye * c - 0.5 * w * s) / (s * (x - 0.5 * w) + eye * c);
|
|
26
|
+
vec2 hit = vec2(0.5 * w + t * (x - 0.5 * w), eye * (t - 1.0));
|
|
27
|
+
return vec2(t, hit.x * c - hit.y * s);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
return
|
|
30
|
+
float project (vec2 p, float w, float eye) {
|
|
31
|
+
return 0.5 * w + (p.x - 0.5 * w) * eye / (eye + p.y);
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
pto = project(pto);
|
|
35
|
-
if (inBounds(pto)) {
|
|
36
|
-
c += mix(black, getToColor(pto), reflection * mix(1.0, 0.0, pto.y));
|
|
37
|
-
}
|
|
38
|
-
return c;
|
|
34
|
+
float easeInOut (float t) {
|
|
35
|
+
return t < 0.5 ? 4.0 * t * t * t : 1.0 - 4.0 * (1.0 - t) * (1.0 - t) * (1.0 - t);
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
vec4
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
pto = (p + vec2(-0.5, -0.5)) * vec2(size, size) + vec2(0.5, 0.5);
|
|
53
|
-
if (inBounds(pfr)) {
|
|
54
|
-
return getFromColor(pfr);
|
|
55
|
-
}
|
|
56
|
-
else if (inBounds(pto)) {
|
|
57
|
-
return getToColor(pto);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
return bgColor(p, pto);
|
|
38
|
+
vec4 room (vec2 uv, float x, float edgeL, float edgeR, float close, float dolly) {
|
|
39
|
+
float size = mix(max(depth, 1.0), 1.0, dolly);
|
|
40
|
+
vec2 p = (uv - 0.5) * size + 0.5;
|
|
41
|
+
|
|
42
|
+
float soft = 0.004 * (size - 1.0) + 1e-6;
|
|
43
|
+
vec2 m = smoothstep(-soft, soft, p) * smoothstep(-soft, soft, 1.0 - p);
|
|
44
|
+
vec4 c = getToColor(clamp(p, 0.0, 1.0)) * (m.x * m.y);
|
|
45
|
+
if (p.y < 0.0) {
|
|
46
|
+
vec2 r = vec2(p.x, -1.2 * p.y - 0.02);
|
|
47
|
+
float f = reflection * (1.0 - r.y) * m.x * smoothstep(0.0, 0.01, r.y);
|
|
48
|
+
c += getToColor(clamp(r, 0.0, 1.0)) * f * (1.0 - m.y);
|
|
61
49
|
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
float wl = 0.03 + 0.12 * close;
|
|
53
|
+
float shadow = (1.0 - smoothstep(0.0, wl, x - edgeL)) + (1.0 - smoothstep(0.0, wl, edgeR - x));
|
|
54
|
+
float light = (1.0 + 0.6 * close * close) * (1.0 - 0.7 * close * min(shadow, 1.0));
|
|
55
|
+
return vec4(min(c.rgb * light, vec3(c.a)), c.a);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
vec4 transition (vec2 uv) {
|
|
59
|
+
float w = ratio;
|
|
60
|
+
float x = uv.x * w;
|
|
61
|
+
|
|
62
|
+
float eye = max(w, 1.0) * (0.5 + 0.2 / max(perspective, 0.01));
|
|
63
|
+
|
|
64
|
+
float swing = progress * progress * (3.0 - 2.0 * progress);
|
|
65
|
+
float a = min(atan(2.0 * eye / w) + 0.1, 0.5 * PI) * swing;
|
|
66
|
+
float dolly = mix(easeInOut(progress), progress, 0.3);
|
|
67
|
+
|
|
68
|
+
float hw = 0.5 * w;
|
|
69
|
+
vec2 front = hw * vec2(cos(a), -sin(a));
|
|
70
|
+
float thick = 0.02 * w * (1.0 - smoothstep(0.8, 1.0, swing));
|
|
71
|
+
float edgeL = project(front, w, eye);
|
|
72
|
+
float backL = project(front + thick * vec2(sin(a), cos(a)), w, eye);
|
|
73
|
+
float close = 1.0 - swing;
|
|
74
|
+
vec4 back = room(uv, x, backL, w - backL, close, dolly);
|
|
75
|
+
|
|
76
|
+
bool left = x < hw;
|
|
77
|
+
float lx = left ? x : w - x;
|
|
78
|
+
vec2 hit = leafHit(lx, w, eye, a);
|
|
79
|
+
float s = clamp(hit.y, 0.0, hw);
|
|
80
|
+
|
|
81
|
+
float v = 0.5 + (uv.y - 0.5) * hit.x;
|
|
82
|
+
vec4 leaf = getFromColor(clamp(vec2(left ? s / w : 1.0 - s / w, v), 0.0, 1.0));
|
|
83
|
+
|
|
84
|
+
leaf.rgb *= 1.0 - 0.5 * (1.0 - cos(a)) - 0.25 * sin(a) * (s / hw);
|
|
85
|
+
|
|
86
|
+
vec4 side = getFromColor(clamp(vec2(left ? 0.499 : 0.501, v), 0.0, 1.0));
|
|
87
|
+
side.rgb = min(side.rgb * 1.5, vec3(side.a));
|
|
88
|
+
|
|
89
|
+
float aa = 0.003 * min(1.0, 20.0 * min(a, close)) + 1e-6;
|
|
90
|
+
vec4 c = mix(back, side, smoothstep(-aa, aa, backL - lx));
|
|
91
|
+
return mix(c, leaf, smoothstep(-aa, aa, edgeL - lx));
|
|
62
92
|
}
|
|
63
93
|
|
|
64
94
|
half4 main(float2 _coord) {
|
package/sksl/Drape.sksl
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// Drape — 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
|
+
|
|
6
|
+
uniform shader _from;
|
|
7
|
+
uniform shader _to;
|
|
8
|
+
uniform float2 _resolution;
|
|
9
|
+
uniform float progress;
|
|
10
|
+
uniform float ratio;
|
|
11
|
+
|
|
12
|
+
vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
13
|
+
vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
14
|
+
|
|
15
|
+
uniform float folds;
|
|
16
|
+
|
|
17
|
+
uniform float depth;
|
|
18
|
+
|
|
19
|
+
uniform float sway;
|
|
20
|
+
|
|
21
|
+
uniform float shadow;
|
|
22
|
+
|
|
23
|
+
const float PI = 3.141592653589793;
|
|
24
|
+
const int STEPS = 24;
|
|
25
|
+
const float DEPTH = 0.8;
|
|
26
|
+
|
|
27
|
+
vec2 mirror(vec2 v) {
|
|
28
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
float hash11(float p) {
|
|
32
|
+
p = fract(p * 0.1031);
|
|
33
|
+
p *= p + 33.33;
|
|
34
|
+
p *= p + p;
|
|
35
|
+
return fract(p);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
float noise1(float x) {
|
|
39
|
+
float i = floor(x);
|
|
40
|
+
float f = x - i;
|
|
41
|
+
return mix(hash11(i), hash11(i + 1.0), f * f * (3.0 - 2.0 * f));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
float topEdge(float x, vec4 m) {
|
|
45
|
+
float c = 2.0 * x - 1.0;
|
|
46
|
+
return m.y - 0.08 * m.x * (1.0 - c * c);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
float sidePull(float sy, float gT) {
|
|
50
|
+
return 0.035 * gT * (0.3 + 0.7 * clamp(sy, 0.0, 1.0));
|
|
51
|
+
}
|
|
52
|
+
|
|
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);
|
|
59
|
+
float pull = sidePull(sy, gT);
|
|
60
|
+
float xc = (x - pull) / (1.0 - 2.0 * pull);
|
|
61
|
+
|
|
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
|
+
|
|
66
|
+
float amp = DEPTH * depth * gT * (0.3 + 0.7 * sy * sqrt(max(sy, 0.0))) / max(foldN, 2.0);
|
|
67
|
+
|
|
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);
|
|
71
|
+
|
|
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
|
+
|
|
81
|
+
float topY = 1.0 - 1.06 * t * (0.35 + 0.65 * t);
|
|
82
|
+
float botY = -0.75 * t * t * t;
|
|
83
|
+
|
|
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
|
+
|
|
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);
|
|
90
|
+
vec4 m = vec4(f, topY, botY, shiftX);
|
|
91
|
+
|
|
92
|
+
float zA = zMax;
|
|
93
|
+
float zB = 0.0;
|
|
94
|
+
bool found = false;
|
|
95
|
+
float dA = 0.0;
|
|
96
|
+
float dB = 0.0;
|
|
97
|
+
bool onA = false;
|
|
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
|
+
|
|
118
|
+
zHit = mix(zA, zB, dA / (dA - dB));
|
|
119
|
+
} else {
|
|
120
|
+
|
|
121
|
+
|
|
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
|
+
|
|
144
|
+
float slope = PI * zMax * foldN;
|
|
145
|
+
|
|
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
|
+
|
|
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;
|
|
154
|
+
|
|
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
|
+
|
|
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
|
+
|
|
167
|
+
float rim = exp(-(1.0 - sy) * span * 70.0) * 0.35 * f;
|
|
168
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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
|
+
}
|
|
187
|
+
|
|
188
|
+
half4 main(float2 _coord) {
|
|
189
|
+
vec2 _uv = _coord / _resolution;
|
|
190
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
191
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
192
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// DuotoneFade — 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
|
+
|
|
6
|
+
uniform shader _from;
|
|
7
|
+
uniform shader _to;
|
|
8
|
+
uniform float2 _resolution;
|
|
9
|
+
uniform float progress;
|
|
10
|
+
uniform float ratio;
|
|
11
|
+
|
|
12
|
+
vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
13
|
+
vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
14
|
+
|
|
15
|
+
uniform vec4 shadowInk;
|
|
16
|
+
|
|
17
|
+
uniform vec4 highlightInk;
|
|
18
|
+
|
|
19
|
+
uniform float contrast;
|
|
20
|
+
|
|
21
|
+
uniform float grain;
|
|
22
|
+
|
|
23
|
+
float dfHash(vec2 v) {
|
|
24
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
25
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
26
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
float dfLuma(vec4 c) {
|
|
30
|
+
return clamp(dot(c.rgb, vec3(0.299, 0.587, 0.114)), 0.0, 1.0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
vec4 transition(vec2 uv) {
|
|
34
|
+
vec4 a = getFromColor(uv);
|
|
35
|
+
vec4 b = getToColor(uv);
|
|
36
|
+
float la = dfLuma(a);
|
|
37
|
+
float lb = dfLuma(b);
|
|
38
|
+
|
|
39
|
+
vec2 q = uv * 360.0 * vec2(max(ratio, 1.0), max(1.0 / ratio, 1.0));
|
|
40
|
+
float g = dfHash(floor(q)) - 0.5;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
float inks = smoothstep(0.0, 0.35, progress);
|
|
44
|
+
float lift = smoothstep(0.65, 1.0, progress);
|
|
45
|
+
float amount = min(
|
|
46
|
+
clamp(inks * 1.35 - 0.35 * la, 0.0, 1.0),
|
|
47
|
+
clamp((1.0 - lift) * 1.35 - 0.35 * lb, 0.0, 1.0)
|
|
48
|
+
);
|
|
49
|
+
amount = amount * amount * (3.0 - 2.0 * amount);
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
float x = smoothstep(0.25, 0.75, progress) * 1.6 - 0.3;
|
|
53
|
+
float t = lb + 0.2 * grain * g;
|
|
54
|
+
float s = smoothstep(t - 0.15, t + 0.15, x);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
float c = 0.4 * contrast;
|
|
58
|
+
float tone = smoothstep(c + 0.03, 1.03 - c, mix(la, lb, s) + 0.08 * grain * g);
|
|
59
|
+
vec4 ink = mix(shadowInk, highlightInk, tone);
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
vec4 base = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), s);
|
|
63
|
+
if (base.a <= 0.0) return vec4(0.0);
|
|
64
|
+
return vec4(mix(base.rgb / base.a, ink.rgb, amount * ink.a), base.a);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
half4 main(float2 _coord) {
|
|
68
|
+
vec2 _uv = _coord / _resolution;
|
|
69
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
70
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
71
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// FacetedGlass — 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
|
+
|
|
6
|
+
uniform shader _from;
|
|
7
|
+
uniform shader _to;
|
|
8
|
+
uniform float2 _resolution;
|
|
9
|
+
uniform float progress;
|
|
10
|
+
uniform float ratio;
|
|
11
|
+
|
|
12
|
+
vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
13
|
+
vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
|
|
14
|
+
|
|
15
|
+
uniform float facets;
|
|
16
|
+
|
|
17
|
+
uniform float refraction;
|
|
18
|
+
|
|
19
|
+
uniform float bevel;
|
|
20
|
+
|
|
21
|
+
uniform vec4 highlight;
|
|
22
|
+
|
|
23
|
+
uniform float seed;
|
|
24
|
+
|
|
25
|
+
const float AA = 0.0015;
|
|
26
|
+
|
|
27
|
+
vec2 hash22(vec2 p) {
|
|
28
|
+
vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
|
|
29
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
30
|
+
return fract((p3.xx + p3.yz) * p3.zy);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
vec2 mirror(vec2 v) {
|
|
34
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
vec4 transition(vec2 uv) {
|
|
38
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
39
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
float h = 1.0 - abs(2.0 * progress - 1.0);
|
|
43
|
+
float amount = h * h * (3.0 - 2.0 * h);
|
|
44
|
+
|
|
45
|
+
float n = max(facets, 1.0);
|
|
46
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
47
|
+
|
|
48
|
+
vec2 p = uv * aspect * n;
|
|
49
|
+
vec2 i = floor(p);
|
|
50
|
+
vec2 f = p - i;
|
|
51
|
+
vec2 offset = vec2(17.31, 41.97) * seed;
|
|
52
|
+
|
|
53
|
+
float bw = 0.18 * amount;
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
vec2 mg = vec2(0.0);
|
|
57
|
+
vec2 mr = vec2(0.0);
|
|
58
|
+
float md = 8.0;
|
|
59
|
+
for (int y = -1; y <= 1; y++) {
|
|
60
|
+
for (int x = -1; x <= 1; x++) {
|
|
61
|
+
vec2 g = vec2(float(x), float(y));
|
|
62
|
+
vec2 r = g + 0.1 + 0.8 * hash22(i + g + offset) - f;
|
|
63
|
+
float d = dot(r, r);
|
|
64
|
+
if (d < md) {
|
|
65
|
+
md = d;
|
|
66
|
+
mr = r;
|
|
67
|
+
mg = g;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
float edge = 8.0;
|
|
75
|
+
vec2 normal = vec2(0.0);
|
|
76
|
+
for (int y = -2; y <= 2; y++) {
|
|
77
|
+
for (int x = -2; x <= 2; x++) {
|
|
78
|
+
vec2 g = mg + vec2(float(x), float(y));
|
|
79
|
+
vec2 r = g + 0.1 + 0.8 * hash22(i + g + offset) - f;
|
|
80
|
+
vec2 dr = r - mr;
|
|
81
|
+
if (dot(dr, dr) > 0.00001) {
|
|
82
|
+
vec2 dn = normalize(dr);
|
|
83
|
+
float e = dot(0.5 * (mr + r), dn);
|
|
84
|
+
edge = min(edge, e);
|
|
85
|
+
float w = max(1.0 - e / bw, 0.0);
|
|
86
|
+
normal += dn * w * w;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
float nl = length(normal);
|
|
91
|
+
normal = nl > 0.0 ? normal / nl : vec2(0.0);
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
vec2 id = i + mg + offset;
|
|
95
|
+
vec2 h1 = hash22(id + 31.7);
|
|
96
|
+
vec2 h2 = hash22(id + 59.3);
|
|
97
|
+
vec2 h3 = hash22(id + 97.1);
|
|
98
|
+
float angle = 6.2831853 * h1.x;
|
|
99
|
+
vec2 dir = vec2(cos(angle), sin(angle));
|
|
100
|
+
vec2 shift = dir * (0.4 + 0.6 * h1.y) * refraction;
|
|
101
|
+
float zoom = (h2.x - 0.5) * 6.0 * refraction;
|
|
102
|
+
float tilt = (h2.y - 0.5) * 2.0 * refraction;
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
vec2 q = -mr / n;
|
|
106
|
+
vec2 view = -q * zoom + vec2(-q.y, q.x) * sin(tilt) + q * (cos(tilt) - 1.0);
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
float bv = 1.0 - smoothstep(0.0, bw, edge);
|
|
110
|
+
bv *= bv;
|
|
111
|
+
|
|
112
|
+
vec2 bend = normal * bv * 0.4 * refraction;
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
float start = 0.15 + 0.5 * h3.x;
|
|
116
|
+
float m = smoothstep(start, start + 0.2, progress);
|
|
117
|
+
vec2 d = amount * (view + bend);
|
|
118
|
+
vec2 s = amount * shift;
|
|
119
|
+
vec4 ca = getFromColor(mirror(uv + (s + d) / aspect));
|
|
120
|
+
vec4 cb = getToColor(mirror(uv + (d - s) / aspect));
|
|
121
|
+
|
|
122
|
+
vec4 c = mix(vec4(ca.rgb * ca.a, ca.a), vec4(cb.rgb * cb.a, cb.a), m);
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
vec2 light = normalize(vec2(-0.6, 0.8));
|
|
126
|
+
vec2 slope = dir * (0.4 + 0.6 * h1.y);
|
|
127
|
+
float facetLight = 0.12 * amount * dot(slope, light);
|
|
128
|
+
|
|
129
|
+
float lit = dot(normal, light);
|
|
130
|
+
float k = clamp(bevel, 0.0, 1.0);
|
|
131
|
+
float glow = k * bv * max(lit, 0.0) * 1.1 * amount;
|
|
132
|
+
float shade = k * bv * max(-lit, 0.0) * 0.6 * amount;
|
|
133
|
+
|
|
134
|
+
float turn = sin(3.14159265 * m);
|
|
135
|
+
glow += k * 0.15 * amount * turn * turn;
|
|
136
|
+
|
|
137
|
+
float seam = 0.6 * amount * (1.0 - smoothstep(0.0, 2.0 * AA, edge / n - 0.5 * AA));
|
|
138
|
+
|
|
139
|
+
c.rgb *= (1.0 + facetLight) * (1.0 - shade) * (1.0 - seam);
|
|
140
|
+
c.rgb += highlight.rgb * highlight.a * glow * c.a;
|
|
141
|
+
return c.a > 0.0 ? vec4(clamp(c.rgb / c.a, 0.0, 1.0), c.a) : vec4(0.0);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
half4 main(float2 _coord) {
|
|
145
|
+
vec2 _uv = _coord / _resolution;
|
|
146
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
147
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
148
|
+
}
|