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,85 @@
1
+ // Accordion — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Accordion.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image folds up like a pleated paper toward one side while the incoming one unfolds out of the other, both in 3D with lit and shadowed pleats
5
+ // Tags: fold, 3d, slide, stripes
6
+
7
+ // @range(1, 12, 1) Number of pleats in each image (a pleat is a pair of panels, one lit and one in the shade)
8
+ uniform int pleats; // = 4
9
+ // @param Direction in which the images move, snapped to its main axis (left, right, up or down): the outgoing image folds up toward it, the incoming one unfolds from the opposite side
10
+ uniform vec2 direction; // = vec2(-1.0, 0.0)
11
+ // @range(0, 1) Contrast between the lit and the shaded panels
12
+ uniform float shading; // = 0.7
13
+ // @range(0, 3) Amount of perspective: the valleys between the pleats recede
14
+ uniform float perspective; // = 1.5
15
+ // @color Color seen around the folded images, where the valleys recede
16
+ uniform vec4 backColor; // = vec4(0.0, 0.0, 0.0, 1.0)
17
+
18
+ // light from the front and the side: its sideways and front components
19
+ const float LIGHT_SIDE = 0.55;
20
+ const float LIGHT_FRONT = 0.835;
21
+ // width of the anti-aliased folds and edges, in frame heights
22
+ const float EDGE = 0.0015;
23
+
24
+ // brightness of a panel folded by angle (c, s) = (cos, sin), facing the light (sign 1) or away (-1)
25
+ float panelLight(float c, float s, float facing) {
26
+ float lambert = (c * LIGHT_FRONT + facing * s * LIGHT_SIDE) / LIGHT_FRONT;
27
+ return mix(1.0, clamp(lambert, 0.08, 1.25), shading);
28
+ }
29
+
30
+ // one folded image: f is the position along it (0 to 1, from its anchored side), c the visible part
31
+ // of its length (cos of the fold angle), len its length and b the position across it, in frame heights
32
+ vec4 pleated(float f, float c, float len, float b, float bLen, bool incoming, bool flipA, bool vertical) {
33
+ float m = 2.0 * float(pleats > 1 ? pleats : 1);
34
+ float s = sqrt(max(1.0 - c * c, 0.0));
35
+ float u = f * m;
36
+ // f = 1 is the end of the last panel, not the start of one more
37
+ float panel = min(floor(u), m - 1.0);
38
+ float fu = u - panel;
39
+ // the ridges (odd boundaries) stay in the frame's plane, the valleys (even ones) recede
40
+ float tri = 1.0 - abs(mod(u, 2.0) - 1.0);
41
+ float panelLen = len / m;
42
+ float z = panelLen * s * (1.0 - tri);
43
+ // farther parts look smaller
44
+ float scale = 1.0 / (1.0 + perspective * z);
45
+ float bb = (b - 0.5 * bLen) / scale / bLen + 0.5;
46
+ // soft top and bottom edges while folded (sharp when flat, to keep the first and last frames exact)
47
+ float edge = EDGE * min(1.0, 20.0 * s * c) + 1e-6;
48
+ float cover = clamp(min(bb, 1.0 - bb) * bLen * scale / edge, 0.0, 1.0);
49
+ float a = flipA ? 1.0 - f : f;
50
+ vec2 st = clamp(vertical ? vec2(bb, a) : vec2(a, bb), 0.0, 1.0);
51
+ vec4 img = incoming ? getToColor(st) : getFromColor(st);
52
+ // even panels face the light, odd ones turn away; blend across each fold over a pixel or so
53
+ float facing = mod(panel, 2.0) < 0.5 ? 1.0 : -1.0;
54
+ float toEdge = min(fu, 1.0 - fu) * panelLen * c;
55
+ float k = 0.5 + 0.5 * clamp(toEdge / EDGE, 0.0, 1.0);
56
+ float light = mix(panelLight(c, s, -facing), panelLight(c, s, facing), k);
57
+ // a touch of shade deep in the valleys
58
+ float valley = 1.0 - tri;
59
+ light *= 1.0 - 0.4 * shading * s * valley * valley;
60
+ return mix(backColor, vec4(img.rgb * light, img.a), cover);
61
+ }
62
+
63
+ vec4 transition(vec2 uv) {
64
+ bool vertical = abs(direction.y) > abs(direction.x);
65
+ bool positive = vertical ? direction.y > 0.0 : direction.x > 0.0;
66
+ // a: along the motion, 0 on the side the outgoing image folds up toward; b: across it
67
+ float a = vertical ? uv.y : uv.x;
68
+ if (positive) a = 1.0 - a;
69
+ float b = vertical ? uv.x : uv.y;
70
+ float len = vertical ? 1.0 : ratio;
71
+ float bLen = vertical ? ratio : 1.0;
72
+
73
+ float p = progress;
74
+ float e = p * p * (3.0 - 2.0 * p);
75
+ e = mix(p, e, 0.8);
76
+ // visible part of each image's length
77
+ float cFrom = 1.0 - e;
78
+ float cTo = e;
79
+ if (a < cFrom || cTo <= 0.0) {
80
+ // the outgoing image, anchored on its side
81
+ return pleated(a / cFrom, cFrom, len, b * bLen, bLen, false, positive, vertical);
82
+ }
83
+ // the incoming image, anchored on the opposite side
84
+ return pleated(1.0 - (1.0 - a) / cTo, cTo, len, b * bLen, bLen, true, positive, vertical);
85
+ }
@@ -0,0 +1,124 @@
1
+ // Ascii — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Ascii.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The image turns into text-mode characters, denser where it is brighter, the characters scramble into those of the incoming image, then resolve back into it
5
+ // Tags: text, pattern, retro, digital
6
+
7
+ // @range(0.01, 0.1) Height of a character, in frame heights
8
+ uniform float cellSize; // = 0.04
9
+ // @param Color the characters with the image (otherwise, with the ink color)
10
+ uniform bool colored; // = true
11
+ // @color Color of the characters when they are not colored with the image
12
+ uniform vec4 ink; // = vec4(0.3, 1.0, 0.45, 1.0)
13
+ // @color Color behind the characters
14
+ uniform vec4 background; // = vec4(0.0, 0.0, 0.0, 1.0)
15
+
16
+ // width of a character cell, in cell heights
17
+ const float ASPECT = 0.6;
18
+ // half width of the strokes, in cell heights
19
+ const float STROKE = 0.05;
20
+
21
+ float hash12(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
+ // distance to the segment from a to b
28
+ float segment(vec2 q, vec2 a, vec2 b) {
29
+ vec2 pa = q - a;
30
+ vec2 ba = b - a;
31
+ return length(pa - ba * clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0));
32
+ }
33
+
34
+ // distance to the strokes of the character of this density, from 0 (" ") to 9 ("@"),
35
+ // at q, in cell heights from the cell's center
36
+ float glyph(float g, vec2 q) {
37
+ if (g < 0.5) return 1.0; // " "
38
+ if (g < 1.5) return length(q - vec2(0.0, -0.27)) - 0.035; // "."
39
+ if (g < 2.5) return min(length(q - vec2(0.0, -0.25)), length(q - vec2(0.0, 0.1))) - 0.035; // ":"
40
+ if (g < 3.5) return segment(q, vec2(-0.17, 0.0), vec2(0.17, 0.0)) - STROKE; // "-"
41
+ if (g < 4.5) { // "="
42
+ return min(segment(q, vec2(-0.18, 0.1), vec2(0.18, 0.1)), segment(q, vec2(-0.18, -0.1), vec2(0.18, -0.1))) - STROKE;
43
+ }
44
+ if (g < 5.5) { // "+"
45
+ return min(segment(q, vec2(-0.19, 0.0), vec2(0.19, 0.0)), segment(q, vec2(0.0, -0.19), vec2(0.0, 0.19))) - STROKE;
46
+ }
47
+ if (g < 6.5) { // "*"
48
+ float d = segment(q, vec2(0.0, -0.2), vec2(0.0, 0.2));
49
+ d = min(d, segment(q, vec2(-0.18, -0.11), vec2(0.18, 0.11)));
50
+ d = min(d, segment(q, vec2(-0.18, 0.11), vec2(0.18, -0.11)));
51
+ return d - STROKE;
52
+ }
53
+ if (g < 7.5) { // "#"
54
+ float d = min(segment(q, vec2(-0.06, -0.3), vec2(-0.1, 0.3)), segment(q, vec2(0.12, -0.3), vec2(0.08, 0.3)));
55
+ d = min(d, min(segment(q, vec2(-0.24, 0.11), vec2(0.24, 0.11)), segment(q, vec2(-0.24, -0.11), vec2(0.24, -0.11))));
56
+ return d - STROKE;
57
+ }
58
+ if (g < 8.5) { // "%"
59
+ float d = segment(q, vec2(-0.2, -0.3), vec2(0.2, 0.3));
60
+ d = min(d, abs(length(q - vec2(-0.13, 0.19)) - 0.08));
61
+ d = min(d, abs(length(q - vec2(0.13, -0.19)) - 0.08));
62
+ return d - STROKE;
63
+ }
64
+ // "@": a ring around a small "a"
65
+ float d = abs(length(q) - 0.25);
66
+ d = min(d, abs(length(q - vec2(-0.02, 0.0)) - 0.1));
67
+ d = min(d, segment(q, vec2(0.08, 0.1), vec2(0.08, -0.12)));
68
+ return d - 0.8 * STROKE;
69
+ }
70
+
71
+ // the brightness of a color, from 0 to 1, as a character density
72
+ float density(vec4 c) {
73
+ return floor(pow(clamp(dot(c.rgb, vec3(0.299, 0.587, 0.114)) * c.a, 0.0, 1.0), 0.75) * 9.99);
74
+ }
75
+
76
+ // the average color of a cell, from 4 samples
77
+ vec4 cellColor(vec2 center, vec2 dims, bool incoming) {
78
+ vec4 c = vec4(0.0);
79
+ for (int i = 0; i < 4; i++) {
80
+ vec2 o = (vec2(mod(float(i), 2.0), floor(float(i) / 2.0)) - 0.5) * 0.5 * dims;
81
+ vec2 st = clamp((center + o) / vec2(ratio, 1.0) + 0.5, 0.0, 1.0);
82
+ c += incoming ? getToColor(st) : getFromColor(st);
83
+ }
84
+ return c * 0.25;
85
+ }
86
+
87
+ vec4 transition(vec2 uv) {
88
+ float p = progress;
89
+ float h = cellSize;
90
+ vec2 fp = (uv - 0.5) * vec2(ratio, 1.0);
91
+ vec2 dims = vec2(ASPECT * h, h);
92
+ vec2 cell = floor(fp / dims);
93
+ vec2 center = (cell + 0.5) * dims;
94
+ vec2 q = (fp - center) / h;
95
+
96
+ // each cell switches to the incoming image at its own time, scrambling through
97
+ // random characters around it
98
+ float r = hash12(cell + 100.0);
99
+ float at = 0.4 + 0.2 * r;
100
+ bool incoming = p > at;
101
+ vec4 c = cellColor(center, dims, incoming);
102
+ float g = density(c);
103
+ float scramble = 1.0 - smoothstep(0.02, 0.045, abs(p - at));
104
+ if (hash12(cell + floor(p * 40.0) * vec2(17.0, 31.0)) < scramble) {
105
+ g = 1.0 + floor(9.0 * hash12(cell * 1.7 + floor(p * 40.0) * vec2(5.0, 11.0)));
106
+ }
107
+
108
+ float cover = 1.0 - smoothstep(-0.02, 0.02, glyph(g, q));
109
+ vec3 tint = colored ? mix(c.rgb, c.rgb / max(max(c.r, max(c.g, c.b)), 0.05), 0.7) : ink.rgb;
110
+ float alpha = colored ? c.a : ink.a * c.a;
111
+ // where the image is transparent, so are the characters and their background
112
+ // colored characters glow faintly over their cell, so the picture stays readable
113
+ vec3 behind = colored ? mix(background.rgb, c.rgb, 0.3) : background.rgb;
114
+ vec4 back = vec4(behind, background.a * c.a);
115
+ vec4 text = mix(back, vec4(clamp(tint, 0.0, 1.0), alpha), cover);
116
+
117
+ // each cell dissolves into its character at its own time, from 0.05 to 0.35,
118
+ // and back into the incoming image from 0.65 to 0.95
119
+ float into = 0.05 + 0.22 * hash12(cell + 200.0);
120
+ float outof = 0.95 - 0.22 * hash12(cell + 300.0);
121
+ float show = smoothstep(into, into + 0.08, p) * (1.0 - smoothstep(outof - 0.08, outof, p));
122
+ vec4 image = p < 0.5 ? getFromColor(uv) : getToColor(uv);
123
+ return mix(image, text, show);
124
+ }
@@ -0,0 +1,87 @@
1
+ // BlockCover — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BlockCover.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Blocks of a solid color pop in at random over the outgoing image until they cover the frame, then pop out in another random order to show the incoming image
5
+ // Tags: blocks, grid, squares, color, cover
6
+
7
+ // @range(1, 40, 1) Number of blocks along the longer side of the frame (the blocks stay about square)
8
+ uniform int blocks; // = 16
9
+ // @color Color of the blocks
10
+ uniform vec4 color; // = vec4(0.95, 0.32, 0.26, 1.0)
11
+ // @range(0, 1) How much a block overshoots its cell as it pops in
12
+ uniform float pop; // = 0.5
13
+ // @range(0, 0.5) Softness of the blocks' edges, in blocks
14
+ uniform float smoothness; // = 0.03
15
+
16
+ const float duration = 0.14; // of one block's pop, in progress
17
+ const float cut = 0.45; // the frame is fully covered from cut - hold to cut + hold
18
+ const float hold = 0.02;
19
+
20
+ float hash (vec2 p) {
21
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
22
+ p3 += dot(p3, p3.yzx + 33.33);
23
+ return fract((p3.x + p3.y) * p3.z);
24
+ }
25
+
26
+ // eases from 0 to 1, a little past 1 (more with a larger c) and back
27
+ float backOut (float t, float c) {
28
+ float u = t - 1.0;
29
+ return 1.0 + (c + 1.0) * u * u * u + c * u * u;
30
+ }
31
+
32
+ // when a cell's block starts to pop in (.x) and to pop out (.y)
33
+ vec2 timing (vec2 cell) {
34
+ return vec2(
35
+ (cut - hold - duration) * hash(cell + 0.5),
36
+ cut + hold + (1.0 - cut - hold - duration) * hash(cell + 71.7));
37
+ }
38
+
39
+ // scale of the block of a cell: 0 when it is not there, 1 when it fills its cell
40
+ float blockScale (vec2 cell, float c) {
41
+ vec2 t = timing(cell);
42
+ float a = clamp((progress - t.x) / duration, 0.0, 1.0);
43
+ float b = clamp((progress - t.y) / duration, 0.0, 1.0);
44
+ // it grows from nothing with an overshoot, and shrinks back to nothing
45
+ return b > 0.0 ? (1.0 - b) * (1.0 - b) : backOut(a, c);
46
+ }
47
+
48
+ // how much of the point q (in cells) the block of a cell covers
49
+ float coverage (vec2 q, vec2 cell, float s, float sm) {
50
+ // at scale 1, its solid part fills the whole cell, so that a covered frame shows no seams
51
+ float h = s * (0.5 + sm);
52
+ vec2 d = abs(q - cell - 0.5);
53
+ return s > 0.0 ? 1.0 - smoothstep(h - sm, h, max(d.x, d.y)) : 0.0;
54
+ }
55
+
56
+ vec4 transition (vec2 uv) {
57
+ float nLong = max(float(blocks), 1.0);
58
+ vec2 n = ratio >= 1.0
59
+ ? vec2(nLong, max(1.0, floor(nLong / ratio + 0.5)))
60
+ : vec2(max(1.0, floor(nLong * ratio + 0.5)), nLong);
61
+ vec2 q = uv * n;
62
+ vec2 cell = floor(q);
63
+ float sm = max(smoothness, 0.001);
64
+ float c = 2.0 * clamp(pop, 0.0, 1.0);
65
+ float s = blockScale(cell, c);
66
+ if (s >= 1.0) return color;
67
+ float cover = coverage(q, cell, s, sm);
68
+ // a neighbour's block can overshoot onto this cell, near its border only
69
+ float u = -2.0 * c / (3.0 * (c + 1.0));
70
+ float reach = backOut(1.0 + u, c) * (0.5 + sm);
71
+ vec2 o = abs(q - cell - 0.5);
72
+ if (max(o.x, o.y) > 1.0 - reach) {
73
+ for (int j = -1; j <= 1; j++) {
74
+ for (int i = -1; i <= 1; i++) {
75
+ vec2 nb = cell + vec2(float(i), float(j));
76
+ vec2 inside = step(vec2(0.0), nb) * step(nb, n - 1.0);
77
+ if (inside.x * inside.y > 0.0 && (i != 0 || j != 0)) {
78
+ cover = max(cover, coverage(q, nb, blockScale(nb, c), sm));
79
+ }
80
+ }
81
+ }
82
+ }
83
+ // each cell switches to the incoming image while its own block covers it
84
+ vec2 t = timing(cell);
85
+ vec4 under = progress < 0.5 * (t.x + duration + t.y) ? getFromColor(uv) : getToColor(uv);
86
+ return mix(under, color, cover);
87
+ }
@@ -0,0 +1,110 @@
1
+ // BloomDissolve — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BloomDissolve.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The highlights of the outgoing image blow out into a soft, wide glow that floods the frame; under it the incoming image takes over, then the glow subsides back into its highlights while the image stays sharp
5
+ // Tags: light, glow, bloom, dissolve
6
+
7
+ // @range(0, 0.6) Reach of the glow at the peak, in frame heights
8
+ uniform float spread; // = 0.25
9
+ // @range(0, 1) Brightness above which the image glows (the whole frame does at the peak)
10
+ uniform float threshold; // = 0.6
11
+ // @range(0, 4) Brightness of the glow
12
+ uniform float intensity; // = 1.5
13
+ // @color Tint of the glow, toward its edges
14
+ uniform vec3 tint; // = vec3(1.0, 0.9, 0.75)
15
+
16
+ // pairs of opposite taps: 20 reads per pixel
17
+ const int PAIRS = 10;
18
+ const float GOLDEN_ANGLE = 2.399963;
19
+
20
+ float hash12(vec2 v) {
21
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
22
+ v3 += dot(v3, v3.yzx + 33.33);
23
+ return fract((v3.x + v3.y) * v3.z);
24
+ }
25
+
26
+ // mirror the coordinates back into the frame
27
+ vec2 mirror(vec2 v) {
28
+ return 1.0 - abs(1.0 - mod(v, 2.0));
29
+ }
30
+
31
+ // the image on screen at a point, premultiplied: one image, or both during the short switch
32
+ vec4 image(vec2 st, float m) {
33
+ if (m <= 0.0) {
34
+ vec4 c = getFromColor(st);
35
+ return vec4(c.rgb * c.a, c.a);
36
+ }
37
+ if (m >= 1.0) {
38
+ vec4 c = getToColor(st);
39
+ return vec4(c.rgb * c.a, c.a);
40
+ }
41
+ vec4 a = getFromColor(st);
42
+ vec4 b = getToColor(st);
43
+ return mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), m);
44
+ }
45
+
46
+ // the light of a pixel (premultiplied): its color above the knee, full well before white
47
+ vec3 glow(vec4 c, float knee) {
48
+ float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
49
+ return c.rgb * smoothstep(knee, knee + max(0.3 * (1.0 - knee), 1e-3), lum);
50
+ }
51
+
52
+ vec4 transition(vec2 uv) {
53
+ float p = progress;
54
+ // the glow blooms on the outgoing image, and subsides on the incoming one
55
+ float amount = 4.0 * p * (1.0 - p);
56
+ float peak = amount * amount;
57
+ // around the middle, the whole frame catches the light and floods with glow
58
+ float flood = peak * peak * peak;
59
+ // the switch, under the glow at its brightest
60
+ float m = smoothstep(0.44, 0.56, p);
61
+ if (amount <= 0.0) return m < 0.5 ? getFromColor(uv) : getToColor(uv);
62
+
63
+ // the image stays sharp underneath (premultiplied colors, only the images on screen are read)
64
+ vec4 c = image(uv, m);
65
+ if (c.a <= 0.0) return vec4(0.0);
66
+ c.rgb /= c.a;
67
+
68
+ // more and more of the image catches the light as the glow grows
69
+ float knee = threshold * (1.0 - 0.3 * peak) * (1.0 - flood);
70
+ float radius = spread * amount;
71
+ // a rotation and a radial shift of the spiral for each pixel blend the taps into a smooth glow;
72
+ // hashed by integer cell so that every GPU computes the same values
73
+ vec2 cell = floor(uv * vec2(ratio, 1.0) * 997.0);
74
+ float spin = 6.2831853 * hash12(cell);
75
+ float shift = hash12(cell + 71.0);
76
+
77
+ // a golden-angle spiral, denser toward the center so the glow is bright at its core with a wide soft tail;
78
+ // each tap is read with its opposite, which cancels most of the noise across smooth gradients
79
+ vec3 bloom = vec3(0.0);
80
+ vec4 soft = vec4(0.0);
81
+ float total = 0.0;
82
+ for (int i = 0; i < PAIRS; i++) {
83
+ float s = (float(i) + shift) / float(PAIRS);
84
+ float r = s * s;
85
+ float a = float(i) * GOLDEN_ANGLE + spin;
86
+ vec2 offset = radius * r * vec2(cos(a) / ratio, sin(a));
87
+ vec4 i0 = image(mirror(uv + offset), m);
88
+ vec4 i1 = image(mirror(uv - offset), m);
89
+ vec3 l = glow(i0, knee) + glow(i1, knee);
90
+ // the sparse outer taps weigh less, so the tail of the glow stays smooth
91
+ float w = 1.0 - 0.75 * s;
92
+ // white at the core, tinted toward the edges
93
+ bloom += w * mix(vec3(1.0), tint, smoothstep(0.0, 0.5, r)) * l;
94
+ total += w;
95
+ // a closer blur of the image, to soften it
96
+ float sw = (1.0 - s) * (1.0 - s);
97
+ soft += sw * (i0 + i1);
98
+ }
99
+ bloom /= 2.0 * total;
100
+ // at the peak the light softens the image itself, which hides the switch
101
+ vec3 blurred = soft.a > 0.0 ? soft.rgb / soft.a : c.rgb;
102
+ vec3 base = mix(c.rgb, blurred, 0.7 * flood);
103
+ bloom *= intensity * peak * (1.0 + 2.0 * flood);
104
+ // compressed, so that the glow floods the frame without flattening into white
105
+ bloom = 0.92 * (1.0 - exp(-bloom));
106
+
107
+ // the glow is a light screened over the image: it adds nothing to its alpha
108
+ base = min(base * (1.0 + 0.25 * peak), 1.0);
109
+ return vec4(base + bloom - base * bloom, c.a);
110
+ }
@@ -0,0 +1,123 @@
1
+ // BokehDissolve — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BokehDissolve.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The image falls out of focus like a camera lens, its highlights swelling into large bright bokeh discs, and the incoming image sharpens back out of its own bokeh
5
+ // Tags: blur, bokeh, lens, dissolve, light
6
+
7
+ // @range(0.01, 0.15) Radius of the bokeh discs at the peak, in frame heights
8
+ uniform float radius; // = 0.05
9
+ // @range(0, 9) Number of aperture blades, which shape the discs into polygons (below 3: round)
10
+ uniform int blades; // = 0
11
+ // @range(0, 1) Brightness above which a pixel is a highlight that swells into a disc
12
+ uniform float threshold; // = 0.7
13
+ // @range(0, 3) Brightness of the bokeh discs
14
+ uniform float intensity; // = 1.0
15
+
16
+ #define PI 3.141592653589793
17
+ const int TAPS = 16;
18
+
19
+ // mirror the coordinates back into the frame
20
+ vec2 mirror(vec2 v) {
21
+ return 1.0 - abs(1.0 - mod(v, 2.0));
22
+ }
23
+
24
+ // a hash of an integer cell, stable across precisions
25
+ float hash12(vec2 p) {
26
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
27
+ p3 += dot(p3, p3.yzx + 33.33);
28
+ return fract((p3.x + p3.y) * p3.z);
29
+ }
30
+
31
+ // how much a pixel is a highlight: none below the threshold, full at white
32
+ float highlight(vec4 c, float t) {
33
+ float lum = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722));
34
+ // nothing is brighter than white, so a threshold of 1 makes no highlights
35
+ if (t >= 1.0) return 0.0;
36
+ float h = smoothstep(t, 1.0, lum);
37
+ return h * h * c.a;
38
+ }
39
+
40
+ vec4 transition(vec2 uv) {
41
+ // the lens defocuses then focuses back: 0 at both ends, 1 at the peak
42
+ float t = 1.0 - abs(2.0 * progress - 1.0);
43
+ float k = t * t * (3.0 - 2.0 * t);
44
+ // the incoming image takes over while everything is out of focus
45
+ float w = smoothstep(0.35, 0.65, progress);
46
+ float r = radius * k;
47
+ // the highlights weigh more as they swell, so they read as bright discs
48
+ float boost = 12.0 * intensity * k;
49
+
50
+ // fewer than 3 blades: a round aperture
51
+ float n = blades >= 3 ? float(blades) : 0.0;
52
+ float sector = n > 0.0 ? 2.0 * PI / n : 1.0;
53
+ float apothem = cos(0.5 * sector);
54
+
55
+ // per-pixel stratification of the taps over the disc, so its edge stays crisp
56
+ vec2 cell = floor(uv * vec2(ratio, 1.0) * 997.0);
57
+ float spin = 2.0 * PI * hash12(cell);
58
+ float jitter = hash12(cell + 17.0);
59
+
60
+ // each image is only read while it shows
61
+ bool useFrom = w < 1.0;
62
+ bool useTo = w > 0.0;
63
+ // premultiplied, weighted sums of each image, and the light of their highlights,
64
+ // starting with the pixel itself
65
+ vec4 s0 = vec4(0.0);
66
+ vec4 s1 = vec4(0.0);
67
+ float t0 = 0.0;
68
+ float t1 = 0.0;
69
+ vec3 l0 = vec3(0.0);
70
+ vec3 l1 = vec3(0.0);
71
+ if (useFrom) {
72
+ vec4 c = getFromColor(uv);
73
+ float h = highlight(c, threshold);
74
+ float wt = 1.0 + boost * h;
75
+ s0 = wt * vec4(c.rgb * c.a, c.a);
76
+ t0 = wt;
77
+ l0 = h * c.rgb;
78
+ }
79
+ if (useTo) {
80
+ vec4 c = getToColor(uv);
81
+ float h = highlight(c, threshold);
82
+ float wt = 1.0 + boost * h;
83
+ s1 = wt * vec4(c.rgb * c.a, c.a);
84
+ t1 = wt;
85
+ l1 = h * c.rgb;
86
+ }
87
+ for (int i = 0; i < TAPS; i++) {
88
+ float fi = float(i);
89
+ float a = fi * 2.39996323 + spin;
90
+ float d = sqrt((fi + jitter) / float(TAPS));
91
+ if (n > 0.0) {
92
+ // the aperture's polygon: its boundary in the direction of the tap
93
+ float s = mod(a, sector) - 0.5 * sector;
94
+ d *= apothem / cos(s);
95
+ }
96
+ vec2 st = mirror(uv + r * d * vec2(cos(a) / ratio, sin(a)));
97
+ if (useFrom) {
98
+ vec4 c = getFromColor(st);
99
+ float h = highlight(c, threshold);
100
+ float wt = 1.0 + boost * h;
101
+ s0 += wt * vec4(c.rgb * c.a, c.a);
102
+ t0 += wt;
103
+ l0 += h * c.rgb;
104
+ }
105
+ if (useTo) {
106
+ vec4 c = getToColor(st);
107
+ float h = highlight(c, threshold);
108
+ float wt = 1.0 + boost * h;
109
+ s1 += wt * vec4(c.rgb * c.a, c.a);
110
+ t1 += wt;
111
+ l1 += h * c.rgb;
112
+ }
113
+ }
114
+ vec4 b = mix(useFrom ? s0 / t0 : vec4(0.0), useTo ? s1 / t1 : vec4(0.0), w);
115
+ if (b.a <= 0.0) {
116
+ return vec4(0.0);
117
+ }
118
+ vec3 rgb = b.rgb / b.a;
119
+ // the discs glow: light lifts the color, never the alpha
120
+ vec3 light = mix(l0, l1, w) * (intensity * k * 4.0 / float(TAPS + 1));
121
+ rgb = 1.0 - (1.0 - clamp(rgb, 0.0, 1.0)) * exp(-light);
122
+ return vec4(rgb, b.a);
123
+ }
@@ -0,0 +1,100 @@
1
+ // BrushWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BrushWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: A few broad brush strokes sweep across the frame in turn, back and forth, painting in the incoming image with streaky bristle edges and dry, ragged ends
5
+ // Tags: wipe, paint, brush, organic
6
+
7
+ // @range(1, 8, 1) Number of brush strokes needed to cover the frame
8
+ uniform float strokes; // = 4.0
9
+ // @range(-45, 45) Angle of the strokes, in degrees
10
+ uniform float angle; // = -7.0
11
+ // @range(0, 1) How rough the bristles make the edges and ends of the strokes
12
+ uniform float roughness; // = 0.6
13
+ // @range(0, 1) How much the strokes wave along their way
14
+ uniform float waviness; // = 0.5
15
+
16
+ const float PI = 3.141592653589793;
17
+
18
+ float hash (vec2 p) {
19
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
20
+ p3 += dot(p3, p3.yzx + 33.33);
21
+ return fract((p3.x + p3.y) * p3.z);
22
+ }
23
+
24
+ // value noise, smooth along both axes
25
+ float vnoise (vec2 p) {
26
+ vec2 i = floor(p);
27
+ vec2 f = fract(p);
28
+ f = f * f * (3.0 - 2.0 * f);
29
+ return mix(
30
+ mix(hash(i), hash(i + vec2(1.0, 0.0)), f.x),
31
+ mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), f.x),
32
+ f.y
33
+ );
34
+ }
35
+
36
+ // bristle streaks: fine across the stroke (t), long along it (u)
37
+ float bristles (float t, float u, float seed) {
38
+ return 0.6 * vnoise(vec2(t * 26.0 + seed, u * 1.3 + seed)) + 0.4 * vnoise(vec2(t * 8.0 - seed, u * 0.7));
39
+ }
40
+
41
+ // one stroke: k its index, t the position across it (-1..1 is its core), u along it
42
+ // returns (coverage, wet streak shading)
43
+ vec2 stroke (float k, float t, float u, float U, float n, float h) {
44
+ float dir = mod(k, 2.0) < 0.5 ? 1.0 : -1.0;
45
+ float x = u * dir;
46
+ float dur = min(1.0, 1.8 / (n + 0.8));
47
+ float start = n > 1.0 ? k * (1.0 - dur) / (n - 1.0) : 0.0;
48
+ float s = clamp((progress - start) / dur, 0.0, 1.0);
49
+ s = mix(s, s * s * (3.0 - 2.0 * s), 0.7);
50
+ float r = roughness;
51
+ float lag = (0.15 + 0.6 * r) * h; // how far the longest bristles run ahead of the shortest
52
+ float dry = (0.1 + 0.9 * r) * h; // length of the streaky, dry trail behind the head of the stroke
53
+ // at the end even the shortest bristles, at the rounded corners, are past the far edge with their dry trail
54
+ float head = mix(-U, U + lag + 0.3 * h + 1.15 * dry + 0.01, s);
55
+ float b = bristles(t, k * 3.7, k * 17.0);
56
+ float front = head - lag * (1.0 - b) - 0.3 * h * t * t; // a rounded, ragged head
57
+ float streak = bristles(t * 1.7, x * 2.0 / h, k * 5.0 + 9.0);
58
+ float along = clamp(((front - x) / (dry + 0.001) - 0.1 - 0.8 * streak) * 6.0, 0.0, 1.0);
59
+ float fringe = 0.1 + 0.7 * r;
60
+ float e = (abs(t) - 1.0) / fringe; // < 0 in the core of the stroke
61
+ float reach = 0.5 + 0.5 * vnoise(vec2(x * 2.5 / h, k * 7.0 + (t > 0.0 ? 3.0 : 0.0))); // the edge wanders
62
+ float hair = clamp(bristles(t * 1.4, x * 3.0 / h, k * 11.0 + 3.0) * 2.0 - 0.5, 0.0, 1.0);
63
+ float side = clamp((reach * hair - e) * 12.0 + 1.0, 0.0, 1.0);
64
+ float cover = along * side;
65
+ float wet = (1.0 - clamp((progress - start - dur) / 0.25, 0.0, 1.0)) * min(1.0, (1.0 - progress) * 6.0);
66
+ return vec2(cover, cover * wet * (bristles(t * 2.0, x * 2.0 / h, k) - 0.5));
67
+ }
68
+
69
+ vec4 transition (vec2 uv) {
70
+ float a = angle * PI / 180.0;
71
+ float c = cos(a);
72
+ float sn = sin(a);
73
+ vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
74
+ float u = c * q.x + sn * q.y; // along the strokes
75
+ float v = -sn * q.x + c * q.y; // across them
76
+ float U = 0.5 * (abs(c) * ratio + abs(sn));
77
+ float V = 0.5 * (abs(sn) * ratio + abs(c));
78
+ float n = max(1.0, floor(strokes + 0.5));
79
+ float h = 2.0 * V / n; // height of a stroke
80
+ // waves shared by the neighbouring strokes so that they always tile the frame
81
+ float A = 0.12 * waviness * h;
82
+ float w = v + A * sin(u * 5.0 / U + v * 2.0 / h + 1.3) + 0.5 * A * sin(u * 11.0 / U - v * 3.0 / h);
83
+ float y = (V + 1.5 * A - w) / (2.0 * V + 3.0 * A) * n; // strokes go from top to bottom
84
+ float hh = (2.0 * V + 3.0 * A) / n;
85
+ float k = clamp(floor(y), 0.0, n - 1.0);
86
+ float cover = 0.0;
87
+ float shade = 0.0;
88
+ for (int i = -1; i <= 1; i++) {
89
+ float j = k + float(i);
90
+ if (j >= 0.0 && j <= n - 1.0) {
91
+ vec2 s = stroke(j, (y - j - 0.5) * 2.0, u, U, n, hh);
92
+ cover = max(cover, s.x);
93
+ shade = mix(shade, s.y, s.x); // the latest stroke is on top
94
+ }
95
+ }
96
+ vec4 from = getFromColor(uv);
97
+ vec4 to = getToColor(uv);
98
+ to.rgb = min(to.rgb * (1.0 + 0.2 * shade), 1.0);
99
+ return mix(from, to, cover);
100
+ }