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,63 @@
|
|
|
1
|
+
// SpotlightWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/SpotlightWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// Description: The stage lights go down on the outgoing image and a soft oval spotlight searches across it along a curved path, comes to rest and lights the incoming image inside it, then widens until the stage lights come back up on the incoming image
|
|
5
|
+
// Tags: light, spotlight, stage, iris, reveal
|
|
6
|
+
|
|
7
|
+
// @param Point where the spotlight comes to rest and opens from
|
|
8
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
9
|
+
// @range(0.08, 0.45) Width of the spotlight while it searches, in frame heights
|
|
10
|
+
uniform float size; // = 0.3
|
|
11
|
+
// @range(0, 1) How dark the stage gets around the spotlight
|
|
12
|
+
uniform float darkness; // = 0.85
|
|
13
|
+
// @color Tint of the spotlight
|
|
14
|
+
uniform vec3 warmth; // = vec3(1.0, 0.93, 0.8)
|
|
15
|
+
|
|
16
|
+
// height of the oval over its width: a cone of light hitting a stage seen at an angle
|
|
17
|
+
const float FLAT = 0.72;
|
|
18
|
+
// distance to the spotlight's center, in oval radii, inside which the incoming image is fully lit
|
|
19
|
+
const float LIT = 0.74;
|
|
20
|
+
|
|
21
|
+
// a point of the curved path the spotlight searches along, from the lower left to its resting point
|
|
22
|
+
vec2 path(float t, vec2 c) {
|
|
23
|
+
vec2 a = vec2(0.08, 0.3);
|
|
24
|
+
vec2 b = vec2(0.35, 1.15);
|
|
25
|
+
vec2 d = vec2(1.05, 0.95);
|
|
26
|
+
float s = 1.0 - t;
|
|
27
|
+
return s * s * s * a + 3.0 * s * s * t * b + 3.0 * s * t * t * d + t * t * t * c;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
vec4 transition(vec2 uv) {
|
|
31
|
+
vec2 asp = vec2(ratio, 1.0);
|
|
32
|
+
float p = progress;
|
|
33
|
+
|
|
34
|
+
// the spotlight slides along its path and eases to rest, its last few steps overlapping the start
|
|
35
|
+
// of its widening so the motion never stops
|
|
36
|
+
float t = clamp(p / 0.5, 0.0, 1.0);
|
|
37
|
+
t = t * t * (3.0 - 2.0 * t);
|
|
38
|
+
vec2 c = path(t, center);
|
|
39
|
+
|
|
40
|
+
// it widens until its lit core covers the farthest corner of the frame
|
|
41
|
+
vec2 far = max(center, 1.0 - center) * asp;
|
|
42
|
+
float full = length(vec2(far.x, far.y / FLAT)) / LIT;
|
|
43
|
+
float g = smoothstep(0.44, 1.0, p);
|
|
44
|
+
float radius = mix(0.5 * size, full, g * (0.3 + 0.7 * g));
|
|
45
|
+
|
|
46
|
+
// distance to the spotlight's center, 1 on the oval's edge
|
|
47
|
+
vec2 q = (uv - c) * asp;
|
|
48
|
+
float r = length(vec2(q.x, q.y / FLAT)) / radius;
|
|
49
|
+
|
|
50
|
+
// light of the spotlight: a flat core, a soft penumbra, a slightly brighter rim and a faint spill
|
|
51
|
+
float core = 1.0 - smoothstep(0.72, 1.08, r);
|
|
52
|
+
float ring = (r - 0.9) / 0.09;
|
|
53
|
+
float spot = max(core * (1.0 - 0.1 * r * r), 0.12 * (1.0 - smoothstep(0.9, 2.4, r))) + 0.16 * exp(-ring * ring);
|
|
54
|
+
|
|
55
|
+
// the stage lights go down at the start and come back up at the end
|
|
56
|
+
float s = darkness * smoothstep(0.0, 0.18, p) * (1.0 - smoothstep(0.72, 1.0, p));
|
|
57
|
+
vec3 light = 1.0 - s + s * spot * warmth;
|
|
58
|
+
|
|
59
|
+
// as it comes to rest, the spotlight lights the incoming image inside it
|
|
60
|
+
float lit = smoothstep(0.42, 0.58, p) * (1.0 - smoothstep(LIT, 1.0, r));
|
|
61
|
+
vec4 col = mix(getFromColor(uv), getToColor(uv), lit);
|
|
62
|
+
return vec4(col.rgb * light, col.a);
|
|
63
|
+
}
|
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
|
+
}
|
package/glsl3/WaterDrop.glsl
CHANGED
|
@@ -1,21 +1,77 @@
|
|
|
1
1
|
// WaterDrop — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/WaterDrop.glsl
|
|
2
2
|
// Author: Paweł Płóciennik
|
|
3
3
|
// License: MIT
|
|
4
|
-
// Description:
|
|
5
|
-
// Tags: ripple, water,
|
|
6
|
-
// @
|
|
4
|
+
// Description: A drop falls into the image like into still water: round ripples spread out from where it hits, bending the image with glints on their slopes, the incoming image shows up inside the leading ripple, and the water calms down
|
|
5
|
+
// Tags: ripple, water, refraction, circle
|
|
6
|
+
// @range(10, 80) Frequency of the ripples: higher makes them closer together
|
|
7
7
|
uniform float amplitude; // = 30
|
|
8
|
-
// @
|
|
8
|
+
// @range(0, 80) Speed of the ripples as they run outward through the spreading rings
|
|
9
9
|
uniform float speed; // = 30
|
|
10
|
+
// @param Where the drop falls, in texture coordinates
|
|
11
|
+
uniform vec2 center; // = vec2(0.5, 0.5)
|
|
12
|
+
// @range(0, 0.08) How far the ripples bend the image, in frame heights
|
|
13
|
+
uniform float refraction; // = 0.015
|
|
14
|
+
// @range(0, 1) Brightness of the glints on the ripples
|
|
15
|
+
uniform float highlight; // = 0.5
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
// mirror the coordinates back into the frame
|
|
18
|
+
vec2 mirror(vec2 v) {
|
|
19
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// height of the water, from -1 to 1, at a distance s inside the front
|
|
23
|
+
float wave(float s, float k, float lambda, float t) {
|
|
24
|
+
// it rises just ahead of the front and dies out a few ripples behind it
|
|
25
|
+
float env = smoothstep(-0.3 * lambda, 0.6 * lambda, s) * exp(-s / (3.5 * lambda));
|
|
26
|
+
// the ripples run out through the train, faster than the train itself spreads
|
|
27
|
+
return env * sin(k * s + speed * t);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
vec4 transition(vec2 uv) {
|
|
31
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
32
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
33
|
+
|
|
34
|
+
float k = 2.0 * max(amplitude, 1.0);
|
|
35
|
+
float lambda = 6.2831853 / k;
|
|
36
|
+
// measured in square pixels, so the ripples are round
|
|
37
|
+
vec2 q = (uv - center) * vec2(ratio, 1.0);
|
|
38
|
+
float r = length(q);
|
|
39
|
+
vec2 dir = r > 0.0 ? q / r : vec2(0.0);
|
|
40
|
+
// the farthest corner of the frame
|
|
41
|
+
vec2 far = max(center, 1.0 - center) * vec2(ratio, 1.0);
|
|
42
|
+
float R = length(far);
|
|
43
|
+
|
|
44
|
+
// the incoming image shows from a little behind the front, with a soft edge
|
|
45
|
+
float edge = 0.35 * lambda;
|
|
46
|
+
float soft = 0.1 * lambda;
|
|
47
|
+
// the front spreads out, slowing down a little, from just before the drop hits until
|
|
48
|
+
// its revealed area is past the farthest corner
|
|
49
|
+
float t = progress;
|
|
50
|
+
float e = mix(t, 1.0 - (1.0 - t) * (1.0 - t), 0.4);
|
|
51
|
+
float front = mix(-0.3 * lambda, R + edge + soft + 0.01, e);
|
|
52
|
+
float s = front - r;
|
|
53
|
+
|
|
54
|
+
// the water calms down at the end
|
|
55
|
+
float calm = 1.0 - smoothstep(0.55, 1.0, t);
|
|
56
|
+
calm *= calm;
|
|
57
|
+
// slope of the water along the radius, normalized to at most about 1
|
|
58
|
+
// (one-sided at the very center)
|
|
59
|
+
float d = 0.02 * lambda;
|
|
60
|
+
float r0 = max(r - d, 0.0);
|
|
61
|
+
float slope = calm * (wave(front - r - d, k, lambda, t) - wave(front - r0, k, lambda, t)) / ((r + d - r0) * k);
|
|
62
|
+
vec2 offset = dir * slope * refraction / vec2(ratio, 1.0);
|
|
63
|
+
|
|
64
|
+
vec4 ca = getFromColor(mirror(uv - offset));
|
|
65
|
+
vec4 cb = getToColor(mirror(uv - offset));
|
|
66
|
+
float m = smoothstep(edge - soft, edge + soft, s);
|
|
67
|
+
// mixed premultiplied, so transparent images do not bleed their color
|
|
68
|
+
vec4 c = mix(vec4(ca.rgb * ca.a, ca.a), vec4(cb.rgb * cb.a, cb.a), m);
|
|
14
69
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
70
|
+
// the slopes facing the light glint, the ones facing away darken a little,
|
|
71
|
+
// and the crests are a little brighter than the troughs
|
|
72
|
+
float h = calm * wave(s, k, lambda, t);
|
|
73
|
+
float lit = -dot(dir, normalize(vec2(-0.6, 0.8))) * slope;
|
|
74
|
+
float glint = highlight * (0.2 * h + 0.6 * smoothstep(0.2, 0.9, lit) - 0.3 * smoothstep(0.2, 0.9, -lit));
|
|
75
|
+
c.rgb = clamp(c.rgb + glint * c.a, 0.0, c.a);
|
|
76
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
21
77
|
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// WaveWipe — GLSL ES 3.00, generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/WaveWipe.glsl
|
|
2
|
+
// Author: gre
|
|
3
|
+
// License: MIT
|
|
4
|
+
// 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
|
|
5
|
+
// Tags: water, wave, ocean, foam, directional, reveal
|
|
6
|
+
|
|
7
|
+
// @param Direction the wave travels toward
|
|
8
|
+
uniform vec2 direction; // = vec2(1.0, 0.0)
|
|
9
|
+
// @range(0.1, 0.45) Size of the curling lip, in wave heights: how far it overhangs ahead of the face
|
|
10
|
+
uniform float curl; // = 0.3
|
|
11
|
+
// @range(0, 1) Amount of foam on the crest and spray thrown ahead of it
|
|
12
|
+
uniform float foam; // = 0.6
|
|
13
|
+
// @range(0, 0.1) How much the water bends the incoming image behind the wave
|
|
14
|
+
uniform float refraction; // = 0.04
|
|
15
|
+
// @color Color of the water tinting the incoming image behind the wave (its alpha is its strength)
|
|
16
|
+
uniform vec4 water; // = vec4(0.05, 0.36, 0.46, 0.75)
|
|
17
|
+
// @color Color of the foam and spray (its alpha is its strength)
|
|
18
|
+
uniform vec4 foamColor; // = vec4(1.0, 1.0, 1.0, 1.0)
|
|
19
|
+
|
|
20
|
+
const float PI = 3.141592653589793;
|
|
21
|
+
// half width of the antialiased edges, in wave heights
|
|
22
|
+
const float AA = 0.002;
|
|
23
|
+
// how far the base of the face trails behind its top, in wave heights
|
|
24
|
+
const float TRAIL = 0.35;
|
|
25
|
+
// how far behind the face the water still tints the incoming image, in wave heights
|
|
26
|
+
const float BAND = 0.4;
|
|
27
|
+
// how far ahead of the lip the spray reaches, in wave heights
|
|
28
|
+
const float REACH = 0.25;
|
|
29
|
+
|
|
30
|
+
float hash12(vec2 v) {
|
|
31
|
+
vec3 v3 = fract(vec3(v.xyx) * 0.1031);
|
|
32
|
+
v3 += dot(v3, v3.yzx + 33.33);
|
|
33
|
+
return fract((v3.x + v3.y) * v3.z);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
float vnoise(vec2 v) {
|
|
37
|
+
vec2 i = floor(v);
|
|
38
|
+
vec2 f = fract(v);
|
|
39
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
40
|
+
return mix(
|
|
41
|
+
mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
|
|
42
|
+
mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
|
|
43
|
+
f.y
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// folds coordinates back into the frame, so a displaced image never shows its clamped edges
|
|
48
|
+
vec2 mirror(vec2 v) {
|
|
49
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// droplets scattered in cells, one per cell at most, kept inside their cell
|
|
53
|
+
float droplets(vec2 q, float cell, float density, float seed) {
|
|
54
|
+
vec2 g = q / cell;
|
|
55
|
+
vec2 id = floor(g);
|
|
56
|
+
if (hash12(id + seed) >= density) return 0.0;
|
|
57
|
+
float r = 0.1 + 0.2 * hash12(id + seed + 4.7);
|
|
58
|
+
vec2 c = id + 0.5 + (0.45 - r) * (vec2(hash12(id + seed + 1.3), hash12(id + seed + 8.1)) * 2.0 - 1.0);
|
|
59
|
+
float px = AA / cell;
|
|
60
|
+
return 1.0 - smoothstep(r - px, r + px, length(g - c));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
vec4 transition(vec2 uv) {
|
|
64
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
65
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
66
|
+
float t = progress;
|
|
67
|
+
|
|
68
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(1.0, 0.0);
|
|
69
|
+
// the crest points up the frame, or to the left when the wave travels straight up or down
|
|
70
|
+
vec2 up = vec2(-dir.y, dir.x);
|
|
71
|
+
if (up.y < 0.0 || (up.y == 0.0 && up.x > 0.0)) up = -up;
|
|
72
|
+
// half extents of the frame along the travel and across it, in frame heights
|
|
73
|
+
float e = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
|
|
74
|
+
float w = 0.5 * (abs(up.x) * ratio + abs(up.y));
|
|
75
|
+
// in wave heights: u along the travel, v from the trough (0) to the crest (1)
|
|
76
|
+
vec2 p = (uv - 0.5) * vec2(ratio, 1.0) / (2.0 * w);
|
|
77
|
+
vec2 q = vec2(dot(p, dir), dot(p, up) + 0.5);
|
|
78
|
+
float E = e / (2.0 * w);
|
|
79
|
+
|
|
80
|
+
float R = max(curl, 0.01);
|
|
81
|
+
// radius of the hollow at the back of the curl, where it meets the face
|
|
82
|
+
float Rb = 0.5 * R;
|
|
83
|
+
// the lip pitches forward, then curls further down as the wave travels
|
|
84
|
+
float tipAngle = PI * (0.08 - 0.5 * smoothstep(0.0, 0.85, t));
|
|
85
|
+
// the wave sweeps from fully ahead of the frame, spray included, to fully past it, tinted water included
|
|
86
|
+
float travel = mix(t, t * t * (3.0 - 2.0 * t), 0.25);
|
|
87
|
+
vec2 C = vec2(mix(-E - R - REACH, E + Rb + TRAIL + BAND, travel), 1.02 - R);
|
|
88
|
+
|
|
89
|
+
// polar coordinates around the center of the curl
|
|
90
|
+
vec2 d = q - C;
|
|
91
|
+
// atan is undefined at the very center
|
|
92
|
+
if (d.x == 0.0) d.x = 1e-6;
|
|
93
|
+
float r = length(d);
|
|
94
|
+
float ang = atan(d.y, d.x);
|
|
95
|
+
// the inner surface of the curl spirals in from the tip of the lip (zero thickness) to the back of the hollow
|
|
96
|
+
float k = clamp((ang - tipAngle) / (PI - tipAngle), 0.0, 1.0);
|
|
97
|
+
float rIn = R - (R - Rb) * (1.0 - (1.0 - k) * (1.0 - k));
|
|
98
|
+
bool curled = ang >= tipAngle;
|
|
99
|
+
// the face below the curl: vertical where it meets the hollow, its base trailing behind
|
|
100
|
+
float s = 1.0 - clamp(q.y / C.y, 0.0, 1.0);
|
|
101
|
+
float face = C.x - Rb - TRAIL * s * s;
|
|
102
|
+
float behind = face - q.x; // > 0 behind the face
|
|
103
|
+
|
|
104
|
+
float wet;
|
|
105
|
+
if (curled) {
|
|
106
|
+
wet = smoothstep(-AA, AA, r - rIn) * (ang > 0.5 * PI ? 1.0 : 1.0 - smoothstep(-AA, AA, r - R));
|
|
107
|
+
} else {
|
|
108
|
+
wet = smoothstep(-AA, AA, behind);
|
|
109
|
+
}
|
|
110
|
+
// the lip: the curl in front of the top of the wave
|
|
111
|
+
float lip = curled ? 1.0 - smoothstep(0.5 * PI - 0.3, 0.5 * PI + 0.5, ang) : 0.0;
|
|
112
|
+
|
|
113
|
+
float n = vnoise(q * vec2(14.0, 10.0) + vec2(-9.0 * t, 3.0 * t));
|
|
114
|
+
|
|
115
|
+
// outgoing image, darkened in the hollow and in the shadow of the overhang just ahead of it
|
|
116
|
+
vec4 a = getFromColor(uv);
|
|
117
|
+
float gap = max(min(r - R, -behind), 0.0);
|
|
118
|
+
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));
|
|
119
|
+
shade += 0.25 * (1.0 - smoothstep(0.0, R, r));
|
|
120
|
+
a.rgb *= 1.0 - shade;
|
|
121
|
+
// spray thrown ahead of the crest, drifting forward and falling, and a mist along it
|
|
122
|
+
float fwd = max(r - R, 0.0);
|
|
123
|
+
float zone = smoothstep(tipAngle - 0.4, tipAngle + 0.2, ang) * (1.0 - smoothstep(0.0, REACH, fwd)) * step(0.0, r - R);
|
|
124
|
+
// stretched along the throw, so the droplets streak forward
|
|
125
|
+
vec2 sq = (d - t * vec2(0.5, -0.25)) * vec2(0.55, 1.0);
|
|
126
|
+
float thin = exp(-fwd / 0.12);
|
|
127
|
+
float spray = droplets(sq, 0.02, foam * thin, 1.0) + 0.6 * droplets(sq * 1.6 + 3.1, 0.02, foam * thin, 7.0);
|
|
128
|
+
// the mist hugs the outside of the lip only
|
|
129
|
+
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);
|
|
130
|
+
a.rgb = mix(a.rgb, foamColor.rgb, foamColor.a * clamp(spray * zone + mist, 0.0, 1.0));
|
|
131
|
+
|
|
132
|
+
// incoming image behind the face, bent and tinted by the water, clearing further behind
|
|
133
|
+
float band = max(1.0 - smoothstep(0.05, BAND, behind), lip);
|
|
134
|
+
float bend = refraction * band * band;
|
|
135
|
+
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));
|
|
136
|
+
vec4 b = getToColor(mirror(uv + off * 2.0 * w / vec2(ratio, 1.0)));
|
|
137
|
+
float luma = dot(b.rgb, vec3(0.299, 0.587, 0.114));
|
|
138
|
+
// lit near the top of the face and through the thin lip, darker on the underside of the lip
|
|
139
|
+
vec3 tinted = water.rgb * (0.4 + 0.9 * luma) * (1.0 + 0.6 * q.y);
|
|
140
|
+
tinted += 0.18 * lip * (1.0 - k) * vec3(0.5, 1.0, 0.9);
|
|
141
|
+
tinted *= 1.0 - 0.35 * lip * (1.0 - smoothstep(0.0, 0.06, r - rIn));
|
|
142
|
+
// a bright line along the surface of the face, fading up into the hollow
|
|
143
|
+
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);
|
|
144
|
+
b.rgb = mix(b.rgb, tinted, water.a * band);
|
|
145
|
+
|
|
146
|
+
// foam: whitewater along the outer edge of the lip, and churning at the base of the face
|
|
147
|
+
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;
|
|
148
|
+
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);
|
|
149
|
+
b.rgb = mix(b.rgb, foamColor.rgb, foamColor.a * clamp(foam * 1.5 * (crest + churn), 0.0, 1.0));
|
|
150
|
+
|
|
151
|
+
// mixed premultiplied, so transparent images do not bleed their color
|
|
152
|
+
vec4 c = mix(vec4(a.rgb * a.a, a.a), vec4(b.rgb * b.a, b.a), wet);
|
|
153
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a) : vec4(0.0);
|
|
154
|
+
}
|