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
@@ -0,0 +1,192 @@
1
+ // Drape — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Drape.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image hangs like a sheet of fabric that is let go at the top: it collapses into soft, uneven folds that hide one another as the cloth bunches up and slides down out of the frame, revealing the incoming image behind it
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform float folds;
16
+
17
+ uniform float depth;
18
+
19
+ uniform float sway;
20
+
21
+ uniform float shadow;
22
+
23
+ const float PI = 3.141592653589793;
24
+ const int STEPS = 24;
25
+ const float DEPTH = 0.8;
26
+
27
+ vec2 mirror(vec2 v) {
28
+ return 1.0 - abs(1.0 - mod(v, 2.0));
29
+ }
30
+
31
+ float hash11(float p) {
32
+ p = fract(p * 0.1031);
33
+ p *= p + 33.33;
34
+ p *= p + p;
35
+ return fract(p);
36
+ }
37
+
38
+ float noise1(float x) {
39
+ float i = floor(x);
40
+ float f = x - i;
41
+ return mix(hash11(i), hash11(i + 1.0), f * f * (3.0 - 2.0 * f));
42
+ }
43
+
44
+ float topEdge(float x, vec4 m) {
45
+ float c = 2.0 * x - 1.0;
46
+ return m.y - 0.08 * m.x * (1.0 - c * c);
47
+ }
48
+
49
+ float sidePull(float sy, float gT) {
50
+ return 0.035 * gT * (0.3 + 0.7 * clamp(sy, 0.0, 1.0));
51
+ }
52
+
53
+ vec4 cloth(vec2 p, vec4 m, float foldN) {
54
+ float gT = m.x;
55
+ float botY = m.z;
56
+ float x = p.x - m.w;
57
+ float top = topEdge(x, m);
58
+ float sy = (p.y - botY) / max(top - botY, 1e-4);
59
+ float pull = sidePull(sy, gT);
60
+ float xc = (x - pull) / (1.0 - 2.0 * pull);
61
+
62
+ float wander = (noise1(0.5 * foldN * xc + 2.5 * sy + 5.3) - 0.5) * 2.4 * (1.0 - sy);
63
+ float ph = 2.0 * PI * (foldN * xc + 0.6 * noise1(0.7 * foldN * xc + 1.7)) + wander;
64
+ float d = 0.15 + 0.85 * noise1(1.1 * foldN * xc + 1.4 * sy + 7.0);
65
+
66
+ float amp = DEPTH * depth * gT * (0.3 + 0.7 * sy * sqrt(max(sy, 0.0))) / max(foldN, 2.0);
67
+
68
+ float w = 0.6 / foldN;
69
+ amp *= smoothstep(0.0, w, xc) * smoothstep(0.0, w, 1.0 - xc);
70
+ float prof = 0.5 - 0.5 * cos(ph);
71
+
72
+ float dt = (1.0 - sy) * (top - botY);
73
+ float crease = exp(-30.0 * dt) * (0.5 + 0.5 * sin(80.0 * dt + 0.7 * ph));
74
+ bool on = sy >= 0.0 && sy <= 1.0 && xc >= 0.0 && xc <= 1.0;
75
+ return on ? vec4(amp * (d * prof + 0.15 * crease), xc, sy, ph) : vec4(-1.0);
76
+ }
77
+
78
+ vec4 transition (vec2 uv) {
79
+ float t = progress;
80
+
81
+ float topY = 1.0 - 1.06 * t * (0.35 + 0.65 * t);
82
+ float botY = -0.75 * t * t * t;
83
+
84
+ float f = 1.0 - (1.0 - t) * (1.0 - t) * (1.0 - t);
85
+ float foldN = max(1.0, floor(folds * min(ratio, 1.0) + 0.5));
86
+ float shiftX = sway * 0.035 * sin(2.0 * PI * t) * f;
87
+
88
+ vec2 view = vec2(0.75 + 0.5 * sway * sin(PI * t) * f, -0.35);
89
+ float zMax = 1.15 * DEPTH * depth * f / max(foldN, 2.0);
90
+ vec4 m = vec4(f, topY, botY, shiftX);
91
+
92
+ float zA = zMax;
93
+ float zB = 0.0;
94
+ bool found = false;
95
+ float dA = 0.0;
96
+ float dB = 0.0;
97
+ bool onA = false;
98
+ for (int i = 0; i < STEPS; i++) {
99
+ if (!found) {
100
+ float z = max(zMax * (1.0 - float(i) / float(STEPS - 1)), 0.0);
101
+ vec4 s = cloth(uv - view * z, m, foldN);
102
+ float dz = s.x - z;
103
+ if (s.x >= 0.0 && dz >= 0.0) {
104
+ found = true;
105
+ zB = z;
106
+ dB = dz;
107
+ } else {
108
+ zA = z;
109
+ dA = dz;
110
+ onA = s.x >= 0.0;
111
+ }
112
+ }
113
+ }
114
+ float zHit = zB;
115
+ if (found && zA > zB) {
116
+ if (onA) {
117
+
118
+ zHit = mix(zA, zB, dA / (dA - dB));
119
+ } else {
120
+
121
+
122
+ float za = zA;
123
+ for (int j = 0; j < 5; j++) {
124
+ float zm = 0.5 * (za + zHit);
125
+ if (cloth(uv - view * zm, m, foldN).x >= zm) zHit = zm;
126
+ else za = zm;
127
+ }
128
+ }
129
+ }
130
+ vec2 hp = uv - view * zHit;
131
+ vec4 hit = found ? cloth(hp, m, foldN) : vec4(-1.0);
132
+ if (found && hit.x < 0.0) {
133
+ zHit = zB;
134
+ hp = uv - view * zB;
135
+ hit = cloth(hp, m, foldN);
136
+ }
137
+ vec4 col = vec4(0.0);
138
+ float cover = 0.0;
139
+ if (hit.x >= 0.0) {
140
+ float xc = hit.y;
141
+ float sy = hit.z;
142
+ float ph = hit.w;
143
+
144
+ float slope = PI * zMax * foldN;
145
+
146
+ float mu = min(0.25 * slope * slope / (1.0 + 0.25 * slope * slope), 0.5);
147
+ float u = xc - mu * sin(2.0 * ph) / (4.0 * PI * foldN);
148
+
149
+ float h = max(topY - botY, 1e-4);
150
+ float comp = max(1.0 - h, 0.0);
151
+ float v = sy * (1.0 - comp) + comp * sy * sy * sy;
152
+ vec4 tex = getFromColor(mirror(vec2(u, v)));
153
+ float span = topEdge(hp.x - shiftX, m) - botY;
154
+
155
+ float e = 0.002;
156
+ float hx = cloth(hp + vec2(e, 0.0), m, foldN).x;
157
+ float hy = cloth(hp + vec2(0.0, e), m, foldN).x;
158
+ float hx0 = hx >= 0.0 ? hx : hit.x;
159
+ float hy0 = hy >= 0.0 ? hy : hit.x;
160
+ vec3 nrm = normalize(vec3(-(hx0 - hit.x) / e, -(hy0 - hit.x) / e, 1.0));
161
+ vec3 light = normalize(vec3(-0.45, 0.35, 1.0));
162
+ float diffuse = mix(1.0, max(dot(nrm, light), 0.0) / light.z, min(1.0, 3.0 * f));
163
+
164
+ float valley = 1.0 - (0.5 - 0.5 * cos(ph));
165
+ float ao = 1.0 - 0.6 * depth * f * valley * valley * (0.35 + 0.65 * sy);
166
+
167
+ float rim = exp(-(1.0 - sy) * span * 70.0) * 0.35 * f;
168
+
169
+ float under = max(hit.x - zHit, 0.0);
170
+ float back = min(1.0, under / max(0.1 * zMax, 1e-6));
171
+ tex.rgb *= diffuse * ao * (1.0 - rim) * (1.0 - 0.6 * back);
172
+ col = tex;
173
+
174
+ float aa = 0.003 * f;
175
+ float inside = min((1.0 - sy) * span - view.y * under, min(xc, 1.0 - xc));
176
+ cover = aa > 0.0 ? clamp(inside / aa, 0.0, 1.0) : 1.0;
177
+ if (cover >= 1.0) return col;
178
+ }
179
+
180
+ vec4 to = getToColor(uv);
181
+ float x = uv.x - shiftX;
182
+ float pull = sidePull((uv.y - botY) / max(topEdge(x, m) - botY, 1e-4), f);
183
+ float outside = max(uv.y - topEdge(x, m), max(-x, x - 1.0) - pull);
184
+ float sh = shadow * exp(-max(outside, 0.0) * 16.0) * f * clamp(8.0 * (1.0 - t), 0.0, 1.0);
185
+ return mix(vec4(to.rgb * (1.0 - 0.8 * sh), to.a), col, cover);
186
+ }
187
+
188
+ half4 main(float2 _coord) {
189
+ vec2 _uv = _coord / _resolution;
190
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
191
+ return half4(_c.rgb * _c.a, _c.a);
192
+ }
@@ -0,0 +1,71 @@
1
+ // DuotoneFade — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/DuotoneFade.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image is printed in two inks, shadows first, as a bold high-contrast duotone; the incoming image is printed over it in the same two inks, its dark tones landing before its highlights, then its own colors come back, highlights first
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform vec4 shadowInk;
16
+
17
+ uniform vec4 highlightInk;
18
+
19
+ uniform float contrast;
20
+
21
+ uniform float grain;
22
+
23
+ float dfHash(vec2 v) {
24
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
25
+ v3 += dot(v3, v3.yzx + 33.33);
26
+ return fract((v3.x + v3.y) * v3.z);
27
+ }
28
+
29
+ float dfLuma(vec4 c) {
30
+ return clamp(dot(c.rgb, vec3(0.299, 0.587, 0.114)), 0.0, 1.0);
31
+ }
32
+
33
+ vec4 transition(vec2 uv) {
34
+ vec4 a = getFromColor(uv);
35
+ vec4 b = getToColor(uv);
36
+ float la = dfLuma(a);
37
+ float lb = dfLuma(b);
38
+
39
+ vec2 q = uv * 360.0 * vec2(max(ratio, 1.0), max(1.0 / ratio, 1.0));
40
+ float g = dfHash(floor(q)) - 0.5;
41
+
42
+
43
+ float inks = smoothstep(0.0, 0.35, progress);
44
+ float lift = smoothstep(0.65, 1.0, progress);
45
+ float amount = min(
46
+ clamp(inks * 1.35 - 0.35 * la, 0.0, 1.0),
47
+ clamp((1.0 - lift) * 1.35 - 0.35 * lb, 0.0, 1.0)
48
+ );
49
+ amount = amount * amount * (3.0 - 2.0 * amount);
50
+
51
+
52
+ float x = smoothstep(0.25, 0.75, progress) * 1.6 - 0.3;
53
+ float t = lb + 0.2 * grain * g;
54
+ float s = smoothstep(t - 0.15, t + 0.15, x);
55
+
56
+
57
+ float c = 0.4 * contrast;
58
+ float tone = smoothstep(c + 0.03, 1.03 - c, mix(la, lb, s) + 0.08 * grain * g);
59
+ vec4 ink = mix(shadowInk, highlightInk, tone);
60
+
61
+
62
+ vec4 base = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), s);
63
+ if (base.a <= 0.0) return vec4(0.0);
64
+ return vec4(mix(base.rgb / base.a, ink.rgb, amount * ink.a), base.a);
65
+ }
66
+
67
+ half4 main(float2 _coord) {
68
+ vec2 _uv = _coord / _resolution;
69
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
70
+ return half4(_c.rgb * _c.a, _c.a);
71
+ }
@@ -0,0 +1,148 @@
1
+ // FacetedGlass — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/FacetedGlass.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The frame is seen through a pane of irregular cut-glass facets, each one showing its own shifted, zoomed and tilted view of the image, with bright beveled edges and thin dark seams; the facets turn to the incoming image one by one, then the glass flattens out and clears
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform float facets;
16
+
17
+ uniform float refraction;
18
+
19
+ uniform float bevel;
20
+
21
+ uniform vec4 highlight;
22
+
23
+ uniform float seed;
24
+
25
+ const float AA = 0.0015;
26
+
27
+ vec2 hash22(vec2 p) {
28
+ vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
29
+ p3 += dot(p3, p3.yzx + 33.33);
30
+ return fract((p3.xx + p3.yz) * p3.zy);
31
+ }
32
+
33
+ vec2 mirror(vec2 v) {
34
+ return 1.0 - abs(1.0 - mod(v, 2.0));
35
+ }
36
+
37
+ vec4 transition(vec2 uv) {
38
+ if (progress <= 0.0) return getFromColor(uv);
39
+ if (progress >= 1.0) return getToColor(uv);
40
+
41
+
42
+ float h = 1.0 - abs(2.0 * progress - 1.0);
43
+ float amount = h * h * (3.0 - 2.0 * h);
44
+
45
+ float n = max(facets, 1.0);
46
+ vec2 aspect = vec2(ratio, 1.0);
47
+
48
+ vec2 p = uv * aspect * n;
49
+ vec2 i = floor(p);
50
+ vec2 f = p - i;
51
+ vec2 offset = vec2(17.31, 41.97) * seed;
52
+
53
+ float bw = 0.18 * amount;
54
+
55
+
56
+ vec2 mg = vec2(0.0);
57
+ vec2 mr = vec2(0.0);
58
+ float md = 8.0;
59
+ for (int y = -1; y <= 1; y++) {
60
+ for (int x = -1; x <= 1; x++) {
61
+ vec2 g = vec2(float(x), float(y));
62
+ vec2 r = g + 0.1 + 0.8 * hash22(i + g + offset) - f;
63
+ float d = dot(r, r);
64
+ if (d < md) {
65
+ md = d;
66
+ mr = r;
67
+ mg = g;
68
+ }
69
+ }
70
+ }
71
+
72
+
73
+
74
+ float edge = 8.0;
75
+ vec2 normal = vec2(0.0);
76
+ for (int y = -2; y <= 2; y++) {
77
+ for (int x = -2; x <= 2; x++) {
78
+ vec2 g = mg + vec2(float(x), float(y));
79
+ vec2 r = g + 0.1 + 0.8 * hash22(i + g + offset) - f;
80
+ vec2 dr = r - mr;
81
+ if (dot(dr, dr) > 0.00001) {
82
+ vec2 dn = normalize(dr);
83
+ float e = dot(0.5 * (mr + r), dn);
84
+ edge = min(edge, e);
85
+ float w = max(1.0 - e / bw, 0.0);
86
+ normal += dn * w * w;
87
+ }
88
+ }
89
+ }
90
+ float nl = length(normal);
91
+ normal = nl > 0.0 ? normal / nl : vec2(0.0);
92
+
93
+
94
+ vec2 id = i + mg + offset;
95
+ vec2 h1 = hash22(id + 31.7);
96
+ vec2 h2 = hash22(id + 59.3);
97
+ vec2 h3 = hash22(id + 97.1);
98
+ float angle = 6.2831853 * h1.x;
99
+ vec2 dir = vec2(cos(angle), sin(angle));
100
+ vec2 shift = dir * (0.4 + 0.6 * h1.y) * refraction;
101
+ float zoom = (h2.x - 0.5) * 6.0 * refraction;
102
+ float tilt = (h2.y - 0.5) * 2.0 * refraction;
103
+
104
+
105
+ vec2 q = -mr / n;
106
+ vec2 view = -q * zoom + vec2(-q.y, q.x) * sin(tilt) + q * (cos(tilt) - 1.0);
107
+
108
+
109
+ float bv = 1.0 - smoothstep(0.0, bw, edge);
110
+ bv *= bv;
111
+
112
+ vec2 bend = normal * bv * 0.4 * refraction;
113
+
114
+
115
+ float start = 0.15 + 0.5 * h3.x;
116
+ float m = smoothstep(start, start + 0.2, progress);
117
+ vec2 d = amount * (view + bend);
118
+ vec2 s = amount * shift;
119
+ vec4 ca = getFromColor(mirror(uv + (s + d) / aspect));
120
+ vec4 cb = getToColor(mirror(uv + (d - s) / aspect));
121
+
122
+ vec4 c = mix(vec4(ca.rgb * ca.a, ca.a), vec4(cb.rgb * cb.a, cb.a), m);
123
+
124
+
125
+ vec2 light = normalize(vec2(-0.6, 0.8));
126
+ vec2 slope = dir * (0.4 + 0.6 * h1.y);
127
+ float facetLight = 0.12 * amount * dot(slope, light);
128
+
129
+ float lit = dot(normal, light);
130
+ float k = clamp(bevel, 0.0, 1.0);
131
+ float glow = k * bv * max(lit, 0.0) * 1.1 * amount;
132
+ float shade = k * bv * max(-lit, 0.0) * 0.6 * amount;
133
+
134
+ float turn = sin(3.14159265 * m);
135
+ glow += k * 0.15 * amount * turn * turn;
136
+
137
+ float seam = 0.6 * amount * (1.0 - smoothstep(0.0, 2.0 * AA, edge / n - 0.5 * AA));
138
+
139
+ c.rgb *= (1.0 + facetLight) * (1.0 - shade) * (1.0 - seam);
140
+ c.rgb += highlight.rgb * highlight.a * glow * c.a;
141
+ return c.a > 0.0 ? vec4(clamp(c.rgb / c.a, 0.0, 1.0), c.a) : vec4(0.0);
142
+ }
143
+
144
+ half4 main(float2 _coord) {
145
+ vec2 _uv = _coord / _resolution;
146
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
147
+ return half4(_c.rgb * _c.a, _c.a);
148
+ }
@@ -0,0 +1,183 @@
1
+ // FrostWipe — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/FrostWipe.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: Ice crystals grow in from the edges of the frame with feathery, branching fronts, frosting the outgoing image white and blurry until it is covered, then thaw back out to the edges on the incoming image
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform float spread;
16
+
17
+ uniform float scale;
18
+
19
+ uniform float blur;
20
+
21
+ uniform vec4 color;
22
+
23
+ const int TAPS = 12;
24
+
25
+ float hash12(vec2 v) {
26
+ vec3 v3 = fract(vec3(v.xyx) * 0.1031);
27
+ v3 += dot(v3, v3.yzx + 33.33);
28
+ return fract((v3.x + v3.y) * v3.z);
29
+ }
30
+
31
+ float vnoise(vec2 v) {
32
+ vec2 i = floor(v);
33
+ vec2 f = fract(v);
34
+ f = f * f * (3.0 - 2.0 * f);
35
+ return mix(
36
+ mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
37
+ mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
38
+ f.y
39
+ );
40
+ }
41
+
42
+ float ridged(vec2 v) {
43
+ float sum = 0.0;
44
+ float amp = 0.5;
45
+ for (int i = 0; i < 4; i++) {
46
+ float n = 1.0 - abs(2.0 * vnoise(v) - 1.0);
47
+ sum += amp * n * n;
48
+ v = mat2(1.6, 1.2, -1.2, 1.6) * v + 4.7;
49
+ amp *= 0.5;
50
+ }
51
+ return sum / 0.9375;
52
+ }
53
+
54
+ vec4 grains(vec2 v) {
55
+ vec2 i = floor(v);
56
+ vec2 f = fract(v);
57
+ float d1 = 8.0;
58
+ float d2 = 8.0;
59
+ vec3 seed = vec3(0.0);
60
+ for (int y = -1; y <= 1; y++) {
61
+ for (int x = -1; x <= 1; x++) {
62
+ vec2 c = vec2(float(x), float(y));
63
+ vec2 o = c + vec2(hash12(i + c), hash12(i + c + 17.3)) - f;
64
+ float d = dot(o, o);
65
+ if (d < d1) {
66
+ d2 = d1;
67
+ d1 = d;
68
+ seed = vec3(hash12(i + c + 41.9), -o);
69
+ } else if (d < d2) {
70
+ d2 = d;
71
+ }
72
+ }
73
+ }
74
+ return vec4(sqrt(d2) - sqrt(d1), seed);
75
+ }
76
+
77
+ vec2 mirror(vec2 v) {
78
+ return 1.0 - abs(1.0 - mod(v, 2.0));
79
+ }
80
+
81
+ vec4 image(vec2 uv, float m) {
82
+ if (m <= 0.0) return getFromColor(uv);
83
+ if (m >= 1.0) return getToColor(uv);
84
+ return mix(getFromColor(uv), getToColor(uv), m);
85
+ }
86
+
87
+ vec4 transition(vec2 uv) {
88
+ float p = progress;
89
+
90
+ float h = 1.0 - abs(2.0 * p - 1.0);
91
+ float a = clamp(h / 0.85, 0.0, 1.0);
92
+ a = a * (1.6 - 0.6 * a);
93
+ float m = smoothstep(0.47, 0.53, p);
94
+ if (a <= 0.0) return image(uv, m);
95
+
96
+
97
+ vec2 q = uv * vec2(ratio, 1.0);
98
+ vec2 dEdge = min(uv, 1.0 - uv) * vec2(ratio, 1.0);
99
+ float depth = min(dEdge.x, dEdge.y) / (0.5 * min(ratio, 1.0));
100
+ depth = 1.0 - (1.0 - depth) * (1.0 - depth);
101
+
102
+
103
+
104
+ float reach = 0.2 + 0.6 * clamp(spread, 0.0, 1.0);
105
+ float front = mix(-0.1, 1.0 + reach + 0.2, a);
106
+ if (depth > front + 0.08) return image(uv, m);
107
+
108
+
109
+
110
+ vec2 gv = q * scale;
111
+
112
+ vec4 gr = grains(gv + 0.35 * vec2(vnoise(gv * 1.7), vnoise(gv * 1.7 + 23.1)));
113
+
114
+ float u = 2.0 * gr.y - 1.0;
115
+ vec2 dir = vec2(1.0 - u * u, 2.0 * u) / (1.0 + u * u);
116
+ float t = dot(gr.zw, dir) * 7.0;
117
+ float needle = 1.0 - abs(2.0 * fract(t) - 1.0);
118
+ float nh = fract(gr.y + 0.618034 * floor(t));
119
+ float len = mix(0.15, 0.6, nh);
120
+ float r = ridged(gv * 1.3);
121
+ float rf = ridged(gv * 4.0 + 11.0);
122
+
123
+
124
+ float grow = min(gr.x * 3.5, gr.x / len * 0.5 + (1.0 - needle) * 1.2 + 0.2 * fract(nh * 13.7));
125
+ float field = depth + reach * (0.8 * min(grow, 1.0) + 0.2 * (1.0 - r)) + 0.1 * (1.0 - rf);
126
+ float inside = front - field;
127
+ float f = smoothstep(0.0, 0.03, inside);
128
+
129
+ float haze = 0.4 * smoothstep(0.9, 1.0, rf) * smoothstep(-0.08, 0.0, inside);
130
+ float frost = max(f, haze);
131
+ if (frost <= 0.0) return image(uv, m);
132
+
133
+
134
+ float thick = smoothstep(0.0, 0.5, inside);
135
+ float full = smoothstep(0.75, 0.95, h);
136
+
137
+
138
+ float radius = (0.004 + 0.03 * blur) * frost * (0.5 + 0.5 * thick);
139
+ float rot = 6.2831853 * hash12(floor(q * 90.0));
140
+ vec3 rgb = vec3(0.0);
141
+ float alpha = 0.0;
142
+ for (int i = 0; i < TAPS; i++) {
143
+ float k = (float(i) + 0.5) / float(TAPS);
144
+ float th = rot + float(i) * 2.3999632;
145
+ vec2 off = sqrt(k) * vec2(cos(th), sin(th)) * radius;
146
+ vec4 c = image(mirror(uv + off / vec2(ratio, 1.0)), m);
147
+ rgb += c.rgb * c.a;
148
+ alpha += c.a;
149
+ }
150
+ alpha /= float(TAPS);
151
+ rgb = alpha > 0.0 ? rgb / (alpha * float(TAPS)) : vec3(0.0);
152
+
153
+
154
+
155
+ float stem = 1.0 - smoothstep(0.0, 0.03, gr.x);
156
+ float needles = smoothstep(0.7, 1.0, needle) * (1.0 - smoothstep(0.0, len, gr.x));
157
+ float glint = 0.4 + 0.6 * rf;
158
+ float veins = clamp(glint * max(0.35 * stem, 0.55 * needles) + 0.3 * smoothstep(0.6, 0.95, r), 0.0, 1.0);
159
+ float rim = smoothstep(0.0, 0.02, inside) * (1.0 - smoothstep(0.02, 0.07, inside));
160
+ vec3 ice = clamp(color.rgb * (0.82 + 0.25 * veins), 0.0, 1.0);
161
+ float cover = frost * (0.35 + 0.3 * thick + 0.25 * veins);
162
+ cover = clamp(mix(cover, frost, full), 0.0, 1.0);
163
+ vec4 under = vec4(rgb * mix(vec3(1.0), color.rgb, 0.5 * frost), alpha);
164
+
165
+ vec4 res = mix(under, vec4(ice, color.a), cover);
166
+
167
+
168
+ vec2 sq = q * 36.0;
169
+ vec2 cell = floor(sq);
170
+ vec2 d = abs(sq - cell - 0.25 - 0.5 * vec2(hash12(cell + 1.3), hash12(cell + 5.9)));
171
+ float star = max(0.0, 1.0 - 9.0 * length(d)) + max(0.0, 1.0 - 4.0 * (d.x + d.y) - 30.0 * min(d.x, d.y));
172
+ float tw = 0.5 + 0.5 * sin(6.2831853 * (hash12(cell + 9.1) + 2.0 * p));
173
+ float sparkle = step(0.82, hash12(cell + 3.7)) * min(star, 1.0) * tw * f * (0.4 + 0.6 * veins);
174
+ float light = clamp(0.4 * rim + 0.8 * sparkle, 0.0, 1.0);
175
+ res = mix(res, vec4(mix(color.rgb, vec3(1.0), 0.6), color.a), light);
176
+ return clamp(res, 0.0, 1.0);
177
+ }
178
+
179
+ half4 main(float2 _coord) {
180
+ vec2 _uv = _coord / _resolution;
181
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
182
+ return half4(_c.rgb * _c.a, _c.a);
183
+ }
@@ -0,0 +1,83 @@
1
+ // Funnel — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Funnel.glsl
2
+ // Author: gre
3
+ // License: MIT
4
+ // Description: The outgoing image narrows into a curved funnel toward a point on the bottom edge and slides into it, its sides bending like a window minimized into a dock, revealing the incoming image behind it
5
+
6
+ uniform shader _from;
7
+ uniform shader _to;
8
+ uniform float2 _resolution;
9
+ uniform float progress;
10
+ uniform float ratio;
11
+
12
+ vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
13
+ vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
14
+
15
+ uniform float target;
16
+
17
+ uniform float curvature;
18
+
19
+ uniform float shadow;
20
+
21
+ const float NECK = 0.04;
22
+
23
+ const float OVERSHOOT = 0.03;
24
+
25
+ const float EDGE = 0.0015;
26
+
27
+ const float SOFT = 0.06;
28
+
29
+ vec4 transition(vec2 uv) {
30
+ float t = progress;
31
+
32
+ float f = smoothstep(0.0, 1.0, 1.0 - (1.0 - t) * (1.0 - t) * (1.0 - t));
33
+ float slide = (1.0 + OVERSHOOT) * t * t * (1.5 - 0.5 * t);
34
+
35
+ float r = max(ratio, 1e-4);
36
+ float nh = 0.5 * NECK / r;
37
+
38
+ float tx = clamp(target, nh, 1.0 - nh);
39
+ float c = clamp(curvature, 0.0, 1.0);
40
+
41
+
42
+ float q = clamp(uv.y, 0.0, 1.0);
43
+ float w = mix(q, q * q * (3.0 - 2.0 * q), c);
44
+ float dw = mix(1.0, 6.0 * q * (1.0 - q), c);
45
+ float L = f * mix(tx - nh, 0.0, w);
46
+ float R = 1.0 - f * (1.0 - mix(tx + nh, 1.0, w));
47
+ float dL = -f * (tx - nh) * dw;
48
+ float dR = f * (1.0 - tx - nh) * dw;
49
+ float v = uv.y + slide;
50
+
51
+
52
+ float e = EDGE * min(1.0, 10.0 * t) + 1e-6;
53
+ float left = L > 0.0 ? (uv.x - L) * r / sqrt(1.0 + dL * dL * r * r) : 1.0;
54
+ float right = R < 1.0 ? (R - uv.x) * r / sqrt(1.0 + dR * dR * r * r) : 1.0;
55
+ float cov = clamp(min(min(left, right), 1.0 - v) / e + 0.5, 0.0, 1.0);
56
+
57
+ vec4 img = vec4(0.0);
58
+ float s = clamp(shadow, 0.0, 1.0);
59
+ if (cov > 0.0) {
60
+ float width = R - L;
61
+ vec2 src = clamp(vec2((uv.x - L) / width, v), 0.0, 1.0);
62
+ img = getFromColor(src);
63
+
64
+ float across = 2.0 * src.x - 1.0;
65
+ img.rgb *= 1.0 - s * (1.0 - width) * (0.5 * across * across + 0.3 * (1.0 - w));
66
+ if (cov >= 1.0) return img;
67
+ }
68
+
69
+ vec4 bg = getToColor(uv);
70
+
71
+ float ox = max(L - uv.x, uv.x - R) * r;
72
+ float oy = uv.y - (1.0 - slide);
73
+ float dist = length(max(vec2(ox, oy), 0.0));
74
+ bg.rgb *= 1.0 - s * 0.6 * f * (1.0 - t) * (1.0 - smoothstep(0.0, SOFT, dist));
75
+
76
+ return mix(bg, img, cov);
77
+ }
78
+
79
+ half4 main(float2 _coord) {
80
+ vec2 _uv = _coord / _resolution;
81
+ vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
82
+ return half4(_c.rgb * _c.a, _c.a);
83
+ }