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.
- package/CHANGELOG.md +80 -0
- package/compatibility.json +455 -11
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/BookFlip.glsl +124 -21
- package/glsl3/CircleBurst.glsl +77 -0
- package/glsl3/Clothesline.glsl +217 -0
- package/glsl3/CodeRain.glsl +114 -0
- package/glsl3/ComicPanels.glsl +174 -0
- package/glsl3/Cube.glsl +105 -52
- package/glsl3/CurtainRise.glsl +71 -0
- 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/GlitterDissolve.glsl +171 -0
- package/glsl3/GravityLens.glsl +66 -0
- package/glsl3/GridFlip.glsl +151 -56
- package/glsl3/HeartWipe.glsl +71 -11
- package/glsl3/InsideCube.glsl +114 -0
- package/glsl3/KeyholeWipe.glsl +104 -0
- package/glsl3/LedWall.glsl +127 -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/RingSpin.glsl +112 -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/SpotlightWipe.glsl +63 -0
- package/glsl3/Swirl.glsl +52 -21
- package/glsl3/TruchetWipe.glsl +80 -0
- package/glsl3/Tumble.glsl +113 -0
- package/glsl3/WaterDrop.glsl +69 -13
- package/glsl3/WaveWipe.glsl +154 -0
- package/index.js +1 -1
- package/layouts.json +1232 -29
- package/llms-full.txt +890 -403
- package/llms.txt +225 -197
- package/msl/BookFlip.metal +575 -114
- package/msl/CircleBurst.metal +351 -0
- package/msl/Clothesline.metal +828 -0
- package/msl/CodeRain.metal +451 -0
- package/msl/ComicPanels.metal +959 -0
- package/msl/Cube.metal +466 -170
- package/msl/CurtainRise.metal +263 -0
- 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/GlitterDissolve.metal +637 -0
- package/msl/GravityLens.metal +236 -0
- package/msl/GridFlip.metal +548 -191
- package/msl/HeartWipe.metal +230 -58
- package/msl/InsideCube.metal +537 -0
- package/msl/KeyholeWipe.metal +370 -0
- package/msl/LedWall.metal +437 -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/RingSpin.metal +474 -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/SpotlightWipe.metal +217 -0
- package/msl/Swirl.metal +144 -77
- package/msl/TruchetWipe.metal +285 -0
- package/msl/Tumble.metal +466 -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 +115 -57
- package/sksl/BookFlip.sksl +117 -20
- package/sksl/CircleBurst.sksl +84 -0
- package/sksl/Clothesline.sksl +217 -0
- package/sksl/CodeRain.sksl +124 -0
- package/sksl/ComicPanels.sksl +176 -0
- package/sksl/Cube.sksl +99 -46
- package/sksl/CurtainRise.sksl +84 -0
- 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/GlitterDissolve.sksl +175 -0
- package/sksl/GravityLens.sksl +77 -0
- package/sksl/GridFlip.sksl +141 -52
- package/sksl/HeartWipe.sksl +60 -11
- package/sksl/InsideCube.sksl +123 -0
- package/sksl/KeyholeWipe.sksl +109 -0
- package/sksl/LedWall.sksl +137 -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/RingSpin.sksl +121 -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/SpotlightWipe.sksl +74 -0
- package/sksl/Swirl.sksl +49 -20
- package/sksl/TruchetWipe.sksl +92 -0
- package/sksl/Tumble.sksl +122 -0
- package/sksl/WaterDrop.sksl +64 -10
- package/sksl/WaveWipe.sksl +165 -0
- package/sksl/index.js +1 -1
- package/transitions/BookFlip.glsl +124 -21
- package/transitions/CircleBurst.glsl +76 -0
- package/transitions/Clothesline.glsl +216 -0
- package/transitions/CodeRain.glsl +113 -0
- package/transitions/ComicPanels.glsl +173 -0
- package/transitions/Cube.glsl +105 -52
- package/transitions/CurtainRise.glsl +70 -0
- 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/GlitterDissolve.glsl +170 -0
- package/transitions/GravityLens.glsl +65 -0
- package/transitions/GridFlip.glsl +151 -56
- package/transitions/HeartWipe.glsl +71 -11
- package/transitions/InsideCube.glsl +113 -0
- package/transitions/KeyholeWipe.glsl +103 -0
- package/transitions/LedWall.glsl +126 -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/RingSpin.glsl +111 -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/SpotlightWipe.glsl +62 -0
- package/transitions/Swirl.glsl +52 -21
- package/transitions/TruchetWipe.glsl +79 -0
- package/transitions/Tumble.glsl +112 -0
- package/transitions/WaterDrop.glsl +69 -13
- package/transitions/WaveWipe.glsl +153 -0
- package/wgsl/BookFlip.wgsl +552 -105
- package/wgsl/CircleBurst.wgsl +310 -0
- package/wgsl/Clothesline.wgsl +756 -0
- package/wgsl/CodeRain.wgsl +415 -0
- package/wgsl/ComicPanels.wgsl +886 -0
- package/wgsl/Cube.wgsl +461 -156
- package/wgsl/CurtainRise.wgsl +235 -0
- 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/GlitterDissolve.wgsl +582 -0
- package/wgsl/GravityLens.wgsl +206 -0
- package/wgsl/GridFlip.wgsl +523 -188
- package/wgsl/HeartWipe.wgsl +225 -55
- package/wgsl/InsideCube.wgsl +496 -0
- package/wgsl/KeyholeWipe.wgsl +337 -0
- package/wgsl/LedWall.wgsl +397 -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/RingSpin.wgsl +426 -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/SpotlightWipe.wgsl +186 -0
- package/wgsl/Swirl.wgsl +138 -77
- package/wgsl/TruchetWipe.wgsl +255 -0
- package/wgsl/Tumble.wgsl +424 -0
- package/wgsl/WaterDrop.wgsl +251 -49
- package/wgsl/WaveWipe.wgsl +581 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A breaking wave crashes across the frame, its lip curling over in front of its face and throwing foam and spray ahead, its shadow darkening the outgoing image; the incoming image is left behind it, tinted and bent by the water, clearing as the wave passes
|
|
4
|
+
// Tags: water, wave, ocean, foam, directional, reveal
|
|
5
|
+
|
|
6
|
+
// @param Direction the wave travels toward
|
|
7
|
+
uniform vec2 direction; // = vec2(1.0, 0.0)
|
|
8
|
+
// @range(0.1, 0.45) Size of the curling lip, in wave heights: how far it overhangs ahead of the face
|
|
9
|
+
uniform float curl; // = 0.3
|
|
10
|
+
// @range(0, 1) Amount of foam on the crest and spray thrown ahead of it
|
|
11
|
+
uniform float foam; // = 0.6
|
|
12
|
+
// @range(0, 0.1) How much the water bends the incoming image behind the wave
|
|
13
|
+
uniform float refraction; // = 0.04
|
|
14
|
+
// @color Color of the water tinting the incoming image behind the wave (its alpha is its strength)
|
|
15
|
+
uniform vec4 water; // = vec4(0.05, 0.36, 0.46, 0.75)
|
|
16
|
+
// @color Color of the foam and spray (its alpha is its strength)
|
|
17
|
+
uniform vec4 foamColor; // = vec4(1.0, 1.0, 1.0, 1.0)
|
|
18
|
+
|
|
19
|
+
const float PI = 3.141592653589793;
|
|
20
|
+
// half width of the antialiased edges, in wave heights
|
|
21
|
+
const float AA = 0.002;
|
|
22
|
+
// how far the base of the face trails behind its top, in wave heights
|
|
23
|
+
const float TRAIL = 0.35;
|
|
24
|
+
// how far behind the face the water still tints the incoming image, in wave heights
|
|
25
|
+
const float BAND = 0.4;
|
|
26
|
+
// how far ahead of the lip the spray reaches, in wave heights
|
|
27
|
+
const float REACH = 0.25;
|
|
28
|
+
|
|
29
|
+
float hash12(vec2 v) {
|
|
30
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
31
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
32
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
float vnoise(vec2 v) {
|
|
36
|
+
vec2 i = floor(v);
|
|
37
|
+
vec2 f = fract(v);
|
|
38
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
39
|
+
return mix(
|
|
40
|
+
mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
|
|
41
|
+
mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
|
|
42
|
+
f.y
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// folds coordinates back into the frame, so a displaced image never shows its clamped edges
|
|
47
|
+
vec2 mirror(vec2 v) {
|
|
48
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// droplets scattered in cells, one per cell at most, kept inside their cell
|
|
52
|
+
float droplets(vec2 q, float cell, float density, float seed) {
|
|
53
|
+
vec2 g = q / cell;
|
|
54
|
+
vec2 id = floor(g);
|
|
55
|
+
if (hash12(id + seed) >= density) return 0.0;
|
|
56
|
+
float r = 0.1 + 0.2 * hash12(id + seed + 4.7);
|
|
57
|
+
vec2 c = id + 0.5 + (0.45 - r) * (vec2(hash12(id + seed + 1.3), hash12(id + seed + 8.1)) * 2.0 - 1.0);
|
|
58
|
+
float px = AA / cell;
|
|
59
|
+
return 1.0 - smoothstep(r - px, r + px, length(g - c));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
vec4 transition(vec2 uv) {
|
|
63
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
64
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
65
|
+
float t = progress;
|
|
66
|
+
|
|
67
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
68
|
+
// the crest points up the frame, or to the left when the wave travels straight up or down
|
|
69
|
+
vec2 up = vec2(-dir.y, dir.x);
|
|
70
|
+
if (up.y < 0.0 || (up.y == 0.0 && up.x > 0.0)) up = -up;
|
|
71
|
+
// half extents of the frame along the travel and across it, in frame heights
|
|
72
|
+
float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
|
|
73
|
+
float w = 0.5 * (abs(up.x) * ratio + abs(up.y));
|
|
74
|
+
// in wave heights: u along the travel, v from the trough (0) to the crest (1)
|
|
75
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0) / (2.0 * w);
|
|
76
|
+
vec2 q = vec2(dot(p, dir), dot(p, up) + 0.5);
|
|
77
|
+
float E = e / (2.0 * w);
|
|
78
|
+
|
|
79
|
+
float R = max(curl, 0.01);
|
|
80
|
+
// radius of the hollow at the back of the curl, where it meets the face
|
|
81
|
+
float Rb = 0.5 * R;
|
|
82
|
+
// the lip pitches forward, then curls further down as the wave travels
|
|
83
|
+
float tipAngle = PI * (0.08 - 0.5 * smoothstep(0.0, 0.85, t));
|
|
84
|
+
// the wave sweeps from fully ahead of the frame, spray included, to fully past it, tinted water included
|
|
85
|
+
float travel = mix(t, t * t * (3.0 - 2.0 * t), 0.25);
|
|
86
|
+
vec2 C = vec2(mix(-E - R - REACH, E + Rb + TRAIL + BAND, travel), 1.02 - R);
|
|
87
|
+
|
|
88
|
+
// polar coordinates around the center of the curl
|
|
89
|
+
vec2 d = q - C;
|
|
90
|
+
// atan is undefined at the very center
|
|
91
|
+
if (d.x == 0.0) d.x = 1e-6;
|
|
92
|
+
float r = length(d);
|
|
93
|
+
float ang = atan(d.y, d.x);
|
|
94
|
+
// the inner surface of the curl spirals in from the tip of the lip (zero thickness) to the back of the hollow
|
|
95
|
+
float k = clamp((ang - tipAngle) / (PI - tipAngle), 0.0, 1.0);
|
|
96
|
+
float rIn = R - (R - Rb) * (1.0 - (1.0 - k) * (1.0 - k));
|
|
97
|
+
bool curled = ang >= tipAngle;
|
|
98
|
+
// the face below the curl: vertical where it meets the hollow, its base trailing behind
|
|
99
|
+
float s = 1.0 - clamp(q.y / C.y, 0.0, 1.0);
|
|
100
|
+
float face = C.x - Rb - TRAIL * s * s;
|
|
101
|
+
float behind = face - q.x; // > 0 behind the face
|
|
102
|
+
|
|
103
|
+
float wet;
|
|
104
|
+
if (curled) {
|
|
105
|
+
wet = smoothstep(-AA, AA, r - rIn) * (ang > 0.5 * PI ? 1.0 : 1.0 - smoothstep(-AA, AA, r - R));
|
|
106
|
+
} else {
|
|
107
|
+
wet = smoothstep(-AA, AA, behind);
|
|
108
|
+
}
|
|
109
|
+
// the lip: the curl in front of the top of the wave
|
|
110
|
+
float lip = curled ? 1.0 - smoothstep(0.5 * PI - 0.3, 0.5 * PI + 0.5, ang) : 0.0;
|
|
111
|
+
|
|
112
|
+
float n = vnoise(q * vec2(14.0, 10.0) + vec2(-9.0 * t, 3.0 * t));
|
|
113
|
+
|
|
114
|
+
// outgoing image, darkened in the hollow and in the shadow of the overhang just ahead of it
|
|
115
|
+
vec4 a = getFromColor(uv);
|
|
116
|
+
float gap = max(min(r - R, -behind), 0.0);
|
|
117
|
+
float shade = 0.55 * exp(-gap / 0.1) * (1.0 - smoothstep(0.0, REACH, gap)) * smoothstep(0.0, 0.6, q.y) * (1.0 - smoothstep(C.y + 0.2 * R, C.y + 1.1 * R, q.y));
|
|
118
|
+
shade += 0.25 * (1.0 - smoothstep(0.0, R, r));
|
|
119
|
+
a.rgb *= 1.0 - shade;
|
|
120
|
+
// spray thrown ahead of the crest, drifting forward and falling, and a mist along it
|
|
121
|
+
float fwd = max(r - R, 0.0);
|
|
122
|
+
float zone = smoothstep(tipAngle - 0.4, tipAngle + 0.2, ang) * (1.0 - smoothstep(0.0, REACH, fwd)) * step(0.0, r - R);
|
|
123
|
+
// stretched along the throw, so the droplets streak forward
|
|
124
|
+
vec2 sq = (d - t * vec2(0.5, -0.25)) * vec2(0.55, 1.0);
|
|
125
|
+
float thin = exp(-fwd / 0.12);
|
|
126
|
+
float spray = droplets(sq, 0.02, foam * thin, 1.0) + 0.6 * droplets(sq * 1.6 + 3.1, 0.02, foam * thin, 7.0);
|
|
127
|
+
// the mist hugs the outside of the lip only
|
|
128
|
+
float mist = foam * n * n * exp(-fwd / 0.06) * (1.0 - smoothstep(0.0, REACH, fwd)) * smoothstep(-AA, AA, r - R) * smoothstep(tipAngle, tipAngle + 0.3, ang);
|
|
129
|
+
a.rgb = mix(a.rgb, foamColor.rgb, foamColor.a * clamp(spray * zone + mist, 0.0, 1.0));
|
|
130
|
+
|
|
131
|
+
// incoming image behind the face, bent and tinted by the water, clearing further behind
|
|
132
|
+
float band = max(1.0 - smoothstep(0.05, BAND, behind), lip);
|
|
133
|
+
float bend = refraction * band * band;
|
|
134
|
+
vec2 off = bend * (dir * sin(17.0 * q.y + 2.0 * sin(9.0 * q.x) - 6.0 * t) + up * cos(13.0 * q.x - 5.0 * t));
|
|
135
|
+
vec4 b = getToColor(mirror(uv + off * 2.0 * w / vec2(ratio, 1.0)));
|
|
136
|
+
float luma = dot(b.rgb, vec3(0.299, 0.587, 0.114));
|
|
137
|
+
// lit near the top of the face and through the thin lip, darker on the underside of the lip
|
|
138
|
+
vec3 tinted = water.rgb * (0.4 + 0.9 * luma) * (1.0 + 0.6 * q.y);
|
|
139
|
+
tinted += 0.18 * lip * (1.0 - k) * vec3(0.5, 1.0, 0.9);
|
|
140
|
+
tinted *= 1.0 - 0.35 * lip * (1.0 - smoothstep(0.0, 0.06, r - rIn));
|
|
141
|
+
// a bright line along the surface of the face, fading up into the hollow
|
|
142
|
+
tinted += 0.35 * (curled ? k * (1.0 - smoothstep(0.0, 0.015, r - rIn)) : 1.0 - smoothstep(0.0, 0.015, behind)) * vec3(0.7, 0.95, 1.0);
|
|
143
|
+
b.rgb = mix(b.rgb, tinted, water.a * band);
|
|
144
|
+
|
|
145
|
+
// foam: whitewater along the outer edge of the lip, and churning at the base of the face
|
|
146
|
+
float crest = curled ? (1.0 - smoothstep(0.01, 0.02 + 0.12 * n, abs(R - r))) * smoothstep(tipAngle, tipAngle + 0.4, ang) * (1.0 - smoothstep(0.5 * PI + 0.2, 0.5 * PI + 0.8, ang)) : 0.0;
|
|
147
|
+
float churn = (1.0 - smoothstep(0.0, 0.15 + 0.1 * n, q.y)) * (1.0 - smoothstep(0.0, 0.3, abs(behind))) * smoothstep(0.3, 0.7, n);
|
|
148
|
+
b.rgb = mix(b.rgb, foamColor.rgb, foamColor.a * clamp(foam * 1.5 * (crest + churn), 0.0, 1.0));
|
|
149
|
+
|
|
150
|
+
// mixed premultiplied, so transparent images do not bleed their color
|
|
151
|
+
vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), wet);
|
|
152
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
153
|
+
}
|