gl-transitions 2.4.0 → 2.5.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 +34 -0
- package/compatibility.json +244 -0
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/ArrowWipe.glsl +100 -0
- package/glsl3/BlockSlide.glsl +87 -0
- package/glsl3/CellDissolve.glsl +91 -0
- package/glsl3/Crumple.glsl +173 -0
- package/glsl3/HeatHaze.glsl +79 -0
- package/glsl3/Hologram.glsl +97 -0
- package/glsl3/LiquidFill.glsl +102 -0
- package/glsl3/PlasmaDissolve.glsl +51 -0
- package/glsl3/RingsWipe.glsl +106 -0
- package/glsl3/SawtoothWipe.glsl +73 -0
- package/glsl3/SnakeBlockWipe.glsl +40 -0
- package/glsl3/Snapshot.glsl +86 -0
- package/glsl3/Sphere.glsl +95 -0
- package/glsl3/SpiralBlockWipe.glsl +65 -0
- package/glsl3/Vortex.glsl +106 -0
- package/index.js +1 -1
- package/layouts.json +618 -18
- package/llms-full.txt +614 -362
- package/llms.txt +204 -189
- package/msl/ArrowWipe.metal +391 -0
- package/msl/BlockSlide.metal +418 -0
- package/msl/CellDissolve.metal +374 -0
- package/msl/Crumple.metal +766 -0
- package/msl/HeatHaze.metal +320 -0
- package/msl/Hologram.metal +380 -0
- package/msl/LiquidFill.metal +373 -0
- package/msl/PlasmaDissolve.metal +178 -0
- package/msl/RingsWipe.metal +437 -0
- package/msl/SawtoothWipe.metal +310 -0
- package/msl/SnakeBlockWipe.metal +216 -0
- package/msl/Snapshot.metal +321 -0
- package/msl/Sphere.metal +345 -0
- package/msl/SpiralBlockWipe.metal +281 -0
- package/msl/Vortex.metal +522 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +68 -34
- package/sksl/ArrowWipe.sksl +111 -0
- package/sksl/BlockSlide.sksl +99 -0
- package/sksl/CellDissolve.sksl +103 -0
- package/sksl/Crumple.sksl +179 -0
- package/sksl/HeatHaze.sksl +90 -0
- package/sksl/Hologram.sksl +108 -0
- package/sksl/LiquidFill.sksl +113 -0
- package/sksl/PlasmaDissolve.sksl +64 -0
- package/sksl/RingsWipe.sksl +115 -0
- package/sksl/SawtoothWipe.sksl +83 -0
- package/sksl/SnakeBlockWipe.sksl +53 -0
- package/sksl/Snapshot.sksl +98 -0
- package/sksl/Sphere.sksl +108 -0
- package/sksl/SpiralBlockWipe.sksl +76 -0
- package/sksl/Vortex.sksl +116 -0
- package/sksl/index.js +1 -1
- package/transitions/ArrowWipe.glsl +99 -0
- package/transitions/BlockSlide.glsl +86 -0
- package/transitions/CellDissolve.glsl +90 -0
- package/transitions/Crumple.glsl +172 -0
- package/transitions/HeatHaze.glsl +78 -0
- package/transitions/Hologram.glsl +96 -0
- package/transitions/LiquidFill.glsl +101 -0
- package/transitions/PlasmaDissolve.glsl +50 -0
- package/transitions/RingsWipe.glsl +105 -0
- package/transitions/SawtoothWipe.glsl +72 -0
- package/transitions/SnakeBlockWipe.glsl +39 -0
- package/transitions/Snapshot.glsl +85 -0
- package/transitions/Sphere.glsl +94 -0
- package/transitions/SpiralBlockWipe.glsl +64 -0
- package/transitions/Vortex.glsl +105 -0
- package/wgsl/ArrowWipe.wgsl +352 -0
- package/wgsl/BlockSlide.wgsl +384 -0
- package/wgsl/CellDissolve.wgsl +323 -0
- package/wgsl/Crumple.wgsl +709 -0
- package/wgsl/HeatHaze.wgsl +282 -0
- package/wgsl/Hologram.wgsl +339 -0
- package/wgsl/LiquidFill.wgsl +339 -0
- package/wgsl/PlasmaDissolve.wgsl +149 -0
- package/wgsl/RingsWipe.wgsl +394 -0
- package/wgsl/SawtoothWipe.wgsl +279 -0
- package/wgsl/SnakeBlockWipe.wgsl +188 -0
- package/wgsl/Snapshot.wgsl +287 -0
- package/wgsl/Sphere.wgsl +316 -0
- package/wgsl/SpiralBlockWipe.wgsl +250 -0
- package/wgsl/Vortex.wgsl +463 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// SawtoothWipe — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SawtoothWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: A wipe whose edge is a row of sharp, regular triangular teeth sweeps across the frame, or two toothed edges that start interlocked part from the middle like jaws opening
|
|
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 vec2 direction;
|
|
16
|
+
|
|
17
|
+
uniform int teeth;
|
|
18
|
+
|
|
19
|
+
uniform float depth;
|
|
20
|
+
|
|
21
|
+
uniform int jaws;
|
|
22
|
+
|
|
23
|
+
uniform float smoothness;
|
|
24
|
+
|
|
25
|
+
const float AA = 0.0015;
|
|
26
|
+
|
|
27
|
+
float zigzag(vec2 q, float w, float h) {
|
|
28
|
+
|
|
29
|
+
float x = abs(fract(q.x / w) - 0.5) * w;
|
|
30
|
+
vec2 a = vec2(0.0, -0.5 * h);
|
|
31
|
+
vec2 ab = vec2(0.5 * w, h);
|
|
32
|
+
vec2 aq = vec2(x, q.y) - a;
|
|
33
|
+
float d = length(aq - ab * clamp(dot(aq, ab) / dot(ab, ab), 0.0, 1.0));
|
|
34
|
+
return q.y > h * (2.0 * x / w - 0.5) ? d : -d;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
vec4 transition(vec2 uv) {
|
|
38
|
+
vec4 a = getFromColor(uv);
|
|
39
|
+
vec4 b = getToColor(uv);
|
|
40
|
+
if (progress <= 0.0) return a;
|
|
41
|
+
if (progress >= 1.0) return b;
|
|
42
|
+
|
|
43
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
44
|
+
|
|
45
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
46
|
+
|
|
47
|
+
float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
|
|
48
|
+
float w = 0.5 * (abs(dir.y) * ratio + abs(dir.x));
|
|
49
|
+
float period = 2.0 * w / float(teeth < 1 ? 1 : teeth);
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
vec2 q = vec2(dot(p, vec2(-dir.y, dir.x)) + w + 0.5 * period, dot(p, dir));
|
|
53
|
+
float h = max(depth, 0.0) * period;
|
|
54
|
+
|
|
55
|
+
float s = max(min(smoothness, 0.25 * period), AA);
|
|
56
|
+
float t = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.35);
|
|
57
|
+
|
|
58
|
+
float d;
|
|
59
|
+
if ((jaws != 0)) {
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
float overlap = s * sqrt(1.0 + 4.0 * h * h / (period * period));
|
|
64
|
+
float o = mix(-overlap, e + 0.5 * h + s, t);
|
|
65
|
+
d = max(zigzag(q - vec2(0.0, o), period, h), -zigzag(q + vec2(0.0, o), period, h));
|
|
66
|
+
} else {
|
|
67
|
+
|
|
68
|
+
float c = mix(-e - 0.5 * h - s, e + 0.5 * h + s, t);
|
|
69
|
+
d = zigzag(q - vec2(0.0, c), period, h);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
float m = 1.0 - smoothstep(-s, s, d);
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
|
|
76
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
half4 main(float2 _coord) {
|
|
80
|
+
vec2 _uv = _coord / _resolution;
|
|
81
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
82
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
83
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// SnakeBlockWipe — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SnakeBlockWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: Blocks switch to the incoming image one at a time, row after row from the top (or column after column from the left), each line running the opposite way to the one before, like a snake winding across the frame
|
|
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 ivec2 grid;
|
|
16
|
+
|
|
17
|
+
uniform int vertical;
|
|
18
|
+
|
|
19
|
+
uniform float smoothness;
|
|
20
|
+
|
|
21
|
+
vec4 transition(vec2 uv) {
|
|
22
|
+
vec4 a = getFromColor(uv);
|
|
23
|
+
vec4 b = getToColor(uv);
|
|
24
|
+
if (progress <= 0.0) return a;
|
|
25
|
+
if (progress >= 1.0) return b;
|
|
26
|
+
|
|
27
|
+
vec2 g = max(vec2(grid), 1.0);
|
|
28
|
+
|
|
29
|
+
vec2 cell = min(floor(vec2(uv.x, 1.0 - uv.y) * g), g - 1.0);
|
|
30
|
+
|
|
31
|
+
float lines = (vertical != 0) ? g.x : g.y;
|
|
32
|
+
float len = (vertical != 0) ? g.y : g.x;
|
|
33
|
+
float line = (vertical != 0) ? cell.x : cell.y;
|
|
34
|
+
float pos = (vertical != 0) ? cell.y : cell.x;
|
|
35
|
+
|
|
36
|
+
if (mod(line, 2.0) > 0.5) pos = len - 1.0 - pos;
|
|
37
|
+
float order = line * len + pos;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
float n = lines * len;
|
|
41
|
+
float w = max(smoothness, 0.001);
|
|
42
|
+
float m = clamp((progress * (n - 1.0 + w) - order) / w, 0.0, 1.0);
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
|
|
46
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
half4 main(float2 _coord) {
|
|
50
|
+
vec2 _uv = _coord / _resolution;
|
|
51
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
52
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
53
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Snapshot — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Snapshot.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: A camera flash freezes the outgoing image into a printed photo with a white border, which shrinks, tilts and drops 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 tilt;
|
|
16
|
+
|
|
17
|
+
uniform float border;
|
|
18
|
+
|
|
19
|
+
uniform float flash;
|
|
20
|
+
|
|
21
|
+
uniform float shadow;
|
|
22
|
+
|
|
23
|
+
uniform vec4 borderColor;
|
|
24
|
+
|
|
25
|
+
const float SHRINK = 0.24;
|
|
26
|
+
const float RADIUS = 0.008;
|
|
27
|
+
const float AA = 0.0015;
|
|
28
|
+
|
|
29
|
+
float roundedBox(vec2 q, vec2 b, float r) {
|
|
30
|
+
vec2 d = abs(q) - b + r;
|
|
31
|
+
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
vec4 premultiply(vec4 c) {
|
|
35
|
+
return vec4(c.rgb * c.a, c.a);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
vec4 transition(vec2 uv) {
|
|
39
|
+
float p = progress;
|
|
40
|
+
vec2 asp = vec2(ratio, 1.0);
|
|
41
|
+
vec2 q = (uv - 0.5) * asp;
|
|
42
|
+
vec2 halfImage = 0.5 * asp;
|
|
43
|
+
vec2 halfCard = halfImage + border;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
float k = smoothstep(0.05, 0.4, p);
|
|
47
|
+
float t = clamp((p - 0.3) / 0.7, 0.0, 1.0);
|
|
48
|
+
float fall = t * t;
|
|
49
|
+
float s = 1.0 - SHRINK * k;
|
|
50
|
+
float a = -tilt * (0.12 * k + 0.88 * fall);
|
|
51
|
+
|
|
52
|
+
float bound = (abs(sin(tilt)) * halfCard.x + abs(cos(tilt)) * halfCard.y) * (1.0 - SHRINK);
|
|
53
|
+
|
|
54
|
+
float lift = 0.035 * k * (1.0 - fall);
|
|
55
|
+
vec2 center = vec2(0.08 * fall, lift - (0.5 + bound + 0.1) * fall);
|
|
56
|
+
|
|
57
|
+
float rad = RADIUS * k;
|
|
58
|
+
|
|
59
|
+
float ca = cos(a), sa = sin(a);
|
|
60
|
+
mat2 unrotate = mat2(ca, -sa, sa, ca);
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
vec4 col = getToColor(uv);
|
|
64
|
+
float sh = shadow * k;
|
|
65
|
+
if (sh > 0.0) {
|
|
66
|
+
vec2 rs = unrotate * (q - center - vec2(0.012, -0.022) * k) / s;
|
|
67
|
+
float ds = roundedBox(rs, halfCard, rad) * s;
|
|
68
|
+
float blur = 0.035 * s;
|
|
69
|
+
col.rgb *= 1.0 - sh * (1.0 - smoothstep(-blur, blur, ds));
|
|
70
|
+
}
|
|
71
|
+
col = premultiply(col);
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
vec2 r = unrotate * (q - center) / s;
|
|
75
|
+
float dCard = roundedBox(r, halfCard, rad) * s;
|
|
76
|
+
float dImage = roundedBox(r, halfImage, 0.0) * s;
|
|
77
|
+
|
|
78
|
+
float cardCover = clamp(1.5 - dCard / AA, 0.0, 1.0);
|
|
79
|
+
float imageCover = clamp(1.5 - dImage / AA, 0.0, 1.0);
|
|
80
|
+
|
|
81
|
+
vec4 photo = premultiply(getFromColor(clamp(r / asp + 0.5, 0.0, 1.0)));
|
|
82
|
+
vec4 paper = premultiply(borderColor);
|
|
83
|
+
vec4 card = mix(paper + col * (1.0 - paper.a), photo, imageCover);
|
|
84
|
+
col = mix(col, card, cardCover);
|
|
85
|
+
if (col.a <= 0.0) return vec4(0.0);
|
|
86
|
+
col.rgb /= col.a;
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
float f = flash * smoothstep(0.0, 0.05, p) * (1.0 - smoothstep(0.05, 0.3, p));
|
|
90
|
+
col.rgb = 1.0 - (1.0 - col.rgb) * (1.0 - f);
|
|
91
|
+
return col;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
half4 main(float2 _coord) {
|
|
95
|
+
vec2 _uv = _coord / _resolution;
|
|
96
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
97
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
98
|
+
}
|
package/sksl/Sphere.sksl
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Sphere — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Sphere.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image wraps itself onto a shaded ball that shrinks and rolls away, revealing the incoming image under its shadow
|
|
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 vec2 direction;
|
|
16
|
+
|
|
17
|
+
uniform float size;
|
|
18
|
+
|
|
19
|
+
uniform float shading;
|
|
20
|
+
|
|
21
|
+
uniform float shadow;
|
|
22
|
+
|
|
23
|
+
const float PI = 3.14159265;
|
|
24
|
+
|
|
25
|
+
const float AA = 0.0015;
|
|
26
|
+
|
|
27
|
+
const vec3 LIGHT = vec3(-0.5, 0.6, 1.0) / 1.2689;
|
|
28
|
+
|
|
29
|
+
vec4 transition(vec2 uv) {
|
|
30
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
31
|
+
vec4 b = getToColor(uv);
|
|
32
|
+
if (progress >= 1.0) return b;
|
|
33
|
+
|
|
34
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
35
|
+
vec2 side = vec2(-dir.y, dir.x);
|
|
36
|
+
|
|
37
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
38
|
+
float shorter = min(ratio, 1.0);
|
|
39
|
+
float r0 = clamp(size, 0.1, 0.5) * shorter;
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
float w = clamp(progress / 0.45, 0.0, 1.0);
|
|
44
|
+
w = 1.0 - (1.0 - w) * (1.0 - w);
|
|
45
|
+
float away = smoothstep(0.3, 1.0, progress);
|
|
46
|
+
away *= away;
|
|
47
|
+
float wrapped = r0 / max(w, 1e-4);
|
|
48
|
+
float radius = wrapped * mix(1.0, 0.5, away);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
float tight = mix(1.0, min(1.0, 0.48 * shorter / (PI * r0)), w * w);
|
|
52
|
+
float paper = radius * tight;
|
|
53
|
+
|
|
54
|
+
float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
|
|
55
|
+
|
|
56
|
+
float full = e + 1.1 * r0 + 2.0 * AA;
|
|
57
|
+
float travel = away * full;
|
|
58
|
+
vec2 center = dir * travel;
|
|
59
|
+
|
|
60
|
+
float angle = -2.0 * full * log(1.0 - 0.5 * away) / wrapped;
|
|
61
|
+
|
|
62
|
+
vec2 d = p - center;
|
|
63
|
+
float r = length(d);
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
vec2 sd = d - vec2(0.25, -0.3) * radius * w;
|
|
67
|
+
float sh = shadow * w * (1.0 - smoothstep(0.6 * radius, 1.4 * radius, length(sd)));
|
|
68
|
+
vec4 bg = vec4(b.rgb * b.a * (1.0 - sh), b.a);
|
|
69
|
+
|
|
70
|
+
vec4 ball = vec4(0.0);
|
|
71
|
+
float cover = 1.0 - smoothstep(radius - AA, radius + AA, r);
|
|
72
|
+
if (cover > 0.0) {
|
|
73
|
+
|
|
74
|
+
vec2 nd = d / radius;
|
|
75
|
+
vec3 n = vec3(nd, sqrt(max(1.0 - dot(nd, nd), 0.0)));
|
|
76
|
+
|
|
77
|
+
float u = dot(n.xy, dir);
|
|
78
|
+
float s = dot(n.xy, side);
|
|
79
|
+
float cu = cos(angle), su = sin(angle);
|
|
80
|
+
vec3 q = vec3(u * cu - n.z * su, s, u * su + n.z * cu);
|
|
81
|
+
|
|
82
|
+
float lq = length(q.xy);
|
|
83
|
+
float arc = atan(lq, q.z) * paper;
|
|
84
|
+
vec2 img = lq > 0.0 ? (q.x * dir + q.y * side) / lq * arc : vec2(0.0);
|
|
85
|
+
vec2 iuv = img / vec2(ratio, 1.0) + 0.5;
|
|
86
|
+
|
|
87
|
+
vec2 edge = min(iuv, 1.0 - iuv) * vec2(ratio, 1.0);
|
|
88
|
+
float inside = cover * smoothstep(-AA, AA, min(edge.x, edge.y));
|
|
89
|
+
if (inside > 0.0) {
|
|
90
|
+
vec4 c = getFromColor(clamp(iuv, 0.0, 1.0));
|
|
91
|
+
float diff = max(dot(n, LIGHT), 0.0);
|
|
92
|
+
float spec = pow(max(reflect(-LIGHT, n).z, 0.0), 24.0);
|
|
93
|
+
float k = shading * w;
|
|
94
|
+
vec3 lit = c.rgb * mix(1.0, 0.25 + 0.85 * diff, k) + 0.35 * k * spec;
|
|
95
|
+
ball = vec4(clamp(lit, 0.0, 1.0) * c.a, c.a) * inside;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
vec4 c = ball + bg * (1.0 - ball.a);
|
|
101
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
half4 main(float2 _coord) {
|
|
105
|
+
vec2 _uv = _coord / _resolution;
|
|
106
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
107
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
108
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// SpiralBlockWipe — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SpiralBlockWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: Square blocks switch to the incoming image one after another along a rectangular spiral, from the border inward or from the center outward
|
|
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 ivec2 grid;
|
|
16
|
+
|
|
17
|
+
uniform int inward;
|
|
18
|
+
|
|
19
|
+
uniform int clockwise;
|
|
20
|
+
|
|
21
|
+
uniform float smoothness;
|
|
22
|
+
|
|
23
|
+
float spiralIndex(vec2 c, vec2 n) {
|
|
24
|
+
|
|
25
|
+
float k = min(min(c.x, c.y), min(n.x - 1.0 - c.x, n.y - 1.0 - c.y));
|
|
26
|
+
|
|
27
|
+
vec2 s = n - 2.0 * k;
|
|
28
|
+
vec2 l = c - k;
|
|
29
|
+
|
|
30
|
+
float before = n.x * n.y - s.x * s.y;
|
|
31
|
+
float along;
|
|
32
|
+
if (l.y == 0.0) along = l.x;
|
|
33
|
+
else if (l.x == s.x - 1.0) along = s.x - 1.0 + l.y;
|
|
34
|
+
else if (l.y == s.y - 1.0) along = 2.0 * s.x + s.y - 3.0 - l.x;
|
|
35
|
+
else along = 2.0 * (s.x - 1.0) + 2.0 * (s.y - 1.0) - l.y;
|
|
36
|
+
return before + along;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
vec4 transition(vec2 uv) {
|
|
40
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
41
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
42
|
+
|
|
43
|
+
vec2 n = max(vec2(grid), vec2(1.0));
|
|
44
|
+
|
|
45
|
+
vec2 c = min(floor(vec2(uv.x, 1.0 - uv.y) * n), n - 1.0);
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if ((clockwise != 0) != (inward != 0)) {
|
|
49
|
+
c = c.yx;
|
|
50
|
+
n = n.yx;
|
|
51
|
+
}
|
|
52
|
+
float count = n.x * n.y;
|
|
53
|
+
float i = spiralIndex(c, n);
|
|
54
|
+
if (!(inward != 0)) i = count - 1.0 - i;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
float w = max(smoothness, 0.0) * count;
|
|
59
|
+
float o = max(0.5 * (1.0 - w), 0.0);
|
|
60
|
+
float x = progress * (count - 1.0 + 2.0 * o + w) - i - o;
|
|
61
|
+
float m = w > 0.0 ? smoothstep(0.0, w, x) : step(0.0, x);
|
|
62
|
+
|
|
63
|
+
if (m <= 0.0) return getFromColor(uv);
|
|
64
|
+
if (m >= 1.0) return getToColor(uv);
|
|
65
|
+
vec4 a = getFromColor(uv);
|
|
66
|
+
vec4 b = getToColor(uv);
|
|
67
|
+
|
|
68
|
+
vec4 col = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
|
|
69
|
+
return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
half4 main(float2 _coord) {
|
|
73
|
+
vec2 _uv = _coord / _resolution;
|
|
74
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
75
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
76
|
+
}
|
package/sksl/Vortex.sksl
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Vortex — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Vortex.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image breaks into hundreds of small squares that a tornado carries away along a spiral around the center, from the eye outward, uncovering the incoming image
|
|
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 int grid;
|
|
16
|
+
|
|
17
|
+
uniform vec2 center;
|
|
18
|
+
|
|
19
|
+
uniform float spin;
|
|
20
|
+
|
|
21
|
+
uniform float randomness;
|
|
22
|
+
|
|
23
|
+
const int GROUPS = 24;
|
|
24
|
+
const float DURATION = 0.25;
|
|
25
|
+
|
|
26
|
+
const float AA = 0.0015;
|
|
27
|
+
const float TAU = 6.2831853;
|
|
28
|
+
|
|
29
|
+
float hash(vec2 n) {
|
|
30
|
+
return fract(sin(dot(n, vec2(12.9898, 78.233))) * 43758.5453);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
int groupOf(vec2 n, float h, vec2 c, float maxR) {
|
|
34
|
+
|
|
35
|
+
float r = min(length((n + 0.5) * h - c) / (0.85 * maxR), 1.0);
|
|
36
|
+
float key = clamp(mix(r * sqrt(r), hash(n), clamp(randomness, 0.0, 1.0)), 0.0, 0.9999);
|
|
37
|
+
return int(floor(key * float(GROUPS)));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
float flight(int g) {
|
|
41
|
+
float delay = float(g) / float(GROUPS) * (1.0 - DURATION);
|
|
42
|
+
return clamp((progress - delay) / DURATION, 0.0, 1.0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
vec4 premultiplied(vec4 c) {
|
|
46
|
+
return vec4(c.rgb * c.a, c.a);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
vec4 transition(vec2 uv) {
|
|
50
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
51
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
55
|
+
vec2 p = uv * aspect;
|
|
56
|
+
vec2 c = center * aspect;
|
|
57
|
+
float maxR = max(max(length(c), length(c - vec2(ratio, 0.0))), max(length(c - vec2(0.0, 1.0)), length(c - aspect)));
|
|
58
|
+
float h = 1.0 / float(grid < 1 ? 1 : grid);
|
|
59
|
+
|
|
60
|
+
float reach = 0.7 * maxR;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
vec2 n0 = floor(p / h);
|
|
64
|
+
vec4 col = flight(groupOf(n0, h, c, maxR)) <= 0.0 ? premultiplied(getFromColor(uv)) : premultiplied(getToColor(uv));
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
for (int k = 0; k < GROUPS; k++) {
|
|
68
|
+
int g = GROUPS - 1 - k;
|
|
69
|
+
float s = flight(g);
|
|
70
|
+
if (s <= 0.0 || s >= 1.0) continue;
|
|
71
|
+
float e = s * s;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
float angle = spin * TAU * e * 2.0 / (1.0 + 6.0 * float(g) / float(GROUPS));
|
|
75
|
+
float push = reach * e * s;
|
|
76
|
+
|
|
77
|
+
float size = (1.0 + 0.35 * sin(3.1415927 * s)) * (1.0 - s * s * s);
|
|
78
|
+
float ca = cos(angle);
|
|
79
|
+
float sa = sin(angle);
|
|
80
|
+
mat2 rot = mat2(ca, sa, -sa, ca);
|
|
81
|
+
|
|
82
|
+
vec2 u = (p - c) * rot;
|
|
83
|
+
float ru = length(u);
|
|
84
|
+
vec2 guess = c + (ru > 0.0 ? u / ru : vec2(0.0)) * max(ru - push, 0.0);
|
|
85
|
+
vec2 ng = floor(guess / h);
|
|
86
|
+
for (int j = -1; j <= 1; j++) {
|
|
87
|
+
for (int i = -1; i <= 1; i++) {
|
|
88
|
+
vec2 n = ng + vec2(float(i), float(j));
|
|
89
|
+
if (groupOf(n, h, c, maxR) != g) continue;
|
|
90
|
+
vec2 home = (n + 0.5) * h;
|
|
91
|
+
vec2 rel = home - c;
|
|
92
|
+
float rr = length(rel);
|
|
93
|
+
vec2 dir = rr > 0.0 ? rel / rr : vec2(0.0);
|
|
94
|
+
vec2 pos = c + rot * (dir * (rr + push));
|
|
95
|
+
|
|
96
|
+
float tumble = angle + (hash(n + 17.0) - 0.5) * 3.0 * e * sign(spin);
|
|
97
|
+
float ct = cos(tumble);
|
|
98
|
+
float st = sin(tumble);
|
|
99
|
+
vec2 d = ((p - pos) * mat2(ct, st, -st, ct)) / max(size, 1e-4);
|
|
100
|
+
float edge = 0.5 * h - max(abs(d.x), abs(d.y));
|
|
101
|
+
float cov = clamp(edge * size / (2.0 * AA) + 0.5, 0.0, 1.0);
|
|
102
|
+
vec2 src = home + d;
|
|
103
|
+
if (cov <= 0.0 || src.x < 0.0 || src.y < 0.0 || src.x > ratio || src.y > 1.0) continue;
|
|
104
|
+
vec4 piece = premultiplied(getFromColor(src / aspect)) * cov;
|
|
105
|
+
col = piece + col * (1.0 - piece.a);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
half4 main(float2 _coord) {
|
|
113
|
+
vec2 _uv = _coord / _resolution;
|
|
114
|
+
vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
|
|
115
|
+
return half4(_c.rgb * _c.a, _c.a);
|
|
116
|
+
}
|