gl-transitions 2.5.0 → 3.1.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.
- package/CHANGELOG.md +97 -0
- package/README.md +16 -1
- package/compatibility.json +383 -149
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/BandWipe.glsl +67 -0
- package/glsl3/BookFlip.glsl +124 -21
- package/glsl3/BowTie.glsl +1 -1
- package/glsl3/Clothesline.glsl +217 -0
- package/glsl3/ComicPanels.glsl +174 -0
- package/glsl3/Cube.glsl +105 -52
- package/glsl3/DirectionalWipe.glsl +1 -1
- package/glsl3/DominoFall.glsl +114 -0
- package/glsl3/Doorway.glsl +74 -38
- package/glsl3/Drape.glsl +186 -0
- package/glsl3/DuotoneFade.glsl +58 -0
- package/glsl3/FacetedGlass.glsl +137 -0
- package/glsl3/FrostWipe.glsl +176 -0
- package/glsl3/Funnel.glsl +71 -0
- package/glsl3/GlintDissolve.glsl +125 -0
- package/glsl3/GlitterDissolve.glsl +171 -0
- package/glsl3/GridFlip.glsl +151 -56
- package/glsl3/HeartWipe.glsl +71 -11
- package/glsl3/InsetWipe.glsl +58 -0
- package/glsl3/InsideCube.glsl +114 -0
- package/glsl3/KeyholeWipe.glsl +104 -0
- package/glsl3/LedWall.glsl +127 -0
- package/glsl3/LightningFlash.glsl +200 -0
- package/glsl3/MoireWipe.glsl +75 -0
- package/glsl3/PaperFold.glsl +168 -0
- package/glsl3/PuzzleCube.glsl +205 -0
- package/glsl3/RibbonTwist.glsl +53 -0
- package/glsl3/Shatter.glsl +231 -35
- package/glsl3/SketchDissolve.glsl +100 -0
- package/glsl3/SlotReels.glsl +118 -0
- package/glsl3/SplitFlap.glsl +124 -0
- package/glsl3/Swirl.glsl +52 -21
- package/glsl3/TruchetWipe.glsl +80 -0
- package/glsl3/Tumble.glsl +113 -0
- package/glsl3/WarpSpeed.glsl +120 -0
- package/glsl3/WaterDrop.glsl +69 -13
- package/glsl3/WaveWipe.glsl +154 -0
- package/index.js +1 -1
- package/layouts.json +1158 -193
- package/llms-full.txt +865 -540
- package/llms.txt +219 -204
- package/msl/BandWipe.metal +353 -0
- package/msl/BookFlip.metal +575 -114
- package/msl/BowTie.metal +1 -1
- package/msl/Clothesline.metal +828 -0
- package/msl/ComicPanels.metal +959 -0
- package/msl/Cube.metal +466 -170
- package/msl/DirectionalWipe.metal +1 -1
- package/msl/DominoFall.metal +510 -0
- package/msl/Doorway.metal +350 -124
- package/msl/Drape.metal +767 -0
- package/msl/DuotoneFade.metal +218 -0
- package/msl/FacetedGlass.metal +529 -0
- package/msl/FrostWipe.metal +677 -0
- package/msl/Funnel.metal +276 -0
- package/msl/GlintDissolve.metal +558 -0
- package/msl/GlitterDissolve.metal +637 -0
- package/msl/GridFlip.metal +548 -191
- package/msl/HeartWipe.metal +230 -58
- package/msl/InsetWipe.metal +232 -0
- package/msl/InsideCube.metal +537 -0
- package/msl/KeyholeWipe.metal +370 -0
- package/msl/LedWall.metal +437 -0
- package/msl/LightningFlash.metal +1038 -0
- package/msl/MoireWipe.metal +252 -0
- package/msl/PaperFold.metal +762 -0
- package/msl/PuzzleCube.metal +1179 -0
- package/msl/RibbonTwist.metal +235 -0
- package/msl/Shatter.metal +1136 -160
- package/msl/SketchDissolve.metal +446 -0
- package/msl/SlotReels.metal +436 -0
- package/msl/SplitFlap.metal +589 -0
- package/msl/Swirl.metal +144 -77
- package/msl/TruchetWipe.metal +285 -0
- package/msl/Tumble.metal +466 -0
- package/msl/WarpSpeed.metal +549 -0
- package/msl/WaterDrop.metal +258 -49
- package/msl/WaveWipe.metal +618 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +119 -74
- package/sksl/BandWipe.sksl +77 -0
- package/sksl/BookFlip.sksl +117 -20
- package/sksl/BowTie.sksl +1 -1
- package/sksl/Clothesline.sksl +217 -0
- package/sksl/ComicPanels.sksl +176 -0
- package/sksl/Cube.sksl +99 -46
- package/sksl/DirectionalWipe.sksl +1 -1
- package/sksl/DominoFall.sksl +122 -0
- package/sksl/Doorway.sksl +65 -35
- package/sksl/Drape.sksl +192 -0
- package/sksl/DuotoneFade.sksl +71 -0
- package/sksl/FacetedGlass.sksl +148 -0
- package/sksl/FrostWipe.sksl +183 -0
- package/sksl/Funnel.sksl +83 -0
- package/sksl/GlintDissolve.sksl +136 -0
- package/sksl/GlitterDissolve.sksl +175 -0
- package/sksl/GridFlip.sksl +141 -52
- package/sksl/HeartWipe.sksl +60 -11
- package/sksl/InsetWipe.sksl +70 -0
- package/sksl/InsideCube.sksl +123 -0
- package/sksl/KeyholeWipe.sksl +109 -0
- package/sksl/LedWall.sksl +137 -0
- package/sksl/LightningFlash.sksl +202 -0
- package/sksl/MoireWipe.sksl +85 -0
- package/sksl/PaperFold.sksl +170 -0
- package/sksl/PuzzleCube.sksl +203 -0
- package/sksl/RibbonTwist.sksl +66 -0
- package/sksl/Shatter.sksl +218 -33
- package/sksl/SketchDissolve.sksl +111 -0
- package/sksl/SlotReels.sksl +127 -0
- package/sksl/SplitFlap.sksl +131 -0
- package/sksl/Swirl.sksl +49 -20
- package/sksl/TruchetWipe.sksl +92 -0
- package/sksl/Tumble.sksl +122 -0
- package/sksl/WarpSpeed.sksl +131 -0
- package/sksl/WaterDrop.sksl +64 -10
- package/sksl/WaveWipe.sksl +165 -0
- package/sksl/index.js +1 -1
- package/transitions/BandWipe.glsl +66 -0
- package/transitions/BookFlip.glsl +124 -21
- package/transitions/BowTie.glsl +1 -1
- package/transitions/Clothesline.glsl +216 -0
- package/transitions/ComicPanels.glsl +173 -0
- package/transitions/Cube.glsl +105 -52
- package/transitions/DirectionalWipe.glsl +1 -1
- package/transitions/DominoFall.glsl +113 -0
- package/transitions/Doorway.glsl +74 -38
- package/transitions/Drape.glsl +185 -0
- package/transitions/DuotoneFade.glsl +57 -0
- package/transitions/FacetedGlass.glsl +136 -0
- package/transitions/FrostWipe.glsl +175 -0
- package/transitions/Funnel.glsl +70 -0
- package/transitions/GlintDissolve.glsl +124 -0
- package/transitions/GlitterDissolve.glsl +170 -0
- package/transitions/GridFlip.glsl +151 -56
- package/transitions/HeartWipe.glsl +71 -11
- package/transitions/InsetWipe.glsl +57 -0
- package/transitions/InsideCube.glsl +113 -0
- package/transitions/KeyholeWipe.glsl +103 -0
- package/transitions/LedWall.glsl +126 -0
- package/transitions/LightningFlash.glsl +199 -0
- package/transitions/MoireWipe.glsl +74 -0
- package/transitions/PaperFold.glsl +167 -0
- package/transitions/PuzzleCube.glsl +204 -0
- package/transitions/RibbonTwist.glsl +52 -0
- package/transitions/Shatter.glsl +231 -35
- package/transitions/SketchDissolve.glsl +99 -0
- package/transitions/SlotReels.glsl +117 -0
- package/transitions/SplitFlap.glsl +123 -0
- package/transitions/Swirl.glsl +52 -21
- package/transitions/TruchetWipe.glsl +79 -0
- package/transitions/Tumble.glsl +112 -0
- package/transitions/WarpSpeed.glsl +119 -0
- package/transitions/WaterDrop.glsl +69 -13
- package/transitions/WaveWipe.glsl +153 -0
- package/wgsl/BandWipe.wgsl +319 -0
- package/wgsl/BookFlip.wgsl +552 -105
- package/wgsl/BowTie.wgsl +1 -1
- package/wgsl/Clothesline.wgsl +756 -0
- package/wgsl/ComicPanels.wgsl +886 -0
- package/wgsl/Cube.wgsl +461 -156
- package/wgsl/DirectionalWipe.wgsl +1 -1
- package/wgsl/DominoFall.wgsl +461 -0
- package/wgsl/Doorway.wgsl +333 -117
- package/wgsl/Drape.wgsl +715 -0
- package/wgsl/DuotoneFade.wgsl +185 -0
- package/wgsl/FacetedGlass.wgsl +476 -0
- package/wgsl/FrostWipe.wgsl +617 -0
- package/wgsl/Funnel.wgsl +248 -0
- package/wgsl/GlintDissolve.wgsl +519 -0
- package/wgsl/GlitterDissolve.wgsl +582 -0
- package/wgsl/GridFlip.wgsl +523 -188
- package/wgsl/HeartWipe.wgsl +225 -55
- package/wgsl/InsetWipe.wgsl +200 -0
- package/wgsl/InsideCube.wgsl +496 -0
- package/wgsl/KeyholeWipe.wgsl +337 -0
- package/wgsl/LedWall.wgsl +397 -0
- package/wgsl/LightningFlash.wgsl +964 -0
- package/wgsl/MoireWipe.wgsl +222 -0
- package/wgsl/PaperFold.wgsl +700 -0
- package/wgsl/PuzzleCube.wgsl +1087 -0
- package/wgsl/RibbonTwist.wgsl +206 -0
- package/wgsl/Shatter.wgsl +1091 -148
- package/wgsl/SketchDissolve.wgsl +409 -0
- package/wgsl/SlotReels.wgsl +391 -0
- package/wgsl/SplitFlap.wgsl +533 -0
- package/wgsl/Swirl.wgsl +138 -77
- package/wgsl/TruchetWipe.wgsl +255 -0
- package/wgsl/Tumble.wgsl +424 -0
- package/wgsl/WarpSpeed.wgsl +497 -0
- package/wgsl/WaterDrop.wgsl +251 -49
- package/wgsl/WaveWipe.wgsl +581 -0
- package/glsl3/BlockDissolve.glsl +0 -16
- package/glsl3/BowTieVertical.glsl +0 -117
- package/glsl3/Box.glsl +0 -33
- package/glsl3/LinearBlur.glsl +0 -30
- package/glsl3/MosaicBlend.glsl +0 -21
- package/glsl3/MosaicFade.glsl +0 -20
- package/glsl3/RotateFade.glsl +0 -22
- package/glsl3/ScaleIn.glsl +0 -18
- package/glsl3/WipeDown.glsl +0 -12
- package/glsl3/WipeLeft.glsl +0 -12
- package/glsl3/WipeRight.glsl +0 -12
- package/glsl3/WipeUp.glsl +0 -12
- package/msl/BlockDissolve.metal +0 -108
- package/msl/BowTieVertical.metal +0 -375
- package/msl/Box.metal +0 -204
- package/msl/LinearBlur.metal +0 -169
- package/msl/MosaicBlend.metal +0 -136
- package/msl/MosaicFade.metal +0 -137
- package/msl/RotateFade.metal +0 -116
- package/msl/ScaleIn.metal +0 -111
- package/msl/WipeDown.metal +0 -105
- package/msl/WipeLeft.metal +0 -105
- package/msl/WipeRight.metal +0 -105
- package/msl/WipeUp.metal +0 -105
- package/sksl/BlockDissolve.sksl +0 -29
- package/sksl/BowTieVertical.sksl +0 -130
- package/sksl/Box.sksl +0 -47
- package/sksl/LinearBlur.sksl +0 -44
- package/sksl/MosaicBlend.sksl +0 -34
- package/sksl/MosaicFade.sksl +0 -33
- package/sksl/RotateFade.sksl +0 -34
- package/sksl/ScaleIn.sksl +0 -32
- package/sksl/WipeDown.sksl +0 -26
- package/sksl/WipeLeft.sksl +0 -26
- package/sksl/WipeRight.sksl +0 -26
- package/sksl/WipeUp.sksl +0 -26
- package/transitions/BlockDissolve.glsl +0 -15
- package/transitions/BowTieVertical.glsl +0 -116
- package/transitions/Box.glsl +0 -32
- package/transitions/LinearBlur.glsl +0 -29
- package/transitions/MosaicBlend.glsl +0 -20
- package/transitions/MosaicFade.glsl +0 -19
- package/transitions/RotateFade.glsl +0 -21
- package/transitions/ScaleIn.glsl +0 -17
- package/transitions/WipeDown.glsl +0 -11
- package/transitions/WipeLeft.glsl +0 -11
- package/transitions/WipeRight.glsl +0 -11
- package/transitions/WipeUp.glsl +0 -11
- package/wgsl/BlockDissolve.wgsl +0 -78
- package/wgsl/BowTieVertical.wgsl +0 -331
- package/wgsl/Box.wgsl +0 -176
- package/wgsl/LinearBlur.wgsl +0 -131
- package/wgsl/MosaicBlend.wgsl +0 -108
- package/wgsl/MosaicFade.wgsl +0 -107
- package/wgsl/RotateFade.wgsl +0 -85
- package/wgsl/ScaleIn.wgsl +0 -79
- package/wgsl/WipeDown.wgsl +0 -77
- package/wgsl/WipeLeft.wgsl +0 -77
- package/wgsl/WipeRight.wgsl +0 -77
- package/wgsl/WipeUp.wgsl +0 -77
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// SlotReels — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SlotReels.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The frame is cut into vertical reels that spin downward like drums, motion-blurred with speed, carrying the outgoing image then the incoming one, and stop one after another from left to right with a small mechanical bounce
|
|
5
|
+
// Tags: 3d, spin, stripes, motion-blur
|
|
6
|
+
|
|
7
|
+
// @range(1, 16, 1) Number of reels
|
|
8
|
+
uniform int reels; // = 5
|
|
9
|
+
// @range(0, 1) Amount of vertical motion blur while the reels spin fast
|
|
10
|
+
uniform float blur; // = 0.6
|
|
11
|
+
// @range(0, 0.9) Delay between the first and the last reel's stop, as a part of the transition
|
|
12
|
+
uniform float stagger; // = 0.45
|
|
13
|
+
// @range(0, 1) Size of the bounce when a reel stops
|
|
14
|
+
uniform float bounce; // = 0.5
|
|
15
|
+
// @color Color of the separators between the reels
|
|
16
|
+
uniform vec4 separator; // = vec4(0.04, 0.04, 0.05, 1.0)
|
|
17
|
+
|
|
18
|
+
const float PI = 3.141592653589793;
|
|
19
|
+
// half of the arc of the drum seen in the frame, in radians
|
|
20
|
+
const float ARC = 1.15;
|
|
21
|
+
// duration of the bounce, as a part of the transition
|
|
22
|
+
const float SETTLE = 0.1;
|
|
23
|
+
// width of the separators, in frame heights
|
|
24
|
+
const float LINE = 0.006;
|
|
25
|
+
// width of the anti-aliased edges, in frame heights
|
|
26
|
+
const float EDGE = 0.0015;
|
|
27
|
+
|
|
28
|
+
// the time at which the reel stops, before its bounce
|
|
29
|
+
float stopTime(float i, float n) {
|
|
30
|
+
float order = n > 1.0 ? i / (n - 1.0) : 1.0;
|
|
31
|
+
return (1.0 - SETTLE) * (1.0 - clamp(stagger, 0.0, 0.9) * (1.0 - order));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// how far the reel has turned at time t, in image heights: it speeds up, slows down to its stop
|
|
35
|
+
// a little past the incoming image and springs back onto it
|
|
36
|
+
float reelOffset(float t, float stopT, float turns) {
|
|
37
|
+
float amp = 0.07 * bounce;
|
|
38
|
+
// speed at the stop, matched with the start of the bounce
|
|
39
|
+
float v1 = amp * PI * stopT / (turns * SETTLE);
|
|
40
|
+
float u = clamp(t / stopT, 0.0, 1.0);
|
|
41
|
+
float g = u * u * (3.0 - 2.0 * u) + v1 * (u * u * u - u * u);
|
|
42
|
+
float b = clamp((t - stopT) / SETTLE, 0.0, 1.0);
|
|
43
|
+
return turns * g + amp * sin(PI * b) * (1.0 - b) * (1.0 - b);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// the reel's speed at time t, the derivative of reelOffset, in image heights per transition
|
|
47
|
+
float reelSpeed(float t, float stopT, float turns) {
|
|
48
|
+
float amp = 0.07 * bounce;
|
|
49
|
+
float v1 = amp * PI * stopT / (turns * SETTLE);
|
|
50
|
+
if (t < stopT) {
|
|
51
|
+
float u = max(t / stopT, 0.0);
|
|
52
|
+
return turns * (6.0 * u * (1.0 - u) + v1 * u * (3.0 * u - 2.0)) / stopT;
|
|
53
|
+
}
|
|
54
|
+
float b = min((t - stopT) / SETTLE, 1.0);
|
|
55
|
+
return amp * (1.0 - b) * (PI * cos(PI * b) * (1.0 - b) - 2.0 * sin(PI * b)) / SETTLE;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
vec4 transition (vec2 uv) {
|
|
59
|
+
float n = max(float(reels), 1.0);
|
|
60
|
+
float i = min(floor(uv.x * n), n - 1.0);
|
|
61
|
+
float lx = uv.x * n - i;
|
|
62
|
+
float stopT = stopTime(i, n);
|
|
63
|
+
// an odd number of turns, more for the reels that spin longer, so they land on the incoming image
|
|
64
|
+
float turns = 2.0 * floor(stopT * 4.0) + 1.0;
|
|
65
|
+
|
|
66
|
+
// the reel is a drum while it spins, and flattens back as it settles
|
|
67
|
+
float drum = smoothstep(0.0, 0.12, progress) * (1.0 - smoothstep(stopT, stopT + SETTLE, progress));
|
|
68
|
+
float y = 2.0 * uv.y - 1.0;
|
|
69
|
+
// theta: the angle around the drum's axis, 0 facing the viewer
|
|
70
|
+
float theta = asin(clamp(y * sin(ARC), -1.0, 1.0));
|
|
71
|
+
float v = mix(uv.y, 0.5 + theta / (2.0 * ARC), drum);
|
|
72
|
+
// the far edges of the drum look narrower
|
|
73
|
+
float depth = (1.0 - cos(theta)) * drum;
|
|
74
|
+
float px = 0.5 + (lx - 0.5) * (1.0 + 0.2 * depth);
|
|
75
|
+
|
|
76
|
+
// offset from the resting position, -turns at the start, 0 once landed
|
|
77
|
+
float off = reelOffset(progress, stopT, turns) - turns;
|
|
78
|
+
float speed = abs(reelSpeed(progress, stopT, turns));
|
|
79
|
+
// the blur spans the distance the reel travels in about a frame
|
|
80
|
+
float spread = blur * min(speed * 0.02, 0.22) * drum;
|
|
81
|
+
|
|
82
|
+
// up to 8 taps along the reel, weighted toward the middle, one when it stands still
|
|
83
|
+
vec4 c = vec4(0.0);
|
|
84
|
+
float wsum = 0.0;
|
|
85
|
+
for (int k = 0; k < 8; k++) {
|
|
86
|
+
float f = float(k) / 7.0 - 0.5;
|
|
87
|
+
float w = 1.0 - abs(f);
|
|
88
|
+
float vv = v + off + spread * f;
|
|
89
|
+
float seg = floor(vv);
|
|
90
|
+
vec2 q = vec2((i + clamp(px, 0.0, 1.0)) / n, vv - seg);
|
|
91
|
+
// the drum carries the incoming image on even segments, the outgoing one on odd segments
|
|
92
|
+
vec4 s = mod(seg, 2.0) < 0.5 ? getToColor(q) : getFromColor(q);
|
|
93
|
+
// a thin shadow at the seams between the images, not at the frame's top and bottom edges
|
|
94
|
+
s.rgb *= 1.0 - 0.6 * drum * (1.0 - y * y) * (1.0 - smoothstep(0.0, 0.02, min(q.y, 1.0 - q.y)));
|
|
95
|
+
c += w * s;
|
|
96
|
+
wsum += w;
|
|
97
|
+
if (spread < 1e-4) break;
|
|
98
|
+
}
|
|
99
|
+
c /= wsum;
|
|
100
|
+
|
|
101
|
+
// the drum's faces darken as they turn away, with a soft highlight above its middle
|
|
102
|
+
float facing = cos(theta);
|
|
103
|
+
c.rgb *= mix(1.0, 0.25 + 0.75 * facing * facing, drum);
|
|
104
|
+
c.rgb += drum * 0.07 * c.a * exp(-12.0 * (y - 0.3) * (y - 0.3));
|
|
105
|
+
|
|
106
|
+
// separators between the reels, and the background around the narrower far edges of the drums
|
|
107
|
+
float env = smoothstep(0.0, 0.1, progress) * (1.0 - smoothstep(0.9, 1.0, progress));
|
|
108
|
+
float reelW = ratio / n;
|
|
109
|
+
float persp = reelW / (1.0 + 0.2 * depth);
|
|
110
|
+
// distance to the reel's sides, and to its sides next to the other reels
|
|
111
|
+
float dSide = min(px, 1.0 - px) * persp;
|
|
112
|
+
float dInner = min(i > 0.5 ? px : 2.0, i < n - 1.5 ? 1.0 - px : 2.0) * persp;
|
|
113
|
+
float line = 1.0 - smoothstep(0.5 * LINE - EDGE, 0.5 * LINE + EDGE, dInner);
|
|
114
|
+
float outside = 1.0 - smoothstep(-EDGE, 0.0, dSide);
|
|
115
|
+
// a soft shadow cast by the separators on the reels
|
|
116
|
+
c.rgb *= 1.0 - 0.35 * env * (1.0 - smoothstep(0.0, 0.03 * reelW + LINE, dInner));
|
|
117
|
+
return mix(c, separator, max(line * env, outside));
|
|
118
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// SplitFlap — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SplitFlap.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The frame becomes a split-flap board: in each cell the top half of the outgoing image flips down on a hinge across the middle, cell after cell, its back bringing the bottom half of the incoming image
|
|
5
|
+
// Tags: 3d, flip, grid
|
|
6
|
+
|
|
7
|
+
// @param Number of cells (columns, rows)
|
|
8
|
+
uniform ivec2 size; // = ivec2(8, 6)
|
|
9
|
+
// @range(0, 0.9) Delay of the last cell's flip, as a part of the transition
|
|
10
|
+
uniform float stagger; // = 0.6
|
|
11
|
+
// @range(0, 1) How much the order of the cells is shuffled, from a wave across the board to random
|
|
12
|
+
uniform float randomness; // = 0.3
|
|
13
|
+
// @range(1, 4, 1) Number of flaps that fall in each cell, the ones before the last showing other parts of the incoming image
|
|
14
|
+
uniform int flaps; // = 1
|
|
15
|
+
// @range(0, 0.05) Width of the gaps between the cells, as a part of the frame's shorter side (the hinges get half of it)
|
|
16
|
+
uniform float gap; // = 0.004
|
|
17
|
+
// @range(0, 1) Amount of perspective: the falling flaps grow as they come toward the viewer
|
|
18
|
+
uniform float perspective; // = 0.35
|
|
19
|
+
// @range(0, 1) How much the flaps darken as they turn away from the light, and the shadows they cast
|
|
20
|
+
uniform float shading; // = 0.4
|
|
21
|
+
// @color Color seen in the gaps between the cells
|
|
22
|
+
uniform vec4 background; // = vec4(0.0, 0.0, 0.0, 1.0)
|
|
23
|
+
|
|
24
|
+
const float PI = 3.141592653589793;
|
|
25
|
+
// width of the anti-aliased edges, as a part of the frame's shorter side
|
|
26
|
+
const float EDGE = 0.001;
|
|
27
|
+
|
|
28
|
+
float hash12(vec2 v) {
|
|
29
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
30
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
31
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// the cell's flip, 0 to 1
|
|
35
|
+
float cellTime(vec2 cell, vec2 grid) {
|
|
36
|
+
float wave = (cell.x + 0.5 * (grid.y - 1.0 - cell.y)) / max(grid.x - 1.0 + 0.5 * (grid.y - 1.0), 1.0);
|
|
37
|
+
float order = mix(wave, hash12(cell + 17.0), randomness);
|
|
38
|
+
float delay = clamp(stagger, 0.0, 0.99);
|
|
39
|
+
return clamp((progress - order * delay) / (1.0 - delay), 0.0, 1.0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// the card on the front of the falling flap, at the cell's flip t
|
|
43
|
+
float flapIndex(float t, float n) {
|
|
44
|
+
return min(floor(t * n), n - 1.0);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// the falling flap's angle, 0 upright to PI down: it starts gently and lands fast
|
|
48
|
+
float flapAngle(float t, float n) {
|
|
49
|
+
float u = t * n - flapIndex(t, n);
|
|
50
|
+
return PI * u * (0.3 + 0.7 * u);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// card i of a cell at the point lc of the card: the outgoing image first, the incoming one last,
|
|
54
|
+
// and in between the incoming image of another cell
|
|
55
|
+
vec4 card(float i, float n, vec2 cell, vec2 grid, vec2 lc) {
|
|
56
|
+
if (i < 0.5) return getFromColor((cell + lc) / grid);
|
|
57
|
+
vec2 src = cell;
|
|
58
|
+
if (i < n - 0.5) src = floor(vec2(hash12(cell * 3.7 + i * 11.3), hash12(cell * 5.3 + i * 7.9 + 1.7)) * grid);
|
|
59
|
+
return getToColor((src + lc) / grid);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 1 inside a half card, 0 in the gaps: x across the card and f the distance from the hinge, in cell sizes
|
|
63
|
+
float cardMask(float x, float f, vec2 cellSize, float g) {
|
|
64
|
+
if (g <= 0.0) return 1.0;
|
|
65
|
+
float e = EDGE * min(1.0, g / max(gap, 1e-4));
|
|
66
|
+
// the gap at the hinge is half as wide as the one between the cells
|
|
67
|
+
float d = min(min(x, 1.0 - x) * cellSize.x, min(2.0 * f, 0.5 - f) * cellSize.y);
|
|
68
|
+
return smoothstep(0.5 * g - e, 0.5 * g + e, d);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
vec4 transition (vec2 uv) {
|
|
72
|
+
vec2 grid = max(vec2(size), 1.0);
|
|
73
|
+
float n = max(float(flaps), 1.0);
|
|
74
|
+
vec2 cellSize = vec2(ratio, 1.0) / grid / min(ratio, 1.0);
|
|
75
|
+
vec2 cell = floor(uv * grid);
|
|
76
|
+
vec2 l = uv * grid - cell;
|
|
77
|
+
// the gaps open at the start and close at the end
|
|
78
|
+
float g = gap * smoothstep(0.0, 0.12, progress) * (1.0 - smoothstep(0.88, 1.0, progress));
|
|
79
|
+
// w: height above the hinge, in cell heights
|
|
80
|
+
float w = l.y - 0.5;
|
|
81
|
+
bool upper = w >= 0.0;
|
|
82
|
+
|
|
83
|
+
// the board behind the falling flaps: the top half of the next card once the flap has left it,
|
|
84
|
+
// the bottom half of the current card until the flap has landed on it
|
|
85
|
+
float t = cellTime(cell, grid);
|
|
86
|
+
float k = flapIndex(t, n);
|
|
87
|
+
float a = flapAngle(t, n);
|
|
88
|
+
bool started = t * n > k;
|
|
89
|
+
bool landed = t >= 1.0;
|
|
90
|
+
vec4 color = card(k + (upper ? (started ? 1.0 : 0.0) : (landed ? 1.0 : 0.0)), n, cell, grid, l);
|
|
91
|
+
// shadows of the flap leaning over the top half, then falling onto the bottom half
|
|
92
|
+
if (started && !landed) color.rgb *= 1.0 - 0.45 * shading * max(upper ? cos(a) : -cos(a), 0.0);
|
|
93
|
+
color = mix(background, color, cardMask(l.x, abs(w), cellSize, g));
|
|
94
|
+
|
|
95
|
+
// the falling flaps of this cell and of its neighbors, which grow beyond their cells as they come closer
|
|
96
|
+
float nearest = -1.0;
|
|
97
|
+
for (int d = -1; d <= 1; d++) {
|
|
98
|
+
vec2 nc = cell + vec2(float(d), 0.0);
|
|
99
|
+
if (nc.x < 0.0 || nc.x > grid.x - 1.0) continue;
|
|
100
|
+
float nt = d == 0 ? t : cellTime(nc, grid);
|
|
101
|
+
float na = d == 0 ? a : flapAngle(nt, n);
|
|
102
|
+
float fc = cos(na);
|
|
103
|
+
float fs = sin(na);
|
|
104
|
+
// a point at distance f from the hinge is at height f * fc and depth f * fs, nearer points look wider
|
|
105
|
+
if (abs(fc) < 1e-5 || (w >= 0.0) != (fc > 0.0)) continue;
|
|
106
|
+
float f = w / fc;
|
|
107
|
+
if (f > 0.5) continue;
|
|
108
|
+
float z = f * fs;
|
|
109
|
+
if (z <= nearest) continue;
|
|
110
|
+
float lx = 0.5 + (l.x - float(d) - 0.5) * (1.0 - perspective * z);
|
|
111
|
+
if (lx < 0.0 || lx > 1.0) continue;
|
|
112
|
+
bool front = fc > 0.0;
|
|
113
|
+
vec2 lc = vec2(lx, front ? 0.5 + f : 0.5 - f);
|
|
114
|
+
float m = cardMask(lx, f, cellSize, g);
|
|
115
|
+
if (m <= 0.0) continue;
|
|
116
|
+
vec4 img = card(flapIndex(nt, n) + (front ? 0.0 : 1.0), n, nc, grid, lc);
|
|
117
|
+
// lit from above the viewer: the front darkens as it turns down, the back brightens as it lands
|
|
118
|
+
float lambert = (front ? 0.92 * fc - 0.4 * fs : 0.4 * fs - 0.92 * fc) / 0.92;
|
|
119
|
+
img.rgb *= mix(1.0 - shading, 1.0, clamp(lambert, 0.0, 1.0));
|
|
120
|
+
color = mix(color, img, m);
|
|
121
|
+
nearest = z;
|
|
122
|
+
}
|
|
123
|
+
return color;
|
|
124
|
+
}
|
package/glsl3/Swirl.glsl
CHANGED
|
@@ -1,34 +1,65 @@
|
|
|
1
1
|
// Swirl — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Swirl.glsl
|
|
2
2
|
// License: MIT
|
|
3
3
|
// Author: Sergey Kosarevsky
|
|
4
|
-
// Description:
|
|
4
|
+
// Description: The image twists into a round swirl around the center that peaks mid-way, where the outgoing image dissolves into the incoming one, then untwists
|
|
5
5
|
// Tags: swirl, rotate, blend
|
|
6
6
|
// ( http://www.linderdaum.com )
|
|
7
7
|
// ported by gre from https://gist.github.com/corporateshark/cacfedb8cca0f5ce3f7c
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
// @range(-3, 3) Turns of the swirl at its center at the peak (negative turns clockwise)
|
|
10
|
+
uniform float strength; // = 1.0
|
|
11
|
+
// @range(0.1, 2) Radius of the swirl, in frame heights
|
|
12
|
+
uniform float radius; // = 0.9
|
|
13
|
+
// Center of the swirl
|
|
14
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
const float PI = 3.141592653589793;
|
|
17
|
+
const float TAU = 6.283185307179586;
|
|
18
|
+
// how much the swirl pulls the image toward its center at the peak
|
|
19
|
+
const float ZOOM = 0.12;
|
|
20
|
+
// spread of the motion blur, as a fraction of the swirl's speed
|
|
21
|
+
const float BLUR = 0.05;
|
|
22
|
+
const int TAPS = 12;
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
// fold the coordinates back into the frame, so the image stays filled without smearing its border
|
|
25
|
+
vec2 mirrored(vec2 v) {
|
|
26
|
+
vec2 m = mod(v, 2.0);
|
|
27
|
+
return mix(m, 2.0 - m, step(1.0, m));
|
|
28
|
+
}
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
UV += vec2( 0.5, 0.5 );
|
|
30
|
+
vec4 transition(vec2 uv) {
|
|
31
|
+
// the swirl eases in and out, and is exactly 0 at both ends
|
|
32
|
+
float s = sin(PI * progress);
|
|
33
|
+
float amount = s * s;
|
|
34
|
+
// its speed, used for the motion blur, also 0 at both ends
|
|
35
|
+
float speed = PI * sin(TAU * progress);
|
|
36
|
+
// the switch from the outgoing to the incoming image happens around the peak
|
|
37
|
+
float reveal = smoothstep(0.3, 0.7, progress);
|
|
29
38
|
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
// measured in frame heights, so the swirl is round
|
|
40
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
41
|
+
vec2 d = (uv - center) * aspect;
|
|
42
|
+
float x = clamp(length(d) / max(radius, 1e-3), 0.0, 1.0);
|
|
43
|
+
// the twist fades out smoothly toward the edge of the swirl
|
|
44
|
+
float falloff = (1.0 - x) * (1.0 - x);
|
|
45
|
+
float twist = strength * TAU * falloff;
|
|
46
|
+
float angle = twist * amount;
|
|
47
|
+
// capped so the blur taps never spread apart into visible streaks
|
|
48
|
+
float spread = clamp(twist * speed * BLUR, -1.2, 1.2);
|
|
49
|
+
// the swirl also slightly pulls the image toward its center
|
|
50
|
+
d *= 1.0 - ZOOM * amount * falloff;
|
|
32
51
|
|
|
33
|
-
|
|
52
|
+
vec4 col = vec4(0.0);
|
|
53
|
+
float total = 0.0;
|
|
54
|
+
for (int i = 0; i < TAPS; i++) {
|
|
55
|
+
float k = float(i) / float(TAPS - 1) - 0.5;
|
|
56
|
+
float w = 1.0 - abs(k);
|
|
57
|
+
float a = angle + spread * k;
|
|
58
|
+
float c = cos(a);
|
|
59
|
+
float sn = sin(a);
|
|
60
|
+
vec2 q = mirrored(center + vec2(c * d.x - sn * d.y, sn * d.x + c * d.y) / aspect);
|
|
61
|
+
col += mix(getFromColor(q), getToColor(q), reveal) * w;
|
|
62
|
+
total += w;
|
|
63
|
+
}
|
|
64
|
+
return col / total;
|
|
34
65
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// TruchetWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/TruchetWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: A grid of square tiles, each holding two quarter-circle arcs, links into long winding paths; starting from the middle and spreading outward, the paths are drawn as thin lines of the incoming image, then thicken into bands with a dark outline and a soft shadow until they merge over the whole frame
|
|
5
|
+
// Tags: truchet, pattern, tiles, paths, graphic, reveal
|
|
6
|
+
|
|
7
|
+
// @range(3, 20, 1) Number of tiles across the frame's height
|
|
8
|
+
uniform float cells; // = 8.0
|
|
9
|
+
// @range(0, 1) Strength of the dark outline and of the shadow along the bands
|
|
10
|
+
uniform float outline; // = 0.6
|
|
11
|
+
// @range(0, 1) How much the paths are staggered from the middle outward: 0 draws them all at once
|
|
12
|
+
uniform float spread; // = 0.75
|
|
13
|
+
|
|
14
|
+
// half width of the antialiased edges, in frame heights
|
|
15
|
+
const float AA = 0.0012;
|
|
16
|
+
// width of the outline, in frame heights
|
|
17
|
+
const float LINE = 0.003;
|
|
18
|
+
// how far the shadow reaches outside a band, in frame heights
|
|
19
|
+
const float SHADOW = 0.025;
|
|
20
|
+
// half width of the thin line a path is first drawn as, in tiles
|
|
21
|
+
const float STROKE = 0.08;
|
|
22
|
+
|
|
23
|
+
float hash12(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 vnoise(vec2 v) {
|
|
30
|
+
vec2 i = floor(v);
|
|
31
|
+
vec2 f = fract(v);
|
|
32
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
33
|
+
return mix(
|
|
34
|
+
mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
|
|
35
|
+
mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
|
|
36
|
+
f.y
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
vec4 transition(vec2 uv) {
|
|
41
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
42
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
43
|
+
|
|
44
|
+
float n = max(floor(cells + 0.5), 1.0);
|
|
45
|
+
// aspect-correct square tiles, centered on the frame
|
|
46
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0);
|
|
47
|
+
vec2 g = p * n + 0.5;
|
|
48
|
+
vec2 cell = floor(g);
|
|
49
|
+
vec2 q = fract(g);
|
|
50
|
+
// each tile is mirrored at random, so its two arcs (centered on opposite corners) link up with its neighbors' in two ways
|
|
51
|
+
if (hash12(cell + 17.0) > 0.5) q.x = 1.0 - q.x;
|
|
52
|
+
// distance to the nearest arc, in tiles: continuous across the tiles' edges, at most 0.5 (at the corners)
|
|
53
|
+
float d = min(abs(length(q) - 0.5), abs(length(q - 1.0) - 0.5));
|
|
54
|
+
|
|
55
|
+
// when the paths reach this point: from the middle outward, made irregular by a noise
|
|
56
|
+
float T = clamp(length(p) / (0.5 * length(vec2(ratio, 1.0))) + 0.4 * (vnoise(p * 3.0 + 4.0) - 0.5), 0.0, 1.0);
|
|
57
|
+
float lag = 0.8 * clamp(spread, 0.0, 1.0);
|
|
58
|
+
// every point is fully covered at progress 0.95
|
|
59
|
+
float s = clamp((progress - lag * T) / (0.95 - lag), 0.0, 1.0);
|
|
60
|
+
// in tiles: the paths are first drawn as thin lines, then the bands widen past the tiles' corners
|
|
61
|
+
float aa = AA * n;
|
|
62
|
+
float k = clamp((s - 0.25) / 0.75, 0.0, 1.0);
|
|
63
|
+
float w = STROKE * smoothstep(0.0, 0.3, s) + (0.5 + LINE * n + 3.0 * aa - STROKE) * k * k;
|
|
64
|
+
// signed distance to the edge of the bands (negative inside), in tiles
|
|
65
|
+
float e = d - w;
|
|
66
|
+
|
|
67
|
+
float band = 1.0 - smoothstep(-2.0 * aa, 0.0, e);
|
|
68
|
+
// outside the bands: a thin outline on their edge and a soft shadow, fading in with the line
|
|
69
|
+
float gap = max(e + aa, 0.0);
|
|
70
|
+
float fall = 1.0 - smoothstep(0.0, SHADOW * n, gap);
|
|
71
|
+
float edge = max(0.8 * (1.0 - smoothstep(LINE * n, LINE * n + 2.0 * aa, gap)), 0.4 * fall * fall);
|
|
72
|
+
float shade = clamp(outline, 0.0, 1.0) * smoothstep(0.0, STROKE, w) * edge;
|
|
73
|
+
|
|
74
|
+
vec4 a = getFromColor(uv);
|
|
75
|
+
a.rgb *= 1.0 - shade;
|
|
76
|
+
vec4 b = getToColor(uv);
|
|
77
|
+
// mixed premultiplied, so transparent images do not bleed their color
|
|
78
|
+
vec4 o = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), band);
|
|
79
|
+
return o.a > 0.0 ? vec4(o.rgb / o.a, o.a) : vec4(0.0);
|
|
80
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Tumble — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Tumble.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The outgoing image is thrown away like a rigid card, tumbling end over end with a slight spin as it flies off into the distance in perspective, its darker back showing on every flip and its soft shadow shrinking on the incoming image behind it
|
|
5
|
+
// Tags: 3d, rotate, flip, card, perspective
|
|
6
|
+
|
|
7
|
+
// @range(-4, 4) Number of turns end over end, negative to tumble the other way
|
|
8
|
+
uniform float flips; // = 2.0
|
|
9
|
+
// @range(-1, 1) Turns of the secondary spin around the line of sight
|
|
10
|
+
uniform float spin; // = 0.15
|
|
11
|
+
// @param Where the card flies toward on screen, in frame heights from the center
|
|
12
|
+
uniform vec2 direction; // = vec2(0.0, 0.3)
|
|
13
|
+
// @range(0.1, 1) Strength of the perspective
|
|
14
|
+
uniform float perspective; // = 0.6
|
|
15
|
+
// @range(0, 1) Shading of the card as it turns, darkness of its back and of its shadow
|
|
16
|
+
uniform float shading; // = 0.7
|
|
17
|
+
|
|
18
|
+
const float PI = 3.141592653589793;
|
|
19
|
+
// width of the anti-aliased card edges, in frame heights
|
|
20
|
+
const float EDGE = 0.0015;
|
|
21
|
+
// direction toward the light: above, to the right, in front
|
|
22
|
+
const vec3 LIGHT = vec3(0.348, 0.696, -0.628);
|
|
23
|
+
|
|
24
|
+
// rotates v around the line of sight
|
|
25
|
+
vec3 roll(vec3 v, float c, float s) {
|
|
26
|
+
return vec3(c * v.x - s * v.y, s * v.x + c * v.y, v.z);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// signed distance to the card's rectangle, in its plane
|
|
30
|
+
float cardDistance(vec2 q) {
|
|
31
|
+
vec2 e = abs(q) - vec2(0.5 * ratio, 0.5);
|
|
32
|
+
return max(e.x, e.y);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// casts the ray d from the eye onto the card's plane, rel being the card's center from the eye:
|
|
36
|
+
// (the point hit in the card's axes, the distance along d), or a negative distance when it misses
|
|
37
|
+
vec3 castOnCard(vec3 d, vec3 rel, vec3 U, vec3 V, vec3 N) {
|
|
38
|
+
float dn = dot(d, N);
|
|
39
|
+
if (abs(dn) < 1e-6) return vec3(0.0, 0.0, -1.0);
|
|
40
|
+
float k = dot(rel, N) / dn;
|
|
41
|
+
vec3 h = k * d - rel;
|
|
42
|
+
return vec3(dot(h, U), dot(h, V), k);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
vec2 cardUv(vec2 q) {
|
|
46
|
+
return clamp(vec2(q.x / ratio, q.y) + 0.5, 0.0, 1.0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
vec4 transition(vec2 uv) {
|
|
50
|
+
// the card is gone a little before the end
|
|
51
|
+
float t = clamp(progress / 0.95, 0.0, 1.0);
|
|
52
|
+
// its size on screen shrinks faster and faster, down to a few percent
|
|
53
|
+
float size = exp(-2.8 * t * t * (0.4 + 0.6 * t));
|
|
54
|
+
float away = 1.0 - size;
|
|
55
|
+
// it spins at its own pace, starting smoothly
|
|
56
|
+
float turn = t * t * (3.0 - 2.0 * t);
|
|
57
|
+
float a = 2.0 * PI * flips * turn;
|
|
58
|
+
float r = 2.0 * PI * spin * turn;
|
|
59
|
+
float cr = cos(r), sr = sin(r);
|
|
60
|
+
// end over end around its horizontal axis, then around the line of sight
|
|
61
|
+
vec3 U = roll(vec3(1.0, 0.0, 0.0), cr, sr);
|
|
62
|
+
vec3 V = roll(vec3(0.0, cos(a), sin(a)), cr, sr);
|
|
63
|
+
vec3 N = roll(vec3(0.0, -sin(a), cos(a)), cr, sr);
|
|
64
|
+
|
|
65
|
+
// the camera, at dist in front of the plane z = 0, sees the frame at rest on it
|
|
66
|
+
float dist = 1.0 / clamp(perspective, 0.1, 1.0);
|
|
67
|
+
// the card's center, seen at direction * away on screen while it goes away, with a slight rise
|
|
68
|
+
vec2 seen = direction * away + vec2(0.0, 0.12 * t * (1.0 - t));
|
|
69
|
+
vec3 rel = vec3(seen / size, dist / size);
|
|
70
|
+
float fade = 1.0 - smoothstep(0.8, 1.0, t);
|
|
71
|
+
float shadowAmount = 0.6 * shading * sqrt(size) * fade;
|
|
72
|
+
|
|
73
|
+
vec2 p = vec2((uv.x - 0.5) * ratio, uv.y - 0.5);
|
|
74
|
+
vec4 color = getToColor(uv);
|
|
75
|
+
|
|
76
|
+
// the soft shadow on the incoming image, cast down and to the left, shrinking with the card
|
|
77
|
+
if (shadowAmount > 0.0) {
|
|
78
|
+
vec3 ds = vec3(p - vec2(-0.05, -0.08) * min(4.0 * t, 1.0) * size, dist);
|
|
79
|
+
vec3 hs = castOnCard(ds, rel, U, V, N);
|
|
80
|
+
if (hs.z > 0.0) {
|
|
81
|
+
float blur = 0.005 + 0.06 * min(3.0 * t, 1.0) * size;
|
|
82
|
+
float sd = cardDistance(hs.xy) * max(abs(dot(ds, N)) / length(ds), 0.05) / hs.z;
|
|
83
|
+
float sh = (1.0 - smoothstep(-blur, blur, sd)) * getFromColor(cardUv(hs.xy)).a;
|
|
84
|
+
color.rgb *= 1.0 - shadowAmount * sh;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// cast the ray onto the card
|
|
89
|
+
vec3 d = vec3(p, dist);
|
|
90
|
+
vec3 hit = castOnCard(d, rel, U, V, N);
|
|
91
|
+
if (hit.z <= 0.0) return color;
|
|
92
|
+
float dn = dot(d, N);
|
|
93
|
+
// anti-aliased edges: a screen pixel covers more of the card when it is far or seen at a grazing angle
|
|
94
|
+
float grazing = max(abs(dn) / length(d), 0.05);
|
|
95
|
+
float e = EDGE * min(20.0 * t, 1.0) * hit.z / grazing;
|
|
96
|
+
float m = clamp(0.5 - cardDistance(hit.xy) / max(e, 1e-6), 0.0, 1.0) * fade;
|
|
97
|
+
if (m <= 0.0) return color;
|
|
98
|
+
|
|
99
|
+
vec4 card = getFromColor(cardUv(hit.xy));
|
|
100
|
+
// the side facing the camera: the front, or the back which shows the image through, darker and duller
|
|
101
|
+
bool front = dn > 0.0;
|
|
102
|
+
vec3 facing = front ? -N : N;
|
|
103
|
+
float lit = min((0.35 + 0.65 * max(dot(facing, LIGHT), 0.0)) / (0.35 + 0.65 * -LIGHT.z), 1.0);
|
|
104
|
+
float shade = mix(1.0, lit * (front ? 1.0 : 0.55), shading);
|
|
105
|
+
if (!front) card.rgb = mix(card.rgb, vec3(dot(card.rgb, vec3(0.299, 0.587, 0.114))), 0.4 * shading);
|
|
106
|
+
// a glint as the card turns through the light, a light added to the image
|
|
107
|
+
float glint = pow(max(dot(facing, normalize(LIGHT - normalize(d))), 0.0), 60.0);
|
|
108
|
+
card.rgb = card.rgb * shade + 0.35 * shading * glint * smoothstep(0.0, 0.2, t);
|
|
109
|
+
if (m >= 1.0) return card;
|
|
110
|
+
// blend premultiplied, so that a transparent layer gives no color to the other one
|
|
111
|
+
vec4 mixed = mix(vec4(color.rgb * color.a, color.a), vec4(card.rgb * card.a, card.a), m);
|
|
112
|
+
return mixed.a > 0.0 ? vec4(mixed.rgb / mixed.a, mixed.a) : vec4(0.0);
|
|
113
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// WarpSpeed — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/WarpSpeed.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The camera jumps to light speed: star streaks shoot out from the center and stretch longer and longer while the outgoing image is pulled into a radial smear, then after a flash the incoming image emerges from the center as the streaks shrink back
|
|
5
|
+
// Tags: zoom, radial, light, motion-blur, space
|
|
6
|
+
|
|
7
|
+
// @param Point the camera flies toward, from (0, 0) at the bottom left to (1, 1) at the top right
|
|
8
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
9
|
+
// @range(20, 400) Number of star streaks around the center
|
|
10
|
+
uniform float streaks; // = 160.0
|
|
11
|
+
// @color Color of the streaks and of the flash, added as light
|
|
12
|
+
uniform vec4 streakColor; // = vec4(0.78, 0.88, 1.0, 1.0)
|
|
13
|
+
// @range(0, 1) Length of the streaks and of the radial smear
|
|
14
|
+
uniform float strength; // = 0.6
|
|
15
|
+
// @range(0, 1) Brightness of the flash at the peak of the jump
|
|
16
|
+
uniform float flash; // = 0.5
|
|
17
|
+
|
|
18
|
+
const float PI = 3.141592653589793;
|
|
19
|
+
const int TAPS = 12;
|
|
20
|
+
|
|
21
|
+
float hash(vec2 p) {
|
|
22
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
23
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
24
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// one layer of stars: one per angular cell, flying outward and stretched along its ray
|
|
28
|
+
float stars(float a, float r, float n, float layer, float travel, float speed, float reach) {
|
|
29
|
+
float cell = floor(a * n);
|
|
30
|
+
float h1 = hash(vec2(cell, layer));
|
|
31
|
+
float h2 = hash(vec2(cell, layer + 17.0));
|
|
32
|
+
float h3 = hash(vec2(cell, layer + 31.0));
|
|
33
|
+
// where the star is in its flight, from near the center to past the corners,
|
|
34
|
+
// speeding up as it comes closer
|
|
35
|
+
float life = fract(h1 + travel * (0.6 + 0.8 * h2));
|
|
36
|
+
float head = reach * (0.05 + 1.05 * pow(life, 1.4));
|
|
37
|
+
// the streak is the path of the star during the exposure: longer when the camera is faster
|
|
38
|
+
float tail = head * (1.0 - min(0.9, speed * (0.15 + 0.5 * h3)));
|
|
39
|
+
float along = clamp((r - tail) / max(head - tail, 1e-4), 0.0, 1.0);
|
|
40
|
+
float inside = step(tail, r) * (1.0 - smoothstep(head - 0.006, head, r));
|
|
41
|
+
// brightest at the head, fading toward the tail
|
|
42
|
+
float profile = inside * along * along;
|
|
43
|
+
// thin across the ray, a bit wider away from the center, with a faint halo,
|
|
44
|
+
// faded out before the edges of the cell so that no seam shows between cells
|
|
45
|
+
float f = fract(a * n);
|
|
46
|
+
float cellWidth = 2.0 * PI * r / n;
|
|
47
|
+
float offset = 0.3 + 0.4 * h3;
|
|
48
|
+
float across = (f - offset) * cellWidth;
|
|
49
|
+
float width = min(0.0014 + 0.002 * r / reach, 0.15 * cellWidth);
|
|
50
|
+
float x = across * across / (width * width);
|
|
51
|
+
float line = (exp(-x) + 0.25 * exp(-x / 9.0)) * smoothstep(0.0, 0.2, min(f, 1.0 - f));
|
|
52
|
+
// fade in from far away, out past the frame, and only some cells hold a star
|
|
53
|
+
float fade = smoothstep(0.0, 0.2, life) * (1.0 - smoothstep(0.9, 1.0, life));
|
|
54
|
+
return profile * line * fade * (0.4 + 0.6 * h2) * step(0.25, hash(vec2(cell, layer + 43.0)));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// an image pulled into a radial smear toward the center: scaled by k, blurred over a fraction b
|
|
58
|
+
vec4 smear(vec2 uv, float k, float b, float jitter, bool incoming) {
|
|
59
|
+
if (b <= 0.0 && k >= 1.0) {
|
|
60
|
+
vec4 c = incoming ? getToColor(uv) : getFromColor(uv);
|
|
61
|
+
return vec4(c.rgb * c.a, c.a);
|
|
62
|
+
}
|
|
63
|
+
vec4 sum = vec4(0.0);
|
|
64
|
+
for (int i = 0; i < TAPS; i++) {
|
|
65
|
+
float s = k * (1.0 - b * (float(i) + jitter) / float(TAPS));
|
|
66
|
+
vec2 q = center + (uv - center) * s;
|
|
67
|
+
vec4 c = incoming ? getToColor(q) : getFromColor(q);
|
|
68
|
+
sum += vec4(c.rgb * c.a, c.a);
|
|
69
|
+
}
|
|
70
|
+
return sum / float(TAPS);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
vec4 transition(vec2 uv) {
|
|
74
|
+
float p = progress;
|
|
75
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
76
|
+
vec2 d = (uv - center) * aspect;
|
|
77
|
+
float r = length(d);
|
|
78
|
+
// (nudged off zero, where atan is undefined)
|
|
79
|
+
float a = atan(d.y, d.x + 1e-6) / (2.0 * PI) + 0.5;
|
|
80
|
+
// distance from the center to the farthest corner
|
|
81
|
+
vec2 far = max(center, 1.0 - center) * aspect;
|
|
82
|
+
float reach = length(far);
|
|
83
|
+
|
|
84
|
+
// the camera speeds up to the jump, at the middle, then slows down
|
|
85
|
+
float speed = sin(PI * p);
|
|
86
|
+
speed *= speed;
|
|
87
|
+
float travel = 3.0 * (p - sin(2.0 * PI * p) / (2.0 * PI));
|
|
88
|
+
float jitter = hash(floor(uv * aspect * 997.0));
|
|
89
|
+
|
|
90
|
+
// the outgoing image is pulled forward into the smear; the incoming one arrives
|
|
91
|
+
// magnified and smeared, and settles
|
|
92
|
+
float goOut = smoothstep(0.0, 0.55, p);
|
|
93
|
+
float goIn = 1.0 - smoothstep(0.45, 1.0, p);
|
|
94
|
+
// the incoming image emerges from the center and spreads out to the corners
|
|
95
|
+
float soft = 0.35 * reach;
|
|
96
|
+
float edge = mix(-soft, reach + soft, smoothstep(0.42, 0.78, p));
|
|
97
|
+
float m = 1.0 - smoothstep(edge - soft, edge, r);
|
|
98
|
+
vec4 before = vec4(0.0);
|
|
99
|
+
vec4 after = vec4(0.0);
|
|
100
|
+
if (m < 1.0) before = smear(uv, 1.0 - 0.3 * strength * goOut * goOut, 0.6 * strength * goOut, jitter, false);
|
|
101
|
+
if (m > 0.0) after = smear(uv, 1.0 - 0.3 * strength * goIn * goIn, 0.6 * strength * goIn, jitter, true);
|
|
102
|
+
vec4 c = mix(before, after, m);
|
|
103
|
+
// darker while in the jump, so that the streaks stand out, and brighter soon after it
|
|
104
|
+
// so the incoming image comes out clear
|
|
105
|
+
float dark = p < 0.5 ? speed : speed * speed * speed;
|
|
106
|
+
c.rgb *= 1.0 - 0.65 * (0.5 + 0.5 * strength) * dark;
|
|
107
|
+
|
|
108
|
+
// the streaks: two layers of stars, their length growing with the speed
|
|
109
|
+
float n = max(floor(streaks), 1.0);
|
|
110
|
+
float len = speed * (0.5 + 1.5 * strength);
|
|
111
|
+
float s = stars(a, r, n, 1.0, travel, len, reach);
|
|
112
|
+
s += stars(fract(a + 0.37), r, max(floor(n * 0.71), 1.0), 2.0, travel * 1.3, len, reach);
|
|
113
|
+
// the flash, brightest at the center, where the incoming image emerges
|
|
114
|
+
float core = r / (0.35 * reach);
|
|
115
|
+
float peak = (p - 0.5) * 9.0;
|
|
116
|
+
float glow = flash * exp(-peak * peak) * speed * (0.35 + 0.9 * exp(-core * core));
|
|
117
|
+
vec3 light = streakColor.rgb * streakColor.a * (2.2 * s * speed + glow);
|
|
118
|
+
// light is added to the image, but adds no opacity
|
|
119
|
+
return c.a > 0.0 ? vec4(clamp(c.rgb / c.a + light, 0.0, 1.0), c.a) : vec4(0.0);
|
|
120
|
+
}
|