rift-ds 1.24.0 → 1.26.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/README.md +5 -4
- package/chat/ChatThreads.d.ts +3 -1
- package/chat/ChatThreads.js +3 -1
- package/chat/ChatWidget.css +166 -15
- package/chat/ChatWidget.d.ts +6 -2
- package/chat/ChatWidget.js +17 -3
- package/components/ActionCard/ActionCard.d.ts +1 -1
- package/components/Attachment/Attachment.css +8 -0
- package/components/Attachment/AttachmentViewer.js +26 -5
- package/components/Attachment/fileTypes.d.ts +4 -0
- package/components/ContextMenu/ContextMenu.css +11 -0
- package/components/ContextMenu/ContextMenu.d.ts +1 -1
- package/components/ContextMenu/ContextMenu.js +3 -1
- package/components/CurrencyInput/CurrencyInput.css +12 -0
- package/components/CurrencyInput/CurrencyInput.d.ts +51 -0
- package/components/CurrencyInput/CurrencyInput.js +158 -0
- package/components/DataTable/columnTypes.js +4 -16
- package/components/DatePicker/DatePicker.d.ts +2 -0
- package/components/DatePicker/DatePicker.js +44 -131
- package/components/DatePicker/MonthGrid.d.ts +56 -0
- package/components/DatePicker/MonthGrid.js +65 -0
- package/components/DatePicker/calendar.d.ts +42 -0
- package/components/DatePicker/calendar.js +108 -0
- package/components/DateRangePicker/DateRangePicker.css +92 -0
- package/components/DateRangePicker/DateRangePicker.d.ts +86 -0
- package/components/DateRangePicker/DateRangePicker.js +294 -0
- package/components/Deadline/Deadline.css +82 -0
- package/components/Deadline/Deadline.d.ts +44 -0
- package/components/Deadline/Deadline.js +94 -0
- package/components/Deadline/deadlineStatus.d.ts +15 -0
- package/components/Deadline/deadlineStatus.js +13 -0
- package/components/DescriptionList/DescriptionList.css +184 -0
- package/components/DescriptionList/DescriptionList.d.ts +64 -0
- package/components/DescriptionList/DescriptionList.js +100 -0
- package/components/DescriptionList/DescriptionListCopy.d.ts +18 -0
- package/components/DescriptionList/DescriptionListCopy.js +45 -0
- package/components/DocumentViewer/DocumentViewer.css +188 -0
- package/components/DocumentViewer/DocumentViewer.d.ts +59 -0
- package/components/DocumentViewer/DocumentViewer.js +185 -0
- package/components/DropdownMenu/DropdownMenu.css +38 -0
- package/components/DropdownMenu/DropdownMenu.d.ts +4 -0
- package/components/DropdownMenu/DropdownMenu.js +11 -5
- package/components/DropdownMenu/ShortcutHint.d.ts +9 -0
- package/components/DropdownMenu/ShortcutHint.js +6 -0
- package/components/ErrorSummary/ErrorSummary.css +94 -0
- package/components/ErrorSummary/ErrorSummary.d.ts +34 -0
- package/components/ErrorSummary/ErrorSummary.js +70 -0
- package/components/ErrorSummary/fieldErrors.d.ts +36 -0
- package/components/ErrorSummary/fieldErrors.js +19 -0
- package/components/Field/Field.css +12 -0
- package/components/Field/Field.d.ts +10 -2
- package/components/Field/Field.js +12 -5
- package/components/Heading/Heading.css +129 -0
- package/components/Heading/Heading.d.ts +31 -0
- package/components/Heading/Heading.js +39 -0
- package/components/Input/Input.css +120 -0
- package/components/Input/Input.d.ts +20 -1
- package/components/Input/Input.js +70 -5
- package/components/InterruptCard/InterruptCard.d.ts +1 -1
- package/components/Link/Link.css +84 -0
- package/components/Link/Link.d.ts +43 -0
- package/components/Link/Link.js +74 -0
- package/components/List/List.css +173 -0
- package/components/List/List.d.ts +44 -0
- package/components/List/List.js +60 -0
- package/components/MaskedInput/MaskedInput.css +16 -0
- package/components/MaskedInput/MaskedInput.d.ts +57 -0
- package/components/MaskedInput/MaskedInput.js +142 -0
- package/components/MaskedInput/mask.d.ts +58 -0
- package/components/MaskedInput/mask.js +106 -0
- package/components/MessageCard/MessageCard.css +17 -6
- package/components/MessageCard/MessageCard.d.ts +1 -1
- package/components/ShaderScene/ShaderScene.css +19 -0
- package/components/ShaderScene/ShaderScene.d.ts +82 -0
- package/components/ShaderScene/ShaderScene.js +167 -0
- package/components/ShaderScene/assemble.d.ts +5 -0
- package/components/ShaderScene/assemble.js +76 -0
- package/components/ShaderScene/common.glsl.d.ts +6 -0
- package/components/ShaderScene/common.glsl.js +49 -0
- package/components/ShaderScene/passes.d.ts +2 -0
- package/components/ShaderScene/passes.js +93 -0
- package/components/ShaderScene/renderer.d.ts +39 -0
- package/components/ShaderScene/renderer.js +170 -0
- package/components/ShaderScene/scenes.d.ts +76 -0
- package/components/ShaderScene/scenes.js +752 -0
- package/components/ShaderScene/types.d.ts +83 -0
- package/components/ShaderScene/types.js +8 -0
- package/components/SignaturePad/SignaturePad.css +141 -0
- package/components/SignaturePad/SignaturePad.d.ts +68 -0
- package/components/SignaturePad/SignaturePad.js +287 -0
- package/components/SignaturePad/signature.d.ts +32 -0
- package/components/SignaturePad/signature.js +46 -0
- package/components/Text/Text.css +129 -0
- package/components/Text/Text.d.ts +36 -0
- package/components/Text/Text.js +36 -0
- package/components/ThreadPanel/ThreadPanel.css +29 -0
- package/components/ThreadPanel/ThreadPanel.d.ts +2 -0
- package/components/ThreadPanel/ThreadPanel.js +13 -2
- package/components/Widget/Widget.css +111 -0
- package/components/Widget/Widget.d.ts +15 -1
- package/components/Widget/Widget.js +63 -11
- package/components/Widget/WidgetDisclosure.d.ts +30 -0
- package/components/Widget/WidgetDisclosure.js +52 -0
- package/components/registry.json +111 -2
- package/components/registry.json.d.ts +111 -2
- package/components/registry.json.js +2 -2
- package/format/index.d.ts +15 -0
- package/format/index.js +17 -0
- package/format/money.d.ts +89 -0
- package/format/money.js +187 -0
- package/format/relative.d.ts +49 -0
- package/format/relative.js +50 -0
- package/index.d.ts +13 -0
- package/index.js +48 -1
- package/package.json +9 -2
- package/tokens/motion.d.ts +4 -0
- package/tokens/motion.js +4 -0
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
const horizon = {
|
|
2
|
+
id: "horizon",
|
|
3
|
+
label: "Horizon",
|
|
4
|
+
description: "A planet's limb at night, a fixed sun at the apex, a hazy world and ocean below.",
|
|
5
|
+
mode: "dark",
|
|
6
|
+
/* The background field's roles, the ones a preset tunes for ambient
|
|
7
|
+
shaders and a DESIGN.md import rewrites from the action colour: in the
|
|
8
|
+
base theme they are cobalt, amber, coral and gold, so the horizon's own
|
|
9
|
+
look is unchanged, and an import recolours it with the field. */
|
|
10
|
+
colours: [
|
|
11
|
+
"--color-ambient-4",
|
|
12
|
+
"--color-ambient-6",
|
|
13
|
+
"--color-ambient-5",
|
|
14
|
+
"--color-ambient-1"
|
|
15
|
+
],
|
|
16
|
+
params: [
|
|
17
|
+
{ key: "crown", label: "Horizon height", min: 0.15, max: 0.75, step: 0.01, default: 0.4 },
|
|
18
|
+
{ key: "curve", label: "Flatness", min: 1.5, max: 10, step: 0.1, default: 5 },
|
|
19
|
+
{ key: "warp", label: "Flow", min: 0, max: 0.2, step: 5e-3, default: 0.07 },
|
|
20
|
+
{ key: "glow", label: "Glow", min: 0, max: 2, step: 0.01, default: 1 },
|
|
21
|
+
{ key: "clouds", label: "Clouds", min: 0, max: 2, step: 0.01, default: 1 },
|
|
22
|
+
{ key: "ocean", label: "Ocean", min: 0, max: 2.5, step: 0.01, default: 1 },
|
|
23
|
+
{ key: "beam", label: "Beam", min: 0, max: 2.5, step: 0.01, default: 1 }
|
|
24
|
+
],
|
|
25
|
+
glsl: (
|
|
26
|
+
/* glsl */
|
|
27
|
+
`
|
|
28
|
+
#define u_scatter u_col[0]
|
|
29
|
+
#define u_halo u_col[1]
|
|
30
|
+
#define u_rim u_col[2]
|
|
31
|
+
#define u_sun u_col[3]
|
|
32
|
+
|
|
33
|
+
vec3 scene(vec2 uv, float t) {
|
|
34
|
+
float aspect = u_size.x / u_size.y;
|
|
35
|
+
vec2 p = vec2((uv.x - 0.5) * aspect, uv.y);
|
|
36
|
+
|
|
37
|
+
vec2 q = vec2(
|
|
38
|
+
fbm(p * 1.4 + vec2(0.0, t * 0.03)),
|
|
39
|
+
fbm(p * 1.4 + vec2(5.2, 1.3) - t * 0.024)
|
|
40
|
+
);
|
|
41
|
+
vec2 w = p + u_warp * (q - 0.5);
|
|
42
|
+
|
|
43
|
+
float crown = u_crown;
|
|
44
|
+
float radius = u_curve * max(aspect, 1.0);
|
|
45
|
+
vec2 centre = vec2(0.0, crown - radius);
|
|
46
|
+
vec2 wl = p + u_warp * 0.17 * (q - 0.5);
|
|
47
|
+
float d = length(wl - centre) - radius;
|
|
48
|
+
|
|
49
|
+
float halfW = 0.5 * aspect;
|
|
50
|
+
float sunX = exp(-pow(w.x, 2.0) / (2.0 * 0.28 * 0.28));
|
|
51
|
+
float wide = exp(-pow(w.x, 2.0) / (2.0 * 0.75 * 0.75));
|
|
52
|
+
float energy = (0.4 + 0.45 * wide + 0.9 * sunX) * u_glow;
|
|
53
|
+
float side = clamp(abs(w.x) / halfW, 0.0, 1.0);
|
|
54
|
+
|
|
55
|
+
float curtain = fbm(vec2(w.x * 5.0 + t * 0.05, d * 1.2 - t * 0.02));
|
|
56
|
+
float band = fbm(vec2(w.x * 1.2 - t * 0.035, d * 11.0 + t * 0.015));
|
|
57
|
+
float veil = fbm(vec2(w.x * 2.2 + t * 0.02, d * 3.5 - t * 0.01) + q * 1.5);
|
|
58
|
+
|
|
59
|
+
vec3 amber = mix(u_halo, u_sun, 0.35);
|
|
60
|
+
vec3 light = vec3(0.0);
|
|
61
|
+
light += u_scatter * lobe(d - 0.02, 0.24, 0.12) * (0.12 + 0.08 * curtain) * (0.7 + 0.5 * energy);
|
|
62
|
+
light += mix(u_scatter, vec3(1.0), 0.35) * lobe(d - 0.05, 0.12, 0.05)
|
|
63
|
+
* (0.06 + 0.16 * smoothstep(0.35, 0.8, curtain)) * energy;
|
|
64
|
+
light += mix(amber, u_rim, side * 0.4) * lobe(d - 0.01, 0.07, 0.045) * (0.35 + 0.35 * band) * energy;
|
|
65
|
+
light += mix(amber, u_sun, 0.3) * lobe(d, 0.02, 0.012) * (0.45 + 0.2 * band) * energy;
|
|
66
|
+
light += mix(amber, vec3(1.0), 0.35) * lobe(d - 0.002, 0.006, 0.003) * 0.55 * energy;
|
|
67
|
+
light += u_rim * lobe(d + 0.03, 0.05, 0.07) * (0.22 + 0.18 * veil) * (0.6 + 0.5 * energy);
|
|
68
|
+
light *= 1.0 - 0.8 * smoothstep(0.0, -0.4, d);
|
|
69
|
+
|
|
70
|
+
float below = max(-d, 0.0);
|
|
71
|
+
float onGround = smoothstep(0.002, -0.012, d);
|
|
72
|
+
float z = 1.0 / (below * 2.4 + 0.08);
|
|
73
|
+
vec2 sp = vec2(w.x * z * 0.55, z * 0.5);
|
|
74
|
+
float drift = t * 0.018;
|
|
75
|
+
|
|
76
|
+
vec2 lp = sp * 0.9 + vec2(drift * 0.4, drift);
|
|
77
|
+
float land = fbm(lp + 1.4 * vec2(fbm(lp * 0.7 + 3.1), fbm(lp * 0.7 + 8.4)));
|
|
78
|
+
land = smoothstep(0.42, 0.72, land);
|
|
79
|
+
vec2 cp = sp * 1.6 + vec2(-drift * 1.6, drift * 1.3);
|
|
80
|
+
float cloud = fbm(cp + 2.0 * vec2(fbm(cp * 0.5 + q), fbm(cp * 0.5 - q + 5.0)));
|
|
81
|
+
vec2 fp = sp * 3.4 + vec2(-drift * 2.4, drift * 1.8) + q * 0.8;
|
|
82
|
+
float fine = fbm(fp + 1.2 * vec2(fbm(fp * 0.6 + 2.3), fbm(fp * 0.6 + 6.1)));
|
|
83
|
+
cloud = smoothstep(0.42, 0.8, cloud);
|
|
84
|
+
cloud = clamp(cloud + 0.55 * smoothstep(0.5, 0.85, fine), 0.0, 1.0) * u_clouds;
|
|
85
|
+
float streaks = fbm(vec2(sp.x * 0.35 - drift * 2.0, sp.y * 4.0));
|
|
86
|
+
|
|
87
|
+
float reach = exp(-below / 0.45);
|
|
88
|
+
float near = exp(-below / 0.07);
|
|
89
|
+
vec3 world = vec3(0.0);
|
|
90
|
+
world += mix(u_ground, u_scatter, 0.5) * land * 0.14 * (0.35 + reach);
|
|
91
|
+
world += mix(u_scatter, vec3(1.0), 0.3) * cloud * 0.48 * reach;
|
|
92
|
+
world += mix(u_rim, amber, 0.4) * cloud * near * 0.6 * energy;
|
|
93
|
+
world += u_scatter * streaks * 0.08 * reach;
|
|
94
|
+
|
|
95
|
+
vec2 src = vec2(0.0, crown - 0.005);
|
|
96
|
+
vec2 r = p - src;
|
|
97
|
+
float ang = atan(r.x, -r.y);
|
|
98
|
+
float shafts = smoothstep(0.2, 0.95, fbm(vec2(ang * 1.6, 3.7)));
|
|
99
|
+
float cone = exp(-pow(ang, 2.0) / (2.0 * 0.55 * 0.55));
|
|
100
|
+
float dist = length(r);
|
|
101
|
+
float beams = shafts * cone * exp(-dist / 0.6);
|
|
102
|
+
vec3 beamColour = mix(mix(amber, u_sun, 0.3), u_scatter, smoothstep(0.08, 0.45, dist) * 0.7);
|
|
103
|
+
world += beamColour * beams * 0.45 * (0.65 + 0.5 * cloud) * u_beam;
|
|
104
|
+
|
|
105
|
+
float bloomSky = exp(-dot(r, r) / (2.0 * 0.09 * 0.09));
|
|
106
|
+
float bloomWide = exp(-dot(r, r) / (2.0 * 0.28 * 0.28));
|
|
107
|
+
light += mix(u_sun, vec3(1.0), 0.35) * (bloomSky * 0.45 + bloomWide * 0.12) * u_glow;
|
|
108
|
+
world += mix(u_sun, amber, 0.4) * bloomWide * 0.12 * u_glow;
|
|
109
|
+
|
|
110
|
+
float sea = smoothstep(0.02, 0.16, below) * (1.0 - 0.65 * land);
|
|
111
|
+
vec3 deep = mix(u_scatter, u_ground, 0.2);
|
|
112
|
+
world *= mix(vec3(1.0), normalize(u_scatter + 0.05) * 1.2, smoothstep(0.08, 0.3, below) * 0.5);
|
|
113
|
+
world += deep * sea * (0.16 + 0.07 * streaks + 0.05 * veil + 0.14 * cloud) * u_ocean;
|
|
114
|
+
|
|
115
|
+
light += world * onGround;
|
|
116
|
+
return u_ground + light;
|
|
117
|
+
}
|
|
118
|
+
`
|
|
119
|
+
)
|
|
120
|
+
};
|
|
121
|
+
const rift = {
|
|
122
|
+
id: "rift",
|
|
123
|
+
label: "Rift",
|
|
124
|
+
description: "A glowing tear in the page, opening at its middle, light streaming in.",
|
|
125
|
+
mode: "dark",
|
|
126
|
+
colours: ["--color-ambient-2", "--color-ambient-3", "--color-ambient-1"],
|
|
127
|
+
params: [
|
|
128
|
+
{ key: "offset", label: "Position", min: -0.45, max: 0.45, step: 0.01, default: 0 },
|
|
129
|
+
{ key: "open", label: "Opening", min: 0, max: 1.5, step: 0.01, default: 0.8 },
|
|
130
|
+
{ key: "glow", label: "Glow", min: 0, max: 2, step: 0.01, default: 1 },
|
|
131
|
+
{ key: "wave", label: "Wander", min: 0, max: 1, step: 0.01, default: 0.4 },
|
|
132
|
+
{ key: "streaks", label: "Streaks", min: 0, max: 2, step: 0.01, default: 1 },
|
|
133
|
+
{ key: "flow", label: "Flow", min: 0, max: 0.3, step: 5e-3, default: 0.08 }
|
|
134
|
+
],
|
|
135
|
+
glsl: (
|
|
136
|
+
/* glsl */
|
|
137
|
+
`
|
|
138
|
+
#define u_from u_col[0]
|
|
139
|
+
#define u_to u_col[1]
|
|
140
|
+
#define u_spark u_col[2]
|
|
141
|
+
|
|
142
|
+
vec3 scene(vec2 uv, float t) {
|
|
143
|
+
float aspect = u_size.x / u_size.y;
|
|
144
|
+
vec2 p = vec2((uv.x - 0.5) * aspect, uv.y - 0.5);
|
|
145
|
+
|
|
146
|
+
vec2 q = vec2(
|
|
147
|
+
fbm(p * 1.6 + vec2(0.0, t * 0.03)),
|
|
148
|
+
fbm(p * 1.6 + vec2(5.2, 1.3) - t * 0.025)
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
/* The tear's line, wandering slowly along its length. */
|
|
152
|
+
float cx = u_offset * aspect + u_wave * 0.35 * (fbm(vec2(p.y * 1.6, t * 0.04)) - 0.5);
|
|
153
|
+
float dx = p.x - cx + u_flow * (q.x - 0.5);
|
|
154
|
+
float ady = abs(dx);
|
|
155
|
+
|
|
156
|
+
/* Widest at the middle, a seam at the ends. */
|
|
157
|
+
float open = u_open * exp(-(p.y * p.y) / (2.0 * 0.3 * 0.3));
|
|
158
|
+
float coreW = 0.006 + 0.01 * open;
|
|
159
|
+
float glowW = 0.07 + 0.2 * open;
|
|
160
|
+
float core = exp(-(dx * dx) / (2.0 * coreW * coreW)) * (0.25 + 0.6 * open);
|
|
161
|
+
float glow = exp(-(dx * dx) / (2.0 * glowW * glowW)) * (0.25 + 0.75 * open);
|
|
162
|
+
float haze = exp(-ady / 0.38) * (0.4 + 0.6 * open);
|
|
163
|
+
|
|
164
|
+
/* Streaks drawn in toward the tear: bands that move inward over time. */
|
|
165
|
+
float s = fbm(vec2(ady * 3.0 + t * 0.35, p.y * 42.0 + q.y * 3.0));
|
|
166
|
+
float streak = smoothstep(0.58, 0.86, s) * exp(-ady / 0.2) * smoothstep(0.01, 0.06, ady) * u_streaks;
|
|
167
|
+
|
|
168
|
+
vec3 colour = mix(u_from, u_to, smoothstep(-0.45, 0.45, p.y + (q.y - 0.5) * 0.4));
|
|
169
|
+
vec3 light = vec3(0.0);
|
|
170
|
+
light += colour * glow * 0.7 * u_glow;
|
|
171
|
+
light += colour * haze * 0.1;
|
|
172
|
+
light += mix(colour, vec3(1.0), 0.45) * core * 0.7 * u_glow;
|
|
173
|
+
light += mix(colour, u_spark, 0.35) * streak * 0.22;
|
|
174
|
+
return u_ground + light;
|
|
175
|
+
}
|
|
176
|
+
`
|
|
177
|
+
)
|
|
178
|
+
};
|
|
179
|
+
const glyphs = {
|
|
180
|
+
id: "glyphs",
|
|
181
|
+
label: "Glyphs",
|
|
182
|
+
description: "Soft light printed in type: a streak and its blooms read through characters that thicken with the brightness.",
|
|
183
|
+
mode: "dark",
|
|
184
|
+
colours: [
|
|
185
|
+
"--color-ambient-4",
|
|
186
|
+
"--color-ambient-2",
|
|
187
|
+
"--color-ambient-1",
|
|
188
|
+
"--color-ambient-3",
|
|
189
|
+
"--color-ambient-5"
|
|
190
|
+
],
|
|
191
|
+
glyphs: ".·xxXXSO0#@",
|
|
192
|
+
/* Type at 1x on a 2x screen is soft, and this scene is cheap: six
|
|
193
|
+
Gaussians and two noise lookups a pixel. */
|
|
194
|
+
pixelRatio: 2,
|
|
195
|
+
params: [
|
|
196
|
+
{ key: "cell", label: "Type size", min: 6, max: 40, step: 1, default: 15 },
|
|
197
|
+
{ key: "ink", label: "Type strength", min: 0, max: 1, step: 0.01, default: 0.42 },
|
|
198
|
+
{ key: "density", label: "Density", min: 0.2, max: 4, step: 0.05, default: 1.6 },
|
|
199
|
+
{ key: "floor", label: "Floor", min: 0, max: 0.6, step: 0.01, default: 0.06 },
|
|
200
|
+
{ key: "scatter", label: "Scatter", min: 0, max: 1.5, step: 0.01, default: 0.55 },
|
|
201
|
+
{ key: "shimmer", label: "Shimmer", min: 0, max: 6, step: 0.1, default: 0.75 },
|
|
202
|
+
{ key: "exposure", label: "Exposure", min: 0.2, max: 4, step: 0.05, default: 1.25 },
|
|
203
|
+
{ key: "spread", label: "Spread", min: 0.3, max: 2.5, step: 0.05, default: 0.85 },
|
|
204
|
+
{ key: "warp", label: "Warp", min: 0, max: 2, step: 0.05, default: 0.6 },
|
|
205
|
+
{ key: "wave", label: "Wave", min: 0, max: 3, step: 0.05, default: 1 },
|
|
206
|
+
{ key: "drift", label: "Drift", min: 0, max: 3, step: 0.05, default: 1.4 },
|
|
207
|
+
{ key: "mosaic", label: "Mosaic", min: 0, max: 1, step: 0.01, default: 0 },
|
|
208
|
+
{ key: "rise", label: "Height", min: -0.45, max: 0.45, step: 0.01, default: 0 }
|
|
209
|
+
],
|
|
210
|
+
glsl: (
|
|
211
|
+
/* glsl */
|
|
212
|
+
`
|
|
213
|
+
/* A theme's ambient tones can be muted; pushed from their own grey and up
|
|
214
|
+
to full brightness they still read as hues once they are light. */
|
|
215
|
+
vec3 glyphHue(vec3 c) {
|
|
216
|
+
float grey = (c.r + c.g + c.b) / 3.0;
|
|
217
|
+
c = max(grey + (c - grey) * 1.8, vec3(0.0));
|
|
218
|
+
return c / max(max(c.r, max(c.g, c.b)), 1e-3);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* One stretched Gaussian light: centre in 0 to 1 across and up the stage,
|
|
222
|
+
half extents along and across its own axis in stage heights, a tilt. */
|
|
223
|
+
float glyphLamp(vec2 p, float aspect, vec2 centre, vec2 extent, float tilt, float k, float t) {
|
|
224
|
+
vec2 c = (centre - 0.5) * vec2(aspect, 1.0);
|
|
225
|
+
c += u_drift * 0.05 * vec2(sin(t * 0.13 + k * 1.7), cos(t * 0.11 + k * 2.3));
|
|
226
|
+
float a = tilt + u_drift * 0.06 * sin(t * 0.09 + k * 1.3);
|
|
227
|
+
vec2 d = p - c;
|
|
228
|
+
d = vec2(cos(a) * d.x + sin(a) * d.y, -sin(a) * d.x + cos(a) * d.y) / (extent * u_spread);
|
|
229
|
+
return (1.0 + u_drift * 0.12 * sin(t * 0.21 + k * 2.9)) * exp(-dot(d, d));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/* The light at a pixel, tone-mapped. */
|
|
233
|
+
vec3 glyphLight(vec2 frag, float t) {
|
|
234
|
+
float aspect = u_size.x / u_size.y;
|
|
235
|
+
vec2 p = (frag / u_size - 0.5) * vec2(aspect, 1.0);
|
|
236
|
+
p.y -= u_rise;
|
|
237
|
+
p += u_warp * 0.09 * (vec2(vnoise(p * 1.6 + t * 0.05), vnoise(p * 1.6 + 7.3 - t * 0.04)) - 0.5);
|
|
238
|
+
/* Slow travelling swells, so the streak rolls like a ribbon. */
|
|
239
|
+
p.y += u_wave * (0.045 * sin(p.x * 2.6 + t * 0.35) + 0.025 * sin(p.x * 5.3 - t * 0.27 + 1.7));
|
|
240
|
+
p.x += u_wave * 0.03 * sin(p.y * 3.1 + t * 0.22);
|
|
241
|
+
|
|
242
|
+
vec3 haze = glyphHue(u_col[0]);
|
|
243
|
+
vec3 bloom = glyphHue(u_col[1]);
|
|
244
|
+
vec3 streak = glyphHue(u_col[2]);
|
|
245
|
+
vec3 low = glyphHue(u_col[3]);
|
|
246
|
+
vec3 foot = glyphHue(u_col[4]);
|
|
247
|
+
vec3 core = mix((haze + bloom + streak + low + foot) / 5.0, vec3(1.0), 0.85);
|
|
248
|
+
|
|
249
|
+
vec3 c = u_ground;
|
|
250
|
+
c += haze * 0.55 * glyphLamp(p, aspect, vec2(0.47, 0.62), vec2(0.95, 0.3), 0.05, 0.0, t);
|
|
251
|
+
c += bloom * 0.95 * glyphLamp(p, aspect, vec2(0.66, 0.74), vec2(0.5, 0.17), 0.2, 1.0, t);
|
|
252
|
+
c += core * 1.7 * glyphLamp(p, aspect, vec2(0.68, 0.625), vec2(0.3, 0.045), 0.0, 2.0, t);
|
|
253
|
+
c += streak * 1.5 * glyphLamp(p, aspect, vec2(0.3, 0.585), vec2(0.62, 0.011), 0.0, 3.0, t);
|
|
254
|
+
c += low * 1.0 * glyphLamp(p, aspect, vec2(0.8, 0.42), vec2(0.36, 0.2), -0.7, 4.0, t);
|
|
255
|
+
c += foot * 0.75 * glyphLamp(p, aspect, vec2(0.76, 0.2), vec2(0.4, 0.16), -1.1, 5.0, t);
|
|
256
|
+
return u_ground + (1.0 - exp(-(c - u_ground) * u_exposure));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
vec3 scene(vec2 uv, float t) {
|
|
260
|
+
vec2 frag = uv * u_size;
|
|
261
|
+
float cellH = max(4.0, floor(u_cell * u_ratio + 0.5));
|
|
262
|
+
vec2 size = vec2(cellH * 0.6, cellH);
|
|
263
|
+
vec2 cell = floor(frag / size);
|
|
264
|
+
vec2 local = fract(frag / size);
|
|
265
|
+
|
|
266
|
+
vec3 blocky = glyphLight((cell + 0.5) * size, t);
|
|
267
|
+
vec3 col = mix(glyphLight(frag, t), blocky, u_mosaic);
|
|
268
|
+
/* A mosaic shows its seams. */
|
|
269
|
+
vec2 edge = min(local, 1.0 - local) * size;
|
|
270
|
+
col = mix(col, u_ground, u_mosaic * 0.3 * (1.0 - smoothstep(0.0, 1.5 * u_ratio, min(edge.x, edge.y))));
|
|
271
|
+
|
|
272
|
+
float lum = dot(blocky - u_ground, vec3(0.2126, 0.7152, 0.0722));
|
|
273
|
+
float beat = t * u_shimmer;
|
|
274
|
+
int tick = int(mod(floor(beat), 512.0));
|
|
275
|
+
ivec2 at = ivec2(cell) + 2048;
|
|
276
|
+
float roll = mix(rnd(at + tick * ivec2(17, 31)), rnd(at + (tick + 1) * ivec2(17, 31)),
|
|
277
|
+
smoothstep(0.0, 1.0, fract(beat)));
|
|
278
|
+
float v = (lum - u_floor) / (1.0 - u_floor) * u_density
|
|
279
|
+
+ (roll - 0.5) * u_scatter * min(1.0, lum * 6.0 + 0.15);
|
|
280
|
+
float g = max(v, 0.0) * u_glyphCount;
|
|
281
|
+
float first = min(u_glyphCount - 1.0, floor(g));
|
|
282
|
+
float second = min(u_glyphCount - 1.0, first + 1.0);
|
|
283
|
+
float ink = mix(texture(u_glyphs, vec2((first + local.x) / u_glyphCount, local.y)).r,
|
|
284
|
+
texture(u_glyphs, vec2((second + local.x) / u_glyphCount, local.y)).r,
|
|
285
|
+
smoothstep(0.25, 0.75, fract(g)));
|
|
286
|
+
return mix(col, vec3(1.0), ink * u_ink * smoothstep(0.0, 0.1, v) * (0.45 + 0.55 * min(1.0, v)));
|
|
287
|
+
}
|
|
288
|
+
`
|
|
289
|
+
)
|
|
290
|
+
};
|
|
291
|
+
const prism = {
|
|
292
|
+
id: "prism",
|
|
293
|
+
label: "Prism",
|
|
294
|
+
description: "Beams of light from a cut stone, uneven in strength, their edges split into the theme's spectrum.",
|
|
295
|
+
mode: "dark",
|
|
296
|
+
colours: [
|
|
297
|
+
"--color-ambient-5",
|
|
298
|
+
"--color-ambient-6",
|
|
299
|
+
"--color-ambient-1",
|
|
300
|
+
"--color-ambient-2",
|
|
301
|
+
"--color-ambient-4"
|
|
302
|
+
],
|
|
303
|
+
params: [
|
|
304
|
+
{ key: "offset", label: "Position", min: -0.5, max: 0.5, step: 0.01, default: 0.12 },
|
|
305
|
+
{ key: "spread", label: "Spread", min: 0, max: 2, step: 0.01, default: 0.6 },
|
|
306
|
+
{ key: "tilt", label: "Tilt", min: -1, max: 1, step: 0.01, default: -0.25 },
|
|
307
|
+
{ key: "fan", label: "Fan", min: 0, max: 3, step: 0.01, default: 1 },
|
|
308
|
+
{ key: "beams", label: "Beams", min: 1, max: 10, step: 1, default: 7 },
|
|
309
|
+
{ key: "sharp", label: "Sharpness", min: 0, max: 1, step: 0.01, default: 0.35 },
|
|
310
|
+
{ key: "dispersion", label: "Dispersion", min: 0, max: 2, step: 0.01, default: 1 },
|
|
311
|
+
{ key: "bleed", label: "Bleed", min: 0, max: 2, step: 0.01, default: 1 },
|
|
312
|
+
{ key: "glow", label: "Glow", min: 0, max: 2, step: 0.01, default: 1 },
|
|
313
|
+
{ key: "drift", label: "Drift", min: 0, max: 3, step: 0.05, default: 1 }
|
|
314
|
+
],
|
|
315
|
+
glsl: (
|
|
316
|
+
/* glsl */
|
|
317
|
+
`
|
|
318
|
+
/* A theme's ambient tones can be muted; pushed from their own grey and up
|
|
319
|
+
to full brightness they read as a spectrum once they are light. */
|
|
320
|
+
vec3 prismHue(vec3 c) {
|
|
321
|
+
float grey = (c.r + c.g + c.b) / 3.0;
|
|
322
|
+
c = max(grey + (c - grey) * 1.8, vec3(0.0));
|
|
323
|
+
return c / max(max(c.r, max(c.g, c.b)), 1e-3);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
vec3 scene(vec2 uv, float t) {
|
|
327
|
+
float aspect = u_size.x / u_size.y;
|
|
328
|
+
vec2 p = vec2((uv.x - 0.5) * aspect, uv.y - 0.5);
|
|
329
|
+
t *= u_drift;
|
|
330
|
+
|
|
331
|
+
vec3 hues[5];
|
|
332
|
+
vec3 total = vec3(0.0);
|
|
333
|
+
for (int k = 0; k < 5; k++) {
|
|
334
|
+
hues[k] = prismHue(u_col[k]);
|
|
335
|
+
total += hues[k];
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
float edge = mix(0.95, 0.12, u_sharp);
|
|
339
|
+
vec3 light = vec3(0.0);
|
|
340
|
+
for (int i = 0; i < 10; i++) {
|
|
341
|
+
if (float(i) >= u_beams) break;
|
|
342
|
+
ivec2 id = ivec2(i * 37 + 5, 91);
|
|
343
|
+
/* The facet this beam leaves, above the stage, and the way it points. */
|
|
344
|
+
vec2 facet = vec2(
|
|
345
|
+
u_offset * aspect + (rnd(id) - 0.5) * (0.25 + 0.5 * u_spread),
|
|
346
|
+
0.58 + 0.5 * rnd(id + 1)
|
|
347
|
+
);
|
|
348
|
+
float angle = u_tilt * 0.7 + (rnd(id + 2) - 0.5) * 1.5 * u_spread
|
|
349
|
+
+ 0.05 * sin(t * (0.05 + 0.06 * rnd(id + 3)) + 6.28 * rnd(id + 4));
|
|
350
|
+
vec2 dir = vec2(sin(angle), -cos(angle));
|
|
351
|
+
vec2 rel = p - facet;
|
|
352
|
+
float run = dot(rel, dir);
|
|
353
|
+
if (run <= 0.0) continue;
|
|
354
|
+
float across = dot(rel, vec2(dir.y, -dir.x));
|
|
355
|
+
|
|
356
|
+
/* A few strong beams among faint ones, each breathing as the stone turns. */
|
|
357
|
+
float strength = pow(rnd(id + 5), 2.2)
|
|
358
|
+
* (0.45 + 0.55 * sin(t * (0.04 + 0.05 * rnd(id + 6)) + 6.28 * rnd(id + 7)));
|
|
359
|
+
strength = max(strength, 0.0) + 0.012;
|
|
360
|
+
float mouth = 0.004 + 0.035 * rnd(id + 8) * rnd(id + 8);
|
|
361
|
+
float halfW = mouth + u_fan * (0.008 + 0.035 * rnd(id + 9)) * run;
|
|
362
|
+
float split = (0.5 + rnd(id + 10)) * 0.13 * u_dispersion * run;
|
|
363
|
+
/* It thins as it opens and gives out with distance. */
|
|
364
|
+
float carry = pow((mouth + 0.02) / (halfW + 0.02), 0.7) * exp(-run / (0.9 + 1.4 * rnd(id + 11)));
|
|
365
|
+
|
|
366
|
+
vec3 beam = vec3(0.0);
|
|
367
|
+
for (int k = 0; k < 5; k++) {
|
|
368
|
+
float off = abs(across - (float(k) / 4.0 - 0.5) * split);
|
|
369
|
+
float body = 1.0 - smoothstep(halfW * (1.0 - edge), halfW * (1.0 + edge) + 0.002, off);
|
|
370
|
+
float halo = exp(-(off * off) / (2.0 * (halfW * 1.7 + 0.015) * (halfW * 1.7 + 0.015)));
|
|
371
|
+
beam += hues[k] * (body + 0.1 * u_bleed * halo);
|
|
372
|
+
}
|
|
373
|
+
/* Every colour in one place is white light. */
|
|
374
|
+
light += beam / max(total, vec3(1e-3)) * strength * carry;
|
|
375
|
+
}
|
|
376
|
+
return u_ground + light * 0.5 * u_glow;
|
|
377
|
+
}
|
|
378
|
+
`
|
|
379
|
+
)
|
|
380
|
+
};
|
|
381
|
+
const meteors = {
|
|
382
|
+
id: "meteors",
|
|
383
|
+
label: "Meteors",
|
|
384
|
+
description: "A meteor shower over a planet's edge, a sun flaring on the limb.",
|
|
385
|
+
mode: "dark",
|
|
386
|
+
colours: [
|
|
387
|
+
"--color-ambient-2",
|
|
388
|
+
"--color-ambient-3",
|
|
389
|
+
"--color-ambient-5",
|
|
390
|
+
"--color-ambient-1",
|
|
391
|
+
"--color-ambient-4"
|
|
392
|
+
],
|
|
393
|
+
params: [
|
|
394
|
+
{ key: "crown", label: "Limb height", min: -0.2, max: 0.7, step: 0.01, default: 0.26 },
|
|
395
|
+
{ key: "curve", label: "Flatness", min: 0.8, max: 8, step: 0.1, default: 2.2 },
|
|
396
|
+
{ key: "lean", label: "Lean", min: -0.6, max: 0.6, step: 0.01, default: -0.18 },
|
|
397
|
+
{ key: "sun", label: "Sun position", min: -0.5, max: 0.5, step: 0.01, default: 0.22 },
|
|
398
|
+
{ key: "flare", label: "Flare", min: 0, max: 2, step: 0.01, default: 1 },
|
|
399
|
+
{ key: "glow", label: "Glow", min: 0, max: 2, step: 0.01, default: 1 },
|
|
400
|
+
{ key: "shower", label: "Shower", min: 0, max: 2, step: 0.01, default: 1 },
|
|
401
|
+
{ key: "angle", label: "Fall angle", min: -1.2, max: 1.2, step: 0.01, default: 0.38 },
|
|
402
|
+
{ key: "tail", label: "Tail length", min: 0.2, max: 3, step: 0.01, default: 1 },
|
|
403
|
+
{ key: "fall", label: "Fall speed", min: 0, max: 3, step: 0.01, default: 1 },
|
|
404
|
+
{ key: "stars", label: "Stars", min: 0, max: 2, step: 0.01, default: 1 },
|
|
405
|
+
{ key: "soft", label: "Softness", min: 0, max: 2, step: 0.01, default: 1 }
|
|
406
|
+
],
|
|
407
|
+
glsl: (
|
|
408
|
+
/* glsl */
|
|
409
|
+
`
|
|
410
|
+
vec3 meteorHue(vec3 c) {
|
|
411
|
+
float grey = (c.r + c.g + c.b) / 3.0;
|
|
412
|
+
c = max(grey + (c - grey) * 1.8, vec3(0.0));
|
|
413
|
+
return c / max(max(c.r, max(c.g, c.b)), 1e-3);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
vec3 scene(vec2 uv, float t) {
|
|
417
|
+
float aspect = u_size.x / u_size.y;
|
|
418
|
+
vec2 p = vec2((uv.x - 0.5) * aspect, uv.y);
|
|
419
|
+
float px = 1.0 / u_size.y;
|
|
420
|
+
|
|
421
|
+
vec3 near = meteorHue(u_col[0]);
|
|
422
|
+
vec3 far = meteorHue(u_col[1]);
|
|
423
|
+
vec3 ember = meteorHue(u_col[2]);
|
|
424
|
+
vec3 sunTint = meteorHue(u_col[3]);
|
|
425
|
+
vec3 deep = meteorHue(u_col[4]);
|
|
426
|
+
|
|
427
|
+
/* ---- The limb: a circle far larger than the stage, leaning. */
|
|
428
|
+
float radius = u_curve * max(aspect, 1.0);
|
|
429
|
+
vec2 centre = vec2(u_lean * radius, u_crown - radius * sqrt(max(1.0 - u_lean * u_lean, 0.05)));
|
|
430
|
+
float d = length(p - centre) - radius;
|
|
431
|
+
float sky = smoothstep(0.0, 2.0 * px + 0.012 * u_soft, d);
|
|
432
|
+
/* The sun sits on the edge, over its own place across the stage. */
|
|
433
|
+
float sx = u_sun * aspect;
|
|
434
|
+
float reachX = clamp(sx - centre.x, -radius * 0.98, radius * 0.98);
|
|
435
|
+
vec2 sun = vec2(sx, centre.y + sqrt(radius * radius - reachX * reachX) + 0.004);
|
|
436
|
+
vec2 r = p - sun;
|
|
437
|
+
float fromSun = length(r);
|
|
438
|
+
float lit = exp(-fromSun / 0.55);
|
|
439
|
+
float litWide = exp(-fromSun / 1.4);
|
|
440
|
+
|
|
441
|
+
vec3 light = vec3(0.0);
|
|
442
|
+
|
|
443
|
+
/* ---- Stars, one to a cell at most. */
|
|
444
|
+
vec2 frag = uv * u_size;
|
|
445
|
+
ivec2 cell = ivec2(floor(frag / 30.0));
|
|
446
|
+
vec2 at = (vec2(cell) + 0.15 + 0.7 * vec2(rnd(cell + 37), rnd(cell + 71))) * 30.0;
|
|
447
|
+
float sd = length(frag - at);
|
|
448
|
+
float pick = rnd(cell + 911);
|
|
449
|
+
float star = exp(-(sd * sd) / (2.0 * 0.7 * 0.7)) * step(0.74, pick) * 0.32
|
|
450
|
+
* (0.25 + 0.75 * pow(rnd(cell + 5), 3.0))
|
|
451
|
+
* (0.7 + 0.3 * sin(t * (0.5 + 1.5 * rnd(cell + 13)) + 40.0 * pick));
|
|
452
|
+
light += mix(vec3(1.0), mix(near, far, rnd(cell + 3)), 0.3) * star * u_stars * (1.0 - 0.8 * exp(-fromSun / 0.18));
|
|
453
|
+
|
|
454
|
+
/* ---- The shower: lanes across the fall, three depths of them. */
|
|
455
|
+
vec2 dir = vec2(-sin(u_angle), -cos(u_angle));
|
|
456
|
+
vec2 q = vec2(p.x, p.y - 0.5);
|
|
457
|
+
float a = dot(q, vec2(-dir.y, dir.x));
|
|
458
|
+
float b = dot(q, dir);
|
|
459
|
+
/* Long enough that a meteor and its whole tail are off the stage when
|
|
460
|
+
its lane starts over, so none ever blinks out. */
|
|
461
|
+
float span = 2.0 + aspect + u_tail;
|
|
462
|
+
for (int i = 0; i < 3; i++) {
|
|
463
|
+
float depth = 1.0 + float(i) * 0.7;
|
|
464
|
+
float laneW = 0.13 / depth;
|
|
465
|
+
float lane = floor(a / laneW);
|
|
466
|
+
ivec2 id = ivec2(int(lane) + 2048, i * 57 + 3);
|
|
467
|
+
float u = t * u_fall * (0.1 + 0.16 * rnd(id)) / depth + rnd(id + 11) * 17.0;
|
|
468
|
+
ivec2 pass = id + ivec2(0, int(mod(floor(u), 512.0)) * 131 + 7);
|
|
469
|
+
float there = step(1.0 - 0.7 * u_shower, rnd(pass + 5));
|
|
470
|
+
float head = (fract(u) - 0.5) * span;
|
|
471
|
+
float ax = (lane + 0.2 + 0.6 * rnd(pass + 9)) * laneW;
|
|
472
|
+
float len = u_tail * (0.16 + 0.34 * rnd(pass + 13)) / depth;
|
|
473
|
+
float back = (head - b) / len;
|
|
474
|
+
float w = max((0.0011 + 0.0012 * rnd(pass + 17)) * (1.0 + 0.5 * u_soft) / depth, 0.6 * px) * (1.0 - 0.5 * clamp(back, 0.0, 1.0));
|
|
475
|
+
float across = exp(-pow((a - ax) / w, 2.0) * 0.5);
|
|
476
|
+
float trail = smoothstep(-3.0 * w / len, 0.25 * u_soft, back) * pow(max(1.0 - back, 0.0), 1.6);
|
|
477
|
+
vec3 tint = mix(vec3(1.0), near, smoothstep(0.0, 0.22, back));
|
|
478
|
+
tint = mix(tint, ember, smoothstep(0.2, 0.6, back));
|
|
479
|
+
tint = mix(tint, far, smoothstep(0.55, 1.0, back));
|
|
480
|
+
light += tint * across * trail * there * (0.3 + 0.7 * rnd(pass + 21)) * 0.55 / (1.0 + 1.2 * u_soft) / sqrt(depth);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/* ---- Air on the limb: a thin wash, cool away from the sun. */
|
|
484
|
+
vec3 air = mix(far, near, lit);
|
|
485
|
+
light += air * lobe(d - 0.012, 0.06, 0.02) * (0.015 + 0.08 * litWide) * u_glow;
|
|
486
|
+
light += deep * lobe(d, 0.3, 0.05) * 0.012 * litWide * u_glow;
|
|
487
|
+
light *= sky;
|
|
488
|
+
|
|
489
|
+
/* ---- The planet's lit edge: a band of light with no line in it, wide
|
|
490
|
+
by the sun and thinning to nothing away from it. */
|
|
491
|
+
float blur = 0.004 + 0.02 * u_soft;
|
|
492
|
+
float litMid = exp(-fromSun / 0.75);
|
|
493
|
+
float band = lobe(d + 0.3 * blur, blur * (0.12 + 1.1 * litMid), blur * (0.15 + 1.9 * litMid));
|
|
494
|
+
vec3 edge = mix(air, vec3(1.0), 0.3 + 0.55 * litMid);
|
|
495
|
+
light += edge * band * (0.06 + 0.6 * litMid * litMid) * u_glow;
|
|
496
|
+
|
|
497
|
+
/* ---- The sun: a soft core, a bloom, and four short spikes that the
|
|
498
|
+
softness melts into it. */
|
|
499
|
+
float coreR = 0.01 + 0.008 * u_soft;
|
|
500
|
+
float core = exp(-dot(r, r) / (2.0 * coreR * coreR));
|
|
501
|
+
float bloom = exp(-dot(r, r) / (2.0 * 0.07 * 0.07)) * 0.3 + exp(-fromSun / 0.16) * 0.1;
|
|
502
|
+
vec2 k = vec2(r.x + r.y, r.x - r.y) * 0.7071;
|
|
503
|
+
float thick = 0.006 + 0.012 * u_soft;
|
|
504
|
+
float spikes = exp(-pow(k.x / thick, 2.0) * 0.5) * exp(-abs(k.y) / 0.09)
|
|
505
|
+
+ exp(-pow(k.y / thick, 2.0) * 0.5) * exp(-abs(k.x) / 0.09);
|
|
506
|
+
float veil = mix(0.5, 1.0, sky);
|
|
507
|
+
light += mix(sunTint, vec3(1.0), 0.85) * (core * 0.55 + spikes * 0.6 / (1.0 + u_soft) * veil) * u_flare;
|
|
508
|
+
light += mix(sunTint, vec3(1.0), 0.7) * bloom * veil * u_flare;
|
|
509
|
+
|
|
510
|
+
return u_ground + light;
|
|
511
|
+
}
|
|
512
|
+
`
|
|
513
|
+
)
|
|
514
|
+
};
|
|
515
|
+
const waves = {
|
|
516
|
+
id: "waves",
|
|
517
|
+
label: "Waves",
|
|
518
|
+
description: "A sea of points rolling off into the dark, bright on the crests, over a deep glow.",
|
|
519
|
+
mode: "dark",
|
|
520
|
+
colours: ["--color-ambient-4", "--color-ambient-3", "--color-ambient-2"],
|
|
521
|
+
params: [
|
|
522
|
+
{ key: "rise", label: "Height", min: -0.3, max: 0.9, step: 0.01, default: 0.12 },
|
|
523
|
+
{ key: "pitch", label: "View", min: 0.15, max: 1.2, step: 0.01, default: 0.3 },
|
|
524
|
+
{ key: "swell", label: "Swell", min: 0, max: 2, step: 0.01, default: 1 },
|
|
525
|
+
{ key: "wavelength", label: "Wave length", min: 0.4, max: 3, step: 0.01, default: 1 },
|
|
526
|
+
{ key: "density", label: "Density", min: 3, max: 30, step: 0.5, default: 16 },
|
|
527
|
+
{ key: "dot", label: "Dot size", min: 0.3, max: 2, step: 0.01, default: 1 },
|
|
528
|
+
{ key: "glow", label: "Glow", min: 0, max: 2, step: 0.01, default: 1 },
|
|
529
|
+
{ key: "reach", label: "Reach", min: 0.2, max: 3, step: 0.01, default: 1 },
|
|
530
|
+
{ key: "drift", label: "Drift", min: 0, max: 3, step: 0.05, default: 1 }
|
|
531
|
+
],
|
|
532
|
+
glsl: (
|
|
533
|
+
/* glsl */
|
|
534
|
+
`
|
|
535
|
+
vec3 waveHue(vec3 c) {
|
|
536
|
+
float grey = (c.r + c.g + c.b) / 3.0;
|
|
537
|
+
c = max(grey + (c - grey) * 1.8, vec3(0.0));
|
|
538
|
+
return c / max(max(c.r, max(c.g, c.b)), 1e-3);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const float WAVE_LENS = 1.6;
|
|
542
|
+
|
|
543
|
+
/* The sea's height at a place on the plane, -1 to 1. */
|
|
544
|
+
float waveHeight(vec2 q, float t) {
|
|
545
|
+
q /= u_wavelength;
|
|
546
|
+
float h = 0.5 * sin(dot(q, vec2(0.62, 0.78)) * 1.15 + t * 0.3)
|
|
547
|
+
+ 0.28 * sin(dot(q, vec2(-0.74, 0.55)) * 2.1 - t * 0.23 + 1.3)
|
|
548
|
+
+ 0.7 * (vnoise(q * 0.5 + vec2(0.0, t * 0.05)) - 0.5);
|
|
549
|
+
return h / 1.13;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
vec3 scene(vec2 uv, float t) {
|
|
553
|
+
float aspect = u_size.x / u_size.y;
|
|
554
|
+
vec2 p = vec2((uv.x - 0.5) * aspect, uv.y - u_rise);
|
|
555
|
+
float px = 1.0 / u_size.y;
|
|
556
|
+
t *= u_drift;
|
|
557
|
+
|
|
558
|
+
vec3 deep = waveHue(u_col[0]);
|
|
559
|
+
vec3 smoke = waveHue(u_col[1]);
|
|
560
|
+
vec3 crest = mix(mix(deep, waveHue(u_col[2]), 0.25), vec3(1.0), 0.65);
|
|
561
|
+
|
|
562
|
+
/* An eye one unit over the plane, looking down at it by the pitch. The
|
|
563
|
+
ray through this pixel falls by 'fall' and runs out by 'run' a step. */
|
|
564
|
+
float cp = cos(u_pitch);
|
|
565
|
+
float sp = sin(u_pitch);
|
|
566
|
+
float fall = WAVE_LENS * sp - p.y * cp;
|
|
567
|
+
float run = WAVE_LENS * cp + p.y * sp;
|
|
568
|
+
float amp = 0.3 * u_swell;
|
|
569
|
+
float farZ = 6.6 * u_reach;
|
|
570
|
+
vec3 light = vec3(0.0);
|
|
571
|
+
|
|
572
|
+
if (fall > 1e-4 && run > 1e-4) {
|
|
573
|
+
/* The ray can only meet the sea inside the slab the swells occupy. */
|
|
574
|
+
float enter = (1.0 - amp) / fall;
|
|
575
|
+
float leave = min((1.0 + amp) / fall, 2.5 * farZ / run);
|
|
576
|
+
/* March by the clear height over the sea, divided by the fastest the
|
|
577
|
+
ray and the sea can close on each other, so a step can never pass
|
|
578
|
+
through a crest: fixed strides did, and whether a thin crest was
|
|
579
|
+
caught turned on where the samples fell, so patches of sea flickered
|
|
580
|
+
as the swell moved. Steps shrink toward the surface; a ray still
|
|
581
|
+
short of it when they run out is grazing a crest, and rests there. */
|
|
582
|
+
float closing = fall + amp * 1.7 / u_wavelength * length(vec2(p.x, run));
|
|
583
|
+
float k = enter;
|
|
584
|
+
/* The last crest the ray cleared on its way: where its height over
|
|
585
|
+
the sea stopped falling and rose again. */
|
|
586
|
+
float skimK = -1.0;
|
|
587
|
+
float lastOver = 1e3;
|
|
588
|
+
float lastK = enter;
|
|
589
|
+
bool falling = false;
|
|
590
|
+
for (int i = 0; i < 72; i++) {
|
|
591
|
+
float over = (1.0 - fall * k) - amp * waveHeight(vec2(p.x * k, run * k), t);
|
|
592
|
+
if (over < 0.0015 * k || k > leave) break;
|
|
593
|
+
if (over > lastOver && falling) skimK = lastK;
|
|
594
|
+
falling = over < lastOver;
|
|
595
|
+
lastOver = over;
|
|
596
|
+
lastK = k;
|
|
597
|
+
k += over / closing;
|
|
598
|
+
}
|
|
599
|
+
k = min(k, leave);
|
|
600
|
+
|
|
601
|
+
vec2 at = vec2(p.x * k, run * k);
|
|
602
|
+
float z = at.y;
|
|
603
|
+
float h = waveHeight(at, t);
|
|
604
|
+
float lift = smoothstep(-0.7, 0.8, h);
|
|
605
|
+
/* Black takes the far sea, and starkly: the dots go first, over a
|
|
606
|
+
short run, and the glow under them a little further out. The near
|
|
607
|
+
edge eases in. */
|
|
608
|
+
float nearEdge = smoothstep(0.0, 0.08, uv.y);
|
|
609
|
+
float fog = exp(-pow(z / (0.8 * farZ), 4.0)) * nearEdge;
|
|
610
|
+
float dotFog = exp(-pow(z / (0.56 * farZ), 6.0)) * nearEdge;
|
|
611
|
+
|
|
612
|
+
/* The glow in the water, smoky, brighter under a crest. */
|
|
613
|
+
float cloud = fbm(at * 0.3 + vec2(t * 0.03, -t * 0.02));
|
|
614
|
+
vec3 body = mix(deep, smoke, 0.3 * smoothstep(0.35, 0.75, cloud));
|
|
615
|
+
light += body * (0.04 + 0.22 * lift * lift) * (0.35 + 0.9 * cloud) * fog * u_glow;
|
|
616
|
+
|
|
617
|
+
/* The dots: this row's and the rows before and behind it, each drawn
|
|
618
|
+
round on the screen from its own place on the surface. */
|
|
619
|
+
float cellW = 1.0 / u_density;
|
|
620
|
+
float row = floor(z / cellW);
|
|
621
|
+
/* The rows either side of where the ray lands, three each way: seen
|
|
622
|
+
side-on a swell packs its rows closer than a dot is wide, and a dot
|
|
623
|
+
left out of the search was a notch in its neighbours that came and
|
|
624
|
+
went as the swell moved. */
|
|
625
|
+
/* And a dot stands proud of the surface it sits on, so one on a crest
|
|
626
|
+
shows above the crest's edge, where the ray has already gone past
|
|
627
|
+
to the sea behind: the rows at the crest it last cleared are looked
|
|
628
|
+
at too, or those dots are cut flat along every crest. */
|
|
629
|
+
float skimRow = skimK > 0.0 ? floor(run * skimK / cellW) : row;
|
|
630
|
+
float dots = 0.0;
|
|
631
|
+
vec2 before = p;
|
|
632
|
+
vec2 behind = p;
|
|
633
|
+
float here = 0.0;
|
|
634
|
+
for (int j = -3; j <= 6; j++) {
|
|
635
|
+
float r = j <= 3 ? row + float(j) : skimRow + float(j - 5);
|
|
636
|
+
if (j > 3 && abs(r - row) < 3.5) continue;
|
|
637
|
+
float cz = (r + 0.5) * cellW;
|
|
638
|
+
/* Where this ray is when it is that far out, to pick the column. */
|
|
639
|
+
float kz = cz / run;
|
|
640
|
+
/* Every other row sits half a cell across, like a halftone. */
|
|
641
|
+
float stagger = 0.5 * mod(r, 2.0);
|
|
642
|
+
float cx = (floor(p.x * kz / cellW - stagger) + 0.5 + stagger) * cellW;
|
|
643
|
+
float ch = waveHeight(vec2(cx, cz), t);
|
|
644
|
+
float cy = amp * ch - 1.0;
|
|
645
|
+
float depth = max(cz * cp - cy * sp, 1e-3);
|
|
646
|
+
vec2 on = vec2(cx, cy * cp + cz * sp) * WAVE_LENS / depth;
|
|
647
|
+
if (j == -1) before = on;
|
|
648
|
+
if (j == 1) behind = on;
|
|
649
|
+
float up = smoothstep(-0.7, 0.8, ch);
|
|
650
|
+
float rad = 0.15 * cellW * u_dot * (0.4 + 0.6 * up) * WAVE_LENS / depth;
|
|
651
|
+
if (j == 0) here = rad;
|
|
652
|
+
/* A dot finer than a pixel is drawn a pixel wide and that much
|
|
653
|
+
fainter, with a softer edge, so it glides rather than snapping
|
|
654
|
+
from one pixel to the next. */
|
|
655
|
+
float shown = max(rad, 1.2 * px);
|
|
656
|
+
float soft = px * mix(1.5, 1.0, smoothstep(1.5 * px, 4.0 * px, rad));
|
|
657
|
+
float disc = 1.0 - smoothstep(shown - soft, shown + soft, length(p - on));
|
|
658
|
+
dots = max(dots, disc * (rad * rad) / (shown * shown) * (0.1 + 0.9 * up * up));
|
|
659
|
+
}
|
|
660
|
+
/* Where the rows are finer than the pixels, or the dots themselves
|
|
661
|
+
are, they become their average: a field of points too small to
|
|
662
|
+
draw can only twinkle. */
|
|
663
|
+
float rowPx = 0.5 * length(behind - before) / px;
|
|
664
|
+
float even = 0.06 * u_dot * u_dot * (0.1 + 0.9 * lift * lift);
|
|
665
|
+
dots = mix(even, dots, smoothstep(1.5, 3.5, rowPx) * smoothstep(0.7, 1.6, here / px));
|
|
666
|
+
light += mix(deep, crest, 0.3 + 0.7 * lift) * dots * dotFog * 1.3;
|
|
667
|
+
}
|
|
668
|
+
return u_ground + light;
|
|
669
|
+
}
|
|
670
|
+
`
|
|
671
|
+
)
|
|
672
|
+
};
|
|
673
|
+
const aurora = {
|
|
674
|
+
id: "aurora",
|
|
675
|
+
label: "Aurora",
|
|
676
|
+
description: "Wide ribbons of the theme's colour folding through one another, round a deep void.",
|
|
677
|
+
mode: "dark",
|
|
678
|
+
colours: [
|
|
679
|
+
"--color-ambient-4",
|
|
680
|
+
"--color-ambient-3",
|
|
681
|
+
"--color-ambient-5",
|
|
682
|
+
"--color-ambient-2",
|
|
683
|
+
"--color-ambient-6"
|
|
684
|
+
],
|
|
685
|
+
params: [
|
|
686
|
+
{ key: "scale", label: "Scale", min: 0.3, max: 3, step: 0.01, default: 1 },
|
|
687
|
+
{ key: "fold", label: "Folds", min: 0, max: 2, step: 0.01, default: 1 },
|
|
688
|
+
{ key: "tilt", label: "Tilt", min: -1.6, max: 1.6, step: 0.01, default: 0.5 },
|
|
689
|
+
{ key: "void", label: "Void", min: 0, max: 1, step: 0.01, default: 0.8 },
|
|
690
|
+
{ key: "bloom", label: "Bloom", min: 0, max: 1, step: 0.01, default: 0.6 },
|
|
691
|
+
{ key: "bright", label: "Brightness", min: 0.1, max: 1.5, step: 0.01, default: 0.8 },
|
|
692
|
+
{ key: "drift", label: "Drift", min: 0, max: 3, step: 0.05, default: 1 }
|
|
693
|
+
],
|
|
694
|
+
glsl: (
|
|
695
|
+
/* glsl */
|
|
696
|
+
`
|
|
697
|
+
vec3 auroraHue(vec3 c) {
|
|
698
|
+
float grey = (c.r + c.g + c.b) / 3.0;
|
|
699
|
+
c = max(grey + (c - grey) * 1.6, vec3(0.0));
|
|
700
|
+
return c / max(max(c.r, max(c.g, c.b)), 1e-3);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
vec3 scene(vec2 uv, float t) {
|
|
704
|
+
float aspect = u_size.x / u_size.y;
|
|
705
|
+
vec2 p = vec2((uv.x - 0.5) * aspect, uv.y - 0.5);
|
|
706
|
+
t *= u_drift;
|
|
707
|
+
float ca = cos(u_tilt);
|
|
708
|
+
float sa = sin(u_tilt);
|
|
709
|
+
vec2 w = vec2(ca * p.x + sa * p.y, -sa * p.x + ca * p.y) * 2.3 * u_scale;
|
|
710
|
+
|
|
711
|
+
/* Fold the plane: each warp bends it along the last one's grain. */
|
|
712
|
+
for (int i = 1; i <= 4; i++) {
|
|
713
|
+
float n = float(i);
|
|
714
|
+
w.x += u_fold * 0.6 / n * sin(n * 1.25 * w.y + t * 0.11 + n * 1.7);
|
|
715
|
+
w.y += u_fold * 0.5 / n * cos(n * 1.05 * w.x - t * 0.09 + n * 2.3);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
float a = 0.5 + 0.5 * sin(w.x * 1.15 + w.y * 0.5 + t * 0.05);
|
|
719
|
+
float b = 0.5 + 0.5 * sin(w.y * 1.35 - w.x * 0.45 + 2.1 - t * 0.04);
|
|
720
|
+
float c = 0.5 + 0.5 * sin((w.x + w.y) * 0.85 + 4.2 + t * 0.03);
|
|
721
|
+
float e = 0.5 + 0.5 * sin(w.x * 0.6 - w.y * 0.95 + 0.7);
|
|
722
|
+
|
|
723
|
+
vec3 base = auroraHue(u_col[0]);
|
|
724
|
+
vec3 col = base;
|
|
725
|
+
col = mix(col, auroraHue(u_col[1]), smoothstep(0.3, 0.9, a) * 0.8);
|
|
726
|
+
col = mix(col, mix(auroraHue(u_col[3]), vec3(1.0), 0.25), smoothstep(0.35, 0.95, c) * 0.6);
|
|
727
|
+
col = mix(col, auroraHue(u_col[2]), smoothstep(0.6, 1.0, b) * 0.8);
|
|
728
|
+
col = mix(col, auroraHue(u_col[4]), smoothstep(0.7, 1.0, e) * smoothstep(0.5, 0.9, b) * 0.6);
|
|
729
|
+
/* A pale bloom where ribbons cross. */
|
|
730
|
+
col = mix(col, vec3(1.0), u_bloom * smoothstep(0.25, 0.95, a * c + 0.35 * e) * 0.85);
|
|
731
|
+
|
|
732
|
+
/* The void, with the base tone deepening toward it. */
|
|
733
|
+
float pool = 0.5 + 0.5 * sin(w.x * 0.75 - w.y * 1.1 + 5.3 + t * 0.02);
|
|
734
|
+
float dark = u_void * smoothstep(0.5, 0.95, pool);
|
|
735
|
+
col = mix(col, base * 0.5, smoothstep(0.0, 0.6, dark) * 0.7);
|
|
736
|
+
float lit = 1.0 - smoothstep(0.35, 1.0, dark);
|
|
737
|
+
return u_ground + col * lit * u_bright;
|
|
738
|
+
}
|
|
739
|
+
`
|
|
740
|
+
)
|
|
741
|
+
};
|
|
742
|
+
const SCENES = [horizon, rift, glyphs, prism, meteors, waves, aurora];
|
|
743
|
+
export {
|
|
744
|
+
SCENES,
|
|
745
|
+
aurora,
|
|
746
|
+
glyphs,
|
|
747
|
+
horizon,
|
|
748
|
+
meteors,
|
|
749
|
+
prism,
|
|
750
|
+
rift,
|
|
751
|
+
waves
|
|
752
|
+
};
|