gl-transitions 2.3.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 (106) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/compatibility.json +308 -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/ColorPanelWipe.glsl +75 -0
  9. package/glsl3/Crumple.glsl +173 -0
  10. package/glsl3/EyeBlink.glsl +83 -0
  11. package/glsl3/Gallery.glsl +133 -0
  12. package/glsl3/HeatHaze.glsl +79 -0
  13. package/glsl3/Hologram.glsl +97 -0
  14. package/glsl3/LiquidFill.glsl +102 -0
  15. package/glsl3/PlasmaDissolve.glsl +51 -0
  16. package/glsl3/RingsWipe.glsl +106 -0
  17. package/glsl3/SawtoothWipe.glsl +73 -0
  18. package/glsl3/SnakeBlockWipe.glsl +40 -0
  19. package/glsl3/Snapshot.glsl +86 -0
  20. package/glsl3/Sphere.glsl +95 -0
  21. package/glsl3/SpiralBlockWipe.glsl +65 -0
  22. package/glsl3/VhsTracking.glsl +127 -0
  23. package/glsl3/Vortex.glsl +106 -0
  24. package/index.js +1 -1
  25. package/layouts.json +787 -18
  26. package/llms-full.txt +675 -354
  27. package/llms.txt +204 -185
  28. package/msl/ArrowWipe.metal +391 -0
  29. package/msl/BlockSlide.metal +418 -0
  30. package/msl/CellDissolve.metal +374 -0
  31. package/msl/ColorPanelWipe.metal +314 -0
  32. package/msl/Crumple.metal +766 -0
  33. package/msl/EyeBlink.metal +355 -0
  34. package/msl/Gallery.metal +813 -0
  35. package/msl/HeatHaze.metal +320 -0
  36. package/msl/Hologram.metal +380 -0
  37. package/msl/LiquidFill.metal +373 -0
  38. package/msl/PlasmaDissolve.metal +178 -0
  39. package/msl/RingsWipe.metal +437 -0
  40. package/msl/SawtoothWipe.metal +310 -0
  41. package/msl/SnakeBlockWipe.metal +216 -0
  42. package/msl/Snapshot.metal +321 -0
  43. package/msl/Sphere.metal +345 -0
  44. package/msl/SpiralBlockWipe.metal +281 -0
  45. package/msl/VhsTracking.metal +514 -0
  46. package/msl/Vortex.metal +522 -0
  47. package/package.json +1 -1
  48. package/skills/gl-transitions/references/catalog.md +84 -38
  49. package/sksl/ArrowWipe.sksl +111 -0
  50. package/sksl/BlockSlide.sksl +99 -0
  51. package/sksl/CellDissolve.sksl +103 -0
  52. package/sksl/ColorPanelWipe.sksl +85 -0
  53. package/sksl/Crumple.sksl +179 -0
  54. package/sksl/EyeBlink.sksl +94 -0
  55. package/sksl/Gallery.sksl +139 -0
  56. package/sksl/HeatHaze.sksl +90 -0
  57. package/sksl/Hologram.sksl +108 -0
  58. package/sksl/LiquidFill.sksl +113 -0
  59. package/sksl/PlasmaDissolve.sksl +64 -0
  60. package/sksl/RingsWipe.sksl +115 -0
  61. package/sksl/SawtoothWipe.sksl +83 -0
  62. package/sksl/SnakeBlockWipe.sksl +53 -0
  63. package/sksl/Snapshot.sksl +98 -0
  64. package/sksl/Sphere.sksl +108 -0
  65. package/sksl/SpiralBlockWipe.sksl +76 -0
  66. package/sksl/VhsTracking.sksl +138 -0
  67. package/sksl/Vortex.sksl +116 -0
  68. package/sksl/index.js +1 -1
  69. package/transitions/ArrowWipe.glsl +99 -0
  70. package/transitions/BlockSlide.glsl +86 -0
  71. package/transitions/CellDissolve.glsl +90 -0
  72. package/transitions/ColorPanelWipe.glsl +74 -0
  73. package/transitions/Crumple.glsl +172 -0
  74. package/transitions/EyeBlink.glsl +82 -0
  75. package/transitions/Gallery.glsl +132 -0
  76. package/transitions/HeatHaze.glsl +78 -0
  77. package/transitions/Hologram.glsl +96 -0
  78. package/transitions/LiquidFill.glsl +101 -0
  79. package/transitions/PlasmaDissolve.glsl +50 -0
  80. package/transitions/RingsWipe.glsl +105 -0
  81. package/transitions/SawtoothWipe.glsl +72 -0
  82. package/transitions/SnakeBlockWipe.glsl +39 -0
  83. package/transitions/Snapshot.glsl +85 -0
  84. package/transitions/Sphere.glsl +94 -0
  85. package/transitions/SpiralBlockWipe.glsl +64 -0
  86. package/transitions/VhsTracking.glsl +126 -0
  87. package/transitions/Vortex.glsl +105 -0
  88. package/wgsl/ArrowWipe.wgsl +352 -0
  89. package/wgsl/BlockSlide.wgsl +384 -0
  90. package/wgsl/CellDissolve.wgsl +323 -0
  91. package/wgsl/ColorPanelWipe.wgsl +274 -0
  92. package/wgsl/Crumple.wgsl +709 -0
  93. package/wgsl/EyeBlink.wgsl +308 -0
  94. package/wgsl/Gallery.wgsl +741 -0
  95. package/wgsl/HeatHaze.wgsl +282 -0
  96. package/wgsl/Hologram.wgsl +339 -0
  97. package/wgsl/LiquidFill.wgsl +339 -0
  98. package/wgsl/PlasmaDissolve.wgsl +149 -0
  99. package/wgsl/RingsWipe.wgsl +394 -0
  100. package/wgsl/SawtoothWipe.wgsl +279 -0
  101. package/wgsl/SnakeBlockWipe.wgsl +188 -0
  102. package/wgsl/Snapshot.wgsl +287 -0
  103. package/wgsl/Sphere.wgsl +316 -0
  104. package/wgsl/SpiralBlockWipe.wgsl +250 -0
  105. package/wgsl/VhsTracking.wgsl +462 -0
  106. package/wgsl/Vortex.wgsl +463 -0
@@ -0,0 +1,132 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The camera pulls back from the outgoing image to show it as a slide hanging in a row on a wall in perspective, the row glides along as each slide turns away from the center, and the camera moves back in on the incoming slide until it fills the frame
4
+ // Tags: 3d, perspective, gallery, slide, reflection, directional
5
+
6
+ // @param Way the row moves: 1 brings the incoming slide in from the right, -1 from the left
7
+ uniform float direction; // = 1.0
8
+ // @range(0, 1) How much the slides turn as they leave the center
9
+ uniform float tilt; // = 0.6
10
+ // @range(0, 1) Space between two slides, in slide widths
11
+ uniform float gap; // = 0.15
12
+ // @range(0.2, 3) How far the camera pulls back
13
+ uniform float zoom; // = 2.0
14
+ // @range(0, 1) Strength of the reflection of the slides on the floor
15
+ uniform float reflection; // = 0.3
16
+ // @color Color of the wall and the floor around the slides
17
+ uniform vec4 background; // = vec4(0.07, 0.07, 0.08, 1.0)
18
+
19
+ const float FOCAL = 1.6; // distance from the camera to a slide when it fills the frame
20
+ const float MAX_ANGLE = 1.4; // turn of a side slide at tilt = 1, in radians
21
+ const float NEIGHBOUR = 0.3; // how visible the repeats beyond the two images are
22
+ const float AA = 0.002; // width of the antialiased slide edges, in frame heights
23
+
24
+ vec4 premultiply(vec4 c) {
25
+ return vec4(c.rgb * c.a, c.a);
26
+ }
27
+
28
+ // how far slide k sits from the center of the view, in slides, clamped to one slide on each side
29
+ float offset(float k, float camQ, float spacing) {
30
+ return clamp((k * spacing - camQ) / spacing, -1.0, 1.0);
31
+ }
32
+
33
+ // the ray o + t d against slide k of the row (a plane turned around its vertical axis):
34
+ // returns (u, v, t, coverage), coverage antialiased over aa frame heights at the slide's edges
35
+ vec4 slideHit(vec3 o, vec3 d, float k, float s, float camQ, float spacing, float aa) {
36
+ // a side slide turns away from the center: its outer edge goes back into the wall
37
+ float a = -s * MAX_ANGLE * tilt * offset(k, camQ, spacing);
38
+ vec3 c = vec3(s * k * spacing, 0.0, 0.0);
39
+ vec3 tg = vec3(cos(a), 0.0, sin(a)); // along the slide, left to right
40
+ vec3 n = vec3(-tg.z, 0.0, tg.x);
41
+ float dn = dot(d, n);
42
+ if (abs(dn) < 1e-5) return vec4(0.0, 0.0, -1.0, 0.0);
43
+ float t = dot(c - o, n) / dn;
44
+ vec3 q = o + d * t - c;
45
+ float lx = dot(q, tg) + 0.5 * ratio;
46
+ float ly = q.y + 0.5;
47
+ // distances to the edges on screen: along the slide, how fast its local x moves with the screen x
48
+ float jx = abs(t * (tg.x - dot(d, tg) * n.x / dn));
49
+ float ex = min(lx, ratio - lx) / max(jx, 1e-6);
50
+ float ey = min(ly, 1.0 - ly) / max(t, 1e-6);
51
+ float cov = t > 0.0 ? clamp(0.5 + min(ex, ey) / aa, 0.0, 1.0) : 0.0;
52
+ return vec4(lx / ratio, ly, t, cov);
53
+ }
54
+
55
+ // the premultiplied color of slide k where the ray hit it; the row is from (k = 0), to (k = 1),
56
+ // and faint repeats beyond them on their own side; refl > 0 is the strength of its reflection
57
+ vec4 slideColor(vec4 h, float k, float camQ, float spacing, float refl, vec4 bg) {
58
+ if (h.w <= 0.0) return vec4(0.0);
59
+ vec2 st = clamp(h.xy, 0.0, 1.0);
60
+ vec4 c = premultiply(k < 0.5 ? getFromColor(st) : getToColor(st));
61
+ // turned away from the light as it turns away from the center
62
+ c.rgb *= 1.0 - 0.3 * tilt * abs(offset(k, camQ, spacing));
63
+ if (k < -0.5 || k > 1.5) c = mix(bg, c, NEIGHBOUR);
64
+ // the reflection fades out below the bottom of the slide
65
+ float f = refl > 0.0 ? refl * (1.0 - smoothstep(0.0, 0.6, st.y)) : 1.0;
66
+ return c * (h.w * f);
67
+ }
68
+
69
+ // how much the slides cover along the ray, whatever their images' alpha
70
+ float sceneCover(vec3 o, vec3 d, float s, float camQ, float spacing, float aa) {
71
+ float kc = floor(s * (o.x + d.x * o.z / -d.z) / spacing + 0.5);
72
+ float w0 = slideHit(o, d, kc - 1.0, s, camQ, spacing, aa).w;
73
+ float w1 = slideHit(o, d, kc, s, camQ, spacing, aa).w;
74
+ float w2 = slideHit(o, d, kc + 1.0, s, camQ, spacing, aa).w;
75
+ return 1.0 - (1.0 - w0) * (1.0 - w1) * (1.0 - w2);
76
+ }
77
+
78
+ // the slides seen along the ray, composited back to front (premultiplied)
79
+ vec4 scene(vec3 o, vec3 d, float s, float camQ, float spacing, float aa, float refl, vec4 bg) {
80
+ // the slide in front of which the ray crosses the wall, and its two neighbours
81
+ float wallQ = s * (o.x + d.x * o.z / -d.z);
82
+ float kc = floor(wallQ / spacing + 0.5);
83
+ vec4 h0 = slideHit(o, d, kc - 1.0, s, camQ, spacing, aa);
84
+ vec4 h1 = slideHit(o, d, kc, s, camQ, spacing, aa);
85
+ vec4 h2 = slideHit(o, d, kc + 1.0, s, camQ, spacing, aa);
86
+ vec4 c0 = slideColor(h0, kc - 1.0, camQ, spacing, refl, bg);
87
+ vec4 c1 = slideColor(h1, kc, camQ, spacing, refl, bg);
88
+ vec4 c2 = slideColor(h2, kc + 1.0, camQ, spacing, refl, bg);
89
+ float t0 = h0.w > 0.0 ? h0.z : 1e6;
90
+ float t1 = h1.w > 0.0 ? h1.z : 1e6;
91
+ float t2 = h2.w > 0.0 ? h2.z : 1e6;
92
+ // sort far to near: t0 >= t1 >= t2
93
+ vec4 tc;
94
+ float tt;
95
+ if (t0 < t1) { tc = c0; c0 = c1; c1 = tc; tt = t0; t0 = t1; t1 = tt; }
96
+ if (t1 < t2) { tc = c1; c1 = c2; c2 = tc; tt = t1; t1 = t2; t2 = tt; }
97
+ if (t0 < t1) { tc = c0; c0 = c1; c1 = tc; }
98
+ vec4 col = c0;
99
+ col = c1 + col * (1.0 - c1.a);
100
+ col = c2 + col * (1.0 - c2.a);
101
+ return col;
102
+ }
103
+
104
+ vec4 transition(vec2 uv) {
105
+ float p = progress;
106
+ float s = direction < 0.0 ? -1.0 : 1.0;
107
+ float spacing = ratio * (1.0 + gap);
108
+ // the camera pulls back, glides along the row, and moves back in
109
+ float back = smoothstep(0.0, 0.42, p) * (1.0 - smoothstep(0.58, 1.0, p));
110
+ float m = clamp((p - 0.18) / 0.64, 0.0, 1.0);
111
+ float glide = m * m * m * (m * (m * 6.0 - 15.0) + 10.0);
112
+ float camQ = spacing * glide;
113
+ vec3 o = vec3(s * camQ, 0.0, FOCAL * (1.0 + zoom * back));
114
+ vec3 d = vec3((uv - 0.5) * vec2(ratio, 1.0), -FOCAL);
115
+ float amount = min(1.0, 40.0 * back);
116
+ float aa = max(AA * amount, 1e-6);
117
+ vec4 bg = premultiply(background);
118
+
119
+ vec4 col = scene(o, d, s, camQ, spacing, aa, 0.0, bg);
120
+ if (col.a < 1.0) {
121
+ vec4 under = bg;
122
+ // the floor, below the slides, reflects them
123
+ if (d.y < 0.0 && reflection > 0.0) {
124
+ vec4 r = scene(vec3(o.x, -1.0 - o.y, o.z), vec3(d.x, -d.y, d.z), s, camQ, spacing, aa, reflection, bg);
125
+ under = r + bg * (1.0 - r.a);
126
+ }
127
+ // the wall shows around the slides, and only fades in behind their transparent parts,
128
+ // so that the images keep their own alpha at the start and the end
129
+ col += under * (mix(1.0, amount, sceneCover(o, d, s, camQ, spacing, aa)) * (1.0 - col.a));
130
+ }
131
+ return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
132
+ }
@@ -0,0 +1,78 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: Shimmering heat waves rise through the frame, strongest at the bottom, making the outgoing image wobble like the air over hot asphalt; the incoming image shows through the haze and settles as it calms
4
+ // Tags: distort, heat, shimmer, noise, organic, blend
5
+
6
+ // @range(0, 0.1) How far the haze bends the image, in frame heights (the strongest waves bend it about 1.5 times as far)
7
+ uniform float strength; // = 0.04
8
+ // @range(1, 12) Size of the heat waves: more, smaller ones with a larger value
9
+ uniform float scale; // = 6.0
10
+ // @range(0, 6) How fast the heat waves rise
11
+ uniform float speed; // = 2.0
12
+
13
+ // reflects coordinates that leave the frame back into it, so the edges do not smear
14
+ vec2 mirror(vec2 v) {
15
+ return 1.0 - abs(1.0 - mod(v, 2.0));
16
+ }
17
+
18
+ float hash12(vec2 v) {
19
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
20
+ v3 += dot(v3, v3.yzx + 33.33);
21
+ return fract((v3.x + v3.y) * v3.z);
22
+ }
23
+
24
+ float vnoise(vec2 v) {
25
+ vec2 i = floor(v);
26
+ vec2 f = fract(v);
27
+ f = f * f * (3.0 - 2.0 * f);
28
+ return mix(
29
+ mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
30
+ mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
31
+ f.y
32
+ );
33
+ }
34
+
35
+ // centered on 0, within [-1.5, 1.5]
36
+ float fbm(vec2 v) {
37
+ float sum = 0.0;
38
+ float amp = 0.5;
39
+ for (int i = 0; i < 4; i++) {
40
+ sum += amp * vnoise(v);
41
+ v = mat2(1.6, 1.2, -1.2, 1.6) * v + 5.3;
42
+ amp *= 0.5;
43
+ }
44
+ return (sum / 0.9375 - 0.5) * 3.0;
45
+ }
46
+
47
+ vec4 transition(vec2 uv) {
48
+ if (progress <= 0.0) return getFromColor(uv);
49
+ if (progress >= 1.0) return getToColor(uv);
50
+
51
+ const float PI = 3.141592653589793;
52
+ float p = progress;
53
+ // the haze builds up then calms down
54
+ float amount = sin(PI * p);
55
+ // the waves scroll upward and slowly churn as they rise
56
+ float t = p * speed;
57
+ // in square pixels, then squashed vertically into the thin bands of rising air
58
+ vec2 q = vec2(uv.x * ratio, uv.y * 2.5) * scale;
59
+ q.y -= t * scale;
60
+ // the bands are bent by a slower, larger turbulence so they do not stay straight
61
+ vec2 w = vec2(fbm(q * 0.35 + vec2(0.0, t)), fbm(q * 0.35 + vec2(7.1, -t)));
62
+ q += 1.5 * w;
63
+ vec2 offset = vec2(fbm(q), 0.5 * fbm(q + vec2(3.7, 1.9)));
64
+ // the hot air is near the ground: strongest at the bottom, fainter at the top
65
+ float ground = mix(1.0, 0.3, uv.y);
66
+ offset *= strength * amount * ground * vec2(1.0 / ratio, 1.0);
67
+
68
+ vec2 d = mirror(uv + offset);
69
+ // the images swap in the thick of the haze
70
+ float m = smoothstep(0.3, 0.7, p);
71
+ if (m <= 0.0) return getFromColor(d);
72
+ if (m >= 1.0) return getToColor(d);
73
+ vec4 a = getFromColor(d);
74
+ vec4 b = getToColor(d);
75
+ // mixed premultiplied, so transparent images do not bleed their color
76
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
77
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
78
+ }
@@ -0,0 +1,96 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The outgoing image turns into a flickering hologram (blue by default) with scanlines and jittering rows, breaks up, and the hologram resolves into the incoming image in full color
4
+ // Tags: hologram, sci-fi, scanlines, flicker, glitch
5
+
6
+ // @color Color of the hologram
7
+ uniform vec3 tint; // = vec3(0.2, 0.75, 1.0)
8
+ // @color Color behind the hologram, seen between its scanlines and where it breaks up
9
+ uniform vec4 background; // = vec4(0.0, 0.02, 0.05, 1.0)
10
+ // @range(20, 300) Number of scanlines over the frame height
11
+ uniform float scanlines; // = 150.0
12
+ // @range(0, 0.2) How far rows of the hologram jump sideways, relative to the frame width
13
+ uniform float jitter; // = 0.04
14
+ // @range(0, 1) Strength of the flicker and of the rows that drop out
15
+ uniform float flicker; // = 0.6
16
+
17
+ const float PI = 3.14159265;
18
+ // steps per transition of the flicker and the jitter
19
+ const float STEPS = 32.0;
20
+
21
+ float hash(vec2 p) {
22
+ p = fract(p * vec2(443.897, 441.423));
23
+ p += dot(p, p.yx + 19.19);
24
+ return fract((p.x + p.y) * p.x);
25
+ }
26
+
27
+ float luma(vec3 c) {
28
+ return dot(c, vec3(0.299, 0.587, 0.114));
29
+ }
30
+
31
+ vec4 premultiplied(vec4 c) {
32
+ return vec4(c.rgb * c.a, c.a);
33
+ }
34
+
35
+ // the image the hologram shows: rows switch from the outgoing image to the incoming one
36
+ // while the hologram breaks up
37
+ vec4 source(vec2 uv, float m) {
38
+ return m > 0.5 ? getToColor(uv) : getFromColor(uv);
39
+ }
40
+
41
+ vec4 transition(vec2 uv) {
42
+ if (progress <= 0.0) return getFromColor(uv);
43
+ if (progress >= 1.0) return getToColor(uv);
44
+
45
+ float p = progress;
46
+ // how much of the hologram shows, and how broken up it is (peaking mid-transition)
47
+ float h = smoothstep(0.0, 0.3, p) * (1.0 - smoothstep(0.7, 1.0, p));
48
+ float b = smoothstep(0.0, 1.0, 1.0 - abs(p - 0.5) / 0.22);
49
+ float f = floor(p * STEPS);
50
+
51
+ // rows of the hologram jump sideways, more while it breaks up
52
+ float band = floor(uv.y * 36.0);
53
+ float jump = step(1.0 - (0.2 + 0.6 * b) * h, hash(vec2(band, f)));
54
+ float offset = (hash(vec2(band, f + 0.37)) - 0.5) * 2.0 * jitter * jump * (0.3 + 0.7 * b);
55
+ offset += sin(uv.y * 23.0 + f * 1.7) * 0.0015 * h;
56
+ vec2 q = uv + vec2(offset, 0.0);
57
+
58
+ // when each row of the hologram switches to the incoming image
59
+ float m = step(hash(vec2(floor(uv.y * 24.0), 7.0)), (p - 0.35) / 0.3);
60
+
61
+ // the hologram: the luma of the image in the tint, with colored fringes
62
+ // (sampled inside the frame, the fringes weighted by the alpha of their texels)
63
+ vec4 c = source(clamp(q, 0.0, 1.0), m);
64
+ vec2 dx = vec2(0.003 + 0.01 * b, 0.0);
65
+ float l = luma(c.rgb);
66
+ vec4 cr = source(clamp(q + dx, 0.0, 1.0), m);
67
+ vec4 cb = source(clamp(q - dx, 0.0, 1.0), m);
68
+ float lr = luma(cr.rgb) * cr.a;
69
+ float lb = luma(cb.rgb) * cb.a;
70
+ vec3 g = smoothstep(0.05, 0.9, vec3(lr, l, lb));
71
+ // the brightest parts burn toward white
72
+ vec3 holo = tint * (0.06 + 1.25 * g) + 0.45 * g * g * g;
73
+ // brighter scan band rolling down
74
+ float roll = fract(uv.y + 2.0 * p);
75
+ holo += tint * 0.35 * smoothstep(0.85, 1.0, roll) * (1.0 - smoothstep(0.98, 1.0, roll));
76
+ holo = clamp(holo, 0.0, 1.0);
77
+ // nothing outside the image where a row jumped out of the frame
78
+ float inside = step(0.0, q.x) * step(q.x, 1.0);
79
+
80
+ // opacity of the hologram: scanlines, flicker and missing rows
81
+ float lines = 0.5 + 0.5 * sin((uv.y * scanlines - p * 6.0) * 2.0 * PI);
82
+ float vis = mix(1.0, 0.15 + 0.85 * lines, h);
83
+ vis *= 1.0 - flicker * (0.25 + 0.75 * b) * hash(vec2(f, 3.1)) * h;
84
+ float gap = step(hash(vec2(floor(uv.y * 90.0), f + 0.71)), flicker * 0.45 * b);
85
+ vis *= 1.0 - gap;
86
+ vec4 layer = vec4(holo, c.a * vis * inside);
87
+ // the hologram over its background, transparent where neither the image nor the
88
+ // hologram is
89
+ vec4 plain = premultiplied(source(uv, m));
90
+ vec4 back = premultiplied(vec4(background.rgb, background.a * max(plain.a, layer.a)));
91
+ vec4 holoColor = premultiplied(layer) + back * (1.0 - layer.a);
92
+
93
+ // the images in full color, then the hologram over them
94
+ vec4 o = mix(plain, holoColor, h);
95
+ return o.a > 0.0 ? vec4(o.rgb / o.a, o.a) : vec4(0.0);
96
+ }
@@ -0,0 +1,101 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The incoming image rises over the outgoing one like liquid filling a glass, its surface sloshing in waves, lit by a bright meniscus line, bending the image just below it, with a few bubbles rising through it
4
+ // Tags: liquid, water, wave, directional, reveal
5
+
6
+ // @param Direction the liquid rises toward
7
+ uniform vec2 direction; // = vec2(0.0, 1.0)
8
+ // @range(0, 0.3) Height of the waves on the surface, in frame heights
9
+ uniform float amplitude; // = 0.06
10
+ // @range(0.5, 6) Number of waves across the frame
11
+ uniform float waves; // = 1.5
12
+ // @color Color of the bright line along the surface and the rims of the bubbles (its alpha is its strength)
13
+ uniform vec4 highlight; // = vec4(1.0, 1.0, 1.0, 0.8)
14
+ // @range(0, 0.1) How much the incoming image is bent just below the surface
15
+ uniform float refraction; // = 0.03
16
+ // @range(0, 1) How many bubbles rise through the liquid
17
+ uniform float bubbles; // = 0.5
18
+
19
+ const float PI = 3.141592653589793;
20
+ // half width of the antialiased edges, in frame heights
21
+ const float AA = 0.0015;
22
+ // width of the meniscus line, in frame heights
23
+ const float LINE = 0.006;
24
+ // size of the cells the bubbles are scattered in, in frame heights
25
+ const float CELL = 0.08;
26
+
27
+ float hash (vec2 p) {
28
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
29
+ p3 += dot(p3, p3.yzx + 33.33);
30
+ return fract((p3.x + p3.y) * p3.z);
31
+ }
32
+
33
+ // height of the surface above its mean level at x (across the frame, from -1 to 1), between -1 and 1:
34
+ // a slosh from side to side and a smaller wave running along it
35
+ float surface (float x, float t) {
36
+ float k = PI * max(waves, 0.01);
37
+ return 0.6 * sin(k * x + 0.5 * PI) * cos(2.0 * PI * 1.3 * t)
38
+ + 0.4 * sin(1.7 * k * x - 9.0 * t + 1.3);
39
+ }
40
+
41
+ vec4 transition (vec2 uv) {
42
+ vec4 a = getFromColor(uv);
43
+ if (progress <= 0.0) return a;
44
+ if (progress >= 1.0) return getToColor(uv);
45
+
46
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(0.0, 1.0);
47
+ vec2 across = vec2(-dir.y, dir.x);
48
+ // measured in square pixels, so the waves and bubbles are not stretched
49
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
50
+ // half extents of the frame along the direction and across it
51
+ float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
52
+ float w = 0.5 * (abs(dir.y) * ratio + abs(dir.x));
53
+ float d = dot(p, dir);
54
+ float x = dot(p, across);
55
+ float t = progress;
56
+ // the liquid moves most in the middle of the transition and settles at the ends
57
+ float stir = sin(PI * t);
58
+ float amp = max(amplitude, 0.0) * (0.35 + 0.65 * stir);
59
+ // the surface starts fully below the frame and ends fully above it, waves and meniscus included
60
+ float margin = max(amplitude, 0.0) + 2.0 * LINE + AA;
61
+ float mean = mix(-e - margin, e + margin, mix(t, t * t * (3.0 - 2.0 * t), 0.5));
62
+ float level = mean + amp * surface(x / w, t);
63
+ // > 0 below the surface, in the liquid
64
+ float depth = level - d;
65
+ float m = smoothstep(-AA, AA, depth);
66
+
67
+ // the incoming image is bent by the waves just below the surface, less and less deeper down
68
+ float bend = refraction * stir * exp(-max(depth, 0.0) / 0.06);
69
+ vec2 offset = bend * (dir * sin(18.0 * x - 7.0 * t) + across * cos(13.0 * x + 5.0 * t));
70
+ vec4 b = getToColor(clamp(uv + offset / vec2(ratio, 1.0), 0.0, 1.0));
71
+
72
+ // bubbles rise in columns through the liquid, carried up with it and rising faster still
73
+ float glow = 0.0;
74
+ float rise = mean + 0.5 * t;
75
+ vec2 bq = vec2(x, d - rise) / CELL;
76
+ vec2 cell = floor(bq);
77
+ float hs = hash(cell + 7.1);
78
+ float r = (0.12 + 0.18 * hash(cell + 3.7)) * stir;
79
+ float px = AA / CELL;
80
+ if (hs < bubbles * 0.6 && r > px) {
81
+ // placed so that it stays inside its cell, wobble and soft edge included
82
+ vec2 c = cell + 0.5 + (0.42 - r - px) * (vec2(hash(cell + 1.3), hash(cell + 9.4)) * 2.0 - 1.0);
83
+ // a slight wobble as it rises
84
+ c.x += 0.08 * sin(6.0 * t + 6.28 * hs);
85
+ float dist = length(bq - c);
86
+ // its rim, and a small glint near its top
87
+ float rim = smoothstep(0.7 * r - px, 0.7 * r + px, dist) * (1.0 - smoothstep(r - px, r + px, dist));
88
+ float glint = 1.0 - smoothstep(0.25 * r - px, 0.25 * r + px, length(bq - c - 0.45 * r * vec2(-0.7, 0.7)));
89
+ // only in the liquid, and fading out as it nears the surface
90
+ glow = max(rim * 0.6, glint) * smoothstep(0.0, 0.05, depth) * stir;
91
+ }
92
+ // the meniscus: a bright line along the surface, on the liquid side
93
+ float line = 1.0 - smoothstep(LINE - AA, LINE + AA, abs(depth - LINE));
94
+ line += 0.35 * stir * exp(-max(depth, 0.0) / 0.03) * m;
95
+ float light = highlight.a * clamp(max(line, glow), 0.0, 1.0) * (0.4 + 0.6 * stir);
96
+ b.rgb = mix(b.rgb, highlight.rgb, light);
97
+
98
+ // mixed premultiplied, so transparent images do not bleed their color
99
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
100
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
101
+ }
@@ -0,0 +1,50 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: A flowing plasma of sine waves, as in the old demos, draws moving bands through which the incoming image spreads like tendrils, with a glowing edge
4
+ // Tags: wipe, plasma, organic, glow
5
+
6
+ // @range(0.5, 10) Size of the plasma: higher values make more, thinner bands
7
+ uniform float scale; // = 3.0
8
+ // @range(0, 0.5) Softness of the band edges
9
+ uniform float smoothness; // = 0.1
10
+ // @range(0, 1) How much the plasma flows during the transition (at most 1, so a revealed area never goes back)
11
+ uniform float flow; // = 1.0
12
+ // @color Color of the glow along the edges
13
+ uniform vec3 edgeColor; // = vec3(1.0, 0.45, 0.9)
14
+ // @range(0, 2) Strength of the glow along the edges
15
+ uniform float edgeStrength; // = 0.6
16
+
17
+ const float PI = 3.14159265;
18
+
19
+ vec4 transition(vec2 uv) {
20
+ vec4 a = getFromColor(uv);
21
+ vec4 b = getToColor(uv);
22
+ if (progress <= 0.0) return a;
23
+ if (progress >= 1.0) return b;
24
+
25
+ // measured in square pixels, so the waves are not stretched
26
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0) * max(scale, 0.0) * 2.0 * PI;
27
+ // the phase of the waves; the folded plasma below then changes by at most 0.9 * flow per
28
+ // unit of progress, slower than the threshold, so the reveal never goes back
29
+ float t = clamp(flow, 0.0, 1.0) * progress * 0.5;
30
+ // the classic plasma: sines of x, y, a diagonal and the distance to an off-center point
31
+ float v = sin(p.x * 0.6 + t)
32
+ + sin(p.y * 0.8 - t * 0.8)
33
+ + sin((p.x * 0.5 + p.y * 0.7) * 0.7 + t * 0.6)
34
+ + sin(length(p - vec2(0.15, -0.1) * max(scale, 0.0) * 2.0 * PI) * 0.9 - t * 1.2);
35
+ // folded into bands in [0, 1]
36
+ v = abs(fract(v * 0.25 + 0.5) * 2.0 - 1.0);
37
+
38
+ // the soft edge is fully below every band at the start and above every band at the end
39
+ float s = max(smoothness, 0.001);
40
+ float threshold = mix(-s, 1.0 + s, progress);
41
+ // > 0 where the incoming image shows
42
+ float m = 1.0 - smoothstep(threshold - s, threshold + s, v);
43
+
44
+ // mixed premultiplied, so transparent images do not bleed their color
45
+ vec4 col = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
46
+ if (col.a <= 0.0) return vec4(0.0);
47
+ // a light along the edge, adding nothing to the alpha
48
+ float glow = 4.0 * m * (1.0 - m) * max(edgeStrength, 0.0);
49
+ return vec4(col.rgb / col.a + edgeColor * glow, col.a);
50
+ }
@@ -0,0 +1,105 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: Concentric rings ripple out from the center and, one after another, each sweeps around like a clock hand in the opposite direction of its neighbors to reveal the incoming image, or fills across its width, with optional colored borders between the rings
4
+ // Tags: wipe, circle, radial, rings, clock
5
+
6
+ // @range(1, 20, 1) Number of rings, from the center to the farthest corner
7
+ uniform int count; // = 6
8
+ // @param Center of the rings, in texture coordinates
9
+ uniform vec2 center; // = vec2(0.5, 0.5)
10
+ // @range(0, 1) Delay between the starts of two rings: 0 moves them all together, 1 starts each one when the previous one is done
11
+ uniform float stagger; // = 0.5
12
+ // @param Each ring fills across its width, outward and inward in turn, instead of sweeping around
13
+ uniform bool radial; // = false
14
+ // @range(0, 0.05) Width of the borders between the rings while they move, in frame heights (0 disables them)
15
+ uniform float borderWidth; // = 0.008
16
+ // @color Color of the borders between the rings
17
+ uniform vec4 borderColor; // = vec4(1.0, 1.0, 1.0, 1.0)
18
+ // @range(0, 0.1) Softness of the edges
19
+ uniform float smoothness; // = 0.004
20
+
21
+ const float PI = 3.141592653589793;
22
+ // half width of the antialiased edge, in frame heights
23
+ const float AA = 0.0015;
24
+
25
+ // progress of ring i, from 0 (not started) to 1 (done), each ring lasting d and starting
26
+ // k * d after the previous one
27
+ float ringProgress(float i, float k, float d, float t) {
28
+ return clamp((t - i * k * d) / d, 0.0, 1.0);
29
+ }
30
+
31
+ // how much ring i, of width w and progress lp, shows the incoming image at radius rad and
32
+ // turn a (0 to 1)
33
+ float ringMask(float i, float lp, float w, float rad, float a, float s) {
34
+ bool odd = mod(i, 2.0) > 0.5;
35
+ if (radial) {
36
+ // the filled part grows across the ring, from its inner edge or from its outer one,
37
+ // starting and ending a soft edge past the ring; measured within the ring, so a ring
38
+ // that has not started does not leak into its neighbor's antialiased boundary
39
+ float e = s / w;
40
+ float f = mix(-e, 1.0 + e, lp);
41
+ float x = clamp((rad - i * w) / w, 0.0, 1.0);
42
+ float dist = (odd ? f - (1.0 - x) : f - x) * w;
43
+ return smoothstep(-s, s, dist);
44
+ }
45
+ // the filled part is a growing arc from the top, clockwise on even rings and
46
+ // counterclockwise on odd ones; both of its ends are soft, and it starts empty and
47
+ // ends full, wrapping around, by a soft edge measured along the circle (no shorter than
48
+ // the softness itself near the center, so the center is not left half blended)
49
+ float aa = odd ? 1.0 - a : a;
50
+ float arc = 2.0 * PI * max(rad, s);
51
+ float e = s / arc;
52
+ float lo = mix(e, -e, lp);
53
+ float hi = mix(-e, 1.0 + e, lp);
54
+ float dist = max(min(aa - lo, hi - aa), min(aa - 1.0 - lo, hi - aa + 1.0));
55
+ return smoothstep(-s, s, dist * arc);
56
+ }
57
+
58
+ vec4 transition(vec2 uv) {
59
+ vec4 a = getFromColor(uv);
60
+ vec4 b = getToColor(uv);
61
+ if (progress <= 0.0) return a;
62
+ if (progress >= 1.0) return b;
63
+
64
+ float n = float(count < 1 ? 1 : count);
65
+ // measured in square pixels, so the rings are round
66
+ vec2 p = (uv - center) * vec2(ratio, 1.0);
67
+ // the rings reach the farthest corner
68
+ vec2 far = max(center, 1.0 - center) * vec2(ratio, 1.0);
69
+ float R = length(far) + AA;
70
+ float w = R / n;
71
+ float rad = length(p);
72
+ float turn = rad > 0.0 ? fract(atan(p.x, p.y) / (2.0 * PI)) : 0.0;
73
+ float s = max(min(smoothness, 0.25 * w), AA);
74
+ float t = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.35);
75
+ float k = clamp(stagger, 0.0, 1.0);
76
+ float d = 1.0 / (1.0 + k * (n - 1.0));
77
+
78
+ // blend the two rings on either side of the nearest boundary, so it is antialiased
79
+ float j = floor(rad / w + 0.5);
80
+ float inner = clamp(j - 1.0, 0.0, n - 1.0);
81
+ float outer = clamp(j, 0.0, n - 1.0);
82
+ float li = ringProgress(inner, k, d, t);
83
+ float lo = ringProgress(outer, k, d, t);
84
+ float m = mix(
85
+ ringMask(inner, li, w, rad, turn, s),
86
+ ringMask(outer, lo, w, rad, turn, s),
87
+ smoothstep(-AA, AA, rad - j * w)
88
+ );
89
+
90
+ // mixed premultiplied, so transparent images do not bleed their color
91
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
92
+
93
+ // the border between two rings shows from when the inner one starts until the outer one
94
+ // is done, without dimming when one hands over to the other
95
+ if (borderWidth > 0.0 && j >= 1.0 && j <= n - 1.0) {
96
+ float on = min(1.0, 4.0 * li * (1.0 - lo));
97
+ // never wider than the ring, and thinner than the antialiasing only by fading out
98
+ float hw = min(0.5 * borderWidth, 0.5 * w - AA);
99
+ float line = (1.0 - smoothstep(hw - AA, hw + AA, abs(rad - j * w)))
100
+ * min(1.0, borderWidth / (2.0 * AA));
101
+ float o = borderColor.a * line * on;
102
+ c = vec4(borderColor.rgb * o, o) + c * (1.0 - o);
103
+ }
104
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
105
+ }
@@ -0,0 +1,72 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // 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
4
+ // Tags: wipe, shape, directional, zigzag
5
+
6
+ // @param Direction the toothed edge moves toward (with jaws, the axis along which the two edges part)
7
+ uniform vec2 direction; // = vec2(1.0, 0.0)
8
+ // @range(1, 40, 1) Number of teeth along the edge
9
+ uniform int teeth; // = 8
10
+ // @range(0, 3) Length of the teeth, relative to their width
11
+ uniform float depth; // = 1.0
12
+ // @param Two toothed edges part from the middle instead of one sweeping across
13
+ uniform bool jaws; // = false
14
+ // @range(0, 0.1) Softness of the edge
15
+ uniform float smoothness; // = 0.004
16
+
17
+ // half width of the antialiased edge, in frame heights
18
+ const float AA = 0.0015;
19
+
20
+ // signed distance to a zigzag line of period w and peak-to-peak height h, centered on y = 0,
21
+ // its tips pointing up at x = 0; positive above it
22
+ float zigzag(vec2 q, float w, float h) {
23
+ // fold into half a tooth: the slope from the bottom of a notch to the tip of a tooth
24
+ float x = abs(fract(q.x / w) - 0.5) * w;
25
+ vec2 a = vec2(0.0, -0.5 * h);
26
+ vec2 ab = vec2(0.5 * w, h);
27
+ vec2 aq = vec2(x, q.y) - a;
28
+ float d = length(aq - ab * clamp(dot(aq, ab) / dot(ab, ab), 0.0, 1.0));
29
+ return q.y > h * (2.0 * x / w - 0.5) ? d : -d;
30
+ }
31
+
32
+ vec4 transition(vec2 uv) {
33
+ vec4 a = getFromColor(uv);
34
+ vec4 b = getToColor(uv);
35
+ if (progress <= 0.0) return a;
36
+ if (progress >= 1.0) return b;
37
+
38
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
39
+ // measured in square pixels, so the teeth are not stretched
40
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
41
+ // half extents of the frame along the direction and across it
42
+ float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
43
+ float w = 0.5 * (abs(dir.y) * ratio + abs(dir.x));
44
+ float period = 2.0 * w / float(teeth < 1 ? 1 : teeth);
45
+ // position across the edge, with the notches on the sides of the frame so that it shows
46
+ // whole teeth, and along the direction
47
+ vec2 q = vec2(dot(p, vec2(-dir.y, dir.x)) + w + 0.5 * period, dot(p, dir));
48
+ float h = max(depth, 0.0) * period;
49
+ // the soft edge never gets wide enough to blur small teeth away
50
+ float s = max(min(smoothness, 0.25 * period), AA);
51
+ float t = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.35);
52
+
53
+ float d;
54
+ if (jaws) {
55
+ // the two edges are the same zigzag, interlocked at the start (crossed by the soft
56
+ // edge, measured across the slopes of the teeth), then moving apart until each one
57
+ // has left the frame on its side
58
+ float overlap = s * sqrt(1.0 + 4.0 * h * h / (period * period));
59
+ float o = mix(-overlap, e + 0.5 * h + s, t);
60
+ d = max(zigzag(q - vec2(0.0, o), period, h), -zigzag(q + vec2(0.0, o), period, h));
61
+ } else {
62
+ // the edge starts fully ahead of the frame and ends fully past it
63
+ float c = mix(-e - 0.5 * h - s, e + 0.5 * h + s, t);
64
+ d = zigzag(q - vec2(0.0, c), period, h);
65
+ }
66
+ // > 0 where the incoming image shows
67
+ float m = 1.0 - smoothstep(-s, s, d);
68
+
69
+ // mixed premultiplied, so transparent images do not bleed their color
70
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
71
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
72
+ }
@@ -0,0 +1,39 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // 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
4
+ // Tags: wipe, blocks, grid, zigzag
5
+
6
+ // @param Number of blocks (columns, rows)
7
+ uniform ivec2 grid; // = ivec2(8, 6)
8
+ // @param Wind down the columns instead of along the rows
9
+ uniform bool vertical; // = false
10
+ // @range(0, 4) How long each block takes to fade in, in turns of one block (0 switches it at once)
11
+ uniform float smoothness; // = 0.5
12
+
13
+ vec4 transition(vec2 uv) {
14
+ vec4 a = getFromColor(uv);
15
+ vec4 b = getToColor(uv);
16
+ if (progress <= 0.0) return a;
17
+ if (progress >= 1.0) return b;
18
+
19
+ vec2 g = max(vec2(grid), 1.0);
20
+ // block coordinates from the top left corner
21
+ vec2 cell = min(floor(vec2(uv.x, 1.0 - uv.y) * g), g - 1.0);
22
+ // the snake runs along the rows, or along the columns when vertical
23
+ float lines = vertical ? g.x : g.y;
24
+ float len = vertical ? g.y : g.x;
25
+ float line = vertical ? cell.x : cell.y;
26
+ float pos = vertical ? cell.y : cell.x;
27
+ // every other line runs backward
28
+ if (mod(line, 2.0) > 0.5) pos = len - 1.0 - pos;
29
+ float order = line * len + pos;
30
+
31
+ // block k fades in from k to k + w, on a timeline from 0 to n - 1 + w
32
+ float n = lines * len;
33
+ float w = max(smoothness, 0.001);
34
+ float m = clamp((progress * (n - 1.0 + w) - order) / w, 0.0, 1.0);
35
+
36
+ // mixed premultiplied, so transparent images do not bleed their color
37
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
38
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
39
+ }