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,67 @@
1
+ // Shred — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Shred.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image is cut into paper strips that drop away at uneven speeds, tilting as they fall, revealing the incoming image
5
+ // Tags: slices, stripes, vertical, shadow
6
+
7
+ // @range(4, 60, 1) Number of strips
8
+ uniform int strips; // = 20
9
+ // @range(0, 0.8) Spread of the strips' start times, as a part of the transition
10
+ uniform float stagger; // = 0.4
11
+ // @range(0, 0.3) Largest tilt of a falling strip, in radians
12
+ uniform float tilt; // = 0.1
13
+ // @range(0, 1) Darkness of the strips' cut edges and of their shadow
14
+ uniform float shadow; // = 0.5
15
+
16
+ // a deterministic random value in [0, 1) for each strip
17
+ float hash (float n) {
18
+ n = fract(n * 0.1031);
19
+ n *= n + 33.33;
20
+ n *= n + n;
21
+ return fract(n);
22
+ }
23
+
24
+ vec4 transition (vec2 uv) {
25
+ float n = float(strips);
26
+ float w = ratio / n; // strip width, in frame heights
27
+ vec2 q = vec2(uv.x * ratio, uv.y);
28
+ vec4 color = getToColor(uv);
29
+ float cover = -1.0;
30
+ float shade = 0.0;
31
+ // narrow strips tilt less, so that they only reach over their neighbours
32
+ float maxTilt = min(tilt, 2.0 * w);
33
+ for (int d = -3; d <= 3; d++) {
34
+ float i = floor(uv.x * n) + float(d);
35
+ if (i < 0.0 || i > n - 1.0) continue;
36
+ // about one strip in five starts right away
37
+ float delay = stagger * max(0.0, 1.25 * hash(i + 1.0) - 0.25);
38
+ float speed = 1.0 + 0.5 * hash(i + 71.0);
39
+ float t = clamp((progress - delay) / (1.0 - delay), 0.0, 1.0);
40
+ // a pull then a fall that speeds up, long enough to leave the frame
41
+ float fall = (0.4 * t + 0.6 * t * t) * (1.0 + w * (0.5 + tilt)) * speed;
42
+ float angle = maxTilt * (2.0 * hash(i + 37.0) - 1.0) * t;
43
+ // the strips are cut apart as they start moving
44
+ float lift = min(1.0, 8.0 * t);
45
+ float gap = 0.06 * w * lift;
46
+ // position in the strip's own frame, relative to its center
47
+ vec2 v = q - vec2((i + 0.5) * w, 0.5 - fall);
48
+ float ca = cos(angle), sa = sin(angle);
49
+ vec2 l = vec2(ca * v.x + sa * v.y, ca * v.y - sa * v.x);
50
+ vec2 edge = vec2(0.5 * w - gap, 0.5) - abs(l);
51
+ // a soft shadow, cast down and right by the moving strip
52
+ vec2 so = abs(l - lift * vec2(0.15 * w, -0.25 * w)) - vec2(0.5 * w - gap, 0.5);
53
+ shade = max(shade, lift * (1.0 - smoothstep(0.0, 0.5 * w, max(so.x, so.y))));
54
+ if (min(edge.x, edge.y) >= 0.0 && fall > cover) {
55
+ vec2 p = vec2((i + 0.5) * w + l.x, 0.5 + l.y);
56
+ vec4 img = getFromColor(vec2(p.x / ratio, p.y));
57
+ // darker cut edges
58
+ float cut = lift * (1.0 - smoothstep(0.0, 0.25 * w, edge.x));
59
+ color = vec4(img.rgb * (1.0 - 0.5 * shadow * cut), img.a);
60
+ cover = fall;
61
+ }
62
+ }
63
+ if (cover < 0.0) {
64
+ color = vec4(color.rgb * (1.0 - 0.6 * shadow * shade), color.a);
65
+ }
66
+ return color;
67
+ }
@@ -0,0 +1,41 @@
1
+ // SpiralWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SpiralWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A spiral arm winds out from the center and widens to reveal the incoming image
5
+ // Tags: shape, wipe, radial
6
+
7
+ #define PI 3.141592653589793
8
+
9
+ // @range(2, 8) Number of turns of the spiral
10
+ uniform float turns; // = 3.0
11
+ // @range(0, 0.5) Softness of the arm's edges
12
+ uniform float smoothness; // = 0.05
13
+ // @param Wind clockwise; false winds counterclockwise
14
+ uniform bool clockwise; // = true
15
+
16
+ // Coverage of the arm turn at position s (in turns along the spiral), d away from its middle line
17
+ float arm (float s, float d) {
18
+ // The tip reaches the frame's corners at 60% of the transition, and the whole arm widens until the end
19
+ float end = -0.5 + (turns + 0.5) / 0.6;
20
+ float tip = mix(-0.5, end, progress);
21
+ s = max(s, -0.5);
22
+ float width = sqrt(clamp((tip - s) / max(end - s, 0.001), 0.0, 1.0));
23
+ // Edge softness in arm widths, at least a pixel wide
24
+ float e = smoothness + 0.005 * turns;
25
+ return smoothstep(0.0, e, width * (0.5 + e) - d);
26
+ }
27
+
28
+ vec4 transition (vec2 uv) {
29
+ // Square pixels, normalized so the frame's corners are at distance 1
30
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0) / (0.5 * length(vec2(ratio, 1.0)));
31
+ // Fraction of a turn, starting at the top
32
+ float a = dot(q, q) < 1e-12 ? 0.0 : atan(q.x, q.y) / (2.0 * PI);
33
+ a = fract(clockwise ? a : -a);
34
+ // Radius in turns of the spiral, and the arm turn the point is in
35
+ float w = length(q) * turns - a;
36
+ float n = floor(w);
37
+ float f = w - n;
38
+ // The arm turns around it can overlap it near the edges
39
+ 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)));
40
+ return mix(getFromColor(uv), getToColor(uv), m);
41
+ }
@@ -0,0 +1,42 @@
1
+ // Tunnel — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Tunnel.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // 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
5
+ // Tags: zoom, 3d, warp, radial
6
+
7
+ // @range(0.5, 10) How far and fast the camera flies down the tunnel
8
+ uniform float speed; // = 6.0
9
+ // @range(-2, 2) How much the walls spiral as they rush by
10
+ uniform float twist; // = 0.5
11
+
12
+ vec2 rotate(vec2 v, float a) {
13
+ float c = cos(a);
14
+ float s = sin(a);
15
+ return vec2(c * v.x - s * v.y, s * v.x + c * v.y);
16
+ }
17
+
18
+ vec4 transition(vec2 uv) {
19
+ vec2 aspect = vec2(ratio, 1.0);
20
+ vec2 c = (uv - 0.5) * aspect;
21
+ float r = length(c);
22
+ // A tube as wide as the frame's corners runs from the camera to an end wall
23
+ // at depth `far`; the outgoing image is projected onto it from the starting
24
+ // point of view, so it looks flat at first. The camera flies to one unit
25
+ // before the end wall, where the incoming image hangs.
26
+ float R = length(0.5 * aspect);
27
+ float far = 1.0 + speed;
28
+ // the distance to the end wall shrinks geometrically, so the end grows evenly
29
+ float e = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.7);
30
+ float d = pow(far, 1.0 - e);
31
+ float t = far - d; // distance flown
32
+ // the end wall covers the center of the view, the tube's walls the rest
33
+ float k = r * d < R ? d / far : R / (R + t * r); // image scale at that point
34
+ float a = twist * min(t * r / R, t / d); // spiral, continuous at the end wall
35
+ vec4 walls = getFromColor(0.5 + rotate(c * k, a) / aspect);
36
+ walls.rgb *= 0.4 + 0.6 * sqrt(k); // darker where the walls are close
37
+ // the incoming image opens in the end wall
38
+ float open = smoothstep(0.0, 0.6, progress);
39
+ vec2 q = 0.5 + (uv - 0.5) * d / max(open, 1e-4);
40
+ vec2 inside = step(0.0, q) * step(q, vec2(1.0));
41
+ return mix(walls, getToColor(q), inside.x * inside.y * step(r * d, R));
42
+ }
@@ -0,0 +1,43 @@
1
+ // TvRoll — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/TvRoll.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // 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
5
+ // Tags: retro, vertical, scanlines
6
+
7
+ // @range(1, 8) Number of frames that roll by
8
+ uniform int rolls; // = 3
9
+ // @range(0, 0.5) Height of the bar between the frames
10
+ uniform float barHeight; // = 0.12
11
+ // @color Color of the bar between the frames
12
+ uniform vec4 barColor; // = vec4(0.0, 0.0, 0.0, 1.0)
13
+
14
+ // The rolling picture at a vertical position y, in frames of height 1 + barHeight
15
+ vec4 picture(vec2 uv, float y, float m) {
16
+ float period = 1.0 + barHeight;
17
+ y = mod(y, period);
18
+ if (y > 1.0) return barColor;
19
+ vec2 q = vec2(uv.x, y);
20
+ return mix(getFromColor(q), getToColor(q), m);
21
+ }
22
+
23
+ vec4 transition(vec2 uv) {
24
+ float period = 1.0 + barHeight;
25
+ // smooth start and stop: the picture locks again after a whole number of frames
26
+ float s = progress * progress * (3.0 - 2.0 * progress);
27
+ float offset = period * fract(float(rolls) * s);
28
+ float speed = 4.0 * progress * (1.0 - progress); // 0 at both ends, 1 in the middle
29
+ float m = smoothstep(0.42, 0.58, progress); // the channel changes at full speed
30
+ // the horizontal sync wobbles a little
31
+ vec2 p = uv + vec2(0.004 * speed * sin(uv.y * 9.0 + progress * 30.0), 0.0);
32
+ // vertical motion blur
33
+ vec4 c = vec4(0.0);
34
+ for (int i = 0; i < 5; i++) {
35
+ c += picture(p, p.y + offset - 0.0015 * float(rolls) * speed * float(i), m);
36
+ }
37
+ c /= 5.0;
38
+ // scanlines and a flickering brightness
39
+ float scan = 0.5 + 0.5 * sin(uv.y * 400.0);
40
+ float flicker = 0.08 * (0.5 + 0.5 * sin(progress * 97.0));
41
+ c.rgb *= 1.0 - speed * (0.08 * scan + flicker);
42
+ return c;
43
+ }
@@ -0,0 +1,47 @@
1
+ // TvTurnOff — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/TvTurnOff.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // 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
5
+ // Tags: retro, vertical, flash
6
+
7
+ // @color Color of the switched-off screen
8
+ uniform vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0)
9
+ // @range(0, 2) Strength of the glow around the line and the dot
10
+ uniform float glow; // = 1.0
11
+
12
+ vec4 getColor(vec2 uv, bool isFrom) {
13
+ return isFrom ? getFromColor(uv) : getToColor(uv);
14
+ }
15
+
16
+ // The screen at a time t of its power-off: 0 is the full image, 1 is off
17
+ vec4 screen(vec2 uv, float t, bool isFrom) {
18
+ float collapse = smoothstep(0.0, 0.4, t); // the image squeezes into a line
19
+ float shrink = smoothstep(0.3, 0.65, t); // the line shrinks into a dot
20
+ float fade = 0.4 * smoothstep(0.75, 1.0, t); // the dot dims
21
+ float radius = 0.01 * (1.0 - fade);
22
+ // half size of the picture, in height units (x is scaled by ratio)
23
+ vec2 size = vec2(mix(0.5 * ratio, radius, shrink), mix(0.5, radius, collapse));
24
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
25
+ vec2 q = clamp(0.5 + 0.5 * p / size, 0.0, 1.0);
26
+ vec4 c = getColor(q, isFrom);
27
+ // the squeezed picture gets brighter and burns to white
28
+ float white = smoothstep(0.4, 1.0, collapse);
29
+ vec4 light = vec4(mix(min(c.rgb * (1.0 + 2.0 * collapse), 1.0), vec3(1.0), white), c.a);
30
+ // soft edges, outside the picture so that t = 0 is the exact image
31
+ vec2 d = abs(p) - size;
32
+ float dist = length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
33
+ float inside = clamp(1.0 - dist / 0.004, 0.0, 1.0);
34
+ // a glow around the line, tinted by the center of the picture, then warm white around the dot
35
+ vec4 mid = getColor(vec2(0.5), isFrom);
36
+ vec4 halo = vec4(mix(mix(mid.rgb, vec3(1.0), 0.7), vec3(1.0, 0.92, 0.8), shrink), mid.a);
37
+ float h = 1.0 - exp(-2.0 * glow * white * exp(-max(dist, 0.0) / (0.02 + 0.04 * shrink)));
38
+ vec4 col = mix(color, halo, h * (1.0 - fade));
39
+ return mix(col, light, inside * (1.0 - fade));
40
+ }
41
+
42
+ vec4 transition(vec2 uv) {
43
+ if (progress < 0.5) {
44
+ return screen(uv, 2.0 * progress, true);
45
+ }
46
+ return screen(uv, 2.0 - 2.0 * progress, false);
47
+ }
@@ -0,0 +1,50 @@
1
+ // WhipPan — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/WhipPan.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A fast camera pan that streaks both images with motion blur, the incoming one arriving from the opposite side
5
+ // Tags: slide, motion-blur, directional
6
+
7
+ // @param Direction in which the images move
8
+ uniform vec2 direction; // = vec2(-1.0, 0.0)
9
+ // @range(0, 1) Length of the motion blur at full speed
10
+ uniform float blur; // = 0.4
11
+
12
+ const int SAMPLES = 24;
13
+
14
+ // The panned strip: the outgoing image, then the incoming one behind it
15
+ vec4 strip(vec2 q, vec2 d) {
16
+ vec2 qt = q + d;
17
+ // which side of the seam between the two images (works for diagonals too)
18
+ if (dot(q - 0.5, -d) < 0.5 * dot(d, d)) {
19
+ return getFromColor(clamp(q, 0.0, 1.0));
20
+ }
21
+ return getToColor(clamp(qt, 0.0, 1.0));
22
+ }
23
+
24
+ float rand(vec2 co) {
25
+ return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
26
+ }
27
+
28
+ vec4 transition(vec2 uv) {
29
+ vec2 d = sign(direction);
30
+ // ease in and out: slow start, whip in the middle, slow landing
31
+ float p = progress;
32
+ float h = 1.0 - abs(2.0 * p - 1.0); // 0 at both ends, 1 in the middle
33
+ // mostly cubic, with a bit of linear so that it starts moving at once
34
+ float e = 0.5 * h * (0.1 + 0.9 * h * h);
35
+ float pos = p < 0.5 ? e : 1.0 - e;
36
+ float len = blur * h * (0.1 + 2.7 * h * h) / 2.8; // follows the speed
37
+
38
+ vec2 q = uv - d * pos;
39
+ // average along the motion, jittered to hide the sample steps
40
+ float jitter = rand(uv);
41
+ vec3 color = vec3(0.0);
42
+ float alpha = 0.0;
43
+ for (int i = 0; i < SAMPLES; i++) {
44
+ float t = (float(i) + jitter) / float(SAMPLES) - 0.5;
45
+ vec4 c = strip(q + d * t * len, d);
46
+ color += c.rgb * c.a;
47
+ alpha += c.a;
48
+ }
49
+ return vec4(color / max(alpha, 1e-5), alpha / float(SAMPLES));
50
+ }