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.
Files changed (86) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/compatibility.json +244 -0
  3. package/gl-transitions.js +1 -1
  4. package/gl-transitions.json +1 -1
  5. package/glsl3/ArrowWipe.glsl +100 -0
  6. package/glsl3/BlockSlide.glsl +87 -0
  7. package/glsl3/CellDissolve.glsl +91 -0
  8. package/glsl3/Crumple.glsl +173 -0
  9. package/glsl3/HeatHaze.glsl +79 -0
  10. package/glsl3/Hologram.glsl +97 -0
  11. package/glsl3/LiquidFill.glsl +102 -0
  12. package/glsl3/PlasmaDissolve.glsl +51 -0
  13. package/glsl3/RingsWipe.glsl +106 -0
  14. package/glsl3/SawtoothWipe.glsl +73 -0
  15. package/glsl3/SnakeBlockWipe.glsl +40 -0
  16. package/glsl3/Snapshot.glsl +86 -0
  17. package/glsl3/Sphere.glsl +95 -0
  18. package/glsl3/SpiralBlockWipe.glsl +65 -0
  19. package/glsl3/Vortex.glsl +106 -0
  20. package/index.js +1 -1
  21. package/layouts.json +618 -18
  22. package/llms-full.txt +614 -362
  23. package/llms.txt +204 -189
  24. package/msl/ArrowWipe.metal +391 -0
  25. package/msl/BlockSlide.metal +418 -0
  26. package/msl/CellDissolve.metal +374 -0
  27. package/msl/Crumple.metal +766 -0
  28. package/msl/HeatHaze.metal +320 -0
  29. package/msl/Hologram.metal +380 -0
  30. package/msl/LiquidFill.metal +373 -0
  31. package/msl/PlasmaDissolve.metal +178 -0
  32. package/msl/RingsWipe.metal +437 -0
  33. package/msl/SawtoothWipe.metal +310 -0
  34. package/msl/SnakeBlockWipe.metal +216 -0
  35. package/msl/Snapshot.metal +321 -0
  36. package/msl/Sphere.metal +345 -0
  37. package/msl/SpiralBlockWipe.metal +281 -0
  38. package/msl/Vortex.metal +522 -0
  39. package/package.json +1 -1
  40. package/skills/gl-transitions/references/catalog.md +68 -34
  41. package/sksl/ArrowWipe.sksl +111 -0
  42. package/sksl/BlockSlide.sksl +99 -0
  43. package/sksl/CellDissolve.sksl +103 -0
  44. package/sksl/Crumple.sksl +179 -0
  45. package/sksl/HeatHaze.sksl +90 -0
  46. package/sksl/Hologram.sksl +108 -0
  47. package/sksl/LiquidFill.sksl +113 -0
  48. package/sksl/PlasmaDissolve.sksl +64 -0
  49. package/sksl/RingsWipe.sksl +115 -0
  50. package/sksl/SawtoothWipe.sksl +83 -0
  51. package/sksl/SnakeBlockWipe.sksl +53 -0
  52. package/sksl/Snapshot.sksl +98 -0
  53. package/sksl/Sphere.sksl +108 -0
  54. package/sksl/SpiralBlockWipe.sksl +76 -0
  55. package/sksl/Vortex.sksl +116 -0
  56. package/sksl/index.js +1 -1
  57. package/transitions/ArrowWipe.glsl +99 -0
  58. package/transitions/BlockSlide.glsl +86 -0
  59. package/transitions/CellDissolve.glsl +90 -0
  60. package/transitions/Crumple.glsl +172 -0
  61. package/transitions/HeatHaze.glsl +78 -0
  62. package/transitions/Hologram.glsl +96 -0
  63. package/transitions/LiquidFill.glsl +101 -0
  64. package/transitions/PlasmaDissolve.glsl +50 -0
  65. package/transitions/RingsWipe.glsl +105 -0
  66. package/transitions/SawtoothWipe.glsl +72 -0
  67. package/transitions/SnakeBlockWipe.glsl +39 -0
  68. package/transitions/Snapshot.glsl +85 -0
  69. package/transitions/Sphere.glsl +94 -0
  70. package/transitions/SpiralBlockWipe.glsl +64 -0
  71. package/transitions/Vortex.glsl +105 -0
  72. package/wgsl/ArrowWipe.wgsl +352 -0
  73. package/wgsl/BlockSlide.wgsl +384 -0
  74. package/wgsl/CellDissolve.wgsl +323 -0
  75. package/wgsl/Crumple.wgsl +709 -0
  76. package/wgsl/HeatHaze.wgsl +282 -0
  77. package/wgsl/Hologram.wgsl +339 -0
  78. package/wgsl/LiquidFill.wgsl +339 -0
  79. package/wgsl/PlasmaDissolve.wgsl +149 -0
  80. package/wgsl/RingsWipe.wgsl +394 -0
  81. package/wgsl/SawtoothWipe.wgsl +279 -0
  82. package/wgsl/SnakeBlockWipe.wgsl +188 -0
  83. package/wgsl/Snapshot.wgsl +287 -0
  84. package/wgsl/Sphere.wgsl +316 -0
  85. package/wgsl/SpiralBlockWipe.wgsl +250 -0
  86. package/wgsl/Vortex.wgsl +463 -0
@@ -0,0 +1,106 @@
1
+ // Vortex — GLSL ES 3.00, 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
+ // Tags: tiles, spiral, rotation, shatter
6
+
7
+ // @range(4, 40, 1) Number of rows of squares
8
+ uniform int grid; // = 24
9
+ // Center of the tornado
10
+ uniform vec2 center; // = vec2(0.5, 0.5)
11
+ // @range(-4, 4) Turns each square makes around the center as it flies away (negative turns clockwise)
12
+ uniform float spin; // = 1.0
13
+ // @range(0, 1) How randomly the squares leave: 0 from the center outward, 1 in any order
14
+ uniform float randomness; // = 0.2
15
+
16
+ // the squares leave in GROUPS waves, each one flying for DURATION of the transition
17
+ const int GROUPS = 24;
18
+ const float DURATION = 0.25;
19
+ // half width of the antialiased edge of the squares, in frame heights
20
+ const float AA = 0.0015;
21
+ const float TAU = 6.2831853;
22
+
23
+ float hash(vec2 n) {
24
+ return fract(sin(dot(n, vec2(12.9898, 78.233))) * 43758.5453);
25
+ }
26
+
27
+ // the wave a square (by its cell index) leaves with
28
+ int groupOf(vec2 n, float h, vec2 c, float maxR) {
29
+ // only the very corners leave last
30
+ float r = min(length((n + 0.5) * h - c) / (0.85 * maxR), 1.0);
31
+ float key = clamp(mix(r * sqrt(r), hash(n), clamp(randomness, 0.0, 1.0)), 0.0, 0.9999);
32
+ return int(floor(key * float(GROUPS)));
33
+ }
34
+
35
+ // local time of a wave's flight, 0 before it leaves, 1 once it has vanished
36
+ float flight(int g) {
37
+ float delay = float(g) / float(GROUPS) * (1.0 - DURATION);
38
+ return clamp((progress - delay) / DURATION, 0.0, 1.0);
39
+ }
40
+
41
+ vec4 premultiplied(vec4 c) {
42
+ return vec4(c.rgb * c.a, c.a);
43
+ }
44
+
45
+ vec4 transition(vec2 uv) {
46
+ if (progress <= 0.0) return getFromColor(uv);
47
+ if (progress >= 1.0) return getToColor(uv);
48
+
49
+ // measured in square pixels, so the squares stay square
50
+ vec2 aspect = vec2(ratio, 1.0);
51
+ vec2 p = uv * aspect;
52
+ vec2 c = center * aspect;
53
+ float maxR = max(max(length(c), length(c - vec2(ratio, 0.0))), max(length(c - vec2(0.0, 1.0)), length(c - aspect)));
54
+ float h = 1.0 / float(grid < 1 ? 1 : grid);
55
+ // how far a square is pushed away from the center by the end of its flight
56
+ float reach = 0.7 * maxR;
57
+
58
+ // the incoming image, under the squares that have not left yet
59
+ vec2 n0 = floor(p / h);
60
+ vec4 col = flight(groupOf(n0, h, c, maxR)) <= 0.0 ? premultiplied(getFromColor(uv)) : premultiplied(getToColor(uv));
61
+
62
+ // the flying squares, painted from the last wave to leave (lowest) to the first (highest)
63
+ for (int k = 0; k < GROUPS; k++) {
64
+ int g = GROUPS - 1 - k;
65
+ float s = flight(g);
66
+ if (s <= 0.0 || s >= 1.0) continue;
67
+ float e = s * s;
68
+ // like in a tornado, the squares near the eye (the first to leave) spin much faster than
69
+ // the outer ones; all of them orbit before they are flung out
70
+ float angle = spin * TAU * e * 2.0 / (1.0 + 6.0 * float(g) / float(GROUPS));
71
+ float push = reach * e * s;
72
+ // the squares lift toward the viewer, then shrink away
73
+ float size = (1.0 + 0.35 * sin(3.1415927 * s)) * (1.0 - s * s * s);
74
+ float ca = cos(angle);
75
+ float sa = sin(angle);
76
+ mat2 rot = mat2(ca, sa, -sa, ca);
77
+ // undo the wave's spiral to guess which square lands here, then test its neighbors exactly
78
+ vec2 u = (p - c) * rot;
79
+ float ru = length(u);
80
+ vec2 guess = c + (ru > 0.0 ? u / ru : vec2(0.0)) * max(ru - push, 0.0);
81
+ vec2 ng = floor(guess / h);
82
+ for (int j = -1; j <= 1; j++) {
83
+ for (int i = -1; i <= 1; i++) {
84
+ vec2 n = ng + vec2(float(i), float(j));
85
+ if (groupOf(n, h, c, maxR) != g) continue;
86
+ vec2 home = (n + 0.5) * h;
87
+ vec2 rel = home - c;
88
+ float rr = length(rel);
89
+ vec2 dir = rr > 0.0 ? rel / rr : vec2(0.0);
90
+ vec2 pos = c + rot * (dir * (rr + push));
91
+ // each square also tumbles on itself
92
+ float tumble = angle + (hash(n + 17.0) - 0.5) * 3.0 * e * sign(spin);
93
+ float ct = cos(tumble);
94
+ float st = sin(tumble);
95
+ vec2 d = ((p - pos) * mat2(ct, st, -st, ct)) / max(size, 1e-4);
96
+ float edge = 0.5 * h - max(abs(d.x), abs(d.y));
97
+ float cov = clamp(edge * size / (2.0 * AA) + 0.5, 0.0, 1.0);
98
+ vec2 src = home + d;
99
+ if (cov <= 0.0 || src.x < 0.0 || src.y < 0.0 || src.x > ratio || src.y > 1.0) continue;
100
+ vec4 piece = premultiplied(getFromColor(src / aspect)) * cov;
101
+ col = piece + col * (1.0 - piece.a);
102
+ }
103
+ }
104
+ }
105
+ return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
106
+ }