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,113 @@
1
+ // LiquidFill — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/LiquidFill.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // 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
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 amplitude;
18
+
19
+ uniform float waves;
20
+
21
+ uniform vec4 highlight;
22
+
23
+ uniform float refraction;
24
+
25
+ uniform float bubbles;
26
+
27
+ const float PI = 3.141592653589793;
28
+
29
+ const float AA = 0.0015;
30
+
31
+ const float LINE = 0.006;
32
+
33
+ const float CELL = 0.08;
34
+
35
+ float hash (vec2 p) {
36
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
37
+ p3 += dot(p3, p3.yzx + 33.33);
38
+ return fract((p3.x + p3.y) * p3.z);
39
+ }
40
+
41
+ float surface (float x, float t) {
42
+ float k = PI * max(waves, 0.01);
43
+ return 0.6 * sin(k * x + 0.5 * PI) * cos(2.0 * PI * 1.3 * t)
44
+ + 0.4 * sin(1.7 * k * x - 9.0 * t + 1.3);
45
+ }
46
+
47
+ vec4 transition (vec2 uv) {
48
+ vec4 a = getFromColor(uv);
49
+ if (progress <= 0.0) return a;
50
+ if (progress >= 1.0) return getToColor(uv);
51
+
52
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(0.0, 1.0);
53
+ vec2 across = vec2(-dir.y, dir.x);
54
+
55
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
56
+
57
+ float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
58
+ float w = 0.5 * (abs(dir.y) * ratio + abs(dir.x));
59
+ float d = dot(p, dir);
60
+ float x = dot(p, across);
61
+ float t = progress;
62
+
63
+ float stir = sin(PI * t);
64
+ float amp = max(amplitude, 0.0) * (0.35 + 0.65 * stir);
65
+
66
+ float margin = max(amplitude, 0.0) + 2.0 * LINE + AA;
67
+ float mean = mix(-e - margin, e + margin, mix(t, t * t * (3.0 - 2.0 * t), 0.5));
68
+ float level = mean + amp * surface(x / w, t);
69
+
70
+ float depth = level - d;
71
+ float m = smoothstep(-AA, AA, depth);
72
+
73
+
74
+ float bend = refraction * stir * exp(-max(depth, 0.0) / 0.06);
75
+ vec2 offset = bend * (dir * sin(18.0 * x - 7.0 * t) + across * cos(13.0 * x + 5.0 * t));
76
+ vec4 b = getToColor(clamp(uv + offset / vec2(ratio, 1.0), 0.0, 1.0));
77
+
78
+
79
+ float glow = 0.0;
80
+ float rise = mean + 0.5 * t;
81
+ vec2 bq = vec2(x, d - rise) / CELL;
82
+ vec2 cell = floor(bq);
83
+ float hs = hash(cell + 7.1);
84
+ float r = (0.12 + 0.18 * hash(cell + 3.7)) * stir;
85
+ float px = AA / CELL;
86
+ if (hs < bubbles * 0.6 && r > px) {
87
+
88
+ vec2 c = cell + 0.5 + (0.42 - r - px) * (vec2(hash(cell + 1.3), hash(cell + 9.4)) * 2.0 - 1.0);
89
+
90
+ c.x += 0.08 * sin(6.0 * t + 6.28 * hs);
91
+ float dist = length(bq - c);
92
+
93
+ float rim = smoothstep(0.7 * r - px, 0.7 * r + px, dist) * (1.0 - smoothstep(r - px, r + px, dist));
94
+ float glint = 1.0 - smoothstep(0.25 * r - px, 0.25 * r + px, length(bq - c - 0.45 * r * vec2(-0.7, 0.7)));
95
+
96
+ glow = max(rim * 0.6, glint) * smoothstep(0.0, 0.05, depth) * stir;
97
+ }
98
+
99
+ float line = 1.0 - smoothstep(LINE - AA, LINE + AA, abs(depth - LINE));
100
+ line += 0.35 * stir * exp(-max(depth, 0.0) / 0.03) * m;
101
+ float light = highlight.a * clamp(max(line, glow), 0.0, 1.0) * (0.4 + 0.6 * stir);
102
+ b.rgb = mix(b.rgb, highlight.rgb, light);
103
+
104
+
105
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
106
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
107
+ }
108
+
109
+ half4 main(float2 _coord) {
110
+ vec2 _uv = _coord / _resolution;
111
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
112
+ return half4(_c.rgb * _c.a, _c.a);
113
+ }
@@ -0,0 +1,64 @@
1
+ // PlasmaDissolve — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/PlasmaDissolve.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // 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
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 scale;
16
+
17
+ uniform float smoothness;
18
+
19
+ uniform float flow;
20
+
21
+ uniform vec3 edgeColor;
22
+
23
+ uniform float edgeStrength;
24
+
25
+ const float PI = 3.14159265;
26
+
27
+ vec4 transition(vec2 uv) {
28
+ vec4 a = getFromColor(uv);
29
+ vec4 b = getToColor(uv);
30
+ if (progress <= 0.0) return a;
31
+ if (progress >= 1.0) return b;
32
+
33
+
34
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0) * max(scale, 0.0) * 2.0 * PI;
35
+
36
+
37
+ float t = clamp(flow, 0.0, 1.0) * progress * 0.5;
38
+
39
+ float v = sin(p.x * 0.6 + t)
40
+ + sin(p.y * 0.8 - t * 0.8)
41
+ + sin((p.x * 0.5 + p.y * 0.7) * 0.7 + t * 0.6)
42
+ + sin(length(p - vec2(0.15, -0.1) * max(scale, 0.0) * 2.0 * PI) * 0.9 - t * 1.2);
43
+
44
+ v = abs(fract(v * 0.25 + 0.5) * 2.0 - 1.0);
45
+
46
+
47
+ float s = max(smoothness, 0.001);
48
+ float threshold = mix(-s, 1.0 + s, progress);
49
+
50
+ float m = 1.0 - smoothstep(threshold - s, threshold + s, v);
51
+
52
+
53
+ vec4 col = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
54
+ if (col.a <= 0.0) return vec4(0.0);
55
+
56
+ float glow = 4.0 * m * (1.0 - m) * max(edgeStrength, 0.0);
57
+ return vec4(col.rgb / col.a + edgeColor * glow, col.a);
58
+ }
59
+
60
+ half4 main(float2 _coord) {
61
+ vec2 _uv = _coord / _resolution;
62
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
63
+ return half4(_c.rgb * _c.a, _c.a);
64
+ }
@@ -0,0 +1,115 @@
1
+ // RingsWipe — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/RingsWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // 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
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 count;
16
+
17
+ uniform vec2 center;
18
+
19
+ uniform float stagger;
20
+
21
+ uniform int radial;
22
+
23
+ uniform float borderWidth;
24
+
25
+ uniform vec4 borderColor;
26
+
27
+ uniform float smoothness;
28
+
29
+ const float PI = 3.141592653589793;
30
+
31
+ const float AA = 0.0015;
32
+
33
+ float ringProgress(float i, float k, float d, float t) {
34
+ return clamp((t - i * k * d) / d, 0.0, 1.0);
35
+ }
36
+
37
+ float ringMask(float i, float lp, float w, float rad, float a, float s) {
38
+ bool odd = mod(i, 2.0) > 0.5;
39
+ if ((radial != 0)) {
40
+
41
+
42
+
43
+ float e = s / w;
44
+ float f = mix(-e, 1.0 + e, lp);
45
+ float x = clamp((rad - i * w) / w, 0.0, 1.0);
46
+ float dist = (odd ? f - (1.0 - x) : f - x) * w;
47
+ return smoothstep(-s, s, dist);
48
+ }
49
+
50
+
51
+
52
+
53
+ float aa = odd ? 1.0 - a : a;
54
+ float arc = 2.0 * PI * max(rad, s);
55
+ float e = s / arc;
56
+ float lo = mix(e, -e, lp);
57
+ float hi = mix(-e, 1.0 + e, lp);
58
+ float dist = max(min(aa - lo, hi - aa), min(aa - 1.0 - lo, hi - aa + 1.0));
59
+ return smoothstep(-s, s, dist * arc);
60
+ }
61
+
62
+ vec4 transition(vec2 uv) {
63
+ vec4 a = getFromColor(uv);
64
+ vec4 b = getToColor(uv);
65
+ if (progress <= 0.0) return a;
66
+ if (progress >= 1.0) return b;
67
+
68
+ float n = float(count < 1 ? 1 : count);
69
+
70
+ vec2 p = (uv - center) * vec2(ratio, 1.0);
71
+
72
+ vec2 far = max(center, 1.0 - center) * vec2(ratio, 1.0);
73
+ float R = length(far) + AA;
74
+ float w = R / n;
75
+ float rad = length(p);
76
+ float turn = rad > 0.0 ? fract(atan(p.x, p.y) / (2.0 * PI)) : 0.0;
77
+ float s = max(min(smoothness, 0.25 * w), AA);
78
+ float t = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.35);
79
+ float k = clamp(stagger, 0.0, 1.0);
80
+ float d = 1.0 / (1.0 + k * (n - 1.0));
81
+
82
+
83
+ float j = floor(rad / w + 0.5);
84
+ float inner = clamp(j - 1.0, 0.0, n - 1.0);
85
+ float outer = clamp(j, 0.0, n - 1.0);
86
+ float li = ringProgress(inner, k, d, t);
87
+ float lo = ringProgress(outer, k, d, t);
88
+ float m = mix(
89
+ ringMask(inner, li, w, rad, turn, s),
90
+ ringMask(outer, lo, w, rad, turn, s),
91
+ smoothstep(-AA, AA, rad - j * w)
92
+ );
93
+
94
+
95
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
96
+
97
+
98
+
99
+ if (borderWidth > 0.0 && j >= 1.0 && j <= n - 1.0) {
100
+ float on = min(1.0, 4.0 * li * (1.0 - lo));
101
+
102
+ float hw = min(0.5 * borderWidth, 0.5 * w - AA);
103
+ float line = (1.0 - smoothstep(hw - AA, hw + AA, abs(rad - j * w)))
104
+ * min(1.0, borderWidth / (2.0 * AA));
105
+ float o = borderColor.a * line * on;
106
+ c = vec4(borderColor.rgb * o, o) + c * (1.0 - o);
107
+ }
108
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
109
+ }
110
+
111
+ half4 main(float2 _coord) {
112
+ vec2 _uv = _coord / _resolution;
113
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
114
+ return half4(_c.rgb * _c.a, _c.a);
115
+ }
@@ -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
+ }
@@ -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
+ }