rift-ds 1.28.0 → 1.30.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/bin/rift-ds.mjs +5 -4
- package/bin/templates/app/components/rift/ColorModeScript.tsx +7 -3
- package/bin/templates/blocks/app/settings/ProfileForm.tsx +98 -0
- package/bin/templates/blocks/app/settings/page.module.css +11 -0
- package/bin/templates/blocks/app/settings/page.tsx +84 -0
- package/bin/templates/blocks/app/shader/page.module.css +75 -0
- package/bin/templates/blocks/app/shader/page.tsx +81 -0
- package/bin/templates/blocks/components/blocks/AppShell.module.css +8 -41
- package/bin/templates/blocks/components/blocks/AppShell.tsx +9 -11
- package/bin/templates/blocks/components/blocks/emberScene.ts +53 -0
- package/bin/templates/blocks/registry.json +24 -0
- package/bin/templates/chat/app/api/chat/feedback/route.ts +0 -3
- package/bin/templates/chat/app/api/chat/followups/route.ts +0 -3
- package/bin/templates/chat/app/api/chat/route.ts +0 -2
- package/chat/ChatLauncher.d.ts +9 -1
- package/chat/ChatLauncher.js +3 -1
- package/chat/threads.js +7 -4
- package/components/Alert/Alert.css +12 -0
- package/components/Alert/Alert.d.ts +2 -0
- package/components/Alert/Alert.js +3 -1
- package/components/Attachment/Attachment.css +92 -0
- package/components/Attachment/FileRow.d.ts +47 -0
- package/components/Attachment/FileRow.js +38 -0
- package/components/Avatar/Avatar.css +14 -0
- package/components/Avatar/Avatar.d.ts +3 -1
- package/components/Avatar/Avatar.js +3 -2
- package/components/Button/Button.css +38 -0
- package/components/Button/Button.d.ts +8 -0
- package/components/Button/Button.js +2 -0
- package/components/Chart/AreaChart.d.ts +2 -0
- package/components/Chart/AreaChart.js +2 -1
- package/components/Chart/BarChart.d.ts +2 -0
- package/components/Chart/BarChart.js +2 -1
- package/components/Chart/ComboChart.d.ts +4 -0
- package/components/Chart/ComboChart.js +4 -2
- package/components/Chart/LineChart.d.ts +2 -0
- package/components/Chart/LineChart.js +2 -1
- package/components/Chart/PieChart.d.ts +4 -4
- package/components/Chart/PieChart.js +1 -1
- package/components/Chart/ScatterChart.d.ts +2 -0
- package/components/Chart/ScatterChart.js +2 -1
- package/components/Checklist/Checklist.css +123 -0
- package/components/Checklist/Checklist.d.ts +66 -0
- package/components/Checklist/Checklist.js +115 -0
- package/components/CircularButton/CircularButton.css +39 -0
- package/components/CircularButton/CircularButton.d.ts +13 -0
- package/components/CircularButton/CircularButton.js +18 -4
- package/components/ColourSwatch/ColourSwatch.css +3 -1
- package/components/ColourSwatch/ColourSwatch.d.ts +5 -3
- package/components/ColourSwatch/ColourSwatch.js +5 -0
- package/components/Combobox/Combobox.d.ts +4 -2
- package/components/Combobox/Combobox.js +7 -3
- package/components/DataTable/DataTable.css +35 -0
- package/components/DataTable/DataTable.d.ts +34 -2
- package/components/DataTable/DataTable.js +58 -5
- package/components/DataTable/columnTypes.d.ts +1 -1
- package/components/DataTable/columnTypes.js +1 -1
- package/components/DateInput/DateInput.d.ts +4 -2
- package/components/DateInput/DateInput.js +7 -3
- package/components/DescriptionList/DescriptionList.css +28 -0
- package/components/DescriptionList/DescriptionList.d.ts +3 -1
- package/components/DescriptionList/DescriptionList.js +4 -3
- package/components/DescriptionList/DescriptionListCopy.js +2 -0
- package/components/Dropdown/Dropdown.d.ts +4 -2
- package/components/Dropdown/Dropdown.js +7 -3
- package/components/EmptyState/EmptyState.css +12 -0
- package/components/EmptyState/EmptyState.d.ts +7 -0
- package/components/EmptyState/EmptyState.js +2 -0
- package/components/EventCalendar/EventCalendar.css +59 -0
- package/components/EventCalendar/EventCalendar.d.ts +24 -2
- package/components/EventCalendar/EventCalendar.js +104 -19
- package/components/FormSection/FormSection.css +70 -0
- package/components/FormSection/FormSection.d.ts +35 -0
- package/components/FormSection/FormSection.js +35 -0
- package/components/Grid/Grid.css +52 -0
- package/components/Grid/Grid.d.ts +30 -0
- package/components/Grid/Grid.js +36 -0
- package/components/Icon/Icon.css +55 -0
- package/components/Icon/Icon.d.ts +27 -0
- package/components/Icon/Icon.js +42 -0
- package/components/NumberInput/NumberInput.d.ts +4 -2
- package/components/NumberInput/NumberInput.js +7 -3
- package/components/OrgChart/OrgChart.css +143 -0
- package/components/OrgChart/OrgChart.d.ts +44 -0
- package/components/OrgChart/OrgChart.js +26 -0
- package/components/PageHeader/PageHeader.css +74 -0
- package/components/PageHeader/PageHeader.d.ts +39 -0
- package/components/PageHeader/PageHeader.js +33 -0
- package/components/Panel/Panel.css +7 -0
- package/components/Panel/Panel.d.ts +5 -2
- package/components/Panel/Panel.js +2 -1
- package/components/ResourceTimeline/ResourceTimeline.css +194 -0
- package/components/ResourceTimeline/ResourceTimeline.d.ts +57 -0
- package/components/ResourceTimeline/ResourceTimeline.js +129 -0
- package/components/ShaderField/useShaderField.js +13 -1
- package/components/ShaderScene/ShaderScene.d.ts +39 -15
- package/components/ShaderScene/ShaderScene.js +87 -6
- package/components/ShaderScene/assemble.d.ts +10 -3
- package/components/ShaderScene/assemble.js +29 -0
- package/components/ShaderScene/renderer.d.ts +12 -4
- package/components/ShaderScene/renderer.js +32 -20
- package/components/ShaderScene/scenes.d.ts +78 -0
- package/components/ShaderScene/scenes.js +933 -1
- package/components/ShaderScene/types.d.ts +52 -23
- package/components/Stack/Stack.css +68 -0
- package/components/Stack/Stack.d.ts +37 -0
- package/components/Stack/Stack.js +39 -0
- package/components/Stat/Stat.css +65 -0
- package/components/Stat/Stat.d.ts +7 -1
- package/components/Stat/Stat.js +16 -1
- package/components/Table/Table.css +11 -0
- package/components/Table/Table.d.ts +2 -0
- package/components/Table/Table.js +5 -1
- package/components/Tabs/Tabs.css +23 -0
- package/components/Tabs/Tabs.d.ts +9 -8
- package/components/Tabs/Tabs.js +38 -5
- package/components/Textarea/Textarea.d.ts +4 -2
- package/components/Textarea/Textarea.js +7 -3
- package/components/ThemeToggle/colorMode.d.ts +17 -1
- package/components/ThemeToggle/colorMode.js +11 -2
- package/components/Widget/Widget.css +21 -0
- package/components/Widget/Widget.d.ts +4 -0
- package/components/Widget/Widget.js +13 -5
- package/components/Wizard/Wizard.css +67 -0
- package/components/Wizard/Wizard.d.ts +54 -0
- package/components/Wizard/Wizard.js +71 -0
- package/components/registry.d.ts +25 -0
- package/components/registry.js +8 -0
- package/components/registry.json +234 -33
- package/components/registry.json.d.ts +234 -33
- package/components/registry.json.js +1 -1
- package/index.d.ts +10 -0
- package/index.js +20 -0
- package/package.json +1 -1
- package/tokens/motion.d.ts +2 -0
- package/tokens/motion.js +2 -0
- package/tokens/values.d.ts +31 -0
- package/tokens/values.js +16 -0
- package/tokens/values.json.js +1 -1
|
@@ -753,14 +753,946 @@ vec3 scene(vec2 uv, float t) {
|
|
|
753
753
|
`
|
|
754
754
|
)
|
|
755
755
|
};
|
|
756
|
-
const
|
|
756
|
+
const highway = {
|
|
757
|
+
id: "highway",
|
|
758
|
+
label: "Highway",
|
|
759
|
+
description: "A straight highway at night, drawn in light trails that pull to one point on a hazy horizon.",
|
|
760
|
+
mode: "dark",
|
|
761
|
+
/* The haze, the tail lights nearest you, the light of the road's far end,
|
|
762
|
+
and the oncoming light on the far side. */
|
|
763
|
+
colours: [
|
|
764
|
+
"--color-ambient-4",
|
|
765
|
+
"--color-ambient-5",
|
|
766
|
+
"--color-ambient-6",
|
|
767
|
+
"--color-ambient-2"
|
|
768
|
+
],
|
|
769
|
+
params: [
|
|
770
|
+
{ key: "crown", label: "Horizon height", min: 0.15, max: 0.85, step: 0.01, default: 0.27 },
|
|
771
|
+
{ key: "trails", label: "Trails", min: 0, max: 2, step: 0.01, default: 1 },
|
|
772
|
+
{ key: "haze", label: "Haze", min: 0, max: 2, step: 0.01, default: 1 },
|
|
773
|
+
{ key: "meet", label: "Vanishing light", min: 0, max: 2, step: 0.01, default: 1 },
|
|
774
|
+
{ key: "city", label: "City lights", min: 0, max: 2, step: 0.01, default: 1 },
|
|
775
|
+
{ key: "clouds", label: "Clouds", min: 0, max: 2, step: 0.01, default: 1 },
|
|
776
|
+
{ key: "side", label: "Vanishing point", min: -0.8, max: 0.8, step: 0.01, default: 0.22 },
|
|
777
|
+
{ key: "flow", label: "Flow", min: 0, max: 3, step: 0.05, default: 1 }
|
|
778
|
+
],
|
|
779
|
+
glsl: (
|
|
780
|
+
/* glsl */
|
|
781
|
+
`
|
|
782
|
+
/* A theme's ambient tones can be muted, a monochrome theme's most of all.
|
|
783
|
+
As the prism does, each is pushed from its own grey and up to full
|
|
784
|
+
brightness, so it reads as colour once it is light, then taken to
|
|
785
|
+
display space, where the scene is composed. */
|
|
786
|
+
vec3 highwayHue(vec3 c) {
|
|
787
|
+
float grey = (c.r + c.g + c.b) / 3.0;
|
|
788
|
+
c = max(grey + (c - grey) * 1.8, vec3(0.0));
|
|
789
|
+
return pow(c / max(max(c.r, max(c.g, c.b)), 1e-3), vec3(1.0 / 2.2));
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/* One trail: a hot core, a halo round it, and a wide wash on the asphalt. */
|
|
793
|
+
vec3 highwayTrail(float l, float at, float width, float px, vec3 tint, float flow) {
|
|
794
|
+
float s = sqrt(width * width + px * px);
|
|
795
|
+
float d = l - at;
|
|
796
|
+
float core = exp(-d * d / (s * s)) * (width / s);
|
|
797
|
+
float halo = exp(-d * d / (s * s * 34.0 + 0.0006)) * 0.29;
|
|
798
|
+
float wash = exp(-abs(d) / 0.45) * 0.045;
|
|
799
|
+
return (tint * (core * 1.7 + halo + wash) + vec3(1.0, 0.9, 0.86) * core * core * 0.6) * flow;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/* Light moves along a trail: a slow shimmer, and brighter heads that travel
|
|
803
|
+
it with their glow dragging behind. Each head fades in over its front, so
|
|
804
|
+
no hard edge crosses the road. */
|
|
805
|
+
float highwayPulse(float d, float t, float seed, float dir) {
|
|
806
|
+
float n = vnoise(vec2(d * 4.6 - t * 0.5 * dir + seed * 7.3, seed * 3.1));
|
|
807
|
+
float u = fract(t * 0.3 - dir * d * 0.5 + seed * 0.37);
|
|
808
|
+
float v = fract(u + 0.45);
|
|
809
|
+
float heads = exp(-u * 3.2) * smoothstep(0.0, 0.09, u) + 0.7 * exp(-v * 4.5) * smoothstep(0.0, 0.09, v);
|
|
810
|
+
return 0.4 + 0.4 * smoothstep(0.22, 0.78, n) + 1.3 * heads;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
vec3 scene(vec2 uv, float t) {
|
|
814
|
+
float aspect = u_size.x / u_size.y;
|
|
815
|
+
vec2 p = vec2((uv.x - 0.5) * aspect, uv.y);
|
|
816
|
+
t *= u_flow;
|
|
817
|
+
vec2 vp = vec2(u_side * aspect, u_crown);
|
|
818
|
+
float up = p.y - vp.y;
|
|
819
|
+
float side = (p.x - vp.x) / aspect;
|
|
820
|
+
/* The light comes from the road's far end and gives out with distance
|
|
821
|
+
from it: far to the other side, the haze, the horizon line and the
|
|
822
|
+
city all fade away into the dark. */
|
|
823
|
+
float reachOut = smoothstep(-1.12, -0.5, side);
|
|
824
|
+
float right = mix(0.14, 1.0, smoothstep(-1.5, 0.1, side)) * reachOut;
|
|
825
|
+
|
|
826
|
+
vec3 cool = highwayHue(u_col[0]);
|
|
827
|
+
vec3 tail = highwayHue(u_col[1]);
|
|
828
|
+
vec3 warm = highwayHue(u_col[2]);
|
|
829
|
+
vec3 oncoming = mix(highwayHue(u_col[3]), vec3(1.0), 0.35);
|
|
830
|
+
vec3 steel = mix(vec3(dot(cool, vec3(0.2126, 0.7152, 0.0722))), cool, 0.3) * 0.6;
|
|
831
|
+
|
|
832
|
+
vec3 col = vec3(0.0);
|
|
833
|
+
if (up > 0.0) {
|
|
834
|
+
/* Sky: a cold haze on the horizon, a shaft of it leaning away, and the
|
|
835
|
+
trails lighting it where the road runs in. */
|
|
836
|
+
/* Mist: two layers of it sliding past each other, the finer one hugging
|
|
837
|
+
the horizon, so the haze thickens and thins as it drifts. */
|
|
838
|
+
float drift = fbm(vec2(p.x * 1.4 - t * 0.06, up * 5.0 + t * 0.015));
|
|
839
|
+
drift = mix(drift, fbm(vec2(p.x * 3.1 + t * 0.045, up * 12.0 - t * 0.02)), 0.4);
|
|
840
|
+
drift = smoothstep(0.15, 0.85, drift);
|
|
841
|
+
vec3 haze = steel * right * (exp(-up / 0.07) * 1.3 + exp(-up / 0.3) * 0.58 + exp(-up / 0.7) * 0.05) * (0.22 + 1.35 * drift);
|
|
842
|
+
vec2 lean = normalize(vec2(-1.0, 0.34));
|
|
843
|
+
vec2 rel = p - vp;
|
|
844
|
+
float along = dot(rel, lean);
|
|
845
|
+
float across = dot(rel, vec2(-lean.y, lean.x));
|
|
846
|
+
float shaft = exp(-across * across / 0.03) * exp(-max(along, 0.0) / 1.2) * smoothstep(0.0, 0.25, along);
|
|
847
|
+
haze += steel * shaft * 0.72 * (0.5 + 1.0 * drift);
|
|
848
|
+
/* Clouds, seen from below and flattening towards the horizon, moving
|
|
849
|
+
slowly across. They catch the light from the road's far end on their
|
|
850
|
+
undersides and dim the haze behind them where they are thick. */
|
|
851
|
+
float lay = 1.0 / (up + 0.2);
|
|
852
|
+
vec2 cu = vec2((p.x - vp.x) * lay * 0.42 + t * 0.022, lay * 0.55 + t * 0.004);
|
|
853
|
+
float cloud = fbm(cu + 0.9 * vec2(fbm(cu * 0.6 + 3.1), fbm(cu * 0.6 + 8.4)));
|
|
854
|
+
cloud = smoothstep(0.42, 0.78, cloud) * smoothstep(0.0, 0.06, up) * u_clouds;
|
|
855
|
+
haze *= 1.0 - 0.6 * cloud;
|
|
856
|
+
haze += steel * cloud * (0.08 + 0.38 * right) * (exp(-up / 0.35) + 0.05);
|
|
857
|
+
float rise = exp(-up / 0.05) * exp(-pow((p.x - vp.x) / (0.2 * aspect), 2.0));
|
|
858
|
+
haze += tail * rise * 0.2 * u_trails * (0.6 + 0.8 * drift);
|
|
859
|
+
/* Keep the darks deep: the thin end of the haze is pulled down towards
|
|
860
|
+
black and only what is already bright is let through at strength. */
|
|
861
|
+
haze *= mix(0.4, 1.12, smoothstep(0.02, 0.36, dot(haze, vec3(0.3333))));
|
|
862
|
+
col += haze * u_haze;
|
|
863
|
+
float speck = step(0.9982, rnd(ivec2(gl_FragCoord.xy / 2.0)));
|
|
864
|
+
col += steel * 1.6 * speck * 0.25 * smoothstep(0.02, 0.3, up);
|
|
865
|
+
} else {
|
|
866
|
+
/* Ground: a plane seen in perspective. You stand on the right shoulder;
|
|
867
|
+
the road runs away to the left of you, its edge line just beside. */
|
|
868
|
+
float below = max(-up, 0.0005);
|
|
869
|
+
float d = log(u_crown / below);
|
|
870
|
+
float l = (p.x - vp.x) / below / 3.0;
|
|
871
|
+
float px = 1.6 / u_size.y / below / 3.0;
|
|
872
|
+
|
|
873
|
+
float on = smoothstep(1.06 + px, 0.98, abs(l + 0.72));
|
|
874
|
+
float grit = fbm(vec2(l * 5.0, d * 9.0));
|
|
875
|
+
vec3 asphalt = vec3(0.027, 0.034, 0.036) * (0.6 + 0.8 * grit);
|
|
876
|
+
vec3 verge = vec3(0.012, 0.019, 0.015) * (0.5 + 0.9 * fbm(vec2((p.x - vp.x) / below * 0.5, d * 6.0)));
|
|
877
|
+
col = mix(verge, asphalt, on);
|
|
878
|
+
float edge = exp(-pow((l - 0.22) / (0.011 + px), 2.0));
|
|
879
|
+
col += vec3(0.75, 0.8, 0.85) * edge * 0.3 * (1.0 - exp(-below / 0.02));
|
|
880
|
+
|
|
881
|
+
float fog = exp(-below / 0.035);
|
|
882
|
+
col += steel * right * fog * 0.46 * u_haze;
|
|
883
|
+
col += steel * on * exp(-below / 0.1) * 0.085 * u_haze;
|
|
884
|
+
|
|
885
|
+
/* Every trail is a straight line to the vanishing point. What moves is
|
|
886
|
+
the light along it: fine fibres streaming past, the way a long
|
|
887
|
+
exposure smears a moving lamp. */
|
|
888
|
+
float fibre = vnoise(vec2(l * 70.0, d * 1.4 - t * 0.7));
|
|
889
|
+
float reach = 1.0 - exp(-below / 0.007);
|
|
890
|
+
vec3 light = vec3(0.0);
|
|
891
|
+
light += highwayTrail(l, -0.24, 0.020, px, tail, highwayPulse(d, t, 1.0, 1.0));
|
|
892
|
+
light += highwayTrail(l, -0.50, 0.022, px, tail, highwayPulse(d, t, 2.0, 1.0));
|
|
893
|
+
light += highwayTrail(l, -0.66, 0.008, px, tail, highwayPulse(d, t, 6.0, 1.0)) * 0.4;
|
|
894
|
+
light += highwayTrail(l, -0.82, 0.020, px, tail, highwayPulse(d, t, 3.0, 1.0)) * 0.9;
|
|
895
|
+
light += highwayTrail(l, -1.06, 0.010, px, tail, highwayPulse(d, t, 7.0, 1.0)) * 0.5;
|
|
896
|
+
light += highwayTrail(l, -1.34, 0.013, px, oncoming, highwayPulse(d, t, 4.0, -1.0)) * 0.55;
|
|
897
|
+
light += highwayTrail(l, -1.52, 0.013, px, oncoming, highwayPulse(d, t, 5.0, -1.0)) * 0.45;
|
|
898
|
+
col += light * (0.7 + 0.6 * fibre) * reach * u_trails;
|
|
899
|
+
|
|
900
|
+
/* Fog lying on the ground, drifting, and catching the colour of the
|
|
901
|
+
trails that run through it. */
|
|
902
|
+
float bank = fbm(vec2(p.x * 2.2 + t * 0.06, d * 1.6 - t * 0.035));
|
|
903
|
+
float mist = exp(-below / 0.075) * (0.25 + 1.1 * bank);
|
|
904
|
+
vec3 scatter = tail * exp(-pow(l + 0.62, 2.0) / 0.5) + oncoming * exp(-pow(l + 1.43, 2.0) / 0.2) * 0.3;
|
|
905
|
+
col += scatter * mist * 0.3 * u_trails * u_haze;
|
|
906
|
+
col += steel * right * mist * 0.37 * u_haze;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/* The line where they meet, warm at the far end, and the hot point where
|
|
910
|
+
every trail ends, with a flare across the horizon. */
|
|
911
|
+
float line = exp(-pow(up / 0.0024, 2.0));
|
|
912
|
+
col += mix(steel * 1.8, warm, smoothstep(-0.25, 0.1, side)) * line * right * 0.55 * u_haze;
|
|
913
|
+
/* A city along the horizon: a low glow, and its lights in two rows, the
|
|
914
|
+
upper ones on buildings and the lower ones their reflections. */
|
|
915
|
+
float cx = p.x * 230.0;
|
|
916
|
+
ivec2 cell = ivec2(int(floor(cx)) + 4096, 0);
|
|
917
|
+
float inCell = exp(-pow((fract(cx) - 0.5) / 0.16, 2.0));
|
|
918
|
+
/* The lights gather into districts with dark gaps between them, and no
|
|
919
|
+
two burn alike. */
|
|
920
|
+
float district = smoothstep(0.3, 0.75, vnoise(vec2(p.x * 3.2, 7.0)));
|
|
921
|
+
float lit = step(0.9 - 0.5 * district, rnd(cell + ivec2(0, 3))) * (0.35 + 0.65 * rnd(cell + ivec2(0, 11)));
|
|
922
|
+
float lift = 0.002 + 0.013 * rnd(cell + ivec2(0, 9));
|
|
923
|
+
float lamp = exp(-pow((up - lift) / 0.0018, 2.0)) + 0.5 * exp(-pow((up + lift * 0.6) / 0.0024, 2.0));
|
|
924
|
+
/* Most lights shimmer, each at its own pace; about one in seven is a
|
|
925
|
+
beacon that blinks slowly on and off. */
|
|
926
|
+
float pace = rnd(cell + ivec2(0, 7));
|
|
927
|
+
float shimmer = 0.6 + 0.4 * sin(t * (1.2 + 2.6 * pace) + 6.283 * pace);
|
|
928
|
+
float beacon = smoothstep(0.35, 0.5, sin(t * (0.9 + 1.4 * pace) + 6.283 * pace) * 0.5 + 0.5);
|
|
929
|
+
float twinkle = mix(shimmer, beacon * 1.5, step(0.86, rnd(cell + ivec2(0, 13))));
|
|
930
|
+
col += mix(warm, tail, rnd(cell + ivec2(0, 5))) * inCell * lit * lamp * twinkle * 0.6 * u_city * reachOut;
|
|
931
|
+
col += mix(warm, steel * 1.6, 0.5) * exp(-abs(up) / (up > 0.0 ? 0.022 : 0.008)) * (0.35 + 0.65 * vnoise(vec2(p.x * 9.0, 1.0))) * 0.1 * u_city * reachOut;
|
|
932
|
+
|
|
933
|
+
vec2 away = p - vp;
|
|
934
|
+
float meet = exp(-dot(away, away) / 0.0016) * 0.9 + exp(-dot(away, away) / 0.02) * 0.22;
|
|
935
|
+
float flare = exp(-pow(away.y / 0.0035, 2.0)) * exp(-abs(away.x) / 0.22) * 0.5;
|
|
936
|
+
col += (mix(warm, vec3(1.0), 0.55) * meet + mix(warm, vec3(1.0), 0.3) * flare) * u_meet;
|
|
937
|
+
|
|
938
|
+
return u_ground + pow(max(col, vec3(0.0)), vec3(2.2));
|
|
939
|
+
}
|
|
940
|
+
`
|
|
941
|
+
)
|
|
942
|
+
};
|
|
943
|
+
const ocean = {
|
|
944
|
+
id: "ocean",
|
|
945
|
+
label: "Ocean",
|
|
946
|
+
description: "Open water from above, sea life drawn in type swimming through it: a turquoise shallow by day, deep and moonlit by night.",
|
|
947
|
+
/* The water's green and its blue (turquoise is the two mixed), then the
|
|
948
|
+
rest of the ambient set, which with those two colours the animals. */
|
|
949
|
+
colours: [
|
|
950
|
+
"--color-ambient-2",
|
|
951
|
+
"--color-ambient-4",
|
|
952
|
+
"--color-ambient-1",
|
|
953
|
+
"--color-ambient-3",
|
|
954
|
+
"--color-ambient-5",
|
|
955
|
+
"--color-ambient-6"
|
|
956
|
+
],
|
|
957
|
+
glyphs: ".:;~!il1][)(}{|/?jftrxnuvczXYUJCLQ0OZmwqpdb",
|
|
958
|
+
/* Type at 1x on a 2x screen is soft. */
|
|
959
|
+
pixelRatio: 2,
|
|
960
|
+
params: [
|
|
961
|
+
{ key: "cell", label: "Type size", min: 6, max: 30, step: 1, default: 11 },
|
|
962
|
+
{ key: "pixel", label: "Pixel size", min: 1, max: 24, step: 1, default: 7 },
|
|
963
|
+
{ key: "life", label: "Sea life", min: 0, max: 1, step: 0.01, default: 0.9 },
|
|
964
|
+
{ key: "scale", label: "Animal size", min: 0.4, max: 2.5, step: 0.05, default: 1 },
|
|
965
|
+
{ key: "swim", label: "Swim speed", min: 0, max: 4, step: 0.05, default: 1 },
|
|
966
|
+
{ key: "wake", label: "Wake", min: 0, max: 2, step: 0.01, default: 1 },
|
|
967
|
+
{ key: "caustics", label: "Caustics", min: 0, max: 2, step: 0.01, default: 1 },
|
|
968
|
+
{ key: "depth", label: "Depth", min: 0, max: 1.5, step: 0.01, default: 1 },
|
|
969
|
+
{ key: "light", label: "Light", min: 0, max: 2, step: 0.01, default: 1 },
|
|
970
|
+
{ key: "glints", label: "Glints", min: 0, max: 3, step: 0.05, default: 1 },
|
|
971
|
+
{ key: "ripple", label: "Ripple", min: 0.4, max: 3, step: 0.05, default: 1 }
|
|
972
|
+
],
|
|
973
|
+
glsl: (
|
|
974
|
+
/* glsl */
|
|
975
|
+
`
|
|
976
|
+
/* A theme's ambient tone at full brightness, so it reads as a hue. */
|
|
977
|
+
vec3 oceanHue(vec3 c) {
|
|
978
|
+
return c / max(max(c.r, max(c.g, c.b)), 1e-3);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/* Light through moving water: a net of bright lines, folded from a few
|
|
982
|
+
turns of one point round another. It tiles, so the caller warps it. */
|
|
983
|
+
float oceanCaustic(vec2 p, float t) {
|
|
984
|
+
vec2 q = mod(p * 6.2831853, 6.2831853) - 250.0;
|
|
985
|
+
vec2 i = q;
|
|
986
|
+
float c = 1.0;
|
|
987
|
+
for (int n = 0; n < 4; n++) {
|
|
988
|
+
float s = t * (1.0 - 3.5 / float(n + 1));
|
|
989
|
+
i = q + vec2(cos(s - i.x) + sin(s + i.y), sin(s - i.y) + cos(s + i.x));
|
|
990
|
+
c += 1.0 / length(vec2(q.x / (sin(i.x + s) / 0.005), q.y / (cos(i.y + s) / 0.005)));
|
|
991
|
+
}
|
|
992
|
+
c = 1.17 - pow(c / 4.0, 1.4);
|
|
993
|
+
return pow(abs(c), 8.0);
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/* The animals. Each returns how deep inside the body a point lies: 1 at
|
|
997
|
+
its core, 0 on its edge, and falling below that with distance outside,
|
|
998
|
+
which is what the night's glow is read from. q is in body lengths, the nose at +x. */
|
|
999
|
+
float oceanBlob(vec2 d, vec2 r) {
|
|
1000
|
+
return 1.0 - length(d / r);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/* A pair of swept fins: a chord that narrows to nothing at the tip. */
|
|
1004
|
+
float oceanFin(vec2 q, float root, float sweep, float chord, float span) {
|
|
1005
|
+
float a = abs(q.y);
|
|
1006
|
+
float c = chord * (1.0 - a / span);
|
|
1007
|
+
return c > 0.0 ? 1.0 - abs(q.x - (root - sweep * a)) / c : -4.0;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
float oceanShark(vec2 q) {
|
|
1011
|
+
float w = 0.2 * pow(max(1.0 - q.x * q.x, 0.0), 0.55) * mix(0.25, 1.0, smoothstep(-1.0, 0.2, q.x));
|
|
1012
|
+
float body = w > 0.0 ? 1.0 - abs(q.y) / w : -4.0;
|
|
1013
|
+
float fins = max(oceanFin(q, 0.3, 1.0, 0.2, 0.5), oceanFin(q, -1.0, 0.9, 0.1, 0.28));
|
|
1014
|
+
return max(body, fins > 0.0 ? 0.7 * fins : fins);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
float oceanRay(vec2 q) {
|
|
1018
|
+
float tail = q.x > -1.7 && q.x < -0.3 ? 0.5 * (1.0 - abs(q.y) / 0.06) : -4.0;
|
|
1019
|
+
return max(oceanFin(q, 0.15, 0.4, 0.62, 1.0), tail);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
float oceanTurtle(vec2 q, float w) {
|
|
1023
|
+
vec2 h = vec2(q.x, abs(q.y));
|
|
1024
|
+
float a = 1.0 + 0.35 * sin(w);
|
|
1025
|
+
vec2 d = h - vec2(0.38, 0.42);
|
|
1026
|
+
vec2 front = vec2(cos(a) * d.x + sin(a) * d.y, -sin(a) * d.x + cos(a) * d.y);
|
|
1027
|
+
float limbs = max(oceanBlob(front - vec2(0.3, 0.0), vec2(0.42, 0.14)),
|
|
1028
|
+
oceanBlob(h - vec2(-0.62, 0.34), vec2(0.2, 0.1)));
|
|
1029
|
+
return max(max(oceanBlob(q, vec2(0.62, 0.5)), oceanBlob(q - vec2(0.8, 0.0), vec2(0.22, 0.17))), limbs > 0.0 ? 0.7 * limbs : limbs);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/* A school: one small fish to a square of a grid, each off its centre,
|
|
1033
|
+
about half the squares empty, all inside an oval. */
|
|
1034
|
+
float oceanSchool(vec2 q, float w, int k, out int tint) {
|
|
1035
|
+
vec2 g = q * 6.0;
|
|
1036
|
+
vec2 id = floor(g);
|
|
1037
|
+
ivec2 at = ivec2(id) + ivec2(64 + k * 31, 64);
|
|
1038
|
+
tint = int(rnd(at + 3) * 5.999);
|
|
1039
|
+
if (length((id + 0.5) / vec2(6.0, 3.6)) > 1.0 || rnd(at) < 0.48) return -4.0;
|
|
1040
|
+
vec2 f = fract(g) - 0.5 - 0.28 * (vec2(rnd(at + 7), rnd(at + 13)) - 0.5);
|
|
1041
|
+
f.y += 0.05 * sin(f.x * 6.0 + w + rnd(at + 5) * 6.0);
|
|
1042
|
+
float fish = max(oceanBlob(f, vec2(0.3, 0.13)), oceanBlob(f + vec2(0.3, 0.0), vec2(0.1, 0.12)));
|
|
1043
|
+
/* Outside a fish the value falls away fast, so the night's glow hugs
|
|
1044
|
+
each one instead of filling its square of the grid. */
|
|
1045
|
+
return fish > 0.0 ? fish : fish * 5.0;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/* Six animals, each crossing the stage on a straight lane and coming back
|
|
1049
|
+
on a new one: its heading, mostly along the stage, and its lane are
|
|
1050
|
+
rolled again for every crossing. This is animal k's own frame: where p
|
|
1051
|
+
lies along (x) and across (y) its lane, with its heading and its size. */
|
|
1052
|
+
vec2 oceanLane(int k, vec2 p, float aspect, float cells, float t, out float turn, out float size) {
|
|
1053
|
+
float lap = length(vec2(aspect, 1.0)) + 1.4;
|
|
1054
|
+
float s = t * u_swim * (0.04 + 0.025 * rnd(ivec2(k, 5))) / lap + rnd(ivec2(k, 9)) + float(k) * 0.37;
|
|
1055
|
+
float along = (fract(s) - 0.5) * lap;
|
|
1056
|
+
ivec2 seed = ivec2(k * 17 + 3, int(floor(s)) + 40);
|
|
1057
|
+
turn = (rnd(seed) - 0.5) * 1.3 + (rnd(seed + 1) > 0.5 ? 3.14159265 : 0.0);
|
|
1058
|
+
float lane = (rnd(seed + 2) - 0.5) * 0.75 + 0.04 * sin(along * 2.0 + float(k));
|
|
1059
|
+
int kind = k < 4 ? k : 5 - k;
|
|
1060
|
+
/* Half a body length in stage heights, and never fewer characters
|
|
1061
|
+
than it takes to read as the animal on a short stage. */
|
|
1062
|
+
size = max(kind == 0 ? 0.22 : kind == 1 ? 0.26 : kind == 2 ? 0.13 : 0.085,
|
|
1063
|
+
cells * (kind == 0 ? 15.0 : kind == 1 ? 16.0 : kind == 2 ? 9.0 : 7.0)) * u_scale;
|
|
1064
|
+
return vec2(cos(turn) * p.x + sin(turn) * p.y, -sin(turn) * p.x + cos(turn) * p.y) - vec2(along, lane);
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
/* tint: which of the scene's colours the nearest animal wears. Each fish
|
|
1068
|
+
of a school takes its own; the others have one apiece. */
|
|
1069
|
+
float oceanLife(vec2 p, float aspect, float cells, float t, out int tint) {
|
|
1070
|
+
float best = -4.0;
|
|
1071
|
+
tint = 0;
|
|
1072
|
+
for (int k = 0; k < 6; k++) {
|
|
1073
|
+
float turn;
|
|
1074
|
+
float size;
|
|
1075
|
+
vec2 q = oceanLane(k, p, aspect, cells, t, turn, size) / size;
|
|
1076
|
+
if (abs(q.x) > 2.6 || abs(q.y) > 2.0) continue;
|
|
1077
|
+
int kind = k < 4 ? k : 5 - k;
|
|
1078
|
+
float w = t * u_swim * 2.0 + float(k) * 1.7;
|
|
1079
|
+
float v;
|
|
1080
|
+
int wears = k == 0 ? 0 : k == 2 ? 3 : k == 3 ? 2 : 4;
|
|
1081
|
+
if (kind == 0) {
|
|
1082
|
+
q.y += 0.1 * sin(q.x * 2.4 + w) * smoothstep(0.5, -1.0, q.x);
|
|
1083
|
+
v = oceanShark(q);
|
|
1084
|
+
} else if (kind == 1) {
|
|
1085
|
+
v = oceanSchool(q, w * 2.0, k, wears);
|
|
1086
|
+
} else if (kind == 2) {
|
|
1087
|
+
q.y *= 1.0 + 0.1 * sin(w);
|
|
1088
|
+
v = oceanRay(q);
|
|
1089
|
+
} else {
|
|
1090
|
+
v = oceanTurtle(q, w);
|
|
1091
|
+
}
|
|
1092
|
+
if (v > best) {
|
|
1093
|
+
best = v;
|
|
1094
|
+
tint = wears;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return best;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/* What the animals do to the water. Each parts it at the nose and drags a
|
|
1101
|
+
wake behind that opens and dies away over a few body lengths, with a
|
|
1102
|
+
train of ripples along it. All of it is written in the animal's own
|
|
1103
|
+
frame, so it travels at the animal's pace and turns with its heading.
|
|
1104
|
+
xy: how far the water is carried; z: the wake's strength there. */
|
|
1105
|
+
vec3 oceanWake(vec2 p, float aspect, float cells, float t) {
|
|
1106
|
+
vec3 wake = vec3(0.0);
|
|
1107
|
+
for (int k = 0; k < 6; k++) {
|
|
1108
|
+
float turn;
|
|
1109
|
+
float size;
|
|
1110
|
+
vec2 q = oceanLane(k, p, aspect, cells, t, turn, size) / size;
|
|
1111
|
+
if (q.x > 1.8 || q.x < -7.0 || abs(q.y) > 3.0) continue;
|
|
1112
|
+
float behind = max(-q.x, 0.0);
|
|
1113
|
+
float width = 0.4 + 0.22 * behind;
|
|
1114
|
+
float strength = exp(-q.y * q.y / (width * width)) * smoothstep(1.6, 0.4, q.x) * exp(-behind * 0.45);
|
|
1115
|
+
/* Carried along with the animal, pushed out from its line, and rippled. */
|
|
1116
|
+
vec2 carry = vec2(0.5, 0.45 * q.y / width + 0.25 * sin(q.x * 5.0 + abs(q.y) * 4.0)) * strength * size;
|
|
1117
|
+
wake.xy += vec2(cos(turn) * carry.x - sin(turn) * carry.y, sin(turn) * carry.x + cos(turn) * carry.y);
|
|
1118
|
+
wake.z += strength * (0.55 + 0.45 * sin(q.x * 7.0 + abs(q.y) * 6.0));
|
|
1119
|
+
}
|
|
1120
|
+
return wake;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
/* The net of light at a point. The water keeps the animals' pace: the net
|
|
1124
|
+
drifts across the stage about as fast as they swim and changes shape
|
|
1125
|
+
more slowly still, so nothing in the water outruns them, and it is
|
|
1126
|
+
carried and brightened where one passes. */
|
|
1127
|
+
float oceanNet(vec2 p, vec3 wake, float flow) {
|
|
1128
|
+
vec2 wp = (p - wake.xy + vec2(0.022, 0.012) * flow) * u_ripple;
|
|
1129
|
+
wp += 0.07 * (vec2(vnoise(wp * 1.3 + flow * 0.03), vnoise(wp * 1.3 + 5.2 - flow * 0.025)) - 0.5);
|
|
1130
|
+
return min(1.0, oceanCaustic(wp * 0.9, flow * 0.03 + 23.0) + 0.45 * wake.z);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
vec3 scene(vec2 uv, float t) {
|
|
1134
|
+
float aspect = u_size.x / u_size.y;
|
|
1135
|
+
/* The water is drawn in square blocks, and the type in cells over it. */
|
|
1136
|
+
float block = max(1.0, floor(u_pixel * u_ratio + 0.5));
|
|
1137
|
+
vec2 p = ((floor(uv * u_size / block) + 0.5) * block / u_size - 0.5) * vec2(aspect, 1.0);
|
|
1138
|
+
/* Day on a light page, night on a dark one. */
|
|
1139
|
+
float day = smoothstep(0.1, 0.45, dot(u_ground, vec3(0.2126, 0.7152, 0.0722)));
|
|
1140
|
+
vec3 green = oceanHue(u_col[0]);
|
|
1141
|
+
vec3 blue = oceanHue(u_col[1]);
|
|
1142
|
+
vec3 turquoise = mix(green, blue, 0.38);
|
|
1143
|
+
vec3 silver = mix(mix(blue, turquoise, 0.3), vec3(1.0), 0.6);
|
|
1144
|
+
|
|
1145
|
+
float cells = max(4.0, floor(u_cell * u_ratio + 0.5)) * 0.6 / u_size.y;
|
|
1146
|
+
vec3 wake = oceanWake(p, aspect, cells, t) * u_wake;
|
|
1147
|
+
float flow = t * (0.4 + 0.6 * u_swim);
|
|
1148
|
+
/* A few flat steps of light, as a pixel drawing has. */
|
|
1149
|
+
float net = floor(oceanNet(p, wake, flow) * 5.0 + 0.5) / 5.0 * u_caustics;
|
|
1150
|
+
float deep = smoothstep(0.3, 0.75, fbm(p * 0.8 + vec2(t * 0.012, 3.0))) * u_depth;
|
|
1151
|
+
/* Where the sun or the moon lies on the water. */
|
|
1152
|
+
vec2 dl = (p - vec2(0.26 * aspect, 0.2)) / vec2(0.6, 0.32);
|
|
1153
|
+
float glow = exp(-dot(dl, dl)) * u_light;
|
|
1154
|
+
|
|
1155
|
+
vec3 shallow = mix(u_ground, turquoise, 0.88);
|
|
1156
|
+
vec3 sea = mix(shallow, mix(turquoise, blue, 0.22) * 0.7, min(1.0, deep * 0.8));
|
|
1157
|
+
sea += u_ground * net * (0.3 + 0.5 * glow) * (1.0 - 0.5 * min(1.0, deep));
|
|
1158
|
+
/* By night the net is shadow, not light: the water is a deep blue and
|
|
1159
|
+
the waves darken it towards the ground, so nothing pale lies on it but
|
|
1160
|
+
the moon's own patch. */
|
|
1161
|
+
vec3 night = u_ground + (blue * (0.02 + 0.016 * (1.0 - min(1.0, deep))) + silver * glow * 0.02)
|
|
1162
|
+
* (1.0 - 0.85 * min(1.0, net));
|
|
1163
|
+
vec3 col = mix(night, sea, day);
|
|
1164
|
+
|
|
1165
|
+
/* The type: the animals, and thin characters adrift between them. */
|
|
1166
|
+
float cellH = max(4.0, floor(u_cell * u_ratio + 0.5));
|
|
1167
|
+
vec2 size = vec2(cellH * 0.6, cellH);
|
|
1168
|
+
vec2 cell = floor(uv * u_size / size);
|
|
1169
|
+
vec2 local = fract(uv * u_size / size);
|
|
1170
|
+
local.x = 0.06 + local.x * 0.88;
|
|
1171
|
+
vec2 pc = ((cell + 0.5) * size / u_size - 0.5) * vec2(aspect, 1.0);
|
|
1172
|
+
int tint;
|
|
1173
|
+
float body = oceanLife(pc, aspect, size.x / u_size.y, t, tint);
|
|
1174
|
+
vec3 accent = oceanHue(u_col[tint]);
|
|
1175
|
+
float inside = smoothstep(0.0, 0.06, body);
|
|
1176
|
+
ivec2 at = ivec2(cell) + 2048;
|
|
1177
|
+
float g = floor(clamp(mix(rnd(at), pow(max(body, 0.0), 0.6), 0.5), 0.0, 0.999) * u_glyphCount);
|
|
1178
|
+
float ink = texture(u_glyphs, vec2((g + local.x) / u_glyphCount, local.y)).r * inside;
|
|
1179
|
+
/* Each animal wears one of the theme's accents. By day it is that
|
|
1180
|
+
colour deepened, a dark shape over the sand. By night it makes its own
|
|
1181
|
+
light in it: each character pulses, hot at the core, and the water
|
|
1182
|
+
round the body glows with it. */
|
|
1183
|
+
float pulse = 0.5 + 0.5 * sin(t * 0.9 + rnd(at) * 6.2831853 + pc.x * 9.0);
|
|
1184
|
+
vec3 lure = mix(accent, mix(accent, vec3(1.0), 0.3), pulse);
|
|
1185
|
+
vec3 lit = mix(lure, vec3(1.0), 0.55 * max(body, 0.0)) * (0.65 + 0.5 * pulse);
|
|
1186
|
+
col += (1.0 - day) * u_life * (lure * 0.16 * pow(smoothstep(-1.6, 0.1, body), 2.0) + turquoise * 0.05 * min(1.0, wake.z));
|
|
1187
|
+
col = mix(col, mix(lit, mix(mix(blue, turquoise, 0.25) * 0.11, accent * 0.5, 0.85), day),
|
|
1188
|
+
u_life * (mix(0.14, 0.34, day) * smoothstep(0.0, 0.25, body) + 0.86 * ink));
|
|
1189
|
+
|
|
1190
|
+
/* The loose characters belong to the waves: a cell prints one only
|
|
1191
|
+
while a bright line of the net lies over it, so they trace the crests
|
|
1192
|
+
and travel with them, and gather in an animal's wake. */
|
|
1193
|
+
float crest = smoothstep(0.22, 0.6, oceanNet(pc, wake, flow));
|
|
1194
|
+
float on = step(rnd(at + ivec2(31, 17)), 0.3 * u_glints * crest * (1.0 + glow)) * (1.0 - inside);
|
|
1195
|
+
float thin = floor(rnd(at + ivec2(3, 71)) * min(10.0, u_glyphCount));
|
|
1196
|
+
float glint = texture(u_glyphs, vec2((thin + local.x) / u_glyphCount, local.y)).r * on * crest;
|
|
1197
|
+
return mix(col, mix(mix(turquoise, vec3(1.0), 0.3), u_ground, day), glint * 0.8);
|
|
1198
|
+
}
|
|
1199
|
+
`
|
|
1200
|
+
)
|
|
1201
|
+
};
|
|
1202
|
+
const sky = {
|
|
1203
|
+
id: "sky",
|
|
1204
|
+
label: "Sky",
|
|
1205
|
+
description: "Cloud massed overhead and burning with a low sun: a golden hour on a light page, the last of a sunset under a night sky on a dark one.",
|
|
1206
|
+
/* The sky's blue, the sun's gold, the tint in a cloud's shade, the green
|
|
1207
|
+
that cools the blue towards slate, and the two tones of the fire. */
|
|
1208
|
+
colours: [
|
|
1209
|
+
"--color-ambient-4",
|
|
1210
|
+
"--color-ambient-1",
|
|
1211
|
+
"--color-ambient-3",
|
|
1212
|
+
"--color-ambient-2",
|
|
1213
|
+
"--color-ambient-5",
|
|
1214
|
+
"--color-ambient-6"
|
|
1215
|
+
],
|
|
1216
|
+
params: [
|
|
1217
|
+
{ key: "cover", label: "Cloud cover", min: 0, max: 1, step: 0.01, default: 0.72 },
|
|
1218
|
+
{ key: "scale", label: "Cloud size", min: 0.3, max: 3, step: 0.01, default: 1.4 },
|
|
1219
|
+
{ key: "soft", label: "Softness", min: 0.1, max: 2, step: 0.01, default: 0.6 },
|
|
1220
|
+
{ key: "warp", label: "Billow", min: 0, max: 2, step: 0.01, default: 1 },
|
|
1221
|
+
{ key: "wisps", label: "High cloud", min: 0, max: 1, step: 0.01, default: 0.5 },
|
|
1222
|
+
{ key: "trails", label: "Contrails", min: 0, max: 1.5, step: 0.01, default: 0.7 },
|
|
1223
|
+
{ key: "planeX", label: "Plane crosses at", min: -1, max: 1, step: 0.01, default: 0 },
|
|
1224
|
+
{ key: "planeY", label: "Plane height", min: 0, max: 1, step: 0.01, default: 0.7 },
|
|
1225
|
+
{ key: "planeTurn", label: "Plane heading", min: -1, max: 1, step: 0.01, default: 0.03 },
|
|
1226
|
+
{ key: "wind", label: "Wind", min: 0, max: 4, step: 0.05, default: 1 },
|
|
1227
|
+
{ key: "horizon", label: "Horizon", min: -0.6, max: 0.4, step: 0.01, default: 0.07 },
|
|
1228
|
+
{ key: "depth", label: "Sky depth", min: 0, max: 1.5, step: 0.01, default: 1 },
|
|
1229
|
+
{ key: "sun", label: "Sun", min: 0, max: 2, step: 0.01, default: 1 },
|
|
1230
|
+
{ key: "fire", label: "Fire", min: 0, max: 1.5, step: 0.01, default: 1 },
|
|
1231
|
+
{ key: "sunX", label: "Sun position", min: -1, max: 1, step: 0.01, default: 0.18 },
|
|
1232
|
+
{ key: "sunY", label: "Sun height", min: 0, max: 1, step: 0.01, default: 0.26 },
|
|
1233
|
+
{ key: "stars", label: "Stars", min: 0, max: 2, step: 0.01, default: 1 }
|
|
1234
|
+
],
|
|
1235
|
+
glsl: (
|
|
1236
|
+
/* glsl */
|
|
1237
|
+
`
|
|
1238
|
+
/* A theme's ambient tone at full brightness, so it reads as a hue. A tone
|
|
1239
|
+
with next to no hue (a monochrome theme's greys) keeps its own value:
|
|
1240
|
+
lifted, a grey would come out white, and the sky would be the page. */
|
|
1241
|
+
vec3 skyHue(vec3 c) {
|
|
1242
|
+
float hi = max(c.r, max(c.g, c.b));
|
|
1243
|
+
float chroma = (hi - min(c.r, min(c.g, c.b))) / max(hi, 1e-3);
|
|
1244
|
+
return mix(c, c / max(hi, 1e-3), smoothstep(0.04, 0.2, chroma));
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/* How much cloud stands over a point of the layer. The fine octaves slide
|
|
1248
|
+
over the broad ones, so a cloud boils slowly as it drifts. */
|
|
1249
|
+
float skyCloud(vec2 q, float t) {
|
|
1250
|
+
float s = 0.0;
|
|
1251
|
+
float a = 0.5;
|
|
1252
|
+
for (int i = 0; i < 7; i++) {
|
|
1253
|
+
s += a * vnoise(q + t * 0.012 * float(i) * vec2(1.0, 0.6));
|
|
1254
|
+
q = q * 2.03 + vec2(17.0, 9.0);
|
|
1255
|
+
a *= 0.54;
|
|
1256
|
+
}
|
|
1257
|
+
return s * 0.93;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
/* A mix made by eye rather than by light, so a blue thinned with the page
|
|
1261
|
+
stays blue instead of going to lilac. */
|
|
1262
|
+
vec3 skyMix(vec3 a, vec3 b, float k) {
|
|
1263
|
+
return pow(mix(pow(a, vec3(1.0 / 2.2)), pow(b, vec3(1.0 / 2.2)), k), vec3(2.2));
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/* Contrails: straight streaks far off and far above the cloud, low over
|
|
1267
|
+
the horizon and small with the distance, each on a heading of its own, laid across one
|
|
1268
|
+
another. A trail is thin and whole at its new
|
|
1269
|
+
end and spreads and breaks up towards its old one, and all of them
|
|
1270
|
+
slide slowly with the wind. */
|
|
1271
|
+
float skyTrails(vec2 p, float aspect, float w) {
|
|
1272
|
+
float s = 0.0;
|
|
1273
|
+
for (int i = 0; i < 7; i++) {
|
|
1274
|
+
float a = rnd(ivec2(i, 91));
|
|
1275
|
+
float b = rnd(ivec2(i, 17));
|
|
1276
|
+
float c = rnd(ivec2(i, 53));
|
|
1277
|
+
float ang = (a - 0.5) * 0.9;
|
|
1278
|
+
vec2 dir = vec2(cos(ang), sin(ang));
|
|
1279
|
+
vec2 at = vec2((b - 0.5) * aspect * 0.9, 0.1 + 0.26 * c) + vec2(0.0016, 0.0004) * w * (0.4 + b);
|
|
1280
|
+
vec2 d = p - at;
|
|
1281
|
+
float along = dot(d, dir);
|
|
1282
|
+
float across = dot(d, vec2(-dir.y, dir.x));
|
|
1283
|
+
float u = along / (0.22 + 0.4 * a) + 0.5;
|
|
1284
|
+
float age = 1.0 - clamp(u, 0.0, 1.0);
|
|
1285
|
+
float width = mix(0.0014, 0.0055, age * age) * (0.6 + 0.8 * c);
|
|
1286
|
+
float body = exp(-across * across / (width * width));
|
|
1287
|
+
float ends = smoothstep(0.0, 0.3, u) * smoothstep(1.0, 0.985, u);
|
|
1288
|
+
float broken = mix(1.0, 0.35 + 0.65 * vnoise(vec2(along * 40.0 + float(i) * 9.0, float(i) * 3.0 + across * 40.0)), age);
|
|
1289
|
+
s += body * ends * broken * mix(1.0, 0.45, age) * (0.45 + 0.55 * b);
|
|
1290
|
+
}
|
|
1291
|
+
return min(1.0, s);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/* One plane, very far off and high in the frame, well clear of the other
|
|
1295
|
+
trails. Its path is the host's to lay: the point it flies through and
|
|
1296
|
+
its heading are settings, so a page can route it clear of its type. It
|
|
1297
|
+
crosses the sky on a straight line and
|
|
1298
|
+
drawing a new trail as it goes: x is its silhouette, a fuselage, swept
|
|
1299
|
+
wings and a tail a few pixels long, and y the streak behind it, thin and
|
|
1300
|
+
bright at the plane and spreading and fading with age. */
|
|
1301
|
+
vec2 skyPlane(vec2 p, float aspect, float w) {
|
|
1302
|
+
float turn = u_planeTurn * 3.14159265;
|
|
1303
|
+
vec2 dir = vec2(cos(turn), sin(turn));
|
|
1304
|
+
vec2 through = vec2(u_planeX * 0.5 * aspect, u_planeY);
|
|
1305
|
+
float run = aspect + 1.8;
|
|
1306
|
+
vec2 d = p - (through + dir * (fract(w * 0.003 + 0.46) - 0.5) * run);
|
|
1307
|
+
float along = dot(d, dir);
|
|
1308
|
+
float across = abs(dot(d, vec2(-dir.y, dir.x)));
|
|
1309
|
+
float age = clamp((-along - 0.011) / 0.55, 0.0, 1.0);
|
|
1310
|
+
float width = mix(0.0012, 0.0042, age);
|
|
1311
|
+
float streak = exp(-across * across / (width * width)) * step(0.011, -along) * (1.0 - age) * (1.0 - age);
|
|
1312
|
+
float body = 1.0 - smoothstep(0.7, 1.0, length(vec2(along / 0.008, across / 0.0012)));
|
|
1313
|
+
float wing = (1.0 - smoothstep(0.7, 1.0, abs(along + 0.0006 + across * 0.4) / 0.0017))
|
|
1314
|
+
* (1.0 - smoothstep(0.006, 0.007, across));
|
|
1315
|
+
float tail = (1.0 - smoothstep(0.7, 1.0, abs(along + 0.0064 + across * 0.35) / 0.0011))
|
|
1316
|
+
* (1.0 - smoothstep(0.0022, 0.0028, across));
|
|
1317
|
+
return vec2(max(body, max(wing, tail)), streak);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
vec3 scene(vec2 uv, float t) {
|
|
1321
|
+
float aspect = u_size.x / u_size.y;
|
|
1322
|
+
vec2 p = vec2((uv.x - 0.5) * aspect, uv.y);
|
|
1323
|
+
/* Day on a light page, night on a dark one. */
|
|
1324
|
+
float day = smoothstep(0.1, 0.45, dot(u_ground, vec3(0.2126, 0.7152, 0.0722)));
|
|
1325
|
+
vec3 blue = mix(skyHue(u_col[0]), skyHue(u_col[3]), 0.35);
|
|
1326
|
+
vec3 gold = skyHue(u_col[1]);
|
|
1327
|
+
vec3 tint = skyHue(u_col[2]);
|
|
1328
|
+
vec3 ember = skyHue(u_col[4]);
|
|
1329
|
+
vec3 flame = mix(ember, skyHue(u_col[5]), 0.45);
|
|
1330
|
+
/* The hottest tone: the sixth role warmed with the sun's. */
|
|
1331
|
+
vec3 blazing = mix(skyHue(u_col[5]), gold, 0.2);
|
|
1332
|
+
/* The dusk sky's own tone: the blue greyed towards slate. */
|
|
1333
|
+
vec3 slate = mix(blue, vec3(dot(blue, vec3(0.2126, 0.7152, 0.0722))), 0.4);
|
|
1334
|
+
|
|
1335
|
+
/* Height above the horizon, and the point of the cloud layer this pixel
|
|
1336
|
+
looks at: the layer is flat, so it runs away as the eye drops. It
|
|
1337
|
+
closes up sideways only half as fast as it does in depth, or the cloud
|
|
1338
|
+
at the edges of a wide frame would be sheared into streaks. */
|
|
1339
|
+
float up = uv.y - u_horizon;
|
|
1340
|
+
float rise = max(up, 0.0) + 0.22;
|
|
1341
|
+
vec2 layer = vec2(p.x / mix(0.75, rise, 0.5), 1.3 / rise);
|
|
1342
|
+
float far = smoothstep(0.0, 0.3, up);
|
|
1343
|
+
float w = t * u_wind;
|
|
1344
|
+
vec2 drift = vec2(0.022, 0.007) * w;
|
|
1345
|
+
|
|
1346
|
+
/* Where the sun stands, how far its light reaches, and the band of sky
|
|
1347
|
+
along the horizon that takes its colour. */
|
|
1348
|
+
vec2 sunAt = vec2(u_sunX * 0.5 * aspect, u_sunY);
|
|
1349
|
+
vec2 toSun = sunAt - p;
|
|
1350
|
+
float sunDist = length(toSun);
|
|
1351
|
+
float reach = exp(-sunDist * sunDist / 0.7);
|
|
1352
|
+
float glow = exp(-sunDist * sunDist / 0.1) * u_sun;
|
|
1353
|
+
float disc = exp(-sunDist * sunDist / 0.005) * u_sun;
|
|
1354
|
+
float facingSky = exp(-sunDist * sunDist / 0.2);
|
|
1355
|
+
float low = exp(-max(up, 0.0) * max(up, 0.0) / 0.1);
|
|
1356
|
+
/* The strip right on the horizon, under the cloud, where the sky burns. */
|
|
1357
|
+
float band = exp(-max(up, 0.0) * max(up, 0.0) / 0.012);
|
|
1358
|
+
float burn = u_fire * min(1.0, u_sun);
|
|
1359
|
+
|
|
1360
|
+
/* The open sky: warm along the horizon, deep overhead. */
|
|
1361
|
+
float climb = pow(clamp(up, 0.0, 1.0), 0.65);
|
|
1362
|
+
vec3 dayHaze = skyMix(skyMix(u_ground, blue, 0.14 * u_depth), mix(flame, gold, 0.4), min(1.0, burn * (0.3 + 0.5 * band) * (0.4 + 0.6 * reach)));
|
|
1363
|
+
vec3 daySky = mix(dayHaze, skyMix(u_ground, mix(blue, tint, 0.12), min(1.0, 0.7 * u_depth)), climb);
|
|
1364
|
+
daySky = skyMix(daySky, mix(gold, vec3(1.0), 0.6), min(1.0, glow * 0.7 + disc));
|
|
1365
|
+
vec3 blaze = (mix(ember, tint, 0.3) * 0.07 * low + mix(blazing, ember, 0.25) * 0.75 * band) * burn * (0.12 + 0.88 * reach);
|
|
1366
|
+
vec3 nightHaze = u_ground + slate * 0.012 * u_depth + blaze;
|
|
1367
|
+
/* The night comes down from the top: the sky is all but the ground
|
|
1368
|
+
overhead and keeps a little slate only towards the sunset. */
|
|
1369
|
+
vec3 nightSky = u_ground + slate * (0.03 * low + 0.012) * (0.4 + 0.6 * reach) * u_depth + blaze
|
|
1370
|
+
+ mix(blazing, ember, 0.35) * glow * 0.32 + mix(gold, vec3(1.0), 0.3) * disc * 0.5;
|
|
1371
|
+
|
|
1372
|
+
/* Deep blue shows through overhead in slow patches, where the night has
|
|
1373
|
+
not quite closed. */
|
|
1374
|
+
vec3 deep = mix(skyHue(u_col[0]), tint, 0.18);
|
|
1375
|
+
float open = smoothstep(0.3, 0.7, vnoise(layer * 0.45 + drift * 0.3 + 71.0));
|
|
1376
|
+
nightSky += deep * (0.012 + 0.075 * open * climb) * u_depth;
|
|
1377
|
+
daySky = mix(daySky, skyMix(u_ground, deep, min(1.0, 0.85 * u_depth)), 0.45 * open * climb);
|
|
1378
|
+
|
|
1379
|
+
/* Stars, a point to a cell, each with its own place, size and beat, and
|
|
1380
|
+
only high up, clear of the fire. */
|
|
1381
|
+
vec2 sc = uv * u_size / (13.0 * u_ratio);
|
|
1382
|
+
ivec2 id = ivec2(floor(sc));
|
|
1383
|
+
float pick = rnd(id + ivec2(3, 57));
|
|
1384
|
+
vec2 at = 0.2 + 0.6 * vec2(rnd(id + ivec2(7, 3)), rnd(id + ivec2(13, 29)));
|
|
1385
|
+
/* A light twinkle: each star swells and dims at a pace of its own, never
|
|
1386
|
+
going out. */
|
|
1387
|
+
float beat = rnd(id + ivec2(19, 41));
|
|
1388
|
+
float star = step(pick, 0.12 * u_stars)
|
|
1389
|
+
* smoothstep(0.11, 0.0, length(fract(sc) - at))
|
|
1390
|
+
* (0.25 + 0.75 * rnd(id + ivec2(5, 11)))
|
|
1391
|
+
* mix(0.4, 1.0, pow(0.5 + 0.5 * sin(t * (0.5 + 1.5 * beat) + beat * 44.0), 2.0))
|
|
1392
|
+
* smoothstep(0.2, 0.6, up) * (1.0 - facingSky);
|
|
1393
|
+
nightSky += mix(slate, vec3(1.0), 0.7) * star * 0.5;
|
|
1394
|
+
|
|
1395
|
+
/* Thin high cloud, combed along the wind and slower than the cloud
|
|
1396
|
+
below; it catches the fire before anything else does. */
|
|
1397
|
+
float comb = skyCloud(layer * vec2(0.5, 2.6) / u_scale + drift * 0.4 + 31.0, w * 0.5);
|
|
1398
|
+
float wisp = smoothstep(0.42, 0.8, comb) * u_wisps * far;
|
|
1399
|
+
daySky = skyMix(daySky, skyMix(vec3(1.0), flame, 0.45 * burn * reach), wisp * 0.6);
|
|
1400
|
+
nightSky += mix(slate, mix(ember, blazing, 0.4), min(1.0, burn * reach * 1.4)) * wisp * (0.008 + 0.1 * facingSky * u_sun);
|
|
1401
|
+
|
|
1402
|
+
/* The layer is bent before it is read, so the cloud billows and curls.
|
|
1403
|
+
Then the cloud here, and the cloud a step towards the light: thicker
|
|
1404
|
+
there, and this point is in shade. */
|
|
1405
|
+
vec2 q = layer * 1.7 / u_scale + drift;
|
|
1406
|
+
q += u_warp * 0.55 * (vec2(
|
|
1407
|
+
vnoise(q * 0.7 + vec2(3.1, w * 0.012)),
|
|
1408
|
+
vnoise(q * 0.7 + vec2(9.4 - w * 0.01, 5.2))
|
|
1409
|
+
) - 0.5);
|
|
1410
|
+
vec2 lightStep = normalize(vec2(toSun.x, -toSun.y) + vec2(1e-4, 0.0)) * 0.26;
|
|
1411
|
+
float here = skyCloud(q, w);
|
|
1412
|
+
float there = skyCloud(q + lightStep, w);
|
|
1413
|
+
float edge = mix(0.66, 0.34, u_cover);
|
|
1414
|
+
float cloud = smoothstep(edge, edge + 0.13 * u_soft, here) * far;
|
|
1415
|
+
float lit = clamp(0.45 + (here - there) * 6.0, 0.0, 1.0);
|
|
1416
|
+
float core = smoothstep(edge, edge + 0.3, here);
|
|
1417
|
+
float shadow = clamp((1.0 - lit) * 0.85 + core * 0.45 - reach * 0.25, 0.0, 1.0);
|
|
1418
|
+
/* The contrails. The planes fly well above the weather, so every cloud
|
|
1419
|
+
stands in front of them: the cloud hides a trail wherever it stands,
|
|
1420
|
+
at its full thickness even where distance has hazed it, and the high
|
|
1421
|
+
cloud veils it. They hold the sun's colour long after the cloud has
|
|
1422
|
+
lost it: hot towards the sun, rose and then violet away from it. */
|
|
1423
|
+
float hidden = smoothstep(edge - 0.07, edge + 0.04, here);
|
|
1424
|
+
float trail = skyTrails(vec2(p.x, up), aspect, w) * u_trails * smoothstep(0.02, 0.12, up)
|
|
1425
|
+
* (1.0 - hidden) * (1.0 - 0.85 * min(1.0, wisp));
|
|
1426
|
+
/* The one plane still flying, and the trail it is laying. */
|
|
1427
|
+
vec2 plane = skyPlane(vec2(p.x, up), aspect, w) * step(0.01, u_trails) * (1.0 - hidden);
|
|
1428
|
+
trail = min(1.0, trail + plane.y * 1.3 * (1.0 - 0.85 * min(1.0, wisp)));
|
|
1429
|
+
vec3 trailHue = mix(mix(tint, ember, 0.6), mix(blazing, gold, 0.3), smoothstep(0.1, 0.8, reach));
|
|
1430
|
+
daySky = skyMix(daySky, skyMix(vec3(1.0), trailHue, min(1.0, 0.75 * burn)), min(1.0, trail * 0.85));
|
|
1431
|
+
nightSky += mix(mix(slate, vec3(1.0), 0.5) * 0.25, trailHue, min(1.0, burn)) * trail * u_sun * (0.14 + 0.9 * reach);
|
|
1432
|
+
daySky = mix(daySky, mix(blue, tint, 0.5) * 0.06, plane.x);
|
|
1433
|
+
nightSky = mix(nightSky, u_ground * 0.3, plane.x);
|
|
1434
|
+
|
|
1435
|
+
/* Thin cloud in front of the sun lets the light through. */
|
|
1436
|
+
float through = min(1.0, glow * (1.0 - core) * 0.9);
|
|
1437
|
+
float hot = 1.0 - smoothstep(0.0, 0.55, shadow);
|
|
1438
|
+
float cold = smoothstep(0.45, 1.0, shadow);
|
|
1439
|
+
|
|
1440
|
+
/* By day: cream on the hot side, rose through the middle, and a deep
|
|
1441
|
+
blue shade greyed with the third role. Far cloud takes the haze. */
|
|
1442
|
+
vec3 cream = skyMix(vec3(1.0), gold, 0.35 * burn * (0.35 + 0.65 * reach));
|
|
1443
|
+
vec3 rose = skyMix(vec3(1.0), mix(flame, ember, 0.3), min(1.0, 0.8 * burn * (0.5 + 0.5 * reach)));
|
|
1444
|
+
vec3 shade = skyMix(mix(blue, tint, 0.5), u_ground, 0.15) * 0.42;
|
|
1445
|
+
vec3 dayCloud = mix(mix(rose, cream, hot), shade, cold);
|
|
1446
|
+
dayCloud = mix(dayCloud, mix(gold, vec3(1.0), 0.75), through);
|
|
1447
|
+
dayCloud = mix(dayHaze, dayCloud, smoothstep(0.0, 0.4, up));
|
|
1448
|
+
/* By night the cloud makes the light: coals on the hot side, embers
|
|
1449
|
+
through the middle, and a shade darker than the sky behind it. With
|
|
1450
|
+
no fire it is a moonlit cloud, silver on slate. */
|
|
1451
|
+
/* Only the cloud that faces the sunset burns; the rest has gone to
|
|
1452
|
+
night. */
|
|
1453
|
+
float facing = facingSky;
|
|
1454
|
+
float power = u_sun * (0.02 + 0.95 * facing);
|
|
1455
|
+
vec3 silver = mix(slate, vec3(1.0), 0.6);
|
|
1456
|
+
vec3 coal = mix(silver * 0.3, mix(blazing, ember, 0.35) * 0.85, min(1.0, burn)) * power;
|
|
1457
|
+
vec3 embers = mix(slate * 0.1, mix(ember, tint, 0.5) * 0.2, min(1.0, burn)) * (0.1 * u_sun * reach + 0.9 * power);
|
|
1458
|
+
/* The shade is a silhouette: darker than the sky it stands against. */
|
|
1459
|
+
vec3 nightCloud = mix(u_ground * 0.75 + mix(embers, coal, hot), u_ground * 0.45 + tint * 0.004 * reach, cold);
|
|
1460
|
+
nightCloud += mix(gold, vec3(1.0), 0.35) * through * 0.55;
|
|
1461
|
+
nightCloud = mix(nightHaze, nightCloud, smoothstep(0.0, 0.4, up));
|
|
1462
|
+
|
|
1463
|
+
vec3 col = mix(mix(nightSky, nightCloud, cloud), mix(daySky, dayCloud, cloud), day);
|
|
1464
|
+
/* Below the horizon the land is dark by night and haze by day. */
|
|
1465
|
+
vec3 land = mix(u_ground + flame * burn * 0.03 * reach, dayHaze, day);
|
|
1466
|
+
return mix(land, col, smoothstep(-0.012, 0.012, up));
|
|
1467
|
+
}
|
|
1468
|
+
`
|
|
1469
|
+
)
|
|
1470
|
+
};
|
|
1471
|
+
const galaxy = {
|
|
1472
|
+
id: "galaxy",
|
|
1473
|
+
label: "Galaxy",
|
|
1474
|
+
description: "A spiral galaxy seen at a slant, a hot core in wound arms, deep in a field of stars.",
|
|
1475
|
+
mode: "dark",
|
|
1476
|
+
pixelRatio: 2,
|
|
1477
|
+
/* The disc's rim, its middle, the halo round the core, and the core. */
|
|
1478
|
+
colours: [
|
|
1479
|
+
"--color-ambient-4",
|
|
1480
|
+
"--color-ambient-3",
|
|
1481
|
+
"--color-ambient-5",
|
|
1482
|
+
"--color-ambient-1"
|
|
1483
|
+
],
|
|
1484
|
+
params: [
|
|
1485
|
+
{ key: "x", label: "Position across", min: -0.6, max: 0.6, step: 0.01, default: 0 },
|
|
1486
|
+
{ key: "y", label: "Position up", min: -0.6, max: 0.6, step: 0.01, default: -0.03 },
|
|
1487
|
+
{ key: "scale", label: "Size", min: 0.2, max: 3, step: 0.01, default: 1.9 },
|
|
1488
|
+
{ key: "tilt", label: "Tilt", min: -1.57, max: 1.57, step: 0.01, default: 0.4 },
|
|
1489
|
+
{ key: "incline", label: "Openness", min: 0.08, max: 1, step: 0.01, default: 0.3 },
|
|
1490
|
+
{ key: "arms", label: "Arms", min: 0, max: 2, step: 0.01, default: 1 },
|
|
1491
|
+
{ key: "wind", label: "Winding", min: 0, max: 10, step: 0.1, default: 4 },
|
|
1492
|
+
{ key: "dust", label: "Dust", min: 0, max: 2, step: 0.01, default: 1 },
|
|
1493
|
+
{ key: "core", label: "Core", min: 0, max: 2, step: 0.01, default: 1 },
|
|
1494
|
+
{ key: "glow", label: "Glow", min: 0, max: 2, step: 0.01, default: 1 },
|
|
1495
|
+
{ key: "companions", label: "Companions", min: 0, max: 2, step: 0.01, default: 1 },
|
|
1496
|
+
{ key: "stars", label: "Stars", min: 0, max: 2, step: 0.01, default: 1 },
|
|
1497
|
+
{ key: "nebula", label: "Nebula", min: 0, max: 2, step: 0.01, default: 1 },
|
|
1498
|
+
{ key: "band", label: "Nebula angle", min: -1.57, max: 1.57, step: 0.01, default: -0.3 },
|
|
1499
|
+
{ key: "bandY", label: "Nebula height", min: -0.7, max: 0.7, step: 0.01, default: 0 },
|
|
1500
|
+
{ key: "spin", label: "Spin", min: -4, max: 4, step: 0.05, default: 1 }
|
|
1501
|
+
],
|
|
1502
|
+
glsl: (
|
|
1503
|
+
/* glsl */
|
|
1504
|
+
`
|
|
1505
|
+
vec3 galaxyHue(vec3 c) {
|
|
1506
|
+
float grey = (c.r + c.g + c.b) / 3.0;
|
|
1507
|
+
c = max(grey + (c - grey) * 1.8, vec3(0.0));
|
|
1508
|
+
return c / max(max(c.r, max(c.g, c.b)), 1e-3);
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/* One depth of stars, in CSS pixels: one to a cell at most, held clear of
|
|
1512
|
+
the cell's edge so none is cut by it, on a grid turned its own way so
|
|
1513
|
+
no two depths line up and none lines up with the screen. Most are
|
|
1514
|
+
faint and a few are bright; thick is how full this part of the sky is.
|
|
1515
|
+
x is the star's light, y a roll for its colour. */
|
|
1516
|
+
vec2 galaxyStars(vec2 at, float size, int seed, float thick, float sigma, float halo, float t) {
|
|
1517
|
+
float turn = 0.6 + float(seed) * 0.37;
|
|
1518
|
+
at = mat2(cos(turn), sin(turn), -sin(turn), cos(turn)) * at + 4096.0;
|
|
1519
|
+
ivec2 cell = ivec2(floor(at / size));
|
|
1520
|
+
ivec2 id = cell + ivec2(seed, seed * 3);
|
|
1521
|
+
vec2 dd = at - (vec2(cell) + 0.16 + 0.68 * vec2(rnd(id + 37), rnd(id + 71))) * size;
|
|
1522
|
+
float pick = rnd(id + 911);
|
|
1523
|
+
float mag = 0.07 + 0.93 * pow(rnd(id + 5), 5.0);
|
|
1524
|
+
/* Each star breathes at its own rate, deeply, and now and then one
|
|
1525
|
+
flashes: a short glint well over its own light. */
|
|
1526
|
+
float rate = 0.8 + 2.8 * rnd(id + 13);
|
|
1527
|
+
float twinkle = 0.62 + 0.38 * sin(t * rate + 40.0 * pick)
|
|
1528
|
+
+ 0.8 * pow(max(sin(t * (0.35 + 0.5 * rnd(id + 17)) + 90.0 * pick), 0.0), 24.0);
|
|
1529
|
+
/* The near stars, the ones with a glow, hold almost steady: a point
|
|
1530
|
+
that flickers twinkles, a glowing bulb that does only pulses. */
|
|
1531
|
+
twinkle = mix(twinkle, 0.9 + 0.1 * sin(t * 0.4 * rate + 40.0 * pick), smoothstep(0.6, 1.0, sigma));
|
|
1532
|
+
float s = sigma * (0.8 + 0.5 * mag);
|
|
1533
|
+
float point = exp(-dot(dd, dd) / (2.0 * s * s));
|
|
1534
|
+
float bloom = halo * mag * (exp(-length(dd) / (2.2 * s)) + 0.25 * exp(-length(dd) / (7.0 * s)));
|
|
1535
|
+
return vec2((point + bloom) * step(pick, thick) * mag * twinkle, rnd(id + 3));
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
/* Two octaves, for the shapes that only steer finer noise. */
|
|
1539
|
+
float galaxyDrift(vec2 p) {
|
|
1540
|
+
return 0.65 * vnoise(p) + 0.35 * vnoise(p * 2.1 + vec2(17.0, 9.0));
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
vec3 scene(vec2 uv, float t) {
|
|
1544
|
+
float aspect = u_size.x / u_size.y;
|
|
1545
|
+
vec2 p = vec2((uv.x - 0.5) * aspect, uv.y - 0.5);
|
|
1546
|
+
vec2 css = uv * u_size / u_ratio;
|
|
1547
|
+
|
|
1548
|
+
vec3 blue = galaxyHue(u_col[0]);
|
|
1549
|
+
vec3 violet = galaxyHue(u_col[1]);
|
|
1550
|
+
vec3 rose = galaxyHue(u_col[2]);
|
|
1551
|
+
vec3 warm = galaxyHue(u_col[3]);
|
|
1552
|
+
|
|
1553
|
+
vec3 light = vec3(0.0);
|
|
1554
|
+
|
|
1555
|
+
/* ---- The galaxy's own frame: q runs along the disc's long axis and
|
|
1556
|
+
across it, with the rim at 1; d is the same place on the disc's face,
|
|
1557
|
+
the slant undone, and dr that face turned by the spin. */
|
|
1558
|
+
vec2 g = p - vec2(u_x * aspect, u_y);
|
|
1559
|
+
float ca = cos(u_tilt);
|
|
1560
|
+
float sa = sin(u_tilt);
|
|
1561
|
+
vec2 q = vec2(ca * g.x + sa * g.y, ca * g.y - sa * g.x) / (0.5 * u_scale);
|
|
1562
|
+
vec2 d = vec2(q.x, q.y / u_incline);
|
|
1563
|
+
float turn = t * u_spin * 0.012;
|
|
1564
|
+
float ct = cos(turn);
|
|
1565
|
+
float st = sin(turn);
|
|
1566
|
+
vec2 dr = vec2(ct * d.x + st * d.y, ct * d.y - st * d.x);
|
|
1567
|
+
float r = length(d);
|
|
1568
|
+
|
|
1569
|
+
vec3 glow = vec3(0.0);
|
|
1570
|
+
if (r < 1.25) {
|
|
1571
|
+
/* ---- The disc, unwound: turning each ring back by its own winding
|
|
1572
|
+
lays the two arms out straight along one line, so noise laid on
|
|
1573
|
+
it is cloud and dust that follow the arms, and the slant alone
|
|
1574
|
+
draws them out along the disc. */
|
|
1575
|
+
float w = 0.5 * u_wind * log(r + 0.05);
|
|
1576
|
+
float cw = cos(w);
|
|
1577
|
+
float sw = sin(w);
|
|
1578
|
+
vec2 dw = vec2(cw * dr.x - sw * dr.y, sw * dr.x + cw * dr.y);
|
|
1579
|
+
float cloud = fbm(dw * 3.6 + 7.0);
|
|
1580
|
+
float fine = fbm(dw * vec2(12.0, 15.0) + 23.0);
|
|
1581
|
+
float phase = 2.0 * atan(dw.y, dw.x) + 3.4 * (cloud - 0.5);
|
|
1582
|
+
float arm = pow(0.5 + 0.5 * cos(phase), 1.25);
|
|
1583
|
+
float outer = smoothstep(0.04, 0.26, r);
|
|
1584
|
+
float disc = exp(-r / 0.27) * smoothstep(1.2, 0.4, r);
|
|
1585
|
+
/* The outer disc thins out: its light drops, the gaps between the
|
|
1586
|
+
arms go dark, and the arms themselves break into patches with
|
|
1587
|
+
empty sky between them. */
|
|
1588
|
+
float thin = smoothstep(0.2, 0.7, r);
|
|
1589
|
+
float broken = mix(1.0, smoothstep(0.47, 0.7, fbm(dw * 5.5 + 80.0) + 0.12 * arm), thin);
|
|
1590
|
+
disc *= mix(1.0, 0.3, thin) * broken;
|
|
1591
|
+
float wound = mix(1.0, mix(0.3, 0.015, thin) + 1.5 * arm, min(1.0, u_arms) * outer) * (1.0 + max(u_arms - 1.0, 0.0) * arm * outer);
|
|
1592
|
+
/* Dust: ragged lanes on each arm's inner edge, and heavier on the
|
|
1593
|
+
near side of the disc, where it stands in front of the core's
|
|
1594
|
+
light. That one-sidedness is what tips the disc back into depth. */
|
|
1595
|
+
float nearSide = smoothstep(0.5, -0.5, d.y);
|
|
1596
|
+
float ridge = 1.0 - abs(2.0 * fbm(dw * vec2(7.0, 9.0) + 41.0) - 1.0);
|
|
1597
|
+
float lane = pow(0.5 + 0.5 * cos(phase - 1.5), 3.0) * smoothstep(0.45, 0.9, ridge + 0.25 * fine);
|
|
1598
|
+
float veil = min(0.94, u_dust * lane * outer * smoothstep(1.1, 0.5, r) * (0.55 + 0.75 * nearSide));
|
|
1599
|
+
/* The disc is stars too fine to tell apart: cloud, and a fine tooth. */
|
|
1600
|
+
float tooth = 0.86 + 0.28 * vnoise(css * 1.7);
|
|
1601
|
+
vec3 body = mix(mix(rose, violet, smoothstep(0.0, 0.2, r)), blue, smoothstep(0.06, 0.4, r));
|
|
1602
|
+
glow += mix(body, vec3(1.0), 0.18) * disc * wound * (0.35 + 1.3 * fine) * tooth * 0.75 * u_glow;
|
|
1603
|
+
/* Knots of young stars strung down the arms, blue-white, and the
|
|
1604
|
+
rose of the gas between them. */
|
|
1605
|
+
float knot = pow(fbm(dw * 19.0 + 60.0), 5.0) * arm * disc * outer;
|
|
1606
|
+
glow += mix(blue, vec3(1.0), 0.6) * knot * 26.0 * u_glow * min(1.0, u_arms);
|
|
1607
|
+
glow += rose * pow(fine, 4.0) * arm * disc * outer * 2.2 * u_glow * min(1.0, u_arms);
|
|
1608
|
+
glow *= 1.0 - veil;
|
|
1609
|
+
/* The lanes are not black: dust reddens what shines through it. */
|
|
1610
|
+
glow += mix(rose, warm, 0.4) * veil * disc * 0.1 * u_glow;
|
|
1611
|
+
}
|
|
1612
|
+
/* A halo wider than the disc and rounder, so the disc sits in it. */
|
|
1613
|
+
float rh = length(vec2(q.x, q.y / mix(u_incline, 1.0, 0.3)));
|
|
1614
|
+
glow += mix(blue, violet, 0.3) * (exp(-rh / 0.3) * 0.028 + exp(-rh / 1.1) * 0.002) * u_glow;
|
|
1615
|
+
|
|
1616
|
+
/* ---- The core: a bulge rounder than the disc, standing out of it. */
|
|
1617
|
+
vec2 b = vec2(q.x, q.y / mix(u_incline, 1.0, 0.5));
|
|
1618
|
+
float rb = length(b);
|
|
1619
|
+
glow += mix(rose, violet, 0.35) * (exp(-rb / 0.1) * 0.5 + exp(-rb / 0.28) * 0.1) * u_core;
|
|
1620
|
+
glow += mix(mix(warm, rose, 0.4), vec3(1.0), 0.6) * (exp(-rb * rb / (2.0 * 0.035 * 0.035)) * 1.6 + exp(-rb / 0.05) * 0.8) * u_core;
|
|
1621
|
+
/* Rolled off like film, so the core burns out to white with colour
|
|
1622
|
+
held in its shoulder and the faint arms keep their place under it. */
|
|
1623
|
+
light += 1.0 - exp(-1.5 * glow);
|
|
1624
|
+
/* The disc's own stars: the sky's faint ones come up where it shines. */
|
|
1625
|
+
float among = 1.0 + 3.0 * min(1.0, dot(glow, vec3(0.6)));
|
|
1626
|
+
|
|
1627
|
+
/* ---- Two companions: a soft ellipse off the disc, and a tight bright
|
|
1628
|
+
one beside the core. */
|
|
1629
|
+
vec2 e = q - vec2(0.03, -0.64);
|
|
1630
|
+
e = vec2(0.8 * e.x + 0.6 * e.y, 0.8 * e.y - 0.6 * e.x) * vec2(1.0, 1.7);
|
|
1631
|
+
float re = length(e);
|
|
1632
|
+
light += mix(blue, vec3(1.0), 0.45) * (exp(-re / 0.03) * 0.5 + exp(-re * re / (2.0 * 0.012 * 0.012)) * 0.6 + exp(-re / 0.09) * 0.05) * u_companions;
|
|
1633
|
+
float rc = length(q - vec2(-0.31, 0.27));
|
|
1634
|
+
light += mix(blue, vec3(1.0), 0.8) * (exp(-rc * rc / (2.0 * 0.011 * 0.011)) + exp(-rc / 0.022) * 0.3 + exp(-rc / 0.07) * 0.04) * u_companions;
|
|
1635
|
+
|
|
1636
|
+
/* ---- The nebula: a band of lit gas across the whole sky, behind the
|
|
1637
|
+
galaxy, as our own galaxy lies across a night sky. m runs along the
|
|
1638
|
+
band and across it. The gas is noise pushed about by slower noise,
|
|
1639
|
+
so it gathers into billows and pulls out into wisps, and that push
|
|
1640
|
+
drifts, so the gas creeps like plasma. It is bright down the band's
|
|
1641
|
+
middle, where a ragged rift of dust is cut back out of it, cools from
|
|
1642
|
+
rose through violet to blue at its edges, and the stars crowd into it. */
|
|
1643
|
+
float cb = cos(u_band);
|
|
1644
|
+
float sb = sin(u_band);
|
|
1645
|
+
vec2 m = vec2(cb * p.x + sb * (p.y - u_bandY), cb * (p.y - u_bandY) - sb * p.x);
|
|
1646
|
+
vec2 mq = m * vec2(1.5, 3.0) + 11.0;
|
|
1647
|
+
vec2 push = vec2(galaxyDrift(mq + vec2(0.0, t * 0.006)), galaxyDrift(mq + vec2(5.2, 1.3) - vec2(t * 0.005, 0.0)));
|
|
1648
|
+
float gas = fbm(mq + 2.4 * push);
|
|
1649
|
+
float wisp = fbm(m * vec2(4.5, 8.0) + 3.2 * push + 40.0);
|
|
1650
|
+
/* Filaments: the bright seams where two billows meet. */
|
|
1651
|
+
float seam = pow(1.0 - abs(2.0 * fbm(m * vec2(6.0, 11.0) + 4.0 * push + 90.0) - 1.0), 5.0);
|
|
1652
|
+
float off = m.y + 0.16 * (push.x - 0.5);
|
|
1653
|
+
float body = exp(-off * off / (2.0 * 0.19 * 0.19));
|
|
1654
|
+
float heart = exp(-off * off / (2.0 * 0.07 * 0.07));
|
|
1655
|
+
float rift = smoothstep(0.42, 0.8, 1.0 - abs(2.0 * galaxyDrift(m * vec2(3.0, 7.0) + 1.6 * push + 70.0) - 1.0)) * heart;
|
|
1656
|
+
float billow = body * smoothstep(0.3, 0.68, gas);
|
|
1657
|
+
vec3 gasHue = mix(mix(blue, violet, smoothstep(0.3, 0.65, wisp)), rose, smoothstep(0.5, 0.8, gas) * heart);
|
|
1658
|
+
vec3 neb = gasHue * billow * (0.12 + 2.4 * wisp * wisp * wisp + 0.9 * seam) * 0.36;
|
|
1659
|
+
neb += mix(warm, rose, 0.5) * heart * gas * gas * (0.6 * gas + 0.5 * seam) * 0.42;
|
|
1660
|
+
neb *= 1.0 - 0.92 * rift;
|
|
1661
|
+
light += (1.0 - exp(-2.0 * neb)) * u_nebula;
|
|
1662
|
+
|
|
1663
|
+
/* ---- The stars, four depths of them, thick where the sky's own
|
|
1664
|
+
cloud and the nebula are and thin between, over a breath of that
|
|
1665
|
+
cloud's colour. */
|
|
1666
|
+
float mist = fbm(p * 1.7 + 3.0);
|
|
1667
|
+
float thick = clamp(1.6 * mist - 0.46 + 0.75 * billow * (1.0 - rift) * min(1.0, u_nebula), 0.025, 0.85);
|
|
1668
|
+
vec2 dust = galaxyStars(css, 4.0, 0, thick, 0.42, 0.0, t);
|
|
1669
|
+
vec2 far = galaxyStars(css, 11.0, 3, thick, 0.55, 0.0, t);
|
|
1670
|
+
vec2 mid = galaxyStars(css, 37.0, 7, 0.25 + 0.6 * thick, 0.75, 0.1, t);
|
|
1671
|
+
vec2 near = galaxyStars(css, 150.0, 11, 0.45, 1.2, 0.4, t);
|
|
1672
|
+
vec3 dustTint = mix(vec3(1.0), mix(blue, violet, dust.y), 0.55);
|
|
1673
|
+
vec3 farTint = mix(vec3(1.0), mix(blue, violet, far.y), 0.45);
|
|
1674
|
+
vec3 midTint = mix(vec3(1.0), mix(mix(blue, violet, mid.y), warm, step(0.9, mid.y)), 0.35);
|
|
1675
|
+
vec3 nearTint = mix(vec3(1.0), mix(mix(blue, rose, near.y), warm, step(0.85, near.y)), 0.22);
|
|
1676
|
+
light += (dustTint * dust.x * 0.42 * among + farTint * far.x * 0.85 * among + midTint * mid.x * 1.3 + nearTint * near.x * 1.8) * u_stars;
|
|
1677
|
+
light += mix(blue, violet, 0.6 * mist) * mist * mist * mist * 0.018 * min(1.0, u_stars);
|
|
1678
|
+
|
|
1679
|
+
return u_ground + light;
|
|
1680
|
+
}
|
|
1681
|
+
`
|
|
1682
|
+
)
|
|
1683
|
+
};
|
|
1684
|
+
const SCENES = [horizon, rift, glyphs, prism, meteors, waves, aurora, highway, ocean, sky, galaxy];
|
|
757
1685
|
export {
|
|
758
1686
|
SCENES,
|
|
759
1687
|
aurora,
|
|
1688
|
+
galaxy,
|
|
760
1689
|
glyphs,
|
|
1690
|
+
highway,
|
|
761
1691
|
horizon,
|
|
762
1692
|
meteors,
|
|
1693
|
+
ocean,
|
|
763
1694
|
prism,
|
|
764
1695
|
rift,
|
|
1696
|
+
sky,
|
|
765
1697
|
waves
|
|
766
1698
|
};
|