gl-transitions 2.0.0 → 2.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/compatibility.json +290 -0
  3. package/gl-transitions.js +1 -1
  4. package/gl-transitions.json +1 -1
  5. package/glsl3/ApertureWipe.glsl +45 -0
  6. package/glsl3/Comb.glsl +26 -0
  7. package/glsl3/Curtains.glsl +47 -0
  8. package/glsl3/DiamondWipe.glsl +21 -0
  9. package/glsl3/DitherDissolve.glsl +27 -0
  10. package/glsl3/FallOver.glsl +36 -0
  11. package/glsl3/Fisheye.glsl +23 -0
  12. package/glsl3/Halftone.glsl +49 -0
  13. package/glsl3/Honeycomb.glsl +55 -0
  14. package/glsl3/PaperTear.glsl +76 -0
  15. package/glsl3/Prisms.glsl +81 -0
  16. package/glsl3/Puzzle.glsl +124 -0
  17. package/glsl3/Shred.glsl +67 -0
  18. package/glsl3/SpiralWipe.glsl +41 -0
  19. package/glsl3/Tunnel.glsl +42 -0
  20. package/glsl3/TvRoll.glsl +43 -0
  21. package/glsl3/TvTurnOff.glsl +47 -0
  22. package/glsl3/WhipPan.glsl +50 -0
  23. package/index.js +1 -1
  24. package/layouts.json +528 -0
  25. package/llms-full.txt +520 -256
  26. package/llms.txt +154 -136
  27. package/msl/ApertureWipe.metal +193 -0
  28. package/msl/Comb.metal +167 -0
  29. package/msl/Curtains.metal +207 -0
  30. package/msl/DiamondWipe.metal +123 -0
  31. package/msl/DitherDissolve.metal +157 -0
  32. package/msl/FallOver.metal +192 -0
  33. package/msl/Fisheye.metal +121 -0
  34. package/msl/Halftone.metal +230 -0
  35. package/msl/Honeycomb.metal +263 -0
  36. package/msl/PaperTear.metal +373 -0
  37. package/msl/Prisms.metal +424 -0
  38. package/msl/Puzzle.metal +632 -0
  39. package/msl/Shred.metal +294 -0
  40. package/msl/SpiralWipe.metal +196 -0
  41. package/msl/Tunnel.metal +207 -0
  42. package/msl/TvRoll.metal +205 -0
  43. package/msl/TvTurnOff.metal +238 -0
  44. package/msl/WhipPan.metal +218 -0
  45. package/package.json +1 -1
  46. package/skills/gl-transitions/references/catalog.md +52 -34
  47. package/sksl/ApertureWipe.sksl +56 -0
  48. package/sksl/Comb.sksl +39 -0
  49. package/sksl/Curtains.sksl +60 -0
  50. package/sksl/DiamondWipe.sksl +34 -0
  51. package/sksl/DitherDissolve.sksl +39 -0
  52. package/sksl/FallOver.sksl +49 -0
  53. package/sksl/Fisheye.sksl +36 -0
  54. package/sksl/Halftone.sksl +61 -0
  55. package/sksl/Honeycomb.sksl +64 -0
  56. package/sksl/PaperTear.sksl +82 -0
  57. package/sksl/Prisms.sksl +94 -0
  58. package/sksl/Puzzle.sksl +134 -0
  59. package/sksl/Shred.sksl +79 -0
  60. package/sksl/SpiralWipe.sksl +51 -0
  61. package/sksl/Tunnel.sksl +55 -0
  62. package/sksl/TvRoll.sksl +55 -0
  63. package/sksl/TvTurnOff.sksl +59 -0
  64. package/sksl/WhipPan.sksl +62 -0
  65. package/sksl/index.js +1 -1
  66. package/transitions/ApertureWipe.glsl +44 -0
  67. package/transitions/Comb.glsl +25 -0
  68. package/transitions/Curtains.glsl +46 -0
  69. package/transitions/DiamondWipe.glsl +20 -0
  70. package/transitions/DitherDissolve.glsl +26 -0
  71. package/transitions/FallOver.glsl +35 -0
  72. package/transitions/Fisheye.glsl +22 -0
  73. package/transitions/Halftone.glsl +48 -0
  74. package/transitions/Honeycomb.glsl +54 -0
  75. package/transitions/PaperTear.glsl +75 -0
  76. package/transitions/Prisms.glsl +80 -0
  77. package/transitions/Puzzle.glsl +123 -0
  78. package/transitions/Shred.glsl +66 -0
  79. package/transitions/SpiralWipe.glsl +40 -0
  80. package/transitions/Tunnel.glsl +41 -0
  81. package/transitions/TvRoll.glsl +42 -0
  82. package/transitions/TvTurnOff.glsl +46 -0
  83. package/transitions/WhipPan.glsl +49 -0
  84. package/wgsl/ApertureWipe.wgsl +160 -0
  85. package/wgsl/Comb.wgsl +139 -0
  86. package/wgsl/Curtains.wgsl +179 -0
  87. package/wgsl/DiamondWipe.wgsl +94 -0
  88. package/wgsl/DitherDissolve.wgsl +123 -0
  89. package/wgsl/FallOver.wgsl +164 -0
  90. package/wgsl/Fisheye.wgsl +93 -0
  91. package/wgsl/Halftone.wgsl +196 -0
  92. package/wgsl/Honeycomb.wgsl +222 -0
  93. package/wgsl/PaperTear.wgsl +324 -0
  94. package/wgsl/Prisms.wgsl +385 -0
  95. package/wgsl/Puzzle.wgsl +587 -0
  96. package/wgsl/Shred.wgsl +259 -0
  97. package/wgsl/SpiralWipe.wgsl +165 -0
  98. package/wgsl/Tunnel.wgsl +177 -0
  99. package/wgsl/TvRoll.wgsl +165 -0
  100. package/wgsl/TvTurnOff.wgsl +196 -0
  101. package/wgsl/WhipPan.wgsl +177 -0
@@ -0,0 +1,66 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image is cut into paper strips that drop away at uneven speeds, tilting as they fall, revealing the incoming image
4
+ // Tags: slices, stripes, vertical, shadow
5
+
6
+ // @range(4, 60, 1) Number of strips
7
+ uniform int strips; // = 20
8
+ // @range(0, 0.8) Spread of the strips' start times, as a part of the transition
9
+ uniform float stagger; // = 0.4
10
+ // @range(0, 0.3) Largest tilt of a falling strip, in radians
11
+ uniform float tilt; // = 0.1
12
+ // @range(0, 1) Darkness of the strips' cut edges and of their shadow
13
+ uniform float shadow; // = 0.5
14
+
15
+ // a deterministic random value in [0, 1) for each strip
16
+ float hash (float n) {
17
+ n = fract(n * 0.1031);
18
+ n *= n + 33.33;
19
+ n *= n + n;
20
+ return fract(n);
21
+ }
22
+
23
+ vec4 transition (vec2 uv) {
24
+ float n = float(strips);
25
+ float w = ratio / n; // strip width, in frame heights
26
+ vec2 q = vec2(uv.x * ratio, uv.y);
27
+ vec4 color = getToColor(uv);
28
+ float cover = -1.0;
29
+ float shade = 0.0;
30
+ // narrow strips tilt less, so that they only reach over their neighbours
31
+ float maxTilt = min(tilt, 2.0 * w);
32
+ for (int d = -3; d <= 3; d++) {
33
+ float i = floor(uv.x * n) + float(d);
34
+ if (i < 0.0 || i > n - 1.0) continue;
35
+ // about one strip in five starts right away
36
+ float delay = stagger * max(0.0, 1.25 * hash(i + 1.0) - 0.25);
37
+ float speed = 1.0 + 0.5 * hash(i + 71.0);
38
+ float t = clamp((progress - delay) / (1.0 - delay), 0.0, 1.0);
39
+ // a pull then a fall that speeds up, long enough to leave the frame
40
+ float fall = (0.4 * t + 0.6 * t * t) * (1.0 + w * (0.5 + tilt)) * speed;
41
+ float angle = maxTilt * (2.0 * hash(i + 37.0) - 1.0) * t;
42
+ // the strips are cut apart as they start moving
43
+ float lift = min(1.0, 8.0 * t);
44
+ float gap = 0.06 * w * lift;
45
+ // position in the strip's own frame, relative to its center
46
+ vec2 v = q - vec2((i + 0.5) * w, 0.5 - fall);
47
+ float ca = cos(angle), sa = sin(angle);
48
+ vec2 l = vec2(ca * v.x + sa * v.y, ca * v.y - sa * v.x);
49
+ vec2 edge = vec2(0.5 * w - gap, 0.5) - abs(l);
50
+ // a soft shadow, cast down and right by the moving strip
51
+ vec2 so = abs(l - lift * vec2(0.15 * w, -0.25 * w)) - vec2(0.5 * w - gap, 0.5);
52
+ shade = max(shade, lift * (1.0 - smoothstep(0.0, 0.5 * w, max(so.x, so.y))));
53
+ if (min(edge.x, edge.y) >= 0.0 && fall > cover) {
54
+ vec2 p = vec2((i + 0.5) * w + l.x, 0.5 + l.y);
55
+ vec4 img = getFromColor(vec2(p.x / ratio, p.y));
56
+ // darker cut edges
57
+ float cut = lift * (1.0 - smoothstep(0.0, 0.25 * w, edge.x));
58
+ color = vec4(img.rgb * (1.0 - 0.5 * shadow * cut), img.a);
59
+ cover = fall;
60
+ }
61
+ }
62
+ if (cover < 0.0) {
63
+ color = vec4(color.rgb * (1.0 - 0.6 * shadow * shade), color.a);
64
+ }
65
+ return color;
66
+ }
@@ -0,0 +1,40 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: A spiral arm winds out from the center and widens to reveal the incoming image
4
+ // Tags: shape, wipe, radial
5
+
6
+ #define PI 3.141592653589793
7
+
8
+ // @range(2, 8) Number of turns of the spiral
9
+ uniform float turns; // = 3.0
10
+ // @range(0, 0.5) Softness of the arm's edges
11
+ uniform float smoothness; // = 0.05
12
+ // @param Wind clockwise; false winds counterclockwise
13
+ uniform bool clockwise; // = true
14
+
15
+ // Coverage of the arm turn at position s (in turns along the spiral), d away from its middle line
16
+ float arm (float s, float d) {
17
+ // The tip reaches the frame's corners at 60% of the transition, and the whole arm widens until the end
18
+ float end = -0.5 + (turns + 0.5) / 0.6;
19
+ float tip = mix(-0.5, end, progress);
20
+ s = max(s, -0.5);
21
+ float width = sqrt(clamp((tip - s) / max(end - s, 0.001), 0.0, 1.0));
22
+ // Edge softness in arm widths, at least a pixel wide
23
+ float e = smoothness + 0.005 * turns;
24
+ return smoothstep(0.0, e, width * (0.5 + e) - d);
25
+ }
26
+
27
+ vec4 transition (vec2 uv) {
28
+ // Square pixels, normalized so the frame's corners are at distance 1
29
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0) / (0.5 * length(vec2(ratio, 1.0)));
30
+ // Fraction of a turn, starting at the top
31
+ float a = dot(q, q) < 1e-12 ? 0.0 : atan(q.x, q.y) / (2.0 * PI);
32
+ a = fract(clockwise ? a : -a);
33
+ // Radius in turns of the spiral, and the arm turn the point is in
34
+ float w = length(q) * turns - a;
35
+ float n = floor(w);
36
+ float f = w - n;
37
+ // The arm turns around it can overlap it near the edges
38
+ float m = max(arm(n + a, abs(f - 0.5)), max(arm(n + 1.0 + a, 1.5 - f), arm(n - 1.0 + a, f + 0.5)));
39
+ return mix(getFromColor(uv), getToColor(uv), m);
40
+ }
@@ -0,0 +1,41 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The camera flies down a tunnel lined with the outgoing image toward the incoming one, which opens at its far end and grows to fill the frame
4
+ // Tags: zoom, 3d, warp, radial
5
+
6
+ // @range(0.5, 10) How far and fast the camera flies down the tunnel
7
+ uniform float speed; // = 6.0
8
+ // @range(-2, 2) How much the walls spiral as they rush by
9
+ uniform float twist; // = 0.5
10
+
11
+ vec2 rotate(vec2 v, float a) {
12
+ float c = cos(a);
13
+ float s = sin(a);
14
+ return vec2(c * v.x - s * v.y, s * v.x + c * v.y);
15
+ }
16
+
17
+ vec4 transition(vec2 uv) {
18
+ vec2 aspect = vec2(ratio, 1.0);
19
+ vec2 c = (uv - 0.5) * aspect;
20
+ float r = length(c);
21
+ // A tube as wide as the frame's corners runs from the camera to an end wall
22
+ // at depth `far`; the outgoing image is projected onto it from the starting
23
+ // point of view, so it looks flat at first. The camera flies to one unit
24
+ // before the end wall, where the incoming image hangs.
25
+ float R = length(0.5 * aspect);
26
+ float far = 1.0 + speed;
27
+ // the distance to the end wall shrinks geometrically, so the end grows evenly
28
+ float e = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.7);
29
+ float d = pow(far, 1.0 - e);
30
+ float t = far - d; // distance flown
31
+ // the end wall covers the center of the view, the tube's walls the rest
32
+ float k = r * d < R ? d / far : R / (R + t * r); // image scale at that point
33
+ float a = twist * min(t * r / R, t / d); // spiral, continuous at the end wall
34
+ vec4 walls = getFromColor(0.5 + rotate(c * k, a) / aspect);
35
+ walls.rgb *= 0.4 + 0.6 * sqrt(k); // darker where the walls are close
36
+ // the incoming image opens in the end wall
37
+ float open = smoothstep(0.0, 0.6, progress);
38
+ vec2 q = 0.5 + (uv - 0.5) * d / max(open, 1e-4);
39
+ vec2 inside = step(0.0, q) * step(q, vec2(1.0));
40
+ return mix(walls, getToColor(q), inside.x * inside.y * step(r * d, R));
41
+ }
@@ -0,0 +1,42 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image rolls faster and faster, like an old TV losing its vertical hold, then the roll slows down and locks on the incoming image
4
+ // Tags: retro, vertical, scanlines
5
+
6
+ // @range(1, 8) Number of frames that roll by
7
+ uniform int rolls; // = 3
8
+ // @range(0, 0.5) Height of the bar between the frames
9
+ uniform float barHeight; // = 0.12
10
+ // @color Color of the bar between the frames
11
+ uniform vec4 barColor; // = vec4(0.0, 0.0, 0.0, 1.0)
12
+
13
+ // The rolling picture at a vertical position y, in frames of height 1 + barHeight
14
+ vec4 picture(vec2 uv, float y, float m) {
15
+ float period = 1.0 + barHeight;
16
+ y = mod(y, period);
17
+ if (y > 1.0) return barColor;
18
+ vec2 q = vec2(uv.x, y);
19
+ return mix(getFromColor(q), getToColor(q), m);
20
+ }
21
+
22
+ vec4 transition(vec2 uv) {
23
+ float period = 1.0 + barHeight;
24
+ // smooth start and stop: the picture locks again after a whole number of frames
25
+ float s = progress * progress * (3.0 - 2.0 * progress);
26
+ float offset = period * fract(float(rolls) * s);
27
+ float speed = 4.0 * progress * (1.0 - progress); // 0 at both ends, 1 in the middle
28
+ float m = smoothstep(0.42, 0.58, progress); // the channel changes at full speed
29
+ // the horizontal sync wobbles a little
30
+ vec2 p = uv + vec2(0.004 * speed * sin(uv.y * 9.0 + progress * 30.0), 0.0);
31
+ // vertical motion blur
32
+ vec4 c = vec4(0.0);
33
+ for (int i = 0; i < 5; i++) {
34
+ c += picture(p, p.y + offset - 0.0015 * float(rolls) * speed * float(i), m);
35
+ }
36
+ c /= 5.0;
37
+ // scanlines and a flickering brightness
38
+ float scan = 0.5 + 0.5 * sin(uv.y * 400.0);
39
+ float flicker = 0.08 * (0.5 + 0.5 * sin(progress * 97.0));
40
+ c.rgb *= 1.0 - speed * (0.08 * scan + flicker);
41
+ return c;
42
+ }
@@ -0,0 +1,46 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image collapses into a glowing line and a dot, like an old TV turned off, then the incoming image powers on from the dot
4
+ // Tags: retro, vertical, flash
5
+
6
+ // @color Color of the switched-off screen
7
+ uniform vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0)
8
+ // @range(0, 2) Strength of the glow around the line and the dot
9
+ uniform float glow; // = 1.0
10
+
11
+ vec4 getColor(vec2 uv, bool isFrom) {
12
+ return isFrom ? getFromColor(uv) : getToColor(uv);
13
+ }
14
+
15
+ // The screen at a time t of its power-off: 0 is the full image, 1 is off
16
+ vec4 screen(vec2 uv, float t, bool isFrom) {
17
+ float collapse = smoothstep(0.0, 0.4, t); // the image squeezes into a line
18
+ float shrink = smoothstep(0.3, 0.65, t); // the line shrinks into a dot
19
+ float fade = 0.4 * smoothstep(0.75, 1.0, t); // the dot dims
20
+ float radius = 0.01 * (1.0 - fade);
21
+ // half size of the picture, in height units (x is scaled by ratio)
22
+ vec2 size = vec2(mix(0.5 * ratio, radius, shrink), mix(0.5, radius, collapse));
23
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
24
+ vec2 q = clamp(0.5 + 0.5 * p / size, 0.0, 1.0);
25
+ vec4 c = getColor(q, isFrom);
26
+ // the squeezed picture gets brighter and burns to white
27
+ float white = smoothstep(0.4, 1.0, collapse);
28
+ vec4 light = vec4(mix(min(c.rgb * (1.0 + 2.0 * collapse), 1.0), vec3(1.0), white), c.a);
29
+ // soft edges, outside the picture so that t = 0 is the exact image
30
+ vec2 d = abs(p) - size;
31
+ float dist = length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
32
+ float inside = clamp(1.0 - dist / 0.004, 0.0, 1.0);
33
+ // a glow around the line, tinted by the center of the picture, then warm white around the dot
34
+ vec4 mid = getColor(vec2(0.5), isFrom);
35
+ vec4 halo = vec4(mix(mix(mid.rgb, vec3(1.0), 0.7), vec3(1.0, 0.92, 0.8), shrink), mid.a);
36
+ float h = 1.0 - exp(-2.0 * glow * white * exp(-max(dist, 0.0) / (0.02 + 0.04 * shrink)));
37
+ vec4 col = mix(color, halo, h * (1.0 - fade));
38
+ return mix(col, light, inside * (1.0 - fade));
39
+ }
40
+
41
+ vec4 transition(vec2 uv) {
42
+ if (progress < 0.5) {
43
+ return screen(uv, 2.0 * progress, true);
44
+ }
45
+ return screen(uv, 2.0 - 2.0 * progress, false);
46
+ }
@@ -0,0 +1,49 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: A fast camera pan that streaks both images with motion blur, the incoming one arriving from the opposite side
4
+ // Tags: slide, motion-blur, directional
5
+
6
+ // @param Direction in which the images move
7
+ uniform vec2 direction; // = vec2(-1.0, 0.0)
8
+ // @range(0, 1) Length of the motion blur at full speed
9
+ uniform float blur; // = 0.4
10
+
11
+ const int SAMPLES = 24;
12
+
13
+ // The panned strip: the outgoing image, then the incoming one behind it
14
+ vec4 strip(vec2 q, vec2 d) {
15
+ vec2 qt = q + d;
16
+ // which side of the seam between the two images (works for diagonals too)
17
+ if (dot(q - 0.5, -d) < 0.5 * dot(d, d)) {
18
+ return getFromColor(clamp(q, 0.0, 1.0));
19
+ }
20
+ return getToColor(clamp(qt, 0.0, 1.0));
21
+ }
22
+
23
+ float rand(vec2 co) {
24
+ return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
25
+ }
26
+
27
+ vec4 transition(vec2 uv) {
28
+ vec2 d = sign(direction);
29
+ // ease in and out: slow start, whip in the middle, slow landing
30
+ float p = progress;
31
+ float h = 1.0 - abs(2.0 * p - 1.0); // 0 at both ends, 1 in the middle
32
+ // mostly cubic, with a bit of linear so that it starts moving at once
33
+ float e = 0.5 * h * (0.1 + 0.9 * h * h);
34
+ float pos = p < 0.5 ? e : 1.0 - e;
35
+ float len = blur * h * (0.1 + 2.7 * h * h) / 2.8; // follows the speed
36
+
37
+ vec2 q = uv - d * pos;
38
+ // average along the motion, jittered to hide the sample steps
39
+ float jitter = rand(uv);
40
+ vec3 color = vec3(0.0);
41
+ float alpha = 0.0;
42
+ for (int i = 0; i < SAMPLES; i++) {
43
+ float t = (float(i) + jitter) / float(SAMPLES) - 0.5;
44
+ vec4 c = strip(q + d * t * len, d);
45
+ color += c.rgb * c.a;
46
+ alpha += c.a;
47
+ }
48
+ return vec4(color / max(alpha, 1e-5), alpha / float(SAMPLES));
49
+ }
@@ -0,0 +1,160 @@
1
+ // ApertureWipe — WGSL, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ApertureWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A camera aperture opens its turning blades to reveal the incoming image
5
+ // Bindings and uniform layout: see the gl-transitions package README
6
+
7
+ struct Uniforms {
8
+ progress: f32,
9
+ ratio: f32,
10
+ blades: i32,
11
+ rotation: f32,
12
+ shadow: f32,
13
+ }
14
+
15
+ @group(0) @binding(2)
16
+ var _from: texture_2d<f32>;
17
+ @group(0) @binding(1)
18
+ var _sampler: sampler;
19
+ @group(0) @binding(3)
20
+ var _to: texture_2d<f32>;
21
+ @group(0) @binding(0)
22
+ var<uniform> uniforms: Uniforms;
23
+ var<private> _fragColor: vec4<f32>;
24
+ var<private> _uv_1: vec2<f32>;
25
+
26
+ fn getToColor(uv: ptr<function, vec2<f32>>) -> vec4<f32> {
27
+ let _e30 = (*uv)[0u];
28
+ let _e32 = (*uv)[1u];
29
+ let _e35 = textureSampleLevel(_to, _sampler, vec2<f32>(_e30, (1f - _e32)), 0f);
30
+ return _e35;
31
+ }
32
+
33
+ fn getFromColor(uv_1: ptr<function, vec2<f32>>) -> vec4<f32> {
34
+ let _e30 = (*uv_1)[0u];
35
+ let _e32 = (*uv_1)[1u];
36
+ let _e35 = textureSampleLevel(_from, _sampler, vec2<f32>(_e30, (1f - _e32)), 0f);
37
+ return _e35;
38
+ }
39
+
40
+ fn transition(uv_2: ptr<function, vec2<f32>>) -> vec4<f32> {
41
+ var q: vec2<f32>;
42
+ var n: f32;
43
+ var sector: f32;
44
+ var turn: f32;
45
+ var r: f32;
46
+ var dist: f32;
47
+ var seam: f32;
48
+ var i: i32;
49
+ var angle: f32;
50
+ var d: f32;
51
+ var next: f32;
52
+ var s: f32;
53
+ var rim: f32;
54
+ var shade: f32;
55
+ var from_: vec4<f32>;
56
+ var param: vec2<f32>;
57
+ var param_1: vec2<f32>;
58
+
59
+ let _e46 = (*uv_2);
60
+ let _e50 = uniforms.ratio;
61
+ let _e54 = uniforms.ratio;
62
+ q = (((_e46 - vec2(0.5f)) * vec2<f32>(_e50, 1f)) / vec2((0.5f * length(vec2<f32>(_e54, 1f)))));
63
+ let _e61 = uniforms.blades;
64
+ n = clamp(f32(_e61), 3f, 12f);
65
+ let _e64 = n;
66
+ sector = (6.2831855f / _e64);
67
+ let _e67 = uniforms.rotation;
68
+ let _e70 = uniforms.progress;
69
+ turn = (radians(_e67) * _e70);
70
+ let _e73 = uniforms.progress;
71
+ r = mix(-0.006f, 1.006f, _e73);
72
+ dist = -1000f;
73
+ seam = 0f;
74
+ i = 0i;
75
+ loop {
76
+ let _e75 = i;
77
+ if (_e75 < 12i) {
78
+ let _e77 = i;
79
+ let _e79 = n;
80
+ if (f32(_e77) < _e79) {
81
+ let _e81 = turn;
82
+ let _e82 = i;
83
+ let _e84 = sector;
84
+ angle = (_e81 + (f32(_e82) * _e84));
85
+ let _e87 = q;
86
+ let _e88 = angle;
87
+ let _e90 = angle;
88
+ let _e94 = r;
89
+ d = (dot(_e87, vec2<f32>(cos(_e88), sin(_e90))) - _e94);
90
+ let _e96 = q;
91
+ let _e97 = angle;
92
+ let _e98 = sector;
93
+ let _e101 = angle;
94
+ let _e102 = sector;
95
+ let _e107 = r;
96
+ next = (dot(_e96, vec2<f32>(cos((_e97 + _e98)), sin((_e101 + _e102)))) - _e107);
97
+ let _e109 = dist;
98
+ let _e110 = d;
99
+ dist = max(_e109, _e110);
100
+ let _e112 = d;
101
+ s = (1f - smoothstep(0f, 0.12f, -(_e112)));
102
+ let _e116 = seam;
103
+ let _e117 = d;
104
+ let _e120 = s;
105
+ let _e122 = s;
106
+ let _e124 = next;
107
+ seam = max(_e116, ((((1f - smoothstep(0f, 0.006f, _e117)) * _e120) * _e122) * smoothstep(0f, 0.006f, _e124)));
108
+ }
109
+ continue;
110
+ } else {
111
+ break;
112
+ }
113
+ continuing {
114
+ let _e128 = i;
115
+ i = (_e128 + 1i);
116
+ }
117
+ }
118
+ let _e130 = dist;
119
+ rim = (1f - smoothstep(0f, 0.08f, _e130));
120
+ let _e134 = uniforms.shadow;
121
+ let _e135 = rim;
122
+ let _e136 = rim;
123
+ let _e138 = seam;
124
+ let _e142 = uniforms.progress;
125
+ shade = ((_e134 * max((_e135 * _e136), _e138)) * smoothstep(0f, 0.1f, _e142));
126
+ let _e145 = (*uv_2);
127
+ param = _e145;
128
+ let _e146 = getFromColor((&param));
129
+ from_ = _e146;
130
+ let _e147 = shade;
131
+ let _e149 = from_;
132
+ let _e151 = (_e149.xyz * (1f - _e147));
133
+ from_[0u] = _e151.x;
134
+ from_[1u] = _e151.y;
135
+ from_[2u] = _e151.z;
136
+ let _e158 = from_;
137
+ let _e159 = (*uv_2);
138
+ param_1 = _e159;
139
+ let _e160 = getToColor((&param_1));
140
+ let _e161 = dist;
141
+ return mix(_e158, _e160, vec4((1f - smoothstep(0f, 0.006f, _e161))));
142
+ }
143
+
144
+ fn main_1() {
145
+ var param_2: vec2<f32>;
146
+
147
+ let _e29 = _uv_1;
148
+ param_2 = _e29;
149
+ let _e30 = transition((&param_2));
150
+ _fragColor = _e30;
151
+ return;
152
+ }
153
+
154
+ @fragment
155
+ fn main(@location(0) _uv: vec2<f32>) -> @location(0) vec4<f32> {
156
+ _uv_1 = _uv;
157
+ main_1();
158
+ let _e3 = _fragColor;
159
+ return _e3;
160
+ }
package/wgsl/Comb.wgsl ADDED
@@ -0,0 +1,139 @@
1
+ // Comb — WGSL, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Comb.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The frame is cut into interleaved strips that slide in opposite directions, each pushing the outgoing image out and the incoming one in
5
+ // Bindings and uniform layout: see the gl-transitions package README
6
+
7
+ struct Uniforms {
8
+ progress: f32,
9
+ ratio: f32,
10
+ strips: i32,
11
+ vertical: i32,
12
+ }
13
+
14
+ @group(0) @binding(2)
15
+ var _from: texture_2d<f32>;
16
+ @group(0) @binding(1)
17
+ var _sampler: sampler;
18
+ @group(0) @binding(3)
19
+ var _to: texture_2d<f32>;
20
+ @group(0) @binding(0)
21
+ var<uniform> uniforms: Uniforms;
22
+ var<private> _fragColor: vec4<f32>;
23
+ var<private> _uv_1: vec2<f32>;
24
+
25
+ fn getToColor(uv: ptr<function, vec2<f32>>) -> vec4<f32> {
26
+ let _e20 = (*uv)[0u];
27
+ let _e22 = (*uv)[1u];
28
+ let _e25 = textureSampleLevel(_to, _sampler, vec2<f32>(_e20, (1f - _e22)), 0f);
29
+ return _e25;
30
+ }
31
+
32
+ fn getFromColor(uv_1: ptr<function, vec2<f32>>) -> vec4<f32> {
33
+ let _e20 = (*uv_1)[0u];
34
+ let _e22 = (*uv_1)[1u];
35
+ let _e25 = textureSampleLevel(_from, _sampler, vec2<f32>(_e20, (1f - _e22)), 0f);
36
+ return _e25;
37
+ }
38
+
39
+ fn transition(uv_2: ptr<function, vec2<f32>>) -> vec4<f32> {
40
+ var a: f32;
41
+ var local: f32;
42
+ var b: f32;
43
+ var local_1: f32;
44
+ var dir: f32;
45
+ var t: f32;
46
+ var fa: f32;
47
+ var local_2: vec2<f32>;
48
+ var param: vec2<f32>;
49
+ var ta: f32;
50
+ var local_3: vec2<f32>;
51
+ var param_1: vec2<f32>;
52
+
53
+ let _e32 = uniforms.vertical;
54
+ if (_e32 != 0i) {
55
+ let _e35 = (*uv_2)[1u];
56
+ local = _e35;
57
+ } else {
58
+ let _e37 = (*uv_2)[0u];
59
+ local = _e37;
60
+ }
61
+ let _e38 = local;
62
+ a = _e38;
63
+ let _e40 = uniforms.vertical;
64
+ if (_e40 != 0i) {
65
+ let _e43 = (*uv_2)[0u];
66
+ local_1 = _e43;
67
+ } else {
68
+ let _e45 = (*uv_2)[1u];
69
+ local_1 = _e45;
70
+ }
71
+ let _e46 = local_1;
72
+ b = _e46;
73
+ let _e47 = b;
74
+ let _e49 = uniforms.strips;
75
+ let _e52 = floor((_e47 * f32(_e49)));
76
+ dir = select(-1f, 1f, ((_e52 - (floor((_e52 / 2f)) * 2f)) < 0.5f));
77
+ let _e60 = uniforms.progress;
78
+ let _e62 = uniforms.progress;
79
+ let _e64 = uniforms.progress;
80
+ let _e67 = uniforms.progress;
81
+ t = mix(_e60, ((_e62 * _e64) * (3f - (2f * _e67))), 0.6f);
82
+ let _e72 = a;
83
+ let _e73 = dir;
84
+ let _e74 = t;
85
+ fa = (_e72 - (_e73 * _e74));
86
+ let _e77 = fa;
87
+ let _e79 = fa;
88
+ if ((_e77 >= 0f) && (_e79 <= 1f)) {
89
+ let _e83 = uniforms.vertical;
90
+ if (_e83 != 0i) {
91
+ let _e85 = b;
92
+ let _e86 = fa;
93
+ local_2 = vec2<f32>(_e85, _e86);
94
+ } else {
95
+ let _e88 = fa;
96
+ let _e89 = b;
97
+ local_2 = vec2<f32>(_e88, _e89);
98
+ }
99
+ let _e91 = local_2;
100
+ param = _e91;
101
+ let _e92 = getFromColor((&param));
102
+ return _e92;
103
+ }
104
+ let _e93 = fa;
105
+ let _e94 = dir;
106
+ ta = (_e93 + _e94);
107
+ let _e97 = uniforms.vertical;
108
+ if (_e97 != 0i) {
109
+ let _e99 = b;
110
+ let _e100 = ta;
111
+ local_3 = vec2<f32>(_e99, _e100);
112
+ } else {
113
+ let _e102 = ta;
114
+ let _e103 = b;
115
+ local_3 = vec2<f32>(_e102, _e103);
116
+ }
117
+ let _e105 = local_3;
118
+ param_1 = _e105;
119
+ let _e106 = getToColor((&param_1));
120
+ return _e106;
121
+ }
122
+
123
+ fn main_1() {
124
+ var param_2: vec2<f32>;
125
+
126
+ let _e19 = _uv_1;
127
+ param_2 = _e19;
128
+ let _e20 = transition((&param_2));
129
+ _fragColor = _e20;
130
+ return;
131
+ }
132
+
133
+ @fragment
134
+ fn main(@location(0) _uv: vec2<f32>) -> @location(0) vec4<f32> {
135
+ _uv_1 = _uv;
136
+ main_1();
137
+ let _e3 = _fragColor;
138
+ return _e3;
139
+ }