gl-transitions 2.4.0 → 3.0.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 (182) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +16 -1
  3. package/compatibility.json +251 -121
  4. package/gl-transitions.js +1 -1
  5. package/gl-transitions.json +1 -1
  6. package/glsl3/ArrowWipe.glsl +100 -0
  7. package/glsl3/BandWipe.glsl +67 -0
  8. package/glsl3/BlockSlide.glsl +87 -0
  9. package/glsl3/BowTie.glsl +1 -1
  10. package/glsl3/CellDissolve.glsl +91 -0
  11. package/glsl3/Crumple.glsl +173 -0
  12. package/glsl3/DirectionalWipe.glsl +1 -1
  13. package/glsl3/GlintDissolve.glsl +125 -0
  14. package/glsl3/HeatHaze.glsl +79 -0
  15. package/glsl3/Hologram.glsl +97 -0
  16. package/glsl3/InsetWipe.glsl +58 -0
  17. package/glsl3/LightningFlash.glsl +200 -0
  18. package/glsl3/LiquidFill.glsl +102 -0
  19. package/glsl3/PlasmaDissolve.glsl +51 -0
  20. package/glsl3/RingsWipe.glsl +106 -0
  21. package/glsl3/SawtoothWipe.glsl +73 -0
  22. package/glsl3/SnakeBlockWipe.glsl +40 -0
  23. package/glsl3/Snapshot.glsl +86 -0
  24. package/glsl3/Sphere.glsl +95 -0
  25. package/glsl3/SpiralBlockWipe.glsl +65 -0
  26. package/glsl3/Vortex.glsl +106 -0
  27. package/glsl3/WarpSpeed.glsl +120 -0
  28. package/index.js +1 -1
  29. package/layouts.json +846 -253
  30. package/llms-full.txt +665 -476
  31. package/llms.txt +197 -189
  32. package/msl/ArrowWipe.metal +391 -0
  33. package/msl/BandWipe.metal +353 -0
  34. package/msl/BlockSlide.metal +418 -0
  35. package/msl/BowTie.metal +1 -1
  36. package/msl/CellDissolve.metal +374 -0
  37. package/msl/Crumple.metal +766 -0
  38. package/msl/DirectionalWipe.metal +1 -1
  39. package/msl/GlintDissolve.metal +558 -0
  40. package/msl/HeatHaze.metal +320 -0
  41. package/msl/Hologram.metal +380 -0
  42. package/msl/InsetWipe.metal +232 -0
  43. package/msl/LightningFlash.metal +1038 -0
  44. package/msl/LiquidFill.metal +373 -0
  45. package/msl/PlasmaDissolve.metal +178 -0
  46. package/msl/RingsWipe.metal +437 -0
  47. package/msl/SawtoothWipe.metal +310 -0
  48. package/msl/SnakeBlockWipe.metal +216 -0
  49. package/msl/Snapshot.metal +321 -0
  50. package/msl/Sphere.metal +345 -0
  51. package/msl/SpiralBlockWipe.metal +281 -0
  52. package/msl/Vortex.metal +522 -0
  53. package/msl/WarpSpeed.metal +549 -0
  54. package/package.json +1 -1
  55. package/skills/gl-transitions/references/catalog.md +92 -59
  56. package/sksl/ArrowWipe.sksl +111 -0
  57. package/sksl/BandWipe.sksl +77 -0
  58. package/sksl/BlockSlide.sksl +99 -0
  59. package/sksl/BowTie.sksl +1 -1
  60. package/sksl/CellDissolve.sksl +103 -0
  61. package/sksl/Crumple.sksl +179 -0
  62. package/sksl/DirectionalWipe.sksl +1 -1
  63. package/sksl/GlintDissolve.sksl +136 -0
  64. package/sksl/HeatHaze.sksl +90 -0
  65. package/sksl/Hologram.sksl +108 -0
  66. package/sksl/InsetWipe.sksl +70 -0
  67. package/sksl/LightningFlash.sksl +202 -0
  68. package/sksl/LiquidFill.sksl +113 -0
  69. package/sksl/PlasmaDissolve.sksl +64 -0
  70. package/sksl/RingsWipe.sksl +115 -0
  71. package/sksl/SawtoothWipe.sksl +83 -0
  72. package/sksl/SnakeBlockWipe.sksl +53 -0
  73. package/sksl/Snapshot.sksl +98 -0
  74. package/sksl/Sphere.sksl +108 -0
  75. package/sksl/SpiralBlockWipe.sksl +76 -0
  76. package/sksl/Vortex.sksl +116 -0
  77. package/sksl/WarpSpeed.sksl +131 -0
  78. package/sksl/index.js +1 -1
  79. package/transitions/ArrowWipe.glsl +99 -0
  80. package/transitions/BandWipe.glsl +66 -0
  81. package/transitions/BlockSlide.glsl +86 -0
  82. package/transitions/BowTie.glsl +1 -1
  83. package/transitions/CellDissolve.glsl +90 -0
  84. package/transitions/Crumple.glsl +172 -0
  85. package/transitions/DirectionalWipe.glsl +1 -1
  86. package/transitions/GlintDissolve.glsl +124 -0
  87. package/transitions/HeatHaze.glsl +78 -0
  88. package/transitions/Hologram.glsl +96 -0
  89. package/transitions/InsetWipe.glsl +57 -0
  90. package/transitions/LightningFlash.glsl +199 -0
  91. package/transitions/LiquidFill.glsl +101 -0
  92. package/transitions/PlasmaDissolve.glsl +50 -0
  93. package/transitions/RingsWipe.glsl +105 -0
  94. package/transitions/SawtoothWipe.glsl +72 -0
  95. package/transitions/SnakeBlockWipe.glsl +39 -0
  96. package/transitions/Snapshot.glsl +85 -0
  97. package/transitions/Sphere.glsl +94 -0
  98. package/transitions/SpiralBlockWipe.glsl +64 -0
  99. package/transitions/Vortex.glsl +105 -0
  100. package/transitions/WarpSpeed.glsl +119 -0
  101. package/wgsl/ArrowWipe.wgsl +352 -0
  102. package/wgsl/BandWipe.wgsl +319 -0
  103. package/wgsl/BlockSlide.wgsl +384 -0
  104. package/wgsl/BowTie.wgsl +1 -1
  105. package/wgsl/CellDissolve.wgsl +323 -0
  106. package/wgsl/Crumple.wgsl +709 -0
  107. package/wgsl/DirectionalWipe.wgsl +1 -1
  108. package/wgsl/GlintDissolve.wgsl +519 -0
  109. package/wgsl/HeatHaze.wgsl +282 -0
  110. package/wgsl/Hologram.wgsl +339 -0
  111. package/wgsl/InsetWipe.wgsl +200 -0
  112. package/wgsl/LightningFlash.wgsl +964 -0
  113. package/wgsl/LiquidFill.wgsl +339 -0
  114. package/wgsl/PlasmaDissolve.wgsl +149 -0
  115. package/wgsl/RingsWipe.wgsl +394 -0
  116. package/wgsl/SawtoothWipe.wgsl +279 -0
  117. package/wgsl/SnakeBlockWipe.wgsl +188 -0
  118. package/wgsl/Snapshot.wgsl +287 -0
  119. package/wgsl/Sphere.wgsl +316 -0
  120. package/wgsl/SpiralBlockWipe.wgsl +250 -0
  121. package/wgsl/Vortex.wgsl +463 -0
  122. package/wgsl/WarpSpeed.wgsl +497 -0
  123. package/glsl3/BlockDissolve.glsl +0 -16
  124. package/glsl3/BowTieVertical.glsl +0 -117
  125. package/glsl3/Box.glsl +0 -33
  126. package/glsl3/LinearBlur.glsl +0 -30
  127. package/glsl3/MosaicBlend.glsl +0 -21
  128. package/glsl3/MosaicFade.glsl +0 -20
  129. package/glsl3/RotateFade.glsl +0 -22
  130. package/glsl3/ScaleIn.glsl +0 -18
  131. package/glsl3/WipeDown.glsl +0 -12
  132. package/glsl3/WipeLeft.glsl +0 -12
  133. package/glsl3/WipeRight.glsl +0 -12
  134. package/glsl3/WipeUp.glsl +0 -12
  135. package/msl/BlockDissolve.metal +0 -108
  136. package/msl/BowTieVertical.metal +0 -375
  137. package/msl/Box.metal +0 -204
  138. package/msl/LinearBlur.metal +0 -169
  139. package/msl/MosaicBlend.metal +0 -136
  140. package/msl/MosaicFade.metal +0 -137
  141. package/msl/RotateFade.metal +0 -116
  142. package/msl/ScaleIn.metal +0 -111
  143. package/msl/WipeDown.metal +0 -105
  144. package/msl/WipeLeft.metal +0 -105
  145. package/msl/WipeRight.metal +0 -105
  146. package/msl/WipeUp.metal +0 -105
  147. package/sksl/BlockDissolve.sksl +0 -29
  148. package/sksl/BowTieVertical.sksl +0 -130
  149. package/sksl/Box.sksl +0 -47
  150. package/sksl/LinearBlur.sksl +0 -44
  151. package/sksl/MosaicBlend.sksl +0 -34
  152. package/sksl/MosaicFade.sksl +0 -33
  153. package/sksl/RotateFade.sksl +0 -34
  154. package/sksl/ScaleIn.sksl +0 -32
  155. package/sksl/WipeDown.sksl +0 -26
  156. package/sksl/WipeLeft.sksl +0 -26
  157. package/sksl/WipeRight.sksl +0 -26
  158. package/sksl/WipeUp.sksl +0 -26
  159. package/transitions/BlockDissolve.glsl +0 -15
  160. package/transitions/BowTieVertical.glsl +0 -116
  161. package/transitions/Box.glsl +0 -32
  162. package/transitions/LinearBlur.glsl +0 -29
  163. package/transitions/MosaicBlend.glsl +0 -20
  164. package/transitions/MosaicFade.glsl +0 -19
  165. package/transitions/RotateFade.glsl +0 -21
  166. package/transitions/ScaleIn.glsl +0 -17
  167. package/transitions/WipeDown.glsl +0 -11
  168. package/transitions/WipeLeft.glsl +0 -11
  169. package/transitions/WipeRight.glsl +0 -11
  170. package/transitions/WipeUp.glsl +0 -11
  171. package/wgsl/BlockDissolve.wgsl +0 -78
  172. package/wgsl/BowTieVertical.wgsl +0 -331
  173. package/wgsl/Box.wgsl +0 -176
  174. package/wgsl/LinearBlur.wgsl +0 -131
  175. package/wgsl/MosaicBlend.wgsl +0 -108
  176. package/wgsl/MosaicFade.wgsl +0 -107
  177. package/wgsl/RotateFade.wgsl +0 -85
  178. package/wgsl/ScaleIn.wgsl +0 -79
  179. package/wgsl/WipeDown.wgsl +0 -77
  180. package/wgsl/WipeLeft.wgsl +0 -77
  181. package/wgsl/WipeRight.wgsl +0 -77
  182. package/wgsl/WipeUp.wgsl +0 -77
@@ -0,0 +1,100 @@
1
+ // ArrowWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ArrowWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A notched arrowhead window onto the incoming image flies in from the edge behind it (or appears at the center), then swells until it fills the frame
5
+ // Tags: shape, wipe, arrow, chevron, directional
6
+
7
+ // @param Direction the arrow points and flies toward
8
+ uniform vec2 direction; // = vec2(1.0, 0.0)
9
+ // @range(0, 0.9) Depth of the notch at the back of the arrowhead (0 for a plain triangle)
10
+ uniform float notch; // = 0.4
11
+ // @range(20, 160) Opening angle of the arrowhead's tip, in degrees
12
+ uniform float width; // = 80.0
13
+ // @range(1, 3, 1) Number of nested chevrons flying in a row
14
+ uniform int count; // = 1
15
+ // @param Grow the arrow from the center of the frame instead of flying it in
16
+ uniform bool origin; // = false
17
+ // @range(0, 0.1) Softness of the arrow's edges
18
+ uniform float smoothness; // = 0.004
19
+
20
+ // Signed distance (in frame heights) to an arrowhead whose tip is at x = tip and whose notch
21
+ // reaches back to x = back, in the arrow's frame (x along the direction, y = |across|)
22
+ float arrow(vec2 q, float tip, float back, vec2 tipN, vec2 notchN) {
23
+ float front = dot(vec2(q.x - tip, q.y), tipN);
24
+ float rear = dot(vec2(back - q.x, -q.y), notchN);
25
+ return max(front, rear);
26
+ }
27
+
28
+ vec4 transition(vec2 uv) {
29
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
30
+ vec2 across = vec2(-dir.y, dir.x);
31
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
32
+ vec2 q = vec2(dot(p, dir), abs(dot(p, across)));
33
+
34
+ float s = max(smoothness, 0.001);
35
+ float n = clamp(notch, 0.0, 0.9);
36
+ float h = radians(0.5 * clamp(width, 20.0, 160.0));
37
+ float cot = cos(h) / sin(h);
38
+ // outward normals of the tip's edges and of the notch's edges
39
+ vec2 tipN = vec2(sin(h), cos(h));
40
+ float notchLen = length(vec2(1.0, n * cot));
41
+ vec2 notchN = vec2(1.0, n * cot) / notchLen;
42
+ // how far the tip must pass a point for the soft edge to clear it
43
+ float tipPad = s / sin(h);
44
+
45
+ // The frame's corners in the arrow's frame
46
+ vec2 c1 = vec2(0.5 * ratio, 0.5);
47
+ vec2 c2 = vec2(0.5 * ratio, -0.5);
48
+ vec2 k1 = vec2(abs(dot(c1, dir)), abs(dot(c1, across)));
49
+ vec2 k2 = vec2(abs(dot(c2, dir)), abs(dot(c2, across)));
50
+ // half extent of the frame along the direction, and where its back edge crosses the axis
51
+ float e = max(k1.x, k2.x);
52
+ float r = 0.5 / max(abs(dir.x) / ratio, abs(dir.y));
53
+ // To cover the frame, the tip must be ahead of every corner, and the notch behind every
54
+ // corner and behind the back edge's middle (with room for the soft edge)
55
+ float tipMin = max(k1.x + k1.y * cot, k2.x + k2.y * cot) + tipPad;
56
+ float notchMax = min(min(n * cot * k1.y - k1.x, n * cot * k2.y - k2.x), -r) - s * notchLen;
57
+
58
+ // The arrow (length 1 from tip to barbs) turns around the middle of its axis: its tip is
59
+ // half its body ahead of that point, its notch half its body behind
60
+ float body = 0.5 * (1.0 - n);
61
+ // The scale at which the arrow centered on the frame covers it
62
+ float cover = max(tipMin, -notchMax) / body;
63
+
64
+ float t = progress;
65
+ float o; // middle of the arrow
66
+ float l; // size of the arrow
67
+ if (origin) {
68
+ o = 0.0;
69
+ l = cover * t * (0.4 + 0.6 * t);
70
+ } else {
71
+ // while it flies, its larger side (length or span) is about the frame's smaller side
72
+ float l0 = 0.92 * min(1.0, ratio) / max(1.0, 2.0 * tan(h));
73
+ // starts just behind the frame, flies to the middle, then swells
74
+ float o0 = -e - 2.0 * tipPad - body * l0;
75
+ // it is already moving when it enters, and slows down as it starts to swell
76
+ float u = 1.0 - clamp(t / 0.65, 0.0, 1.0);
77
+ float fly = 1.0 - u * u * u;
78
+ // the swell speeds up and still moves at the end, so the last corners do not linger
79
+ float grow = clamp((t - 0.3) / 0.7, 0.0, 1.0);
80
+ o = mix(o0, 0.0, fly);
81
+ l = mix(l0, cover, grow * grow * (2.0 - grow));
82
+ }
83
+
84
+ // the nested chevrons follow the first one, each tucked behind the previous one's notch
85
+ float gap = (1.0 - n) * 1.35;
86
+ float d = arrow(q, o + body * l, o - body * l, tipN, notchN);
87
+ for (int i = 1; i < 3; i++) {
88
+ if (i < count) {
89
+ float back = o - float(i) * gap * l;
90
+ d = min(d, arrow(q, back + body * l, back - body * l, tipN, notchN));
91
+ }
92
+ }
93
+ // the soft edge slides from outside the arrow to inside it, so nothing shows at the start
94
+ float m = 1.0 - smoothstep(-s, s, d + 2.0 * s * (1.0 - t));
95
+
96
+ vec4 a = getFromColor(uv);
97
+ vec4 b = getToColor(uv);
98
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
99
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
100
+ }
@@ -0,0 +1,67 @@
1
+ // BandWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BandWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Alternating bands wipe in from opposite sides together and interleave like fingers, while both images stay still
5
+ // Tags: wipe, stripes, interleave, horizontal
6
+
7
+ // @range(2, 40, 1) Number of bands
8
+ uniform int bands; // = 8
9
+ // @param Cut the frame into columns that wipe up and down instead of rows that wipe sideways
10
+ uniform bool vertical; // = false
11
+ // @range(0, 0.2) Softness of the bands' leading edges
12
+ uniform float smoothness; // = 0.02
13
+ // @range(0, 0.8) Delay between the first and the last band, so they cascade from the top (or the left)
14
+ uniform float stagger; // = 0.1
15
+
16
+ // half width of the antialiased edges, in frame heights
17
+ const float AA = 0.0015;
18
+
19
+ // how far band i has wiped in (0..1) at position a along the bands (0..l), alternate bands
20
+ // entering from opposite ends
21
+ float bandMask(float i, float n, float a, float l, float s) {
22
+ // each band takes the same time, starting a little after the one before it from the top
23
+ // (or the left)
24
+ float k = vertical ? i : n - 1.0 - i;
25
+ float g = clamp(stagger, 0.0, 0.95);
26
+ float t = clamp((progress - g * k / max(n - 1.0, 1.0)) / (1.0 - g), 0.0, 1.0);
27
+ t = mix(t, t * t * (3.0 - 2.0 * t), 0.5);
28
+ float x = mod(i, 2.0) > 0.5 ? l - a : a;
29
+ // the edge starts fully before the band and ends fully past it
30
+ float c = mix(-s, l + s, t);
31
+ return 1.0 - smoothstep(c - s, c + s, x);
32
+ }
33
+
34
+ vec4 transition(vec2 uv) {
35
+ if (progress <= 0.0) return getFromColor(uv);
36
+ if (progress >= 1.0) return getToColor(uv);
37
+
38
+ float n = float(bands < 1 ? 1 : bands);
39
+ // along: position along the bands, in frame heights; across: position across them (0..1)
40
+ float along = vertical ? uv.y : uv.x * ratio;
41
+ float across = vertical ? uv.x : uv.y;
42
+ float l = vertical ? 1.0 : ratio;
43
+ // the antialiasing across the bands, in units of across
44
+ float aaAcross = vertical ? AA / ratio : AA;
45
+ float s = max(smoothness, AA);
46
+
47
+ float f = across * n;
48
+ float i = clamp(floor(f), 0.0, n - 1.0);
49
+ float m = bandMask(i, n, along, l, s);
50
+
51
+ // near a cut between two bands, blend with the neighbor band over a pixel or so so the cut
52
+ // does not alias (at the frame's borders the neighbor is the band itself)
53
+ float fr = f - i;
54
+ float edge = min(fr, 1.0 - fr) / n;
55
+ if (edge < aaAcross) {
56
+ float j = clamp(fr < 0.5 ? i - 1.0 : i + 1.0, 0.0, n - 1.0);
57
+ m = mix(bandMask(j, n, along, l, s), m, 0.5 + 0.5 * smoothstep(0.0, aaAcross, edge));
58
+ }
59
+
60
+ if (m <= 0.0) return getFromColor(uv);
61
+ if (m >= 1.0) return getToColor(uv);
62
+ vec4 a = getFromColor(uv);
63
+ vec4 b = getToColor(uv);
64
+ // mixed premultiplied, so transparent images do not bleed their color
65
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
66
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
67
+ }
@@ -0,0 +1,87 @@
1
+ // BlockSlide — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BlockSlide.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The frame is cut into a grid of blocks that slide out one after another in a staggered cascade, some of them shrinking as they go, while the blocks of the incoming image slide in behind them to take their place
5
+ // Tags: slide, blocks, grid, directional, zoom
6
+
7
+ // @param Number of blocks (columns, rows), at most 40 along the direction
8
+ uniform ivec2 grid; // = ivec2(5, 4)
9
+ // @param Direction the blocks slide toward (rounded to the nearest axis)
10
+ uniform vec2 direction; // = vec2(1.0, 0.0)
11
+ // @range(0, 0.95) Share of the transition over which the blocks set off one after another (0 slides them all together)
12
+ uniform float stagger; // = 0.6
13
+ // @range(0, 0.9) How much the zooming blocks shrink on their way, as a share of their size
14
+ uniform float zoom; // = 0.35
15
+ // @color Color seen in the gaps between the blocks
16
+ uniform vec4 background; // = vec4(0.0, 0.0, 0.0, 1.0)
17
+
18
+ // blocks per strip, at most
19
+ const int MAX_BLOCKS = 40;
20
+
21
+ float hash(vec2 p) {
22
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
23
+ p3 += dot(p3, p3.yzx + 33.33);
24
+ return fract((p3.x + p3.y) * p3.z);
25
+ }
26
+
27
+ vec4 transition(vec2 uv) {
28
+ if (progress <= 0.0) return getFromColor(uv);
29
+ if (progress >= 1.0) return getToColor(uv);
30
+
31
+ bool vertical = abs(direction.y) > abs(direction.x);
32
+ bool backward = vertical ? direction.y < 0.0 : direction.x < 0.0;
33
+ vec2 g = max(vec2(grid), 1.0);
34
+ // a: position along the motion, toward which the blocks slide, b: across it
35
+ float a = vertical ? uv.y : uv.x;
36
+ float b = vertical ? uv.x : uv.y;
37
+ if (backward) a = 1.0 - a;
38
+ float n = min(vertical ? g.y : g.x, float(MAX_BLOCKS));
39
+ float strips = vertical ? g.x : g.y;
40
+ // every block of a strip slides along it, so a point can only show a block of its own strip
41
+ float r = min(floor(b * strips), strips - 1.0);
42
+ // the strips set off one after another, from the top (or the left)
43
+ float rowOrder = strips > 1.0 ? (vertical ? r : strips - 1.0 - r) / (strips - 1.0) : 0.0;
44
+ float st = clamp(stagger, 0.0, 0.95);
45
+ float z = clamp(zoom, 0.0, 0.9);
46
+ // in blocks
47
+ float an = a * n;
48
+ float bn = b * strips - r;
49
+
50
+ // the incoming blocks follow the last outgoing block to leave, the rear one: they all
51
+ // stay behind it, so no block ever overlaps another, and each one gets closer to the
52
+ // block ahead of it until they all arrive together
53
+ float rear = clamp((progress - st * mix(rowOrder, 1.0, 0.2)) / (1.0 - st), 0.0, 1.0);
54
+ rear = rear * rear * (3.0 - 2.0 * rear);
55
+
56
+ for (int k = 0; k < MAX_BLOCKS; k++) {
57
+ float i = float(k);
58
+ if (i >= n) break;
59
+ // the block at the front sets off first, so that the outgoing blocks move apart
60
+ float order = mix(rowOrder, n > 1.0 ? (n - 1.0 - i) / (n - 1.0) : 0.0, 0.2);
61
+ float p = clamp((progress - st * order) / (1.0 - st), 0.0, 1.0);
62
+ p = p * p * (3.0 - 2.0 * p);
63
+ float pin = max(0.0, 1.0 - (1.0 - rear) * (1.0 + (n - 1.0 - i) / n));
64
+ // about half of the blocks shrink as they leave, and their incoming blocks grow as they come
65
+ float zi = hash(vec2(i, r) + 3.7) < 0.5 ? z : 0.0;
66
+ // position in the block, from its corner, for the outgoing block (xy), which travels the
67
+ // frame's length to leave it, and the incoming one (zw), from one length behind; at rest,
68
+ // the blocks tile the frame exactly
69
+ float sFrom = 1.0 - zi * p * p;
70
+ float sTo = 1.0 - zi * (1.0 - pin) * (1.0 - pin);
71
+ vec4 l = vec4(
72
+ (an - i - p * n - 0.5 * (1.0 - sFrom)) / sFrom,
73
+ (bn - 0.5 * (1.0 - sFrom)) / sFrom,
74
+ (an - i - (pin - 1.0) * n - 0.5 * (1.0 - sTo)) / sTo,
75
+ (bn - 0.5 * (1.0 - sTo)) / sTo);
76
+ bool inFrom = all(greaterThanEqual(l.xy, vec2(0.0))) && all(lessThan(l.xy, vec2(1.0)));
77
+ bool inTo = all(greaterThanEqual(l.zw, vec2(0.0))) && all(lessThan(l.zw, vec2(1.0)));
78
+ if (inFrom || inTo) {
79
+ // back to the frame's coordinates
80
+ vec2 q = (vec2(i, r) + (inTo ? l.zw : l.xy)) / vec2(n, strips);
81
+ if (backward) q.x = 1.0 - q.x;
82
+ q = vertical ? q.yx : q;
83
+ return inTo ? getToColor(q) : getFromColor(q);
84
+ }
85
+ }
86
+ return background;
87
+ }
package/glsl3/BowTie.glsl CHANGED
@@ -1,7 +1,7 @@
1
1
  // BowTie — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BowTie.glsl
2
2
  // Author: KMojek
3
3
  // License: MIT
4
- // Description: A bow-tie wipe with an adjustable shape that can run in reverse
4
+ // Description: Two triangles grow from the top and bottom edges into a bow tie that reveals the incoming image, with an adjustable shape, and can run in reverse
5
5
  // Tags: wipe, shape
6
6
 
7
7
  uniform float adjust; // = 0.5
@@ -0,0 +1,91 @@
1
+ // CellDissolve — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CellDissolve.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Irregular cells, like cracked mud or soap foam, switch to the incoming image one by one, with an optional bright border glowing along the cracks between them
5
+ // Tags: dissolve, cells, voronoi, random
6
+
7
+ // @range(1, 40) Number of cells across the height of the frame
8
+ uniform float cells; // = 8.0
9
+ // @range(0, 1) Duration of each cell's switch, as a fraction of the transition (0: each cell switches at once)
10
+ uniform float smoothness; // = 0.1
11
+ // @range(0, 0.05) Width of the border along the cell edges, in frame heights (0: no border)
12
+ uniform float border; // = 0.006
13
+ // @color Color of the border
14
+ uniform vec4 borderColor; // = vec4(1.0, 0.95, 0.8, 1.0)
15
+ // @param Random seed: another value gives other cells, switching in another order
16
+ uniform float seed; // = 0.0
17
+
18
+ // half width of the antialiased edges, in frame heights
19
+ const float AA = 0.0015;
20
+
21
+ vec2 hash22(vec2 p) {
22
+ vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
23
+ p3 += dot(p3, p3.yzx + 33.33);
24
+ return fract((p3.xx + p3.yz) * p3.zy);
25
+ }
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
+ float n = max(cells, 1.0);
34
+ // measured in square pixels, so the cells are not stretched
35
+ vec2 p = uv * vec2(ratio, 1.0) * n;
36
+ vec2 i = floor(p);
37
+ vec2 f = p - i;
38
+ vec2 offset = vec2(17.31, 41.97) * seed;
39
+
40
+ // nearest cell point
41
+ vec2 mg = vec2(0.0);
42
+ vec2 mr = vec2(0.0);
43
+ float md = 8.0;
44
+ for (int y = -1; y <= 1; y++) {
45
+ for (int x = -1; x <= 1; x++) {
46
+ vec2 g = vec2(float(x), float(y));
47
+ vec2 r = g + hash22(i + g + offset) - f;
48
+ float d = dot(r, r);
49
+ if (d < md) {
50
+ md = d;
51
+ mr = r;
52
+ mg = g;
53
+ }
54
+ }
55
+ }
56
+
57
+ // distance to the nearest cell edge: the bisector with the closest neighbor point,
58
+ // searched over 5x5 cells around the nearest one so that no edge is missed
59
+ float edge = 8.0;
60
+ for (int y = -2; y <= 2; y++) {
61
+ for (int x = -2; x <= 2; x++) {
62
+ vec2 g = mg + vec2(float(x), float(y));
63
+ vec2 r = g + hash22(i + g + offset) - f;
64
+ vec2 dr = r - mr;
65
+ if (dot(dr, dr) > 0.00001) {
66
+ edge = min(edge, dot(0.5 * (mr + r), normalize(dr)));
67
+ }
68
+ }
69
+ }
70
+ // in frame heights
71
+ edge /= n;
72
+
73
+ // the cell's own switch time, from its hash
74
+ float h = hash22(i + mg + offset + 97.13).x;
75
+ float w = clamp(smoothness, 0.0, 1.0);
76
+ float start = h * (1.0 - w);
77
+ float m = w > 0.0 ? smoothstep(start, start + w, progress) : step(start, progress);
78
+
79
+ // mixed premultiplied, so transparent images do not bleed their color
80
+ vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
81
+
82
+ // the cracks open at the start and close at the end
83
+ float open = smoothstep(0.0, 0.2, progress) * (1.0 - smoothstep(0.8, 1.0, progress));
84
+ float bw = max(border, 0.0) * open;
85
+ if (bw > 0.0) {
86
+ float l = 1.0 - smoothstep(0.5 * bw - AA, 0.5 * bw + AA, edge);
87
+ float ba = borderColor.a * l * min(1.0, bw / (2.0 * AA));
88
+ c = vec4(borderColor.rgb * ba, ba) + c * (1.0 - ba);
89
+ }
90
+ return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
91
+ }
@@ -0,0 +1,173 @@
1
+ // Crumple — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Crumple.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image crumples into a creased paper ball, shaded along its folds, which is then tossed away to reveal the incoming image
5
+ // Tags: paper, 3d, shrink, shadow
6
+
7
+ // @range(1, 32, 1) Number of folds creasing the paper
8
+ uniform int creases; // = 16
9
+ // @range(0.05, 0.4) Radius of the paper ball, relative to the image height
10
+ uniform float size; // = 0.2
11
+ // @param Direction the ball is tossed toward
12
+ uniform vec2 direction; // = vec2(1.0, 0.4)
13
+ // @color Color of the bare paper showing through the ink along the sharpest creases
14
+ uniform vec4 paper; // = vec4(0.96, 0.95, 0.91, 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.45)
17
+
18
+ const float PI = 3.14159265;
19
+
20
+ vec2 hash2(vec2 p) {
21
+ p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));
22
+ return fract(sin(p) * 43758.5453);
23
+ }
24
+
25
+ mat2 rot(float a) {
26
+ float s = sin(a);
27
+ float c = cos(a);
28
+ return mat2(c, -s, s, c);
29
+ }
30
+
31
+ // distance from the center to the edge of the frame in the direction a (unit vector)
32
+ float frame(vec2 a) {
33
+ return min(0.5 * ratio / max(abs(a.x), 1e-4), 0.5 / max(abs(a.y), 1e-4));
34
+ }
35
+
36
+ // distance from the center to the edge of the paper in the direction a (unit vector):
37
+ // the frame shrinking and buckling while it crumples (c), turning into a lumpy ball (k)
38
+ float outline(vec2 a, float c, float k, float radius) {
39
+ float rect = frame(a);
40
+ float th = atan(a.y, a.x);
41
+ float buckle = 0.03 + 0.05 * abs(sin(4.0 * th + 0.7)) + 0.03 * abs(sin(9.0 * th + 2.0)) + 0.015 * abs(sin(23.0 * th + 1.3));
42
+ // the ball is a polygon with irregular corners
43
+ float i = floor((th / (2.0 * PI) + 0.5) * 9.0);
44
+ float a0 = i * 2.0 * PI / 9.0 - PI;
45
+ float a1 = a0 + 2.0 * PI / 9.0;
46
+ vec2 v0 = vec2(cos(a0), sin(a0)) * (0.78 + 0.27 * hash2(vec2(mod(i, 9.0), 3.0)).x);
47
+ vec2 v1 = vec2(cos(a1), sin(a1)) * (0.78 + 0.27 * hash2(vec2(mod(i + 1.0, 9.0), 3.0)).x);
48
+ vec2 e = v1 - v0;
49
+ float ball = radius * (v0.x * e.y - v0.y * e.x) / (a.x * e.y - a.y * e.x);
50
+ return mix(rect * mix(1.0, 0.75, c) * (1.0 - c * buckle), ball, k);
51
+ }
52
+
53
+ // n straight creases of random position, orientation and length, in a space where the
54
+ // paper spans about [-span, span]; each one tilts the paper on its two sides (a sharp ridge
55
+ // or valley between flat facets) and swallows a strip of the image. They come one after
56
+ // another as c grows; px is the half width of a crease line, in the units of x.
57
+ void fold(vec2 x, float seed, int n, vec2 span, float len, float c, float px, float weight,
58
+ inout vec2 grad, inout vec2 shift, inout float valley, inout float ridge) {
59
+ float tilt = 2.0 / sqrt(float(n));
60
+ for (int i = 0; i < 32; i++) {
61
+ if (i >= n) break;
62
+ float fi = float(i);
63
+ vec2 h = hash2(vec2(fi, seed));
64
+ vec2 g = hash2(vec2(fi, seed + 11.8));
65
+ vec2 o = (h - 0.5) * 2.0 * span;
66
+ vec2 nrm = vec2(cos(2.0 * PI * g.x), sin(2.0 * PI * g.x));
67
+ float d = dot(x - o, nrm);
68
+ float along = dot(x - o, vec2(-nrm.y, nrm.x));
69
+ float l = len * (0.5 + g.y);
70
+ float start = 0.4 * fi / float(n);
71
+ float act = weight * smoothstep(start, start + 0.3, c) * (1.0 - smoothstep(0.5 * l, l, abs(along)));
72
+ float amp = (h.x > 0.5 ? 1.0 : -1.0) * (0.5 + 0.5 * h.y);
73
+ float side = d / (abs(d) + px);
74
+ grad += act * amp * side * nrm * tilt;
75
+ shift += act * 0.03 * side * nrm;
76
+ float line = 1.0 - smoothstep(0.0, 2.0 * px, abs(d));
77
+ if (amp < 0.0) valley += act * line;
78
+ else ridge += act * line * amp;
79
+ }
80
+ }
81
+
82
+ vec4 transition(vec2 uv) {
83
+ if (progress <= 0.0) return getFromColor(uv);
84
+ vec4 b = getToColor(uv);
85
+ if (progress >= 1.0) return b;
86
+
87
+ // crumpling (c), balling up (k), then tossing (t)
88
+ float c = smoothstep(0.0, 0.6, progress);
89
+ float k = smoothstep(0.1, 0.62, progress);
90
+ float t = smoothstep(0.58, 1.0, progress);
91
+ t *= t;
92
+
93
+ vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
94
+ float radius = max(size, 0.01) * mix(1.0, 0.6, t);
95
+ // far enough along the direction for the ball and its shadow (offset and blurred by up
96
+ // to about 0.09 each) to leave the frame
97
+ float reach = 0.5 * (abs(dir.x) * ratio + abs(dir.y)) + 1.2 * radius + 0.3;
98
+ float bend = dir.x < 0.0 ? -1.0 : 1.0;
99
+ vec2 center = dir * reach * t + vec2(-dir.y, dir.x) * 0.15 * bend * sin(PI * t);
100
+ float angle = 0.6 * c - 5.0 * bend * t;
101
+ // how high the paper is above the incoming image
102
+ float lift = 0.012 * c + 0.06 * t;
103
+
104
+ vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
105
+
106
+ // soft shadow on the incoming image
107
+ vec2 sp = rot(angle) * (p - center - vec2(0.6, -1.0) * lift);
108
+ float sl = length(sp);
109
+ float sd = sl - outline(sl > 1e-5 ? sp / sl : vec2(1.0, 0.0), c, k, radius);
110
+ float blur = 0.005 + 1.2 * lift;
111
+ vec4 col = vec4(mix(b.rgb, shadow.rgb, shadow.a * c * (1.0 - smoothstep(-blur, blur, sd))), b.a);
112
+
113
+ vec2 q = rot(angle) * (p - center);
114
+ float l = length(q);
115
+ vec2 dq = l > 1e-5 ? q / l : vec2(1.0, 0.0);
116
+ float edge = outline(dq, c, k, radius);
117
+ // the edge (about a pixel at 300 px high) is antialiased only once the sheet has left the
118
+ // borders of the frame
119
+ float aa = 0.003 * smoothstep(0.0, 0.1, progress) + 1e-5;
120
+ float inside = 1.0 - smoothstep(-aa, aa, l - edge);
121
+ if (inside <= 0.0) return col;
122
+
123
+ // back onto the flat sheet: the outline is mapped onto the frame, the middle of the ball
124
+ // holds more of it, as if the edges were tucked under
125
+ float r = l / edge;
126
+ float rect = frame(dq);
127
+ vec2 s = dq * rect * mix(r, r * (0.6 + 0.4 * r), k);
128
+
129
+ // the creases of the sheet, then those of the ball, that crumpling adds over them
130
+ int count = creases < 1 ? 1 : creases;
131
+ vec2 grad = vec2(0.0);
132
+ vec2 shift = vec2(0.0);
133
+ float valley = 0.0;
134
+ float ridge = 0.0;
135
+ fold(s, 7.3, count, 0.45 * vec2(ratio, 1.0), 0.6, c, 0.003 * rect / edge, 1.0 - 0.8 * k, grad, shift, valley, ridge);
136
+ vec2 g2 = vec2(0.0);
137
+ vec2 s2 = vec2(0.0);
138
+ float v2 = 0.0;
139
+ float r2 = 0.0;
140
+ fold(q / radius, 2.9, count, vec2(0.7), 8.0, k, 0.003 / radius, k, g2, s2, v2, r2);
141
+ grad += g2 * 0.8;
142
+ vec2 piece = s + shift + s2 * 3.0;
143
+
144
+ // the facets over the volume of the ball, lit from the top left (the light does not turn
145
+ // with the ball)
146
+ float rr = clamp(l / (radius * 1.1), 0.0, 1.0);
147
+ vec3 sphere = vec3(q / (radius * 1.1) * k * 0.8, sqrt(1.0 - 0.64 * rr * rr * k));
148
+ vec3 n = normalize(sphere + vec3(grad, 0.0));
149
+ n.xy = rot(-angle) * n.xy;
150
+ vec3 light = normalize(vec3(-0.5, 0.6, 0.8));
151
+ float diffuse = max(dot(n, light), 0.0);
152
+ vec3 hv = normalize(light + vec3(0.0, 0.0, 1.0));
153
+ // only what facets add over the flat sheet
154
+ float spec = max(pow(max(dot(n, hv), 0.0), 20.0) - pow(hv.z, 20.0), 0.0);
155
+ float level = light.z;
156
+ float relief = min(2.0 * c, 1.0);
157
+ float shade = 1.0 + relief * ((0.12 + diffuse) / (0.12 + level) - 1.0) + 0.7 * spec * relief;
158
+ shade -= 0.2 * relief * min(valley, 1.0);
159
+ // occlusion toward the rim of the ball
160
+ shade *= 1.0 - 0.3 * k * smoothstep(0.6, 1.0, r);
161
+
162
+ // the edges of the sheet that the folds pull in are mirrored, as if folded back
163
+ vec2 f = piece / vec2(ratio, 1.0) + 0.5;
164
+ vec4 img = getFromColor(1.0 - abs(1.0 - mod(f, 2.0)));
165
+ // the ink cracks along the ridges
166
+ img.rgb = mix(img.rgb, paper.rgb, 0.6 * min(ridge, 1.0) * paper.a * c);
167
+ vec4 ball = vec4(img.rgb * shade, img.a);
168
+
169
+ // mixed premultiplied, so transparent images do not bleed their color
170
+ float m = inside * ball.a;
171
+ vec4 o = vec4(mix(col.rgb * col.a, ball.rgb, m), mix(col.a, 1.0, m));
172
+ return o.a > 0.0 ? vec4(o.rgb / o.a, o.a) : vec4(0.0);
173
+ }
@@ -1,7 +1,7 @@
1
1
  // DirectionalWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/DirectionalWipe.glsl
2
2
  // Author: gre
3
3
  // License: MIT
4
- // Description: A soft-edged diagonal wipe
4
+ // Description: A straight wipe in any direction, diagonal and soft-edged by default; a smoothness of 0 gives a hard edge
5
5
  // Tags: wipe, directional
6
6
 
7
7
  // @param Direction of the wipe
@@ -0,0 +1,125 @@
1
+ // GlintDissolve — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/GlintDissolve.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The bright points of the outgoing image sparkle into crisp four-point star glints that swell and twinkle up to the cut, then shrink back into the highlights of the incoming image, which stays sharp
5
+ // Tags: light, glints, sparkle, dissolve
6
+
7
+ // @range(0.02, 0.3) Length of the longest rays of the glints at the peak, in frame heights
8
+ uniform float size; // = 0.15
9
+ // @range(0, 1) Brightness above which the image sparkles
10
+ uniform float threshold; // = 0.6
11
+ // @range(0, 4) Brightness of the glints
12
+ uniform float intensity; // = 2.0
13
+ // @param Add a shorter, softer pair of diagonal rays to each glint
14
+ uniform bool diagonals; // = false
15
+ // @range(-45, 45) Angle of the cross, in degrees
16
+ uniform float rotation; // = 0.0
17
+ // @range(0, 1) Rainbow fringes along the rays
18
+ uniform float rainbow; // = 0.35
19
+ // @color Tint of the glints, added as light
20
+ uniform vec3 tint; // = vec3(1.0, 0.95, 0.85)
21
+
22
+ // the long rays reach over this many cells of the glint grid
23
+ const float REACH = 6.0;
24
+
25
+ float hash12(vec2 v) {
26
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
27
+ v3 += dot(v3, v3.yzx + 33.33);
28
+ return fract((v3.x + v3.y) * v3.z);
29
+ }
30
+
31
+ // one thin ray along x, from the glint center to its tip at x = len (in cells)
32
+ float ray(vec2 d, float len, float width) {
33
+ float a = abs(d.x) / len;
34
+ if (a >= 1.0) return 0.0;
35
+ float fall = (1.0 - a) * (1.0 - a);
36
+ float w = width * (1.0 - 0.7 * a);
37
+ return fall * exp(-d.y * d.y / (w * w));
38
+ }
39
+
40
+ vec3 spectrum(float a) {
41
+ return 0.5 + 0.5 * cos(6.2831853 * (a + vec3(0.0, 0.33, 0.67)));
42
+ }
43
+
44
+ vec4 transition(vec2 uv) {
45
+ float p = progress;
46
+ // the glints swell up to the cut, then shrink back: 0 at both ends
47
+ float t = 1.0 - abs(2.0 * p - 1.0);
48
+ float amount = t * (2.0 - t);
49
+ // a short crossfade under the glints at their brightest
50
+ float m = smoothstep(0.42, 0.58, p);
51
+ if (amount <= 0.0) return m < 0.5 ? getFromColor(uv) : getToColor(uv);
52
+
53
+ vec4 fromColor = getFromColor(uv);
54
+ vec4 toColor = getToColor(uv);
55
+ vec4 c = mix(vec4(fromColor.rgb * fromColor.a, fromColor.a), vec4(toColor.rgb * toColor.a, toColor.a), m);
56
+ if (c.a <= 0.0) return vec4(0.0);
57
+ vec3 base = c.rgb / c.a;
58
+
59
+ // a grid of glint cells, turned with the cross so that its long rays run along the rows and columns
60
+ float cell = size / REACH;
61
+ float ang = radians(rotation);
62
+ vec2 cs = vec2(cos(ang), sin(ang));
63
+ vec2 aspect = vec2(ratio, 1.0);
64
+ vec2 o = (uv - 0.5) * aspect;
65
+ vec2 q = vec2(o.x * cs.x + o.y * cs.y, o.y * cs.x - o.x * cs.y) / cell;
66
+ vec2 home = floor(q);
67
+ // thin rays, in cells, thin enough to vanish before the next row of cells
68
+ float width = min(0.0022 / cell, 0.07);
69
+
70
+ vec3 light = vec3(0.0);
71
+ // the glints of the own cell, of the cells along its row and column (whose long rays reach this
72
+ // pixel) and of its four diagonal neighbours (for their short diagonal rays and their cores)
73
+ for (int k = 0; k < 29; k++) {
74
+ float fk = float(k);
75
+ vec2 off = vec2(0.0);
76
+ if (k >= 1 && k <= 12) off = vec2(fk < 7.0 ? fk - 7.0 : fk - 6.0, 0.0);
77
+ else if (k >= 13 && k <= 24) off = vec2(0.0, fk < 19.0 ? fk - 19.0 : fk - 18.0);
78
+ else if (k >= 25) off = vec2(mod(fk, 2.0) * 2.0 - 1.0, fk < 27.0 ? -1.0 : 1.0);
79
+ // the rays are never longer than this, so farther glints cannot reach the pixel
80
+ if (max(abs(off.x), abs(off.y)) > REACH * amount + 1.0) continue;
81
+ vec2 id = home + off;
82
+ // only some of the cells hold a glint
83
+ if (hash12(id + 89.5) > 0.55) continue;
84
+ float h0 = hash12(id + 0.5);
85
+ float h1 = hash12(id + 19.5);
86
+ float h2 = hash12(id + 41.5);
87
+ float h3 = hash12(id + 67.5);
88
+ // the glint: somewhere in its cell, so that the grid never shows
89
+ vec2 center = id + 0.5 + 0.6 * (vec2(h0, h1) - 0.5);
90
+ vec2 cw = center * cell;
91
+ vec2 st = vec2(cw.x * cs.x - cw.y * cs.y, cw.x * cs.y + cw.y * cs.x) / aspect + 0.5;
92
+ if (st.x < 0.0 || st.x > 1.0 || st.y < 0.0 || st.y > 1.0) continue;
93
+ // each glint reads one image: it blinks out at its own moment of the crossfade and comes back
94
+ // on the incoming image
95
+ float turn = 0.15 + 0.7 * h3;
96
+ vec4 src = m < turn ? getFromColor(st) : getToColor(st);
97
+ float lum = dot(src.rgb, vec3(0.2126, 0.7152, 0.0722)) * src.a;
98
+ // the brighter the image, the more of its cells sparkle
99
+ float knee = threshold + 0.8 * (1.0 - threshold) * h2;
100
+ float b = smoothstep(knee, knee + 0.2 * (1.0 - threshold) + 1e-3, lum);
101
+ if (b <= 0.0) continue;
102
+ // each glint twinkles at its own pace
103
+ float twinkle = (0.6 + 0.4 * sin(6.2831853 * (h2 + (1.5 + h0) * p))) * smoothstep(0.0, 0.12, abs(m - turn));
104
+ float len = REACH * amount * (0.45 + 0.55 * b) * (0.3 + 0.7 * h1 * h1) * (0.85 + 0.15 * twinkle);
105
+ vec2 d = q - center;
106
+ float r = length(d);
107
+ float star = ray(d, len, width) + ray(d.yx, len, width);
108
+ if (diagonals) {
109
+ vec2 e = vec2(d.x + d.y, d.x - d.y) * 0.70710678;
110
+ star += 0.5 * (ray(e, 0.25 * len, width) + ray(e.yx, 0.25 * len, width));
111
+ }
112
+ // a bright core and a faint halo
113
+ float cr = r / (0.08 * len);
114
+ star += exp(-cr * cr) + 0.3 * exp(-r / 0.2);
115
+ // white light with the hue of the highlight, and rainbow fringes toward the tips
116
+ float along = r / len;
117
+ vec3 hue = mix(vec3(1.0), spectrum(1.3 * along + h0), rainbow * smoothstep(0.05, 0.4, along));
118
+ vec3 col = mix(src.rgb / max(max(src.r, max(src.g, src.b)), 1e-3), vec3(1.0), 0.6);
119
+ light += b * twinkle * star * hue * col;
120
+ }
121
+ light *= tint * intensity * amount * amount;
122
+ // compressed, so that crossing rays never flatten into white
123
+ light = 1.0 - exp(-light);
124
+ return vec4(clamp(base + light - base * light, 0.0, 1.0), c.a);
125
+ }