gl-transitions 2.2.0 → 2.4.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 (156) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/compatibility.json +464 -0
  3. package/gl-transitions.js +1 -1
  4. package/gl-transitions.json +1 -1
  5. package/glsl3/Accordion.glsl +85 -0
  6. package/glsl3/Ascii.glsl +124 -0
  7. package/glsl3/BlockCover.glsl +87 -0
  8. package/glsl3/BloomDissolve.glsl +110 -0
  9. package/glsl3/BokehDissolve.glsl +123 -0
  10. package/glsl3/BrushWipe.glsl +100 -0
  11. package/glsl3/CameraShake.glsl +98 -0
  12. package/glsl3/CardSwipe.glsl +81 -0
  13. package/glsl3/ColorPanelWipe.glsl +75 -0
  14. package/glsl3/CurvedWipe.glsl +52 -0
  15. package/glsl3/Disintegrate.glsl +112 -0
  16. package/glsl3/EyeBlink.glsl +83 -0
  17. package/glsl3/FilmDissolve.glsl +49 -0
  18. package/glsl3/FilmStrip.glsl +105 -0
  19. package/glsl3/FlameWipe.glsl +154 -0
  20. package/glsl3/Gallery.glsl +133 -0
  21. package/glsl3/GooeyWipe.glsl +97 -0
  22. package/glsl3/InkBleed.glsl +96 -0
  23. package/glsl3/LensFlare.glsl +125 -0
  24. package/glsl3/LightRays.glsl +106 -0
  25. package/glsl3/LightWipe.glsl +89 -0
  26. package/glsl3/PhotoDevelop.glsl +59 -0
  27. package/glsl3/PlusWipe.glsl +38 -0
  28. package/glsl3/PopIn.glsl +57 -0
  29. package/glsl3/SmokeDissolve.glsl +102 -0
  30. package/glsl3/SplatterWipe.glsl +154 -0
  31. package/glsl3/StretchSlide.glsl +62 -0
  32. package/glsl3/VhsTracking.glsl +127 -0
  33. package/glsl3/WedgeWipe.glsl +35 -0
  34. package/index.js +1 -1
  35. package/layouts.json +1091 -17
  36. package/llms-full.txt +774 -304
  37. package/llms.txt +189 -160
  38. package/msl/Accordion.metal +421 -0
  39. package/msl/Ascii.metal +567 -0
  40. package/msl/BlockCover.metal +403 -0
  41. package/msl/BloomDissolve.metal +416 -0
  42. package/msl/BokehDissolve.metal +447 -0
  43. package/msl/BrushWipe.metal +488 -0
  44. package/msl/CameraShake.metal +393 -0
  45. package/msl/CardSwipe.metal +342 -0
  46. package/msl/ColorPanelWipe.metal +314 -0
  47. package/msl/CurvedWipe.metal +229 -0
  48. package/msl/Disintegrate.metal +468 -0
  49. package/msl/EyeBlink.metal +355 -0
  50. package/msl/FilmDissolve.metal +199 -0
  51. package/msl/FilmStrip.metal +429 -0
  52. package/msl/FlameWipe.metal +575 -0
  53. package/msl/Gallery.metal +813 -0
  54. package/msl/GooeyWipe.metal +398 -0
  55. package/msl/InkBleed.metal +409 -0
  56. package/msl/LensFlare.metal +455 -0
  57. package/msl/LightRays.metal +427 -0
  58. package/msl/LightWipe.metal +321 -0
  59. package/msl/PhotoDevelop.metal +245 -0
  60. package/msl/PlusWipe.metal +199 -0
  61. package/msl/PopIn.metal +245 -0
  62. package/msl/SmokeDissolve.metal +400 -0
  63. package/msl/SplatterWipe.metal +677 -0
  64. package/msl/StretchSlide.metal +243 -0
  65. package/msl/VhsTracking.metal +514 -0
  66. package/msl/WedgeWipe.metal +154 -0
  67. package/package.json +1 -1
  68. package/skills/gl-transitions/references/catalog.md +115 -39
  69. package/sksl/Accordion.sksl +94 -0
  70. package/sksl/Ascii.sksl +131 -0
  71. package/sksl/BlockCover.sksl +96 -0
  72. package/sksl/BloomDissolve.sksl +119 -0
  73. package/sksl/BokehDissolve.sksl +132 -0
  74. package/sksl/BrushWipe.sksl +109 -0
  75. package/sksl/CameraShake.sksl +108 -0
  76. package/sksl/CardSwipe.sksl +93 -0
  77. package/sksl/ColorPanelWipe.sksl +85 -0
  78. package/sksl/CurvedWipe.sksl +64 -0
  79. package/sksl/Disintegrate.sksl +117 -0
  80. package/sksl/EyeBlink.sksl +94 -0
  81. package/sksl/FilmDissolve.sksl +60 -0
  82. package/sksl/FilmStrip.sksl +114 -0
  83. package/sksl/FlameWipe.sksl +162 -0
  84. package/sksl/Gallery.sksl +139 -0
  85. package/sksl/GooeyWipe.sksl +109 -0
  86. package/sksl/InkBleed.sksl +109 -0
  87. package/sksl/LensFlare.sksl +135 -0
  88. package/sksl/LightRays.sksl +115 -0
  89. package/sksl/LightWipe.sksl +97 -0
  90. package/sksl/PhotoDevelop.sksl +72 -0
  91. package/sksl/PlusWipe.sksl +50 -0
  92. package/sksl/PopIn.sksl +69 -0
  93. package/sksl/SmokeDissolve.sksl +115 -0
  94. package/sksl/SplatterWipe.sksl +161 -0
  95. package/sksl/StretchSlide.sksl +74 -0
  96. package/sksl/VhsTracking.sksl +138 -0
  97. package/sksl/WedgeWipe.sksl +46 -0
  98. package/sksl/index.js +1 -1
  99. package/transitions/Accordion.glsl +84 -0
  100. package/transitions/Ascii.glsl +123 -0
  101. package/transitions/BlockCover.glsl +86 -0
  102. package/transitions/BloomDissolve.glsl +109 -0
  103. package/transitions/BokehDissolve.glsl +122 -0
  104. package/transitions/BrushWipe.glsl +99 -0
  105. package/transitions/CameraShake.glsl +97 -0
  106. package/transitions/CardSwipe.glsl +80 -0
  107. package/transitions/ColorPanelWipe.glsl +74 -0
  108. package/transitions/CurvedWipe.glsl +51 -0
  109. package/transitions/Disintegrate.glsl +111 -0
  110. package/transitions/EyeBlink.glsl +82 -0
  111. package/transitions/FilmDissolve.glsl +48 -0
  112. package/transitions/FilmStrip.glsl +104 -0
  113. package/transitions/FlameWipe.glsl +153 -0
  114. package/transitions/Gallery.glsl +132 -0
  115. package/transitions/GooeyWipe.glsl +96 -0
  116. package/transitions/InkBleed.glsl +95 -0
  117. package/transitions/LensFlare.glsl +124 -0
  118. package/transitions/LightRays.glsl +105 -0
  119. package/transitions/LightWipe.glsl +88 -0
  120. package/transitions/PhotoDevelop.glsl +58 -0
  121. package/transitions/PlusWipe.glsl +37 -0
  122. package/transitions/PopIn.glsl +56 -0
  123. package/transitions/SmokeDissolve.glsl +101 -0
  124. package/transitions/SplatterWipe.glsl +153 -0
  125. package/transitions/StretchSlide.glsl +61 -0
  126. package/transitions/VhsTracking.glsl +126 -0
  127. package/transitions/WedgeWipe.glsl +34 -0
  128. package/wgsl/Accordion.wgsl +376 -0
  129. package/wgsl/Ascii.wgsl +519 -0
  130. package/wgsl/BlockCover.wgsl +352 -0
  131. package/wgsl/BloomDissolve.wgsl +372 -0
  132. package/wgsl/BokehDissolve.wgsl +409 -0
  133. package/wgsl/BrushWipe.wgsl +443 -0
  134. package/wgsl/CameraShake.wgsl +348 -0
  135. package/wgsl/CardSwipe.wgsl +308 -0
  136. package/wgsl/ColorPanelWipe.wgsl +274 -0
  137. package/wgsl/CurvedWipe.wgsl +198 -0
  138. package/wgsl/Disintegrate.wgsl +426 -0
  139. package/wgsl/EyeBlink.wgsl +308 -0
  140. package/wgsl/FilmDissolve.wgsl +169 -0
  141. package/wgsl/FilmStrip.wgsl +381 -0
  142. package/wgsl/FlameWipe.wgsl +531 -0
  143. package/wgsl/Gallery.wgsl +741 -0
  144. package/wgsl/GooeyWipe.wgsl +353 -0
  145. package/wgsl/InkBleed.wgsl +366 -0
  146. package/wgsl/LensFlare.wgsl +406 -0
  147. package/wgsl/LightRays.wgsl +380 -0
  148. package/wgsl/LightWipe.wgsl +277 -0
  149. package/wgsl/PhotoDevelop.wgsl +213 -0
  150. package/wgsl/PlusWipe.wgsl +165 -0
  151. package/wgsl/PopIn.wgsl +213 -0
  152. package/wgsl/SmokeDissolve.wgsl +363 -0
  153. package/wgsl/SplatterWipe.wgsl +613 -0
  154. package/wgsl/StretchSlide.wgsl +213 -0
  155. package/wgsl/VhsTracking.wgsl +462 -0
  156. package/wgsl/WedgeWipe.wgsl +126 -0
@@ -0,0 +1,153 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: A wall of flames sweeps across the frame, scorching the outgoing image ahead of it and leaving the incoming image under a fading warm glow
4
+ // Tags: fire, flame, burn, wipe, directional
5
+
6
+ // @param Direction in which the flames sweep across the frame
7
+ uniform vec2 direction; // = vec2(0.0, 1.0)
8
+ // @range(0, 1) Height of the flames, as a fraction of the frame height
9
+ uniform float height; // = 0.4
10
+ // @range(0, 1) How much the outgoing image browns and chars ahead of the flames
11
+ uniform float scorch; // = 0.7
12
+ // @range(0, 1) Strength of the warm glow left on the incoming image
13
+ uniform float glow; // = 0.6
14
+ // @color Tint of the body of the flames
15
+ uniform vec3 color; // = vec3(1.0, 0.4, 0.08)
16
+
17
+ // width of the scorched band ahead of the flames, and of the glow behind them
18
+ const float BAND = 0.45;
19
+ // how far off the frame the front starts and ends
20
+ const float PAD = 0.3;
21
+ // how far the front of the fire wanders around its straight line
22
+ const float RAGGED = 0.05;
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
+ float noise(vec2 v) {
31
+ vec2 i = floor(v);
32
+ vec2 f = v - i;
33
+ f = f * f * (3.0 - 2.0 * f);
34
+ return mix(mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
35
+ mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x), f.y);
36
+ }
37
+
38
+ float fbm(vec2 v) {
39
+ float sum = 0.0;
40
+ float amp = 0.5;
41
+ for (int i = 0; i < 4; i++) {
42
+ sum += amp * noise(v);
43
+ v = v * 2.03 + vec2(17.3, 9.1);
44
+ amp *= 0.5;
45
+ }
46
+ return sum / 0.9375;
47
+ }
48
+
49
+ // mirror the coordinates back into the frame
50
+ vec2 mirror(vec2 v) {
51
+ return 1.0 - abs(1.0 - mod(v, 2.0));
52
+ }
53
+
54
+ // color of the fire by its heat: dark red tips, a tinted body, a white-yellow core
55
+ vec3 fire(float h) {
56
+ vec3 c = mix(vec3(0.22, 0.01, 0.0), color * color * vec3(1.0, 0.6, 0.4), smoothstep(0.0, 0.3, h));
57
+ c = mix(c, color, smoothstep(0.25, 0.55, h));
58
+ c = mix(c, vec3(1.0, 0.8, 0.35), smoothstep(0.55, 0.8, h));
59
+ return mix(c, vec3(1.0, 0.96, 0.82), smoothstep(0.8, 1.0, h));
60
+ }
61
+
62
+ // width of a flame tongue climbing along an upright line, from its base (s = 0) to its tip
63
+ // (s = 1), with a random size
64
+ float climbing(float s, float size) {
65
+ return (0.42 + 0.56 * size) * 6.75 * s * (1.0 - s) * (1.0 - s);
66
+ }
67
+
68
+ vec4 transition(vec2 uv) {
69
+ vec2 dir = length(direction) > 1e-5 ? normalize(direction) : vec2(1.0, 0.0);
70
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
71
+ // the flames rise upward from the front: over this distance along the direction
72
+ float rise = height * dir.y;
73
+ // half-width of the burning line, and how far it swells
74
+ float w = 0.05 + 0.35 * height;
75
+ float reach = w * (1.75 + 0.6 * abs(dir.x));
76
+ // the front crosses the frame at the same pace whatever the height of the flames
77
+ float extent = 0.5 * (abs(dir.x) * ratio + abs(dir.y)) + PAD;
78
+ float e = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.3);
79
+ // the fire catches at the start and dies out at the end, the scorch grows in, the glow fades
80
+ float burn = smoothstep(0.0, 0.12, progress) * (1.0 - smoothstep(0.88, 1.0, progress));
81
+ float scorchAmount = scorch * smoothstep(0.0, 0.2, progress);
82
+ float glowAmount = glow * (1.0 - smoothstep(0.75, 1.0, progress));
83
+ // the flames flicker as they go
84
+ float t = progress * 5.0;
85
+
86
+ float side = dot(q, vec2(-dir.y, dir.x));
87
+ float front = mix(-extent, extent, e) + RAGGED * (2.0 * noise(vec2(side * 4.0, t * 0.4)) - 1.0);
88
+ // > 0 ahead of the fire, on the outgoing image
89
+ float k = dot(q, dir) - front;
90
+
91
+ // heat before the turbulence: the burning line, and the flames rising from it.
92
+ // Billows rising in screen space swell and thin the line; where it stands upright,
93
+ // they are tongues climbing along it, each widest at its base and pointed at its tip
94
+ float billow = noise(vec2(q.x * 3.0 + 5.0, q.y * 2.5 - t * 1.6));
95
+ float y = q.y * 3.0 - t * 1.4;
96
+ float y2 = y + 0.5;
97
+ float climb = max(climbing(fract(y), hash12(vec2(floor(y), 3.0))),
98
+ climbing(fract(y2), hash12(vec2(floor(y2), 7.0))));
99
+ billow = mix(billow, 0.4 * billow + climb, abs(dir.x));
100
+ float lineWidth = w * (0.25 + 1.5 * billow);
101
+ float line = 1.0 - smoothstep(0.0, lineWidth, abs(k));
102
+ float tongue = 0.0;
103
+ if (abs(rise) > 1e-4) {
104
+ float s = k / rise;
105
+ if (s >= 0.0) tongue = clamp(1.0 - s, 0.0, 1.0);
106
+ }
107
+ float heat = max(line, tongue) * burn;
108
+ float near = 1.0 - smoothstep(0.0, BAND, abs(k));
109
+
110
+ // the outgoing image shimmers in the heat ahead of the fire
111
+ vec2 h = q * vec2(9.0, 5.0) + vec2(0.0, -t * 3.0);
112
+ vec2 shimmer = (vec2(noise(h), noise(h + 31.7)) - 0.5) * 0.012 * min(near + heat, 1.0) * burn;
113
+ vec4 a = getFromColor(mirror(uv + shimmer));
114
+ vec4 b = getToColor(uv);
115
+
116
+ // the outgoing image browns, then chars close to the flames
117
+ float brown = k > 0.0 ? scorchAmount * near : 0.0;
118
+ float lum = dot(a.rgb, vec3(0.299, 0.587, 0.114));
119
+ a.rgb = mix(a.rgb, lum * vec3(0.9, 0.55, 0.28), brown) * (1.0 - 0.35 * brown) * (1.0 - 0.9 * brown * near * near);
120
+ // the incoming image under a warm glow fading away from the fire
121
+ float g = k < 0.0 ? glowAmount * near : 0.0;
122
+ b.rgb = b.rgb * mix(vec3(1.0), vec3(1.0, 0.6, 0.35), 0.7 * g) + color * 0.4 * g * g;
123
+
124
+ // far from the fire, only one of the images shows
125
+ if (k >= max(BAND, max(rise, reach))) return a.a > 0.0 ? a : vec4(0.0);
126
+ if (-k >= max(BAND, max(-rise, reach))) return b.a > 0.0 ? b : vec4(0.0);
127
+
128
+ // the two images meet under the burning line (mixed premultiplied)
129
+ float m = smoothstep(-0.5 * w, 0.5 * w, k);
130
+ vec4 c = mix(vec4(b.rgb * b.a, b.a), vec4(a.rgb * a.a, a.a), m);
131
+ if (c.a <= 0.0) return vec4(0.0);
132
+ vec3 col = c.rgb / c.a;
133
+
134
+ // turbulence rising in screen space, stretched upward and swaying into pointed tongues
135
+ vec2 f = vec2(q.x * mix(10.0, 6.0, abs(dir.x)), q.y * mix(1.8, 3.2, abs(dir.x)) - t * 2.4);
136
+ float sway = fbm(vec2(q.x * 2.5, q.y * 1.5 - t * 1.2));
137
+ float n = fbm(f + vec2(1.5 * sway - 0.75, 0.0));
138
+ n = clamp(1.7 * n - 0.35, 0.0, 1.0);
139
+ // a continuous hot core hugging the base of the flames
140
+ float core = (1.0 - smoothstep(0.0, 0.35 * lineWidth, abs(k + 0.4 * w * (sway - 0.5)))) * burn * (1.0 - 0.5 * abs(dir.x));
141
+ // under the flames, where they take root, the turbulence calms down into a soft glow
142
+ float root = rise > 0.0 ? clamp(-k / w, 0.0, 1.0) : rise < 0.0 ? clamp(k / w, 0.0, 1.0) : 0.0;
143
+ root *= abs(dir.y);
144
+ float flame = clamp(heat * 0.95 + 0.45 * core * (0.75 + 0.25 * n) - (1.0 - n) * 1.1 * (1.0 - 0.8 * root), 0.0, 1.0);
145
+
146
+ // the flames darken what is behind their body and add their light, with a soft halo;
147
+ // the alpha stays the image's
148
+ // crisp around the tongues, soft at their roots
149
+ float body = smoothstep(0.0, 0.08 + 0.5 * root, flame);
150
+ col = col * (1.0 - 0.7 * body) + fire(flame) * (0.45 + 0.65 * flame) * body;
151
+ col += color * 0.25 * heat * heat * (1.0 - body);
152
+ return vec4(clamp(col, 0.0, 1.0), c.a);
153
+ }
@@ -0,0 +1,132 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The camera pulls back from the outgoing image to show it as a slide hanging in a row on a wall in perspective, the row glides along as each slide turns away from the center, and the camera moves back in on the incoming slide until it fills the frame
4
+ // Tags: 3d, perspective, gallery, slide, reflection, directional
5
+
6
+ // @param Way the row moves: 1 brings the incoming slide in from the right, -1 from the left
7
+ uniform float direction; // = 1.0
8
+ // @range(0, 1) How much the slides turn as they leave the center
9
+ uniform float tilt; // = 0.6
10
+ // @range(0, 1) Space between two slides, in slide widths
11
+ uniform float gap; // = 0.15
12
+ // @range(0.2, 3) How far the camera pulls back
13
+ uniform float zoom; // = 2.0
14
+ // @range(0, 1) Strength of the reflection of the slides on the floor
15
+ uniform float reflection; // = 0.3
16
+ // @color Color of the wall and the floor around the slides
17
+ uniform vec4 background; // = vec4(0.07, 0.07, 0.08, 1.0)
18
+
19
+ const float FOCAL = 1.6; // distance from the camera to a slide when it fills the frame
20
+ const float MAX_ANGLE = 1.4; // turn of a side slide at tilt = 1, in radians
21
+ const float NEIGHBOUR = 0.3; // how visible the repeats beyond the two images are
22
+ const float AA = 0.002; // width of the antialiased slide edges, in frame heights
23
+
24
+ vec4 premultiply(vec4 c) {
25
+ return vec4(c.rgb * c.a, c.a);
26
+ }
27
+
28
+ // how far slide k sits from the center of the view, in slides, clamped to one slide on each side
29
+ float offset(float k, float camQ, float spacing) {
30
+ return clamp((k * spacing - camQ) / spacing, -1.0, 1.0);
31
+ }
32
+
33
+ // the ray o + t d against slide k of the row (a plane turned around its vertical axis):
34
+ // returns (u, v, t, coverage), coverage antialiased over aa frame heights at the slide's edges
35
+ vec4 slideHit(vec3 o, vec3 d, float k, float s, float camQ, float spacing, float aa) {
36
+ // a side slide turns away from the center: its outer edge goes back into the wall
37
+ float a = -s * MAX_ANGLE * tilt * offset(k, camQ, spacing);
38
+ vec3 c = vec3(s * k * spacing, 0.0, 0.0);
39
+ vec3 tg = vec3(cos(a), 0.0, sin(a)); // along the slide, left to right
40
+ vec3 n = vec3(-tg.z, 0.0, tg.x);
41
+ float dn = dot(d, n);
42
+ if (abs(dn) < 1e-5) return vec4(0.0, 0.0, -1.0, 0.0);
43
+ float t = dot(c - o, n) / dn;
44
+ vec3 q = o + d * t - c;
45
+ float lx = dot(q, tg) + 0.5 * ratio;
46
+ float ly = q.y + 0.5;
47
+ // distances to the edges on screen: along the slide, how fast its local x moves with the screen x
48
+ float jx = abs(t * (tg.x - dot(d, tg) * n.x / dn));
49
+ float ex = min(lx, ratio - lx) / max(jx, 1e-6);
50
+ float ey = min(ly, 1.0 - ly) / max(t, 1e-6);
51
+ float cov = t > 0.0 ? clamp(0.5 + min(ex, ey) / aa, 0.0, 1.0) : 0.0;
52
+ return vec4(lx / ratio, ly, t, cov);
53
+ }
54
+
55
+ // the premultiplied color of slide k where the ray hit it; the row is from (k = 0), to (k = 1),
56
+ // and faint repeats beyond them on their own side; refl > 0 is the strength of its reflection
57
+ vec4 slideColor(vec4 h, float k, float camQ, float spacing, float refl, vec4 bg) {
58
+ if (h.w <= 0.0) return vec4(0.0);
59
+ vec2 st = clamp(h.xy, 0.0, 1.0);
60
+ vec4 c = premultiply(k < 0.5 ? getFromColor(st) : getToColor(st));
61
+ // turned away from the light as it turns away from the center
62
+ c.rgb *= 1.0 - 0.3 * tilt * abs(offset(k, camQ, spacing));
63
+ if (k < -0.5 || k > 1.5) c = mix(bg, c, NEIGHBOUR);
64
+ // the reflection fades out below the bottom of the slide
65
+ float f = refl > 0.0 ? refl * (1.0 - smoothstep(0.0, 0.6, st.y)) : 1.0;
66
+ return c * (h.w * f);
67
+ }
68
+
69
+ // how much the slides cover along the ray, whatever their images' alpha
70
+ float sceneCover(vec3 o, vec3 d, float s, float camQ, float spacing, float aa) {
71
+ float kc = floor(s * (o.x + d.x * o.z / -d.z) / spacing + 0.5);
72
+ float w0 = slideHit(o, d, kc - 1.0, s, camQ, spacing, aa).w;
73
+ float w1 = slideHit(o, d, kc, s, camQ, spacing, aa).w;
74
+ float w2 = slideHit(o, d, kc + 1.0, s, camQ, spacing, aa).w;
75
+ return 1.0 - (1.0 - w0) * (1.0 - w1) * (1.0 - w2);
76
+ }
77
+
78
+ // the slides seen along the ray, composited back to front (premultiplied)
79
+ vec4 scene(vec3 o, vec3 d, float s, float camQ, float spacing, float aa, float refl, vec4 bg) {
80
+ // the slide in front of which the ray crosses the wall, and its two neighbours
81
+ float wallQ = s * (o.x + d.x * o.z / -d.z);
82
+ float kc = floor(wallQ / spacing + 0.5);
83
+ vec4 h0 = slideHit(o, d, kc - 1.0, s, camQ, spacing, aa);
84
+ vec4 h1 = slideHit(o, d, kc, s, camQ, spacing, aa);
85
+ vec4 h2 = slideHit(o, d, kc + 1.0, s, camQ, spacing, aa);
86
+ vec4 c0 = slideColor(h0, kc - 1.0, camQ, spacing, refl, bg);
87
+ vec4 c1 = slideColor(h1, kc, camQ, spacing, refl, bg);
88
+ vec4 c2 = slideColor(h2, kc + 1.0, camQ, spacing, refl, bg);
89
+ float t0 = h0.w > 0.0 ? h0.z : 1e6;
90
+ float t1 = h1.w > 0.0 ? h1.z : 1e6;
91
+ float t2 = h2.w > 0.0 ? h2.z : 1e6;
92
+ // sort far to near: t0 >= t1 >= t2
93
+ vec4 tc;
94
+ float tt;
95
+ if (t0 < t1) { tc = c0; c0 = c1; c1 = tc; tt = t0; t0 = t1; t1 = tt; }
96
+ if (t1 < t2) { tc = c1; c1 = c2; c2 = tc; tt = t1; t1 = t2; t2 = tt; }
97
+ if (t0 < t1) { tc = c0; c0 = c1; c1 = tc; }
98
+ vec4 col = c0;
99
+ col = c1 + col * (1.0 - c1.a);
100
+ col = c2 + col * (1.0 - c2.a);
101
+ return col;
102
+ }
103
+
104
+ vec4 transition(vec2 uv) {
105
+ float p = progress;
106
+ float s = direction < 0.0 ? -1.0 : 1.0;
107
+ float spacing = ratio * (1.0 + gap);
108
+ // the camera pulls back, glides along the row, and moves back in
109
+ float back = smoothstep(0.0, 0.42, p) * (1.0 - smoothstep(0.58, 1.0, p));
110
+ float m = clamp((p - 0.18) / 0.64, 0.0, 1.0);
111
+ float glide = m * m * m * (m * (m * 6.0 - 15.0) + 10.0);
112
+ float camQ = spacing * glide;
113
+ vec3 o = vec3(s * camQ, 0.0, FOCAL * (1.0 + zoom * back));
114
+ vec3 d = vec3((uv - 0.5) * vec2(ratio, 1.0), -FOCAL);
115
+ float amount = min(1.0, 40.0 * back);
116
+ float aa = max(AA * amount, 1e-6);
117
+ vec4 bg = premultiply(background);
118
+
119
+ vec4 col = scene(o, d, s, camQ, spacing, aa, 0.0, bg);
120
+ if (col.a < 1.0) {
121
+ vec4 under = bg;
122
+ // the floor, below the slides, reflects them
123
+ if (d.y < 0.0 && reflection > 0.0) {
124
+ vec4 r = scene(vec3(o.x, -1.0 - o.y, o.z), vec3(d.x, -d.y, d.z), s, camQ, spacing, aa, reflection, bg);
125
+ under = r + bg * (1.0 - r.a);
126
+ }
127
+ // the wall shows around the slides, and only fades in behind their transparent parts,
128
+ // so that the images keep their own alpha at the start and the end
129
+ col += under * (mix(1.0, amount, sceneCover(o, d, s, camQ, spacing, aa)) * (1.0 - col.a));
130
+ }
131
+ return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
132
+ }
@@ -0,0 +1,96 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: Soft, glossy blobs of liquid pop up over the outgoing image, swell and melt into each other, revealing the incoming image until they cover the whole frame
4
+ // Tags: blob, liquid, organic, reveal
5
+
6
+ // @range(2, 12, 1) Number of blobs across the frame
7
+ uniform float blobs; // = 5.0
8
+ // @range(0, 1) How smoothly neighbouring blobs melt into each other
9
+ uniform float smoothness; // = 0.5
10
+ // @color Color of the glossy highlight on the rim of the blobs (its alpha is its strength)
11
+ uniform vec4 highlight; // = vec4(1.0, 1.0, 1.0, 0.7)
12
+ // @color Color of the soft shadow that the blobs cast on the outgoing image
13
+ uniform vec4 shadow; // = vec4(0.0, 0.0, 0.0, 0.3)
14
+
15
+ float hash (vec2 p) {
16
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
17
+ p3 += dot(p3, p3.yzx + 33.33);
18
+ return fract((p3.x + p3.y) * p3.z);
19
+ }
20
+
21
+ vec2 fold (vec2 p) {
22
+ return 1.0 - abs(1.0 - mod(p, 2.0));
23
+ }
24
+
25
+ // signed distance to the blob of a grid cell (in cells), its center returned in .yz
26
+ vec3 blob (vec2 cell, float rStart, float rEnd) {
27
+ vec2 c = cell + 0.5 + 0.7 * (vec2(hash(cell + 0.5), hash(cell + 41.3)) - 0.5);
28
+ float t0 = 0.02 + 0.43 * hash(cell + 17.9); // when it pops up
29
+ float s = clamp((progress - t0) / (1.0 - t0), 0.0, 1.0);
30
+ // it pops up fast with a little wobble, then swells slowly
31
+ float pop = clamp((progress - t0) / 0.12, 0.0, 1.0);
32
+ pop = 1.0 - (1.0 - pop) * (1.0 - pop) * (1.0 - pop);
33
+ float r = mix(rStart, 0.18, pop) + (rEnd - 0.18) * s * sqrt(s);
34
+ r += 0.05 * sin(pop * 9.0) * (1.0 - s) * pop;
35
+ return vec3(r, c);
36
+ }
37
+
38
+ vec4 transition (vec2 uv) {
39
+ float n = max(1.0, floor(blobs + 0.5));
40
+ float cellSize = max(ratio, 1.0) / n;
41
+ vec2 q = vec2(uv.x * ratio, uv.y) / cellSize; // in cells
42
+ vec2 base = floor(q);
43
+ float k = 0.02 + 0.25 * smoothness; // melting distance, in cells
44
+ float w = 0.16; // width of the rounded rim, in cells
45
+ // a blob starts far enough below the surface not to show (the union of 49 blobs bulges by up to k * log(49)),
46
+ // and ends up covering the whole of its cell (its center is at most 0.85 * sqrt(2) cells away) and its rim
47
+ float rStart = -(0.03 + 4.0 * k);
48
+ float rEnd = 0.85 * sqrt(2.0) + w + 0.05;
49
+ // smooth union (log-sum-exp, computed online) of the blobs around, with its gradient;
50
+ // blobs further than 3 cells away weigh less than exp(-7) and are left out
51
+ float m = 1e3; // distance to the nearest blob
52
+ float sum = 0.0;
53
+ vec2 grad = vec2(0.0);
54
+ float rNear = 0.0; // radius of the nearest blob
55
+ for (int j = -3; j <= 3; j++) {
56
+ for (int i = -3; i <= 3; i++) {
57
+ vec3 b = blob(base + vec2(float(i), float(j)), rStart, rEnd);
58
+ vec2 dq = q - b.yz;
59
+ float l = length(dq);
60
+ float dist = l - b.x;
61
+ vec2 g = dq / max(l, 1e-4);
62
+ if (dist < m) {
63
+ float scale = exp((dist - m) / k);
64
+ sum = sum * scale + 1.0;
65
+ grad = grad * scale + g;
66
+ m = dist;
67
+ rNear = b.x;
68
+ } else {
69
+ float wt = exp((m - dist) / k);
70
+ sum += wt;
71
+ grad += wt * g;
72
+ }
73
+ }
74
+ }
75
+ float d = m - k * log(sum); // < 0 inside the goo
76
+ grad /= sum;
77
+ float aa = 0.012 * n / 5.0;
78
+ float inside = 1.0 - smoothstep(-aa, aa, d);
79
+ // a rounded, glossy surface near the edge, flat further inside; the goo settles flat at the end
80
+ float h = clamp(-d / w, 0.0, 1.0);
81
+ float settle = 1.0 - smoothstep(0.45, 0.85, progress);
82
+ float tilt = (1.0 - h) * (1.0 - h) * settle;
83
+ vec3 nrm = normalize(vec3(grad * tilt * 3.0, 1.0));
84
+ vec3 halfway = normalize(vec3(-0.35, 0.45, 1.0) + vec3(0.0, 0.0, 1.0));
85
+ float spec = pow(max(dot(nrm, halfway), 0.0), 200.0) * settle;
86
+ // thick, opaque goo: darker toward its edge, more so on the side away from the light
87
+ float shade = 1.0 - tilt * (0.25 + 0.3 * clamp(dot(grad, vec2(0.6, -0.8)) + 0.3, 0.0, 1.0));
88
+ vec4 to = getToColor(fold(uv - grad * tilt * 0.01 * cellSize / vec2(ratio, 1.0)));
89
+ float t2 = tilt * tilt;
90
+ float gloss = 0.3 * t2 * t2; // a thin bright line right on the rim
91
+ to.rgb = mix(to.rgb * shade, highlight.rgb, clamp(spec + gloss, 0.0, 1.0) * highlight.a);
92
+ vec4 from = getFromColor(uv);
93
+ float sh = shadow.a * (1.0 - smoothstep(0.0, 0.15, d + 0.03)) * smoothstep(0.0, 0.3, rNear);
94
+ from.rgb = mix(from.rgb, shadow.rgb, sh);
95
+ return mix(from, to, inside);
96
+ }
@@ -0,0 +1,95 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: The incoming image spreads over the outgoing one like drops of ink in water, blooming from a few points with curling, wispy edges and a darker rim, until it fills the frame
4
+ // Tags: ink, organic, fluid, noise
5
+
6
+ // @range(1, 8, 1) Number of ink drops
7
+ uniform float drops; // = 4.0
8
+ // @range(0, 1) How far the curling tendrils reach out of the blooms
9
+ uniform float tendrils; // = 0.7
10
+ // @range(0, 1) How dark the rim of ink at the front of the blooms is
11
+ uniform float rim; // = 0.5
12
+ // @param Random seed for the drop positions and the swirls
13
+ uniform float seed; // = 3.0
14
+
15
+ float hash (vec2 p) {
16
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
17
+ p3 += dot(p3, p3.yzx + 33.33);
18
+ return fract((p3.x + p3.y) * p3.z);
19
+ }
20
+
21
+ float vnoise (vec2 p) {
22
+ vec2 i = floor(p);
23
+ vec2 f = fract(p);
24
+ f = f * f * (3.0 - 2.0 * f);
25
+ return mix(
26
+ mix(hash(i), hash(i + vec2(1.0, 0.0)), f.x),
27
+ mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), f.x),
28
+ f.y
29
+ );
30
+ }
31
+
32
+ float fbm (vec2 p) {
33
+ float v = 0.0;
34
+ float a = 0.5;
35
+ for (int i = 0; i < 4; i++) {
36
+ v += a * vnoise(p);
37
+ p = mat2(1.6, 1.2, -1.2, 1.6) * p + 7.3;
38
+ a *= 0.5;
39
+ }
40
+ return v / 0.9375;
41
+ }
42
+
43
+ vec2 fold (vec2 p) {
44
+ return 1.0 - abs(1.0 - mod(p, 2.0));
45
+ }
46
+
47
+ vec4 transition (vec2 uv) {
48
+ float p = progress;
49
+ vec2 q = vec2(uv.x * ratio, uv.y);
50
+ // swirls: noise warped twice by itself, drifting as the ink spreads
51
+ vec2 o = vec2(seed * 3.1, seed * 1.7);
52
+ vec2 sq = q * 2.2 + o;
53
+ vec2 w1 = vec2(fbm(sq + vec2(0.0, 0.6 * p)), fbm(sq + vec2(5.2, 1.3) - vec2(0.5 * p, 0.0)));
54
+ vec2 w2 = vec2(fbm(sq + 3.0 * w1 + vec2(1.7, 9.2)), fbm(sq + 3.0 * w1 + vec2(8.3, 2.8)));
55
+ float swirl = fbm(sq * 0.8 + 2.5 * w2) - 0.5; // marbled, curling pattern
56
+ vec2 flow = w2 - 0.5;
57
+ float amp = 0.05 + 0.35 * tendrils;
58
+ float n = clamp(floor(drops + 0.5), 1.0, 8.0);
59
+ float rimW = 0.1;
60
+ float feather = 0.05; // soft, diluted ink around the front
61
+ float margin = 1.2 * amp + rimW + 0.08; // how far the swirls can pull the front back
62
+ float f = -1e3; // > 0 inside the ink
63
+ float fs = -1e3; // the same, only for the drops already fallen, which fades their haze in
64
+ for (int i = 0; i < 8; i++) {
65
+ float fi = float(i);
66
+ if (fi < n) {
67
+ vec2 hs = vec2(fi * 7.13 + seed, fi * 3.71 - seed);
68
+ vec2 c = vec2(mix(0.15, 0.85, hash(hs)) * ratio, mix(0.15, 0.85, hash(hs + 19.7)));
69
+ float start = 0.2 * fi / n;
70
+ float s = clamp((p - start) / (1.0 - start), 0.0, 1.0);
71
+ // distance to the farthest corner: each bloom alone covers the frame in the end
72
+ vec2 m = max(c, vec2(ratio, 1.0) - c);
73
+ float far = length(m) + margin;
74
+ float s3 = s * s * s;
75
+ float r = (far + 0.02) * s * (0.35 + 0.65 * s3 * s3) - 0.02;
76
+ // a drop starts round, then its front curls more and more as it spreads
77
+ float reach = amp * min(1.0, max(r, 0.0) * 5.0);
78
+ float g = r - length(q - c + 1.3 * reach * flow) + reach * 0.9 * swirl;
79
+ f = max(f, g);
80
+ fs = max(fs, g - 0.15 * (1.0 - min(1.0, s * 12.0)));
81
+ }
82
+ }
83
+ float aa = 0.003;
84
+ float inside = smoothstep(-aa, aa, f);
85
+ // feathered wisps of diluted ink, streaked along the swirls, ahead of the front
86
+ float wisp = 1.0 - smoothstep(0.0, 0.08, abs(fbm(sq * 2.0 + 5.0 * w2) - 0.5));
87
+ float soft = smoothstep(-feather, 0.0, fs) * (0.35 + 0.4 * wisp);
88
+ float haze = 0.35 * wisp * (1.0 - smoothstep(0.0, 0.1, -fs));
89
+ float cover = max(inside, max(soft, haze));
90
+ // the ink is denser, and still moving, close to its front
91
+ float edge = 1.0 - smoothstep(0.0, rimW, f);
92
+ vec4 to = getToColor(fold(uv - 0.015 * edge * flow / vec2(ratio, 1.0)));
93
+ to.rgb = mix(to.rgb, to.rgb * to.rgb * 0.7, rim * edge);
94
+ return mix(getFromColor(uv), to, cover);
95
+ }
@@ -0,0 +1,124 @@
1
+ // Author: gre
2
+ // License: MIT
3
+ // Description: A bright light sweeps across the frame and flares the lens: a long thin horizontal streak, a glowing core and a trail of colored ghost reflections; at its peak the incoming image spreads out from the light under its glare
4
+ // Tags: light, flare, glow, streak
5
+
6
+ // @range(-90, 90) Angle of the path of the light, in degrees (0 sweeps from left to right)
7
+ uniform float angle; // = -12.0
8
+ // @range(-0.5, 0.5) How far above the center of the frame the light passes
9
+ uniform float height; // = 0.18
10
+ // @range(0, 2) Brightness of the flare
11
+ uniform float intensity; // = 1.0
12
+ // @color Color of the streak and of the glare
13
+ uniform vec3 color; // = vec3(0.35, 0.6, 1.0)
14
+
15
+ const int BLOOM_TAPS = 12;
16
+ const int GHOSTS = 6;
17
+
18
+ // mirror the coordinates back into the frame
19
+ vec2 mirror(vec2 v) {
20
+ return 1.0 - abs(1.0 - mod(v, 2.0));
21
+ }
22
+
23
+ vec4 premultiplied(vec4 c) {
24
+ return vec4(c.rgb * c.a, c.a);
25
+ }
26
+
27
+ // the image on screen (premultiplied): the outgoing one, then the incoming one after the cut
28
+ vec4 frame(vec2 st, float m) {
29
+ if (m <= 0.0) return premultiplied(getFromColor(st));
30
+ if (m >= 1.0) return premultiplied(getToColor(st));
31
+ return mix(premultiplied(getFromColor(st)), premultiplied(getToColor(st)), m);
32
+ }
33
+
34
+ // the light of a pixel (premultiplied): its color above a knee
35
+ vec3 highlight(vec4 c) {
36
+ float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
37
+ return c.rgb * smoothstep(0.55, 0.95, lum);
38
+ }
39
+
40
+ vec4 transition(vec2 uv) {
41
+ float p = progress;
42
+ if (p <= 0.0) return getFromColor(uv);
43
+ if (p >= 1.0) return getToColor(uv);
44
+
45
+ // 0 at both ends, 1 at the peak
46
+ float env = 4.0 * p * (1.0 - p);
47
+ float peak = pow(env, 24.0);
48
+ // frame coordinates, centered, with square units
49
+ vec2 aspect = vec2(ratio, 1.0);
50
+ vec2 q = (uv - 0.5) * aspect;
51
+ float r = radians(angle);
52
+ vec2 dir = vec2(cos(r), -sin(r));
53
+ vec2 normal = vec2(-dir.y, dir.x);
54
+ // the light crosses the frame, slowing down as it passes the middle
55
+ float t = p - 0.5;
56
+ float travel = 0.5 * (abs(dir.x) * ratio + abs(dir.y)) + 0.3;
57
+ float along = travel * (2.0 * t) * (0.55 + 1.8 * t * t);
58
+ vec2 src = dir * along + normal * height;
59
+
60
+ vec2 d = q - src;
61
+ float dist = length(d);
62
+ float k = intensity * env;
63
+
64
+ // the cut, under the glare: the incoming image spreads out from the light in a soft circle,
65
+ // slower as the flare gets dimmer so that it still reads as intended
66
+ float cut = mix(0.2, 0.06, clamp(intensity, 0.0, 1.0));
67
+ float s = clamp((p - 0.5 + cut) / (2.0 * cut), 0.0, 1.0);
68
+ float soft = 0.3;
69
+ float reach = 0.5 * length(aspect) + length(src) + soft;
70
+ float front = s * (reach + soft);
71
+ float m = smoothstep(front, front - soft, dist);
72
+ vec4 base = frame(uv, m);
73
+
74
+ // the anamorphic streak: long and thin, always horizontal, white at the center and tinted along
75
+ float ax = abs(d.x);
76
+ float ay = abs(d.y);
77
+ float thin = exp(-ay * 140.0) * exp(-ax * 0.7);
78
+ float wide = exp(-ay * 30.0) * exp(-ax * 1.6);
79
+ vec3 tint = color;
80
+ vec3 streak = (thin * mix(vec3(1.0), tint, smoothstep(0.0, 0.3, ax)) + 0.5 * wide * tint) * 3.0;
81
+
82
+ // the core and its halo
83
+ vec3 core = vec3(1.0, 0.97, 0.92) * exp(-dist * dist * 600.0) * 3.0 + mix(vec3(1.0), tint, 0.5) * exp(-dist * 7.0) * 0.6;
84
+
85
+ // ghosts on the line from the light through the center of the frame
86
+ vec3 ghosts = vec3(0.0);
87
+ for (int i = 0; i < GHOSTS; i++) {
88
+ float fi = float(i);
89
+ float f = -0.45 + 0.42 * fi + 0.08 * sin(fi * 2.3);
90
+ vec2 g = -src * f;
91
+ float size = 0.025 + 0.06 * fract(fi * 0.618 + 0.2);
92
+ float gd = length(q - g) / size;
93
+ // a soft disc with a brighter rim
94
+ float disc = smoothstep(1.0, 0.8, gd) * (0.35 + 0.65 * smoothstep(0.4, 0.95, gd));
95
+ vec3 hue = mix(tint, vec3(1.0, 0.65, 0.35), fract(fi * 0.53));
96
+ hue = mix(hue, vec3(0.5, 1.0, 0.6), step(4.5, fi) * 0.6);
97
+ ghosts += disc * hue * 0.45;
98
+ }
99
+
100
+ // the highlights of the image bloom at the peak
101
+ vec3 bloom = vec3(0.0);
102
+ if (peak > 1e-3) {
103
+ float radius = 0.06 * env;
104
+ for (int i = 0; i < BLOOM_TAPS; i++) {
105
+ float fi = float(i);
106
+ float a = fi * 2.39996;
107
+ float rr = radius * sqrt((fi + 0.5) / float(BLOOM_TAPS));
108
+ vec2 o = vec2(cos(a), sin(a)) * rr / aspect;
109
+ bloom += highlight(frame(mirror(uv + o), m));
110
+ }
111
+ bloom /= float(BLOOM_TAPS);
112
+ }
113
+
114
+ // at the peak, the glare: a wide halo around the light and a light veil over the frame, to hide the cut
115
+ vec3 glare = mix(vec3(1.0), tint, 0.5) * peak * (0.45 + 2.2 * exp(-dist * 3.0));
116
+
117
+ vec3 light = k * (streak + core + ghosts) + intensity * (bloom * 2.5 * peak + glare);
118
+ light = 1.0 - exp(-light);
119
+
120
+ // screened over the image; the flare only shows on the image, so transparency is kept
121
+ vec3 c = base.rgb + light * base.a - base.rgb * light;
122
+ if (base.a <= 0.0) return vec4(0.0);
123
+ return vec4(clamp(c / base.a, 0.0, 1.0), base.a);
124
+ }