gl-transitions 3.2.0 → 3.3.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 +30 -0
- package/compatibility.json +210 -0
- package/gl-transitions.js +1 -1
- package/gl-transitions.json +1 -1
- package/glsl3/CardDeal.glsl +146 -0
- package/glsl3/EchoSlide.glsl +93 -0
- package/glsl3/GeometricCollage.glsl +241 -0
- package/glsl3/HingedSquares.glsl +121 -0
- package/glsl3/HorizontalHold.glsl +62 -0
- package/glsl3/LayoutGrid.glsl +147 -0
- package/glsl3/ProjectorThrow.glsl +75 -0
- package/glsl3/Reassemble.glsl +156 -0
- package/glsl3/Shockwave.glsl +103 -0
- package/glsl3/ShoreWash.glsl +150 -0
- package/glsl3/ShutterWipe.glsl +68 -0
- package/glsl3/StopMotion.glsl +118 -0
- package/glsl3/Vaporize.glsl +125 -0
- package/index.js +1 -1
- package/layouts.json +493 -0
- package/llms-full.txt +647 -434
- package/llms.txt +238 -225
- package/msl/CardDeal.metal +539 -0
- package/msl/EchoSlide.metal +438 -0
- package/msl/GeometricCollage.metal +1188 -0
- package/msl/HingedSquares.metal +564 -0
- package/msl/HorizontalHold.metal +286 -0
- package/msl/LayoutGrid.metal +544 -0
- package/msl/ProjectorThrow.metal +313 -0
- package/msl/Reassemble.metal +667 -0
- package/msl/Shockwave.metal +256 -0
- package/msl/ShoreWash.metal +538 -0
- package/msl/ShutterWipe.metal +286 -0
- package/msl/StopMotion.metal +551 -0
- package/msl/Vaporize.metal +462 -0
- package/package.json +1 -1
- package/skills/gl-transitions/references/catalog.md +70 -32
- package/sksl/CardDeal.sksl +156 -0
- package/sksl/EchoSlide.sksl +99 -0
- package/sksl/GeometricCollage.sksl +242 -0
- package/sksl/HingedSquares.sksl +124 -0
- package/sksl/HorizontalHold.sksl +74 -0
- package/sksl/LayoutGrid.sksl +156 -0
- package/sksl/ProjectorThrow.sksl +85 -0
- package/sksl/Reassemble.sksl +166 -0
- package/sksl/Shockwave.sksl +116 -0
- package/sksl/ShoreWash.sksl +159 -0
- package/sksl/ShutterWipe.sksl +80 -0
- package/sksl/StopMotion.sksl +126 -0
- package/sksl/Vaporize.sksl +134 -0
- package/sksl/index.js +1 -1
- package/transitions/CardDeal.glsl +145 -0
- package/transitions/EchoSlide.glsl +92 -0
- package/transitions/GeometricCollage.glsl +240 -0
- package/transitions/HingedSquares.glsl +120 -0
- package/transitions/HorizontalHold.glsl +61 -0
- package/transitions/LayoutGrid.glsl +146 -0
- package/transitions/ProjectorThrow.glsl +74 -0
- package/transitions/Reassemble.glsl +155 -0
- package/transitions/Shockwave.glsl +102 -0
- package/transitions/ShoreWash.glsl +149 -0
- package/transitions/ShutterWipe.glsl +67 -0
- package/transitions/StopMotion.glsl +117 -0
- package/transitions/Vaporize.glsl +124 -0
- package/wgsl/CardDeal.wgsl +496 -0
- package/wgsl/EchoSlide.wgsl +386 -0
- package/wgsl/GeometricCollage.wgsl +1075 -0
- package/wgsl/HingedSquares.wgsl +506 -0
- package/wgsl/HorizontalHold.wgsl +243 -0
- package/wgsl/LayoutGrid.wgsl +495 -0
- package/wgsl/ProjectorThrow.wgsl +274 -0
- package/wgsl/Reassemble.wgsl +609 -0
- package/wgsl/Shockwave.wgsl +226 -0
- package/wgsl/ShoreWash.wgsl +492 -0
- package/wgsl/ShutterWipe.wgsl +252 -0
- package/wgsl/StopMotion.wgsl +496 -0
- package/wgsl/Vaporize.wgsl +420 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The frame splits into an asymmetric magazine grid as paper gutters open between the panels; panel after panel in reading order, the incoming image pushes the outgoing one out of its panel from a different side, a colored accent band between them, then the gutters close over the full incoming image
|
|
4
|
+
// Tags: grid, panels, magazine, push, slide, layout
|
|
5
|
+
|
|
6
|
+
// @range(0, 0.08) Width of the gutters at their widest, as a part of the frame's shorter side
|
|
7
|
+
uniform float gutter; // = 0.04
|
|
8
|
+
// @range(0, 0.9) How much the panels' pushes overlap in time (0 pushes them one strictly after another, 0.9 almost all together)
|
|
9
|
+
uniform float overlap; // = 0.55
|
|
10
|
+
// @range(0, 0.6) Length of the accent band between the two images, as a part of the panel's length along its push
|
|
11
|
+
uniform float band; // = 0.22
|
|
12
|
+
// @range(0, 1) Darkness of the soft shadows the panels cast on the paper and the incoming image casts on the band
|
|
13
|
+
uniform float shadow; // = 0.4
|
|
14
|
+
// @color Color of the paper seen in the gutters
|
|
15
|
+
uniform vec4 paper; // = vec4(0.96, 0.95, 0.91, 1.0)
|
|
16
|
+
// @color Color of the accent band between the outgoing and incoming images
|
|
17
|
+
uniform vec4 accent; // = vec4(0.93, 0.27, 0.2, 1.0)
|
|
18
|
+
|
|
19
|
+
const int PANELS = 6;
|
|
20
|
+
// the gutters open over [0, OPEN] and close over [1 - OPEN, 1]
|
|
21
|
+
const float OPEN = 0.28;
|
|
22
|
+
// the first push starts at START, the last one ends at 1 - START
|
|
23
|
+
const float START = 0.1;
|
|
24
|
+
// width of the antialiased edges, as a part of the frame's shorter side
|
|
25
|
+
const float EDGE = 0.0025;
|
|
26
|
+
|
|
27
|
+
// panel i of the layout: xy its bottom-left corner, zw its top-right corner, in uv; panels in reading order
|
|
28
|
+
vec4 panelRect(int i, bool portrait) {
|
|
29
|
+
if (portrait) {
|
|
30
|
+
if (i == 0) return vec4(0.0, 0.68, 0.62, 1.0);
|
|
31
|
+
if (i == 1) return vec4(0.62, 0.68, 1.0, 1.0);
|
|
32
|
+
if (i == 2) return vec4(0.0, 0.36, 1.0, 0.68);
|
|
33
|
+
if (i == 3) return vec4(0.0, 0.0, 0.46, 0.36);
|
|
34
|
+
if (i == 4) return vec4(0.46, 0.17, 1.0, 0.36);
|
|
35
|
+
return vec4(0.46, 0.0, 1.0, 0.17);
|
|
36
|
+
}
|
|
37
|
+
if (i == 0) return vec4(0.0, 0.42, 0.4, 1.0);
|
|
38
|
+
if (i == 1) return vec4(0.4, 0.64, 1.0, 1.0);
|
|
39
|
+
if (i == 2) return vec4(0.4, 0.0, 0.7, 0.64);
|
|
40
|
+
if (i == 3) return vec4(0.7, 0.32, 1.0, 0.64);
|
|
41
|
+
if (i == 4) return vec4(0.7, 0.0, 1.0, 0.32);
|
|
42
|
+
return vec4(0.0, 0.0, 0.4, 0.42);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// direction the outgoing image of panel i is pushed toward (the incoming one enters from the opposite side)
|
|
46
|
+
vec2 panelDir(int i, bool portrait) {
|
|
47
|
+
if (portrait) {
|
|
48
|
+
if (i == 0) return vec2(1.0, 0.0);
|
|
49
|
+
if (i == 1) return vec2(0.0, -1.0);
|
|
50
|
+
if (i == 2) return vec2(-1.0, 0.0);
|
|
51
|
+
if (i == 3) return vec2(0.0, 1.0);
|
|
52
|
+
if (i == 4) return vec2(1.0, 0.0);
|
|
53
|
+
return vec2(-1.0, 0.0);
|
|
54
|
+
}
|
|
55
|
+
if (i == 0) return vec2(0.0, -1.0);
|
|
56
|
+
if (i == 1) return vec2(-1.0, 0.0);
|
|
57
|
+
if (i == 2) return vec2(0.0, 1.0);
|
|
58
|
+
if (i == 3) return vec2(1.0, 0.0);
|
|
59
|
+
if (i == 4) return vec2(-1.0, 0.0);
|
|
60
|
+
return vec2(1.0, 0.0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
float easeInOut(float t) {
|
|
64
|
+
return t < 0.5 ? 4.0 * t * t * t : 1.0 - 4.0 * (1.0 - t) * (1.0 - t) * (1.0 - t);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// coverage of the interval [lo, hi] at x, with antialiased ends: the coverages of adjacent intervals add up to 1
|
|
68
|
+
float span1(float x, float lo, float hi, float aa) {
|
|
69
|
+
return smoothstep(lo - aa, lo + aa, x) * (1.0 - smoothstep(hi - aa, hi + aa, x));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// signed distance from p to the box [lo, hi]
|
|
73
|
+
float boxDist(vec2 p, vec2 lo, vec2 hi) {
|
|
74
|
+
vec2 d = abs(p - 0.5 * (lo + hi)) - 0.5 * (hi - lo);
|
|
75
|
+
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
vec4 transition(vec2 uv) {
|
|
79
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
80
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
81
|
+
|
|
82
|
+
bool portrait = ratio < 1.0;
|
|
83
|
+
// frame coordinates, in shorter sides
|
|
84
|
+
vec2 aspect = vec2(ratio, 1.0) / min(ratio, 1.0);
|
|
85
|
+
vec2 p = uv * aspect;
|
|
86
|
+
// the gutters open then close, 0 at both ends
|
|
87
|
+
float open = smoothstep(0.0, OPEN, progress) * (1.0 - smoothstep(1.0 - OPEN, 1.0, progress));
|
|
88
|
+
float g = gutter * open;
|
|
89
|
+
float ov = clamp(overlap, 0.0, 0.9);
|
|
90
|
+
// duration of a push, the pushes starting one after another over [START, 1 - START]
|
|
91
|
+
float span = (1.0 - 2.0 * START) / (1.0 + float(PANELS - 1) * (1.0 - ov));
|
|
92
|
+
|
|
93
|
+
vec4 color = vec4(0.0);
|
|
94
|
+
float cover = 0.0;
|
|
95
|
+
float shade = 0.0;
|
|
96
|
+
for (int i = 0; i < PANELS; i++) {
|
|
97
|
+
vec4 r = panelRect(i, portrait);
|
|
98
|
+
vec2 lo = r.xy * aspect + 0.5 * g;
|
|
99
|
+
vec2 hi = r.zw * aspect - 0.5 * g;
|
|
100
|
+
// no gutter along the frame's border: the panels there run past it
|
|
101
|
+
lo = mix(lo, vec2(-1.0), step(r.xy, vec2(0.0)));
|
|
102
|
+
hi = mix(hi, aspect + 1.0, step(vec2(1.0), r.zw));
|
|
103
|
+
float t = clamp((progress - START - float(i) * span * (1.0 - ov)) / span, 0.0, 1.0);
|
|
104
|
+
// the panel being pushed lifts off the paper: its shadow grows longer and softer
|
|
105
|
+
float lift = 1.0 + 1.2 * sin(3.141592653589793 * t);
|
|
106
|
+
// soft drop shadow down and to the right on the paper
|
|
107
|
+
float sd = boxDist(p - vec2(0.2, -0.35) * g * lift, lo, hi);
|
|
108
|
+
shade = max(shade, (1.0 - smoothstep(-0.2 * g, 0.6 * g * lift + 1e-4, sd)) / sqrt(lift));
|
|
109
|
+
// separable coverage, so that the panels of the grid add up to exactly 1 once the gutters close
|
|
110
|
+
float inside = span1(p.x, lo.x, hi.x, EDGE) * span1(p.y, lo.y, hi.y, EDGE);
|
|
111
|
+
if (inside > 0.0) {
|
|
112
|
+
vec2 dir = panelDir(i, portrait);
|
|
113
|
+
vec4 c;
|
|
114
|
+
if (t <= 0.0) {
|
|
115
|
+
c = getFromColor(uv);
|
|
116
|
+
} else if (t >= 1.0) {
|
|
117
|
+
c = getToColor(uv);
|
|
118
|
+
} else {
|
|
119
|
+
float e = easeInOut(t);
|
|
120
|
+
// a train slides along dir through the panel: outgoing image, accent band, incoming image
|
|
121
|
+
float len = abs(dot(r.zw - r.xy, dir));
|
|
122
|
+
float w = band * len;
|
|
123
|
+
vec2 q = uv - dir * e * (len + w);
|
|
124
|
+
// position along dir from the outgoing image's trailing edge (inside it when >= 0)
|
|
125
|
+
float a = dot(q - (dir.x + dir.y < 0.0 ? r.zw : r.xy), dir);
|
|
126
|
+
// the same in frame units, for antialiasing
|
|
127
|
+
float af = a * abs(dot(aspect, dir));
|
|
128
|
+
float wf = w * abs(dot(aspect, dir));
|
|
129
|
+
float fromW = smoothstep(-EDGE, 0.0, af);
|
|
130
|
+
float toW = 1.0 - smoothstep(-wf, -wf + EDGE, af);
|
|
131
|
+
// the incoming image's leading edge casts a soft shadow on the band
|
|
132
|
+
float bandShade = 1.0 - shadow * 0.5 * (1.0 - smoothstep(-wf, -wf + 0.35 * wf + 1e-4, af));
|
|
133
|
+
vec4 b = vec4(accent.rgb * bandShade, accent.a);
|
|
134
|
+
// the antialiased ends of the images are sampled inside the panel
|
|
135
|
+
c = mix(b, getFromColor(clamp(q, r.xy, r.zw)), fromW);
|
|
136
|
+
c = mix(c, getToColor(clamp(q + dir * (len + w), r.xy, r.zw)), toW);
|
|
137
|
+
}
|
|
138
|
+
color += c * inside;
|
|
139
|
+
cover += inside;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
color /= max(cover, 1.0);
|
|
143
|
+
cover = min(cover, 1.0);
|
|
144
|
+
vec4 bg = vec4(paper.rgb * (1.0 - shadow * shade * open), paper.a);
|
|
145
|
+
return color + bg * (1.0 - cover);
|
|
146
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The lights go down on the outgoing image and a projector throws the incoming one onto it: a small, blurred, keystoned picture of light lands on the scene, tinted by the colors it falls on, then grows, comes into focus and squares up until it fills the frame as the scene beneath it fades away
|
|
4
|
+
// Tags: light, projector, projection, keystone, focus, reveal
|
|
5
|
+
|
|
6
|
+
// @range(0, 1) How dark the outgoing image gets once the lights go down
|
|
7
|
+
uniform float darkness; // = 0.8
|
|
8
|
+
// @range(0, 0.8) How much wider the top of the projected picture is than its bottom when it lands
|
|
9
|
+
uniform float keystone; // = 0.45
|
|
10
|
+
// @range(0, 0.05) How out of focus the projected picture is when it lands, in frame heights
|
|
11
|
+
uniform float blur; // = 0.015
|
|
12
|
+
|
|
13
|
+
// folds coordinates back into the frame, so the picture never shows its clamped edges
|
|
14
|
+
vec2 mirror(vec2 v) {
|
|
15
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// the projected picture, sampled with 8 taps on a disc of radius r (in its own coordinates),
|
|
19
|
+
// averaged premultiplied so transparent texels do not bleed into it
|
|
20
|
+
vec4 projected(vec2 q, vec2 r) {
|
|
21
|
+
vec4 c = vec4(0.0);
|
|
22
|
+
for (int i = 0; i < 8; i++) {
|
|
23
|
+
float a = float(i) * 2.39996;
|
|
24
|
+
vec2 o = sqrt((float(i) + 0.5) / 8.0) * vec2(cos(a), sin(a));
|
|
25
|
+
vec4 t = getToColor(mirror(q + o * r));
|
|
26
|
+
c += vec4(t.rgb * t.a, t.a);
|
|
27
|
+
}
|
|
28
|
+
return c.a > 0.0 ? vec4(c.rgb / c.a, c.a / 8.0) : vec4(0.0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
vec4 transition(vec2 uv) {
|
|
32
|
+
float p = progress;
|
|
33
|
+
if (p <= 0.0) return getFromColor(uv);
|
|
34
|
+
if (p >= 1.0) return getToColor(uv);
|
|
35
|
+
vec4 from = getFromColor(uv);
|
|
36
|
+
|
|
37
|
+
// the lamp warms up as the room lights go down
|
|
38
|
+
float on = smoothstep(0.06, 0.26, p);
|
|
39
|
+
float ambient = 1.0 - darkness * smoothstep(0.0, 0.2, p);
|
|
40
|
+
// the picture grows and squares up, while it comes into focus
|
|
41
|
+
float g = smoothstep(0.02, 1.0, p);
|
|
42
|
+
float focus = 1.0 - smoothstep(0.15, 0.85, p);
|
|
43
|
+
float size = mix(0.32, 1.0, g * (0.6 + 0.4 * g));
|
|
44
|
+
float k = keystone * (1.0 - g);
|
|
45
|
+
float cy = mix(0.58, 0.5, g);
|
|
46
|
+
|
|
47
|
+
// keystone: the picture is a trapezoid seen in perspective, its rows spaced wider where it is wider
|
|
48
|
+
float y = (uv.y - cy) / size + 0.5;
|
|
49
|
+
float wy = max(1.0 - 0.5 * k + k * y, 0.05);
|
|
50
|
+
vec2 q = vec2((uv.x - 0.5) / (size * wy) + 0.5, y * (1.0 + 0.5 * k) / wy);
|
|
51
|
+
|
|
52
|
+
// soft edges of the beam, in frame heights, sharp once in focus
|
|
53
|
+
float e = min((0.5 * size * wy - abs(uv.x - 0.5)) * ratio, size * min(y, 1.0 - y));
|
|
54
|
+
float soft = 0.0015 + 0.035 * focus;
|
|
55
|
+
float cov = mix(smoothstep(-soft, soft, e), 1.0, smoothstep(0.9, 1.0, p));
|
|
56
|
+
// stray light spilling around the beam
|
|
57
|
+
float halo = 0.15 * focus * on * exp(-24.0 * max(-e, 0.0)) * (1.0 - cov);
|
|
58
|
+
|
|
59
|
+
// the light of the picture: brighter while concentrated on a small area, with a lamp vignette
|
|
60
|
+
vec2 d = q - 0.5;
|
|
61
|
+
float gain = on * mix(1.25, 1.0, g) * (1.0 + focus * (0.15 - 1.2 * dot(d, d)));
|
|
62
|
+
// the blur is round on the frame: picture coordinates stretch with the keystone
|
|
63
|
+
vec2 r = blur * focus / (size * wy) * vec2(1.0 / ratio, (1.0 - 0.25 * k * k) / wy);
|
|
64
|
+
vec4 pic = projected(q, r);
|
|
65
|
+
vec3 light = pic.rgb * gain * cov + halo;
|
|
66
|
+
|
|
67
|
+
// light lands on the dimmed scene and is tinted by its colors; under the picture, the scene
|
|
68
|
+
// fades to a plain screen
|
|
69
|
+
float screen = smoothstep(0.35, 0.95, p);
|
|
70
|
+
vec3 surface = mix(from.rgb, vec3(1.0), 0.35 + 0.65 * screen);
|
|
71
|
+
vec3 col = from.rgb * ambient * (1.0 - cov * screen) + surface * light;
|
|
72
|
+
// the picture of light shows even over a transparent scene
|
|
73
|
+
return vec4(col, mix(max(from.a, pic.a * cov * on), pic.a, cov * screen));
|
|
74
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: The outgoing image cracks into irregular shards that burst apart toward the viewer, each one turning over in 3D at its own moment, then fly back together and lock into place as the incoming image carried on their backs
|
|
4
|
+
// Tags: 3d, shards, flip, explode
|
|
5
|
+
|
|
6
|
+
// @range(2, 8, 1) Number of rows of shards
|
|
7
|
+
uniform int rows; // = 4
|
|
8
|
+
// @range(0, 1) How far the shards come toward the viewer
|
|
9
|
+
uniform float depth; // = 0.8
|
|
10
|
+
// @range(0, 0.5) How far the shards spread apart, as a part of their distance from the center
|
|
11
|
+
uniform float spread; // = 0.05
|
|
12
|
+
// @color Color seen between the shards
|
|
13
|
+
uniform vec4 backColor; // = vec4(0.04, 0.04, 0.05, 1.0)
|
|
14
|
+
|
|
15
|
+
const float PI = 3.141592653589793;
|
|
16
|
+
// distance of the eye, in frame heights
|
|
17
|
+
const float EYE = 2.5;
|
|
18
|
+
// width of the anti-aliased edges and half width of the open cracks, in frame heights
|
|
19
|
+
const float EDGE = 0.0015;
|
|
20
|
+
const float CRACK = 0.005;
|
|
21
|
+
// the shards leave between START and START + DELAY, and each one flies for FLIGHT
|
|
22
|
+
const float START = 0.03;
|
|
23
|
+
const float DELAY = 0.08;
|
|
24
|
+
const float FLIGHT = 0.86;
|
|
25
|
+
|
|
26
|
+
vec3 hash3(vec2 p) {
|
|
27
|
+
vec3 q = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
|
|
28
|
+
q += dot(q, q.yxz + 33.33);
|
|
29
|
+
return fract((q.xxy + q.yzz) * q.zyx);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// the seed of the shard of grid cell g, in frame heights from the center
|
|
33
|
+
vec2 seed(vec2 g, float size) {
|
|
34
|
+
return (g + 0.5 + 0.7 * (hash3(g).xy - 0.5)) * size;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// distance from q to the border of the shard of cell g (its Voronoi cell), negative outside it
|
|
38
|
+
float shardDist(vec2 q, vec2 g, float size) {
|
|
39
|
+
vec2 sj = seed(g, size);
|
|
40
|
+
float d = 1e9;
|
|
41
|
+
for (int y = -1; y <= 1; y++) {
|
|
42
|
+
for (int x = -1; x <= 1; x++) {
|
|
43
|
+
if (x == 0 && y == 0) continue;
|
|
44
|
+
vec2 sk = seed(g + vec2(float(x), float(y)), size);
|
|
45
|
+
vec2 dir = sk - sj;
|
|
46
|
+
d = min(d, dot(0.5 * (sj + sk) - q, dir) / length(dir));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return d;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
float ease(float t) {
|
|
53
|
+
return t * t * (3.0 - 2.0 * t);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// how far a shard is out of place along its flight t: a quick burst, then a soft landing
|
|
57
|
+
float burst(float t) {
|
|
58
|
+
float u = clamp(t / 0.4, 0.0, 1.0);
|
|
59
|
+
float v = clamp((t - 0.4) / 0.6, 0.0, 1.0);
|
|
60
|
+
return t < 0.4 ? 1.0 - (1.0 - u) * (1.0 - u) : 1.0 - ease(v);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
vec4 transition(vec2 uv) {
|
|
64
|
+
vec2 aspect = vec2(ratio, 1.0);
|
|
65
|
+
vec2 x = (uv - 0.5) * aspect;
|
|
66
|
+
float size = 1.0 / clamp(float(rows), 1.0, 8.0);
|
|
67
|
+
float E = clamp(spread, 0.0, 0.5);
|
|
68
|
+
float Z = clamp(depth, 0.0, 1.0);
|
|
69
|
+
float p = clamp(progress, 0.0, 1.0);
|
|
70
|
+
vec3 L = normalize(vec3(-0.45, 0.55, 1.0));
|
|
71
|
+
vec3 H = normalize(L + vec3(0.0, 0.0, 1.0));
|
|
72
|
+
vec3 eye = vec3(0.0, 0.0, EYE);
|
|
73
|
+
vec3 dir = vec3(x, -EYE);
|
|
74
|
+
// the cracks open as the image breaks and close as the shards lock back into place
|
|
75
|
+
float act = smoothstep(0.0, START + DELAY, p) * (1.0 - smoothstep(START + FLIGHT, 1.0, p));
|
|
76
|
+
|
|
77
|
+
// where this point roughly comes from, to find the shards that can cover it
|
|
78
|
+
float b0 = burst(clamp((p - START - 0.5 * DELAY) / FLIGHT, 0.0, 1.0));
|
|
79
|
+
vec2 x0 = x * (EYE - 0.75 * Z * b0) / EYE / (1.0 + E * b0);
|
|
80
|
+
vec2 cell0 = floor(x0 / size);
|
|
81
|
+
|
|
82
|
+
// the two nearest shards seen here: depth, image point, side (1 front), coverage, shading, rim
|
|
83
|
+
float z1 = 1e9, z2 = 1e9;
|
|
84
|
+
vec2 q1 = x, q2 = x;
|
|
85
|
+
float f1 = 1.0, f2 = 1.0, m1 = 0.0, m2 = 0.0;
|
|
86
|
+
float s1 = 1.0, s2 = 1.0, r1 = 0.0, r2 = 0.0;
|
|
87
|
+
for (int j = -1; j <= 1; j++) {
|
|
88
|
+
for (int i = -1; i <= 1; i++) {
|
|
89
|
+
vec2 g = cell0 + vec2(float(i), float(j));
|
|
90
|
+
vec3 h = hash3(g + 17.0);
|
|
91
|
+
float t = clamp((p - START - DELAY * h.x) / FLIGHT, 0.0, 1.0);
|
|
92
|
+
float b = burst(t);
|
|
93
|
+
// each shard turns over around its own axis at its own moment, while it is out of place
|
|
94
|
+
float th = PI * ease(clamp((t - 0.1 - 0.48 * h.z) / 0.24, 0.0, 1.0));
|
|
95
|
+
float ct = cos(th), st = sin(th);
|
|
96
|
+
// and turns a little in the frame, back straight when it lands
|
|
97
|
+
float phi = PI * h.y;
|
|
98
|
+
float rz = 0.5 * (h.z - 0.5) * b;
|
|
99
|
+
vec2 a0 = vec2(cos(phi), sin(phi));
|
|
100
|
+
vec2 p0 = vec2(-a0.y, a0.x);
|
|
101
|
+
vec3 a = vec3(cos(phi + rz), sin(phi + rz), 0.0);
|
|
102
|
+
vec3 w = vec3(-a.y, a.x, 0.0) * ct + vec3(0.0, 0.0, st);
|
|
103
|
+
vec2 c = seed(g, size);
|
|
104
|
+
vec3 center = vec3(c * (1.0 + E * b), Z * b * (0.5 + 0.5 * h.x));
|
|
105
|
+
vec3 nrm = cross(a, w);
|
|
106
|
+
float den = dot(dir, nrm);
|
|
107
|
+
if (abs(den) < 1e-6) continue;
|
|
108
|
+
float lam = dot(center - eye, nrm) / den;
|
|
109
|
+
if (lam <= 0.0) continue;
|
|
110
|
+
vec3 hit = eye + lam * dir - center;
|
|
111
|
+
float u = dot(hit, a), v = dot(hit, w);
|
|
112
|
+
// the front carries the outgoing image, the back the incoming one, mirrored so that it lands in place;
|
|
113
|
+
// the side seen is the one facing the eye, which swaps where the shard is seen edge-on
|
|
114
|
+
float front = den < 0.0 ? 1.0 : -1.0;
|
|
115
|
+
vec2 q = c + u * a0 + front * v * p0;
|
|
116
|
+
// anti-aliased edges, scaled to the screen; at rest the shards overlap a little to hide their seams
|
|
117
|
+
float k = EYE / (EYE - center.z);
|
|
118
|
+
float e = shardDist(q, g, size) - CRACK * act;
|
|
119
|
+
vec2 box = 0.5 * aspect - abs(q);
|
|
120
|
+
e = min(e, min(box.x, box.y)) * k * mix(1.0, max(abs(ct), 0.2), min(b * 8.0, 1.0)) + 4.0 * EDGE * (1.0 - act);
|
|
121
|
+
float m = clamp(e / (2.0 * EDGE) + 0.5, 0.0, 1.0);
|
|
122
|
+
// at rest the shards lie at the same depth: the one that covers this point fully comes first
|
|
123
|
+
float zk = lam - 0.001 * m;
|
|
124
|
+
if (m <= 0.0 || zk >= z2) continue;
|
|
125
|
+
// lit from the upper left, with a glint as a shard faces the light; unchanged at rest
|
|
126
|
+
vec3 n = nrm * front;
|
|
127
|
+
float lit = mix(0.45, 1.0, clamp(dot(n, L) / L.z, 0.0, 1.0));
|
|
128
|
+
float glint = 0.2 * min(b * 4.0, 1.0) * pow(max(dot(n, H), 0.0), 24.0);
|
|
129
|
+
// a pale rim on the broken edges while they fly, flashing as each shard locks into place
|
|
130
|
+
float lock = sin(PI * clamp((t - 0.86) / 0.14, 0.0, 1.0));
|
|
131
|
+
float rim = (0.3 * act * min(b * 4.0, 1.0) + 0.35 * lock) * (1.0 - smoothstep(0.0, 0.006, e));
|
|
132
|
+
if (zk < z1) {
|
|
133
|
+
z2 = z1; q2 = q1; f2 = f1; m2 = m1; s2 = s1; r2 = r1;
|
|
134
|
+
z1 = zk; q1 = q; f1 = front; m1 = m; s1 = lit + glint; r1 = rim;
|
|
135
|
+
} else {
|
|
136
|
+
z2 = zk; q2 = q; f2 = front; m2 = m; s2 = lit + glint; r2 = rim;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
vec4 col = backColor;
|
|
142
|
+
if (m2 > 0.0) {
|
|
143
|
+
vec2 src = q2 / aspect + 0.5;
|
|
144
|
+
vec4 img = f2 > 0.0 ? getFromColor(src) : getToColor(src);
|
|
145
|
+
img.rgb = mix(min(img.rgb * s2, vec3(img.a)), vec3(img.a), r2);
|
|
146
|
+
col = mix(col, img, m2);
|
|
147
|
+
}
|
|
148
|
+
if (m1 > 0.0) {
|
|
149
|
+
vec2 src = q1 / aspect + 0.5;
|
|
150
|
+
vec4 img = f1 > 0.0 ? getFromColor(src) : getToColor(src);
|
|
151
|
+
img.rgb = mix(min(img.rgb * s1, vec3(img.a)), vec3(img.a), r1);
|
|
152
|
+
col = mix(col, img, m1);
|
|
153
|
+
}
|
|
154
|
+
return col;
|
|
155
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Author: Gilad Levi, github @Giladx
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A diagonal shockwave breaks the outgoing image into tiny falling glass tiles. Each tile slips away with a brief chromatic split and neon edge glow, revealing the incoming image beneath it.
|
|
4
|
+
// Tags: diagonal, mosaic, pixel, cascade, glass, prism, chromatic, neon, cinematic
|
|
5
|
+
|
|
6
|
+
// @range(0.012, 0.10) Size of each square tile relative to slide height
|
|
7
|
+
uniform float tileSize; // = 0.035
|
|
8
|
+
// @range(0.0, 1.5) How far the tiles slide and fall
|
|
9
|
+
uniform float scatter; // = 0.85
|
|
10
|
+
// @range(0.0, 1.0) 0 is a horizontal sweep; 1 is a strongly diagonal sweep
|
|
11
|
+
uniform float diagonal; // = 0.9
|
|
12
|
+
// @range(0.0, 1.0) Amount of red/blue optical separation at the moving edges
|
|
13
|
+
uniform float prism; // = 0.65
|
|
14
|
+
// @range(0.0, 1.0) Brightness of the colored edges around moving tiles
|
|
15
|
+
uniform float glow; // = 0.75
|
|
16
|
+
|
|
17
|
+
// A deterministic pseudo-random value per cell, stable between frames.
|
|
18
|
+
float toseeHash(vec2 p) {
|
|
19
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
vec4 transition(vec2 uv) {
|
|
23
|
+
// Preserve perfect, undistorted source and destination frames.
|
|
24
|
+
if (progress <= 0.0) return getFromColor(uv);
|
|
25
|
+
if (progress >= 1.0) return getToColor(uv);
|
|
26
|
+
|
|
27
|
+
// Build an aspect-correct grid: square cells on wide and tall sliders.
|
|
28
|
+
float size = max(tileSize, 0.008);
|
|
29
|
+
vec2 grid = max(vec2(1.0), floor(vec2(ratio, 1.0) / size));
|
|
30
|
+
vec2 cell = floor(uv * grid);
|
|
31
|
+
vec2 cellUV = fract(uv * grid);
|
|
32
|
+
vec2 centerUV = (cell + 0.5) / grid;
|
|
33
|
+
|
|
34
|
+
// Schedule each tile in a diagonal wave with random stagger.
|
|
35
|
+
float sweep = mix(
|
|
36
|
+
centerUV.x,
|
|
37
|
+
0.64 * centerUV.x + 0.36 * (1.0 - centerUV.y),
|
|
38
|
+
clamp(diagonal, 0.0, 1.0)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
float noise = toseeHash(cell);
|
|
42
|
+
float start = 0.62 * sweep + 0.07 * noise;
|
|
43
|
+
float t = clamp((progress - start) / 0.29, 0.0, 1.0);
|
|
44
|
+
float movement = t * clamp(scatter, 0.0, 1.5);
|
|
45
|
+
|
|
46
|
+
// Move each outgoing image tile sideways and downward.
|
|
47
|
+
float wobble = toseeHash(cell + vec2(19.3, 7.7)) * 2.0 - 1.0;
|
|
48
|
+
vec2 drift = vec2(0.65 * wobble, -0.95) * movement;
|
|
49
|
+
vec2 movingCellUV = cellUV - drift;
|
|
50
|
+
|
|
51
|
+
// Clip moving tiles to their cells, revealing the next image.
|
|
52
|
+
float inside =
|
|
53
|
+
step(0.012, movingCellUV.x) *
|
|
54
|
+
step(movingCellUV.x, 0.988) *
|
|
55
|
+
step(0.012, movingCellUV.y) *
|
|
56
|
+
step(movingCellUV.y, 0.988);
|
|
57
|
+
|
|
58
|
+
float tileShape = mix(1.0, inside, smoothstep(0.0, 0.13, t));
|
|
59
|
+
float oldVisibility = 1.0 - smoothstep(0.48, 0.87, t);
|
|
60
|
+
float oldMask = tileShape * oldVisibility;
|
|
61
|
+
|
|
62
|
+
// Sample the old image using the tile's displaced position.
|
|
63
|
+
vec2 oldUV = clamp(uv - drift / grid, 0.0, 1.0);
|
|
64
|
+
vec4 oldColor = getFromColor(oldUV);
|
|
65
|
+
|
|
66
|
+
// Add chromatic separation while each tile is moving.
|
|
67
|
+
float flare = sin(3.14159265 * t);
|
|
68
|
+
vec2 shift = vec2(0.006, -0.002) * prism * flare;
|
|
69
|
+
vec4 offsetColor = getFromColor(
|
|
70
|
+
clamp(oldUV + shift, 0.0, 1.0)
|
|
71
|
+
);
|
|
72
|
+
oldColor.r = offsetColor.r;
|
|
73
|
+
|
|
74
|
+
// Reveal the incoming image below the falling tiles.
|
|
75
|
+
vec4 result = mix(getToColor(uv), oldColor, oldMask);
|
|
76
|
+
|
|
77
|
+
// Draw a temporary cyan or pink glowing rim around moving tiles.
|
|
78
|
+
float edgeDistance = min(
|
|
79
|
+
min(movingCellUV.x, 1.0 - movingCellUV.x),
|
|
80
|
+
min(movingCellUV.y, 1.0 - movingCellUV.y)
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
float edge =
|
|
84
|
+
(1.0 - smoothstep(0.0, 0.10, edgeDistance)) * inside;
|
|
85
|
+
|
|
86
|
+
vec3 cyan = vec3(0.12, 0.95, 1.0);
|
|
87
|
+
vec3 pink = vec3(1.0, 0.20, 0.65);
|
|
88
|
+
|
|
89
|
+
vec3 rimColor = mix(
|
|
90
|
+
cyan,
|
|
91
|
+
pink,
|
|
92
|
+
toseeHash(cell + vec2(5.4, 28.6))
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
result.rgb = clamp(
|
|
96
|
+
result.rgb + rimColor * edge * flare * glow * oldMask * 0.60,
|
|
97
|
+
0.0,
|
|
98
|
+
1.0
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// Author: gre
|
|
2
|
+
// License: MIT
|
|
3
|
+
// Description: A thin sheet of water runs up over the outgoing image like the last of a wave on a beach, its lobed front edged with bubbly foam; it slows, stops just past the far edge and drains back, leaving the incoming image wet and glossy as it dries
|
|
4
|
+
// Tags: water, foam, beach, liquid, directional, reveal
|
|
5
|
+
|
|
6
|
+
// @param Direction the water runs up toward
|
|
7
|
+
uniform vec2 direction; // = vec2(0.0, 1.0)
|
|
8
|
+
// @range(0, 1) Amount of foam on the front and left behind
|
|
9
|
+
uniform float foam; // = 0.7
|
|
10
|
+
// @range(0, 0.05) How much the sheet of water bends the image under it
|
|
11
|
+
uniform float refraction; // = 0.02
|
|
12
|
+
// @color Color of the water (its alpha is its strength)
|
|
13
|
+
uniform vec4 water; // = vec4(0.1, 0.6, 0.62, 0.4)
|
|
14
|
+
|
|
15
|
+
// half width of the antialiased edges, in frame heights
|
|
16
|
+
const float AA = 0.002;
|
|
17
|
+
// how far the lobes of the front lead or trail, in frame heights
|
|
18
|
+
const float LOBE = 0.06;
|
|
19
|
+
// width of the band of foam lace behind the front, in frame heights
|
|
20
|
+
const float LACE = 0.3;
|
|
21
|
+
// size of the foam bubbles, in frame heights
|
|
22
|
+
const float CELL = 0.045;
|
|
23
|
+
// part of the transition the water runs up during; it drains back during the rest
|
|
24
|
+
const float RUNUP = 0.4;
|
|
25
|
+
// width of the dense band of foam right behind the front, in frame heights
|
|
26
|
+
const float FOAMW = 0.1;
|
|
27
|
+
|
|
28
|
+
float hash12(vec2 p) {
|
|
29
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
30
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
31
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
vec2 hash22(vec2 p) {
|
|
35
|
+
vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
|
|
36
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
37
|
+
return fract((p3.xx + p3.yz) * p3.zy);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
float vnoise(vec2 p) {
|
|
41
|
+
vec2 i = floor(p);
|
|
42
|
+
vec2 f = fract(p);
|
|
43
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
44
|
+
return mix(
|
|
45
|
+
mix(hash12(i), hash12(i + vec2(1.0, 0.0)), f.x),
|
|
46
|
+
mix(hash12(i + vec2(0.0, 1.0)), hash12(i + vec2(1.0, 1.0)), f.x),
|
|
47
|
+
f.y
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// foam: bubbles packed side by side, white where they touch and open at their centers.
|
|
52
|
+
// Sparse foam is a faint lace; the denser it is, the brighter it is and the smaller the
|
|
53
|
+
// holes, until they close (density 1)
|
|
54
|
+
float bubbles(vec2 p, float density) {
|
|
55
|
+
vec2 i = floor(p);
|
|
56
|
+
vec2 f = fract(p);
|
|
57
|
+
float d1 = 8.0;
|
|
58
|
+
float d2 = 8.0;
|
|
59
|
+
for (int y = -1; y <= 1; y++) {
|
|
60
|
+
for (int x = -1; x <= 1; x++) {
|
|
61
|
+
vec2 o = vec2(float(x), float(y));
|
|
62
|
+
vec2 c = o + 0.15 + 0.7 * hash22(i + o) - f;
|
|
63
|
+
float d = dot(c, c);
|
|
64
|
+
if (d < d1) {
|
|
65
|
+
d2 = d1;
|
|
66
|
+
d1 = d;
|
|
67
|
+
} else if (d < d2) {
|
|
68
|
+
d2 = d;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
float e = sqrt(d2) - sqrt(d1);
|
|
73
|
+
float w = 0.12 + 0.6 * density;
|
|
74
|
+
return (1.0 - smoothstep(w - 0.12, w + 0.12, e)) * smoothstep(0.0, 0.35, density);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
vec2 mirror(vec2 v) {
|
|
78
|
+
return 1.0 - abs(1.0 - mod(v, 2.0));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
vec4 transition(vec2 uv) {
|
|
82
|
+
vec2 dir = length(direction) > 0.0 ? normalize(direction) : vec2(0.0, 1.0);
|
|
83
|
+
vec2 q = (uv - 0.5) * vec2(ratio, 1.0);
|
|
84
|
+
// distance along the run-up, 0 at the middle of the frame, and across it
|
|
85
|
+
float a = dot(q, dir);
|
|
86
|
+
float b = dot(q, vec2(-dir.y, dir.x));
|
|
87
|
+
// half the extent of the frame along the run-up
|
|
88
|
+
float extent = 0.5 * (abs(dir.x) * ratio + abs(dir.y));
|
|
89
|
+
float start = -extent - LOBE - 0.1;
|
|
90
|
+
float stop = extent + LOBE + 0.01;
|
|
91
|
+
|
|
92
|
+
// the front races in, slows down and stops (run-up), then drains back faster and faster
|
|
93
|
+
float up = clamp(progress / RUNUP, 0.0, 1.0);
|
|
94
|
+
float back = clamp((progress - RUNUP) / (1.0 - RUNUP), 0.0, 1.0);
|
|
95
|
+
float front = mix(start, stop, 1.0 - pow(1.0 - up, 1.6)) - (stop - start) * pow(back, 1.5);
|
|
96
|
+
|
|
97
|
+
// lobed front: tongues of water run ahead in some places, and drift sideways a little
|
|
98
|
+
float lobes = vnoise(vec2(b * 7.0 + 3.1, progress * 2.0)) * 0.7 + vnoise(vec2(b * 17.0, 5.0 + progress * 3.0)) * 0.3;
|
|
99
|
+
float behind = front + LOBE * (lobes - 0.5) * 2.0 - a; // > 0 under the water
|
|
100
|
+
float sheet = smoothstep(-AA, AA, behind);
|
|
101
|
+
|
|
102
|
+
// the image swaps under the dense foam right behind the running front, and finishes
|
|
103
|
+
// swapping under the water as it stops by the far edge
|
|
104
|
+
float swapped = max(smoothstep(0.01, 0.8 * FOAMW, behind), (progress < RUNUP ? sheet : 1.0) * smoothstep(RUNUP - 0.08, RUNUP, progress));
|
|
105
|
+
|
|
106
|
+
// the sheet of water ripples (stretched across the flow) and bends what is under it
|
|
107
|
+
vec2 rp = vec2(a * 20.0, b * 5.0 + 3.0 * vnoise(q * 4.0)) - vec2(7.0 * min(progress, RUNUP) - 5.0 * back, 0.0);
|
|
108
|
+
float n0 = vnoise(rp);
|
|
109
|
+
vec2 g = (vnoise(rp + vec2(0.15, 0.0)) - n0) / 0.15 * dir + (vnoise(rp + vec2(0.0, 0.15)) - n0) / 0.15 * vec2(-dir.y, dir.x);
|
|
110
|
+
// the water is thin at its edge and deeper behind it
|
|
111
|
+
float thick = sheet * smoothstep(0.0, 0.12, behind);
|
|
112
|
+
vec2 off = g * refraction * thick * vec2(1.0 / ratio, 1.0);
|
|
113
|
+
|
|
114
|
+
vec4 c = mix(getFromColor(mirror(uv + off)), getToColor(mirror(uv + off)), swapped);
|
|
115
|
+
c.rgb = mix(c.rgb, water.rgb, water.a * sheet * (0.3 + 0.7 * smoothstep(0.0, 0.35, behind)));
|
|
116
|
+
// soft glints on the ripples
|
|
117
|
+
float glint = pow(max(dot(normalize(vec3(-g, 3.0)), normalize(vec3(-0.3, 0.6, 1.0))), 0.0), 14.0);
|
|
118
|
+
c.rgb += glint * 0.4 * thick;
|
|
119
|
+
|
|
120
|
+
// wet: what the water has drained off is darker and glossier, and dries out
|
|
121
|
+
float wet = (1.0 - sheet) * exp(min(behind, 0.0) * 2.5) * smoothstep(RUNUP, RUNUP + 0.05, progress) * (1.0 - smoothstep(0.7, 1.0, progress));
|
|
122
|
+
c.rgb *= mix(vec3(1.0), c.rgb, 0.55 * wet);
|
|
123
|
+
c.rgb += 0.1 * wet * smoothstep(0.4, 0.9, vnoise(vec2(a * 30.0, b * 6.0)));
|
|
124
|
+
|
|
125
|
+
// foam: thick and bubbly right behind the running front, a lace trailing behind it,
|
|
126
|
+
// and a thin line on the draining front; none is left on the image the water has drained off
|
|
127
|
+
// the foam drifts with the water as it runs up, then stays where it is
|
|
128
|
+
vec2 lp = vec2(a - 0.4 * (progress < RUNUP ? front : stop), b) / CELL;
|
|
129
|
+
// the lace gathers in streaks along the front, broken into patches
|
|
130
|
+
float patches = smoothstep(0.45, 0.8, 0.6 * vnoise(lp * vec2(0.4, 0.1) + 4.0) + 0.4 * vnoise(lp * 0.3 + 9.0));
|
|
131
|
+
float bandW = FOAMW * (0.5 + vnoise(vec2(b * 25.0, 2.0)));
|
|
132
|
+
float density = (1.0 - smoothstep(0.0, bandW, behind)) * (1.0 - smoothstep(RUNUP - 0.05, RUNUP + 0.12, progress));
|
|
133
|
+
density = max(density, 0.55 * patches * (1.0 - smoothstep(0.0, LACE, behind)) * (1.0 - 0.5 * back));
|
|
134
|
+
density = max(density, 0.9 * (1.0 - smoothstep(0.0, 0.012 + 0.02 * vnoise(vec2(b * 40.0, 1.0)), behind)));
|
|
135
|
+
density *= sheet;
|
|
136
|
+
// bubbles of two sizes, over a milky haze where the foam is dense
|
|
137
|
+
float f = 0.0;
|
|
138
|
+
if (density > 0.0) {
|
|
139
|
+
f = max(bubbles(lp, density), 0.85 * bubbles(lp * 1.7 + 7.0, density * 0.9));
|
|
140
|
+
f = max(f, 0.45 * smoothstep(0.15, 0.7, density)) * foam;
|
|
141
|
+
}
|
|
142
|
+
// the foam shades the water around it a little
|
|
143
|
+
c.rgb *= 1.0 - 0.25 * sheet * foam * (1.0 - f) * smoothstep(0.0, 0.6, density);
|
|
144
|
+
c.rgb = mix(c.rgb, vec3(0.97, 0.98, 0.97), clamp(f, 0.0, 1.0));
|
|
145
|
+
// a thin shadow just ahead of the running front
|
|
146
|
+
float sh = smoothstep(-0.03, 0.0, behind);
|
|
147
|
+
c.rgb *= 1.0 - 0.35 * (1.0 - sheet) * sh * sh * (1.0 - smoothstep(RUNUP - 0.05, RUNUP, progress));
|
|
148
|
+
return c;
|
|
149
|
+
}
|