gl-transitions 3.0.0 → 3.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 (191) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/compatibility.json +455 -11
  3. package/gl-transitions.js +1 -1
  4. package/gl-transitions.json +1 -1
  5. package/glsl3/BookFlip.glsl +124 -21
  6. package/glsl3/CircleBurst.glsl +77 -0
  7. package/glsl3/Clothesline.glsl +217 -0
  8. package/glsl3/CodeRain.glsl +114 -0
  9. package/glsl3/ComicPanels.glsl +174 -0
  10. package/glsl3/Cube.glsl +105 -52
  11. package/glsl3/CurtainRise.glsl +71 -0
  12. package/glsl3/DominoFall.glsl +114 -0
  13. package/glsl3/Doorway.glsl +74 -38
  14. package/glsl3/Drape.glsl +186 -0
  15. package/glsl3/DuotoneFade.glsl +58 -0
  16. package/glsl3/FacetedGlass.glsl +137 -0
  17. package/glsl3/FrostWipe.glsl +176 -0
  18. package/glsl3/Funnel.glsl +71 -0
  19. package/glsl3/GlitterDissolve.glsl +171 -0
  20. package/glsl3/GravityLens.glsl +66 -0
  21. package/glsl3/GridFlip.glsl +151 -56
  22. package/glsl3/HeartWipe.glsl +71 -11
  23. package/glsl3/InsideCube.glsl +114 -0
  24. package/glsl3/KeyholeWipe.glsl +104 -0
  25. package/glsl3/LedWall.glsl +127 -0
  26. package/glsl3/MoireWipe.glsl +75 -0
  27. package/glsl3/PaperFold.glsl +168 -0
  28. package/glsl3/PuzzleCube.glsl +205 -0
  29. package/glsl3/RibbonTwist.glsl +53 -0
  30. package/glsl3/RingSpin.glsl +112 -0
  31. package/glsl3/Shatter.glsl +231 -35
  32. package/glsl3/SketchDissolve.glsl +100 -0
  33. package/glsl3/SlotReels.glsl +118 -0
  34. package/glsl3/SplitFlap.glsl +124 -0
  35. package/glsl3/SpotlightWipe.glsl +63 -0
  36. package/glsl3/Swirl.glsl +52 -21
  37. package/glsl3/TruchetWipe.glsl +80 -0
  38. package/glsl3/Tumble.glsl +113 -0
  39. package/glsl3/WaterDrop.glsl +69 -13
  40. package/glsl3/WaveWipe.glsl +154 -0
  41. package/index.js +1 -1
  42. package/layouts.json +1232 -29
  43. package/llms-full.txt +890 -403
  44. package/llms.txt +225 -197
  45. package/msl/BookFlip.metal +575 -114
  46. package/msl/CircleBurst.metal +351 -0
  47. package/msl/Clothesline.metal +828 -0
  48. package/msl/CodeRain.metal +451 -0
  49. package/msl/ComicPanels.metal +959 -0
  50. package/msl/Cube.metal +466 -170
  51. package/msl/CurtainRise.metal +263 -0
  52. package/msl/DominoFall.metal +510 -0
  53. package/msl/Doorway.metal +350 -124
  54. package/msl/Drape.metal +767 -0
  55. package/msl/DuotoneFade.metal +218 -0
  56. package/msl/FacetedGlass.metal +529 -0
  57. package/msl/FrostWipe.metal +677 -0
  58. package/msl/Funnel.metal +276 -0
  59. package/msl/GlitterDissolve.metal +637 -0
  60. package/msl/GravityLens.metal +236 -0
  61. package/msl/GridFlip.metal +548 -191
  62. package/msl/HeartWipe.metal +230 -58
  63. package/msl/InsideCube.metal +537 -0
  64. package/msl/KeyholeWipe.metal +370 -0
  65. package/msl/LedWall.metal +437 -0
  66. package/msl/MoireWipe.metal +252 -0
  67. package/msl/PaperFold.metal +762 -0
  68. package/msl/PuzzleCube.metal +1179 -0
  69. package/msl/RibbonTwist.metal +235 -0
  70. package/msl/RingSpin.metal +474 -0
  71. package/msl/Shatter.metal +1136 -160
  72. package/msl/SketchDissolve.metal +446 -0
  73. package/msl/SlotReels.metal +436 -0
  74. package/msl/SplitFlap.metal +589 -0
  75. package/msl/SpotlightWipe.metal +217 -0
  76. package/msl/Swirl.metal +144 -77
  77. package/msl/TruchetWipe.metal +285 -0
  78. package/msl/Tumble.metal +466 -0
  79. package/msl/WaterDrop.metal +258 -49
  80. package/msl/WaveWipe.metal +618 -0
  81. package/package.json +1 -1
  82. package/skills/gl-transitions/references/catalog.md +115 -57
  83. package/sksl/BookFlip.sksl +117 -20
  84. package/sksl/CircleBurst.sksl +84 -0
  85. package/sksl/Clothesline.sksl +217 -0
  86. package/sksl/CodeRain.sksl +124 -0
  87. package/sksl/ComicPanels.sksl +176 -0
  88. package/sksl/Cube.sksl +99 -46
  89. package/sksl/CurtainRise.sksl +84 -0
  90. package/sksl/DominoFall.sksl +122 -0
  91. package/sksl/Doorway.sksl +65 -35
  92. package/sksl/Drape.sksl +192 -0
  93. package/sksl/DuotoneFade.sksl +71 -0
  94. package/sksl/FacetedGlass.sksl +148 -0
  95. package/sksl/FrostWipe.sksl +183 -0
  96. package/sksl/Funnel.sksl +83 -0
  97. package/sksl/GlitterDissolve.sksl +175 -0
  98. package/sksl/GravityLens.sksl +77 -0
  99. package/sksl/GridFlip.sksl +141 -52
  100. package/sksl/HeartWipe.sksl +60 -11
  101. package/sksl/InsideCube.sksl +123 -0
  102. package/sksl/KeyholeWipe.sksl +109 -0
  103. package/sksl/LedWall.sksl +137 -0
  104. package/sksl/MoireWipe.sksl +85 -0
  105. package/sksl/PaperFold.sksl +170 -0
  106. package/sksl/PuzzleCube.sksl +203 -0
  107. package/sksl/RibbonTwist.sksl +66 -0
  108. package/sksl/RingSpin.sksl +121 -0
  109. package/sksl/Shatter.sksl +218 -33
  110. package/sksl/SketchDissolve.sksl +111 -0
  111. package/sksl/SlotReels.sksl +127 -0
  112. package/sksl/SplitFlap.sksl +131 -0
  113. package/sksl/SpotlightWipe.sksl +74 -0
  114. package/sksl/Swirl.sksl +49 -20
  115. package/sksl/TruchetWipe.sksl +92 -0
  116. package/sksl/Tumble.sksl +122 -0
  117. package/sksl/WaterDrop.sksl +64 -10
  118. package/sksl/WaveWipe.sksl +165 -0
  119. package/sksl/index.js +1 -1
  120. package/transitions/BookFlip.glsl +124 -21
  121. package/transitions/CircleBurst.glsl +76 -0
  122. package/transitions/Clothesline.glsl +216 -0
  123. package/transitions/CodeRain.glsl +113 -0
  124. package/transitions/ComicPanels.glsl +173 -0
  125. package/transitions/Cube.glsl +105 -52
  126. package/transitions/CurtainRise.glsl +70 -0
  127. package/transitions/DominoFall.glsl +113 -0
  128. package/transitions/Doorway.glsl +74 -38
  129. package/transitions/Drape.glsl +185 -0
  130. package/transitions/DuotoneFade.glsl +57 -0
  131. package/transitions/FacetedGlass.glsl +136 -0
  132. package/transitions/FrostWipe.glsl +175 -0
  133. package/transitions/Funnel.glsl +70 -0
  134. package/transitions/GlitterDissolve.glsl +170 -0
  135. package/transitions/GravityLens.glsl +65 -0
  136. package/transitions/GridFlip.glsl +151 -56
  137. package/transitions/HeartWipe.glsl +71 -11
  138. package/transitions/InsideCube.glsl +113 -0
  139. package/transitions/KeyholeWipe.glsl +103 -0
  140. package/transitions/LedWall.glsl +126 -0
  141. package/transitions/MoireWipe.glsl +74 -0
  142. package/transitions/PaperFold.glsl +167 -0
  143. package/transitions/PuzzleCube.glsl +204 -0
  144. package/transitions/RibbonTwist.glsl +52 -0
  145. package/transitions/RingSpin.glsl +111 -0
  146. package/transitions/Shatter.glsl +231 -35
  147. package/transitions/SketchDissolve.glsl +99 -0
  148. package/transitions/SlotReels.glsl +117 -0
  149. package/transitions/SplitFlap.glsl +123 -0
  150. package/transitions/SpotlightWipe.glsl +62 -0
  151. package/transitions/Swirl.glsl +52 -21
  152. package/transitions/TruchetWipe.glsl +79 -0
  153. package/transitions/Tumble.glsl +112 -0
  154. package/transitions/WaterDrop.glsl +69 -13
  155. package/transitions/WaveWipe.glsl +153 -0
  156. package/wgsl/BookFlip.wgsl +552 -105
  157. package/wgsl/CircleBurst.wgsl +310 -0
  158. package/wgsl/Clothesline.wgsl +756 -0
  159. package/wgsl/CodeRain.wgsl +415 -0
  160. package/wgsl/ComicPanels.wgsl +886 -0
  161. package/wgsl/Cube.wgsl +461 -156
  162. package/wgsl/CurtainRise.wgsl +235 -0
  163. package/wgsl/DominoFall.wgsl +461 -0
  164. package/wgsl/Doorway.wgsl +333 -117
  165. package/wgsl/Drape.wgsl +715 -0
  166. package/wgsl/DuotoneFade.wgsl +185 -0
  167. package/wgsl/FacetedGlass.wgsl +476 -0
  168. package/wgsl/FrostWipe.wgsl +617 -0
  169. package/wgsl/Funnel.wgsl +248 -0
  170. package/wgsl/GlitterDissolve.wgsl +582 -0
  171. package/wgsl/GravityLens.wgsl +206 -0
  172. package/wgsl/GridFlip.wgsl +523 -188
  173. package/wgsl/HeartWipe.wgsl +225 -55
  174. package/wgsl/InsideCube.wgsl +496 -0
  175. package/wgsl/KeyholeWipe.wgsl +337 -0
  176. package/wgsl/LedWall.wgsl +397 -0
  177. package/wgsl/MoireWipe.wgsl +222 -0
  178. package/wgsl/PaperFold.wgsl +700 -0
  179. package/wgsl/PuzzleCube.wgsl +1087 -0
  180. package/wgsl/RibbonTwist.wgsl +206 -0
  181. package/wgsl/RingSpin.wgsl +426 -0
  182. package/wgsl/Shatter.wgsl +1091 -148
  183. package/wgsl/SketchDissolve.wgsl +409 -0
  184. package/wgsl/SlotReels.wgsl +391 -0
  185. package/wgsl/SplitFlap.wgsl +533 -0
  186. package/wgsl/SpotlightWipe.wgsl +186 -0
  187. package/wgsl/Swirl.wgsl +138 -77
  188. package/wgsl/TruchetWipe.wgsl +255 -0
  189. package/wgsl/Tumble.wgsl +424 -0
  190. package/wgsl/WaterDrop.wgsl +251 -49
  191. package/wgsl/WaveWipe.wgsl +581 -0
@@ -1,37 +1,140 @@
1
1
  // BookFlip — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BookFlip.glsl
2
2
  // Author: hong
3
3
  // License: MIT
4
- // Description: The outgoing image turns like a book page from right to left, revealing the incoming one
4
+ // Description: The right half of the outgoing image is a book page that turns over from right to left on the spine at the middle of the frame, curling near its free edge, its back bringing the left half of the incoming image
5
5
  // Tags: page, flip, 3d
6
6
 
7
- // Avoids dividing by zero when the page is edge-on (progress = 0.5).
8
- float nonZero(float x) {
9
- return abs(x) < 1e-4 ? (x < 0.0 ? -1e-4 : 1e-4) : x;
7
+ // @range(0, 1) Strength of the perspective: the page grows as it lifts toward the viewer
8
+ uniform float perspective; // = 0.5
9
+ // @range(0, 1) How much the page darkens as it turns away from the light, and the shadows it casts
10
+ uniform float shading; // = 0.6
11
+ // @range(0, 1) How much the page bends near its free edge, which trails behind as it turns
12
+ uniform float curl; // = 0.5
13
+
14
+ const float PI = 3.141592653589793;
15
+ // width of the anti-aliased edges, as a part of the frame's height
16
+ const float EDGE = 0.0015;
17
+ // part of the page's width that curls
18
+ const float CURL_PART = 0.45;
19
+ // direction of the light, in (x, height toward the viewer)
20
+ const vec2 LIGHT = vec2(-0.447214, 0.894427);
21
+
22
+ float cross2(vec2 a, vec2 b) {
23
+ return a.x * b.y - a.y * b.x;
10
24
  }
11
25
 
12
- vec2 skewRight(vec2 p) {
13
- float skewX = (p.x - progress)/nonZero(0.5 - progress) * 0.5;
14
- float skewY = (p.y - 0.5)/(0.5 + progress * (p.x - 0.5) / 0.5)* 0.5 + 0.5;
15
- return vec2(skewX, skewY);
26
+ // the page's angle, 0 lying on the right to PI lying on the left: eased, but never at rest
27
+ float pageAngle() {
28
+ float p = clamp(progress, 0.0, 1.0);
29
+ return PI * p * (0.35 + p * (1.95 - 1.3 * p));
16
30
  }
17
31
 
18
- vec2 skewLeft(vec2 p) {
19
- float skewX = (p.x - 0.5)/nonZero(progress - 0.5) * 0.5 + 0.5;
20
- float skewY = (p.y - 0.5) / (0.5 + (1.0 - progress ) * (0.5 - p.x) / 0.5) * 0.5 + 0.5;
21
- return vec2(skewX, skewY);
32
+ // The page is seen in a cross-section across the spine, in (x, height toward the viewer) from the spine:
33
+ // a straight part at angle a from the spine, then, when k is not 0, an arc of curvature k centered on c up to its free edge,
34
+ // extruded along y. Returns the nearest point of the page hit by the ray from eye along dir:
35
+ // (ray length, distance along the page, angle there), with a negative ray length when it is missed.
36
+ vec3 hitPage(vec2 eye, vec2 dir, float a, float k, float straight, vec2 c, float w) {
37
+ vec3 best = vec3(-1.0, 0.0, 0.0);
38
+ vec2 d = vec2(cos(a), sin(a));
39
+ // the straight part
40
+ float den = cross2(d, dir);
41
+ if (abs(den) > 1e-7) {
42
+ float u = cross2(eye, dir) / den;
43
+ float t = cross2(eye, d) / den;
44
+ if (t > 0.0 && u >= 0.0 && u <= straight) best = vec3(t, u, a);
45
+ }
46
+ if (k != 0.0) {
47
+ float r = 1.0 / k;
48
+ vec2 oc = eye - c;
49
+ float qa = dot(dir, dir);
50
+ float qb = dot(oc, dir);
51
+ float disc = qb * qb - qa * (dot(oc, oc) - r * r);
52
+ if (disc >= 0.0) {
53
+ float sq = sqrt(disc);
54
+ for (int i = 0; i < 2; i++) {
55
+ float t = (-qb + (i == 0 ? -sq : sq)) / qa;
56
+ if (t > 0.0 && (best.x < 0.0 || t < best.x)) {
57
+ // (sin(b), -cos(b)) where b is the angle of the page at that point
58
+ vec2 v = (oc + t * dir) * k;
59
+ float db = atan(v.x, -v.y) - a;
60
+ db -= 2.0 * PI * floor((db + PI) / (2.0 * PI));
61
+ float s = db / k;
62
+ if (s >= 0.0 && s <= w - straight) best = vec3(t, straight + s, a + db);
63
+ }
64
+ }
65
+ }
66
+ }
67
+ return best;
22
68
  }
23
69
 
24
- vec4 addShade() {
25
- float shadeVal = max(0.7, abs(progress - 0.5) * 2.0);
26
- return vec4(vec3(shadeVal ), 1.0);
70
+ // the point of the curled part of the page where its angle is b
71
+ vec2 curlPoint(vec2 c, float k, float b) {
72
+ return c + vec2(sin(b), -cos(b)) / k;
27
73
  }
28
74
 
29
- vec4 transition (vec2 p) {
30
- float pr = step(1.0 - progress, p.x);
75
+ vec4 transition (vec2 uv) {
76
+ float a = pageAngle();
77
+ float lift = sin(a);
78
+ // half the frame's width: the page's width
79
+ float w = 0.5 * ratio;
80
+ float x = uv.x * ratio - w;
81
+ // the viewer is above the spine, the page lifting toward it
82
+ float dist = w * (1.0 + 1.5 / max(perspective, 0.01));
83
+ vec2 eye = vec2(0.0, dist);
84
+ vec2 dir = vec2(x, -dist);
85
+
86
+ // the shape of the page: straight, then curled with its free edge trailing behind (a negative curvature)
87
+ vec2 d = vec2(cos(a), sin(a));
88
+ float k = -clamp(curl, 0.0, 1.0) * lift / (CURL_PART * w);
89
+ if (abs(k) * CURL_PART * w <= 1e-4) k = 0.0;
90
+ float straight = k != 0.0 ? (1.0 - CURL_PART) * w : w;
91
+ vec2 c = straight * d + vec2(-d.y, d.x) / (k != 0.0 ? k : 1.0);
92
+ vec2 bend = straight * d;
93
+ vec2 middle = k != 0.0 ? curlPoint(c, k, a + 0.5 * k * (w - straight)) : bend;
94
+ vec2 edge = k != 0.0 ? curlPoint(c, k, a + k * (w - straight)) : bend;
31
95
 
32
- if (p.x < 0.5) {
33
- return mix(getFromColor(p), getToColor(skewLeft(p)) * addShade(), pr);
34
- } else {
35
- return mix(getFromColor(skewRight(p)) * addShade(), getToColor(p), pr);
96
+ // anti-aliased edges, only once the page has left the frame's plane, so that it covers it exactly at both ends
97
+ float aa = EDGE * min(20.0 * lift, 1.0);
98
+ vec4 img = vec4(0.0);
99
+ float m = 0.0;
100
+ vec3 hit = hitPage(eye, dir, a, k, straight, c, w);
101
+ if (hit.x > 0.0) {
102
+ float t = hit.x;
103
+ float u = hit.y;
104
+ float b = hit.z;
105
+ vec2 pt = eye + t * dir;
106
+ // the height on the page, magnified as it comes closer (its top and bottom edges are out of the frame)
107
+ float y = clamp(0.5 + (uv.y - 0.5) * t, 0.0, 1.0);
108
+ // near its free edge, the distance to it on the screen
109
+ float edgeX = edge.x * dist / max(dist - edge.y, 1e-4);
110
+ m = aa > 0.0 && u > (k != 0.0 ? straight : 0.5 * w) ? clamp(abs(x - edgeX) / aa, 0.0, 1.0) : 1.0;
111
+ vec2 normal = vec2(-sin(b), cos(b));
112
+ bool front = dot(normal, eye - pt) > 0.0;
113
+ img = front
114
+ ? getFromColor(vec2(clamp(w + u, w, ratio) / ratio, y))
115
+ : getToColor(vec2(clamp(w - u, 0.0, w) / ratio, y));
116
+ // lit from the upper left: brighter as it turns toward the light, darker as it turns away, with a soft crease along the spine
117
+ float diffuse = max(dot(front ? normal : -normal, LIGHT), 0.0) / LIGHT.y;
118
+ float shade = mix(1.0, 0.25 + 0.75 * diffuse, shading);
119
+ shade *= 1.0 - 0.35 * shading * lift * exp(-u / (0.04 * w));
120
+ img.rgb *= shade;
121
+ if (m >= 1.0) return img;
36
122
  }
123
+
124
+ // the pages beneath: the outgoing image on the left, the incoming one on the right
125
+ vec4 color = x < 0.0 ? getFromColor(uv) : getToColor(uv);
126
+ // the lifted page shades them, the more it hides of the sky (and so the more near the spine and its free edge)
127
+ vec2 toEdge = edge - vec2(x, 0.0);
128
+ float cosEdge = toEdge.x / max(length(toEdge), 1e-6);
129
+ float blocked = 0.5 * abs((x < 0.0 ? 1.0 : -1.0) - cosEdge);
130
+ float shadow = blocked * blocked * (3.0 - 2.0 * blocked);
131
+ // and casts a shadow, the light coming from the upper left, softer as the page is higher
132
+ float slope = -LIGHT.x / LIGHT.y;
133
+ vec3 reach = vec3(bend.x, middle.x, edge.x) + slope * vec3(bend.y, middle.y, edge.y);
134
+ float lo = min(0.0, min(reach.x, min(reach.y, reach.z)));
135
+ float hi = max(0.0, max(reach.x, max(reach.y, reach.z)));
136
+ float soft = max(0.25 * edge.y, 1e-5);
137
+ shadow = max(0.5 * shadow, 0.85 * clamp(min(x - lo, hi - x) / soft + 0.5, 0.0, 1.0) * min(4.0 * lift, 1.0));
138
+ color.rgb *= 1.0 - shading * shadow;
139
+ return mix(color, img, m);
37
140
  }
@@ -0,0 +1,77 @@
1
+ // CircleBurst — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CircleBurst.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Discs of three solid colors burst out of a point one after another, each covering the last, then a hole bursts open from the same point in the last one to reveal the incoming image
5
+ // Tags: circle, burst, color, reveal, motion-graphics
6
+
7
+ // @param Point the discs burst out of, in texture coordinates
8
+ uniform vec2 center; // = vec2(0.5, 0.5)
9
+ // @color Color of the first disc
10
+ uniform vec4 color1; // = vec4(0.99, 0.79, 0.29, 1.0)
11
+ // @color Color of the second disc
12
+ uniform vec4 color2; // = vec4(0.95, 0.38, 0.33, 1.0)
13
+ // @color Color of the third disc, which opens onto the incoming image
14
+ uniform vec4 color3; // = vec4(0.13, 0.15, 0.3, 1.0)
15
+ // @range(0, 1) Delay between the discs, relative to the burst of one disc (at 0, they burst as one: a single circle opens onto the incoming image)
16
+ uniform float stagger; // = 0.3
17
+
18
+ // half width of the antialiased edges, in frame heights
19
+ const float AA = 0.0015;
20
+ // width and opacity of the soft shadow each disc casts on what is under it
21
+ const float SW = 0.03;
22
+ const float SO = 0.32;
23
+
24
+ // local progress of a layer starting at s and lasting d
25
+ float phase(float s, float d) {
26
+ return clamp((progress - s) / d, 0.0, 1.0);
27
+ }
28
+
29
+ // radius of the edge of a layer at local progress t: it bursts out of just before the point and
30
+ // leaves the frame still moving, its shadow last
31
+ float radius(float t, float R) {
32
+ float u = 1.0 - t;
33
+ return mix(-SW - AA, R, mix(t, 1.0 - u * u * u, 0.8));
34
+ }
35
+
36
+ // fold texture coordinates back into the frame
37
+ vec2 mirror(vec2 v) {
38
+ return 1.0 - abs(1.0 - mod(abs(v), 2.0));
39
+ }
40
+
41
+ // a layer of color c and radius r laid over p (premultiplied), with its shadow around it, at distance x
42
+ vec4 layer(vec4 p, vec4 c, float r, float x) {
43
+ float k = smoothstep(r - AA, r + AA, x);
44
+ float s = SO * c.a * k * (1.0 - smoothstep(0.0, SW, x - r));
45
+ p = p * (1.0 - s) + vec4(0.0, 0.0, 0.0, s);
46
+ k = c.a * (1.0 - k);
47
+ return p * (1.0 - k) + vec4(c.rgb, 1.0) * k;
48
+ }
49
+
50
+ vec4 transition(vec2 uv) {
51
+ vec2 asp = vec2(ratio, 1.0);
52
+ float x = length((uv - center) * asp);
53
+ // past the farthest corner, with room for the shadows
54
+ float R = length(max(center, 1.0 - center) * asp) + SW + AA;
55
+ float k = clamp(stagger, 0.0, 1.0);
56
+ float d = 1.0 / (1.0 + 3.0 * k);
57
+
58
+ // the outgoing image is pushed in by the first burst
59
+ float t = phase(0.0, d);
60
+ vec4 a = getFromColor(mirror(center + (uv - center) / (1.0 + 0.06 * t * (2.0 - t))));
61
+ vec4 p = vec4(a.rgb * a.a, a.a);
62
+ p = layer(p, color1, radius(t, R), x);
63
+ p = layer(p, color2, radius(phase(k * d, d), R), x);
64
+ float r = radius(phase(2.0 * k * d, d), R);
65
+ p = layer(p, color3, r, x);
66
+
67
+ // the hole in the last disc shows the incoming image, which pops in slightly zoomed, overshoots
68
+ // and settles, shaded along the hole's rim as much as the disc around it is wide
69
+ t = phase(3.0 * k * d, d);
70
+ float h = radius(t, R);
71
+ float u = 1.0 - t;
72
+ vec4 b = getToColor(mirror(center + (uv - center) / (1.0 + 0.14 * u * u * (1.0 - 2.4 * t))));
73
+ float s = SO * color3.a * clamp((r - h) / SW, 0.0, 1.0) * (1.0 - smoothstep(0.0, SW, h - x));
74
+ vec4 q = vec4(b.rgb * b.a * (1.0 - s), b.a * (1.0 - s) + s);
75
+ p = mix(p, q, 1.0 - smoothstep(h - AA, h + AA, x));
76
+ return p.a > 0.0 ? vec4(p.rgb / p.a, p.a) : vec4(0.0);
77
+ }
@@ -0,0 +1,217 @@
1
+ // Clothesline — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Clothesline.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The camera pulls back to show the outgoing image as a print hung by two clothespins on a line in front of a wall, the line is pulled sideways and carries it away while the incoming print slides in, both prints swinging and tilting like hanging paper, then the camera moves back in on the incoming print until it fills the frame
5
+ // Tags: 3d, perspective, slide, swing, paper, directional
6
+
7
+ // @param Way the line is pulled: 1 brings the incoming print in from the right, -1 from the left
8
+ uniform float direction; // = 1.0
9
+ // @range(0, 1) How much the prints swing and tilt as the line moves
10
+ uniform float sway; // = 0.5
11
+ // @range(0.4, 0.95) Size of the prints when the camera is farthest, as a part of the frame
12
+ uniform float size; // = 0.72
13
+ // @color Color of the wall behind the line
14
+ uniform vec4 background; // = vec4(0.86, 0.84, 0.8, 1.0)
15
+ // @color Color of the line
16
+ uniform vec4 lineColor; // = vec4(0.42, 0.34, 0.26, 1.0)
17
+ // @color Color of the clothespins
18
+ uniform vec4 pinColor; // = vec4(0.84, 0.68, 0.47, 1.0)
19
+
20
+ const float FOCAL = 2.0; // distance from the camera to a print when it fills the frame
21
+ const float GAP = 0.35; // space between two prints on the line, in frame heights
22
+ const float WALL = 0.14; // distance from the line to the wall behind it
23
+ const float ROPE = 0.0055; // half thickness of the line
24
+ const vec2 PIN = vec2(0.021, 0.072); // half size of a clothespin
25
+ const float PIN_Y = -0.01; // center of a clothespin below the top edge of its print
26
+ const float AA = 0.0015; // width of the antialiased edges, in frame heights
27
+ const vec3 LIGHT = vec3(-0.28, 0.48, 0.83); // toward the light: above, a bit on the left, in front
28
+ const float PIN_X = 0.32; // clothespins from the center of their print, in print widths
29
+ const int STEPS = 32; // steps of the swing simulation over the whole transition
30
+
31
+ // the line moves between these progress values
32
+ const float SLIDE_START = 0.1;
33
+ const float SLIDE_END = 0.86;
34
+
35
+ vec4 premultiply(vec4 c) {
36
+ return vec4(c.rgb * c.a, c.a);
37
+ }
38
+
39
+ // time of the line's move at p, from 0 to 1
40
+ float slideTime(float p) {
41
+ return clamp((p - SLIDE_START) / (SLIDE_END - SLIDE_START), 0.0, 1.0);
42
+ }
43
+
44
+ // part of its travel done (smootherstep of the time)
45
+ float slideAmount(float u) {
46
+ return u * u * u * (u * (u * 6.0 - 15.0) + 10.0);
47
+ }
48
+
49
+ // acceleration of the travel at p, per progress squared
50
+ float slideAccel(float p) {
51
+ float u = slideTime(p);
52
+ float dur = SLIDE_END - SLIDE_START;
53
+ return 60.0 * u * (1.0 - u) * (1.0 - 2.0 * u) / (dur * dur);
54
+ }
55
+
56
+ // the sideways swing of the prints' bottoms, along the travel: a damped pendulum driven by the
57
+ // line's acceleration, lagging behind it at the start and overshooting at the stop
58
+ float swing(float p) {
59
+ const float OMEGA = 10.0; // about 1.6 swings over the transition
60
+ const float DAMP = 0.28;
61
+ const float STEP = 1.0 / float(STEPS);
62
+ float x = 0.0;
63
+ float v = 0.0;
64
+ // fixed steps, the last one cut at p, so that every frame follows the same curve
65
+ for (int i = 0; i < STEPS; i++) {
66
+ float t0 = float(i) * STEP;
67
+ float dt = clamp(p - t0, 0.0, STEP);
68
+ float a = slideAccel(t0 + 0.5 * dt) - OMEGA * OMEGA * x - 2.0 * DAMP * OMEGA * v;
69
+ v += a * dt;
70
+ x += v * dt;
71
+ }
72
+ // it settles as the camera moves back in
73
+ return x * (1.0 - smoothstep(0.7, 1.0, p));
74
+ }
75
+
76
+ // signed distance to a rounded box of half size b and corner radius r
77
+ float roundedBox(vec2 q, vec2 b, float r) {
78
+ vec2 d = abs(q) - b + r;
79
+ return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - r;
80
+ }
81
+
82
+ // the point (u across, v down from the top edge) where the ray o + t d meets the plane of a print
83
+ // hanging from (cx, 0.5, 0) and swung back by psi around its top edge, and t
84
+ vec3 printHit(vec3 o, vec3 d, float cx, float psi) {
85
+ vec3 dn = vec3(0.0, -cos(psi), -sin(psi));
86
+ vec3 n = vec3(0.0, sin(psi), -cos(psi));
87
+ vec3 p0 = vec3(cx, 0.5, 0.0);
88
+ float t = dot(p0 - o, n) / dot(d, n);
89
+ vec3 q = o + d * t - p0;
90
+ return vec3(q.x, dot(q, dn), t);
91
+ }
92
+
93
+ // the bottom of the print bends sideways by bend frame heights
94
+ float bendShift(float v, float bend) {
95
+ float h = clamp(v, 0.0, 1.0);
96
+ return bend * h * (0.6 + 0.4 * h);
97
+ }
98
+
99
+ // signed distance to the paper (negative inside), in frame heights
100
+ float paperDist(vec2 uv, float bend) {
101
+ vec2 q = abs(vec2(uv.x - bendShift(uv.y, bend), uv.y - 0.5)) - vec2(0.5 * ratio, 0.5);
102
+ return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
103
+ }
104
+
105
+ // signed distance to the two clothespins of a print
106
+ float pinDist(vec2 uv) {
107
+ vec2 q = vec2(abs(uv.x) - PIN_X * ratio, uv.y - PIN_Y);
108
+ return roundedBox(q, PIN, 0.012);
109
+ }
110
+
111
+ // the print hanging at cx over col (premultiplied), then its clothespins
112
+ vec4 drawPrint(vec4 col, vec3 h, bool isFrom, float bend, float psi, float aa, float vis) {
113
+ vec2 lp = h.xy;
114
+ float d = paperDist(lp, bend);
115
+ float cov = clamp(0.5 - d / (h.z * aa), 0.0, 1.0);
116
+ if (cov > 0.0) {
117
+ vec2 st = clamp(vec2((lp.x - bendShift(lp.y, bend)) / ratio + 0.5, 1.0 - lp.y), 0.0, 1.0);
118
+ vec4 c = premultiply(isFrom ? getFromColor(st) : getToColor(st));
119
+ // the paper darkens as it swings back and bends, and under the clothespins
120
+ float shade = 1.0 - 1.2 * abs(sin(psi)) * lp.y - 0.35 * abs(bend) * lp.y;
121
+ float ps = pinDist(lp - vec2(0.006, 0.01));
122
+ shade -= 0.35 * vis * (1.0 - smoothstep(-0.004, 0.012, ps));
123
+ c.rgb *= clamp(shade, 0.0, 1.0);
124
+ col = c * cov + col * (1.0 - c.a * cov);
125
+ }
126
+ return col;
127
+ }
128
+
129
+ vec4 drawPins(vec4 col, vec3 h, float aa, float vis) {
130
+ vec2 lp = h.xy;
131
+ float d = pinDist(lp);
132
+ float cov = vis * clamp(0.5 - d / (h.z * aa), 0.0, 1.0);
133
+ if (cov > 0.0) {
134
+ // rounded wood, with the steel spring across it
135
+ float k = clamp((abs(lp.x) - PIN_X * ratio) / PIN.x, -1.0, 1.0);
136
+ vec3 c = pinColor.rgb * (0.62 + 0.45 * sqrt(1.0 - k * k));
137
+ float y = lp.y - PIN_Y;
138
+ float spring = 1.0 - smoothstep(0.004, 0.007, abs(y + 0.02));
139
+ c = mix(c, vec3(0.3, 0.31, 0.33) * (0.6 + 0.8 * sqrt(1.0 - k * k)), spring);
140
+ // the groove that grips the paper
141
+ c *= 1.0 - 0.3 * (1.0 - smoothstep(0.002, 0.005, abs(y - 0.012)));
142
+ vec4 pc = premultiply(vec4(c, pinColor.a));
143
+ col = pc * cov + col * (1.0 - pc.a * cov);
144
+ }
145
+ return col;
146
+ }
147
+
148
+ vec4 transition(vec2 uv) {
149
+ float p = progress;
150
+ float s = direction < 0.0 ? -1.0 : 1.0;
151
+ float sw = clamp(sway, 0.0, 1.0);
152
+
153
+ // the camera pulls back, then moves back in on the incoming print
154
+ float back = smoothstep(0.0, 0.3, p) * (1.0 - smoothstep(0.6, 1.0, p));
155
+ float zoom = mix(1.0, clamp(size, 0.1, 1.0), back);
156
+ float vis = smoothstep(0.0, 0.35, back);
157
+ vec3 o = vec3(0.0, 0.05 * back, FOCAL / zoom);
158
+ vec3 d = vec3((uv - 0.5) * vec2(ratio, 1.0), -FOCAL);
159
+ float aa = max(AA * min(1.0, 40.0 * back), 1e-6);
160
+
161
+ // the line carries the prints along
162
+ float u = slideTime(p);
163
+ float m = slideAmount(u);
164
+ float speed = 16.0 * u * u * (1.0 - u) * (1.0 - u);
165
+ float spacing = ratio + GAP;
166
+ float cFrom = -s * spacing * m;
167
+ float cTo = s * spacing * (1.0 - m);
168
+ // the bottoms lag behind and overshoot, and swing back in the wind of the move
169
+ float bend = s * 0.65 * sw * swing(p);
170
+ float psi = 0.45 * sw * speed;
171
+
172
+ vec3 hf = printHit(o, d, cFrom, psi);
173
+ vec3 ht = printHit(o, d, cTo, psi);
174
+
175
+ // the wall, seen around the prints (only behind their transparent parts at the ends),
176
+ // with the soft shadows of the prints, the pins and the line
177
+ vec4 col = premultiply(background);
178
+ float cover = max(
179
+ clamp(0.5 - paperDist(hf.xy, bend) / (hf.z * aa), 0.0, 1.0),
180
+ clamp(0.5 - paperDist(ht.xy, bend) / (ht.z * aa), 0.0, 1.0));
181
+ col *= mix(1.0, back, cover);
182
+ if (back > 0.0) {
183
+ vec3 w = o + d * ((o.z + WALL) / FOCAL);
184
+ vec3 sf = printHit(w, LIGHT, cFrom, psi);
185
+ vec3 st = printHit(w, LIGHT, cTo, psi);
186
+ float blur = 0.025;
187
+ float sh = 1.0 - smoothstep(-blur, blur, min(paperDist(sf.xy, bend), paperDist(st.xy, bend)));
188
+ sh = max(sh, 1.0 - smoothstep(-0.012, 0.02, min(pinDist(sf.xy), pinDist(st.xy))));
189
+ float ry = w.y + LIGHT.y * (WALL / LIGHT.z) - (0.5 - 0.012);
190
+ sh = max(sh, 0.8 * (1.0 - smoothstep(0.0, 0.012, abs(ry))));
191
+ // and a soft falloff of the light away from the top left
192
+ float fall = 0.1 * clamp(length(w.xy - vec2(-0.4 * ratio, 0.6)) / (1.2 * ratio + 0.6), 0.0, 1.0);
193
+ col.rgb *= (1.0 - 0.42 * vis * sh) * (1.0 - fall * vis);
194
+ }
195
+
196
+ col = drawPrint(col, hf, true, bend, psi, aa, vis);
197
+ col = drawPrint(col, ht, false, bend, psi, aa, vis);
198
+
199
+ // the line, in front of the top of the prints
200
+ if (vis > 0.0) {
201
+ float tl = (o.z - 0.004) / FOCAL;
202
+ float ly = o.y + d.y * tl - (0.5 - 0.012);
203
+ float lc = vis * clamp(0.5 - (abs(ly) - ROPE) / (tl * aa), 0.0, 1.0);
204
+ if (lc > 0.0) {
205
+ float k = clamp(ly / ROPE, -1.0, 1.0);
206
+ // twisted strands, carried along with the line, lit from above
207
+ float lx = o.x + d.x * tl + s * spacing * m;
208
+ float strand = 0.88 + 0.12 * sin((lx + ly * 0.6) * 360.0);
209
+ vec3 c = lineColor.rgb * (0.7 + 0.45 * sqrt(1.0 - k * k) + 0.15 * k) * strand;
210
+ vec4 lcp = premultiply(vec4(c, lineColor.a));
211
+ col = lcp * lc + col * (1.0 - lcp.a * lc);
212
+ }
213
+ col = drawPins(col, hf, aa, vis);
214
+ col = drawPins(col, ht, aa, vis);
215
+ }
216
+ return col.a > 0.0 ? vec4(col.rgb / col.a, col.a) : vec4(0.0);
217
+ }
@@ -0,0 +1,114 @@
1
+ // CodeRain — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/CodeRain.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image darkens into a grid of flickering code characters tinted by its colors, then glowing streams of characters fall down the columns at their own speeds, each with a bright head and a fading tail, leaving the incoming image behind
5
+ // Tags: text, digital, rain, reveal
6
+
7
+ // @range(0.02, 0.1) Height of a character, in frame heights
8
+ uniform float cellSize; // = 0.045
9
+ // @range(0.05, 1) Average length of the streams' fading tails, in frame heights
10
+ uniform float trail; // = 0.5
11
+ // @range(0, 1) How much the characters of the outgoing image take its colors, instead of the glow color
12
+ uniform float tint; // = 0.5
13
+ // @color Color of the falling streams and their glow
14
+ uniform vec4 glow; // = vec4(0.2, 1.0, 0.4, 1.0)
15
+
16
+ float hash12(vec2 p) {
17
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
18
+ p3 += dot(p3, p3.yzx + 33.33);
19
+ return fract((p3.x + p3.y) * p3.z);
20
+ }
21
+
22
+ vec4 hash42(vec2 p) {
23
+ vec4 p4 = fract(vec4(p.xyxy) * vec4(0.1031, 0.1030, 0.0973, 0.1099));
24
+ p4 += dot(p4, p4.wzxy + 33.33);
25
+ return fract((p4.xxyz + p4.yzzw) * p4.zywx);
26
+ }
27
+
28
+ // 1 inside a stroke, fading out from 0.3 to 0.6 dot of distance
29
+ vec4 band(vec4 d) {
30
+ return 1.0 - smoothstep(0.3, 0.6, d);
31
+ }
32
+
33
+ // coverage of the character of this cell at this time, drawn on a 5x7 dot grid in a 6x8 cell
34
+ // (local: 0..1 in the cell, from its top left), made of strokes picked by hashes
35
+ float glyph(vec2 cell, float t, vec2 local) {
36
+ vec2 b = local * vec2(6.0, 8.0) - 0.5;
37
+ float x = b.x;
38
+ float y = b.y;
39
+ float d = 0.667 * y;
40
+ // how far outside the spans 0..4, 0..6, 0..3 and 3..6, in dots
41
+ float x04 = abs(x - 2.0) - 2.0;
42
+ float y06 = abs(y - 3.0) - 3.0;
43
+ float y03 = abs(y - 1.5) - 1.5;
44
+ float y36 = abs(y - 4.5) - 1.5;
45
+ vec2 seed = cell + t * vec2(37.0, 61.0);
46
+ // strokes: three bars and a diagonal, the halves of the side verticals,
47
+ // the halves of the middle vertical, the other diagonal and a short bar
48
+ vec4 sa = band(abs(vec4(y, y - 3.0, y - 6.0, x - d))) * band(vec4(x04, x04, x04, y06));
49
+ vec4 sb = band(abs(vec4(x, x, x - 4.0, x - 4.0))) * band(vec4(y03, y36, y03, y36));
50
+ vec4 sc = band(abs(vec4(x - 2.0, x - 2.0, x + d - 4.0, y - 1.0))) * band(vec4(y03, y36, y06, abs(x - 2.0) - 1.0));
51
+ float on = dot(step(0.68, hash42(seed)), sa);
52
+ on += dot(step(0.68, hash42(seed + 41.0)), sb);
53
+ on += dot(step(0.68, hash42(seed + 83.0)), sc);
54
+ return min(on, 1.0);
55
+ }
56
+
57
+ vec4 transition(vec2 uv) {
58
+ float h = max(cellSize, 0.005);
59
+ vec2 dims = vec2(0.75 * h, h);
60
+ // frame coordinates from the top left, in frame heights
61
+ vec2 fp = vec2(uv.x * ratio, 1.0 - uv.y);
62
+ // (shifted by odd fractions of a cell, so that pixel centers don't fall on its lines at usual sizes)
63
+ vec2 grid = fp / dims + vec2(0.389, 0.278);
64
+ vec2 cell = floor(grid);
65
+ vec2 local = grid - cell;
66
+ float rc = hash12(cell + vec2(97.0, 131.0));
67
+
68
+ // each column has its own stream: its start, speed and tail length
69
+ float r1 = hash12(vec2(cell.x, 11.0));
70
+ float r2 = hash12(vec2(cell.x, 23.0));
71
+ float r3 = hash12(vec2(cell.x, 37.0));
72
+ float T = mix(progress, progress * progress * (3.0 - 2.0 * progress), 0.5);
73
+ float len = max(trail, 0.01) * (0.5 + r3);
74
+ float u = clamp((T - 0.03 - 0.5 * r1) / (0.3 + 0.12 * r2), 0.0, 1.0);
75
+ // the head falls from above the frame, speeding up a little, until its tail has left the frame
76
+ float head = mix(-0.2, 1.0 + h + len, u * (0.7 + 0.3 * u));
77
+ // how far the head has gone past the cell's top
78
+ float dy = head - (cell.y - 0.278) * h;
79
+
80
+ vec4 a = getFromColor(uv);
81
+ vec4 b = getToColor(uv);
82
+
83
+ // ahead of the stream: the outgoing image darkens into characters tinted by its cell's color,
84
+ // over time and as the head comes near
85
+ vec2 cuv = clamp(vec2((cell.x + 0.111) * dims.x / ratio, 1.0 - (cell.y + 0.222) * h), 0.0, 1.0);
86
+ vec4 ca = getFromColor(cuv);
87
+ float lum = dot(ca.rgb, vec3(0.299, 0.587, 0.114));
88
+ vec3 hue = ca.rgb / max(max(ca.r, max(ca.g, ca.b)), 0.05);
89
+ vec3 ink = mix(glow.rgb * glow.a, hue, tint) * (0.1 + 0.6 * lum);
90
+ float near = smoothstep(-0.15, 0.0, dy);
91
+ float dim = max(smoothstep(0.0, 0.3, T), near);
92
+ float g = max(smoothstep(0.0, 0.2, T - 0.12 * rc), near);
93
+ float passed = step(0.0, dy);
94
+ // the characters change slowly ahead of the stream and fast in it
95
+ float slow = mod(floor(T * 12.0 + rc * 7.0), 32.0);
96
+ float fast = 32.0 + mod(floor(T * 40.0 + rc * 13.0), 32.0);
97
+ float chr = glyph(cell, mix(slow, fast, passed), local);
98
+ vec3 code = a.rgb * (1.0 - 0.8 * dim) + ink * chr * g;
99
+
100
+ // behind the head: bright characters changing fast, fading along the tail, over a shadow that
101
+ // clears in the tail's last two thirds to leave the incoming image
102
+ float fade = clamp(1.0 - dy / len, 0.0, 1.0);
103
+ float shade = 1.0 - smoothstep(0.3 * len, len, dy);
104
+ float hot = 1.0 - smoothstep(h, 3.0 * h, dy);
105
+ vec3 col = mix(glow.rgb * 1.2, vec3(1.0), 0.8 * hot) * glow.a;
106
+ vec3 stream = b.rgb * (1.0 - 0.8 * shade) + col * chr * (fade * (2.0 - fade) + hot * fade);
107
+
108
+ // a soft glow around the head, within its column
109
+ float yy = (head - fp.y) / (1.5 * h);
110
+ float halo = 1.6 * u * (1.0 - u) * exp(-yy * yy) * (1.0 - smoothstep(0.25, 0.5, abs(local.x - 0.5)));
111
+ vec3 rgb = mix(code, stream, passed) + glow.rgb * glow.a * halo;
112
+ // the outgoing image's opacity stays under the tail's shadow, then gives way to the incoming one's
113
+ return vec4(clamp(rgb, 0.0, 1.0), mix(a.a, mix(b.a, a.a, shade), passed));
114
+ }