gl-transitions 2.0.0 → 2.2.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 (131) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/compatibility.json +386 -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/CylinderRoll.glsl +102 -0
  9. package/glsl3/DiamondWipe.glsl +21 -0
  10. package/glsl3/DitherDissolve.glsl +27 -0
  11. package/glsl3/FallOver.glsl +36 -0
  12. package/glsl3/Fisheye.glsl +23 -0
  13. package/glsl3/Halftone.glsl +49 -0
  14. package/glsl3/Honeycomb.glsl +55 -0
  15. package/glsl3/LightStreaks.glsl +117 -0
  16. package/glsl3/PaperTear.glsl +76 -0
  17. package/glsl3/PixelStretch.glsl +73 -0
  18. package/glsl3/Prisms.glsl +81 -0
  19. package/glsl3/Puzzle.glsl +124 -0
  20. package/glsl3/Refraction.glsl +95 -0
  21. package/glsl3/Shred.glsl +67 -0
  22. package/glsl3/SpiralWipe.glsl +41 -0
  23. package/glsl3/Tunnel.glsl +42 -0
  24. package/glsl3/TvRoll.glsl +43 -0
  25. package/glsl3/TvTurnOff.glsl +47 -0
  26. package/glsl3/WhipPan.glsl +50 -0
  27. package/glsl3/WhipSpin.glsl +69 -0
  28. package/glsl3/WhipTilt.glsl +79 -0
  29. package/index.js +1 -1
  30. package/layouts.json +764 -0
  31. package/llms-full.txt +620 -256
  32. package/llms.txt +160 -136
  33. package/msl/ApertureWipe.metal +193 -0
  34. package/msl/Comb.metal +167 -0
  35. package/msl/Curtains.metal +207 -0
  36. package/msl/CylinderRoll.metal +374 -0
  37. package/msl/DiamondWipe.metal +123 -0
  38. package/msl/DitherDissolve.metal +157 -0
  39. package/msl/FallOver.metal +192 -0
  40. package/msl/Fisheye.metal +121 -0
  41. package/msl/Halftone.metal +230 -0
  42. package/msl/Honeycomb.metal +263 -0
  43. package/msl/LightStreaks.metal +518 -0
  44. package/msl/PaperTear.metal +373 -0
  45. package/msl/PixelStretch.metal +337 -0
  46. package/msl/Prisms.metal +424 -0
  47. package/msl/Puzzle.metal +632 -0
  48. package/msl/Refraction.metal +333 -0
  49. package/msl/Shred.metal +294 -0
  50. package/msl/SpiralWipe.metal +196 -0
  51. package/msl/Tunnel.metal +207 -0
  52. package/msl/TvRoll.metal +205 -0
  53. package/msl/TvTurnOff.metal +238 -0
  54. package/msl/WhipPan.metal +218 -0
  55. package/msl/WhipSpin.metal +278 -0
  56. package/msl/WhipTilt.metal +327 -0
  57. package/package.json +1 -1
  58. package/skills/gl-transitions/references/catalog.md +69 -39
  59. package/sksl/ApertureWipe.sksl +56 -0
  60. package/sksl/Comb.sksl +39 -0
  61. package/sksl/Curtains.sksl +60 -0
  62. package/sksl/CylinderRoll.sksl +112 -0
  63. package/sksl/DiamondWipe.sksl +34 -0
  64. package/sksl/DitherDissolve.sksl +39 -0
  65. package/sksl/FallOver.sksl +49 -0
  66. package/sksl/Fisheye.sksl +36 -0
  67. package/sksl/Halftone.sksl +61 -0
  68. package/sksl/Honeycomb.sksl +64 -0
  69. package/sksl/LightStreaks.sksl +126 -0
  70. package/sksl/PaperTear.sksl +82 -0
  71. package/sksl/PixelStretch.sksl +84 -0
  72. package/sksl/Prisms.sksl +94 -0
  73. package/sksl/Puzzle.sksl +134 -0
  74. package/sksl/Refraction.sksl +103 -0
  75. package/sksl/Shred.sksl +79 -0
  76. package/sksl/SpiralWipe.sksl +51 -0
  77. package/sksl/Tunnel.sksl +55 -0
  78. package/sksl/TvRoll.sksl +55 -0
  79. package/sksl/TvTurnOff.sksl +59 -0
  80. package/sksl/WhipPan.sksl +62 -0
  81. package/sksl/WhipSpin.sksl +79 -0
  82. package/sksl/WhipTilt.sksl +90 -0
  83. package/sksl/index.js +1 -1
  84. package/transitions/ApertureWipe.glsl +44 -0
  85. package/transitions/Comb.glsl +25 -0
  86. package/transitions/Curtains.glsl +46 -0
  87. package/transitions/CylinderRoll.glsl +101 -0
  88. package/transitions/DiamondWipe.glsl +20 -0
  89. package/transitions/DitherDissolve.glsl +26 -0
  90. package/transitions/FallOver.glsl +35 -0
  91. package/transitions/Fisheye.glsl +22 -0
  92. package/transitions/Halftone.glsl +48 -0
  93. package/transitions/Honeycomb.glsl +54 -0
  94. package/transitions/LightStreaks.glsl +116 -0
  95. package/transitions/PaperTear.glsl +75 -0
  96. package/transitions/PixelStretch.glsl +72 -0
  97. package/transitions/Prisms.glsl +80 -0
  98. package/transitions/Puzzle.glsl +123 -0
  99. package/transitions/Refraction.glsl +94 -0
  100. package/transitions/Shred.glsl +66 -0
  101. package/transitions/SpiralWipe.glsl +40 -0
  102. package/transitions/Tunnel.glsl +41 -0
  103. package/transitions/TvRoll.glsl +42 -0
  104. package/transitions/TvTurnOff.glsl +46 -0
  105. package/transitions/WhipPan.glsl +49 -0
  106. package/transitions/WhipSpin.glsl +68 -0
  107. package/transitions/WhipTilt.glsl +78 -0
  108. package/wgsl/ApertureWipe.wgsl +160 -0
  109. package/wgsl/Comb.wgsl +139 -0
  110. package/wgsl/Curtains.wgsl +179 -0
  111. package/wgsl/CylinderRoll.wgsl +330 -0
  112. package/wgsl/DiamondWipe.wgsl +94 -0
  113. package/wgsl/DitherDissolve.wgsl +123 -0
  114. package/wgsl/FallOver.wgsl +164 -0
  115. package/wgsl/Fisheye.wgsl +93 -0
  116. package/wgsl/Halftone.wgsl +196 -0
  117. package/wgsl/Honeycomb.wgsl +222 -0
  118. package/wgsl/LightStreaks.wgsl +460 -0
  119. package/wgsl/PaperTear.wgsl +324 -0
  120. package/wgsl/PixelStretch.wgsl +298 -0
  121. package/wgsl/Prisms.wgsl +385 -0
  122. package/wgsl/Puzzle.wgsl +587 -0
  123. package/wgsl/Refraction.wgsl +294 -0
  124. package/wgsl/Shred.wgsl +259 -0
  125. package/wgsl/SpiralWipe.wgsl +165 -0
  126. package/wgsl/Tunnel.wgsl +177 -0
  127. package/wgsl/TvRoll.wgsl +165 -0
  128. package/wgsl/TvTurnOff.wgsl +196 -0
  129. package/wgsl/WhipPan.wgsl +177 -0
  130. package/wgsl/WhipSpin.wgsl +241 -0
  131. package/wgsl/WhipTilt.wgsl +291 -0
@@ -0,0 +1,45 @@
1
+ // ApertureWipe — GLSL ES 3.00, 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
+ // Tags: shape, wipe, iris, rotate
6
+
7
+ #define PI 3.141592653589793
8
+
9
+ // @range(3, 12) Number of blades
10
+ uniform int blades; // = 6
11
+ // @range(-180, 180) How much the blades turn while opening, in degrees
12
+ uniform float rotation; // = 60.0
13
+ // @range(0, 1) How dark the blades are shaded along their edges
14
+ uniform float shadow; // = 0.5
15
+
16
+ const float AA = 0.006;
17
+
18
+ vec4 transition (vec2 uv) {
19
+ // Square pixels, normalized so the frame's corners are at distance 1
20
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0) / (0.5 * length(vec2(ratio, 1.0)));
21
+ float n = clamp(float(blades), 3.0, 12.0);
22
+ float sector = 2.0 * PI / n;
23
+ float turn = radians(rotation) * progress;
24
+ // Each blade's straight edge is at distance r from the center: the opening is the polygon they enclose
25
+ float r = mix(-AA, 1.0 + AA, progress);
26
+ float dist = -1e3;
27
+ float seam = 0.0;
28
+ for (int i = 0; i < 12; i++) {
29
+ if (float(i) < n) {
30
+ float angle = turn + float(i) * sector;
31
+ float d = dot(q, vec2(cos(angle), sin(angle))) - r;
32
+ float next = dot(q, vec2(cos(angle + sector), sin(angle + sector))) - r;
33
+ dist = max(dist, d);
34
+ // Past its corner, the edge of a blade lies over the next blade and casts a shadow on it
35
+ float s = 1.0 - smoothstep(0.0, 0.12, -d);
36
+ seam = max(seam, (1.0 - smoothstep(0.0, AA, d)) * s * s * smoothstep(0.0, AA, next));
37
+ }
38
+ }
39
+ // The blades are also shaded along the opening; the shading fades in as the aperture starts to open
40
+ float rim = 1.0 - smoothstep(0.0, 0.08, dist);
41
+ float shade = shadow * max(rim * rim, seam) * smoothstep(0.0, 0.1, progress);
42
+ vec4 from = getFromColor(uv);
43
+ from.rgb *= 1.0 - shade;
44
+ return mix(from, getToColor(uv), 1.0 - smoothstep(0.0, AA, dist));
45
+ }
@@ -0,0 +1,26 @@
1
+ // Comb — GLSL ES 3.00, 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
+ // Tags: slide, stripes, push, horizontal
6
+
7
+ // @range(2, 40, 1) Number of strips
8
+ uniform int strips; // = 10
9
+ // @param Cut the frame into columns that slide up and down instead
10
+ uniform bool vertical; // = false
11
+
12
+ vec4 transition (vec2 uv) {
13
+ // a: the axis along which the strips slide, b: the axis across them
14
+ float a = vertical ? uv.y : uv.x;
15
+ float b = vertical ? uv.x : uv.y;
16
+ // alternate strips slide in opposite directions
17
+ float dir = mod(floor(b * float(strips)), 2.0) < 0.5 ? 1.0 : -1.0;
18
+ // ease in and out, but keep moving from the first frame
19
+ float t = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.6);
20
+ float fa = a - dir * t;
21
+ if (fa >= 0.0 && fa <= 1.0) {
22
+ return getFromColor(vertical ? vec2(b, fa) : vec2(fa, b));
23
+ }
24
+ float ta = fa + dir;
25
+ return getToColor(vertical ? vec2(b, ta) : vec2(ta, b));
26
+ }
@@ -0,0 +1,47 @@
1
+ // Curtains — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Curtains.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image parts in the middle like stage curtains, gathering into shaded folds as it is pulled to the sides
5
+ // Tags: split, horizontal, fold, 3d
6
+
7
+ // @range(1, 16, 1) Number of folds in each curtain (fewer in a portrait image)
8
+ uniform float folds; // = 7.0
9
+ // @range(0, 1) Depth of the shading on the folds
10
+ uniform float shading; // = 0.7
11
+ // @range(0, 0.4) Width of each curtain once gathered, relative to the image width
12
+ uniform float bunch; // = 0.12
13
+ // @range(0, 1) How much the bottom of the curtains lags behind the top
14
+ uniform float sway; // = 0.4
15
+
16
+ const float PI = 3.141592653589793;
17
+
18
+ vec4 transition (vec2 uv) {
19
+ // the bottom of the fabric follows the top with a little delay
20
+ float lag = sway * (1.0 - uv.y);
21
+ float p = progress * (1.0 - lag * (1.0 - progress));
22
+ float open = mix(p, p * p * (3.0 - 2.0 * p), 0.75);
23
+ // each curtain hangs from its outer edge, gathers to the bunch width, then leaves the frame
24
+ float edge = -bunch * open * open;
25
+ float w = mix(0.5, bunch, open);
26
+ float x = min(uv.x, 1.0 - uv.x) - edge; // distance to the outer edge of the curtain
27
+ if (x >= w) {
28
+ // soft shadow of the curtain on the stage, fading as the curtain leaves the frame
29
+ vec4 to = getToColor(uv);
30
+ float shadow = 0.4 * exp((w - x) * 25.0) * clamp((edge + w) * 20.0, 0.0, 1.0);
31
+ return vec4(to.rgb * (1.0 - shadow * open), to.a);
32
+ }
33
+ float t = x / w;
34
+ // pleats: the fabric bunches up where cos(a) > 0 and is stretched elsewhere
35
+ float n = max(1.0, floor(folds * min(ratio, 1.0) + 0.5)); // folds keep their size in portrait
36
+ float a = 2.0 * PI * n * t;
37
+ float f = 1.0 - (1.0 - open) * (1.0 - open) * (1.0 - open); // the folds form early
38
+ float gather = 0.92 * f;
39
+ float s = 0.5 * (t + gather * sin(a) / (2.0 * PI * n)); // position in the fabric
40
+ vec4 c = getFromColor(vec2(uv.x < 0.5 ? s : 1.0 - s, uv.y));
41
+ // light comes from the front, a bit from the middle of the stage
42
+ float slope = 3.0 * gather * cos(a) * (uv.x < 0.5 ? 1.0 : -1.0);
43
+ float diffuse = (1.0 + 0.5 * slope) / sqrt(1.25 * (1.0 + slope * slope));
44
+ float crease = 0.5 + 0.5 * sin(a); // the back of each pleat is in the dark
45
+ float light = mix(1.0, diffuse * (1.0 - 0.6 * crease * crease), shading * f);
46
+ return vec4(c.rgb * light, c.a);
47
+ }
@@ -0,0 +1,102 @@
1
+ // CylinderRoll — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CylinderRoll.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The frame wraps around a drum that rolls up, the outgoing image turning away over its top in a motion blur and the incoming one coming around from below and unrolling flat
5
+ // Tags: 3d, roll, motion-blur, vertical, chromatic
6
+
7
+ // @range(0, 1) How much the frame wraps around the drum
8
+ uniform float curvature; // = 0.8
9
+ // @range(0, 1) Length of the motion blur at full speed
10
+ uniform float blur; // = 0.5
11
+ // @range(0, 1) How much the drum darkens as it turns away
12
+ uniform float shading; // = 0.6
13
+ // @range(0, 1) Amount of RGB split along the roll, growing with speed
14
+ uniform float chroma; // = 0.5
15
+ // @param Roll downward instead, the incoming image coming around from above
16
+ uniform bool downward; // = false
17
+
18
+ const int SAMPLES = 24;
19
+ // the half angle of the drum seen in the frame height, at full curvature
20
+ const float MAX_ANGLE = 1.1;
21
+ // distance from the camera to the drum's axis, in drum radii
22
+ const float DIST = 2.6;
23
+ // how much the horizontal lines arc away from the middle, per frame height squared
24
+ const float ARC = 0.12;
25
+
26
+ float hash(vec2 c) {
27
+ vec2 q = fract(c * vec2(0.1031, 0.1030));
28
+ q += dot(q, q.yx + 33.33);
29
+ return fract((q.x + q.y) * q.x);
30
+ }
31
+
32
+ // mirrored coordinate, folded back into 0..1
33
+ float fold(float v) {
34
+ return 1.0 - abs(1.0 - mod(v, 2.0));
35
+ }
36
+
37
+ // the strip around the drum: the outgoing image, with the incoming one below it (or above)
38
+ vec4 strip(float x, float v) {
39
+ if (downward ? v > 1.0 : v < 0.0) {
40
+ return getToColor(vec2(x, fold(downward ? v - 1.0 : v + 1.0)));
41
+ }
42
+ return getFromColor(vec2(x, fold(v)));
43
+ }
44
+
45
+ // angle on the drum seen at the projected height c (the drum has a radius of 1)
46
+ float angleAt(float c) {
47
+ c = clamp(c, -0.98 / sqrt(DIST * DIST - 1.0), 0.98 / sqrt(DIST * DIST - 1.0));
48
+ return asin(c * DIST / sqrt(1.0 + c * c)) - atan(c);
49
+ }
50
+
51
+ vec4 transition(vec2 uv) {
52
+ float p = progress;
53
+ // ease in, roll fast in the middle, ease out
54
+ float h = 1.0 - abs(2.0 * p - 1.0); // 0 at both ends, 1 in the middle
55
+ float e = 0.5 * h * (0.1 + 0.9 * h * h);
56
+ float roll = p < 0.5 ? e : 1.0 - e;
57
+ // the blur and the RGB split stay low until the peak of the roll
58
+ float h3 = h * h * h;
59
+ float peak = h3 * h3;
60
+
61
+ // the frame wraps around the drum early, and unwraps to flat sooner as the incoming image settles
62
+ float bend = curvature * (p < 0.5 ? h * (2.0 - h) : h * h * (3.0 - 2.0 * h));
63
+ float phi = MAX_ANGLE * bend + 1e-4;
64
+ float arcK = ARC * bend;
65
+ // the height of the frame's edge, projected with perspective
66
+ float edgeY = sin(phi) / (DIST - cos(phi));
67
+
68
+ vec2 n = 2.0 * uv - 1.0;
69
+ // the horizontal lines arc away from the middle, toward the left and right edges
70
+ float xr = n.x * ratio;
71
+ float yn = n.y * (1.0 + arcK * xr * xr);
72
+ float theta = angleAt(yn * edgeY);
73
+ // nearer parts of the drum look wider: the drum is made wide enough to fill the frame's corners
74
+ float thetaCorner = angleAt((1.0 + arcK * ratio * ratio) * edgeY);
75
+ float width = (DIST - 1.0) / (DIST - cos(theta));
76
+ float zoom = (DIST - cos(thetaCorner)) / (DIST - 1.0);
77
+ float x = 0.5 + 0.5 * n.x / (zoom * width);
78
+ // lit from the camera: darker as the surface turns away
79
+ float facing = (DIST * cos(theta) - 1.0)
80
+ / sqrt(1.0 + DIST * DIST - 2.0 * DIST * cos(theta)) ;
81
+ float light = mix(1.0, clamp(facing, 0.0, 1.0), shading);
82
+
83
+ // position on the strip (the frame height when flat), rolling the outgoing image away
84
+ float v = 0.5 * (theta / phi + 1.0) + (downward ? roll : -roll);
85
+ float len = 0.5 * blur * peak;
86
+ float split = chroma * peak;
87
+ float jitter = hash(uv * 1000.0);
88
+ vec3 color = vec3(0.0);
89
+ vec3 weight = vec3(0.0);
90
+ float alpha = 0.0;
91
+ for (int i = 0; i < SAMPLES; i++) {
92
+ float t = (float(i) + jitter) / float(SAMPLES) - 0.5;
93
+ vec4 img = strip(x, v + t * len);
94
+ // the channels weigh the samples differently along the roll: an RGB split
95
+ vec3 w = vec3(max(1.0 - 4.0 * split * t, 0.0), 1.0, max(1.0 + 4.0 * split * t, 0.0));
96
+ color += img.rgb * img.a * w;
97
+ weight += img.a * w;
98
+ alpha += img.a;
99
+ }
100
+ color = color / max(weight, vec3(1e-5));
101
+ return vec4(color * light, alpha / float(SAMPLES));
102
+ }
@@ -0,0 +1,21 @@
1
+ // DiamondWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/DiamondWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A soft-edged diamond grows from the center to reveal the incoming image
5
+ // Tags: shape, wipe, iris
6
+
7
+ // @param Center of the diamond
8
+ uniform vec2 center; // = vec2(0.5)
9
+ // @range(0, 0.5) Softness of the diamond's edge
10
+ uniform float smoothness; // = 0.03
11
+
12
+ vec4 transition (vec2 uv) {
13
+ // Measured in square pixels, so the diamond is not stretched
14
+ vec2 d = abs(uv - center) * vec2(ratio, 1.0);
15
+ // The diamond covers the frame once it reaches the farthest corner
16
+ vec2 far = max(center, 1.0 - center) * vec2(ratio, 1.0);
17
+ float dist = (d.x + d.y) / (far.x + far.y);
18
+ float s = max(smoothness, 0.001);
19
+ float m = smoothstep(0.0, s, progress * (1.0 + s) - dist);
20
+ return mix(getFromColor(uv), getToColor(uv), m);
21
+ }
@@ -0,0 +1,27 @@
1
+ // DitherDissolve — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/DitherDissolve.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The incoming image appears through a regular 8x8 ordered dither pattern, like a retro computer screen
5
+ // Tags: dissolve, pattern, retro, pixelate
6
+
7
+ // @range(0.002, 0.05) Size of a dither dot, relative to the height
8
+ uniform float dotSize; // = 0.02
9
+
10
+ // Threshold of the 8x8 Bayer matrix at integer cell c, in (0, 1)
11
+ float bayer(vec2 c) {
12
+ float v = 0.0;
13
+ float scale = 16.0;
14
+ for (int i = 0; i < 3; i++) {
15
+ vec2 bit = mod(floor(c), 2.0);
16
+ // a 2x2 step: 0 2 / 3 1, i.e. 2 * (x xor y) + y
17
+ v += scale * (2.0 * abs(bit.x - bit.y) + bit.y);
18
+ c *= 0.5;
19
+ scale *= 0.25;
20
+ }
21
+ return (v + 0.5) / 64.0;
22
+ }
23
+
24
+ vec4 transition(vec2 uv) {
25
+ vec2 cell = floor(uv * vec2(ratio, 1.0) / dotSize);
26
+ return progress < bayer(cell) ? getFromColor(uv) : getToColor(uv);
27
+ }
@@ -0,0 +1,36 @@
1
+ // FallOver — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/FallOver.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image falls over backward, hinged on its bottom edge, revealing the incoming one behind it
5
+ // Tags: rotate, vertical, 3d
6
+
7
+ // @range(0, 1) Strength of the perspective
8
+ uniform float perspective; // = 0.8
9
+ // @range(0, 1) How much the image darkens as it falls
10
+ uniform float shading; // = 0.7
11
+
12
+ const float PI = 3.141592653589793;
13
+
14
+ vec4 transition (vec2 uv) {
15
+ // it starts slowly, then gravity takes over
16
+ float fall = progress * (0.25 + 0.75 * progress);
17
+ float angle = 0.5 * PI * fall;
18
+ float c = cos(angle), s = sin(angle);
19
+ // a camera in front of the middle of the image goes down to the level of the hinge,
20
+ // so that the image ends edge-on
21
+ float dist = 1.0 / max(perspective, 0.01);
22
+ vec3 eye = vec3(0.5 * ratio, 0.5 * c, -dist);
23
+ vec3 dir = vec3(uv.x * ratio, uv.y, 0.0) - eye;
24
+ // cast a ray onto the plane of the image turned back by angle around its bottom edge
25
+ float den = dir.z * c - dir.y * s;
26
+ if (den > 0.0) {
27
+ float t = (eye.y * s - eye.z * c) / den;
28
+ vec3 hit = eye + t * dir;
29
+ vec2 puv = vec2(hit.x / ratio, hit.y * c + hit.z * s);
30
+ if (t > 0.0 && puv.y > 0.0 && puv.y <= 1.0 && puv.x >= 0.0 && puv.x <= 1.0) {
31
+ vec4 col = getFromColor(puv);
32
+ return vec4(col.rgb * (1.0 - shading * s), col.a);
33
+ }
34
+ }
35
+ return getToColor(uv);
36
+ }
@@ -0,0 +1,23 @@
1
+ // Fisheye — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Fisheye.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image bulges toward the viewer through a strong fisheye lens, then the incoming one flattens back into place
5
+ // Tags: lens, distort, zoom, blend
6
+
7
+ // @range(0, 1) Strength of the lens at its peak
8
+ uniform float strength; // = 0.8
9
+
10
+ vec4 transition(vec2 uv) {
11
+ // lens amount: grows, peaks in the middle, then relaxes, eased so that
12
+ // the magnification of the center (1 / (1 - k)) changes at an even pace
13
+ float h = smoothstep(0.0, 1.0, 1.0 - abs(2.0 * progress - 1.0));
14
+ float k = 1.0 - pow(max(1.0 - strength, 0.01), h);
15
+ // round lens: aspect-corrected coordinates, 1.0 at the corners
16
+ vec2 aspect = vec2(ratio, 1.0);
17
+ vec2 c = (uv - 0.5) * aspect;
18
+ float r = length(c) / length(0.5 * aspect);
19
+ // barrel mapping that keeps the corners in place: the center is magnified,
20
+ // the edges squeezed, and every sample stays inside the image
21
+ vec2 q = 0.5 + (uv - 0.5) * (1.0 - k + k * r * r);
22
+ return mix(getFromColor(q), getToColor(q), smoothstep(0.38, 0.62, progress));
23
+ }
@@ -0,0 +1,49 @@
1
+ // Halftone — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Halftone.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The image breaks into printed halftone dots whose size follows its shades, the dots reshape into the incoming image, then merge back into it
5
+ // Tags: dots, pattern, retro
6
+
7
+ // @range(4, 80) Number of dots across the shorter side
8
+ uniform float dots; // = 28.0
9
+ // @range(0, 90) Angle of the dot grid, in degrees
10
+ uniform float angle; // = 45.0
11
+ // @color Color of the paper between the dots
12
+ uniform vec4 paper; // = vec4(1.0, 1.0, 1.0, 1.0)
13
+
14
+ // Dot radius, in cells, of a halftone printing this color (darker is bigger)
15
+ float dotRadius(vec4 c) {
16
+ float shade = 1.0 - dot(c.rgb, vec3(0.299, 0.587, 0.114));
17
+ return mix(0.1, 0.74, sqrt(clamp(shade, 0.0, 1.0))) * c.a;
18
+ }
19
+
20
+ vec4 transition(vec2 uv) {
21
+ // the image turns into dots until 0.3, the dots reshape from left to right, then merge back from 0.7
22
+ float h = smoothstep(0.0, 0.3, progress) * (1.0 - smoothstep(0.7, 1.0, progress));
23
+ float t = (progress - 0.3) / 0.4;
24
+ // rotated square grid, in cells
25
+ float a = radians(angle);
26
+ mat2 rot = mat2(cos(a), sin(a), -sin(a), cos(a));
27
+ vec2 scale = vec2(ratio, 1.0) * dots / min(ratio, 1.0);
28
+ vec2 g = rot * ((uv - 0.5) * scale);
29
+ vec2 base = floor(g - 0.5) + 0.5;
30
+ vec4 pixel = progress < 0.5 ? getFromColor(uv) : getToColor(uv);
31
+ // the dots of the 4 nearest cells may overlap this point: keep the one it is deepest in
32
+ float best = 1e3;
33
+ vec4 ink = pixel;
34
+ for (int i = 0; i < 4; i++) {
35
+ vec2 center = base + vec2(mod(float(i), 2.0), floor(float(i) / 2.0));
36
+ vec2 cuv = (center * rot) / scale + 0.5; // inverse rotation
37
+ vec4 cf = getFromColor(cuv);
38
+ vec4 ct = getToColor(cuv);
39
+ float m = smoothstep(0.0, 1.0, clamp(2.5 * t - 1.5 * cuv.x, 0.0, 1.0));
40
+ // at h = 0, the dots cover their whole cell with the image itself
41
+ float r = mix(0.78, mix(dotRadius(cf), dotRadius(ct), m), h);
42
+ float sd = length(g - center) - r;
43
+ if (sd < best) {
44
+ best = sd;
45
+ ink = mix(pixel, mix(cf, ct, m), h);
46
+ }
47
+ }
48
+ return mix(paper, ink, 1.0 - smoothstep(-0.06, 0.06, best));
49
+ }
@@ -0,0 +1,55 @@
1
+ // Honeycomb — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Honeycomb.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The image splits into hexagons that spin and shrink away in a wave from the center, uncovering the incoming image
5
+ // Tags: hexagon, tiles, rotate, radial
6
+
7
+ // @range(2, 30) Number of hexagons across the shorter side
8
+ uniform float size; // = 6.0
9
+
10
+ // Distance to the center of a pointy-top hexagon, 0.5 on the edges of a cell
11
+ float hexDist(vec2 p) {
12
+ p = abs(p);
13
+ return max(p.x, dot(p, vec2(0.5, 0.8660254)));
14
+ }
15
+
16
+ mat2 rotation(float a) {
17
+ return mat2(cos(a), sin(a), -sin(a), cos(a));
18
+ }
19
+
20
+ // Coverage of a hexagon turned by a and scaled by s inside its cell, with soft edges of width e
21
+ // (unturned at s = 1, it covers its whole cell)
22
+ float hexMask(vec2 local, float s, float a, float e) {
23
+ float r = (0.52 + e) * s;
24
+ return 1.0 - smoothstep(r - e, r, hexDist(rotation(-a) * local));
25
+ }
26
+
27
+ // Where the image is sampled, for a point of a hexagon turned by a and scaled by s
28
+ vec2 hexUv(vec2 uv, vec2 local, vec2 cellToUv, float s, float a) {
29
+ return uv + cellToUv * (rotation(-a) * local / max(s, 0.001) - local);
30
+ }
31
+
32
+ vec4 transition(vec2 uv) {
33
+ // nearest hexagon center, on two interleaved rectangular grids (centers 1 apart)
34
+ vec2 toCells = vec2(ratio, 1.0) * size / min(ratio, 1.0);
35
+ vec2 p = (uv - 0.5) * toCells;
36
+ const vec2 grid = vec2(1.0, 1.7320508);
37
+ vec2 a = (floor(p / grid) + 0.5) * grid;
38
+ vec2 b = (floor((p - 0.5 * grid) / grid) + 1.0) * grid;
39
+ vec2 center = dot(p - a, p - a) < dot(p - b, p - b) ? a : b;
40
+ vec2 local = p - center;
41
+
42
+ // each hexagon starts later the further it is from the center
43
+ float d = min(length(center / toCells * vec2(ratio, 1.0)) / (0.5 * length(vec2(ratio, 1.0))), 1.0);
44
+ float t = clamp((progress - 0.6 * d) / 0.4, 0.0, 1.0);
45
+
46
+ // the outgoing hexagon spins (opening gaps at the corners of its cell), shrinks away and darkens,
47
+ // casting a soft shadow on the incoming image
48
+ float s = 1.0 - smoothstep(0.1, 1.0, t);
49
+ float turn = 1.8 * t * (2.0 - t);
50
+ vec4 fromTile = getFromColor(hexUv(uv, local, 1.0 / toCells, s, turn));
51
+ fromTile.rgb *= 1.0 - 0.3 * t;
52
+ vec4 below = getToColor(uv);
53
+ below.rgb *= 1.0 - 0.5 * hexMask(local - vec2(0.06, -0.08) * s, s, turn, 0.2);
54
+ return mix(below, fromTile, hexMask(local, s, turn, 0.03));
55
+ }
@@ -0,0 +1,117 @@
1
+ // LightStreaks — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/LightStreaks.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The highlights of the outgoing image flare into long horizontal (or vertical) lens streaks while it smears with motion blur; at the peak the incoming image takes over and its streaks shrink back into its highlights as it sharpens
5
+ // Tags: light, flare, motion-blur, glow
6
+
7
+ // @range(0, 2) Length of the streaks at the peak, in frame widths
8
+ uniform float reach; // = 0.6
9
+ // @range(0, 1) Brightness above which the image flares
10
+ uniform float threshold; // = 0.7
11
+ // @range(0, 4) Brightness of the streaks
12
+ uniform float intensity; // = 1.5
13
+ // @color Tint of the streaks, toward their ends
14
+ uniform vec3 tint; // = vec3(0.45, 0.7, 1.0)
15
+ // @range(0, 0.5) Length of the motion blur at the peak
16
+ uniform float blur; // = 0.1
17
+ // @param Streak and smear vertically instead
18
+ uniform bool vertical; // = false
19
+
20
+ const int BLUR_TAPS = 6;
21
+ // taps on each side of a streak, spaced further and further apart along its falloff
22
+ const int STREAK_TAPS = 11;
23
+
24
+ float hash12(vec2 v) {
25
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
26
+ v3 += dot(v3, v3.yzx + 33.33);
27
+ return fract((v3.x + v3.y) * v3.z);
28
+ }
29
+
30
+ // mirror the coordinates back into the frame
31
+ vec2 mirror(vec2 v) {
32
+ return 1.0 - abs(1.0 - mod(v, 2.0));
33
+ }
34
+
35
+ // the image on screen: the outgoing one, then the incoming one after a short switch
36
+ vec4 frame(vec2 st, float m) {
37
+ if (m <= 0.0) return getFromColor(st);
38
+ if (m >= 1.0) return getToColor(st);
39
+ return mix(getFromColor(st), getToColor(st), m);
40
+ }
41
+
42
+ // the light of a pixel: its color above the threshold
43
+ vec3 glow(vec4 c, float knee) {
44
+ float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
45
+ return c.rgb * c.a * smoothstep(knee, knee + 0.2, lum);
46
+ }
47
+
48
+ // one image only, for the blur and streak taps: during the switch, every other tap reads each image
49
+ vec4 light(vec2 st, float m, bool incoming) {
50
+ if (m <= 0.0) return getFromColor(st);
51
+ if (m >= 1.0) return getToColor(st);
52
+ return incoming ? getToColor(st) : getFromColor(st);
53
+ }
54
+
55
+ float lightWeight(float m, bool incoming) {
56
+ if (m <= 0.0 || m >= 1.0) return 1.0;
57
+ return incoming ? 2.0 * m : 2.0 * (1.0 - m);
58
+ }
59
+
60
+ vec4 transition(vec2 uv) {
61
+ float p = progress;
62
+ // eased in on the outgoing side, and quickly out after the switch so the incoming image lands sharp
63
+ float amount = p < 0.5 ? smoothstep(0.0, 0.5, p) : pow(2.0 - 2.0 * p, 3.0);
64
+ float peak = amount * amount * amount;
65
+ float m = smoothstep(0.44, 0.56, p);
66
+ vec2 axis = vertical ? vec2(0.0, 1.0) : vec2(1.0, 0.0);
67
+ // a small shift of the taps, under their spacing, blends their copies into a smooth smear;
68
+ // hashed by integer cell so that every GPU computes the same shift
69
+ float jitter = hash12(floor(uv * vec2(ratio, 1.0) * 997.0)) - 0.5;
70
+
71
+ // the image smears along the streaks (a tent filter)
72
+ float smear = blur * amount;
73
+ vec3 base = vec3(0.0);
74
+ float alpha = 0.0;
75
+ float total = 0.0;
76
+ for (int i = 0; i < BLUR_TAPS; i++) {
77
+ float t = (float(i) + 0.5 + jitter) / float(BLUR_TAPS) - 0.5;
78
+ float w = 1.0 - abs(t);
79
+ total += w;
80
+ bool incoming = mod(float(i), 2.0) > 0.5;
81
+ w *= lightWeight(m, incoming);
82
+ vec4 c = light(mirror(uv + axis * t * smear), m, incoming);
83
+ base += w * c.rgb * c.a;
84
+ alpha += w * c.a;
85
+ }
86
+ base /= total;
87
+ alpha /= total;
88
+
89
+ // the streaks: the light above the threshold, spread along the axis with an exponential falloff
90
+ float falloff = 0.25 * reach * amount;
91
+ float knee = mix(threshold, 0.8 * threshold, peak);
92
+ vec3 streak = glow(frame(uv, m), knee);
93
+ float weights = 1.0;
94
+ for (int k = 1; k <= STREAK_TAPS; k++) {
95
+ // the distance in units of the falloff, and the stretch of the streak this tap stands for
96
+ float d = exp(0.14 * (float(k) + 0.8 * jitter)) - 1.0;
97
+ float span = 0.14 * (d + 1.0);
98
+ // white at the source, tinted along the streak, red fading first so the tails turn blue and violet
99
+ vec3 hue = mix(vec3(1.0), tint, smoothstep(0.0, 0.8, d));
100
+ hue *= exp(-d * vec3(0.6, 0.2, -0.15));
101
+ float w = exp(-d) * span * 4.0;
102
+ bool incoming = mod(float(k), 2.0) > 0.5;
103
+ vec4 ahead = light(mirror(uv + axis * d * falloff), m, incoming);
104
+ vec4 behind = light(mirror(uv - axis * d * falloff), m, !incoming);
105
+ streak += w * hue * (glow(ahead, knee) * lightWeight(m, incoming) + glow(behind, knee) * lightWeight(m, !incoming));
106
+ weights += 2.0 * w;
107
+ }
108
+ streak *= intensity * amount * (0.6 + 2.4 * peak) * 2.0 / weights;
109
+ // compressed, so that bright skies never flatten into white
110
+ streak = 0.85 * (1.0 - exp(-streak));
111
+
112
+ // a lift of the exposure at the peak, then the streaks screened on top (premultiplied colors)
113
+ base = min(base * (1.0 + 0.2 * peak), vec3(alpha));
114
+ vec3 color = base + streak - base * streak;
115
+ float a = alpha + max(streak.r, max(streak.g, streak.b)) * (1.0 - alpha);
116
+ return vec4(clamp(color / max(a, 1e-5), 0.0, 1.0), a);
117
+ }
@@ -0,0 +1,76 @@
1
+ // PaperTear — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/PaperTear.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image tears in two along a ragged line, and the halves are pulled apart to reveal the incoming one
5
+ // Tags: split, horizontal, shadow
6
+
7
+ // @range(0, 0.3) How far the tear wanders from the middle, relative to the image height
8
+ uniform float roughness; // = 0.12
9
+ // @range(0, 0.5) How much the top of each half leans away first, so that the tear opens from the top
10
+ uniform float tilt; // = 0.1
11
+ // @range(0, 0.05) Width of the white torn edge, relative to the image height
12
+ uniform float rim; // = 0.012
13
+ // @color Color of the paper fibers on the torn edges
14
+ uniform vec4 paper; // = vec4(1.0, 0.98, 0.94, 1.0)
15
+ // @color Color of the shadow cast on the incoming image
16
+ uniform vec4 shadow; // = vec4(0.0, 0.0, 0.0, 0.35)
17
+
18
+ float tri (float x) {
19
+ return abs(fract(x) - 0.5) - 0.25;
20
+ }
21
+
22
+ // horizontal position of the tear at height y: smooth meanders...
23
+ float meander (float y) {
24
+ return 0.5 * ratio + roughness * (0.5 * sin(y * 4.7 + 1.3) + 0.25 * sin(y * 11.3 + 4.1));
25
+ }
26
+
27
+ // ...and sharp jags
28
+ float tear (float y) {
29
+ return meander(y) + roughness * (0.1 * sin(y * 29.0 + 0.7) + 0.35 * tri(y * 19.0 + sin(y * 7.0)) + 0.12 * tri(y * 47.0 + 0.6 * sin(y * 13.0)));
30
+ }
31
+
32
+ // width of the torn edge along it, so that the fibers look uneven
33
+ float fibers (float y, float seed) {
34
+ return rim * (0.7 + 0.3 * sin(y * 37.0 + seed) + 0.4 * tri(y * 83.0 + seed));
35
+ }
36
+
37
+ // the left half (or the mirrored right half) slides out, its top leaning away first:
38
+ // from a point on screen to the point of the paper (the frame edges stay covered)
39
+ vec2 unfold (vec2 q, float away, float lean) {
40
+ return vec2(q.x + away + lean * q.y, q.y);
41
+ }
42
+
43
+ // a torn half over the background, with its fibers and an anti-aliased edge
44
+ // e: distance past the torn edge, limit: how far the fibers reach, aa: edge softness
45
+ vec4 torn (vec4 bg, vec4 col, float e, float limit, float aa) {
46
+ vec4 c = vec4(mix(col.rgb, paper.rgb, clamp(0.5 + e / aa, 0.0, 1.0) * paper.a), col.a);
47
+ return mix(bg, c, clamp(0.5 - (e - limit) / aa, 0.0, 1.0));
48
+ }
49
+
50
+ vec4 transition (vec2 uv) {
51
+ float p = progress;
52
+ float away = p * p * (0.5 * ratio + 0.1 + roughness + 2.0 * rim); // far enough to leave the frame
53
+ float lean = tilt * p * (2.0 - p);
54
+ float fiber = smoothstep(0.0, 0.15, p); // no torn edge on the intact image
55
+ float aa = 0.002 * fiber + 1e-6;
56
+ vec2 q = vec2(uv.x * ratio, uv.y);
57
+ vec2 l = unfold(q, away, lean);
58
+ vec2 r = unfold(vec2(ratio - q.x, q.y), away, lean);
59
+ float el = l.x - tear(l.y); // > 0 right of the left half's torn edge
60
+ float er = r.x - (ratio - tear(r.y)); // > 0 left of the right half's torn edge
61
+ // soft shadow of the two halves on the incoming image, cast toward the right
62
+ vec2 sq = q - vec2(0.01, 0.0);
63
+ float dl = unfold(sq, away, lean).x - meander(sq.y);
64
+ float dr = unfold(vec2(ratio - sq.x, sq.y), away, lean).x - (ratio - meander(sq.y));
65
+ vec4 to = getToColor(uv);
66
+ float sh = shadow.a * (1.0 - smoothstep(-0.02, 0.08, min(dl, dr)));
67
+ vec4 c = vec4(mix(to.rgb, shadow.rgb, sh), to.a);
68
+ // the image stops at the tear; the bare paper fibers stick out a little beyond it
69
+ if (r.x >= 0.0) {
70
+ c = torn(c, getFromColor(vec2(1.0 - r.x / ratio, r.y)), er, fibers(r.y, 2.0) * 1.5 * fiber, aa);
71
+ }
72
+ if (l.x >= 0.0) {
73
+ c = torn(c, getFromColor(vec2(l.x / ratio, l.y)), el, fibers(l.y, 0.0) * fiber, aa);
74
+ }
75
+ return c;
76
+ }