@mkbabb/glass-ui 10.1.3 → 11.0.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/MIGRATION.md +1024 -1461
- package/README.md +2 -2
- package/dist/DialogContent-DG5kseRQ.js +159 -0
- package/dist/DropdownMenuTrigger-uhSXgEfK.js +76 -0
- package/dist/{Surface-1nPoabc3.js → Surface-C7wq2j0A.js} +3 -0
- package/dist/aurora.css +1 -0
- package/dist/aurora.js +246 -2472
- package/dist/auroraImageSource-xNLDUjcy.js +30 -0
- package/dist/axes.js +8 -8
- package/dist/blob.css +1 -0
- package/dist/blob.js +57 -54
- package/dist/budget-CJfhLIIV.js +13 -0
- package/dist/button-CAKhiOZy.js +113 -0
- package/dist/button.js +1 -1
- package/dist/{card-ByyqRBvK.js → card-D_uXphvL.js} +4 -1
- package/dist/card.js +1 -1
- package/dist/carousel.js +3 -2
- package/dist/{checkbox-B1qn65se.js → checkbox-COLnvULu.js} +1 -0
- package/dist/checkbox.css +1 -0
- package/dist/checkbox.js +1 -1
- package/dist/{collapsible-DFzK29Oh.js → collapsible-Bd4Et730.js} +1 -0
- package/dist/collapsible.css +1 -0
- package/dist/collapsible.js +1 -1
- package/dist/color-HkUaTAJj.js +270 -0
- package/dist/{color.glsl-DTJhdekG.js → color.glsl-bFJm8k5R.js} +4 -16
- package/dist/color.wgsl-B-qDJ_OM.js +4 -0
- package/dist/{command-CatrAsrl.js → command-BsFOGZwB.js} +3 -2
- package/dist/command.css +1 -0
- package/dist/command.js +1 -1
- package/dist/component-styles.css +0 -1
- package/dist/components/_shared/axes.d.ts +7 -0
- package/dist/components/_shared/feedback/dot-ring.css +1 -1
- package/dist/components/_shared/overlay/focus-return.d.ts +9 -0
- package/dist/components/_shared/overlay/index.d.ts +3 -0
- package/dist/components/_shared/overlay/root-scroll-lock.d.ts +4 -0
- package/dist/components/_shared/overlay/sheet-width.d.ts +2 -0
- package/dist/components/_shared/shape/useBarShape.d.ts +4 -0
- package/dist/components/aurora/composables/auroraFallbackGround.d.ts +12 -0
- package/dist/components/aurora/constants/presets.d.ts +21 -0
- package/dist/components/aurora/index.d.ts +2 -2
- package/dist/components/button/styles.css +1 -1
- package/dist/components/dark-mode-toggle/dark-mode-toggle.css +1 -1
- package/dist/components/data-table/composables/useDataTableResponsive.d.ts +2 -0
- package/dist/components/deck/styles/capture.css +1 -1
- package/dist/components/dialog/DialogContent.vue.d.ts +2 -2
- package/dist/components/dialog/ModalOverlay.vue.d.ts +2 -2
- package/dist/components/dialog/ModalScrim.vue.d.ts +26 -0
- package/dist/components/dialog/styles.css +1 -1
- package/dist/components/dock/GlassDock.vue.d.ts +4 -1
- package/dist/components/dock/composables/useDockClickIntegrity.d.ts +4 -0
- package/dist/components/dock/composables/useDockShellProps.d.ts +34 -2
- package/dist/components/dock/composables/useDockState.d.ts +5 -0
- package/dist/components/dock/index.d.ts +1 -2
- package/dist/components/dock/styles/controls/icon-button.css +1 -1
- package/dist/components/dock/styles/controls/tab-button.css +1 -1
- package/dist/components/dock/styles/morph.css +1 -1
- package/dist/components/dock/styles/run.css +1 -1
- package/dist/components/dock/trigger.d.ts +1 -0
- package/dist/components/expandable-container/ExpandableContainer.vue.d.ts +30 -29
- package/dist/components/menu/ContextMenu.vue.d.ts +27 -0
- package/dist/components/menu/DropdownMenu.vue.d.ts +5 -23
- package/dist/components/menu/context.d.ts +18 -5
- package/dist/components/menu/family-click.d.ts +2 -0
- package/dist/components/menu/family-context.d.ts +2 -0
- package/dist/components/menu/index.d.ts +1 -1
- package/dist/components/sheet/SheetContent.vue.d.ts +2 -2
- package/dist/components/sortable-list/styles.css +1 -0
- package/dist/components/surface/Surface.vue.d.ts +4 -1
- package/dist/components/tabs/composables/useTabDragMorph.d.ts +4 -7
- package/dist/components/tabs/styles/segmented.css +1 -1
- package/dist/components/tabs/types.d.ts +7 -8
- package/dist/composables/dom/useResizeObserver.d.ts +3 -1
- package/dist/composables/glass/fieldPaint.d.ts +4 -0
- package/dist/composables/glass/useGlassBackdropLuminance.d.ts +7 -6
- package/dist/composables/glass/webgpu/useGpuSubstrate.d.ts +8 -0
- package/dist/composables/motion/core/motionTempo.d.ts +2 -1
- package/dist/composables/motion/morph/useDragMorph.d.ts +2 -2
- package/dist/composables/motion/morph/useSelectionGroup.d.ts +6 -25
- package/dist/composables/motion/morph/useSelectionIndicator.d.ts +8 -54
- package/dist/composables/motion/spring/useLiquidFlex.d.ts +3 -5
- package/dist/composables/motion/spring/useSpringMount.d.ts +0 -9
- package/dist/{configurator-CPxIo3q2.js → configurator-C1ZKEf1b.js} +7 -5
- package/dist/configurator.css +1 -0
- package/dist/configurator.js +1 -1
- package/dist/constants-DfrO-IaH.js +8 -0
- package/dist/constellation.css +1 -0
- package/dist/constellation.js +2 -1
- package/dist/control.css +1 -0
- package/dist/{control.css_vue_type_style_index_0_src_true_lang-BIdufaDG.js → control.css_vue_type_style_index_0_src_true_lang-D2hdtjs4.js} +1 -0
- package/dist/{createCanvasLifecycle-hJHobVTn.js → createCanvasLifecycle-DS0vEs_G.js} +76 -75
- package/dist/dark-mode-toggle.js +1 -1
- package/dist/{data-table-Cs93-uY7.js → data-table-lDykVYuo.js} +113 -107
- package/dist/data-table.css +1 -0
- package/dist/data-table.js +1 -1
- package/dist/{deck-Cm_VmyNL.js → deck-Bc-2mEKE.js} +1 -0
- package/dist/deck.js +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dock-trigger.d.ts +1 -0
- package/dist/dock-trigger.js +88 -0
- package/dist/dock.js +677 -689
- package/dist/dom.js +1 -1
- package/dist/easing.js +4 -4
- package/dist/expandable-container-wS1awXGd.js +135 -0
- package/dist/expandable-container.css +1 -0
- package/dist/expandable-container.js +1 -1
- package/dist/{fading-scroll-CTeW3KNS.js → fading-scroll-D3Y20ibL.js} +2 -2
- package/dist/fading-scroll.js +1 -1
- package/dist/fieldPaint-Ci77oajZ.js +7 -0
- package/dist/fourier-field.css +1 -0
- package/dist/fourier-field.js +15 -13
- package/dist/glSetup-DMaDgrEj.js +577 -0
- package/dist/glass-ui.js +67 -66
- package/dist/handmark.css +1 -0
- package/dist/handmark.js +82 -71
- package/dist/index.css +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/{input-eLZ_AU7l.js → input-BLF2pMHE.js} +1 -1
- package/dist/input.js +1 -1
- package/dist/{label-CE03H1KL.js → label-ryNPL7e6.js} +1 -0
- package/dist/label.css +1 -0
- package/dist/label.js +1 -1
- package/dist/labeled-field.css +1 -0
- package/dist/labeled-field.js +5 -4
- package/dist/{menu-DaYAZiVW.js → menu-C_l2Sslf.js} +162 -112
- package/dist/menu.js +3 -3
- package/dist/metric.js +1 -0
- package/dist/motion-core.js +138 -44
- package/dist/motion-lHDAQHEE.js +91 -0
- package/dist/motion.js +5 -5
- package/dist/motionTempo-DXdVbCWr.js +13 -0
- package/dist/music-staff.js +1 -0
- package/dist/{number-field-RP89046a.js → number-field-BXFUP49Z.js} +3 -2
- package/dist/number-field.css +1 -0
- package/dist/number-field.js +1 -1
- package/dist/pager-dots.css +1 -0
- package/dist/pager-dots.js +4 -3
- package/dist/participation-C5y5VZTN.js +52 -0
- package/dist/{popover-BdpoE4Ar.js → popover-DQUmwuAa.js} +3 -2
- package/dist/popover.js +1 -1
- package/dist/{progress-eVa-mc7J.js → progress-BUn0Bw7Z.js} +1 -0
- package/dist/progress.css +1 -0
- package/dist/progress.js +1 -1
- package/dist/{radio-group-B58Bz16F.js → radio-group-xdEy2tdi.js} +1 -0
- package/dist/radio-group.css +1 -0
- package/dist/radio-group.js +1 -1
- package/dist/root-scroll-lock-DJFrQhMa.js +22 -0
- package/dist/select-Dt5dXm87.js +309 -0
- package/dist/select.js +1 -1
- package/dist/{separator-D4EZM10u.js → separator-C4y9p_ky.js} +1 -0
- package/dist/separator.css +1 -0
- package/dist/separator.js +1 -1
- package/dist/sheet-DLqNUIZl.js +347 -0
- package/dist/sheet-width-DgXgJNa5.js +18 -0
- package/dist/sheet.js +2 -2
- package/dist/{slider-5uoY-cLG.js → slider-CZiKrWGg.js} +8 -8
- package/dist/slider.js +1 -1
- package/dist/sortable-list.js +2 -1
- package/dist/{status-dot-W4LFiJps.js → status-dot-BDZKcRxy.js} +2 -1
- package/dist/status-dot.css +1 -0
- package/dist/status-dot.js +1 -1
- package/dist/styles/components.css +1 -1
- package/dist/styles/glass/glass-capsule.css +1 -1
- package/dist/styles/glass/glass-chip.css +1 -1
- package/dist/styles/glass/mark.css +1 -1
- package/dist/styles/glass/overlay-plate.css +1 -1
- package/dist/styles/glass/surface-axis.css +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles/theme/radius.css +1 -1
- package/dist/styles/tokens/color-radius.css +1 -1
- package/dist/styles/tokens/manifest.d.ts +1 -1
- package/dist/styles/tokens/scale-paper.css +1 -1
- package/dist/styles/utilities/base-misc.css +1 -1
- package/dist/surface.js +1 -1
- package/dist/{switch-BYUZ6g9G.js → switch-DLfGYU35.js} +1 -0
- package/dist/switch.css +1 -0
- package/dist/switch.js +1 -1
- package/dist/tabs-NgTRPGZx.js +229 -0
- package/dist/tabs.js +1 -1
- package/dist/textarea.js +1 -1
- package/dist/timeline.css +1 -0
- package/dist/timeline.js +4 -3
- package/dist/toggle-group-DgXcJGD6.js +129 -0
- package/dist/toggle-group.css +1 -0
- package/dist/toggle-group.js +1 -1
- package/dist/tokens.js +2 -0
- package/dist/{tooltip-CZVubnJf.js → tooltip-Do3qCw0r.js} +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/typewriter.css +1 -0
- package/dist/typewriter.js +1 -0
- package/dist/uniformBridge-CJyy7NOn.js +150 -0
- package/dist/useBarShape-CmP35Z8o.js +24 -0
- package/dist/{useCanvas2D-CQRElMyE.js → useCanvas2D-Bhpwua98.js} +1 -1
- package/dist/{useDockCtaReceive-BSSgD6mu.js → useDockCtaReceive-Dn_-paqP.js} +1 -1
- package/dist/{useDragMorph-B363RUbF.js → useDragMorph-BEI74U0t.js} +51 -40
- package/dist/{color.wgsl-BTszLY39.js → useGpuSubstrate-Y5XAdU8d.js} +7 -7
- package/dist/{useLiquidPress-h1scrPtP.js → useLiquidPress-D5mjZC6U.js} +2 -2
- package/dist/{useResizeObserver-CdUlm2QZ.js → useResizeObserver-Bv3nN46q.js} +4 -7
- package/dist/useScrollChrome-DMP6kDI9.js +67 -0
- package/dist/useSelectionGroup-DAQv5Lb5.js +186 -0
- package/dist/{useSpring-9u2_shxV.js → useSpring-Aof0nTRt.js} +1 -1
- package/dist/useSpringMount-jgNkymRl.js +73 -0
- package/dist/wgpuSetup-CFuqd_RP.js +1278 -0
- package/package.json +8 -1
- package/dist/DialogContent-CwIBvou_.js +0 -157
- package/dist/DropdownMenuTrigger-CKRnhDSQ.js +0 -93
- package/dist/button-BOFTUPyU.js +0 -110
- package/dist/composables/motion/morph/eyeglass.d.ts +0 -141
- package/dist/expandable-container-CZUj9BzY.js +0 -142
- package/dist/glass-ui.css +0 -2
- package/dist/motion-BvV1_24p.js +0 -61
- package/dist/motionTempo-tscp92Nm.js +0 -7
- package/dist/participation-B7UFdgXB.js +0 -55
- package/dist/select-BiF0FCZf.js +0 -292
- package/dist/sheet-DmJxgAHc.js +0 -345
- package/dist/tabs-C5sC0fBE.js +0 -269
- package/dist/toggle-group-CC5b3o1R.js +0 -125
- package/dist/useScrollChrome-BJbWV32F.js +0 -162
- package/dist/useSelectionGroup-zsEwitF6.js +0 -291
- package/dist/useSpringMount-OA-0mTNv.js +0 -73
package/dist/aurora.js
CHANGED
|
@@ -1,2314 +1,37 @@
|
|
|
1
|
+
import "./aurora.css";
|
|
1
2
|
import { t as e } from "./useIntersectionPause-CzKR3EyP.js";
|
|
2
3
|
import { t } from "./_plugin-vue_export-helper-B3ysoDQm.js";
|
|
3
4
|
import { t as n } from "./usePointerVelocityField-Lx26_Yap.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { a as
|
|
11
|
-
import {
|
|
12
|
-
import { interpolateHue as de } from "@mkbabb/value.js/color";
|
|
13
|
-
//#region src/components/aurora/composables/textureUpload.ts
|
|
14
|
-
var fe = {
|
|
15
|
-
premultiplyAlpha: "none",
|
|
16
|
-
colorSpaceConversion: "none"
|
|
17
|
-
};
|
|
18
|
-
function pe(e) {
|
|
19
|
-
return createImageBitmap(e, fe);
|
|
20
|
-
}
|
|
21
|
-
async function me(e) {
|
|
22
|
-
return typeof e == "string" ? pe(await (await fetch(e)).blob()) : e instanceof Blob ? pe(e) : e;
|
|
23
|
-
}
|
|
24
|
-
function he() {
|
|
25
|
-
let e = new ImageData(1, 1);
|
|
26
|
-
return e.data.set([
|
|
27
|
-
128,
|
|
28
|
-
128,
|
|
29
|
-
128,
|
|
30
|
-
255
|
|
31
|
-
]), e;
|
|
32
|
-
}
|
|
33
|
-
function ge(e) {
|
|
34
|
-
return e instanceof HTMLImageElement ? {
|
|
35
|
-
width: e.naturalWidth,
|
|
36
|
-
height: e.naturalHeight
|
|
37
|
-
} : {
|
|
38
|
-
width: e.width,
|
|
39
|
-
height: e.height
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function _e(e, t, n = {}) {
|
|
43
|
-
let { linearFilter: r = !0, clampToEdge: i = !0 } = n, a = e.createTexture();
|
|
44
|
-
e.bindTexture(e.TEXTURE_2D, a), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, e.NONE), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t);
|
|
45
|
-
let o = r ? e.LINEAR : e.NEAREST;
|
|
46
|
-
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, o), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, o);
|
|
47
|
-
let s = i ? e.CLAMP_TO_EDGE : e.REPEAT;
|
|
48
|
-
return e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, s), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, s), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, e.BROWSER_DEFAULT_WEBGL), a;
|
|
49
|
-
}
|
|
50
|
-
function ve(e, t) {
|
|
51
|
-
let { width: n, height: r } = ge(t), i = e.createTexture({
|
|
52
|
-
label: "[texture-upload] image",
|
|
53
|
-
size: [
|
|
54
|
-
n,
|
|
55
|
-
r,
|
|
56
|
-
1
|
|
57
|
-
],
|
|
58
|
-
format: "rgba8unorm",
|
|
59
|
-
usage: 22
|
|
60
|
-
});
|
|
61
|
-
return e.queue.copyExternalImageToTexture({
|
|
62
|
-
source: t,
|
|
63
|
-
flipY: !1
|
|
64
|
-
}, {
|
|
65
|
-
texture: i,
|
|
66
|
-
premultipliedAlpha: !1
|
|
67
|
-
}, [
|
|
68
|
-
n,
|
|
69
|
-
r,
|
|
70
|
-
1
|
|
71
|
-
]), {
|
|
72
|
-
texture: i,
|
|
73
|
-
width: n,
|
|
74
|
-
height: r
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/components/aurora/composables/auroraImageSource.ts
|
|
79
|
-
function ye(e) {
|
|
80
|
-
let t = null, n = null, r;
|
|
81
|
-
return {
|
|
82
|
-
getDecodedImage: () => t,
|
|
83
|
-
setImageUploader(e) {
|
|
84
|
-
n = e, e && t && e(t);
|
|
85
|
-
},
|
|
86
|
-
ensureDecoded(i) {
|
|
87
|
-
i.source !== "image" || i.src == null || i.src !== r && (r = i.src, me(i.src).then((r) => {
|
|
88
|
-
t = r, n?.(r), e.wake();
|
|
89
|
-
}).catch((t) => {
|
|
90
|
-
e.onError?.(t instanceof Error ? t : Error(String(t)));
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
function be(e, t, n) {
|
|
96
|
-
let r = null;
|
|
97
|
-
e.activeTexture(e.TEXTURE0);
|
|
98
|
-
let i = (n) => {
|
|
99
|
-
e.useProgram(t), e.activeTexture(e.TEXTURE0), r && e.deleteTexture(r), r = _e(e, n);
|
|
100
|
-
};
|
|
101
|
-
return i(n.getDecodedImage() ?? he()), n.setImageUploader(i), () => {
|
|
102
|
-
r && e.deleteTexture(r), n.setImageUploader(null);
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
//#endregion
|
|
5
|
+
import { t as r } from "./useScrollProgress-Bq-KPaKM.js";
|
|
6
|
+
import { cssToOklch as i, gamutMapStop as a, oklchStopToHex as o, oklchToLinear as s } from "./color.js";
|
|
7
|
+
import { n as c, t as l } from "./budget-CJfhLIIV.js";
|
|
8
|
+
import { a as u, c as d, d as f, f as p, i as m, l as h, n as g, o as _, p as v, r as y, s as b, t as x, u as S } from "./color-HkUaTAJj.js";
|
|
9
|
+
import { n as C } from "./auroraImageSource-xNLDUjcy.js";
|
|
10
|
+
import { n as w, t as T } from "./useGpuSubstrate-Y5XAdU8d.js";
|
|
11
|
+
import { a as E, n as D, o as O } from "./rendererStatus-BxUlBLVy.js";
|
|
12
|
+
import { Fragment as k, computed as A, createElementBlock as j, createElementVNode as M, defineComponent as ee, getCurrentInstance as N, isMemoSame as P, normalizeClass as F, normalizeStyle as I, onBeforeUnmount as te, onMounted as L, openBlock as R, readonly as z, ref as B, renderList as ne, shallowRef as V, unref as H, watch as U } from "vue";
|
|
106
13
|
//#region src/components/aurora/constants/renderMode.ts
|
|
107
|
-
function
|
|
14
|
+
function W() {
|
|
108
15
|
let e;
|
|
109
16
|
try {
|
|
110
|
-
e =
|
|
17
|
+
e = w();
|
|
111
18
|
} catch {
|
|
112
19
|
return !1;
|
|
113
20
|
}
|
|
114
21
|
return e === null ? !1 : e.includes("swiftshader") || e.includes("llvmpipe") || e.includes("software") || e.includes("basic render") || e.includes("microsoft basic");
|
|
115
22
|
}
|
|
116
|
-
function
|
|
117
|
-
return e !== "css" && !t.forceWebGLUnderSoftwareRaster &&
|
|
118
|
-
}
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/components/aurora/constants/shaders/aurora.vert.ts
|
|
121
|
-
var Se = "#version 300 es\nin vec2 aPos;\nout vec2 vUv;\nvoid main() {\n vUv = aPos * 0.5 + 0.5;\n gl_Position = vec4(aPos, 0.0, 1.0);\n}", Ce = "\nconst float CURL_EPS = 0.012;\n\n// Scalar fbm potential psi — the host's noise basis, wrapped so the curl operator is\n// basis-agnostic. A host carrying its own fbm defines this as: return fbm(p);\nfloat potentialFBM(vec2 p);\n\n// ∇×ψ in 2D — the divergence-free flow direction. Central finite differences of the\n// scalar potential give the partials; the cross-pairing (∂y, −∂x) is the 2D curl.\nvec2 curlFBM(vec2 p) {\n float dx = potentialFBM(p + vec2(CURL_EPS, 0.0)) - potentialFBM(p - vec2(CURL_EPS, 0.0));\n float dy = potentialFBM(p + vec2(0.0, CURL_EPS)) - potentialFBM(p - vec2(0.0, CURL_EPS));\n // ψ-gradient is (dx, dy)/(2·eps); the curl rotates it 90°: (∂ψ/∂y, −∂ψ/∂x).\n vec2 g = vec2(dx, dy) / (2.0 * CURL_EPS);\n return vec2(g.y, -g.x);\n}\n", we = "// ── Palette LUT (OKLCh/OKLab interpolation) ──────────────────────────────\n// The endpoints stay CPU-baked to LINEAR sRGB (the Aras precompute pattern); only\n// the between-endpoint interpolation runs in perceptual space. The ramp\n// itself (the smoothstep ease + the OKLab-rectangular-vs-OKLCh-hue-arc dispatch on\n// uHuePath) is the shared samplePaletteRamp from procedural-color.glsl, the SAME\n// source the WebGPU twin splices; samplePalette here only selects the bracketing\n// stop pair + the raw inter-stop t and hands them to the shared ramp.\nvec3 samplePalette(float id) {\n id = clamp(id, 0.0, 1.0);\n float scaled = id * float(uStopCount - 1);\n int i0 = int(floor(scaled));\n int i1 = min(i0 + 1, uStopCount - 1);\n float t = fract(scaled);\n return samplePaletteRamp(uPalette[i0], uPalette[i1], t, uHuePath);\n}\n\n// ── Nuclei field ──────────────────────────────────────────────────────────\nvoid nucleiField(vec2 p, float t, out float paletteId, out float valueMod) {\n float accumBias = 0.0;\n float accumValue = 0.0;\n float accumW = 0.0;\n for (int i = 0; i < MAX_NUCLEI; i++) {\n if (i >= uNucleiCount) break;\n vec2 posI = uNucleiPos[i]\n + uNucleiDriftRadius[i] * vec2(\n cos(t * uNucleiDrift * K_NUCLEI + uNucleiDriftPhase[i]),\n sin(t * uNucleiDrift * K_NUCLEI + uNucleiDriftPhase[i] * 1.13)\n );\n vec2 diff = p - posI;\n // Anisotropic Gaussian: rotate diff into the nucleus's local frame\n // (major axis along uNucleiAngle), then scale the major-axis component by\n // 1/elongation so the squared distance describes an ellipse. Defaults\n // 1.0/0.0 reduce to the isotropic dot(diff, diff).\n float ca = cos(uNucleiAngle[i]);\n float sa = sin(uNucleiAngle[i]);\n vec2 local = vec2( ca * diff.x + sa * diff.y,\n -sa * diff.x + ca * diff.y);\n float along = local.x / max(uNucleiElong[i], 0.01);\n float across = local.y;\n float d2 = along * along + across * across;\n float r = max(uNucleiRadius[i], 0.01);\n float w = exp(-uSoftmaxBeta * d2 / (r * r));\n accumBias += w * uNucleiPaletteBias[i];\n accumValue += w * uNucleiValueBias[i];\n accumW += w;\n }\n paletteId = accumBias / max(accumW, 1e-4);\n valueMod = accumValue / max(accumW, 1e-4);\n\n // Palette drift — slow global paletteId breathe between adjacent stops. The\n // rate rides K_PAL (perceptible ~30–60s hue cycle at the default coefficient);\n // the amplitude lifts the authored coefficient into a 0.03..0.06 paletteId band\n // so the palette visibly travels rather than dithering within one stop.\n float palAmp = clamp(uPaletteDrift * 6.0, 0.0, 0.06);\n paletteId += palAmp * sin(t * uPaletteDrift * K_PAL);\n paletteId = clamp(paletteId, 0.0, 1.0);\n}\n", Te = "// ── Flow field ────────────────────────────────────────────────────────────\n// Structure-tensor prototype (body defined post-sampleBase in the mediums block).\n// Returns vec4(dir.x, dir.y, coherence, packedGrad) — the minor-eigenvector tangent + A + the\n// metal-gradient .w lane in the widened vec3→vec4 return. The forward declaration must match\n// the vec4 definition or WebKit's compiler rejects the mismatched signature (L1b).\nvec4 structureTensorField(vec2 p, float t, vec2 fallbackDir);\n\nvec2 flowField(vec2 p, float t) {\n vec2 dir = vec2(1.0, 0.0);\n if (uFlowPattern == 1) {\n // radial\n dir = normalize(p - uFlowFocal + 1e-4);\n } else if (uFlowPattern == 2) {\n // swirl — tangent to radial\n vec2 rad = normalize(p - uFlowFocal + 1e-4);\n dir = vec2(-rad.y, rad.x);\n } else if (uFlowPattern == 3) {\n // diagonal\n float a = radians(uFlowAngle);\n dir = vec2(cos(a), sin(a));\n } else if (uFlowPattern == 4) {\n // multi — curl-noise driven\n float n = fbm(p * 2.0 + t * 0.02);\n float a = n * 6.2831;\n dir = vec2(cos(a), sin(a));\n } else if (uFlowPattern == 5) {\n // Tensor / ETF: the color field's own edge-tangent flow. The\n // diagonal angle seeds the smooth fallback the coherence-weighted blend\n // relaxes toward in low-structure zones. Returns directly (no curl/cursor\n // post-mix — the tensor field already carries the structure orientation;\n // the cursor warp still drives the underlying color field in domainWarp).\n float a = radians(uFlowAngle);\n vec2 fallback = vec2(cos(a), sin(a));\n return structureTensorField(p, t, fallback).xy;\n }\n // curl — perturb by noise. Radial gets much less curl so rays stay clean.\n if (uFlowCurl > 0.0) {\n float n = fbm(p * 3.0) - 0.5;\n float curlAmt = uFlowCurl;\n if (uFlowPattern == 1) curlAmt *= 0.25; // radial: preserve ray clarity\n if (uFlowPattern == 2) curlAmt *= 0.55; // swirl: allow moderate curl\n float a = atan(dir.y, dir.x) + n * 3.14159 * curlAmt;\n dir = vec2(cos(a), sin(a));\n }\n // cursor influence — swirl around the cursor position\n if (uCursorStrength > 0.001) {\n vec2 toCur = uCursor - p;\n float d = length(toCur);\n float r = max(uCursorRadius, 0.01);\n float w = exp(-(d * d) / (r * r * 0.5));\n // swirl tangent\n vec2 tangent = vec2(-toCur.y, toCur.x) / max(d, 1e-4);\n float a0 = atan(dir.y, dir.x);\n float a1 = atan(tangent.y, tangent.x);\n // blend angle\n float da = a1 - a0;\n da = atan(sin(da), cos(da)); // wrap to [-pi, pi]\n float a = a0 + da * w * uCursorStrength;\n dir = vec2(cos(a), sin(a));\n }\n return dir;\n}\n", Ee = "// Khronos PBR-Neutral tonemap (hue + saturation preserving)\nvec3 aces(vec3 color) {\n const float startCompression = 0.8 - 0.04;\n const float desaturation = 0.15;\n float x = min(color.r, min(color.g, color.b));\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n float peak = max(color.r, max(color.g, color.b));\n if (peak < startCompression) return clamp(color, 0.0, 1.0);\n float d = 1.0 - startCompression;\n float newPeak = 1.0 - d * d / (peak + d - startCompression);\n color *= newPeak / peak;\n float g = 1.0 - 1.0 / (desaturation * (peak - newPeak) + 1.0);\n return clamp(mix(color, newPeak * vec3(1.0), g), 0.0, 1.0);\n}\n", De = "// ── Curved swept brushstroke primitive ────────────────────────────────────\n// A stroke is a curved spine from A to B with quadratic bulge K (sideways offset\n// at midpoint). Width varies along length via a shape profile. Edge is ragged\n// (bristle-modulated), ends are rounded blobs, inside has streak modulation.\n//\n// For pixel p, we invert an approximate projection onto the curved spine:\n// 1) project p onto straight AB axis -> along0, cross0\n// 2) at parameter along0, spine offset = 4·K·along0·(1-along0) perpendicular\n// 3) cross = cross0 - spineOffset, refine along one iteration\n// Coverage blends paint atop col based on per-stroke color sampled from the\n// underlying base at spine midpoint — so overlapping strokes from different\n// palette regions meet at hard, ragged demarcations.\n\nstruct StrokeHit {\n float coverage; // 0..1\n vec3 color;\n float alongT; // 0..1 along spine, for internal modulation\n float crossN; // cross distance / current half-width, signed\n float edgeN; // distance to edge in half-widths (0 = at edge, 1 = at spine)\n};\n\nStrokeHit noHit() { return StrokeHit(0.0, vec3(0.0), 0.0, 0.0, 0.0); }\n\nvec2 rotateDir(vec2 dir, float angle) {\n float ca = cos(angle), sa = sin(angle);\n return vec2(dir.x * ca - dir.y * sa, dir.x * sa + dir.y * ca);\n}\n\nvec2 safeDir(vec2 dir) {\n float len = length(dir);\n return len > 1e-4 ? dir / len : vec2(1.0, 0.0);\n}\n\n// Shape profile along the stroke. type:\n// 0 tapered — thin-fat-thin (classic brush)\n// 1 load-drag — fat start, tapers to a point\n// 2 dab — ellipse-like, round center\n// 3 even — near-constant, slight end taper\n// 4 comma — van-Gogh atomic dab: ASYMMETRIC taper, fat near one end and\n// drawn to a fine point at the other (the divisionist crescent\n// mark). The width peak sits off-centre (~0.32) so the two ends\n// taper at DIFFERENT rates — a loaded round head + a dragged tail.\nfloat strokeShape(float t, int type) {\n t = clamp(t, 0.0, 1.0);\n if (type == 1) {\n // loaded at t=0, tapering\n return pow(1.0 - t, 0.55) * smoothstep(0.0, 0.08, t);\n } else if (type == 2) {\n // dab / blob\n float d = t - 0.5;\n return exp(-d * d * 12.0);\n } else if (type == 3) {\n // mostly even, slight end softening\n return smoothstep(0.0, 0.08, t) * smoothstep(1.0, 0.92, t) * 0.95 + 0.05;\n } else if (type == 4) {\n // comma / crescent — width peaks at ~0.32 then drags to a fine tail. The two\n // sides of the peak fall at different exponents (a fat round head, a long thin\n // tail), so the mark reads as a directional van-Gogh comma, not a symmetric oval.\n float peak = 0.32;\n float head = smoothstep(0.0, peak, t); // rounded loaded head\n float tail = pow(clamp((1.0 - t) / (1.0 - peak), 0.0, 1.0), 1.6); // dragged thin tail\n return clamp(min(head, tail) * 1.04, 0.0, 1.0);\n }\n // 0 tapered\n return smoothstep(0.0, 0.22, t) * smoothstep(1.0, 0.78, t);\n}\n\n// A single curved stroke.\n// a, b — endpoints\n// halfW — base half-width (world units)\n// bulge — signed perpendicular midpoint offset, in world units\n// shapeType — 0..3\n// bristleFreq — spatial frequency of edge raggedness\n// bristleAmp — 0..0.5 fraction of halfW chewed away at edge extrema\n// streakSeed — uniqueness seed for internal streaks\n// colAtMid — pre-sampled color at midpoint\nStrokeHit curvedStroke(vec2 p, vec2 a, vec2 b, float halfW,\n float bulge, int shapeType,\n float bristleFreq, float bristleAmp,\n float streakSeed, vec3 colAtMid) {\n vec2 ab = b - a;\n float L = length(ab);\n if (L < 1e-5) return noHit();\n vec2 tang = ab / L;\n vec2 norm = vec2(-tang.y, tang.x);\n\n vec2 rel = p - a;\n float along0 = dot(rel, tang) / L; // straight projection 0..1 along AB\n float cross0 = dot(rel, norm); // signed cross\n\n // Spine sideways offset due to bulge (parabolic)\n float bend = 4.0 * bulge * along0 * (1.0 - along0);\n float cross1 = cross0 - bend;\n\n // One refinement step: as the spine bends, the closest-point along shifts.\n // Spine tangent differs from straight tangent; first-order correction:\n float dBend = 4.0 * bulge * (1.0 - 2.0 * along0); // d(bend)/d(along)\n float along1 = along0 + (cross1 * dBend) / (L * (1.0 + dBend * dBend / (L * L)));\n\n // Bristle-ragged edge: half-width gets chewed by 1D noise along the spine\n float edgeNoise = fbm(vec2(along1 * bristleFreq, streakSeed * 7.3)) - 0.5;\n float edgeNoise2 = fbm(vec2(along1 * bristleFreq * 2.3, streakSeed * 3.1 + 17.0)) - 0.5;\n float edgeMod = 1.0 - bristleAmp * (0.6 + 0.4 * edgeNoise) * (0.5 + edgeNoise2);\n\n // Width profile along the stroke\n float shape = strokeShape(along1, shapeType);\n float halfWNow = halfW * shape * edgeMod;\n\n // Inside-segment coverage\n float cov = 0.0;\n if (along1 >= 0.0 && along1 <= 1.0 && halfWNow > 1e-6) {\n float cn = abs(cross1) / halfWNow;\n // fwidth-derived AA: half-width from the field's screen-space gradient so the\n // edge holds ~1px regardless of zoom/DPR (mirrors metaball.frag.ts:252-255).\n float aaC = max(fwidth(cn), 1e-6);\n cov = 1.0 - smoothstep(1.0 - aaC, 1.0 + aaC, cn);\n }\n\n // End-cap blobs (rounded tips, not perpendicular cuts)\n float capA = 0.0, capB = 0.0;\n {\n vec2 capCenterA = a + norm * (bulge * 0.0); // at a\n vec2 capCenterB = a + tang * L + norm * bend * 0.0 + norm * 0.0; // at b; bend is 0 at endpoints\n capCenterB = b;\n float endShapeA = strokeShape(0.02, shapeType);\n float endShapeB = strokeShape(0.98, shapeType);\n float rA = halfW * endShapeA * (0.9 + 0.2 * fbm(vec2(streakSeed * 13.0)));\n float rB = halfW * endShapeB * (0.9 + 0.2 * fbm(vec2(streakSeed * 19.0 + 5.0)));\n float dA = length(p - capCenterA);\n float dB = length(p - capCenterB);\n // fwidth-derived AA on the clean Euclidean cap distances (mirrors metaball.frag.ts:252-255).\n float aaA = max(fwidth(dA), 1e-6);\n float aaB = max(fwidth(dB), 1e-6);\n capA = 1.0 - smoothstep(rA - aaA, rA + aaA, dA);\n capB = 1.0 - smoothstep(rB - aaB, rB + aaB, dB);\n // Only apply caps if we're BEYOND the segment; otherwise the segment wins.\n capA *= (along1 < 0.05) ? 1.0 : 0.0;\n capB *= (along1 > 0.95) ? 1.0 : 0.0;\n }\n\n float coverage = max(cov, max(capA, capB));\n if (coverage < 0.002) return noHit();\n\n // Edge distance (for impasto later): 0 at edge, 1 at spine\n float edgeDist = halfWNow > 1e-6 ? clamp(1.0 - abs(cross1) / halfWNow, 0.0, 1.0) : 0.0;\n\n return StrokeHit(\n coverage,\n colAtMid,\n clamp(along1, 0.0, 1.0),\n halfWNow > 1e-6 ? cross1 / halfWNow : 0.0,\n edgeDist\n );\n}\n\n// The painterly STROKE mediums (those that deposit via paintStrokeLayers/paintOver):\n// oil (3), van-Gogh (5), oil-pastel (6). For these the stroke OVER-composite runs in\n// OKLab so overlapping complementaries mix through a chromatic path, not the linear-\n// RGB grey mud; the smooth/atmospheric pole never reaches paintOver so it pays nothing.\nbool isPainterlyStroke() {\n return uMedium == 3 || uMedium == 5 || uMedium == 6;\n}\n\n// OKLab OVER-composite: lerp L,a,b of the over-color toward the under-color (the\n// Ottosson matrices spliced from procedural-color.glsl.ts — no new color math). Two\n// complementary-hued strokes overlapping transition through OKLab, where the midpoint\n// holds chroma, instead of the linear mix() that desaturates toward grey.\nvec3 paintOverOklab(vec3 under, vec3 over, float alpha) {\n vec3 labU = linOklab(under);\n vec3 labO = linOklab(over);\n return max(oklabToLinearSrgb(mix(labU, labO, alpha)), vec3(0.0));\n}\n\n// Composite stroke over col with internal streaking + ACCUMULATE paint HEIGHT.\n// streakAmp — 0..0.2 how much internal streaks darken/lighten\n// impastoAmp — 0..1 paint-thickness contribution (the height the relight reads)\n// hardness — 0..1 how crisp the compositing transition is (1 = razor, 0 = creamy)\n//\n// The fixed-RGB edge rim (the phantom upper-left light) is retired. Each\n// stroke now deposits PAINT HEIGHT into the height accumulator (coverage x per-stroke\n// thickness, perturbed by the bristle/streak fbm for ridges/grooves); mediumOil\n// derives a normal from the accumulated height gradient (dFdx/dFdy) and relights it\n// once with the movable uLightDir source (relightImpasto), in linear before aces().\n//\n// The internal streak perturbs hue and chroma in OKLCh, not value only,\n// so a single stroke carries a small hue gradient (broken color at the ATOM level —\n// adjacent strokes shimmer like real impasto, not flat stamped swatches);\n// and the OVER-composite runs in OKLab on the painterly stroke mediums so overlapping\n// complementaries mix as pigment, not the linear-mix grey.\n// impastoFloor — the per-stroke height-crown floor: oil's 0.4+0.6*edgeN reads\n// floor=0.4 (the crown tapers to 40% at the stroke edge); the van-Gogh\n// profile passes floor=1.0 so each atomic dab catches a FULL-height\n// glint (scope item 1d). The crown magnitude is floor + (1-floor)*edgeN.\nvoid paintOver(inout vec3 col, inout float height, StrokeHit s,\n float streakFreq, float streakAmp,\n float impastoAmp, float hardness, float streakSeed,\n float impastoFloor) {\n if (s.coverage < 0.002) return;\n float strokeOpacity = clamp(uStrokeAmount, 0.0, 1.0);\n if (strokeOpacity <= 0.001) return;\n vec3 c = s.color;\n\n // Internal streaks — fbm along spine, modulated by cross position. Gives\n // the loaded-brush look: some bristles carry more pigment than others.\n float streakA = fbm(vec2(s.alongT * streakFreq, s.crossN * 2.7 + streakSeed));\n float streakB = fbm(vec2(s.alongT * streakFreq * 0.6 + streakSeed * 3.7, s.crossN * 4.1));\n float streak = 0.6 * (streakA - 0.5) + 0.4 * (streakB - 0.5);\n\n // ── Within-stroke OKLCh broken color. The streak fBm perturbs\n // the stroke's HUE + CHROMA along alongT/crossN, seeded per-stroke, so a single\n // stroke reads a small hue gradient (the atom-level broken-color shimmer). Value is\n // carried by the same streak so the loaded-brush light/dark survives. Gated to the\n // painterly stroke mediums + uBrokenColor (the smooth pole keeps the cheap value-only\n // streak). A second decorrelated fBm drives the hue axis so hue ≠ a scaled value.\n float hueStreak = fbm(vec2(s.alongT * streakFreq * 0.45 + streakSeed * 5.3,\n s.crossN * 1.9 + streakSeed * 1.7)) - 0.5;\n if (isPainterlyStroke() && uBrokenColor > 0.001) {\n vec3 lch = oklabToOklch(linOklab(c));\n // ±~10° within-stroke hue swing + ±~9% chroma, scaled by uBrokenColor. Smaller\n // than the per-stroke cell jitter (brokenColorJitter) — this is the intra-stroke\n // gradient layered on top of the per-cell pigment patch.\n lch.z += hueStreak * (20.0 * PI / 180.0) * uBrokenColor;\n lch.y = max(lch.y * (1.0 + (streak) * 0.18 * uBrokenColor), 0.0);\n c = max(oklabToLinearSrgb(oklchToOklab(lch)), vec3(0.0));\n }\n // Value streak (the loaded-brush light/dark across the bristles) — kept for every\n // medium that reaches paintOver (the smooth pole never does). The along-spine value\n // modulation is the loaded-brush light/dark that gives each stroke its OWN directional\n // luminance band — the structure-tensor signal a low-contrast color field (a uniform-hue\n // oil field) has no other source for (the §4.2 anisotropy lift on the flat-palette case).\n c *= 1.0 + streak * streakAmp * 3.2;\n\n // Cross-stroke ridge/valley shading — a catch-light along the spine centre, darkening to\n // the stroke edges. This is the strongest DIRECTIONAL luminance cue: it carves a bright\n // ridge down the stroke's length and dark grooves between adjacent strokes, so a field of\n // parallel strokes reads as parallel light/dark bands (the high-A van-Gogh signature) even\n // where the underlying colour is flat. s.edgeN is 0 at the edge, 1 at the spine.\n float ridgeShade = smoothstep(0.0, 0.55, s.edgeN);\n c *= 1.0 + (ridgeShade - 0.5) * 0.30;\n\n float softLimit = mix(0.35, 0.98, hardness);\n float alpha = smoothstep(0.0, 1.0 - softLimit, s.coverage) * strokeOpacity;\n // OKLab OVER-composite on the painterly stroke mediums (overlap mixes as pigment,\n // not grey); the smooth pole never reaches paintOver, so it keeps the cheap path.\n col = isPainterlyStroke() ? paintOverOklab(col, c, alpha) : mix(col, c, alpha);\n\n // ── Accumulate paint height. Thickness peaks at the stroke spine and\n // falls toward the impastoFloor at the edge (edgeN: 0=edge, 1=spine), perturbed by\n // the bristle streak so ridges/grooves form. The relight reads the gradient of this\n // field. The van-Gogh profile's floor=1.0 gives every atomic dab a full-height crown.\n float ridge = 0.7 + 0.3 * (streak + 0.5);\n float crown = impastoFloor + (1.0 - impastoFloor) * s.edgeN;\n height += s.coverage * impastoAmp * crown * ridge * alpha;\n}\n\n// Relight the accumulated paint height. Derive a normal from the height\n// gradient (dFdx/dFdy — derivatives are in-pattern; fwidth is already used for AA),\n// then apply diffuse + Blinn specular from the movable uLightDir/uLightColor source.\n// LINEAR-space lighting BEFORE aces() (the tonemap/OETF stay locked); thin strokes\n// inherit a low shininess, thick impasto raises it (high-height ridges catch a sharp\n// glint). canvasBase is the tooth height so the canvas weave also catches the light.\nvec3 relightImpasto(vec3 col, float height, float canvasBase) {\n float h = height + canvasBase;\n // Height-gradient normal. heightScale trades relief depth for surface flatness.\n float heightScale = 6.0;\n vec3 N = normalize(vec3(-dFdx(h) * 40.0, -dFdy(h) * 40.0, 1.0 / heightScale));\n vec3 L = normalize(uLightDir);\n vec3 V = vec3(0.0, 0.0, 1.0); // view straight on\n vec3 H = normalize(L + V);\n float diff = max(dot(N, L), 0.0);\n // Thick impasto → high shininess (sharp glint); thin paint → broad soft sheen.\n float shininess = mix(8.0, 64.0, clamp(height * 2.0, 0.0, 1.0));\n float spec = pow(max(dot(N, H), 0.0), shininess);\n // Modulate the lit terms by how much paint sits here (no relief on bare ground).\n float relief = clamp(h * 1.5, 0.0, 1.0);\n vec3 lit = col * (1.0 + uImpasto * relief * (diff - 0.5) * 0.5 * uLightColor);\n // The specular glint is gated to ACCUMULATED-thick paint (height²) — a per-fine-stroke\n // sharp glint on every thin fill dab read as bright isotropic SPECKLE that buried the\n // directional stroke bands (the §4.2 anisotropy / §4.3 slope sink on the low-contrast\n // oil field). Only where real impasto has built up does the raked glint fire, so the\n // highlight tracks the macro ridges, not the fine speckle.\n float specGate = clamp(height, 0.0, 1.0);\n lit += uImpasto * relief * spec * specGate * 0.5 * uLightColor;\n return lit;\n}\n\n// Best-of-9-neighbor placement: sample 3x3 surrounding cells and take the\n// stroke that covers this pixel most. Breaks the grid by per-cell jitter and\n// sparse density via noise thresholding.\n// energyGrade — the SBR energy-grade magnitude (0 = none, the oil/oil-pastel\n// baseline; 1 = the full van-Gogh Starry-Night cascade — long\n// confident strokes in the lights/coherent zones, short dabs in\n// the darks/flat zones). The van-Gogh profile carries 1.0 (the\n// energy grade is a PROFILE field, not a buried uMedium==5 branch).\nStrokeHit bestOil(vec2 p, float cellSize, float lenMul, float halfWMul,\n float jitterAmt, float density, int shapeType,\n float bristleAmp, vec2 flow, float t, float seed,\n float energyGrade) {\n vec2 cell = floor(p / cellSize);\n\n StrokeHit best = noHit();\n // 3x3 neighborhood\n for (int dy = -1; dy <= 1; dy++) {\n for (int dx = -1; dx <= 1; dx++) {\n vec2 cc = cell + vec2(float(dx), float(dy));\n vec2 hh = hash22(cc + seed) - 0.5;\n // Density gate — noise threshold; sparse placement.\n float gate = hash21(cc * 1.7 + seed * 0.3);\n if (gate > density) continue;\n\n vec2 center = (cc + 0.5 + hh * jitterAmt) * cellSize;\n\n // Per-stroke direction source from the strokeOrient switch:\n // uStrokeOrient==0 (flow) — the layer-provided hand-authored flowField.\n // uStrokeOrient==1 (tensor) — the structure-tensor minor eigenvector at the\n // cell center (the color field's edge-tangent),\n // so strokes hug the color zones (van Gogh).\n // coh carries the per-cell coherence A for the energy grading (long\n // confident strokes where structure is coherent, stubby dabs in flat zones).\n vec2 f;\n float coh = 1.0;\n if (uStrokeOrient == 1) {\n // vec4 (the metal-finish widen) — .xy tangent + .z coherence; the .w gradient lane\n // is unused here. A vec3 local would be a type-mismatch WebKit rejects (L1c).\n vec4 tf = structureTensorField(center, t, safeDir(flow));\n f = safeDir(tf.xy);\n coh = tf.z;\n } else {\n f = safeDir(flow);\n }\n // Per-stroke deterministic local perturbation so alternate stroke layers stay\n // live. Tensor strokes get FAR less angular jitter (the field already orients them\n // — over-jittering the tensor strokes scatters their directions and the rendered\n // field reads isotropic, the §4.2 anisotropy floor). The flow-oriented (non-tensor)\n // strokes keep the full jitter (they have no per-cell orientation source).\n float jScale = (uStrokeOrient == 1) ? 0.15 : 1.0;\n float angJ = (hash21(cc + seed + 11.0) - 0.5) * 0.9 * jScale; // +/- 0.45/0.07 rad\n float curlScale = (uStrokeOrient == 1) ? 0.30 : 1.0;\n float localCurl = (fbm(center * (2.6 + seed * 0.11) + seed * 1.9) - 0.5) * 0.55 * uFlowCurl * curlScale;\n vec2 dir = rotateDir(f, angJ + localCurl);\n\n // The SBR energy grade is a profile field (energyGrade), not a buried\n // uMedium==5 branch. The van-Gogh profile passes energyGrade=1.0 (the full\n // Starry-Night cascade); oil/oil-pastel pass 0.0 (uniform length). The grade\n // modulates stroke length by local luminance (bright → long confident strokes,\n // dark → short dabs, the Kolmogorov/Batchelor congruence) AND by coherence\n // (coherent zones → long, flat → stubby), lerped in by energyGrade so a profile\n // can dial the cascade from off (0) to full (1).\n float energy = 1.0;\n if (energyGrade > 0.001) {\n float luma = clamp(dot(sampleBase(center, t), W_LUMA), 0.0, 1.0);\n float graded = mix(0.5, 1.5, luma) * mix(0.6, 1.0, coh);\n energy = mix(1.0, graded, energyGrade);\n }\n\n float lenV = cellSize * lenMul * (0.65 + 0.55 * hash21(cc + seed + 23.0)) * energy;\n float halfW = cellSize * halfWMul * (0.70 + 0.55 * hash21(cc + seed + 41.0));\n float bulge = (hash21(cc + seed + 53.0) - 0.5) * lenV * 0.35;\n\n vec2 a = center - dir * (lenV * 0.5);\n vec2 b = center + dir * (lenV * 0.5);\n\n vec3 colMid = brokenColorJitter(\n sampleBase(center, t),\n hash21(cc + seed + 89.0),\n hash21(cc * 2.3 + seed + 97.0),\n 1.0\n );\n\n StrokeHit h = curvedStroke(p, a, b, halfW, bulge, shapeType,\n 7.0, bristleAmp,\n hash21(cc + seed + 67.0), colMid);\n if (h.coverage > best.coverage) best = h;\n }\n }\n return best;\n}\n", Oe = "// ── Van Gogh atomic-dab body ─────────────────────────────────────────────\n// Van-Gogh does NOT route through the shared\n// oil paintStrokeMedium cascade — four DENSE layers of LONG-THIN tensor-oriented\n// strokes (lenMul up to 5.2, widMul 0.22) hugging a continuous coherent field. Packed\n// that tight, thin strokes that follow continuous iso-bands MERGE into smooth flowing\n// filaments — the \"marbled flow-bands\" read (a spirograph/fingerprint, not impasto),\n// AND the per-cell 8-tap structure tensor × 4 layers × 9 cells = ~324 sampleBase/pixel\n// runs at ~4fps. Van Gogh's sky is NOT continuous flow — it is DISCRETE, SHORT,\n// LOADED comma dabs, separated by visible ground, queued into swirl ROWS.\n//\n// This is a purpose-built two-layer DAB pass, disjoint from the oil cascade:\n// • orientation from the analytic SWIRL flowField (van-Gogh skies ARE swirl rows) +\n// per-cell angular jitter — NOT the expensive per-cell tensor (the lag source, and\n// the marble source: a jittered discrete dab can NOT merge into a continuous\n// filament the way a tensor-locked thin stroke does).\n// • SHORT comma dabs (len/wid ≈ 2.6 : 1 — a loaded crescent mark, not a 10:1\n// filament), so each reads as a SEPARABLE atom.\n// • SPARSE placement with visible inter-dab ground (density ≈ 0.42), over a darkened\n// swirl underpainting (the Starry-Night visible ground the bright dabs read over).\n// • a single sampleBase per cell + OKLCh broken-color jitter (pigment shimmer);\n// full-height impasto crown per dab (each catches its own raked glint).\n// This is ~2 layers × 9 cells × ~1 sampleBase ≈ 20/pixel (a ~16× cost cut, ~60fps), and\n// jittered short dabs CANNOT marble.\n\n// One atomic comma dab — a CLEAN analytic crescent SDF (NOT the oil curvedStroke).\n// The oil curvedStroke's spine-projection + rounded end-caps + fwidth-AA + bristle\n// edge each leave a thin sub-pixel skirt, and a field of those skirts over open ground\n// abuts into a faint network of SEAM LINES. A van-Gogh dab needs none of that\n// machinery — it is a short oriented capsule (rounded line segment) whose half-width\n// tapers along its length (the loaded-head → dragged-tail comma). The capsule SDF is\n// derivative-free (smoothstep AA against the analytic distance), so no fwidth skirt, no\n// best-of-9 seam. Returns a StrokeHit (coverage/color/alongT/edgeN) for paintOver.\n// cellSize — dab cell pitch (UV units); lenMul/widMul — dab aspect off the cell;\n// density — placement gate (sparse → visible gaps); seed — layer decorrelation.\nStrokeHit vangoghDab(vec2 p, float cellSize, float lenMul, float widMul,\n float density, float jitterAmt, float angJitter,\n vec2 flow, float t, float seed) {\n vec2 cell = floor(p / cellSize);\n StrokeHit best = noHit();\n for (int dy = -1; dy <= 1; dy++) {\n for (int dx = -1; dx <= 1; dx++) {\n vec2 cc = cell + vec2(float(dx), float(dy));\n // Sparse density gate — leaves visible canvas ground between dabs (atomicity).\n if (hash21(cc * 1.7 + seed * 0.3) > density) continue;\n vec2 jit = (hash22(cc + seed) - 0.5) * jitterAmt;\n vec2 center = (cc + 0.5 + jit) * cellSize;\n\n // Orientation: the analytic swirl flow at the cell center + per-cell angular\n // jitter (so adjacent dabs FAN — the divisionist scatter that keeps the dabs from\n // locking into perfectly-concentric rows) + a flow-noise curl wobble.\n float ang = (hash21(cc + seed + 11.0) - 0.5) * angJitter;\n float curl = (fbm(center * 3.1 + seed * 1.9) - 0.5) * (0.18 + 0.3 * uFlowCurl);\n vec2 dir = rotateDir(safeDir(flow), ang + curl);\n\n // SHORT comma — len ≈ the cell pitch (a contained dab, not a tiling filament).\n float len = cellSize * lenMul * (0.82 + 0.30 * hash21(cc + seed + 23.0));\n float halfW = max(cellSize * widMul * (0.86 + 0.28 * hash21(cc + seed + 41.0)), 0.010);\n\n // Local dab frame: along = projection onto the dab axis (centred 0), perp = cross.\n vec2 rel = p - center;\n float along = dot(rel, dir);\n float perp = dot(rel, vec2(-dir.y, dir.x));\n // The comma TAPER: half-width peaks ~1/3 from the loaded head and drags to a fine\n // tail (the asymmetric crescent). u in [0,1] along the dab from head to tail.\n float halfLen = len * 0.5;\n float u = clamp((along + halfLen) / max(len, 1e-5), 0.0, 1.0);\n float head = smoothstep(0.0, 0.30, u); // rounded loaded head\n float tail = pow(clamp((1.0 - u) / 0.70, 0.0, 1.0), 1.3); // dragged thin tail\n float prof = clamp(min(head, tail) * 1.05, 0.0, 1.0);\n float wNow = halfW * prof;\n // A gentle comma CURVE — bow the spine sideways so the mark reads as a crescent.\n float bowAmt = (hash21(cc + seed + 53.0) - 0.5) * halfW * 1.4;\n float spine = bowAmt * sin(u * PI); // 0 at ends, max mid\n float d = abs(perp - spine);\n // Derivative-free AA: a fixed fraction of the dab width (no fwidth skirt). Coverage\n // is 1 in the dab body, smoothly 0 at the edge; outside the [head,tail] span wNow→0\n // so the dab self-terminates with no end-cap blob.\n float aa = max(halfW * 0.45, 0.002);\n float cov = (wNow > 1e-5) ? (1.0 - smoothstep(wNow - aa, wNow + aa, d)) : 0.0;\n if (cov < 0.004) continue;\n\n // One sampleBase per cell + OKLCh broken-color jitter (pigment patch shimmer). The\n // dab pigment is chroma-boosted (saturate3 1.22) AND value-lifted (×1.14) at the\n // SOURCE — the loaded brush mark deposits BRIGHTER + more saturated pigment than the\n // base field, so the loaded-mark pixels lift BOTH the §4.1 colourfulness AND the field\n // mean-luma. The higher mean raises the gap-fraction threshold (meanLum·0.6) so the\n // moderate-depth inter-dab ground falls below it (the gap-fraction atomicity read is\n // DECOUPLED from the ground floor depth — the ground can stay only moderately dark, so\n // the §4.3 slope is NOT over-steepened, while the bright dabs manufacture the gap). The\n // dark ground is untouched, so this lifts C + gap WITHOUT a band-conflicting deep ground.\n vec3 colMid = brokenColorJitter(\n saturate3(sampleBase(center, t), 1.22),\n hash21(cc + seed + 89.0),\n hash21(cc * 2.3 + seed + 97.0),\n 1.0\n );\n\n // edgeN: 1 at the spine, 0 at the edge (the impasto crown reads it).\n float edgeN = (wNow > 1e-5) ? clamp(1.0 - d / wNow, 0.0, 1.0) : 0.0;\n if (cov > best.coverage) {\n best = StrokeHit(cov, colMid, u, (wNow > 1e-5 ? (perp - spine) / wNow : 0.0), edgeN);\n }\n }\n }\n return best;\n}\n\nvec3 mediumVangogh(vec3 col, vec2 p, float t) {\n vec3 result = col;\n float height = 0.0;\n\n // The swirl flow basis (van-Gogh sky = swirl rows). Computed ONCE per pixel.\n vec2 flow = flowField(p, t);\n\n // Dab cell pitch in UV [0,1]. CHUNKY, SEPARABLE marks — the big layer is ~1/14 of\n // the frame so it reads as a distinct loaded brush dab (not a fine speckle, not a\n // screen-spanning filament). uStrokeScale (authored ~110) modulates the pitch\n // INVERSELY (higher = finer dabs) around the ~0.07 chunky default; clamped so the\n // dab never collapses to noise or balloons past one screen. uStrokeAnisotropy\n // stretches the comma aspect (longer, more directional marks).\n float pitch = clamp(7.0 / max(uStrokeScale, 20.0), 0.044, 0.12);\n // The dab LENGTH ≈ the cell pitch (lenAniso ~1.2-1.7) so a dab sits WITHIN its cell\n // and leaves visible ground around it — a longer dab (lenMul > 2) spans neighbour\n // cells and tiles the field into continuous coverage (no gaps, the gap-fraction floor\n // miss + the marble). Narrow width keeps it a directional crescent, not a wide shard.\n // lenAniso/widAniso — the comma aspect. The current profile lengthens\n // the comma (1.25-1.75 → 1.5-2.0) and THINNED it (0.40-0.30 → 0.32-0.24): the rebuilt\n // dabs measured §4.2 structure-tensor anisotropy A=0.699, BELOW the reference band\n // floor 0.732 (the dabs read slightly too short-fat → locally isotropic, dragging mean\n // A down). A LONGER, THINNER comma hugs the swirl-flow tangent more strongly so the\n // rendered field reads coherent the way the tensor metric measures it (A lift), while\n // the thinner width LEAVES MORE inter-dab ground (the gap-fraction atomicity read is\n // preserved, not closed). The length stays ≈ the cell pitch so each dab remains a\n // CONTAINED separable mark, not a tiling filament.\n float lenAniso = mix(2.1, 2.7, uStrokeAnisotropy); // comma length / cell pitch (a contained dab)\n float widAniso = mix(0.23, 0.16, uStrokeAnisotropy); // comma width / cell pitch (a thin loaded crescent)\n\n // Layer 1 — the big swirl-row dabs: the loaded gestural marks, SPARSE so the dark\n // underpainting shows BETWEEN them (the atomicity read — visible inter-dab ground).\n // hardness 0.74 — the loaded brush deposits with a SOFT shoulder, so adjacent dabs\n // feather instead of razor-clipping into hard polygon shards. jitterAmt 0.85 fully\n // scatters the cell centres so the placement GRID never reads as a periodic seam.\n // angJitter EASED 0.55 → 0.38 (the reconcile A lift): a tighter angular spread keeps\n // adjacent dabs more flow-aligned (coherent) while the per-cell curl wobble still\n // breaks the perfectly-concentric-rows read (the dabs FAN gently, not lock to a grid).\n // angJitter eased 0.38 → 0.26 + hardness 0.74 → 0.84 (the §4.2 A lift): a tighter angular\n // spread keeps adjacent dabs strongly flow-aligned (the structure-tensor coherence) and a\n // sharper edge gives each dab a STRONGER directional gradient (a soft dab's faint edge\n // reads weakly anisotropic). The per-cell curl wobble still breaks the perfectly-\n // concentric-rows read, so the dabs FAN gently rather than locking to a grid.\n StrokeHit dBig = vangoghDab(p, pitch, lenAniso, widAniso,\n 0.30, 0.50, 0.08, flow, t, 1.3);\n // streakFreq raised 14 → 34 (the §4.3 slope fix): a high-frequency streak runs ALONG the\n // dab spine, injecting fine-scale luma energy that flattens the too-steep β WITHOUT\n // adding new isotropic marks (the along-spine streak stays directional, so the §4.2\n // anisotropy the long-thin dab carries is preserved — the band-conflict resolution).\n paintOver(result, height, dBig, 48.0, 0.34,\n uImpasto * 0.75 * uStrokeAmount, 0.84, 1.3, 1.0 /* full crown */);\n\n // Layer 2 — two-thirds-pitch accent dabs (the divisionist sparkle between the big\n // marks — denser placement but still contained dabs, so dark canvas survives between).\n // angJitter eased 0.5 → 0.34 (same A-lift reasoning — the accent dabs queue along the\n // flow rather than scattering isotropically); hardness 0.78 → 0.86 sharpens the gradient.\n StrokeHit dSml = vangoghDab(p + vec2(-5.1, 8.4), pitch * 0.62, lenAniso * 0.95,\n widAniso * 0.95, 0.36, 0.60, 0.20, flow, t, 4.1);\n paintOver(result, height, dSml, 42.0, 0.22,\n uImpasto * 0.55 * uStrokeAmount, 0.86, 4.1, 1.0);\n\n // Layer 3 — fine divisionist flecks. The two-layer\n // field read as a few BIG cobalt dabs over a smooth empty teal ground (the side-by-side\n // against starry-night-crop.png: the painting is DENSE small varied flecks, not sparse\n // large marks). The flecks are LONG·THIN directional commas hugging the swirl tangent\n // (the A-preserving fleck — short fat flecks read isotropic and drag §4.2 down). Sparse\n // density 0.30 keeps the inter-fleck ground open (the gap-fraction atomicity read).\n // The flecks are FINE (≈0.42× pitch) directional commas, tightly flow-aligned (angJitter\n // 0.22) and SPARSE (0.30) — the divisionist sparkle between the loaded marks that keeps\n // the inter-dab ground open (atomicity) while adding the small-mark mid-band energy. Thin\n // + flow-aligned so the §4.2 anisotropy the long dabs carry survives the added small marks.\n StrokeHit dFleck = vangoghDab(p + vec2(8.7, -3.2), pitch * 0.42, lenAniso * 1.0,\n widAniso * 0.68, 0.30, 0.85, 0.22, flow, t, 7.7);\n paintOver(result, height, dFleck, 30.0, 0.16,\n uImpasto * 0.40 * uStrokeAmount, 0.80, 7.7, 1.0);\n\n // ── Flow-aligned ground swirl grooving ─────────────────────────\n // The bare ground between the dabs was a SMOOTH low-frequency teal gradient — the §4.3\n // power-spectrum slope ran too STEEP (β≈−2.0: too much low-frequency nuclei-field energy\n // vs the high band). Van Gogh's actual sky has the swirl BRUSHWORK everywhere, so groove\n // the OPEN GROUND with a flow-aligned ripple. It is SUBTRACTIVE-biased (it only darkens,\n // never brightens the ground), so it DEEPENS the inter-dab valleys (MORE gap-fraction —\n // atomicity preserved/strengthened) while injecting the across-flow mid-band luma energy\n // that flattens β. Gated to the open ground (low height) via the (1-height) gate so it\n // never lifts/erodes the loaded dab bodies (the dab read is untouched). Across the swirl\n // FLOW axis so the grooves run WITH the sky's brushwork direction.\n // The ground swirl-combing — a FIXED-global-angle directional grain on the open ground.\n // A flow-FOLLOWING comb varies its direction with the swirl across the readback window,\n // so its blurred structure tensor averages toward isotropic (no §4.2 lift). A comb at one\n // GLOBAL angle (van-Gogh's dominant diagonal stroke grain) is COHERENT over the whole\n // window ⇒ every open-ground pixel reads the SAME direction (the §4.2 mean-anisotropy lift\n // the swirl comb could not reach). Two resolved bands (≈22 + ≈44 across the global axis ⇒\n // ~21px + ~11px at 464px, both in the §4.3 fit window) also feed the β flatten. Gated to\n // the open ground (low height) so the loaded dabs are untouched; SUBTRACTIVE-biased so the\n // inter-dab valleys deepen (gap-fraction preserved, not filled).\n vec2 gdir = normalize(vec2(0.82, 0.57)); // the dominant global stroke grain axis\n float gacross = dot(p, vec2(-gdir.y, gdir.x));\n float groundGate = 1.0 - smoothstep(0.05, 0.28, height);\n float groove = sin(gacross * 22.0) + 0.5 * sin(gacross * 44.0 + 1.3);\n result *= 1.0 - 0.16 * groundGate * (0.5 - 0.5 * groove);\n\n // Canvas tooth (fine linen weave — base relief the raking light catches).\n float tooth1 = vnoise(p * 220.0);\n float tooth2 = vnoise(p * 220.0 * vec2(0.6, 2.4) + 37.0);\n float tooth = (0.6 * tooth1 + 0.4 * tooth2) - 0.5;\n result *= 1.0 + tooth * 0.06 * uCanvasGrain;\n\n // Relight the accumulated impasto height (raking light catches each dab's crown —\n // the visible impasto ridge that makes a dab read as a RAISED loaded mark).\n float canvasBase = tooth * 0.06 * 0.5;\n result = relightImpasto(result, height, canvasBase);\n\n // The visible Starry-Night GROUND — the open canvas between dabs (low accumulated\n // height) darkens toward the deep underpainting, so the bright impasto dabs read as\n // SEPARABLE atomic marks over a darker field (the dab↔ground contrast the user's\n // \"reads as strokes\" bar needs, AND the painterly-statistics gap-fraction floor — the\n // dark inter-dab ground must register as a measurable fraction of the field). 0.30\n // floor over a WIDER smoothstep (0..0.40): deep enough that the open gaps read as the\n // dark Starry-Night sky between marks (clearing the 4% gap floor) while the gradual\n // ramp keeps the gaps reading as flowing underpainting, not the hard black ink LINES a\n // narrow near-black step (0.26 / 0.0..0.32) produced.\n // The smoothstep FLOOR starts at 0.10 (not 0): a dab's faint AA coverage TAIL deposits\n // a sliver of height, and where many tails align along the swirl flow those slivers\n // accumulate into a faint continuous height ridge that read as thin curved LINES in the\n // ground. Holding the ground full-dark until a real dab CORE (height > 0.10) lifts out\n // keeps the open field clean — only the loaded dab bodies emerge, the tails stay ground.\n result *= mix(0.115, 1.0, smoothstep(0.085, 0.31, height));\n\n // The van-Gogh chroma — a light OKLCh punch at 0.92 in the\n // The discrete-dab profile's per-dab OKLCh\n // broken-color jitter (the ±16° hue + ±chroma swing per cell) lifts the field's\n // colourfulness on its own, so a 1.04 punch on TOP overshoots the\n // reference band (rendered C=100.5 vs the painting's measured 70.67 ± 15/+25 →\n // ceiling 95.67 — neon, not Starry Night's rich-but-not-garish blue/gold). The 0.92\n // demote pulls the rendered colourfulness back IN-band while the broken-color jitter\n // keeps the per-dab pigment variation (the discrete-stroke read is untouched — this\n // is a chroma scale, not a dab-geometry change). Band-anchored on the real painting\n // not a widened band.\n result = saturate3(result, 1.0);\n return result;\n}\n\n", ke = "StrokeProfile profileFor(int medium, int mode) {\n // The oil baseline (mode 0) — balanced modern-abstract/palette-knife hybrid.\n StrokeProfile prof = StrokeProfile(\n 0, // shapeType — tapered\n 0.25, // bristleAmp\n 9.0, // streakFreq\n 0.09, // streakAmp\n 0.9, // impastoAmp\n 0.80, // hardness\n 340.0, // toothScale — finer 240 → 340. Oil's β sat\n // right AT the −1.45 band ceiling (±0.02 frame variance straddling\n // it, surfaced once the vangogh bands went green and the spec reached\n // the oil β assert). MEASURED on the live GPU: ADDING fine high-\n // frequency tooth energy steepens oil's power-spectrum slope (more\n // negative — coarsening it the other way pushed β SHALLOWER to\n // −1.33). A finer, stronger tooth moves β to a safe distance inside\n // the −5/3 band [−1.85, −1.45]. Oil-only (oil-pastel sets 280).\n 0.14, // toothAmp — raised 0.09 → 0.14 (same oil-β steepen: more fine-grain high band).\n 1.03, // pigmentSat\n 0.65, // densityBig\n 0.78, // densityMed\n 0.90, // densitySml\n 0.0, // energyGrade — oil is uniform-length (no Starry-Night cascade)\n 0.4, // impastoFloor — oil's 0.4+0.6·edgeN crown falloff\n 0.92, // densityFill — oil fills DENSELY with the directional low-relief fill so the\n // flat-colour regions between the macro strokes are TEXTURED with\n // flow-aligned fine strokes (the §4.2 anisotropy needs every pixel\n // to carry directional gradient; a flat untextured region reads as\n // an isotropic/degenerate tensor and drags mean A down). The fill\n // is now directional + low-streak, so dense coverage textures\n // WITHOUT the round-dab speckle.\n 1.0 // groundFloor — oil keeps the full base (no ground darken; fills everywhere)\n );\n\n // The Van Gogh medium does NOT route through this oil\n // StrokeProfile cascade. It is a DEDICATED atomic-dab body (mediumVangogh / vangoghDab\n // below) — a profile-driven cascade (four dense layers of long-thin\n // tensor-oriented strokes) merges into the \"marbled flow-bands\" read and runs at ~4fps.\n // profileFor now serves ONLY the oil + oil-pastel stroke mediums; the MEDIUM_VANGOGH\n // case is removed (no caller). MEDIUM_VANGOGH stays #define'd (the main() dispatch +\n // isPainterlyStroke still key off uMedium==5).\n\n // ── Oil-pastel — broad smeared directional strokes deposited via the brush engine\n // Creamy soft edges (low hardness), heavy build-up, and a chroma punch.\n // Distinct from the dry-crayon tooth-multiply (mediumCrayon): oil-pastel LAYS strokes.\n if (medium == MEDIUM_OILPASTEL) {\n prof.shapeType = 0; // tapered directional smear — a round dab reads locally\n // isotropic (steep β / low A); the creamy oil-pastel mark\n // is a broad DIRECTIONAL smear, which carries the §4.2\n // coherence + adds the directional mid-band the §4.3 slope\n // needs (the round-dab profile rolled β off to −2.8)\n prof.bristleAmp = 0.10; // smooth creamy edges (waxy pastel, not bristle)\n prof.streakFreq = 18.0; // finer internal smear — adds the mid/high-band the smooth\n // round-dab profile lacked (the β-too-steep fix); the\n // directional along-spine streak flattens the §4.3 slope\n // without crossing the strokes\n prof.streakAmp = 0.20;\n prof.impastoAmp = 0.7; // build-up, but flatter than oil impasto\n prof.hardness = 0.42; // CREAMY — soft compositing, strokes blend on overlap\n prof.toothScale = 280.0;\n prof.toothAmp = 0.12; // the pastel tooth reads stronger\n prof.pigmentSat = 0.80; // the waxy chroma — kept low so the rendered C clears\n // the §4.1 band ceiling with margin while the K-M subtractive\n // overlap path (paintOverOklab) keeps the chroma OFF the grey floor\n prof.hardness = 0.58; // creamy but the strokes still REGISTER — a too-soft blend\n // (0.42) smeared the marks into the smooth colour zones and\n // the field rolled off too steep (β≈−2.9, a near-gradient);\n // a crisper deposit keeps the mid/high-band the −5/3 slope needs\n prof.densityBig = 0.62; // broad directional coverage — but NOT over-dense: too many\n // overlapping creamy strokes point in slightly-varied\n // directions and the local §4.2 coherence DROPS (over-dense\n // measured A=0.57 < the 0.62-density A=0.63). The mid-density\n // flow-aligned deposit is the coherence sweet spot.\n prof.densityMed = 0.78;\n prof.densitySml = 0.90;\n prof.energyGrade = 0.80; // a strong Starry-Night length cascade — varies stroke length\n // by luma/coherence so the dab-size energy spreads across\n // scales (the −5/3 cascade the uniform-length 0.0 grade lacked,\n // the §4.3 β-too-steep fix). Not the full van-Gogh 1.0 (oil-\n // pastel keeps its creamy broad character).\n prof.impastoFloor = 0.55; // a softer crown than van-Gogh's full-height glint\n return prof;\n }\n\n // ── Oil sub-modes (mode dispatch on the oil medium).\n if (mode == 1) { // palette knife — razor edges, heavy impasto\n prof.shapeType = 3; // flat, even\n prof.bristleAmp = 0.12;\n prof.streakFreq = 4.0; prof.streakAmp = 0.05;\n prof.impastoAmp = 1.6;\n prof.hardness = 0.95;\n prof.toothAmp = 0.04;\n prof.densityBig = 0.80; prof.densityMed = 0.88; prof.densitySml = 0.70;\n } else if (mode == 3) { // thick brushwork — heavy bristle brush\n prof.shapeType = 0; // tapered\n prof.bristleAmp = 0.32;\n prof.streakFreq = 14.0; prof.streakAmp = 0.14;\n prof.impastoAmp = 1.2;\n prof.hardness = 0.85;\n prof.toothAmp = 0.07;\n }\n return prof;\n}\n", Ae = "\n// ── Gradient pack ──────────────────────────────────\n// structureTensorField re-plumbs its already-computed luma gradient (Gx,Gy) out through\n// the vec4 return value's .w lane so the metal medium pays ZERO extra taps (a second Sobel is\n// 8 sampleBase() taps). 12 bits per bounded component ([-4,4]) into one f32, exact under\n// highp; the .xy/.z crayon/kuwahara callers are transparent to the widen.\nfloat packGrad(float gx, float gy) {\n float qx = floor(clamp(gx * 0.125 + 0.5, 0.0, 1.0) * 4095.0);\n float qy = floor(clamp(gy * 0.125 + 0.5, 0.0, 1.0) * 4095.0);\n return qx + qy * 4096.0;\n}\nvec2 unpackGrad(float packed) {\n float qy = floor(packed * (1.0 / 4096.0));\n float qx = packed - qy * 4096.0;\n return (vec2(qx, qy) * (1.0 / 4095.0) - 0.5) * 8.0;\n}\n", je = "#define MEDIUM_METAL 8\n#define MEDIUM_METALGRAD 9\n\n// ── Metal — two-term anisotropic BRDF over the field relief (uMedium==8/9) ──\n// Metal is a MUTUALLY-EXCLUSIVE medium (NOT a finish axis) — the field re-lights as\n// warm folded metal: the luma HEIGHT field (the packed structure-tensor gradient →\n// the surface normal) catches an anisotropic Blinn streak (brushed metal, the streak\n// runs ALONG the coherent edge-tangent) plus a sharp crest, both raked by a cursor-\n// synthesized light that reads on BOTH backends (uCursor is in-struct — a phantom\n// uLightDir read would be flat on the WGSL primary). The catch is the ACHROMATIC-WARM\n// anchor (AURORA_CATCH_LIGHT_ANCHOR ≈ [1.0,0.97,0.90], never a cold chrome-blue). The\n// body keeps the field HUE (technicolor valley base); the height rides the relief.\n// ZERO new taps — structureTensorField already computed the gradient (unpacked from .w).\nconst vec3 METAL_CATCH_WARM = vec3(1.0, 0.97, 0.90); // AURORA_CATCH_LIGHT_ANCHOR\nconst float METAL_HEIGHT_SCALE = 2.2; // gradient → normal tilt (× uMetalHeightScale)\nconst float METAL_LIGHT_Z = 0.55; // synth-light z (toward viewer)\nconst vec2 METAL_IDLE_RAKE = vec2(0.32, 0.34); // upper-right idle rake bias\nconst float METAL_SHININESS_ANISO = 6.0; // anisotropic streak exponent (brushed)\nconst float METAL_SHININESS_CREST = 40.0; // crest specular exponent (sharp)\nconst float METAL_COHERENCE_FLOOR = 0.22; // streak gates on edge coherence A\nconst float METAL_BODY_FLOOR = 0.42; // diffuse valley floor (dark side reads)\nconst float METAL_GRADIENT_FLATTEN = 0.55; // metal-gradient pre-flatten toward luma\nconst float METAL_SPARKLE_DENSITY = 240.0; // metal-gradient per-cell flake grid\nconst float METAL_SPARKLE_THRESH = 0.72; // only some cells flake\nconst float METAL_SPARKLE_AMP = 0.6; // flake glint amplitude\n\n// The shared metal BRDF core — takes the ALREADY-computed structureTensorField vec4 so\n// the caller pays ZERO extra taps (metal-gradient reuses the same stf). WebKit-fenced:\n// every pow base is clamped to [0,1], the exponents are compile-time constants.\nvec3 metalShade(vec3 baseCol, vec2 p, vec4 stf) {\n vec2 tangent = stf.xy;\n float A = stf.z;\n vec2 grad = unpackGrad(stf.w);\n // Height-field normal: N = normalize(vec3(grad * scale, 1)). The luma relief tilts\n // the surface; the flat field reads near vec3(0,0,1) (facing the viewer).\n vec3 N = normalize(vec3(grad * (METAL_HEIGHT_SCALE * uMetalHeightScale), 1.0));\n vec3 V = vec3(0.0, 0.0, 1.0);\n // Cursor-synthesized rake light (in-struct on BOTH backends — never uLightDir). The\n // idle bias keeps a still field lit from the upper-right; a moving cursor rakes it.\n vec3 L = normalize(vec3((uCursor - p) + METAL_IDLE_RAKE, METAL_LIGHT_Z));\n vec3 H = normalize(L + V);\n // Anisotropic streak — brushed metal: the highlight runs ALONG the edge-tangent, so\n // it is a function of the H-component PERPENDICULAR to the tangent (sinTH).\n float tH = dot(normalize(tangent), H.xy);\n float sinTH = sqrt(clamp(1.0 - tH * tH, 0.0, 1.0));\n float streak = pow(clamp(sinTH, 0.0, 1.0), METAL_SHININESS_ANISO);\n float crest = pow(clamp(dot(N, H), 0.0, 1.0), METAL_SHININESS_CREST);\n float spec = streak * crest;\n // Coherence gate — the anisotropic streak reads only where the field has a real edge\n // (a flat zone has no brush direction; A≈0 → no streak).\n spec *= smoothstep(0.0, METAL_COHERENCE_FLOOR, A);\n // Technicolor valley base — the body keeps the FIELD hue; the diffuse term rides the\n // height relief so the ridges brighten and the pits fall toward the floor.\n float diff = clamp(dot(N, L), 0.0, 1.0);\n vec3 body = baseCol * (METAL_BODY_FLOOR + (1.0 - METAL_BODY_FLOOR) * diff);\n // The catch is the achromatic-warm anchor, scaled by the polish knob.\n return body + METAL_CATCH_WARM * (spec * clamp(uMetalPolish, 0.0, 4.0));\n}\n\nvec3 mediumMetal(vec3 col, vec2 p, float t) {\n vec4 stf = structureTensorField(p, t, flowField(p, t));\n return metalShade(col, p, stf);\n}\n\n// metal-gradient (uMedium==9) — the SAME BRDF over a pre-flattened/gradient base + a\n// twinkle-in-place flake sparkle (position FIXED per cell, PHASE-animated, gated on\n// facing — flake glint, never a boil).\nvec3 mediumMetalGradient(vec3 col, vec2 p, float t) {\n vec4 stf = structureTensorField(p, t, flowField(p, t));\n // Pre-flatten toward luma (the smoother gradient-metallic base) — same BRDF, calmer body.\n // NB: flat is a GLSL reserved interpolation qualifier — WebKit's compiler REJECTS it as an\n // identifier (ANGLE tolerates it); named flatCol so the WebKit aurora shader compiles (L1a).\n vec3 flatCol = mix(col, vec3(dot(col, W_LUMA)), METAL_GRADIENT_FLATTEN);\n vec3 metal = metalShade(flatCol, p, stf);\n // The height-field normal facing (recomputed from the same packed gradient — ZERO taps).\n vec2 grad = unpackGrad(stf.w);\n float facing = normalize(vec3(grad * (METAL_HEIGHT_SCALE * uMetalHeightScale), 1.0)).z;\n // Twinkle-in-place: a fixed per-cell flake seed, phase-animated glint gated on facing.\n vec2 cell = floor(p * METAL_SPARKLE_DENSITY);\n float seed = hash21(cell);\n float tw = pow(clamp(sin(t + seed * 6.2831853), 0.0, 1.0), 40.0);\n float flakeGate = step(METAL_SPARKLE_THRESH, seed);\n metal += METAL_CATCH_WARM * (tw * flakeGate * clamp(facing, 0.0, 1.0) * METAL_SPARKLE_AMP);\n return metal;\n}\n", Me = "// ── Medium overlays ───────────────────────────────────────────────────────\n\n// A quick re-computation of base color for edge-mask sampling\nvec3 sampleBase(vec2 p, float t) {\n vec2 pw = domainWarp(p, t);\n float id; float vm;\n nucleiField(pw, t, id, vm);\n vec3 c = samplePalette(id);\n c *= 1.0 + uValueVariance * vm;\n return c;\n}\n" + Ae + "\n// ── Structure tensor / edge-tangent flow ───────────────────────────────────\n// The keystone of the painterly engine: derive stroke orientation from the COLOR\n// FIELD's OWN structure, not a hand-authored flow pattern. A 3x3 Sobel over\n// luma(sampleBase) yields the gradient (Gx,Gy); the 2x2 structure tensor\n// J = [[Gx², GxGy],[GxGy, Gy²]] eigen-decomposes closed-form into the MINOR\n// eigenvector (the edge-TANGENT — least color change, the stroke direction) + the\n// coherence A = (λ1-λ2)/(λ1+λ2); flat zones relax toward fallbackDir by (1-A). The\n// single-pass small-tap WebGL2 form. Returns vec4(tangent.xy, A, packGrad(Gx,Gy)) —\n// The .w lane carries the metal medium's gradient; the .xy/.z callers are unchanged.\nvec4 structureTensorField(vec2 p, float t, vec2 fallbackDir) {\n float e = 0.0035; // small-tap neighborhood (edge-mask scale)\n // 3x3 luma samples.\n float l00 = dot(sampleBase(p + vec2(-e, -e), t), W_LUMA);\n float l10 = dot(sampleBase(p + vec2( 0.0, -e), t), W_LUMA);\n float l20 = dot(sampleBase(p + vec2( e, -e), t), W_LUMA);\n float l01 = dot(sampleBase(p + vec2(-e, 0.0), t), W_LUMA);\n float l21 = dot(sampleBase(p + vec2( e, 0.0), t), W_LUMA);\n float l02 = dot(sampleBase(p + vec2(-e, e), t), W_LUMA);\n float l12 = dot(sampleBase(p + vec2( 0.0, e), t), W_LUMA);\n float l22 = dot(sampleBase(p + vec2( e, e), t), W_LUMA);\n // Sobel derivatives.\n float Gx = (l20 + 2.0 * l21 + l22) - (l00 + 2.0 * l01 + l02);\n float Gy = (l02 + 2.0 * l12 + l22) - (l00 + 2.0 * l10 + l20);\n // Structure tensor components.\n float Jxx = Gx * Gx;\n float Jyy = Gy * Gy;\n float Jxy = Gx * Gy;\n // Closed-form 2x2 eigenvalues: λ = 0.5(tr ± sqrt((Jxx-Jyy)² + 4Jxy²)).\n float tr = Jxx + Jyy;\n float disc = sqrt(max((Jxx - Jyy) * (Jxx - Jyy) + 4.0 * Jxy * Jxy, 0.0));\n float lambdaMaj = 0.5 * (tr + disc);\n float lambdaMin = 0.5 * (tr - disc);\n // The MAJOR eigenvector points along the gradient (the edge NORMAL); the MINOR\n // is its perpendicular — the edge TANGENT (the stroke direction). The principal\n // angle is θ = 0.5·atan2(2·Jxy, Jxx-Jyy); this form is robust at Jxy≈0 (where the\n // (λ-Jyy, Jxy) eigenvector formula collapses to a zero vector). The tangent is at\n // θ + 90°. Guard the fully-isotropic (no-gradient) degenerate case → fallback dir.\n vec2 tangent;\n if (disc < 1e-7) {\n tangent = fallbackDir;\n } else {\n float theta = 0.5 * atan(2.0 * Jxy, Jxx - Jyy); // major (gradient) angle\n tangent = vec2(-sin(theta), cos(theta)); // perpendicular = tangent\n }\n // Coherence A in [0,1] — high where one eigenvalue dominates (a strong edge),\n // ~0 in flat zones. Relax toward the smooth fallback by (1 - A).\n float A = (lambdaMaj - lambdaMin) / (lambdaMaj + lambdaMin + 1e-6);\n A = clamp(A, 0.0, 1.0);\n // Coherence-weighted blend: full tensor in coherent zones, smooth in flat ones.\n // Resolve the 180° sign ambiguity toward the fallback so the blend is continuous.\n if (dot(tangent, fallbackDir) < 0.0) tangent = -tangent;\n // The blend weight is a low-power curve (A^0.35) so even MODERATE-coherence zones queue\n // strongly along the tangent (a flowing van-Gogh band reads coherent the way the\n // structure-tensor metric measures it; a linear A under-orients the mid-band and the\n // rendered field reads too isotropic — the §4.2 anisotropy lift). The flat-zone (A≈0)\n // relax to the fallback survives (0^0.35=0), so tensor noise never reads as jitter.\n float blendW = pow(A, 0.28);\n vec2 dir = normalize(mix(fallbackDir, tangent, blendW) + 1e-6);\n return vec4(dir, A, packGrad(Gx, Gy));\n}\n\nvec3 mediumWatercolor(vec3 col, vec2 p, float t) {\n // Wet-edge cauliflowers via luma-gradient magnitude\n float eps = 0.004;\n vec3 cx1 = sampleBase(p + vec2(eps, 0.0), t);\n vec3 cx2 = sampleBase(p - vec2(eps, 0.0), t);\n vec3 cy1 = sampleBase(p + vec2(0.0, eps), t);\n vec3 cy2 = sampleBase(p - vec2(0.0, eps), t);\n float gx = dot(cx1 - cx2, W_LUMA);\n float gy = dot(cy1 - cy2, W_LUMA);\n float edge = sqrt(gx * gx + gy * gy) / (2.0 * eps);\n float mask = smoothstep(0.0, 2.5, edge);\n col *= mix(1.0, 0.78, mask * uWetEdge);\n\n // Granulation — pigment settles in paper tooth\n float paper = 0.5 * vnoise(p * 160.0) + 0.5 * vnoise(p * 360.0);\n float pigLoad = 1.0 - dot(col, W_LUMA);\n col *= 1.0 - uGranulation * pigLoad * (paper - 0.5);\n\n // Wash banding — faint horizontal wet gradient\n float band = fbm(vec2(p.x * 1.5, p.y * 0.4));\n col *= 1.0 + 0.04 * (band - 0.5);\n return col;\n}\n\nvec3 mediumPastel(vec3 col, vec2 p, float t) {\n vec2 flow = flowField(p, t);\n vec2 perp = vec2(-flow.y, flow.x);\n float along = dot(p, flow) * uStrokeScale;\n float across = dot(p, perp) * uStrokeScale;\n across += 0.03 * (vnoise(p * 260.0) - 0.5);\n\n float aniso = mix(1.0, 0.18, uStrokeAnisotropy);\n float stroke = fbm(vec2(along * aniso, across));\n col *= mix(1.0, 0.82 + 0.32 * stroke, uStrokeAmount);\n\n // Pastel tooth — tiny high-frequency grain\n float tooth = vnoise(p * 800.0);\n col *= 1.0 - 0.08 * uStrokeAmount * (tooth - 0.5);\n return col;\n}\n", Ne = "// ── Medium id constants (mirror uniformBridge.ts MEDIUM_ID — the uMedium ladder) ──\n// The StrokeProfile selector dispatches on the medium id: oil,\n// van-Gogh, and oil-pastel each AUTHOR a first-class profile in profileFor.\n#define MEDIUM_OIL 3\n#define MEDIUM_CRAYON 4\n#define MEDIUM_VANGOGH 5\n#define MEDIUM_OILPASTEL 6\n\n// ── Crayon — DRY wax pigment on paper tooth (first-class medium, uMedium==4) ──\n// Crayon is not strokes. It's dry pigment crumbs dragged across paper tooth — the\n// DRY tooth-multiply model: anisotropic tooth noise multiplied into the base, a hard\n// SCUMBLE that lets the lower color show through the broken upper layer, and stable\n// OKLCh broken-color pigment patches. NO sheen, NO burnish film — that waxy gloss is\n// the OIL-PASTEL deposition's signature (mediumOilPastel), distinct from dry crayon\n// split. Crayon shares the substrate (the structure-tensor\n// orientation, the tooth noise, OKLCh brokenColorJitter), not the dispatch body.\nvec3 mediumCrayon(vec3 col, vec2 p, float t) {\n // Orient the deposition along the structure-tensor edge-tangent (the bridge forces\n // tensor for crayon, so read the tensor field directly).\n vec2 flow = structureTensorField(p, t, flowField(p, t)).xy;\n float ang = atan(flow.y, flow.x);\n float ca = cos(-ang), sa = sin(-ang);\n vec2 pr = vec2(p.x * ca - p.y * sa, p.x * sa + p.y * ca);\n\n float aniso = mix(0.45, 0.95, uStrokeAnisotropy);\n float scale = max(uStrokeScale * 1.6, 180.0);\n\n // ── Paper TOOTH height field — the relief the dry pigment rides. Anisotropic\n // (squished along flow, coarse cross-flow). Peaks = ridges, valleys = paper pits.\n float t1 = vnoise(vec2(pr.x * scale * aniso, pr.y * scale));\n float t2 = vnoise(vec2(pr.x * scale * aniso * 0.4, pr.y * scale * 0.4) + 11.0);\n float t3 = vnoise(vec2(pr.x * scale * aniso * 2.1, pr.y * scale * 2.1) + 23.0);\n float tooth = 0.55 * t1 + 0.30 * t2 + 0.15 * t3;\n\n // ── DRY TOOTH-MULTIPLY — the crayon multiplies the tooth relief into the base\n // color (dark in the pits, bright on the ridges). The pressure (uStrokeAmount) sets\n // how hard the multiply bites. This is the DRY model — no pigment build-up, no sheen.\n float pressure = clamp(uStrokeAmount, 0.0, 1.0);\n float bite = mix(0.18, 0.46, pressure); // multiply strength\n vec3 result = col * (1.0 - bite * (0.5 - tooth));\n\n // ── HARD SCUMBLE — a broken upper layer that lets the lower color show through the\n // gaps. A coarse mask gates a HARD (high-contrast) dragged pass so the dry crayon\n // reads as broken pigment crumbs, not a smooth wash. Drag follows the tensor flow.\n float scumbleMask = smoothstep(0.42, 0.78, vnoise(vec2(pr.x * scale * 0.55, pr.y * scale * 0.22) + 7.0));\n float scumbleCoverage = scumbleMask * pressure * 0.7; // hard broken upper layer\n vec3 paper = col * mix(0.80, 0.94, pressure); // the paper showing through\n result = mix(paper, result, scumbleCoverage);\n\n // ── Broken-color pigment: stable wax/pigment patches in OKLCh, not flicker.\n vec2 pigmentCell = floor(pr * max(scale * 0.18, 32.0));\n float pigmentMask = smoothstep(0.28, 0.82, vnoise(pr * scale * 0.21 + 19.0));\n result = brokenColorJitter(\n result,\n hash21(pigmentCell + 17.0),\n hash21(pigmentCell * 2.1 + 31.0),\n 0.45 + 0.55 * pigmentMask\n );\n\n // Crayon is saturation-amplified (the wax chroma punch — but DRY, no sheen).\n result = saturate3(result, 1.08);\n\n return result;\n}\n\n// ── StrokeProfile — the oil-stroke parameter vector ────────────────────────\n// The SBR \"stroke = parameter vector\" canon (facet 11): the per-mode if-ladder knobs\n// become struct FIELDS — logic-as-DATA, not an imperative branch. profileFor(medium,\n// mode) populates the profile for a (medium, mode) pair; paintStrokeLayers(profile) runs\n// the four-layer bestOil/paintOver cascade off it. A new medium, such as van-Gogh or\n// oil-pastel, authors a profile entry; it never edits a monolith.\nstruct StrokeProfile {\n int shapeType; // 0 tapered, 1 load-drag, 2 dab, 3 even, 4 comma/crescent\n float bristleAmp; // edge raggedness 0..0.5\n float streakFreq; // internal-streak spatial frequency\n float streakAmp; // internal-streak amplitude\n float impastoAmp; // paint-thickness contribution (the relight reads the height)\n float hardness; // edge-compositing crispness 0..1\n float toothScale; // canvas-tooth (linen weave) spatial frequency\n float toothAmp; // canvas-tooth amplitude\n float pigmentSat; // pigment saturation boost (OKLCh chroma scale)\n float densityBig; // layer-1 (big gestural) placement density gate\n float densityMed; // layer-2 (medium body) placement density gate\n float densitySml; // layer-3 (small dabs) placement density gate\n float energyGrade; // SBR energy-grade magnitude (0 off; 1 the van-Gogh\n // Starry-Night length cascade). The energy grade is a PROFILE\n // field, NOT a buried uMedium==5 bestOil branch.\n float impastoFloor;// Per-stroke height-crown floor (0.4 oil falloff;\n // 1.0 van-Gogh FULL-height crown so each dab catches its glint).\n float densityFill; // Layer-4 fill-dab density. Oil/oil-pastel fill the\n // bald spots (0.95, full coverage); van-Gogh sets it LOW so the\n // sparse atomic dabs keep their visible inter-stroke ground gaps\n // (the atomicity read — a 0.95 fill would close every gap to a smear).\n float groundFloor; // Bare-ground darken floor. The gaps between strokes\n // (low accumulated height) multiply toward this floor, so van-Gogh's\n // sparse atomic dabs read over a visibly darker underpainting (the\n // Starry-Night visible ground). Oil/oil-pastel keep 1.0 (no darken).\n};\n\n// The (medium, mode) -> StrokeProfile selector. The if-ladder's knobs are the profile's\n// fields; a new medium adds a CASE here (never an edit to a dispatch body). mode is the\n// uStrokeMode oil-stroke sub-mode (0 oil, 1 palette-knife, 3 brushwork). crayon\n// (uMedium==4) is a PEER tooth-multiply medium that never reaches the stroke cascade.\n// The painterly STROKE mediums are oil (MEDIUM_OIL), van-Gogh (MEDIUM_VANGOGH) and\n// oil-pastel (MEDIUM_OILPASTEL) — each AUTHORS its own profile entry below.\n" + ke + "\n// The single parameterized four-layer stroke cascade. The four hand-unrolled\n// bestOil/paintOver invocations collapse into ONE body driven by the profile + the\n// uniform-derived per-layer scale/anisotropy multipliers (which are mode-INVARIANT — the\n// per-layer offsets, seeds, and len/wid muls are fixed across modes, so they stay here as\n// the cascade's structure; only the profile's knobs differentiate the medium). The\n// mode passes through for the two mode-special-cased shapes (knife layer-3 dabs +\n// layer-4 fill shape), which are placement details of the cascade, not profile knobs.\nvoid paintStrokeLayers(inout vec3 col, inout float height, StrokeProfile prof,\n int mode, vec2 p, float t) {\n // Scales & multipliers from uniforms (mode-invariant cascade structure).\n float baseScale = max(uStrokeScale * 0.006, 0.008);\n // Three primary layers: big gestural, medium body, small dabs.\n // The −5/3 radii respacing was measured and reverted, not\n // silently struck). The φ-adjacent geometric candidate (2.4, 1.45, 0.87, a fixed\n // ≈1.66× step) moved oil-pastel β −2.534 → −2.413 — TOWARD the −5/3 band but NOT into\n // it (floor −1.85), so the keep-iff-into-band gate failed. The single-pass WebGL2 path\n // is the true limiter (HC-aurora §5): the oil-pastel β + the oil/oil-pastel anisotropy\n // residual stays the oil/oil-pastel stroke-cascade ceiling. The soft\n // anisotropic-Kuwahara finish therefore remains the opt-in mediumKuwahara() body\n // (uMedium==7) the consumer selects — NOT a re-tune of these oil/oil-pastel knobs. The\n // hand-set 2.4, 1.1, 0.45 stays — it is van-Gogh's landed-band spacing.\n float sBig = baseScale * 2.4;\n float sMed = baseScale * 1.1;\n float sSml = baseScale * 0.45;\n\n // Strokes are elongated HARD (long·thin) so the rendered field reads strongly\n // directional — the §4.2 structure-tensor anisotropy lift. A short fat dab is locally\n // isotropic and drags the measured A down; a long thin stroke that hugs the tensor\n // tangent is what gives Starry Night its A≈0.83. The width muls are pulled tighter to\n // keep the long·thin aspect.\n float lenMulBig = mix(3.0, 5.2, uStrokeAnisotropy);\n float widMulBig = mix(0.42, 0.22, uStrokeAnisotropy);\n float lenMulMed = mix(2.8, 4.8, uStrokeAnisotropy);\n float widMulMed = mix(0.40, 0.21, uStrokeAnisotropy);\n float lenMulSml = mix(2.2, 3.6, uStrokeAnisotropy);\n float widMulSml = mix(0.36, 0.23, uStrokeAnisotropy);\n\n float jitterAmt = 0.75; // large jitter — no grid\n vec2 flow = flowField(p, t);\n\n // Layer 1 — big gestural strokes (sparse, shaping)\n StrokeHit hBig = bestOil(p, sBig, lenMulBig, widMulBig, jitterAmt * 0.55,\n prof.densityBig, prof.shapeType, prof.bristleAmp, flow, t, 1.3,\n prof.energyGrade);\n paintOver(col, height, hBig, prof.streakFreq * 0.7, prof.streakAmp,\n uImpasto * prof.impastoAmp * uStrokeAmount, prof.hardness, 1.3, prof.impastoFloor);\n\n // Layer 2 — medium body strokes\n StrokeHit hMed = bestOil(p + vec2(11.3, 3.7), sMed, lenMulMed, widMulMed,\n jitterAmt, prof.densityMed, prof.shapeType, prof.bristleAmp, flow, t, 2.7,\n prof.energyGrade);\n paintOver(col, height, hMed, prof.streakFreq, prof.streakAmp,\n uImpasto * prof.impastoAmp * uStrokeAmount, prof.hardness, 2.7, prof.impastoFloor);\n\n // Layer 3 — small strokes (more frequent, smaller). Even the knife layer-3 stays the\n // medium's DIRECTIONAL shape, not a round dab — the round-dab sparkle was a fine-scale\n // isotropic speckle that dragged the §4.2 anisotropy down + rolled the §4.3 slope shallow.\n int smlShape = prof.shapeType;\n StrokeHit hSml = bestOil(p + vec2(-5.1, 8.4), sSml, lenMulSml, widMulSml,\n jitterAmt * 0.9, prof.densitySml, smlShape,\n prof.bristleAmp * 0.85, flow, t, 4.1, prof.energyGrade);\n paintOver(col, height, hSml, prof.streakFreq * 1.4, prof.streakAmp * 0.6,\n uImpasto * prof.impastoAmp * 0.45 * uStrokeAmount, prof.hardness, 4.1, prof.impastoFloor);\n\n // Layer 4 — fill strokes (dense, fine) — cover bald spots. The density is\n // PROFILE-driven (prof.densityFill): oil/oil-pastel fill to full coverage; van-Gogh\n // keeps it sparse so the bare-ground gaps between its atomic dabs survive. The fill is\n // ELONGATED + flow-oriented (NOT a round dab) — a dense round-dab fill is locally\n // isotropic and was the dominant §4.2 anisotropy sink; an oriented fine stroke keeps the\n // fill directional so the whole field reads coherent.\n float sFill = baseScale * 0.22;\n float lenMulFill = mix(2.0, 3.2, uStrokeAnisotropy);\n float widMulFill = mix(0.34, 0.24, uStrokeAnisotropy);\n int fillShape = (mode == 1) ? 3 : prof.shapeType; // knife=even; others inherit the medium's directional shape\n StrokeHit hFill = bestOil(p + vec2(3.9, -6.2), sFill, lenMulFill, widMulFill,\n jitterAmt * 0.8, prof.densityFill, fillShape,\n prof.bristleAmp * 0.6, flow, t, 8.9, prof.energyGrade);\n // The fill is a low-relief, low-streak base coat — it covers bald spots WITHOUT adding\n // fine bright speckle (a high-impasto/high-streak fill caught a per-dab glint that read\n // as isotropic noise over the directional macro strokes — the §4.2/§4.3 sink). Its\n // positional jitter is tamed too so the fill strokes stay flow-aligned, not scattered.\n paintOver(col, height, hFill, prof.streakFreq * 1.2, prof.streakAmp * 0.35,\n uImpasto * prof.impastoAmp * 0.18 * uStrokeAmount, prof.hardness * 0.9, 8.9, prof.impastoFloor);\n\n // Optional crosshatch layer\n if (uStrokeLayers == 2) {\n vec2 flow2 = vec2(-flow.y, flow.x);\n StrokeHit hX = bestOil(p + vec2(7.3, -2.1), sMed, lenMulMed * 0.9, widMulMed,\n jitterAmt, prof.densityMed * 0.7, prof.shapeType, prof.bristleAmp, flow2, t, 6.5,\n prof.energyGrade);\n paintOver(col, height, hX, prof.streakFreq, prof.streakAmp * 0.85,\n uImpasto * prof.impastoAmp * 0.55 * uStrokeAmount, prof.hardness, 6.5, prof.impastoFloor);\n }\n}\n\n// The shared stroke-medium substrate finish paints the four-layer\n// cascade off the profile, then canvas-tooth + relight + saturation. The three painterly\n// STROKE mediums (oil, van-Gogh, oil-pastel) each AUTHOR their own profile and call\n// this — the substrate is shared, the PROFILE (not a dispatch-body fork) differentiates\n// the medium. mode passes through for the cascade's mode-special-cased shapes.\nvec3 paintStrokeMedium(vec3 col, vec2 p, float t, StrokeProfile prof, int mode) {\n vec3 result = col;\n // Accumulated paint height across the stroke layers. The relight reads\n // its gradient for the normal; the canvas tooth seeds the base relief.\n float height = 0.0;\n paintStrokeLayers(result, height, prof, mode, p, t);\n\n // Canvas tooth — linen weave\n float tooth1 = vnoise(p * prof.toothScale);\n float tooth2 = vnoise(p * prof.toothScale * vec2(0.6, 2.4) + 37.0);\n float tooth = (0.6 * tooth1 + 0.4 * tooth2) - 0.5;\n result *= 1.0 + tooth * prof.toothAmp * uCanvasGrain;\n\n // Relight the accumulated paint height with the movable uLightDir\n // source (diffuse + Blinn specular, in LINEAR before aces()). The canvas tooth\n // is the base relief term so the weave also catches the raking light.\n float canvasBase = tooth * prof.toothAmp * 0.5;\n result = relightImpasto(result, height, canvasBase);\n\n // Preserve visible ground. The bare-ground gaps (low accumulated stroke height)\n // multiply toward prof.groundFloor, so van-Gogh's sparse atomic dabs read as separable\n // marks over a darker underpainting (oil/oil-pastel keep groundFloor=1.0 → no-op). The\n // smoothstep keeps the impasto dabs (high height) at full value; only the open ground\n // between them darkens.\n result *= mix(prof.groundFloor, 1.0, smoothstep(0.0, 0.38, height));\n\n // Pigment saturation boost\n result = saturate3(result, prof.pigmentSat);\n\n return result;\n}\n\nvec3 mediumOil(vec3 col, vec2 p, float t) {\n // The oil medium is a thin body: fetch the oil profile (mode-dispatched), paint via\n // the shared stroke substrate. uStrokeMode: 0 oil (gestural), 1 knife, 3 brushwork.\n int mode = uStrokeMode;\n StrokeProfile prof = profileFor(MEDIUM_OIL, mode);\n return paintStrokeMedium(col, p, t, prof, mode);\n}\n\n#define MEDIUM_KUWAHARA 7\n\n// ── Kuwahara — anisotropic generalized painterly finish (uMedium==7) ───────\n// The SOTA edge-preserving painterly smoothing: the generalized/anisotropic Kuwahara of\n// Kyprianidis 2010, the SOFT polynomial-weighted variant (NOT the pre-2010 hard argmin,\n// which BANDS the flat field into an 8-spoke pinwheel — the §4.2 anti-regression). Aurora\n// is a PROCEDURAL field (no input texture), so the operator runs over sampleBase() directly:\n// an elliptical kernel oriented along the structure tensor (elongated along the edge-tangent,\n// narrowed by the anisotropy), divided into 8 overlapping sectors via smooth weights; the\n// output is the variance-weighted blend of the sector means (1/(1+var^q) — low-variance\n// sectors dominate, the SOFT criterion → flat oil-paint patches with crisp zone boundaries).\n// Single-pass small-radius WebGL2 form: 4 rings × 8 angular taps = 32 procedural samples\n// (cost-bounded; the offscreen-park, PRM freeze the substrate owns is untouched).\nvec3 mediumKuwahara(vec3 col, vec2 p, float t) {\n // Orient the kernel along the structure-tensor edge-tangent + read the coherence A\n // (the field widened vec3→vec4 for metal's gradient; Kuwahara reads only .xy/.z).\n vec4 stf = structureTensorField(p, t, flowField(p, t));\n vec2 tangent = stf.xy;\n float A = stf.z;\n // The ellipse axes: major along the tangent, minor across. Anisotropy squeezes the\n // minor axis (coherent zones → long-thin patch along the colour band; flat zones →\n // near-circular so the operator degrades gracefully to the isotropic Kuwahara). The\n // base radius rides uStrokeScale so the painterly patch size tracks the studio knob.\n float radius = clamp(0.010 + uStrokeScale * 0.00018, 0.006, 0.024);\n float aniso = mix(1.0, 0.34, clamp(A, 0.0, 1.0)); // minor/major axis ratio\n vec2 ax = tangent; // major-axis unit vector (edge-tangent)\n vec2 ay = vec2(-tangent.y, tangent.x); // minor-axis unit vector (edge-normal)\n\n // 8 sectors, soft polynomial weights. Each sector i centers on angle i·45°; a sample's\n // sector weight is a smooth gaussian-of-angular-distance so sectors OVERLAP (no hard\n // argmin → no pinwheel banding). The center sample seeds all sectors equally.\n const int SECTORS = 8;\n vec3 m[8]; // per-sector weighted colour sum\n vec3 s[8]; // per-sector weighted colour² sum (for variance)\n float w[8]; // per-sector weight sum\n for (int i = 0; i < SECTORS; i++) { m[i] = vec3(0.0); s[i] = vec3(0.0); w[i] = 0.0; }\n\n // 4 rings × 8 angular taps over the elliptical disc. Each tap: sample the procedural\n // field, then deposit into the sectors by the soft angular weight × the radial falloff.\n const int RINGS = 4;\n const int TAPS = 8;\n for (int r = 1; r <= RINGS; r++) {\n float rr = float(r) / float(RINGS); // 0.25 .. 1.0\n float radial = 1.0 - 0.6 * rr; // inner taps weigh more (gaussian-ish)\n for (int a = 0; a < TAPS; a++) {\n float ang = 6.2831853 * float(a) / float(TAPS);\n // Elliptical offset: major axis full radius, minor axis squeezed by aniso.\n vec2 dirE = ax * cos(ang) + ay * (sin(ang) * aniso);\n vec2 off = dirE * (radius * rr);\n vec3 c = sampleBase(p + off, t);\n // The sample's angular bin (its sector) — soft, so it spills into neighbours.\n for (int k = 0; k < SECTORS; k++) {\n float sectorAng = 6.2831853 * float(k) / float(SECTORS);\n // Smallest signed angular distance to the sector center.\n float d = ang - sectorAng;\n d = atan(sin(d), cos(d)); // wrap to [-π, π]\n float sw = exp(-d * d * 2.2) * radial; // gaussian angular weight × radial\n m[k] += c * sw;\n s[k] += c * c * sw;\n w[k] += sw;\n }\n }\n }\n\n // Per-sector mean + scalar luma-variance, then the SOFT variance-weighted blend.\n vec3 accum = vec3(0.0);\n float accumW = 0.0;\n for (int k = 0; k < SECTORS; k++) {\n float wk = max(w[k], 1e-4);\n vec3 mean = m[k] / wk;\n vec3 var3 = max(s[k] / wk - mean * mean, vec3(0.0));\n float variance = dot(var3, W_LUMA); // perceptual scalar variance\n // SOFT criterion: low-variance sectors (flat, inside a colour zone) dominate; a\n // high-variance sector (straddling an edge) is suppressed. q controls the sharpness;\n // a finite q (not argmin) keeps the blend continuous → no pinwheel spoke.\n float sectorW = 1.0 / (1.0 + pow(variance * 320.0, 4.0));\n accum += mean * sectorW;\n accumW += sectorW;\n }\n vec3 result = accum / max(accumW, 1e-4);\n\n // The center sample anchors the result in near-flat zones (where every sector reads the\n // same colour) so the operator is a no-op there — the smoothing only BITES at edges.\n vec3 center = sampleBase(p, t);\n result = mix(center, result, clamp(0.35 + 0.65 * A, 0.0, 1.0));\n\n // A faint canvas tooth + pigment-saturation lift so the flattened patches read as\n // oil-paint, not a posterized blur (the painterly identity the smoothing alone lacks).\n float tooth = vnoise(p * 300.0) - 0.5;\n result *= 1.0 + tooth * 0.06 * uCanvasGrain;\n result = saturate3(result, 1.04);\n\n // Blend toward the incoming col by uStrokeAmount so the studio amount knob controls\n // the finish strength (uStrokeAmount=0 → the raw field passes through; default → full).\n return mix(col, result, clamp(uStrokeAmount, 0.0, 1.0));\n}\n\n" + je + Oe + "// The oil-pastel medium (uMedium==6) is a distinct stroke-deposition body,\n// separate from the dry-crayon tooth-multiply (mediumCrayon). It DEPOSITS\n// broad smeared directional strokes via the same brush engine with a creamy soft\n// hardness, heavy pigment build-up where strokes overlap, and a chroma punch — the\n// stroke-deposition model that gives oil-pastel its depth and less-uniform read.\n// Shares the SUBSTRATE (the stroke cascade + tooth + relight) with oil/van-Gogh, NOT\n// the dispatch body of dry crayon. The bridge forces tensor orientation.\nvec3 mediumOilPastel(vec3 col, vec2 p, float t) {\n StrokeProfile prof = profileFor(MEDIUM_OILPASTEL, 0);\n return paintStrokeMedium(col, p, t, prof, 0);\n}", I = "\n", Pe = `#version 300 es
|
|
122
|
-
precision highp float;
|
|
123
|
-
|
|
124
|
-
in vec2 vUv;
|
|
125
|
-
out vec4 fragColor;
|
|
126
|
-
|
|
127
|
-
#define MAX_NUCLEI 8
|
|
128
|
-
#define MAX_STOPS 8
|
|
129
|
-
|
|
130
|
-
// ── Uniforms ───────────────────────────────────────────────────────────────
|
|
131
|
-
uniform float uTime;
|
|
132
|
-
|
|
133
|
-
// Palette baked CPU-side to linear-sRGB
|
|
134
|
-
uniform vec3 uPalette[MAX_STOPS];
|
|
135
|
-
uniform int uStopCount;
|
|
136
|
-
|
|
137
|
-
// Nuclei (parallel arrays)
|
|
138
|
-
uniform int uNucleiCount;
|
|
139
|
-
uniform vec2 uNucleiPos[MAX_NUCLEI];
|
|
140
|
-
uniform float uNucleiRadius[MAX_NUCLEI];
|
|
141
|
-
uniform float uNucleiPaletteBias[MAX_NUCLEI];
|
|
142
|
-
uniform float uNucleiValueBias[MAX_NUCLEI];
|
|
143
|
-
uniform float uNucleiDriftRadius[MAX_NUCLEI];
|
|
144
|
-
uniform float uNucleiDriftPhase[MAX_NUCLEI];
|
|
145
|
-
// Anisotropy: per-nucleus elongation (1.0 = isotropic) and major-axis angle (radians).
|
|
146
|
-
// Defaults (1.0, 0.0) reduce to the original circular Gaussian.
|
|
147
|
-
uniform float uNucleiElong[MAX_NUCLEI];
|
|
148
|
-
uniform float uNucleiAngle[MAX_NUCLEI];
|
|
149
|
-
uniform float uSoftmaxBeta;
|
|
150
|
-
uniform float uValueVariance;
|
|
151
|
-
|
|
152
|
-
// Warp
|
|
153
|
-
uniform float uWarpAmount;
|
|
154
|
-
uniform float uWarpScale;
|
|
155
|
-
uniform float uWarpDrift;
|
|
156
|
-
uniform int uWarpMode; // 0=fbm 1=cellular 2=hybrid 3=curl (opt-in Bridson flow warp)
|
|
157
|
-
uniform int uNoiseOctaves;
|
|
158
|
-
|
|
159
|
-
// Medium
|
|
160
|
-
// 0 smooth, 1 pastel, 2 watercolor, 3 oil, 4 crayon (peer medium — wax pigment
|
|
161
|
-
// on paper tooth; NOT an oil-stroke sub-mode, so it dispatches at main() level).
|
|
162
|
-
uniform int uMedium;
|
|
163
|
-
// Hue-arc method for OKLCh palette interpolation. Mirrors value.js's
|
|
164
|
-
// HueInterpolationMethod: 0 shorter, 1 longer, 2 increasing, 3 decreasing. Only
|
|
165
|
-
// consulted when the hue-arc path is requested; OKLab-rectangular ramps (the
|
|
166
|
-
// default for adjacent-hue stops) ignore it.
|
|
167
|
-
uniform int uHuePath;
|
|
168
|
-
uniform int uFlowPattern; // 0 none, 1 radial, 2 swirl, 3 diagonal, 4 multi, 5 tensor/ETF
|
|
169
|
-
uniform vec2 uFlowFocal;
|
|
170
|
-
uniform float uFlowAngle;
|
|
171
|
-
uniform float uFlowCurl;
|
|
172
|
-
uniform vec2 uCursor; // in 0..1 screen space (matches pN)
|
|
173
|
-
uniform float uCursorStrength; // 0..1 attraction amount
|
|
174
|
-
uniform float uCursorRadius; // radius of influence (0.05..0.5)
|
|
175
|
-
uniform float uStrokeAmount;
|
|
176
|
-
uniform float uStrokeScale;
|
|
177
|
-
uniform float uStrokeAnisotropy;
|
|
178
|
-
uniform int uStrokeLayers; // 1 or 2 (crosshatch)
|
|
179
|
-
uniform int uStrokeMode; // 0 oil (modern gestural), 1 palette-knife, 3 modern-chunky (crayon is uMedium==4, a peer medium)
|
|
180
|
-
// Stroke-orientation source: 0 flow (hand-authored flowField), 1
|
|
181
|
-
// tensor (the structure-tensor minor eigenvector — the color field's edge-tangent).
|
|
182
|
-
uniform int uStrokeOrient;
|
|
183
|
-
uniform float uWetEdge;
|
|
184
|
-
uniform float uGranulation;
|
|
185
|
-
uniform float uImpasto;
|
|
186
|
-
uniform float uBrokenColor;
|
|
187
|
-
uniform float uCanvasGrain;
|
|
188
|
-
|
|
189
|
-
// Metal-medium knobs (uMedium==8/9). uMetalPolish scales
|
|
190
|
-
// the specular catch intensity; uMetalHeightScale scales the luma-relief → normal tilt.
|
|
191
|
-
// On the WGSL primary these ride the free cursor.z/.w pad lanes (uniformBridgeWGPU); the
|
|
192
|
-
// The fragment shader carries them as uniforms. Non-metal configs write 0.
|
|
193
|
-
uniform float uMetalPolish;
|
|
194
|
-
uniform float uMetalHeightScale;
|
|
195
|
-
|
|
196
|
-
// The impasto relight axis is a movable directional source lighting the
|
|
197
|
-
// accumulated paint-height field (diffuse + Blinn specular, in LINEAR before aces()).
|
|
198
|
-
// The cursor drives uLightDir; the upper-left default supplies the still pose.
|
|
199
|
-
uniform vec3 uLightDir; // unit direction (x,y in screen space, z toward viewer)
|
|
200
|
-
uniform vec3 uLightColor; // warm-white tint (linear)
|
|
201
|
-
|
|
202
|
-
// Motion
|
|
203
|
-
uniform float uNucleiDrift;
|
|
204
|
-
uniform float uPaletteDrift;
|
|
205
|
-
uniform float uBreathDepth;
|
|
206
|
-
uniform float uBreathPeriod;
|
|
207
|
-
|
|
208
|
-
// Output
|
|
209
|
-
uniform float uSaturation;
|
|
210
|
-
uniform float uPaperGrain;
|
|
211
|
-
uniform float uAlpha;
|
|
212
|
-
|
|
213
|
-
// Chroma-floor strength (0 = off,
|
|
214
|
-
// 1 = the vivid default). The shader lifts any pale zone's OKLab chroma toward
|
|
215
|
-
// uVividness * VIVID_TARGET, hue-preserving, warm-anchored below the near-gray epsilon.
|
|
216
|
-
uniform float uVividness;
|
|
217
|
-
|
|
218
|
-
// ── Time rate ────────────────────────────────────────────────────────────────
|
|
219
|
-
// The authoring coefficients (uNucleiDrift, uPaletteDrift, uWarpDrift) live in a
|
|
220
|
-
// human-friendly 0..~0.05 band — that scale is what the config schema and every
|
|
221
|
-
// demo preset are tuned against. But that band, multiplied straight into uTime
|
|
222
|
-
// (seconds), yields rad/sec rates so small the field reads visually static (one
|
|
223
|
-
// nuclei orbit would otherwise take minutes). These K_* constants decouple
|
|
224
|
-
// the AUTHORING scale from the RAD/SEC scale: each time term wraps its coefficient
|
|
225
|
-
// in the matching K_, lifting the same authored value to a perceptible period
|
|
226
|
-
// without touching any preset. Tuned so the field reads SLOWLY ALIVE — drift over
|
|
227
|
-
// a ~5–15s window, never a frantic pan. These are downstream of uTime, which the
|
|
228
|
-
// runtime FREEZES under reduced-motion (t = frozenOffset) before the shader sees
|
|
229
|
-
// it, so the lift cannot leak motion into the reduced-motion path.
|
|
230
|
-
const float K_NUCLEI = 14.0; // nuclei orbit: ~one cycle per ~45s at default 0.01
|
|
231
|
-
const float K_PAL = 24.0; // palette hue breathe: ~one cycle per ~33s at default
|
|
232
|
-
const float K_WARP = 5.0; // domain warp scroll: a perceptible fbm-cell traverse
|
|
233
|
-
|
|
234
|
-
// ── Noise ──────────────────────────────────────────────────────────────────
|
|
235
|
-
float hash21(vec2 p) {
|
|
236
|
-
p = fract(p * vec2(123.34, 456.21));
|
|
237
|
-
p += dot(p, p + 45.32);
|
|
238
|
-
return fract(p.x * p.y);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
vec2 hash22(vec2 p) {
|
|
242
|
-
p = vec2(dot(p, vec2(127.1, 311.7)),
|
|
243
|
-
dot(p, vec2(269.5, 183.3)));
|
|
244
|
-
return fract(sin(p) * 43758.5453);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
float vnoise(vec2 p) {
|
|
248
|
-
vec2 i = floor(p);
|
|
249
|
-
vec2 f = fract(p);
|
|
250
|
-
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
251
|
-
float a = hash21(i);
|
|
252
|
-
float b = hash21(i + vec2(1.0, 0.0));
|
|
253
|
-
float c = hash21(i + vec2(0.0, 1.0));
|
|
254
|
-
float d = hash21(i + vec2(1.0, 1.0));
|
|
255
|
-
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// The rotated-octave FBM rotation constant is spliced from the shared chunk
|
|
259
|
-
// as the sole FBM_ROT. The loop below stays aurora-local (2.02 lacunarity +
|
|
260
|
-
// uniform-driven octaves, per §3a — only the rotation constant converges).
|
|
261
|
-
${x}
|
|
262
|
-
|
|
263
|
-
float fbm(vec2 p) {
|
|
264
|
-
float v = 0.0;
|
|
265
|
-
float a = 0.5;
|
|
266
|
-
for (int i = 0; i < 5; i++) {
|
|
267
|
-
if (i >= uNoiseOctaves) break;
|
|
268
|
-
v += a * vnoise(p);
|
|
269
|
-
p = FBM_ROT * p * 2.02;
|
|
270
|
-
a *= 0.5;
|
|
271
|
-
}
|
|
272
|
-
return v;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// The shared curl-noise flow chunk (curlFBM) is spliced from the single source
|
|
276
|
-
// procedural surfaces share (the shared-chunk precedent, applied to FLOW). The
|
|
277
|
-
// chunk owns ONLY the basis-agnostic curl operator; the host owns the noise basis —
|
|
278
|
-
// aurora wraps its OWN fbm as the scalar potential (so curl rides the same 2.02-
|
|
279
|
-
// lacunarity loop the rest of the warp uses). The curl operator is consumed ONLY on
|
|
280
|
-
// the OPT-IN warpMode == "curl" branch (uWarpMode == 3) — the default warp paths are
|
|
281
|
-
// byte-untouched (no curl call), so every existing aurora gate stays byte-equivalent.
|
|
282
|
-
${Ce}
|
|
283
|
-
|
|
284
|
-
// The scalar fbm potential ψ for curlFBM — aurora's own fbm. The splice above
|
|
285
|
-
// forward-declares potentialFBM; this defines it (ES 3.00 allows the prototype).
|
|
286
|
-
float potentialFBM(vec2 p) { return fbm(p); }
|
|
287
|
-
|
|
288
|
-
// The painterly-medium organic noise basis (Jarzynski PCG2D integer-bit hash
|
|
289
|
-
// + 2D simplex gradient noise), SPLICED from the shared procedural-color chunk (the
|
|
290
|
-
// single hash source).
|
|
291
|
-
// The painterly mediums (mediumOil's tooth/granulation) opt into pcgHash2/gnoise for
|
|
292
|
-
// organic paper/pigment grain; the smooth/atmospheric pole KEEPS its cheap value-noise
|
|
293
|
-
// fbm above (the cost tiering is preserved: this is an additive basis,
|
|
294
|
-
// not a blanket upgrade). The aurora-local hash21/vnoise/fbm loop stays (legitimately
|
|
295
|
-
// divergent per the chunk's §3a).
|
|
296
|
-
${p}
|
|
297
|
-
|
|
298
|
-
// The sRGB OETF (linearToSrgb) is spliced from the shared procedural-color chunk,
|
|
299
|
-
// the sole OETF source; the local copy is deleted here. Aurora's linear pipeline
|
|
300
|
-
// closes the color-space seam with this transfer before fragColor.
|
|
301
|
-
${_}
|
|
302
|
-
|
|
303
|
-
// The four Ottosson OKLab/OKLCh matrices + their space fns, spliced from the
|
|
304
|
-
// SAME shared chunk the goo-blob uses (zero new payload, 1e-6-verified). PI is
|
|
305
|
-
// defined first because the chunk's oklabToOklch folds the hue into [0, 2pi).
|
|
306
|
-
const float PI = 3.141592653589793;
|
|
307
|
-
${y}
|
|
308
|
-
|
|
309
|
-
// ── OKLCh palette ramp (single-sourced twin) ───────────────────────────────
|
|
310
|
-
// The muddy-midtone kill: distant-hue stops interpolated by a plain linear mix()
|
|
311
|
-
// desaturate toward grey at the midpoint. The OKLab-rectangular lerp (L,a,b) holds
|
|
312
|
-
// chroma across the ramp; the OKLCh hue-arc form (deliberate rainbow travel via
|
|
313
|
-
// uHuePath increasing/decreasing) sweeps the hue wheel without flipping.
|
|
314
|
-
//
|
|
315
|
-
// The ramp (interpolateHueTurns + mixPaletteOklab + mixPaletteOklchArc +
|
|
316
|
-
// the smoothstep-eased samplePaletteRamp dispatcher) is SPLICED from the shared
|
|
317
|
-
// procedural-color chunk (the single ramp source). composition.glsl.ts's
|
|
318
|
-
// samplePalette calls samplePaletteRamp.
|
|
319
|
-
${h}
|
|
320
|
-
|
|
321
|
-
// Interleaved Gradient Noise (Jimenez) — a 1-LSB triangular dither applied in
|
|
322
|
-
// DISPLAY space AFTER the OETF, so 8-bit mid-tone banding on the soft gradient is
|
|
323
|
-
// quantization-dithered at the value being quantized (post-transfer, not linear).
|
|
324
|
-
float ign(vec2 p) {
|
|
325
|
-
return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// Cellular, Worley f1
|
|
329
|
-
float cellular(vec2 p) {
|
|
330
|
-
vec2 i = floor(p);
|
|
331
|
-
vec2 f = fract(p);
|
|
332
|
-
float m = 1e9;
|
|
333
|
-
for (int y = -1; y <= 1; y++) {
|
|
334
|
-
for (int x = -1; x <= 1; x++) {
|
|
335
|
-
vec2 g = vec2(float(x), float(y));
|
|
336
|
-
vec2 o = hash22(i + g);
|
|
337
|
-
vec2 r = g + o - f;
|
|
338
|
-
m = min(m, dot(r, r));
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
return sqrt(m);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// ── Warp ──────────────────────────────────────────────────────────────────
|
|
345
|
-
vec2 domainWarp(vec2 p, float t) {
|
|
346
|
-
// Quilez canonical double warp
|
|
347
|
-
vec2 q = vec2(fbm(p * uWarpScale + vec2(0.0, 0.0) + t * uWarpDrift * K_WARP),
|
|
348
|
-
fbm(p * uWarpScale + vec2(5.2, 1.3) + t * uWarpDrift * K_WARP));
|
|
349
|
-
vec2 r = vec2(fbm(p * uWarpScale + 4.0 * q + vec2(1.7, 9.2)),
|
|
350
|
-
fbm(p * uWarpScale + 4.0 * q + vec2(8.3, 2.8)));
|
|
351
|
-
|
|
352
|
-
vec2 warp = r;
|
|
353
|
-
if (uWarpMode == 1) {
|
|
354
|
-
// cellular — chunky territories (MEADOW block-like)
|
|
355
|
-
float c1 = cellular(p * uWarpScale * 1.5 + vec2(t * uWarpDrift * K_WARP * 2.0, 0.0));
|
|
356
|
-
float c2 = cellular(p * uWarpScale * 1.5 + vec2(11.0, 7.0 + t * uWarpDrift * K_WARP * 2.0));
|
|
357
|
-
warp = vec2(c1, c2);
|
|
358
|
-
} else if (uWarpMode == 2) {
|
|
359
|
-
// hybrid — fbm + cellular averaged
|
|
360
|
-
float c1 = cellular(p * uWarpScale * 1.2);
|
|
361
|
-
float c2 = cellular(p * uWarpScale * 1.2 + vec2(11.0, 7.0));
|
|
362
|
-
warp = mix(r, vec2(c1, c2), 0.5);
|
|
363
|
-
} else if (uWarpMode == 3) {
|
|
364
|
-
// Curl (Bridson flow warp). The divergence-free curl of an fbm potential
|
|
365
|
-
// advects the field along a source-free swirl — folds + stretches like fluid
|
|
366
|
-
// advection, never the source-y bulge a raw fbm gradient produces. The potential
|
|
367
|
-
// scrolls on the same warp-drift clock; curlFBM is the shared chunk's operator.
|
|
368
|
-
vec2 fp = p * uWarpScale + vec2(t * uWarpDrift * K_WARP);
|
|
369
|
-
warp = curlFBM(fp);
|
|
370
|
-
}
|
|
371
|
-
vec2 warped = p + uWarpAmount * warp;
|
|
372
|
-
|
|
373
|
-
// Cursor swirl — rotate p around uCursor with radial falloff.
|
|
374
|
-
// This warps the underlying color field so the bands sweep around the pointer.
|
|
375
|
-
if (uCursorStrength > 0.001) {
|
|
376
|
-
vec2 toP = p - uCursor;
|
|
377
|
-
float d = length(toP);
|
|
378
|
-
float r = max(uCursorRadius, 0.01);
|
|
379
|
-
// Smooth falloff; strong near cursor, zero beyond ~1.5× radius.
|
|
380
|
-
float w = exp(-(d * d) / (r * r * 0.45));
|
|
381
|
-
// Max rotation ~120° at cursor center, scaled by strength
|
|
382
|
-
float ang = w * uCursorStrength * 2.1;
|
|
383
|
-
float ca = cos(ang), sa = sin(ang);
|
|
384
|
-
vec2 rotated = vec2(ca * toP.x - sa * toP.y, sa * toP.x + ca * toP.y) + uCursor;
|
|
385
|
-
// Also pinch slightly toward the cursor (gravity) — adds depth to swirl
|
|
386
|
-
float pinch = w * uCursorStrength * 0.08;
|
|
387
|
-
rotated = mix(rotated, uCursor, pinch);
|
|
388
|
-
// Blend original warped position with cursor-rotated version
|
|
389
|
-
warped = mix(warped, rotated + uWarpAmount * warp * 0.7, w * uCursorStrength);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
return warped;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
` + we + I + Te + "\n// ── Color utils (OKLCh; the sRGB YIQ hueShift matrix is DELETED) ──────────\nconst vec3 W_LUMA = vec3(0.2126, 0.7152, 0.0722);\n\n// Linear sRGB → OKLab (the cbrt-LMS path; the goo-blob's srgbToOklab takes gamma,\n// here the color field is already linear so we skip the OETF inverse).\nvec3 linOklab(vec3 lin) {\n vec3 lms = LINEAR_SRGB_TO_LMS * lin;\n return LMS_TO_OKLAB * (sign(lms) * pow(abs(lms), vec3(1.0 / 3.0)));\n}\n\n// Broken color — hue + chroma jitter at fixed PERCEPTUAL lightness, in OKLCh.\n// Broken color is hue variation at constant VALUE, which only OKLCh makes true (the\n// prior YIQ-style sRGB rotation muddied value). Van-Gogh and oil-pastel consume\n// this seam for per-stroke pigment jitter.\nvec3 brokenColorJitter(vec3 c, float hueSeed, float valueSeed, float strength) {\n float amt = clamp(uBrokenColor * strength, 0.0, 1.0);\n if (amt <= 0.001) return c;\n vec3 lch = oklabToOklch(linOklab(c));\n // ±~16° hue swing + ±~12% chroma swing; L held so value reads constant.\n lch.z += (hueSeed - 0.5) * (32.0 * PI / 180.0) * amt;\n lch.y = max(lch.y * (1.0 + (valueSeed - 0.5) * 0.28 * amt), 0.0);\n return max(oklabToLinearSrgb(oklchToOklab(lch)), vec3(0.0));\n}\n\n// Saturation — chroma scale at fixed L/H in OKLCh (the perceptual saturation,\n// replacing the luma-mix sRGB form). amt=1 is identity; amt<1 desaturates toward\n// the achromatic axis with NO lightness shift (the muddy-luma-mix grey is gone).\nvec3 saturate3(vec3 c, float amt) {\n vec3 lch = oklabToOklch(linOklab(c));\n lch.y = max(lch.y * amt, 0.0);\n return max(oklabToLinearSrgb(oklchToOklab(lch)), vec3(0.0));\n}\n\n// The chroma floor operates in OKLab: lightness + hue are\n// untouched, chroma is lifted toward the floor. A pale zone BLOOMS to transmission-fit;\n// a vivid zone (already above the floor) is byte-untouched. The near-gray hue guard is\n// STRUCTURAL: below VIVID_EPS the (a,b) direction is precision noise, so the lift\n// synthesizes along the WARM anchor (amber, both components positive) — NEVER the noisy\n// near-zero vector, NEVER a cold/teal hue. uVividness:0 returns c identically (the gated\n// byte-identity opt-out). Mode factor: a dark route lifts the floor a touch (a dim field\n// needs more chroma to read vivid through glass) — derived from the field's own L.\nconst float VIVID_TARGET = 0.115;\nconst float VIVID_EPS = 0.012;\n// The warm amber anchor in OKLab (a,b): OKLCh hue 70°, unit chroma. cos/sin(70°) — both\n// POSITIVE (warm yellow-orange). The near-gray fallback direction, the warm-floor law.\nconst vec2 VIVID_WARM_ANCHOR = vec2(0.34202, 0.93969);\nvec3 vividnessFloor(vec3 c) {\n if (uVividness <= 0.0001) return c;\n vec3 lab = linOklab(c);\n float C = length(lab.yz);\n // Mode-aware: dim fields (low L) get a slightly higher target so they read vivid\n // through glass. The mix factor is gentle (1.0–1.18) so light routes are unaffected.\n float modeLift = mix(1.18, 1.0, clamp(lab.x * 1.4, 0.0, 1.0));\n float Cmin = uVividness * VIVID_TARGET * modeLift;\n vec2 hueDir = (C > VIVID_EPS) ? lab.yz / C : VIVID_WARM_ANCHOR;\n lab.yz = hueDir * max(C, Cmin);\n return max(oklabToLinearSrgb(lab), vec3(0.0));\n}\n\n" + Ee + I + Me + I + De + I + Ne + "\n\n// ── Main ──────────────────────────────────────────────────────────────────\nvoid main() {\n // Normalized 0..1 coordinates for nuclei, domain warp, and medium sampling.\n vec2 uv = vUv;\n vec2 pN = uv;\n\n float t = uTime;\n\n // Warp in pN space\n vec2 p_warp = domainWarp(pN, t);\n\n // Composition\n float paletteId; float valueMod;\n nucleiField(p_warp, t, paletteId, valueMod);\n vec3 col = samplePalette(paletteId);\n col *= 1.0 + uValueVariance * valueMod;\n\n // Breath — slow global luminance wobble\n float breath = sin(t * 6.2831 / max(uBreathPeriod, 1.0));\n col *= 1.0 + uBreathDepth * breath * 0.5;\n\n // Medium dispatch: each is a first-class body with no shared dispatch.\n // 1 pastel · 2 watercolor · 3 oil · 4 crayon (DRY tooth-multiply) ·\n // 5 van-Gogh (atomic comma/crescent dabs) · 6 oil-pastel (stroke deposition) ·\n // 7 kuwahara (anisotropic-Kuwahara edge-preserving painterly finish).\n // van-Gogh is no longer a mediumOil passthrough; oil-pastel and crayon no longer\n // share a body — they share the SUBSTRATE (the tooth/placement helpers), not the\n // dispatch body. Kuwahara is OPT-IN (default-off — no preset selects\n // it unless a config explicitly sets medium:\"kuwahara\"); the smooth default + the\n // van-Gogh HERO + the existing painterly bodies are byte-unchanged by its addition.\n if (uMedium == 1) col = mediumPastel(col, pN, t);\n else if (uMedium == 2) col = mediumWatercolor(col, pN, t);\n else if (uMedium == 3) col = mediumOil(col, pN, t);\n else if (uMedium == 4) col = mediumCrayon(col, pN, t);\n else if (uMedium == 5) col = mediumVangogh(col, pN, t);\n else if (uMedium == 6) col = mediumOilPastel(col, pN, t);\n else if (uMedium == 7) col = mediumKuwahara(col, pN, t);\n // The mutually exclusive metal mediums are opt-in at uMedium==8/9;\n // the smooth default + every existing medium are byte-unchanged by these arms).\n else if (uMedium == 8) col = mediumMetal(col, pN, t);\n else if (uMedium == 9) col = mediumMetalGradient(col, pN, t);\n\n // Cursor-local luminance lean. Position, radius, and the CPU-folded strength are the\n // same four packed values on WebGL2 and WebGPU; absent interactivity writes strength 0.\n vec2 cursorDelta = pN - uCursor;\n float cursorRadius = max(uCursorRadius, 0.01);\n float cursorLean = exp(-dot(cursorDelta, cursorDelta) / (cursorRadius * cursorRadius * 0.5));\n col *= 1.0 + 0.12 * cursorLean * uCursorStrength;\n\n // Saturation trim\n col = saturate3(col, uSaturation);\n\n // The chroma floor is warm-anchored and hue-preserving. It lifts a\n // pale zone toward the transmissive floor so warm glass over the field reads\n // transmissive-not-gray; a vivid zone is untouched; uVividness:0 is a no-op.\n col = vividnessFloor(col);\n\n // Tonemap + film grain\n col = aces(col);\n float grain = hash21(gl_FragCoord.xy + t * 17.0);\n col += (grain - 0.5) * uPaperGrain;\n\n col = clamp(col * 0.985 + 0.008, 0.0, 1.0);\n\n // MANDATORY OETF — closes the seam (mirrors metaball.frag.ts:278). The whole\n // pipeline above (linear palette LUT, ACES tonemap, grain) runs in LINEAR; without\n // this transfer the aurora ships ~2.2× too dark (linear 0.5 → ~0.215, not ~0.735).\n col = linearToSrgb(col);\n\n // 1-LSB triangular IGN dither in DISPLAY space, AFTER the OETF — breaks 8-bit\n // mid-tone banding on the soft gradient. Texture-free (the canonical Jimenez IGN).\n col += (1.0 / 255.0) * (ign(gl_FragCoord.xy) - 0.5);\n\n // Premultiply operates on DISPLAY-space color (matches the blob: OETF, then premul).\n fragColor = vec4(col * uAlpha, uAlpha);\n}\n", Fe = `#version 300 es
|
|
396
|
-
precision highp float;
|
|
397
|
-
|
|
398
|
-
in vec2 vUv;
|
|
399
|
-
out vec4 fragColor;
|
|
400
|
-
|
|
401
|
-
#define MAX_NUCLEI 8
|
|
402
|
-
#define BLUR_RINGS 3
|
|
403
|
-
#define BLUR_SECTORS 8
|
|
404
|
-
const float PI = 3.141592653589793;
|
|
405
|
-
|
|
406
|
-
uniform float uTime;
|
|
407
|
-
|
|
408
|
-
// The drifting field uniforms — the SAME nuclei/warp/cursor lanes the palette program
|
|
409
|
-
// reads; here they drive the BLUR ZONE, not the color.
|
|
410
|
-
uniform int uNucleiCount;
|
|
411
|
-
uniform vec2 uNucleiPos[MAX_NUCLEI];
|
|
412
|
-
uniform float uNucleiRadius[MAX_NUCLEI];
|
|
413
|
-
uniform float uNucleiValueBias[MAX_NUCLEI];
|
|
414
|
-
uniform float uNucleiDriftRadius[MAX_NUCLEI];
|
|
415
|
-
uniform float uNucleiDriftPhase[MAX_NUCLEI];
|
|
416
|
-
uniform float uNucleiElong[MAX_NUCLEI];
|
|
417
|
-
uniform float uNucleiAngle[MAX_NUCLEI];
|
|
418
|
-
uniform float uSoftmaxBeta;
|
|
419
|
-
uniform float uNucleiDrift;
|
|
420
|
-
uniform float uWarpAmount;
|
|
421
|
-
uniform float uWarpScale;
|
|
422
|
-
uniform float uWarpDrift;
|
|
423
|
-
uniform int uNoiseOctaves;
|
|
424
|
-
uniform vec2 uCursor;
|
|
425
|
-
uniform float uCursorStrength;
|
|
426
|
-
uniform float uCursorRadius;
|
|
427
|
-
|
|
428
|
-
// Output shaping (shared with the palette program's meaning).
|
|
429
|
-
uniform float uSaturation;
|
|
430
|
-
uniform float uPaperGrain;
|
|
431
|
-
uniform float uAlpha;
|
|
432
|
-
uniform float uVividness;
|
|
433
|
-
|
|
434
|
-
// ── The image lane (this program's OWN uniform tail) ──
|
|
435
|
-
uniform sampler2D uImage;
|
|
436
|
-
uniform float uBlurMin; // 0..1 uv-space blur radius at zone=0 (near-sharp)
|
|
437
|
-
uniform float uBlurMax; // 0..1 uv-space blur radius at zone=1 (dissolved)
|
|
438
|
-
uniform float uImageAspect; // canvas W/H — keeps the bokeh circular in screen space
|
|
439
|
-
|
|
440
|
-
// Authoring-scale → rad/sec lifts (byte-identical to aurora.frag.ts).
|
|
441
|
-
const float K_NUCLEI = 14.0;
|
|
442
|
-
const float K_WARP = 5.0;
|
|
443
|
-
|
|
444
|
-
// ── Noise (aurora-local hash21/vnoise/fbm — the same compact foundation) ──
|
|
445
|
-
float hash21(vec2 p) {
|
|
446
|
-
p = fract(p * vec2(123.34, 456.21));
|
|
447
|
-
p += dot(p, p + 45.32);
|
|
448
|
-
return fract(p.x * p.y);
|
|
449
|
-
}
|
|
450
|
-
float vnoise(vec2 p) {
|
|
451
|
-
vec2 i = floor(p);
|
|
452
|
-
vec2 f = fract(p);
|
|
453
|
-
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
454
|
-
float a = hash21(i);
|
|
455
|
-
float b = hash21(i + vec2(1.0, 0.0));
|
|
456
|
-
float c = hash21(i + vec2(0.0, 1.0));
|
|
457
|
-
float d = hash21(i + vec2(1.0, 1.0));
|
|
458
|
-
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
|
|
459
|
-
}
|
|
460
|
-
${x}
|
|
461
|
-
float fbm(vec2 p) {
|
|
462
|
-
float v = 0.0;
|
|
463
|
-
float a = 0.5;
|
|
464
|
-
for (int i = 0; i < 5; i++) {
|
|
465
|
-
if (i >= uNoiseOctaves) break;
|
|
466
|
-
v += a * vnoise(p);
|
|
467
|
-
p = FBM_ROT * p * 2.02;
|
|
468
|
-
a *= 0.5;
|
|
469
|
-
}
|
|
470
|
-
return v;
|
|
471
|
-
}
|
|
472
|
-
// Interleaved Gradient Noise (Jimenez) — display-space 1-LSB dither.
|
|
473
|
-
float ign(vec2 p) {
|
|
474
|
-
return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
${_}
|
|
478
|
-
${y}
|
|
479
|
-
|
|
480
|
-
// linear-sRGB → raw OKLab (the vividnessFloor helper — mirrors aurora.frag's linOklab).
|
|
481
|
-
vec3 linOklab(vec3 lin) {
|
|
482
|
-
vec3 lms = LINEAR_SRGB_TO_LMS * lin;
|
|
483
|
-
return LMS_TO_OKLAB * (sign(lms) * pow(abs(lms), vec3(1.0 / 3.0)));
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// The Quilez double-warp (the fbm branch — byte-parallel to aurora.frag's default warp)
|
|
487
|
-
// + the cursor swirl. The SAME drift that moves the palette field here moves the blur zone.
|
|
488
|
-
vec2 domainWarp(vec2 p, float t) {
|
|
489
|
-
vec2 q = vec2(fbm(p * uWarpScale + vec2(0.0, 0.0) + t * uWarpDrift * K_WARP),
|
|
490
|
-
fbm(p * uWarpScale + vec2(5.2, 1.3) + t * uWarpDrift * K_WARP));
|
|
491
|
-
vec2 r = vec2(fbm(p * uWarpScale + 4.0 * q + vec2(1.7, 9.2)),
|
|
492
|
-
fbm(p * uWarpScale + 4.0 * q + vec2(8.3, 2.8)));
|
|
493
|
-
vec2 warped = p + uWarpAmount * r;
|
|
494
|
-
if (uCursorStrength > 0.001) {
|
|
495
|
-
vec2 toP = p - uCursor;
|
|
496
|
-
float d = length(toP);
|
|
497
|
-
float rr = max(uCursorRadius, 0.01);
|
|
498
|
-
float w = exp(-(d * d) / (rr * rr * 0.45));
|
|
499
|
-
float ang = w * uCursorStrength * 2.1;
|
|
500
|
-
float ca = cos(ang), sa = sin(ang);
|
|
501
|
-
vec2 rotated = vec2(ca * toP.x - sa * toP.y, sa * toP.x + ca * toP.y) + uCursor;
|
|
502
|
-
warped = mix(warped, rotated + uWarpAmount * r * 0.7, w * uCursorStrength);
|
|
503
|
-
}
|
|
504
|
-
return warped;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// The drifting BLUR ZONE — a smooth [0,1] scalar from the anisotropic-Gaussian nuclei
|
|
508
|
-
// softmax (the SAME field nucleiField reads), drift-coupled. Reads high where a nucleus
|
|
509
|
-
// sits → that region dissolves; the inter-nucleus gaps stay near-sharp.
|
|
510
|
-
float zoneField(vec2 p, float t) {
|
|
511
|
-
float accum = 0.0;
|
|
512
|
-
float accumW = 0.0;
|
|
513
|
-
for (int i = 0; i < MAX_NUCLEI; i++) {
|
|
514
|
-
if (i >= uNucleiCount) break;
|
|
515
|
-
float driftPhase = uNucleiDriftPhase[i];
|
|
516
|
-
vec2 posI = uNucleiPos[i] + uNucleiDriftRadius[i] * vec2(
|
|
517
|
-
cos(t * uNucleiDrift * K_NUCLEI + driftPhase),
|
|
518
|
-
sin(t * uNucleiDrift * K_NUCLEI + driftPhase * 1.13));
|
|
519
|
-
vec2 diff = p - posI;
|
|
520
|
-
float ang = uNucleiAngle[i];
|
|
521
|
-
float ca = cos(ang), sa = sin(ang);
|
|
522
|
-
vec2 local = vec2(ca * diff.x + sa * diff.y, -sa * diff.x + ca * diff.y);
|
|
523
|
-
float along = local.x / max(uNucleiElong[i], 0.01);
|
|
524
|
-
float d2 = along * along + local.y * local.y;
|
|
525
|
-
float rad = max(uNucleiRadius[i], 0.01);
|
|
526
|
-
float w = exp(-uSoftmaxBeta * d2 / (rad * rad));
|
|
527
|
-
accum += w * (0.5 + 0.5 * uNucleiValueBias[i]);
|
|
528
|
-
accumW += w;
|
|
529
|
-
}
|
|
530
|
-
return clamp(accum / max(accumW, 1e-4), 0.0, 1.0);
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
// Object-fit:cover — map the screen uv into the image so a non-matching aspect crops,
|
|
534
|
-
// never stretches. uImageAspect is the canvas aspect (W/H); the image is authored to
|
|
535
|
-
// fill it. A centred cover keeps the photo readable under the dissolve.
|
|
536
|
-
vec2 coverUv(vec2 uv) {
|
|
537
|
-
vec2 c = uv - 0.5;
|
|
538
|
-
c.x *= max(uImageAspect, 0.0001);
|
|
539
|
-
float s = 1.0 / max(uImageAspect, 1.0);
|
|
540
|
-
return c * s + 0.5;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
// The bounded 24-tap zone blur — a FIXED 3-ring × 8-sector stratified kernel. The radius
|
|
544
|
-
// is per-fragment (mix(uBlurMin, uBlurMax, zone)); every tap is sampled in LINEAR light
|
|
545
|
-
// (srgbToLinear) so the average is a physically-correct bokeh. The x-offset is divided by
|
|
546
|
-
// the canvas aspect so the kernel stays circular in screen space.
|
|
547
|
-
vec3 zoneBlur(vec2 uv, float radius) {
|
|
548
|
-
vec3 sum = srgbToLinear(texture(uImage, coverUv(uv)).rgb);
|
|
549
|
-
float wsum = 1.0;
|
|
550
|
-
for (int ring = 1; ring <= BLUR_RINGS; ring++) {
|
|
551
|
-
float rr = radius * (float(ring) / float(BLUR_RINGS));
|
|
552
|
-
for (int s = 0; s < BLUR_SECTORS; s++) {
|
|
553
|
-
float a = (float(s) + 0.5 * float(ring)) / float(BLUR_SECTORS) * 2.0 * PI;
|
|
554
|
-
vec2 off = vec2(cos(a) / max(uImageAspect, 0.0001), sin(a)) * rr;
|
|
555
|
-
sum += srgbToLinear(texture(uImage, coverUv(uv + off)).rgb);
|
|
556
|
-
wsum += 1.0;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
return sum / wsum;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
// The §3 chroma FLOOR — source-agnostic (operates on the final linear col), the WGSL/GLSL
|
|
563
|
-
// twin of aurora.frag's vividnessFloor. A washed-out photo blooms to transmission-fit; a
|
|
564
|
-
// vivid photo is untouched; uVividness:0 is a no-op.
|
|
565
|
-
const float VIVID_TARGET = 0.115;
|
|
566
|
-
const float VIVID_EPS = 0.012;
|
|
567
|
-
const vec2 VIVID_WARM_ANCHOR = vec2(0.34202, 0.93969);
|
|
568
|
-
vec3 vividnessFloor(vec3 c) {
|
|
569
|
-
if (uVividness <= 0.0001) return c;
|
|
570
|
-
vec3 lab = linOklab(c);
|
|
571
|
-
float C = length(lab.yz);
|
|
572
|
-
float modeLift = mix(1.18, 1.0, clamp(lab.x * 1.4, 0.0, 1.0));
|
|
573
|
-
float Cmin = uVividness * VIVID_TARGET * modeLift;
|
|
574
|
-
vec2 hueDir = (C > VIVID_EPS) ? lab.yz / C : VIVID_WARM_ANCHOR;
|
|
575
|
-
lab.yz = hueDir * max(C, Cmin);
|
|
576
|
-
return max(oklabToLinearSrgb(lab), vec3(0.0));
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
vec3 saturate3(vec3 c, float amt) {
|
|
580
|
-
vec3 lch = oklabToOklch(linOklab(c));
|
|
581
|
-
lch.y = max(lch.y * amt, 0.0);
|
|
582
|
-
return max(oklabToLinearSrgb(oklchToOklab(lch)), vec3(0.0));
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
// ── PBR-Neutral tonemap (named aces() — the tonemap slot; byte-parallel to aurora.frag) ──
|
|
587
|
-
vec3 aces(vec3 color) {
|
|
588
|
-
const float startCompression = 0.8 - 0.04;
|
|
589
|
-
const float desaturation = 0.15;
|
|
590
|
-
float x = min(color.r, min(color.g, color.b));
|
|
591
|
-
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
|
|
592
|
-
color -= offset;
|
|
593
|
-
float peak = max(color.r, max(color.g, color.b));
|
|
594
|
-
if (peak < startCompression) return clamp(color, 0.0, 1.0);
|
|
595
|
-
float d = 1.0 - startCompression;
|
|
596
|
-
float newPeak = 1.0 - d * d / (peak + d - startCompression);
|
|
597
|
-
color *= newPeak / peak;
|
|
598
|
-
float g = 1.0 - 1.0 / (desaturation * (peak - newPeak) + 1.0);
|
|
599
|
-
return clamp(mix(color, newPeak * vec3(1.0), g), 0.0, 1.0);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
void main() {
|
|
603
|
-
vec2 uv = vUv;
|
|
604
|
-
float t = uTime;
|
|
605
|
-
|
|
606
|
-
// The SAME drifting field the palette program computes — here it drives BLUR, not color.
|
|
607
|
-
vec2 p_warp = domainWarp(uv, t);
|
|
608
|
-
float zone = zoneField(p_warp, t);
|
|
609
|
-
|
|
610
|
-
// Per-fragment blur radius — near-sharp at zone 0, dissolved at zone 1.
|
|
611
|
-
float radius = mix(uBlurMin, uBlurMax, zone);
|
|
612
|
-
vec3 col = zoneBlur(uv, radius);
|
|
613
|
-
|
|
614
|
-
vec2 cursorDelta = uv - uCursor;
|
|
615
|
-
float cursorRadius = max(uCursorRadius, 0.01);
|
|
616
|
-
float cursorLean = exp(-dot(cursorDelta, cursorDelta) / (cursorRadius * cursorRadius * 0.5));
|
|
617
|
-
col *= 1.0 + 0.12 * cursorLean * uCursorStrength;
|
|
618
|
-
|
|
619
|
-
// Saturation trim + the source-agnostic vividness floor (a washed photo blooms).
|
|
620
|
-
col = saturate3(col, uSaturation);
|
|
621
|
-
col = vividnessFloor(col);
|
|
622
|
-
|
|
623
|
-
// Tonemap + film grain (byte-parallel closing of the palette program's seam).
|
|
624
|
-
col = aces(col);
|
|
625
|
-
float grain = hash21(gl_FragCoord.xy + t * 17.0);
|
|
626
|
-
col += (grain - 0.5) * uPaperGrain;
|
|
627
|
-
col = clamp(col * 0.985 + 0.008, 0.0, 1.0);
|
|
628
|
-
|
|
629
|
-
// MANDATORY OETF (the whole pipeline above runs in LINEAR) + display-space IGN dither.
|
|
630
|
-
col = linearToSrgb(col);
|
|
631
|
-
col += (1.0 / 255.0) * (ign(gl_FragCoord.xy) - 0.5);
|
|
632
|
-
|
|
633
|
-
// Premultiply on display-space color (matches the palette path: OETF, then premul).
|
|
634
|
-
fragColor = vec4(col * uAlpha, uAlpha);
|
|
635
|
-
}
|
|
636
|
-
`, L = {
|
|
637
|
-
nucleiDrift: 5e-4,
|
|
638
|
-
paletteDrift: 4e-4,
|
|
639
|
-
breathDepth: .0015,
|
|
640
|
-
warpDrift: 15e-5
|
|
641
|
-
};
|
|
642
|
-
function R(e) {
|
|
643
|
-
return Math.abs(e.nucleiDrift) >= L.nucleiDrift || Math.abs(e.paletteDrift) >= L.paletteDrift || Math.abs(e.breathDepth) >= L.breathDepth || Math.abs(e.warpDrift) >= L.warpDrift;
|
|
644
|
-
}
|
|
645
|
-
var Ie = 8, Le = 8, Re = 1, ze = .115, Be = .004, Ve = .06, z = {
|
|
646
|
-
palette: [
|
|
647
|
-
{
|
|
648
|
-
L: .64,
|
|
649
|
-
C: .17,
|
|
650
|
-
h: 30
|
|
651
|
-
},
|
|
652
|
-
{
|
|
653
|
-
L: .76,
|
|
654
|
-
C: .15,
|
|
655
|
-
h: 55
|
|
656
|
-
},
|
|
657
|
-
{
|
|
658
|
-
L: .87,
|
|
659
|
-
C: .13,
|
|
660
|
-
h: 82
|
|
661
|
-
}
|
|
662
|
-
],
|
|
663
|
-
nuclei: [{
|
|
664
|
-
x: .3,
|
|
665
|
-
y: .3,
|
|
666
|
-
radius: .5,
|
|
667
|
-
paletteBias: 0,
|
|
668
|
-
valueBias: 0,
|
|
669
|
-
driftRadius: .045,
|
|
670
|
-
driftPhase: 0
|
|
671
|
-
}, {
|
|
672
|
-
x: .7,
|
|
673
|
-
y: .65,
|
|
674
|
-
radius: .5,
|
|
675
|
-
paletteBias: 1,
|
|
676
|
-
valueBias: .05,
|
|
677
|
-
driftRadius: .045,
|
|
678
|
-
driftPhase: 2.4
|
|
679
|
-
}],
|
|
680
|
-
softmaxBeta: 3,
|
|
681
|
-
valueVariance: .08,
|
|
682
|
-
warpAmount: .5,
|
|
683
|
-
warpScale: 1.6,
|
|
684
|
-
warpDrift: .008,
|
|
685
|
-
warpMode: "fbm",
|
|
686
|
-
noiseOctaves: 4,
|
|
687
|
-
medium: "smooth",
|
|
688
|
-
flow: {
|
|
689
|
-
pattern: "none",
|
|
690
|
-
focalX: .5,
|
|
691
|
-
focalY: .5,
|
|
692
|
-
angle: 0,
|
|
693
|
-
curl: 0
|
|
694
|
-
},
|
|
695
|
-
strokeAmount: 0,
|
|
696
|
-
strokeScale: 140,
|
|
697
|
-
strokeAnisotropy: .7,
|
|
698
|
-
strokeLayers: 1,
|
|
699
|
-
strokeMode: "oil",
|
|
700
|
-
wetEdge: 0,
|
|
701
|
-
granulation: 0,
|
|
702
|
-
impasto: 0,
|
|
703
|
-
brokenColor: 0,
|
|
704
|
-
canvasGrain: 0,
|
|
705
|
-
nucleiDrift: .015,
|
|
706
|
-
paletteDrift: .015,
|
|
707
|
-
breathDepth: .05,
|
|
708
|
-
breathPeriod: 40,
|
|
709
|
-
saturation: 1,
|
|
710
|
-
paperGrain: .008,
|
|
711
|
-
alpha: 1,
|
|
712
|
-
vividness: 1
|
|
713
|
-
}, He = {
|
|
714
|
-
medium: "crayon",
|
|
715
|
-
strokeOrient: "tensor",
|
|
716
|
-
granulation: .3,
|
|
717
|
-
canvasGrain: .5,
|
|
718
|
-
strokeAmount: .35,
|
|
719
|
-
strokeAnisotropy: .5,
|
|
720
|
-
strokeLayers: 1,
|
|
721
|
-
impasto: 0,
|
|
722
|
-
brokenColor: 0,
|
|
723
|
-
wetEdge: 0,
|
|
724
|
-
saturation: .92,
|
|
725
|
-
paperGrain: .008
|
|
726
|
-
}, B = .001, Ue = 1e-4;
|
|
727
|
-
function V(e, t, n) {
|
|
728
|
-
let a = i(e);
|
|
729
|
-
if (n > 0) {
|
|
730
|
-
let t = e.acceleration.value, n = e.velocity.value, r = -(t.x * n.x + t.y * n.y);
|
|
731
|
-
r > 0 && (a.burst = Math.min(1, a.burst + r * 3));
|
|
732
|
-
}
|
|
733
|
-
let o = r(a, t);
|
|
734
|
-
return {
|
|
735
|
-
x: o.cx,
|
|
736
|
-
y: o.cy,
|
|
737
|
-
strength: o.strength,
|
|
738
|
-
radius: o.radius
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
function H(e) {
|
|
742
|
-
let t = e.attractorVelocity.value;
|
|
743
|
-
return e.engagement.value > B || e.speed.value > B || e.burst.value > B || Math.hypot(t.x, t.y) > Ue;
|
|
744
|
-
}
|
|
745
|
-
function We(e) {
|
|
746
|
-
let { gl: t, prog: n, uniforms: r, pointerField: i, getCursorScalars: a, getConfig: o, getReducedMotion: s, getRenderTime: c } = e, l = (e) => 1 - e, u = null, d = {
|
|
747
|
-
x: .5,
|
|
748
|
-
y: .5,
|
|
749
|
-
strength: 0,
|
|
750
|
-
radius: .25
|
|
751
|
-
};
|
|
752
|
-
function f() {
|
|
753
|
-
return +!s();
|
|
754
|
-
}
|
|
755
|
-
function p(e) {
|
|
756
|
-
let i = c(e);
|
|
757
|
-
if (t.useProgram(n), t.uniform2f(r.uCursor, d.x, l(d.y)), t.uniform1f(r.uCursorStrength, d.strength), t.uniform1f(r.uCursorRadius, d.radius), t.uniform1f(r.uTime, i), o().interactivity?.light) {
|
|
758
|
-
let e = f(), n = i * .25, a = Math.cos(n) * .5, o = Math.sin(n) * .5, s = (d.x - .5) * 2, c = (.5 - d.y) * 2, l = d.strength * e;
|
|
759
|
-
a = a * (1 - l) + s * l, o = o * (1 - l) + c * l, t.uniform3f(r.uLightDir, a * e + (1 - e) * -.5, o * e + (1 - e) * .6, .62);
|
|
760
|
-
}
|
|
761
|
-
t.clear(t.COLOR_BUFFER_BIT), t.drawArrays(t.TRIANGLES, 0, 3);
|
|
762
|
-
}
|
|
763
|
-
function m() {
|
|
764
|
-
return s() ? !1 : R(o()) ? !0 : H(i);
|
|
765
|
-
}
|
|
766
|
-
return {
|
|
767
|
-
frame: (e) => {
|
|
768
|
-
let t = f(), n = u === null ? 0 : Math.max(0, (e - u) * 1e3);
|
|
769
|
-
u = e, i.tick(t === 0 ? 0 : n), d = V(i, a(), t), p(e);
|
|
770
|
-
},
|
|
771
|
-
needsAnimation: m
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
//#endregion
|
|
775
|
-
//#region src/components/aurora/composables/color.ts
|
|
776
|
-
function U(e, t = 8, n) {
|
|
777
|
-
let r = n ?? new Float32Array(t * 3), i = Math.min(e.length, t);
|
|
778
|
-
for (let t = 0; t < i; t++) {
|
|
779
|
-
let [n, i, a] = d(e[t]);
|
|
780
|
-
r[t * 3 + 0] = n, r[t * 3 + 1] = i, r[t * 3 + 2] = a;
|
|
781
|
-
}
|
|
782
|
-
for (let e = i; e < t; e++) r[e * 3 + 0] = 0, r[e * 3 + 1] = 0, r[e * 3 + 2] = 0;
|
|
783
|
-
return r;
|
|
784
|
-
}
|
|
785
|
-
function Ge(e) {
|
|
786
|
-
if (e.length === 0) return "transparent";
|
|
787
|
-
if (e.length === 1) return u(e[0]);
|
|
788
|
-
let t = e.length;
|
|
789
|
-
return `linear-gradient(135deg, ${e.map((e, n) => {
|
|
790
|
-
let r = Math.round(n / (t - 1) * 100);
|
|
791
|
-
return `${u(e)} ${r}%`;
|
|
792
|
-
}).join(", ")})`;
|
|
793
|
-
}
|
|
794
|
-
function Ke(e) {
|
|
795
|
-
return s(e);
|
|
796
|
-
}
|
|
797
|
-
var qe = [.35, .95], Je = [.18, .42];
|
|
798
|
-
function Ye(e, t) {
|
|
799
|
-
return e ? [Math.max(0, Math.min(1, e[0])), Math.max(0, Math.min(1, e[1]))] : t === "dark" ? Je : qe;
|
|
800
|
-
}
|
|
801
|
-
function Xe(e, t = {}) {
|
|
802
|
-
let n = typeof e == "string" ? s(e) : e, { stopCount: r = 4, harmony: i = "analogous", lightnessSpread: a = .32, chromaFalloff: o = .85, hueSpread: u = 28, lightnessEasing: d = "linear", chromaEasing: f = "bell", temperatureShift: p = 0, avoidHues: m, scheme: h, lBand: g } = t, _ = Math.max(2, Math.min(8, Math.round(r))), [v, y] = Ye(g, h), b = n.L - a / 2, x = n.L + a / 2;
|
|
803
|
-
b < v && (x += v - b, b = v), x > y && (b -= x - y, x = y), b = Math.max(v, b), x = Math.min(y, x);
|
|
804
|
-
let S = [], C = -Infinity;
|
|
805
|
-
for (let e = 0; e < _; e++) {
|
|
806
|
-
let t = _ === 1 ? 0 : e / (_ - 1), r = b + (x - b) * Qe(t, d), a = n.C * o, s;
|
|
807
|
-
if (f === "bell") s = a + (n.C - a) * $e(t);
|
|
808
|
-
else {
|
|
809
|
-
let e = f === "sine" ? Qe(t, "sine") : t;
|
|
810
|
-
s = n.C - (n.C - a) * e;
|
|
811
|
-
}
|
|
812
|
-
let h = c(n.h, i, u, t);
|
|
813
|
-
p > 0 && (h = rt(h, t, p)), m && m.length > 0 && (h = ot(h, m));
|
|
814
|
-
let g = Ze(l({
|
|
815
|
-
L: r,
|
|
816
|
-
C: s,
|
|
817
|
-
h
|
|
818
|
-
}), C);
|
|
819
|
-
C = g.L, S.push(g);
|
|
820
|
-
}
|
|
821
|
-
return S;
|
|
822
|
-
}
|
|
823
|
-
function Ze(e, t) {
|
|
824
|
-
if (e.L >= t) return e;
|
|
825
|
-
let { h: n } = e, r = t, i = e.C;
|
|
826
|
-
for (let e = 0; e < 48; e++) {
|
|
827
|
-
let [e, t, a] = d({
|
|
828
|
-
L: r,
|
|
829
|
-
C: i,
|
|
830
|
-
h: n
|
|
831
|
-
});
|
|
832
|
-
if (Math.max(e, t, a) <= 1) break;
|
|
833
|
-
i *= .99;
|
|
834
|
-
}
|
|
835
|
-
return {
|
|
836
|
-
L: r,
|
|
837
|
-
C: i,
|
|
838
|
-
h: n
|
|
839
|
-
};
|
|
840
|
-
}
|
|
841
|
-
function Qe(e, t) {
|
|
842
|
-
return t === "sine" ? .5 - .5 * Math.cos(Math.PI * e) : e;
|
|
843
|
-
}
|
|
844
|
-
function $e(e) {
|
|
845
|
-
return Math.sin(Math.PI * e);
|
|
846
|
-
}
|
|
847
|
-
var et = 70, tt = 250, nt = 22;
|
|
848
|
-
function rt(e, t, n) {
|
|
849
|
-
let r = (t - .5) * 2;
|
|
850
|
-
if (r === 0 || n === 0) return e;
|
|
851
|
-
let i = (o("applyTemperature", de(e, r >= 0 ? et : tt, 1, "shorter")) - e + 540) % 360 - 180;
|
|
852
|
-
return ((e + Math.sign(i) * Math.min(Math.abs(r) * n * nt, Math.abs(i))) % 360 + 360) % 360;
|
|
853
|
-
}
|
|
854
|
-
var W = (e) => (e % 360 + 360) % 360;
|
|
855
|
-
function it(e, t, n) {
|
|
856
|
-
let r = W(e), i = W(t), a = W(n);
|
|
857
|
-
return i <= a ? r >= i && r <= a : r >= i || r <= a;
|
|
858
|
-
}
|
|
859
|
-
function at(e, t) {
|
|
860
|
-
let n = Math.abs(W(e) - W(t)) % 360;
|
|
861
|
-
return n > 180 ? 360 - n : n;
|
|
862
|
-
}
|
|
863
|
-
function ot(e, t) {
|
|
864
|
-
let n = .5, r = W(e);
|
|
865
|
-
for (let e = 0; e < t.length + 2; e++) {
|
|
866
|
-
let e = !1;
|
|
867
|
-
for (let [i, a] of t) {
|
|
868
|
-
if (!it(r, i, a)) continue;
|
|
869
|
-
let t = W(i - n), o = W(a + n);
|
|
870
|
-
r = at(r, t) <= at(r, o) ? t : o, e = !0;
|
|
871
|
-
}
|
|
872
|
-
if (!e) return r;
|
|
873
|
-
}
|
|
874
|
-
return r;
|
|
875
|
-
}
|
|
876
|
-
//#endregion
|
|
877
|
-
//#region src/components/aurora/composables/uniformBridge.ts
|
|
878
|
-
var st = {
|
|
879
|
-
x: .5,
|
|
880
|
-
y: .5,
|
|
881
|
-
strength: 0,
|
|
882
|
-
radius: .25
|
|
883
|
-
}, ct = {
|
|
884
|
-
smooth: 0,
|
|
885
|
-
pastel: 1,
|
|
886
|
-
watercolor: 2,
|
|
887
|
-
oil: 3,
|
|
888
|
-
crayon: 4,
|
|
889
|
-
vangogh: 5,
|
|
890
|
-
"oil-pastel": 6,
|
|
891
|
-
kuwahara: 7,
|
|
892
|
-
metal: 8,
|
|
893
|
-
"metal-gradient": 9
|
|
894
|
-
}, lt = {
|
|
895
|
-
shorter: 0,
|
|
896
|
-
longer: 1,
|
|
897
|
-
increasing: 2,
|
|
898
|
-
decreasing: 3
|
|
899
|
-
}, ut = {
|
|
900
|
-
none: 0,
|
|
901
|
-
radial: 1,
|
|
902
|
-
swirl: 2,
|
|
903
|
-
diagonal: 3,
|
|
904
|
-
multi: 4,
|
|
905
|
-
tensor: 5
|
|
906
|
-
}, dt = {
|
|
907
|
-
flow: 0,
|
|
908
|
-
tensor: 1
|
|
909
|
-
}, ft = {
|
|
910
|
-
fbm: 0,
|
|
911
|
-
cellular: 1,
|
|
912
|
-
hybrid: 2,
|
|
913
|
-
curl: 3
|
|
914
|
-
}, pt = {
|
|
915
|
-
oil: 0,
|
|
916
|
-
knife: 1,
|
|
917
|
-
chunky: 3
|
|
918
|
-
}, G = {
|
|
919
|
-
L: .985,
|
|
920
|
-
C: .0125,
|
|
921
|
-
h: 77.5
|
|
922
|
-
};
|
|
923
|
-
function mt(e) {
|
|
924
|
-
return e === void 0 ? f(G.L, G.C, G.h) : Array.isArray(e) ? e : f(e.L, e.C, e.h);
|
|
925
|
-
}
|
|
926
|
-
function ht(e) {
|
|
927
|
-
return ct[e.medium];
|
|
928
|
-
}
|
|
929
|
-
function gt(e) {
|
|
930
|
-
return pt[e.strokeMode];
|
|
931
|
-
}
|
|
932
|
-
function _t(e) {
|
|
933
|
-
return e.medium === "vangogh" || e.medium === "oil-pastel" || e.medium === "crayon" || e.medium === "kuwahara" ? dt.tensor : dt[e.strokeOrient ?? "flow"];
|
|
934
|
-
}
|
|
935
|
-
function vt(e, t, n, r = !1) {
|
|
936
|
-
let i = (e) => 1 - e, a = {
|
|
937
|
-
palette: /* @__PURE__ */ new Float32Array(24),
|
|
938
|
-
pos: /* @__PURE__ */ new Float32Array(16),
|
|
939
|
-
rad: /* @__PURE__ */ new Float32Array(8),
|
|
940
|
-
pb: /* @__PURE__ */ new Float32Array(8),
|
|
941
|
-
vb: /* @__PURE__ */ new Float32Array(8),
|
|
942
|
-
dr: /* @__PURE__ */ new Float32Array(8),
|
|
943
|
-
dp: /* @__PURE__ */ new Float32Array(8),
|
|
944
|
-
elong: /* @__PURE__ */ new Float32Array(8),
|
|
945
|
-
angle: /* @__PURE__ */ new Float32Array(8)
|
|
946
|
-
};
|
|
947
|
-
return function(o) {
|
|
948
|
-
e.useProgram(t), U(o.palette, 8, a.palette), e.uniform3fv(n.uPalette, a.palette), e.uniform1i(n.uStopCount, Math.min(o.palette.length, 8));
|
|
949
|
-
let s = Math.min(o.nuclei.length, 8);
|
|
950
|
-
e.uniform1i(n.uNucleiCount, s);
|
|
951
|
-
for (let e = 0; e < s; e++) {
|
|
952
|
-
let t = o.nuclei[e];
|
|
953
|
-
a.pos[e * 2 + 0] = t.x, a.pos[e * 2 + 1] = i(t.y), a.rad[e] = t.radius, a.pb[e] = t.paletteBias, a.vb[e] = t.valueBias, a.dr[e] = t.driftRadius, a.dp[e] = t.driftPhase, a.elong[e] = t.elongation ?? 1, a.angle[e] = -(t.angle ?? 0) * Math.PI / 180;
|
|
954
|
-
}
|
|
955
|
-
for (let e = s; e < 8; e++) a.pos[e * 2 + 0] = 0, a.pos[e * 2 + 1] = 0, a.rad[e] = 0, a.pb[e] = 0, a.vb[e] = 0, a.dr[e] = 0, a.dp[e] = 0, a.elong[e] = 1, a.angle[e] = 0;
|
|
956
|
-
e.uniform2fv(n.uNucleiPos, a.pos), e.uniform1fv(n.uNucleiRadius, a.rad), e.uniform1fv(n.uNucleiPaletteBias, a.pb), e.uniform1fv(n.uNucleiValueBias, a.vb), e.uniform1fv(n.uNucleiDriftRadius, a.dr), e.uniform1fv(n.uNucleiDriftPhase, a.dp), e.uniform1fv(n.uNucleiElong, a.elong), e.uniform1fv(n.uNucleiAngle, a.angle), e.uniform1f(n.uSoftmaxBeta, o.softmaxBeta), e.uniform1f(n.uValueVariance, o.valueVariance), e.uniform1f(n.uWarpAmount, o.warpAmount), e.uniform1f(n.uWarpScale, o.warpScale), e.uniform1f(n.uWarpDrift, o.warpDrift), e.uniform1i(n.uWarpMode, ft[o.warpMode]), e.uniform1i(n.uNoiseOctaves, o.noiseOctaves), e.uniform1i(n.uMedium, ht(o)), e.uniform1i(n.uHuePath, lt[o.huePath ?? "shorter"]), e.uniform1i(n.uFlowPattern, ut[o.flow.pattern]), e.uniform2f(n.uFlowFocal, o.flow.focalX, i(o.flow.focalY)), e.uniform1f(n.uFlowAngle, o.flow.angle), e.uniform1f(n.uFlowCurl, o.flow.curl);
|
|
957
|
-
let c = st;
|
|
958
|
-
e.uniform2f(n.uCursor, c.x, i(c.y)), e.uniform1f(n.uCursorStrength, c.strength), e.uniform1f(n.uCursorRadius, c.radius), e.uniform1f(n.uStrokeAmount, o.strokeAmount), e.uniform1f(n.uStrokeScale, o.strokeScale), e.uniform1f(n.uStrokeAnisotropy, o.strokeAnisotropy), e.uniform1i(n.uStrokeLayers, o.strokeLayers), e.uniform1i(n.uStrokeMode, gt(o)), e.uniform1i(n.uStrokeOrient, _t(o));
|
|
959
|
-
{
|
|
960
|
-
let t = o.lightDir ?? [
|
|
961
|
-
-.5,
|
|
962
|
-
.6,
|
|
963
|
-
.62
|
|
964
|
-
], r = mt(o.lightColor);
|
|
965
|
-
e.uniform3f(n.uLightDir, t[0], t[1], t[2]), e.uniform3f(n.uLightColor, r[0], r[1], r[2]);
|
|
966
|
-
}
|
|
967
|
-
e.uniform1f(n.uWetEdge, o.wetEdge), e.uniform1f(n.uGranulation, o.granulation), e.uniform1f(n.uImpasto, o.impasto), e.uniform1f(n.uBrokenColor, o.brokenColor), e.uniform1f(n.uCanvasGrain, o.canvasGrain), e.uniform1f(n.uMetalPolish, o.metalPolish ?? 1), e.uniform1f(n.uMetalHeightScale, o.metalHeightScale ?? 1), e.uniform1f(n.uNucleiDrift, o.nucleiDrift), e.uniform1f(n.uPaletteDrift, o.paletteDrift), e.uniform1f(n.uBreathDepth, o.breathDepth), e.uniform1f(n.uBreathPeriod, o.breathPeriod), e.uniform1f(n.uSaturation, o.saturation), e.uniform1f(n.uPaperGrain, o.paperGrain), e.uniform1f(n.uAlpha, r ? 1 : o.alpha), e.uniform1f(n.uVividness, o.vividness ?? 1), e.uniform1i(n.uImage, 0), e.uniform1f(n.uBlurMin, o.imageBlur?.min ?? .004), e.uniform1f(n.uBlurMax, o.imageBlur?.max ?? .06);
|
|
968
|
-
let l = e.drawingBufferHeight > 0 ? e.drawingBufferWidth / e.drawingBufferHeight : 1;
|
|
969
|
-
e.uniform1f(n.uImageAspect, l);
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
|
-
//#endregion
|
|
973
|
-
//#region src/components/aurora/composables/glSetup.ts
|
|
974
|
-
var K = "[Aurora]", yt = /* @__PURE__ */ "uTime.uPalette.uStopCount.uNucleiCount.uNucleiPos.uNucleiRadius.uNucleiPaletteBias.uNucleiValueBias.uNucleiDriftRadius.uNucleiDriftPhase.uNucleiElong.uNucleiAngle.uSoftmaxBeta.uValueVariance.uWarpAmount.uWarpScale.uWarpDrift.uWarpMode.uNoiseOctaves.uMedium.uHuePath.uFlowPattern.uFlowFocal.uFlowAngle.uFlowCurl.uCursor.uCursorStrength.uCursorRadius.uStrokeAmount.uStrokeScale.uStrokeAnisotropy.uStrokeLayers.uStrokeMode.uStrokeOrient.uLightDir.uLightColor.uWetEdge.uGranulation.uImpasto.uBrokenColor.uCanvasGrain.uMetalPolish.uMetalHeightScale.uNucleiDrift.uPaletteDrift.uBreathDepth.uBreathPeriod.uSaturation.uPaperGrain.uAlpha.uVividness.uImage.uBlurMin.uBlurMax.uImageAspect".split(".");
|
|
975
|
-
function bt(e, t, n) {
|
|
976
|
-
let r = v(e, e.VERTEX_SHADER, t, K), i = v(e, e.FRAGMENT_SHADER, n, K), a = b(e, r, i, K);
|
|
977
|
-
e.useProgram(a);
|
|
978
|
-
let o = e.createVertexArray();
|
|
979
|
-
e.bindVertexArray(o);
|
|
980
|
-
let s = e.createBuffer();
|
|
981
|
-
e.bindBuffer(e.ARRAY_BUFFER, s), e.bufferData(e.ARRAY_BUFFER, new Float32Array([
|
|
982
|
-
-1,
|
|
983
|
-
-1,
|
|
984
|
-
3,
|
|
985
|
-
-1,
|
|
986
|
-
-1,
|
|
987
|
-
3
|
|
988
|
-
]), e.STATIC_DRAW);
|
|
989
|
-
let c = e.getAttribLocation(a, "aPos");
|
|
990
|
-
e.enableVertexAttribArray(c), e.vertexAttribPointer(c, 2, e.FLOAT, !1, 0, 0);
|
|
991
|
-
let l = {};
|
|
992
|
-
for (let t of yt) l[t] = e.getUniformLocation(a, t);
|
|
993
|
-
return {
|
|
994
|
-
program: a,
|
|
995
|
-
vs: r,
|
|
996
|
-
fs: i,
|
|
997
|
-
uniforms: l,
|
|
998
|
-
geometry: {
|
|
999
|
-
vao: o,
|
|
1000
|
-
buf: s
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
}
|
|
1004
|
-
function xt(e) {
|
|
1005
|
-
return (t) => {
|
|
1006
|
-
let n = e.getConfig().source === "image", { program: r, vs: i, fs: a, uniforms: o, geometry: s } = bt(t, Se, n ? Fe : Pe), c = n ? be(t, r, e.imageCoordinator) : null, l = (e) => {
|
|
1007
|
-
t.viewport(0, 0, e.w, e.h), t.useProgram(r);
|
|
1008
|
-
}, u = vt(t, r, o, e.opaquePresentation), d = (e) => u(e);
|
|
1009
|
-
e.registerConfigUploader(d), d(e.getConfig());
|
|
1010
|
-
let f = We({
|
|
1011
|
-
gl: t,
|
|
1012
|
-
prog: r,
|
|
1013
|
-
uniforms: o,
|
|
1014
|
-
pointerField: e.pointerField,
|
|
1015
|
-
getCursorScalars: e.getCursorScalars,
|
|
1016
|
-
getConfig: e.getConfig,
|
|
1017
|
-
getReducedMotion: e.getReducedMotion,
|
|
1018
|
-
getRenderTime: e.getRenderTime
|
|
1019
|
-
});
|
|
1020
|
-
return t.clearColor(0, 0, 0, +!!e.opaquePresentation), t.disable(t.DEPTH_TEST), e.opaquePresentation ? t.disable(t.BLEND) : (t.enable(t.BLEND), t.blendFunc(t.ONE, t.ONE_MINUS_SRC_ALPHA)), {
|
|
1021
|
-
frame: f.frame,
|
|
1022
|
-
shouldContinue: f.needsAnimation,
|
|
1023
|
-
resize: l,
|
|
1024
|
-
teardown: () => {
|
|
1025
|
-
e.registerConfigUploader(null), t.deleteProgram(r), t.deleteShader(i), t.deleteShader(a), t.deleteBuffer(s.buf), t.deleteVertexArray(s.vao), c?.();
|
|
1026
|
-
}
|
|
1027
|
-
};
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1030
|
-
//#endregion
|
|
1031
|
-
//#region src/components/aurora/constants/shaders/aurora.wgsl.ts
|
|
1032
|
-
var St = `
|
|
1033
|
-
const MAX_NUCLEI: i32 = 8;
|
|
1034
|
-
const MAX_STOPS: i32 = 8;
|
|
1035
|
-
const PI: f32 = 3.141592653589793;
|
|
1036
|
-
|
|
1037
|
-
// ── Uniforms (the typed-struct source-of-truth — see aurora.wgsl.uniforms.ts) ──
|
|
1038
|
-
// Scalars are packed into vec4 lanes to keep the std140/WGSL 16-byte struct alignment
|
|
1039
|
-
// trivial. nuc0[i] = (pos.x, pos.y, radius, paletteBias); nuc1[i] = (valueBias,
|
|
1040
|
-
// driftRadius, driftPhase, elong); nuc2[i] = (angle, _, _, _). palette[i].rgb is the
|
|
1041
|
-
// CPU-baked linear-sRGB stop.
|
|
1042
|
-
struct Uniforms {
|
|
1043
|
-
// scalars0: (uTime, uSoftmaxBeta, uValueVariance, uWarpAmount)
|
|
1044
|
-
scalars0: vec4<f32>,
|
|
1045
|
-
// scalars1: (uWarpScale, uWarpDrift, uSaturation, uPaperGrain)
|
|
1046
|
-
scalars1: vec4<f32>,
|
|
1047
|
-
// scalars2: (uAlpha, uNucleiDrift, uPaletteDrift, uBreathDepth)
|
|
1048
|
-
scalars2: vec4<f32>,
|
|
1049
|
-
// scalars3: (uBreathPeriod, uCursorStrength, uCursorRadius, uVividness)
|
|
1050
|
-
// The .w pad lane now carries the chroma-floor strength.
|
|
1051
|
-
scalars3: vec4<f32>,
|
|
1052
|
-
// cursor: (uCursor.x, uCursor.y, uMetalPolish, uMetalHeightScale)
|
|
1053
|
-
// The two free pad lanes carry the metal-medium knobs (the
|
|
1054
|
-
// metal light is cursor-synthesized so it reads in-struct on the WGSL primary too).
|
|
1055
|
-
cursor: vec4<f32>,
|
|
1056
|
-
// ints: (uStopCount, uNucleiCount, uWarpMode, uNoiseOctaves)
|
|
1057
|
-
ints0: vec4<i32>,
|
|
1058
|
-
// ints1: (uMedium, uHuePath, _, _)
|
|
1059
|
-
ints1: vec4<i32>,
|
|
1060
|
-
palette: array<vec4<f32>, 8>,
|
|
1061
|
-
nuc0: array<vec4<f32>, 8>,
|
|
1062
|
-
nuc1: array<vec4<f32>, 8>,
|
|
1063
|
-
nuc2: array<vec4<f32>, 8>,
|
|
1064
|
-
// The painterly-medium scalar lanes are appended after the
|
|
1065
|
-
// arrays so EVERY existing offset (and the smooth-default parity capture) is
|
|
1066
|
-
// byte-identical (these lanes are written 0 on a smooth config). scalars4:
|
|
1067
|
-
// (uStrokeAmount, uStrokeScale, uStrokeAnisotropy, uCanvasGrain). scalars5:
|
|
1068
|
-
// (uWetEdge, uGranulation, uBrokenColor, uKuwaharaQ). kuwahara: (uKuwaharaRadius,
|
|
1069
|
-
// uKuwaharaSectors, _, _) — the Kuwahara radius/sectors/q in lockstep with
|
|
1070
|
-
// packAuroraWGPUUniforms (the typed-struct discipline).
|
|
1071
|
-
scalars4: vec4<f32>,
|
|
1072
|
-
scalars5: vec4<f32>,
|
|
1073
|
-
kuwahara: vec4<f32>,
|
|
1074
|
-
};
|
|
1075
|
-
|
|
1076
|
-
@group(0) @binding(0) var<uniform> u: Uniforms;
|
|
1077
|
-
|
|
1078
|
-
// ── Authoring-scale → rad/sec lifts (byte-identical to aurora.frag.ts) ──
|
|
1079
|
-
const K_NUCLEI: f32 = 14.0;
|
|
1080
|
-
const K_PAL: f32 = 24.0;
|
|
1081
|
-
const K_WARP: f32 = 5.0;
|
|
1082
|
-
|
|
1083
|
-
// ── Noise (Aurora-local hash21/vnoise/fbm, deliberately distinct) ──────────
|
|
1084
|
-
fn hash21(p0: vec2<f32>) -> f32 {
|
|
1085
|
-
var p = fract(p0 * vec2<f32>(123.34, 456.21));
|
|
1086
|
-
p = p + dot(p, p + 45.32);
|
|
1087
|
-
return fract(p.x * p.y);
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
fn hash22(p0: vec2<f32>) -> vec2<f32> {
|
|
1091
|
-
let p = vec2<f32>(dot(p0, vec2<f32>(127.1, 311.7)),
|
|
1092
|
-
dot(p0, vec2<f32>(269.5, 183.3)));
|
|
1093
|
-
return fract(sin(p) * 43758.5453);
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
fn vnoise(p: vec2<f32>) -> f32 {
|
|
1097
|
-
let i = floor(p);
|
|
1098
|
-
let f = fract(p);
|
|
1099
|
-
let uu = f * f * (3.0 - 2.0 * f);
|
|
1100
|
-
let a = hash21(i);
|
|
1101
|
-
let b = hash21(i + vec2<f32>(1.0, 0.0));
|
|
1102
|
-
let c = hash21(i + vec2<f32>(0.0, 1.0));
|
|
1103
|
-
let d = hash21(i + vec2<f32>(1.0, 1.0));
|
|
1104
|
-
return mix(mix(a, b, uu.x), mix(c, d, uu.x), uu.y);
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
${D}
|
|
1108
|
-
|
|
1109
|
-
fn fbm(p0: vec2<f32>) -> f32 {
|
|
1110
|
-
var v = 0.0;
|
|
1111
|
-
var a = 0.5;
|
|
1112
|
-
var p = p0;
|
|
1113
|
-
let octaves = u.ints0.w;
|
|
1114
|
-
for (var i = 0; i < 5; i = i + 1) {
|
|
1115
|
-
if (i >= octaves) { break; }
|
|
1116
|
-
v = v + a * vnoise(p);
|
|
1117
|
-
p = FBM_ROT * p * 2.02;
|
|
1118
|
-
a = a * 0.5;
|
|
1119
|
-
}
|
|
1120
|
-
return v;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
fn potentialFBM(p: vec2f) -> f32 { return fbm(p); }
|
|
1124
|
-
|
|
1125
|
-
const CURL_EPS: f32 = 0.012;
|
|
1126
|
-
|
|
1127
|
-
// ∇×ψ in 2D — the divergence-free flow direction. Central finite differences of the
|
|
1128
|
-
// scalar potential give the partials; the cross-pairing (∂y, −∂x) is the 2D curl.
|
|
1129
|
-
fn curlFBM(p: vec2f) -> vec2f {
|
|
1130
|
-
let dx = potentialFBM(p + vec2f(CURL_EPS, 0.0)) - potentialFBM(p - vec2f(CURL_EPS, 0.0));
|
|
1131
|
-
let dy = potentialFBM(p + vec2f(0.0, CURL_EPS)) - potentialFBM(p - vec2f(0.0, CURL_EPS));
|
|
1132
|
-
// ψ-gradient is (dx, dy)/(2·eps); the curl rotates it 90°: (∂ψ/∂y, −∂ψ/∂x).
|
|
1133
|
-
let g = vec2f(dx, dy) / (2.0 * CURL_EPS);
|
|
1134
|
-
return vec2f(g.y, -g.x);
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
${w}
|
|
1139
|
-
${E}
|
|
1140
|
-
${C}
|
|
1141
|
-
|
|
1142
|
-
// Interleaved Gradient Noise (Jimenez) — display-space 1-LSB dither.
|
|
1143
|
-
fn ign(p: vec2<f32>) -> f32 {
|
|
1144
|
-
return fract(52.9829189 * fract(dot(p, vec2<f32>(0.06711056, 0.00583715))));
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
// Cellular, Worley f1.
|
|
1148
|
-
fn cellular(p: vec2<f32>) -> f32 {
|
|
1149
|
-
let i = floor(p);
|
|
1150
|
-
let f = fract(p);
|
|
1151
|
-
var m = 1e9;
|
|
1152
|
-
for (var y = -1; y <= 1; y = y + 1) {
|
|
1153
|
-
for (var x = -1; x <= 1; x = x + 1) {
|
|
1154
|
-
let g = vec2<f32>(f32(x), f32(y));
|
|
1155
|
-
let o = hash22(i + g);
|
|
1156
|
-
let r = g + o - f;
|
|
1157
|
-
m = min(m, dot(r, r));
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
return sqrt(m);
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
// ── Warp (Quilez double warp + the four warp modes + the cursor swirl) ──
|
|
1164
|
-
fn domainWarp(p: vec2<f32>, t: f32) -> vec2<f32> {
|
|
1165
|
-
let warpScale = u.scalars1.x;
|
|
1166
|
-
let warpDrift = u.scalars1.y;
|
|
1167
|
-
let warpAmount = u.scalars0.w;
|
|
1168
|
-
let warpMode = u.ints0.z;
|
|
1169
|
-
let cursorStrength = u.scalars3.y;
|
|
1170
|
-
let cursorRadius = u.scalars3.z;
|
|
1171
|
-
let cursor = u.cursor.xy;
|
|
1172
|
-
|
|
1173
|
-
let q = vec2<f32>(fbm(p * warpScale + vec2<f32>(0.0, 0.0) + t * warpDrift * K_WARP),
|
|
1174
|
-
fbm(p * warpScale + vec2<f32>(5.2, 1.3) + t * warpDrift * K_WARP));
|
|
1175
|
-
let r = vec2<f32>(fbm(p * warpScale + 4.0 * q + vec2<f32>(1.7, 9.2)),
|
|
1176
|
-
fbm(p * warpScale + 4.0 * q + vec2<f32>(8.3, 2.8)));
|
|
1177
|
-
|
|
1178
|
-
var warp = r;
|
|
1179
|
-
if (warpMode == 1) {
|
|
1180
|
-
// cellular — chunky territories
|
|
1181
|
-
let c1 = cellular(p * warpScale * 1.5 + vec2<f32>(t * warpDrift * K_WARP * 2.0, 0.0));
|
|
1182
|
-
let c2 = cellular(p * warpScale * 1.5 + vec2<f32>(11.0, 7.0 + t * warpDrift * K_WARP * 2.0));
|
|
1183
|
-
warp = vec2<f32>(c1, c2);
|
|
1184
|
-
} else if (warpMode == 2) {
|
|
1185
|
-
// hybrid — fbm + cellular averaged
|
|
1186
|
-
let c1 = cellular(p * warpScale * 1.2);
|
|
1187
|
-
let c2 = cellular(p * warpScale * 1.2 + vec2<f32>(11.0, 7.0));
|
|
1188
|
-
warp = mix(r, vec2<f32>(c1, c2), 0.5);
|
|
1189
|
-
} else if (warpMode == 3) {
|
|
1190
|
-
let fp = p * warpScale + vec2<f32>(t * warpDrift * K_WARP);
|
|
1191
|
-
warp = curlFBM(fp);
|
|
1192
|
-
}
|
|
1193
|
-
var warped = p + warpAmount * warp;
|
|
1194
|
-
|
|
1195
|
-
// Cursor swirl — rotate p around the cursor with radial falloff.
|
|
1196
|
-
if (cursorStrength > 0.001) {
|
|
1197
|
-
let toP = p - cursor;
|
|
1198
|
-
let d = length(toP);
|
|
1199
|
-
let rr = max(cursorRadius, 0.01);
|
|
1200
|
-
let w = exp(-(d * d) / (rr * rr * 0.45));
|
|
1201
|
-
let ang = w * cursorStrength * 2.1;
|
|
1202
|
-
let ca = cos(ang);
|
|
1203
|
-
let sa = sin(ang);
|
|
1204
|
-
var rotated = vec2<f32>(ca * toP.x - sa * toP.y, sa * toP.x + ca * toP.y) + cursor;
|
|
1205
|
-
let pinch = w * cursorStrength * 0.08;
|
|
1206
|
-
rotated = mix(rotated, cursor, pinch);
|
|
1207
|
-
warped = mix(warped, rotated + warpAmount * warp * 0.7, w * cursorStrength);
|
|
1208
|
-
}
|
|
1209
|
-
return warped;
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
// ── Palette LUT ──
|
|
1213
|
-
fn samplePalette(id0: f32) -> vec3<f32> {
|
|
1214
|
-
let id = clamp(id0, 0.0, 1.0);
|
|
1215
|
-
let stopCount = u.ints0.x;
|
|
1216
|
-
let scaled = id * f32(stopCount - 1);
|
|
1217
|
-
let i0 = i32(floor(scaled));
|
|
1218
|
-
let i1 = min(i0 + 1, stopCount - 1);
|
|
1219
|
-
let t = fract(scaled);
|
|
1220
|
-
return samplePaletteRamp(u.palette[i0].rgb, u.palette[i1].rgb, t, u.ints1.y);
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
// ── Nuclei field (anisotropic Gaussian softmax + drift + palette drift) ──
|
|
1224
|
-
struct NucleiResult { paletteId: f32, valueMod: f32 };
|
|
1225
|
-
|
|
1226
|
-
fn nucleiField(p: vec2<f32>, t: f32) -> NucleiResult {
|
|
1227
|
-
let nucleiCount = u.ints0.y;
|
|
1228
|
-
let nucleiDrift = u.scalars2.y;
|
|
1229
|
-
let paletteDrift = u.scalars2.z;
|
|
1230
|
-
let softmaxBeta = u.scalars0.y;
|
|
1231
|
-
|
|
1232
|
-
var accumBias = 0.0;
|
|
1233
|
-
var accumValue = 0.0;
|
|
1234
|
-
var accumW = 0.0;
|
|
1235
|
-
for (var i = 0; i < MAX_NUCLEI; i = i + 1) {
|
|
1236
|
-
if (i >= nucleiCount) { break; }
|
|
1237
|
-
let n0 = u.nuc0[i]; // pos.x, pos.y, radius, paletteBias
|
|
1238
|
-
let n1 = u.nuc1[i]; // valueBias, driftRadius, driftPhase, elong
|
|
1239
|
-
let angle = u.nuc2[i].x;
|
|
1240
|
-
let driftRadius = n1.y;
|
|
1241
|
-
let driftPhase = n1.z;
|
|
1242
|
-
let posI = n0.xy + driftRadius * vec2<f32>(
|
|
1243
|
-
cos(t * nucleiDrift * K_NUCLEI + driftPhase),
|
|
1244
|
-
sin(t * nucleiDrift * K_NUCLEI + driftPhase * 1.13)
|
|
1245
|
-
);
|
|
1246
|
-
let diff = p - posI;
|
|
1247
|
-
let ca = cos(angle);
|
|
1248
|
-
let sa = sin(angle);
|
|
1249
|
-
let local = vec2<f32>(ca * diff.x + sa * diff.y, -sa * diff.x + ca * diff.y);
|
|
1250
|
-
let along = local.x / max(n1.w, 0.01);
|
|
1251
|
-
let across = local.y;
|
|
1252
|
-
let d2 = along * along + across * across;
|
|
1253
|
-
let r = max(n0.z, 0.01);
|
|
1254
|
-
let w = exp(-softmaxBeta * d2 / (r * r));
|
|
1255
|
-
accumBias = accumBias + w * n0.w;
|
|
1256
|
-
accumValue = accumValue + w * n1.x;
|
|
1257
|
-
accumW = accumW + w;
|
|
1258
|
-
}
|
|
1259
|
-
var paletteId = accumBias / max(accumW, 1e-4);
|
|
1260
|
-
let valueMod = accumValue / max(accumW, 1e-4);
|
|
1261
|
-
|
|
1262
|
-
let palAmp = clamp(paletteDrift * 6.0, 0.0, 0.06);
|
|
1263
|
-
paletteId = paletteId + palAmp * sin(t * paletteDrift * K_PAL);
|
|
1264
|
-
paletteId = clamp(paletteId, 0.0, 1.0);
|
|
1265
|
-
return NucleiResult(paletteId, valueMod);
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
// ── Color utils (OKLCh saturation) ──
|
|
1269
|
-
fn linOklab(lin: vec3<f32>) -> vec3<f32> {
|
|
1270
|
-
let lms = LINEAR_SRGB_TO_LMS * lin;
|
|
1271
|
-
return LMS_TO_OKLAB * cbrt3(lms);
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
fn saturate3(c: vec3<f32>, amt: f32) -> vec3<f32> {
|
|
1275
|
-
var lch = oklabToOklch(linOklab(c));
|
|
1276
|
-
lch.y = max(lch.y * amt, 0.0);
|
|
1277
|
-
return max(oklabToLinearSrgb(oklchToOklab(lch)), vec3<f32>(0.0));
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
// The chroma floor, the WGSL twin of the GLSL vividnessFloor.
|
|
1281
|
-
// OKLab chroma lifted toward the floor, hue + L preserved; below VIVID_EPS the (a,b)
|
|
1282
|
-
// direction is precision noise so the lift synthesizes along the WARM anchor (amber,
|
|
1283
|
-
// both components positive) — never teal/navy. vividness (scalars3.w) == 0 is a no-op
|
|
1284
|
-
// (the byte-identity opt-out). Mode factor lifts a dim field a touch (read through glass).
|
|
1285
|
-
const VIVID_TARGET: f32 = 0.115;
|
|
1286
|
-
const VIVID_EPS: f32 = 0.012;
|
|
1287
|
-
const VIVID_WARM_ANCHOR: vec2<f32> = vec2<f32>(0.34202, 0.93969);
|
|
1288
|
-
fn vividnessFloor(c: vec3<f32>, vividness: f32) -> vec3<f32> {
|
|
1289
|
-
if (vividness <= 0.0001) { return c; }
|
|
1290
|
-
var lab = linOklab(c);
|
|
1291
|
-
let C = length(lab.yz);
|
|
1292
|
-
let modeLift = mix(1.18, 1.0, clamp(lab.x * 1.4, 0.0, 1.0));
|
|
1293
|
-
let Cmin = vividness * VIVID_TARGET * modeLift;
|
|
1294
|
-
var hueDir = VIVID_WARM_ANCHOR;
|
|
1295
|
-
if (C > VIVID_EPS) { hueDir = lab.yz / C; }
|
|
1296
|
-
let yz = hueDir * max(C, Cmin);
|
|
1297
|
-
lab = vec3<f32>(lab.x, yz.x, yz.y);
|
|
1298
|
-
return max(oklabToLinearSrgb(lab), vec3<f32>(0.0));
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
// ── PBR-Neutral tonemap (named aces() in the GLSL — the tonemap slot) ──
|
|
1302
|
-
fn aces(color0: vec3<f32>) -> vec3<f32> {
|
|
1303
|
-
let startCompression = 0.8 - 0.04;
|
|
1304
|
-
let desaturation = 0.15;
|
|
1305
|
-
var color = color0;
|
|
1306
|
-
let x = min(color.r, min(color.g, color.b));
|
|
1307
|
-
var offset = 0.04;
|
|
1308
|
-
if (x < 0.08) { offset = x - 6.25 * x * x; }
|
|
1309
|
-
color = color - offset;
|
|
1310
|
-
let peak = max(color.r, max(color.g, color.b));
|
|
1311
|
-
if (peak < startCompression) { return clamp(color, vec3<f32>(0.0), vec3<f32>(1.0)); }
|
|
1312
|
-
let d = 1.0 - startCompression;
|
|
1313
|
-
let newPeak = 1.0 - d * d / (peak + d - startCompression);
|
|
1314
|
-
color = color * (newPeak / peak);
|
|
1315
|
-
let g = 1.0 - 1.0 / (desaturation * (peak - newPeak) + 1.0);
|
|
1316
|
-
return clamp(mix(color, newPeak * vec3<f32>(1.0), g), vec3<f32>(0.0), vec3<f32>(1.0));
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
// ── Painterly-medium bodies (the keystone WGSL port) ───────────────────────
|
|
1320
|
-
// Spliced HERE, after every helper the mediums consume is defined (domainWarp,
|
|
1321
|
-
// nucleiField, samplePalette, linOklab, saturate3, oklabToOklch/oklchToOklab,
|
|
1322
|
-
// hash21/vnoise/fbm) and before the vertex/fragment stages. applyMedium(col,p,t)
|
|
1323
|
-
// is the dispatch the fragment stage calls.
|
|
1324
|
-
|
|
1325
|
-
// ── Painterly luma + medium scalar accessors ───────────────────────────────
|
|
1326
|
-
const W_LUMA: vec3<f32> = vec3<f32>(0.2126, 0.7152, 0.0722);
|
|
1327
|
-
|
|
1328
|
-
fn mStrokeAmount() -> f32 { return u.scalars4.x; }
|
|
1329
|
-
fn mStrokeScale() -> f32 { return u.scalars4.y; }
|
|
1330
|
-
fn mStrokeAnisotropy() -> f32 { return u.scalars4.z; }
|
|
1331
|
-
fn mCanvasGrain() -> f32 { return u.scalars4.w; }
|
|
1332
|
-
fn mWetEdge() -> f32 { return u.scalars5.x; }
|
|
1333
|
-
fn mGranulation() -> f32 { return u.scalars5.y; }
|
|
1334
|
-
fn mBrokenColor() -> f32 { return u.scalars5.z; }
|
|
1335
|
-
fn mKuwaharaQ() -> f32 { return u.scalars5.w; }
|
|
1336
|
-
fn mKuwaharaRadius() -> f32 { return u.kuwahara.x; }
|
|
1337
|
-
// The metal-medium knobs ride the free cursor.z/.w pad lanes
|
|
1338
|
-
// (uniformBridgeWGPU packs them; written 0 on a non-metal config → no-op). These read
|
|
1339
|
-
// the IN-STRUCT cursor — the metal light is cursor-synthesized so it crosses to WGSL
|
|
1340
|
-
// (a phantom uLightDir read would be flat on the primary; uLightDir is fragment-only).
|
|
1341
|
-
fn mMetalPolish() -> f32 { return u.cursor.z; }
|
|
1342
|
-
fn mMetalHeightScale() -> f32 { return u.cursor.w; }
|
|
1343
|
-
|
|
1344
|
-
// ── Gradient pack (the WGSL twin) ──────────────────────────────────────────
|
|
1345
|
-
// structureTensorField re-plumbs its already-computed luma gradient (Gx,Gy) out
|
|
1346
|
-
// through the return value's .w lane so the metal medium pays ZERO extra taps. 12 bits per
|
|
1347
|
-
// bounded component ([-4,4]) fit into one f32; the crayon/kuwahara callers read only .xy/.z.
|
|
1348
|
-
fn packGrad(gx: f32, gy: f32) -> f32 {
|
|
1349
|
-
let qx = floor(clamp(gx * 0.125 + 0.5, 0.0, 1.0) * 4095.0);
|
|
1350
|
-
let qy = floor(clamp(gy * 0.125 + 0.5, 0.0, 1.0) * 4095.0);
|
|
1351
|
-
return qx + qy * 4096.0;
|
|
1352
|
-
}
|
|
1353
|
-
fn unpackGrad(packed: f32) -> vec2<f32> {
|
|
1354
|
-
let qy = floor(packed * (1.0 / 4096.0));
|
|
1355
|
-
let qx = packed - qy * 4096.0;
|
|
1356
|
-
return (vec2<f32>(qx, qy) * (1.0 / 4095.0) - 0.5) * 8.0;
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
// ── Base color re-sample (the edge-mask operator the mediums Sobel/sector-sample) ──
|
|
1360
|
-
// The WGSL twin of mediums.glsl.ts sampleBase: warp -> nuclei field -> palette -> value.
|
|
1361
|
-
fn sampleBase(p: vec2<f32>, t: f32) -> vec3<f32> {
|
|
1362
|
-
let pw = domainWarp(p, t);
|
|
1363
|
-
let nf = nucleiField(pw, t);
|
|
1364
|
-
var c = samplePalette(nf.paletteId);
|
|
1365
|
-
c = c * (1.0 + u.scalars0.z * nf.valueMod);
|
|
1366
|
-
return c;
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
// ── Broken color (hue + chroma jitter at constant OKLCh L) ──────────────────
|
|
1370
|
-
fn brokenColorJitter(c: vec3<f32>, hueSeed: f32, valueSeed: f32, strength: f32) -> vec3<f32> {
|
|
1371
|
-
let amt = clamp(mBrokenColor() * strength, 0.0, 1.0);
|
|
1372
|
-
if (amt <= 0.001) { return c; }
|
|
1373
|
-
var lch = oklabToOklch(linOklab(c));
|
|
1374
|
-
lch.z = lch.z + (hueSeed - 0.5) * (32.0 * PI / 180.0) * amt;
|
|
1375
|
-
lch.y = max(lch.y * (1.0 + (valueSeed - 0.5) * 0.28 * amt), 0.0);
|
|
1376
|
-
return max(oklabToLinearSrgb(oklchToOklab(lch)), vec3<f32>(0.0));
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
// ── Structure tensor / edge-tangent flow (the WGSL twin) ───────────────────
|
|
1380
|
-
// Returns vec4(tangent.x, tangent.y, A, packGrad(Gx,Gy)) — the minor-eigenvector
|
|
1381
|
-
// edge-tangent + coherence + the metal medium's packed gradient. The .xy/.z
|
|
1382
|
-
// crayon/kuwahara callers are byte-unchanged.
|
|
1383
|
-
fn structureTensorField(p: vec2<f32>, t: f32, fallbackDir: vec2<f32>) -> vec4<f32> {
|
|
1384
|
-
let e = 0.0035;
|
|
1385
|
-
let l00 = dot(sampleBase(p + vec2<f32>(-e, -e), t), W_LUMA);
|
|
1386
|
-
let l10 = dot(sampleBase(p + vec2<f32>(0.0, -e), t), W_LUMA);
|
|
1387
|
-
let l20 = dot(sampleBase(p + vec2<f32>( e, -e), t), W_LUMA);
|
|
1388
|
-
let l01 = dot(sampleBase(p + vec2<f32>(-e, 0.0), t), W_LUMA);
|
|
1389
|
-
let l21 = dot(sampleBase(p + vec2<f32>( e, 0.0), t), W_LUMA);
|
|
1390
|
-
let l02 = dot(sampleBase(p + vec2<f32>(-e, e), t), W_LUMA);
|
|
1391
|
-
let l12 = dot(sampleBase(p + vec2<f32>(0.0, e), t), W_LUMA);
|
|
1392
|
-
let l22 = dot(sampleBase(p + vec2<f32>( e, e), t), W_LUMA);
|
|
1393
|
-
let Gx = (l20 + 2.0 * l21 + l22) - (l00 + 2.0 * l01 + l02);
|
|
1394
|
-
let Gy = (l02 + 2.0 * l12 + l22) - (l00 + 2.0 * l10 + l20);
|
|
1395
|
-
let Jxx = Gx * Gx;
|
|
1396
|
-
let Jyy = Gy * Gy;
|
|
1397
|
-
let Jxy = Gx * Gy;
|
|
1398
|
-
let tr = Jxx + Jyy;
|
|
1399
|
-
let disc = sqrt(max((Jxx - Jyy) * (Jxx - Jyy) + 4.0 * Jxy * Jxy, 0.0));
|
|
1400
|
-
let lambdaMaj = 0.5 * (tr + disc);
|
|
1401
|
-
let lambdaMin = 0.5 * (tr - disc);
|
|
1402
|
-
var tangent: vec2<f32>;
|
|
1403
|
-
if (disc < 1e-7) {
|
|
1404
|
-
tangent = fallbackDir;
|
|
1405
|
-
} else {
|
|
1406
|
-
let theta = 0.5 * atan2(2.0 * Jxy, Jxx - Jyy);
|
|
1407
|
-
tangent = vec2<f32>(-sin(theta), cos(theta));
|
|
1408
|
-
}
|
|
1409
|
-
var A = (lambdaMaj - lambdaMin) / (lambdaMaj + lambdaMin + 1e-6);
|
|
1410
|
-
A = clamp(A, 0.0, 1.0);
|
|
1411
|
-
if (dot(tangent, fallbackDir) < 0.0) { tangent = -tangent; }
|
|
1412
|
-
let blendW = pow(A, 0.28);
|
|
1413
|
-
let dir = normalize(mix(fallbackDir, tangent, blendW) + vec2<f32>(1e-6, 1e-6));
|
|
1414
|
-
return vec4<f32>(dir, A, packGrad(Gx, Gy));
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
// ── Flow field (the WGSL twin — the simple flow seed the medium fallback dirs use) ──
|
|
1418
|
-
fn flowField(p: vec2<f32>, t: f32) -> vec2<f32> {
|
|
1419
|
-
// Curl-noise-driven swirl (the medium-default dir; the full radial/swirl/diagonal
|
|
1420
|
-
// dispatch rides uniforms the WGSL struct does not carry — the procedural mediums
|
|
1421
|
-
// use this multi/curl seed as the fallback the structure tensor relaxes toward).
|
|
1422
|
-
let n = fbm(p * 2.0 + vec2<f32>(t * 0.02, t * 0.02));
|
|
1423
|
-
let a = n * 6.2831853;
|
|
1424
|
-
var dir = vec2<f32>(cos(a), sin(a));
|
|
1425
|
-
// Cursor swirl bias (matches the GLSL flow cursor term — the steady attraction).
|
|
1426
|
-
let cursorStrength = u.scalars3.y;
|
|
1427
|
-
let cursorRadius = u.scalars3.z;
|
|
1428
|
-
let cursor = u.cursor.xy;
|
|
1429
|
-
if (cursorStrength > 0.001) {
|
|
1430
|
-
let toCur = cursor - p;
|
|
1431
|
-
let d = length(toCur);
|
|
1432
|
-
let r = max(cursorRadius, 0.01);
|
|
1433
|
-
let w = exp(-(d * d) / (r * r * 0.5));
|
|
1434
|
-
let tangent = vec2<f32>(-toCur.y, toCur.x) / max(d, 1e-4);
|
|
1435
|
-
let a0 = atan2(dir.y, dir.x);
|
|
1436
|
-
let a1 = atan2(tangent.y, tangent.x);
|
|
1437
|
-
var da = a1 - a0;
|
|
1438
|
-
da = atan2(sin(da), cos(da));
|
|
1439
|
-
let aa = a0 + da * w * cursorStrength;
|
|
1440
|
-
dir = vec2<f32>(cos(aa), sin(aa));
|
|
1441
|
-
}
|
|
1442
|
-
return dir;
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
// ── Watercolor — wet-edge cauliflowers + granulation + wash banding ─────────
|
|
1446
|
-
fn mediumWatercolor(col0: vec3<f32>, p: vec2<f32>, t: f32) -> vec3<f32> {
|
|
1447
|
-
var col = col0;
|
|
1448
|
-
let eps = 0.004;
|
|
1449
|
-
let cx1 = sampleBase(p + vec2<f32>(eps, 0.0), t);
|
|
1450
|
-
let cx2 = sampleBase(p - vec2<f32>(eps, 0.0), t);
|
|
1451
|
-
let cy1 = sampleBase(p + vec2<f32>(0.0, eps), t);
|
|
1452
|
-
let cy2 = sampleBase(p - vec2<f32>(0.0, eps), t);
|
|
1453
|
-
let gx = dot(cx1 - cx2, W_LUMA);
|
|
1454
|
-
let gy = dot(cy1 - cy2, W_LUMA);
|
|
1455
|
-
let edge = sqrt(gx * gx + gy * gy) / (2.0 * eps);
|
|
1456
|
-
let mask = smoothstep(0.0, 2.5, edge);
|
|
1457
|
-
col = col * mix(1.0, 0.78, mask * mWetEdge());
|
|
1458
|
-
|
|
1459
|
-
let paper = 0.5 * vnoise(p * 160.0) + 0.5 * vnoise(p * 360.0);
|
|
1460
|
-
let pigLoad = 1.0 - dot(col, W_LUMA);
|
|
1461
|
-
col = col * (1.0 - mGranulation() * pigLoad * (paper - 0.5));
|
|
1462
|
-
|
|
1463
|
-
let band = fbm(vec2<f32>(p.x * 1.5, p.y * 0.4));
|
|
1464
|
-
col = col * (1.0 + 0.04 * (band - 0.5));
|
|
1465
|
-
return col;
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
|
-
// ── Pastel — anisotropic stroke noise along the flow + tooth grain ──────────
|
|
1469
|
-
fn mediumPastel(col0: vec3<f32>, p: vec2<f32>, t: f32) -> vec3<f32> {
|
|
1470
|
-
var col = col0;
|
|
1471
|
-
let flow = flowField(p, t);
|
|
1472
|
-
let perp = vec2<f32>(-flow.y, flow.x);
|
|
1473
|
-
let strokeScale = mStrokeScale();
|
|
1474
|
-
let along = dot(p, flow) * strokeScale;
|
|
1475
|
-
var across = dot(p, perp) * strokeScale;
|
|
1476
|
-
across = across + 0.03 * (vnoise(p * 260.0) - 0.5);
|
|
1477
|
-
|
|
1478
|
-
let aniso = mix(1.0, 0.18, mStrokeAnisotropy());
|
|
1479
|
-
let stroke = fbm(vec2<f32>(along * aniso, across));
|
|
1480
|
-
col = col * mix(1.0, 0.82 + 0.32 * stroke, mStrokeAmount());
|
|
1481
|
-
|
|
1482
|
-
let tooth = vnoise(p * 800.0);
|
|
1483
|
-
col = col * (1.0 - 0.08 * mStrokeAmount() * (tooth - 0.5));
|
|
1484
|
-
return col;
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
// ── Crayon — DRY wax pigment on paper tooth (the tooth-multiply + scumble) ──
|
|
1488
|
-
fn mediumCrayon(col0: vec3<f32>, p: vec2<f32>, t: f32) -> vec3<f32> {
|
|
1489
|
-
let flow = structureTensorField(p, t, flowField(p, t)).xy;
|
|
1490
|
-
let ang = atan2(flow.y, flow.x);
|
|
1491
|
-
let ca = cos(-ang);
|
|
1492
|
-
let sa = sin(-ang);
|
|
1493
|
-
let pr = vec2<f32>(p.x * ca - p.y * sa, p.x * sa + p.y * ca);
|
|
1494
|
-
|
|
1495
|
-
let aniso = mix(0.45, 0.95, mStrokeAnisotropy());
|
|
1496
|
-
let scale = max(mStrokeScale() * 1.6, 180.0);
|
|
1497
|
-
|
|
1498
|
-
let t1 = vnoise(vec2<f32>(pr.x * scale * aniso, pr.y * scale));
|
|
1499
|
-
let t2 = vnoise(vec2<f32>(pr.x * scale * aniso * 0.4, pr.y * scale * 0.4) + vec2<f32>(11.0, 11.0));
|
|
1500
|
-
let t3 = vnoise(vec2<f32>(pr.x * scale * aniso * 2.1, pr.y * scale * 2.1) + vec2<f32>(23.0, 23.0));
|
|
1501
|
-
let tooth = 0.55 * t1 + 0.30 * t2 + 0.15 * t3;
|
|
1502
|
-
|
|
1503
|
-
let pressure = clamp(mStrokeAmount(), 0.0, 1.0);
|
|
1504
|
-
let bite = mix(0.18, 0.46, pressure);
|
|
1505
|
-
var result = col0 * (1.0 - bite * (0.5 - tooth));
|
|
1506
|
-
|
|
1507
|
-
let scumbleMask = smoothstep(0.42, 0.78, vnoise(vec2<f32>(pr.x * scale * 0.55, pr.y * scale * 0.22) + vec2<f32>(7.0, 7.0)));
|
|
1508
|
-
let scumbleCoverage = scumbleMask * pressure * 0.7;
|
|
1509
|
-
let paper = col0 * mix(0.80, 0.94, pressure);
|
|
1510
|
-
result = mix(paper, result, scumbleCoverage);
|
|
1511
|
-
|
|
1512
|
-
let pigmentCell = floor(pr * max(scale * 0.18, 32.0));
|
|
1513
|
-
let pigmentMask = smoothstep(0.28, 0.82, vnoise(pr * scale * 0.21 + vec2<f32>(19.0, 19.0)));
|
|
1514
|
-
result = brokenColorJitter(
|
|
1515
|
-
result,
|
|
1516
|
-
hash21(pigmentCell + vec2<f32>(17.0, 17.0)),
|
|
1517
|
-
hash21(pigmentCell * 2.1 + vec2<f32>(31.0, 31.0)),
|
|
1518
|
-
0.45 + 0.55 * pigmentMask
|
|
1519
|
-
);
|
|
1520
|
-
|
|
1521
|
-
result = saturate3(result, 1.08);
|
|
1522
|
-
return result;
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
// ── Kuwahara — the SOFT anisotropic generalized Kuwahara painterly finish ────
|
|
1526
|
-
// THE KEYSTONE (Kyprianidis 2010). Aurora is a PROCEDURAL field (no input texture) so the
|
|
1527
|
-
// operator runs over sampleBase directly: an elliptical kernel oriented along the structure
|
|
1528
|
-
// tensor (elongated along the edge-tangent, narrowed across by the anisotropy), 8 OVERLAPPING
|
|
1529
|
-
// sectors via SMOOTH gaussian-angular weights, blended by 1/(1+var^q) (the SOFT criterion →
|
|
1530
|
-
// no 8-spoke pinwheel by construction). 4 rings × 8 angular taps = 32 procedural samples.
|
|
1531
|
-
fn mediumKuwahara(col0: vec3<f32>, p: vec2<f32>, t: f32) -> vec3<f32> {
|
|
1532
|
-
let stf = structureTensorField(p, t, flowField(p, t));
|
|
1533
|
-
let tangent = stf.xy;
|
|
1534
|
-
let A = stf.z;
|
|
1535
|
-
// The studio knob drives the patch radius; clamp into the procedural patch band.
|
|
1536
|
-
let radius = clamp(mKuwaharaRadius() + mStrokeScale() * 0.00018, 0.006, 0.024);
|
|
1537
|
-
let aniso = mix(1.0, 0.34, clamp(A, 0.0, 1.0));
|
|
1538
|
-
let ax = tangent;
|
|
1539
|
-
let ay = vec2<f32>(-tangent.y, tangent.x);
|
|
1540
|
-
|
|
1541
|
-
// Per-sector weighted sums (8 sectors). WGSL has no runtime-indexed local arrays of
|
|
1542
|
-
// vectors as cleanly as GLSL, so unroll the sector accumulators explicitly.
|
|
1543
|
-
var mSum: array<vec3<f32>, 8>;
|
|
1544
|
-
var sSum: array<vec3<f32>, 8>;
|
|
1545
|
-
var wSum: array<f32, 8>;
|
|
1546
|
-
for (var i = 0; i < 8; i = i + 1) {
|
|
1547
|
-
mSum[i] = vec3<f32>(0.0);
|
|
1548
|
-
sSum[i] = vec3<f32>(0.0);
|
|
1549
|
-
wSum[i] = 0.0;
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
let RINGS = 4;
|
|
1553
|
-
let TAPS = 8;
|
|
1554
|
-
for (var r = 1; r <= RINGS; r = r + 1) {
|
|
1555
|
-
let rr = f32(r) / f32(RINGS);
|
|
1556
|
-
let radial = 1.0 - 0.6 * rr;
|
|
1557
|
-
for (var a = 0; a < TAPS; a = a + 1) {
|
|
1558
|
-
let ang = 6.2831853 * f32(a) / f32(TAPS);
|
|
1559
|
-
let dirE = ax * cos(ang) + ay * (sin(ang) * aniso);
|
|
1560
|
-
let off = dirE * (radius * rr);
|
|
1561
|
-
let c = sampleBase(p + off, t);
|
|
1562
|
-
for (var k = 0; k < 8; k = k + 1) {
|
|
1563
|
-
let sectorAng = 6.2831853 * f32(k) / 8.0;
|
|
1564
|
-
var d = ang - sectorAng;
|
|
1565
|
-
d = atan2(sin(d), cos(d));
|
|
1566
|
-
let sw = exp(-d * d * 2.2) * radial;
|
|
1567
|
-
mSum[k] = mSum[k] + c * sw;
|
|
1568
|
-
sSum[k] = sSum[k] + c * c * sw;
|
|
1569
|
-
wSum[k] = wSum[k] + sw;
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
let q = max(mKuwaharaQ(), 1.0);
|
|
1575
|
-
var accum = vec3<f32>(0.0);
|
|
1576
|
-
var accumW = 0.0;
|
|
1577
|
-
for (var k = 0; k < 8; k = k + 1) {
|
|
1578
|
-
let wk = max(wSum[k], 1e-4);
|
|
1579
|
-
let mean = mSum[k] / wk;
|
|
1580
|
-
let var3 = max(sSum[k] / wk - mean * mean, vec3<f32>(0.0));
|
|
1581
|
-
let variance = dot(var3, W_LUMA);
|
|
1582
|
-
let sectorW = 1.0 / (1.0 + pow(variance * 320.0, q));
|
|
1583
|
-
accum = accum + mean * sectorW;
|
|
1584
|
-
accumW = accumW + sectorW;
|
|
1585
|
-
}
|
|
1586
|
-
var result = accum / max(accumW, 1e-4);
|
|
1587
|
-
|
|
1588
|
-
// Anchor in near-flat zones so the smoothing only bites at edges.
|
|
1589
|
-
let center = sampleBase(p, t);
|
|
1590
|
-
result = mix(center, result, clamp(0.35 + 0.65 * A, 0.0, 1.0));
|
|
1591
|
-
|
|
1592
|
-
// Faint canvas tooth + pigment-saturation so the flattened patches read as oil paint.
|
|
1593
|
-
let tooth = vnoise(p * 300.0) - 0.5;
|
|
1594
|
-
result = result * (1.0 + tooth * 0.06 * mCanvasGrain());
|
|
1595
|
-
result = saturate3(result, 1.04);
|
|
1596
|
-
|
|
1597
|
-
return mix(col0, result, clamp(mStrokeAmount(), 0.0, 1.0));
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
// ── Metal — the two-term anisotropic BRDF (uMedium==8/9; the WGSL twin) ──────
|
|
1601
|
-
// The field re-lights as warm folded metal: the luma HEIGHT field (the packed
|
|
1602
|
-
// structure-tensor gradient → the surface normal) catches an anisotropic Blinn streak
|
|
1603
|
-
// (brushed metal, running ALONG the coherent edge-tangent) plus a sharp crest, both
|
|
1604
|
-
// raked by the IN-STRUCT cursor-synth light (crosses to WGSL — never uLightDir). The
|
|
1605
|
-
// catch is the achromatic-warm anchor (never a cold chrome-blue). ZERO extra taps —
|
|
1606
|
-
// the gradient is unpacked from the tensor's .w lane the caller already computed.
|
|
1607
|
-
const METAL_CATCH_WARM: vec3<f32> = vec3<f32>(1.0, 0.97, 0.90);
|
|
1608
|
-
const METAL_HEIGHT_SCALE: f32 = 2.2;
|
|
1609
|
-
const METAL_LIGHT_Z: f32 = 0.55;
|
|
1610
|
-
const METAL_IDLE_RAKE: vec2<f32> = vec2<f32>(0.32, 0.34);
|
|
1611
|
-
const METAL_SHININESS_ANISO: f32 = 6.0;
|
|
1612
|
-
const METAL_SHININESS_CREST: f32 = 40.0;
|
|
1613
|
-
const METAL_COHERENCE_FLOOR: f32 = 0.22;
|
|
1614
|
-
const METAL_BODY_FLOOR: f32 = 0.42;
|
|
1615
|
-
const METAL_GRADIENT_FLATTEN: f32 = 0.55;
|
|
1616
|
-
const METAL_SPARKLE_DENSITY: f32 = 240.0;
|
|
1617
|
-
const METAL_SPARKLE_THRESH: f32 = 0.72;
|
|
1618
|
-
const METAL_SPARKLE_AMP: f32 = 0.6;
|
|
1619
|
-
|
|
1620
|
-
fn metalShade(baseCol: vec3<f32>, p: vec2<f32>, stf: vec4<f32>) -> vec3<f32> {
|
|
1621
|
-
let tangent = stf.xy;
|
|
1622
|
-
let A = stf.z;
|
|
1623
|
-
let grad = unpackGrad(stf.w);
|
|
1624
|
-
let N = normalize(vec3<f32>(grad * (METAL_HEIGHT_SCALE * mMetalHeightScale()), 1.0));
|
|
1625
|
-
let V = vec3<f32>(0.0, 0.0, 1.0);
|
|
1626
|
-
// Cursor-synth rake light (u.cursor is in-struct — crosses to WGSL).
|
|
1627
|
-
let L = normalize(vec3<f32>((u.cursor.xy - p) + METAL_IDLE_RAKE, METAL_LIGHT_Z));
|
|
1628
|
-
let H = normalize(L + V);
|
|
1629
|
-
// Anisotropic streak — brushed metal along the edge-tangent.
|
|
1630
|
-
let tH = dot(normalize(tangent), H.xy);
|
|
1631
|
-
let sinTH = sqrt(clamp(1.0 - tH * tH, 0.0, 1.0));
|
|
1632
|
-
let streak = pow(clamp(sinTH, 0.0, 1.0), METAL_SHININESS_ANISO);
|
|
1633
|
-
let crest = pow(clamp(dot(N, H), 0.0, 1.0), METAL_SHININESS_CREST);
|
|
1634
|
-
var spec = streak * crest;
|
|
1635
|
-
spec = spec * smoothstep(0.0, METAL_COHERENCE_FLOOR, A);
|
|
1636
|
-
// Technicolor valley base — the body keeps the FIELD hue; luma rides the relief.
|
|
1637
|
-
let diff = clamp(dot(N, L), 0.0, 1.0);
|
|
1638
|
-
let body = baseCol * (METAL_BODY_FLOOR + (1.0 - METAL_BODY_FLOOR) * diff);
|
|
1639
|
-
return body + METAL_CATCH_WARM * (spec * clamp(mMetalPolish(), 0.0, 4.0));
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
|
-
fn mediumMetal(col: vec3<f32>, p: vec2<f32>, t: f32) -> vec3<f32> {
|
|
1643
|
-
let stf = structureTensorField(p, t, flowField(p, t));
|
|
1644
|
-
return metalShade(col, p, stf);
|
|
1645
|
-
}
|
|
1646
|
-
|
|
1647
|
-
// metal-gradient (uMedium==9) — the SAME BRDF over a pre-flattened base + the
|
|
1648
|
-
// twinkle-in-place flake sparkle (position FIXED per cell, phase-animated, facing-gated).
|
|
1649
|
-
fn mediumMetalGradient(col: vec3<f32>, p: vec2<f32>, t: f32) -> vec3<f32> {
|
|
1650
|
-
let stf = structureTensorField(p, t, flowField(p, t));
|
|
1651
|
-
let flat = mix(col, vec3<f32>(dot(col, W_LUMA)), METAL_GRADIENT_FLATTEN);
|
|
1652
|
-
var metal = metalShade(flat, p, stf);
|
|
1653
|
-
let grad = unpackGrad(stf.w);
|
|
1654
|
-
let facing = normalize(vec3<f32>(grad * (METAL_HEIGHT_SCALE * mMetalHeightScale()), 1.0)).z;
|
|
1655
|
-
let cell = floor(p * METAL_SPARKLE_DENSITY);
|
|
1656
|
-
let seed = hash21(cell);
|
|
1657
|
-
let tw = pow(clamp(sin(t + seed * 6.2831853), 0.0, 1.0), 40.0);
|
|
1658
|
-
let flakeGate = step(METAL_SPARKLE_THRESH, seed);
|
|
1659
|
-
metal = metal + METAL_CATCH_WARM * (tw * flakeGate * clamp(facing, 0.0, 1.0) * METAL_SPARKLE_AMP);
|
|
1660
|
-
return metal;
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
// ── Medium dispatch (the WGSL twin of the GLSL main() if-ladder) ────────────
|
|
1664
|
-
// uMedium: 0 smooth · 1 pastel · 2 watercolor · 3 oil · 4 crayon · 5 vangogh ·
|
|
1665
|
-
// 6 oil-pastel · 7 kuwahara · 8 metal · 9 metal-gradient. The cheap peer mediums
|
|
1666
|
-
// (pastel/watercolor/crayon) + kuwahara + metal port their own bodies; the
|
|
1667
|
-
// oil/vangogh/oil-pastel STROKE cascade renders the anisotropic-Kuwahara PAINTERLY
|
|
1668
|
-
// finish here (a real oil-paint read, never the smooth core — the "NO FALLBACKS on
|
|
1669
|
-
// Safari" mandate; the full per-dab Starry-Night stroke WGSL remains a separate
|
|
1670
|
-
// full-fidelity port).
|
|
1671
|
-
fn applyMedium(col: vec3<f32>, p: vec2<f32>, t: f32) -> vec3<f32> {
|
|
1672
|
-
let medium = u.ints1.x;
|
|
1673
|
-
if (medium == 1) { return mediumPastel(col, p, t); }
|
|
1674
|
-
if (medium == 2) { return mediumWatercolor(col, p, t); }
|
|
1675
|
-
if (medium == 4) { return mediumCrayon(col, p, t); }
|
|
1676
|
-
// Metal uses both renderer paths; a fragment-only implementation is invisible on the
|
|
1677
|
-
// WGSL primary. IDs 8 and 9 select metal and metal-gradient respectively.
|
|
1678
|
-
if (medium == 8) { return mediumMetal(col, p, t); }
|
|
1679
|
-
if (medium == 9) { return mediumMetalGradient(col, p, t); }
|
|
1680
|
-
// oil(3), vangogh(5), oil-pastel(6), kuwahara(7) all render the painterly
|
|
1681
|
-
// anisotropic-Kuwahara finish on the WGSL primary (the WebGL2 fallback carries the
|
|
1682
|
-
// full per-dab stroke cascade for oil/vangogh/oil-pastel).
|
|
1683
|
-
if (medium == 3 || medium == 5 || medium == 6 || medium == 7) {
|
|
1684
|
-
return mediumKuwahara(col, p, t);
|
|
1685
|
-
}
|
|
1686
|
-
return col;
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
// ── Full-screen triangle vertex stage (the pilot idiom — no vertex buffer) ──
|
|
1691
|
-
struct VSOut {
|
|
1692
|
-
@builtin(position) pos: vec4<f32>,
|
|
1693
|
-
@location(0) uv: vec2<f32>,
|
|
1694
|
-
};
|
|
1695
|
-
|
|
1696
|
-
@vertex
|
|
1697
|
-
fn vs_main(@builtin(vertex_index) vi: u32) -> VSOut {
|
|
1698
|
-
// NDC corners of the covering triangle (-1,-1), (3,-1), (-1,3).
|
|
1699
|
-
var p = vec2<f32>(-1.0, -1.0);
|
|
1700
|
-
if (vi == 1u) { p = vec2<f32>(3.0, -1.0); }
|
|
1701
|
-
else if (vi == 2u) { p = vec2<f32>(-1.0, 3.0); }
|
|
1702
|
-
var out: VSOut;
|
|
1703
|
-
out.pos = vec4<f32>(p, 0.0, 1.0);
|
|
1704
|
-
// vUv = aPos * 0.5 + 0.5 (the aurora.vert convention).
|
|
1705
|
-
out.uv = p * 0.5 + 0.5;
|
|
1706
|
-
return out;
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
// ── Fragment stage (the main() transcription) ──
|
|
1710
|
-
@fragment
|
|
1711
|
-
fn fs_main(in: VSOut) -> @location(0) vec4<f32> {
|
|
1712
|
-
let t = u.scalars0.x;
|
|
1713
|
-
let valueVariance = u.scalars0.z;
|
|
1714
|
-
let breathDepth = u.scalars2.w;
|
|
1715
|
-
let breathPeriod = u.scalars3.x;
|
|
1716
|
-
let saturation = u.scalars1.z;
|
|
1717
|
-
let paperGrain = u.scalars1.w;
|
|
1718
|
-
let alpha = u.scalars2.x;
|
|
1719
|
-
let vividness = u.scalars3.w;
|
|
1720
|
-
|
|
1721
|
-
let uv = in.uv;
|
|
1722
|
-
let pN = uv;
|
|
1723
|
-
|
|
1724
|
-
let p_warp = domainWarp(pN, t);
|
|
1725
|
-
|
|
1726
|
-
let nf = nucleiField(p_warp, t);
|
|
1727
|
-
var col = samplePalette(nf.paletteId);
|
|
1728
|
-
col = col * (1.0 + valueVariance * nf.valueMod);
|
|
1729
|
-
|
|
1730
|
-
// Breath — slow global luminance wobble.
|
|
1731
|
-
let breath = sin(t * 6.2831 / max(breathPeriod, 1.0));
|
|
1732
|
-
col = col * (1.0 + breathDepth * breath * 0.5);
|
|
1733
|
-
|
|
1734
|
-
// Painterly-medium dispatch. uMedium 0 (smooth) is a
|
|
1735
|
-
// no-op pass-through so the DEFAULT smooth config renders unchanged
|
|
1736
|
-
// (the parity capture); uMedium 1-7 render the painterly
|
|
1737
|
-
// bodies (pastel/watercolor/crayon/kuwahara) or the anisotropic-Kuwahara finish
|
|
1738
|
-
// (oil/vangogh/oil-pastel) — never a silent smooth degrade on Safari 26.
|
|
1739
|
-
col = applyMedium(col, pN, t);
|
|
1740
|
-
|
|
1741
|
-
// Cursor-local luminance lean, byte-parallel with the GLSL path.
|
|
1742
|
-
let cursorDelta = pN - u.cursor.xy;
|
|
1743
|
-
let cursorRadius = max(u.scalars3.z, 0.01);
|
|
1744
|
-
let cursorLean = exp(-dot(cursorDelta, cursorDelta) / (cursorRadius * cursorRadius * 0.5));
|
|
1745
|
-
col = col * (1.0 + 0.12 * cursorLean * u.scalars3.y);
|
|
1746
|
-
|
|
1747
|
-
// Saturation trim.
|
|
1748
|
-
col = saturate3(col, saturation);
|
|
1749
|
-
|
|
1750
|
-
// The chroma floor is warm-anchored and hue-preserving. The WGSL
|
|
1751
|
-
// twin of the GLSL call; vividness:0 is a no-op so the smooth/pale default stays gated.
|
|
1752
|
-
col = vividnessFloor(col, vividness);
|
|
1753
|
-
|
|
1754
|
-
// Tonemap + film grain.
|
|
1755
|
-
col = aces(col);
|
|
1756
|
-
// gl_FragCoord.xy → the device-pixel position (the WGSL @builtin(position)).
|
|
1757
|
-
let fragCoord = in.pos.xy;
|
|
1758
|
-
let grain = hash21(fragCoord + t * 17.0);
|
|
1759
|
-
col = col + (grain - 0.5) * paperGrain;
|
|
1760
|
-
|
|
1761
|
-
col = clamp(col * 0.985 + 0.008, vec3<f32>(0.0), vec3<f32>(1.0));
|
|
1762
|
-
|
|
1763
|
-
// MANDATORY OETF — closes the seam (the whole pipeline above runs in LINEAR).
|
|
1764
|
-
col = linearToSrgb(col);
|
|
1765
|
-
|
|
1766
|
-
// 1-LSB triangular IGN dither in DISPLAY space, AFTER the OETF.
|
|
1767
|
-
col = col + (1.0 / 255.0) * (ign(fragCoord) - 0.5);
|
|
1768
|
-
|
|
1769
|
-
// Premultiply on DISPLAY-space color (matches the WebGL2 path: OETF, then premul).
|
|
1770
|
-
return vec4<f32>(col * alpha, alpha);
|
|
1771
|
-
}
|
|
1772
|
-
`, Ct = `
|
|
1773
|
-
const MAX_NUCLEI: i32 = 8;
|
|
1774
|
-
const PI: f32 = 3.141592653589793;
|
|
1775
|
-
const BLUR_RINGS: i32 = 3;
|
|
1776
|
-
const BLUR_SECTORS: i32 = 8;
|
|
1777
|
-
|
|
1778
|
-
// The image program's OWN uniform struct (packed vec4 lanes — trivial std140/WGSL
|
|
1779
|
-
// alignment). DISTINCT from the palette program's 672-byte struct (a separate program).
|
|
1780
|
-
struct ImageUniforms {
|
|
1781
|
-
// scalars0: (uTime, uWarpAmount, uWarpScale, uWarpDrift)
|
|
1782
|
-
scalars0: vec4<f32>,
|
|
1783
|
-
// scalars1: (uSoftmaxBeta, uNucleiDrift, uCursorStrength, uCursorRadius)
|
|
1784
|
-
scalars1: vec4<f32>,
|
|
1785
|
-
// scalars2: (uSaturation, uPaperGrain, uAlpha, uVividness)
|
|
1786
|
-
scalars2: vec4<f32>,
|
|
1787
|
-
// image: (uBlurMin, uBlurMax, uImageAspect, _)
|
|
1788
|
-
image: vec4<f32>,
|
|
1789
|
-
// cursor: (uCursor.x, uCursor.y, _, _)
|
|
1790
|
-
cursor: vec4<f32>,
|
|
1791
|
-
// ints: (uNucleiCount, uNoiseOctaves, _, _)
|
|
1792
|
-
ints: vec4<i32>,
|
|
1793
|
-
// nuc0[i] = (pos.x, pos.y, radius, valueBias); nuc1[i] = (driftRadius, driftPhase, elong, angle)
|
|
1794
|
-
nuc0: array<vec4<f32>, 8>,
|
|
1795
|
-
nuc1: array<vec4<f32>, 8>,
|
|
1796
|
-
};
|
|
1797
|
-
|
|
1798
|
-
@group(0) @binding(0) var<uniform> u: ImageUniforms;
|
|
1799
|
-
@group(0) @binding(1) var imgTex: texture_2d<f32>;
|
|
1800
|
-
@group(0) @binding(2) var imgSampler: sampler;
|
|
1801
|
-
|
|
1802
|
-
const K_NUCLEI: f32 = 14.0;
|
|
1803
|
-
const K_WARP: f32 = 5.0;
|
|
1804
|
-
|
|
1805
|
-
// ── Noise (aurora-local hash21/vnoise/fbm — the same compact foundation) ──
|
|
1806
|
-
fn hash21(p0: vec2<f32>) -> f32 {
|
|
1807
|
-
var p = fract(p0 * vec2<f32>(123.34, 456.21));
|
|
1808
|
-
p = p + dot(p, p + 45.32);
|
|
1809
|
-
return fract(p.x * p.y);
|
|
1810
|
-
}
|
|
1811
|
-
fn vnoise(p: vec2<f32>) -> f32 {
|
|
1812
|
-
let i = floor(p);
|
|
1813
|
-
let f = fract(p);
|
|
1814
|
-
let uu = f * f * (3.0 - 2.0 * f);
|
|
1815
|
-
let a = hash21(i);
|
|
1816
|
-
let b = hash21(i + vec2<f32>(1.0, 0.0));
|
|
1817
|
-
let c = hash21(i + vec2<f32>(0.0, 1.0));
|
|
1818
|
-
let d = hash21(i + vec2<f32>(1.0, 1.0));
|
|
1819
|
-
return mix(mix(a, b, uu.x), mix(c, d, uu.x), uu.y);
|
|
1820
|
-
}
|
|
1821
|
-
${D}
|
|
1822
|
-
fn fbm(p0: vec2<f32>) -> f32 {
|
|
1823
|
-
var v = 0.0;
|
|
1824
|
-
var a = 0.5;
|
|
1825
|
-
var p = p0;
|
|
1826
|
-
let octaves = u.ints.y;
|
|
1827
|
-
for (var i = 0; i < 5; i = i + 1) {
|
|
1828
|
-
if (i >= octaves) { break; }
|
|
1829
|
-
v = v + a * vnoise(p);
|
|
1830
|
-
p = FBM_ROT * p * 2.02;
|
|
1831
|
-
a = a * 0.5;
|
|
1832
|
-
}
|
|
1833
|
-
return v;
|
|
1834
|
-
}
|
|
1835
|
-
fn ign(p: vec2<f32>) -> f32 {
|
|
1836
|
-
return fract(52.9829189 * fract(dot(p, vec2<f32>(0.06711056, 0.00583715))));
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
${w}
|
|
1840
|
-
${E}
|
|
1841
|
-
|
|
1842
|
-
fn linOklab(lin: vec3<f32>) -> vec3<f32> {
|
|
1843
|
-
let lms = LINEAR_SRGB_TO_LMS * lin;
|
|
1844
|
-
return LMS_TO_OKLAB * cbrt3(lms);
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
// The Quilez double-warp (fbm) + the cursor swirl — the drift that moves the blur zone.
|
|
1848
|
-
fn domainWarp(p: vec2<f32>, t: f32) -> vec2<f32> {
|
|
1849
|
-
let warpAmount = u.scalars0.y;
|
|
1850
|
-
let warpScale = u.scalars0.z;
|
|
1851
|
-
let warpDrift = u.scalars0.w;
|
|
1852
|
-
let cursorStrength = u.scalars1.z;
|
|
1853
|
-
let cursorRadius = u.scalars1.w;
|
|
1854
|
-
let cursor = u.cursor.xy;
|
|
1855
|
-
let q = vec2<f32>(fbm(p * warpScale + vec2<f32>(0.0, 0.0) + t * warpDrift * K_WARP),
|
|
1856
|
-
fbm(p * warpScale + vec2<f32>(5.2, 1.3) + t * warpDrift * K_WARP));
|
|
1857
|
-
let r = vec2<f32>(fbm(p * warpScale + 4.0 * q + vec2<f32>(1.7, 9.2)),
|
|
1858
|
-
fbm(p * warpScale + 4.0 * q + vec2<f32>(8.3, 2.8)));
|
|
1859
|
-
var warped = p + warpAmount * r;
|
|
1860
|
-
if (cursorStrength > 0.001) {
|
|
1861
|
-
let toP = p - cursor;
|
|
1862
|
-
let d = length(toP);
|
|
1863
|
-
let rr = max(cursorRadius, 0.01);
|
|
1864
|
-
let w = exp(-(d * d) / (rr * rr * 0.45));
|
|
1865
|
-
let ang = w * cursorStrength * 2.1;
|
|
1866
|
-
let ca = cos(ang);
|
|
1867
|
-
let sa = sin(ang);
|
|
1868
|
-
let rotated = vec2<f32>(ca * toP.x - sa * toP.y, sa * toP.x + ca * toP.y) + cursor;
|
|
1869
|
-
warped = mix(warped, rotated + warpAmount * r * 0.7, w * cursorStrength);
|
|
1870
|
-
}
|
|
1871
|
-
return warped;
|
|
1872
|
-
}
|
|
1873
|
-
|
|
1874
|
-
// The drifting BLUR ZONE — the anisotropic-Gaussian nuclei softmax (the SAME field the
|
|
1875
|
-
// palette program reads), drift-coupled.
|
|
1876
|
-
fn zoneField(p: vec2<f32>, t: f32) -> f32 {
|
|
1877
|
-
let nucleiCount = u.ints.x;
|
|
1878
|
-
let nucleiDrift = u.scalars1.y;
|
|
1879
|
-
let softmaxBeta = u.scalars1.x;
|
|
1880
|
-
var accum = 0.0;
|
|
1881
|
-
var accumW = 0.0;
|
|
1882
|
-
for (var i = 0; i < MAX_NUCLEI; i = i + 1) {
|
|
1883
|
-
if (i >= nucleiCount) { break; }
|
|
1884
|
-
let n0 = u.nuc0[i]; // pos.x, pos.y, radius, valueBias
|
|
1885
|
-
let n1 = u.nuc1[i]; // driftRadius, driftPhase, elong, angle
|
|
1886
|
-
let posI = n0.xy + n1.x * vec2<f32>(
|
|
1887
|
-
cos(t * nucleiDrift * K_NUCLEI + n1.y),
|
|
1888
|
-
sin(t * nucleiDrift * K_NUCLEI + n1.y * 1.13));
|
|
1889
|
-
let diff = p - posI;
|
|
1890
|
-
let ca = cos(n1.w);
|
|
1891
|
-
let sa = sin(n1.w);
|
|
1892
|
-
let local = vec2<f32>(ca * diff.x + sa * diff.y, -sa * diff.x + ca * diff.y);
|
|
1893
|
-
let along = local.x / max(n1.z, 0.01);
|
|
1894
|
-
let d2 = along * along + local.y * local.y;
|
|
1895
|
-
let rad = max(n0.z, 0.01);
|
|
1896
|
-
let w = exp(-softmaxBeta * d2 / (rad * rad));
|
|
1897
|
-
accum = accum + w * (0.5 + 0.5 * n0.w);
|
|
1898
|
-
accumW = accumW + w;
|
|
1899
|
-
}
|
|
1900
|
-
return clamp(accum / max(accumW, 1e-4), 0.0, 1.0);
|
|
1901
|
-
}
|
|
1902
|
-
|
|
1903
|
-
fn coverUv(uv: vec2<f32>) -> vec2<f32> {
|
|
1904
|
-
let aspect = max(u.image.z, 0.0001);
|
|
1905
|
-
var c = uv - vec2<f32>(0.5);
|
|
1906
|
-
c.x = c.x * aspect;
|
|
1907
|
-
let s = 1.0 / max(aspect, 1.0);
|
|
1908
|
-
return c * s + vec2<f32>(0.5);
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
|
-
// The bounded 24-tap zone blur — a FIXED 3-ring × 8-sector stratified kernel, radius
|
|
1912
|
-
// per-fragment, sampled in LINEAR light. textureSampleLevel (explicit LOD 0) — WGSL has
|
|
1913
|
-
// no implicit derivative in a varying-radius loop.
|
|
1914
|
-
fn zoneBlur(uv: vec2<f32>, radius: f32) -> vec3<f32> {
|
|
1915
|
-
let aspect = max(u.image.z, 0.0001);
|
|
1916
|
-
var sum = srgbToLinear(textureSampleLevel(imgTex, imgSampler, coverUv(uv), 0.0).rgb);
|
|
1917
|
-
var wsum = 1.0;
|
|
1918
|
-
for (var ring = 1; ring <= BLUR_RINGS; ring = ring + 1) {
|
|
1919
|
-
let rr = radius * (f32(ring) / f32(BLUR_RINGS));
|
|
1920
|
-
for (var s = 0; s < BLUR_SECTORS; s = s + 1) {
|
|
1921
|
-
let a = (f32(s) + 0.5 * f32(ring)) / f32(BLUR_SECTORS) * 2.0 * PI;
|
|
1922
|
-
let off = vec2<f32>(cos(a) / aspect, sin(a)) * rr;
|
|
1923
|
-
sum = sum + srgbToLinear(textureSampleLevel(imgTex, imgSampler, coverUv(uv + off), 0.0).rgb);
|
|
1924
|
-
wsum = wsum + 1.0;
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
return sum / wsum;
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
const VIVID_TARGET: f32 = 0.115;
|
|
1931
|
-
const VIVID_EPS: f32 = 0.012;
|
|
1932
|
-
const VIVID_WARM_ANCHOR: vec2<f32> = vec2<f32>(0.34202, 0.93969);
|
|
1933
|
-
fn vividnessFloor(c: vec3<f32>, vividness: f32) -> vec3<f32> {
|
|
1934
|
-
if (vividness <= 0.0001) { return c; }
|
|
1935
|
-
var lab = linOklab(c);
|
|
1936
|
-
let C = length(lab.yz);
|
|
1937
|
-
let modeLift = mix(1.18, 1.0, clamp(lab.x * 1.4, 0.0, 1.0));
|
|
1938
|
-
let Cmin = vividness * VIVID_TARGET * modeLift;
|
|
1939
|
-
var hueDir = VIVID_WARM_ANCHOR;
|
|
1940
|
-
if (C > VIVID_EPS) { hueDir = lab.yz / C; }
|
|
1941
|
-
let yz = hueDir * max(C, Cmin);
|
|
1942
|
-
lab = vec3<f32>(lab.x, yz.x, yz.y);
|
|
1943
|
-
return max(oklabToLinearSrgb(lab), vec3<f32>(0.0));
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
fn saturate3(c: vec3<f32>, amt: f32) -> vec3<f32> {
|
|
1947
|
-
var lch = oklabToOklch(linOklab(c));
|
|
1948
|
-
lch.y = max(lch.y * amt, 0.0);
|
|
1949
|
-
return max(oklabToLinearSrgb(oklchToOklab(lch)), vec3<f32>(0.0));
|
|
1950
|
-
}
|
|
1951
|
-
|
|
1952
|
-
fn aces(color0: vec3<f32>) -> vec3<f32> {
|
|
1953
|
-
let startCompression = 0.8 - 0.04;
|
|
1954
|
-
let desaturation = 0.15;
|
|
1955
|
-
var color = color0;
|
|
1956
|
-
let x = min(color.r, min(color.g, color.b));
|
|
1957
|
-
var offset = 0.04;
|
|
1958
|
-
if (x < 0.08) { offset = x - 6.25 * x * x; }
|
|
1959
|
-
color = color - offset;
|
|
1960
|
-
let peak = max(color.r, max(color.g, color.b));
|
|
1961
|
-
if (peak < startCompression) { return clamp(color, vec3<f32>(0.0), vec3<f32>(1.0)); }
|
|
1962
|
-
let d = 1.0 - startCompression;
|
|
1963
|
-
let newPeak = 1.0 - d * d / (peak + d - startCompression);
|
|
1964
|
-
color = color * (newPeak / peak);
|
|
1965
|
-
let g = 1.0 - 1.0 / (desaturation * (peak - newPeak) + 1.0);
|
|
1966
|
-
return clamp(mix(color, newPeak * vec3<f32>(1.0), g), vec3<f32>(0.0), vec3<f32>(1.0));
|
|
1967
|
-
}
|
|
1968
|
-
|
|
1969
|
-
struct VSOut {
|
|
1970
|
-
@builtin(position) pos: vec4<f32>,
|
|
1971
|
-
@location(0) uv: vec2<f32>,
|
|
1972
|
-
};
|
|
1973
|
-
|
|
1974
|
-
@vertex
|
|
1975
|
-
fn vs_main(@builtin(vertex_index) vi: u32) -> VSOut {
|
|
1976
|
-
var p = vec2<f32>(-1.0, -1.0);
|
|
1977
|
-
if (vi == 1u) { p = vec2<f32>(3.0, -1.0); }
|
|
1978
|
-
else if (vi == 2u) { p = vec2<f32>(-1.0, 3.0); }
|
|
1979
|
-
var out: VSOut;
|
|
1980
|
-
out.pos = vec4<f32>(p, 0.0, 1.0);
|
|
1981
|
-
out.uv = p * 0.5 + 0.5;
|
|
1982
|
-
return out;
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
@fragment
|
|
1986
|
-
fn fs_main(in: VSOut) -> @location(0) vec4<f32> {
|
|
1987
|
-
let t = u.scalars0.x;
|
|
1988
|
-
let saturation = u.scalars2.x;
|
|
1989
|
-
let paperGrain = u.scalars2.y;
|
|
1990
|
-
let alpha = u.scalars2.z;
|
|
1991
|
-
let vividness = u.scalars2.w;
|
|
1992
|
-
let blurMin = u.image.x;
|
|
1993
|
-
let blurMax = u.image.y;
|
|
1994
|
-
|
|
1995
|
-
let uv = in.uv;
|
|
1996
|
-
let p_warp = domainWarp(uv, t);
|
|
1997
|
-
let zone = zoneField(p_warp, t);
|
|
1998
|
-
|
|
1999
|
-
let radius = mix(blurMin, blurMax, zone);
|
|
2000
|
-
var col = zoneBlur(uv, radius);
|
|
2001
|
-
|
|
2002
|
-
let cursorDelta = uv - u.cursor.xy;
|
|
2003
|
-
let cursorRadius = max(u.scalars1.w, 0.01);
|
|
2004
|
-
let cursorLean = exp(-dot(cursorDelta, cursorDelta) / (cursorRadius * cursorRadius * 0.5));
|
|
2005
|
-
col = col * (1.0 + 0.12 * cursorLean * u.scalars1.z);
|
|
2006
|
-
|
|
2007
|
-
col = saturate3(col, saturation);
|
|
2008
|
-
col = vividnessFloor(col, vividness);
|
|
2009
|
-
|
|
2010
|
-
col = aces(col);
|
|
2011
|
-
let fragCoord = in.pos.xy;
|
|
2012
|
-
let grain = hash21(fragCoord + t * 17.0);
|
|
2013
|
-
col = col + (grain - 0.5) * paperGrain;
|
|
2014
|
-
col = clamp(col * 0.985 + 0.008, vec3<f32>(0.0), vec3<f32>(1.0));
|
|
2015
|
-
|
|
2016
|
-
col = linearToSrgb(col);
|
|
2017
|
-
col = col + (1.0 / 255.0) * (ign(fragCoord) - 0.5);
|
|
2018
|
-
|
|
2019
|
-
return vec4<f32>(col * alpha, alpha);
|
|
2020
|
-
}
|
|
2021
|
-
`, q = {
|
|
2022
|
-
scalars0: 0,
|
|
2023
|
-
scalars1: 4,
|
|
2024
|
-
scalars2: 8,
|
|
2025
|
-
scalars3: 12,
|
|
2026
|
-
cursor: 16,
|
|
2027
|
-
ints0: 20,
|
|
2028
|
-
ints1: 24,
|
|
2029
|
-
palette: 28,
|
|
2030
|
-
nuc0: 60,
|
|
2031
|
-
nuc1: 92,
|
|
2032
|
-
nuc2: 124,
|
|
2033
|
-
scalars4: 156,
|
|
2034
|
-
scalars5: 160,
|
|
2035
|
-
kuwahara: 164
|
|
2036
|
-
}, wt = .01, Tt = 8, Et = 4, Dt = (e) => 1 - e;
|
|
2037
|
-
function Ot() {
|
|
2038
|
-
let e = /* @__PURE__ */ new ArrayBuffer(672);
|
|
2039
|
-
return {
|
|
2040
|
-
buffer: e,
|
|
2041
|
-
f32: new Float32Array(e),
|
|
2042
|
-
i32: new Int32Array(e),
|
|
2043
|
-
paletteScratch: /* @__PURE__ */ new Float32Array(24)
|
|
2044
|
-
};
|
|
2045
|
-
}
|
|
2046
|
-
function kt(e, t, n, r, i = t.alpha) {
|
|
2047
|
-
let { f32: a, i32: o, paletteScratch: s } = e;
|
|
2048
|
-
a[q.scalars0 + 0] = r, a[q.scalars0 + 1] = t.softmaxBeta, a[q.scalars0 + 2] = t.valueVariance, a[q.scalars0 + 3] = t.warpAmount, a[q.scalars1 + 0] = t.warpScale, a[q.scalars1 + 1] = t.warpDrift, a[q.scalars1 + 2] = t.saturation, a[q.scalars1 + 3] = t.paperGrain, a[q.scalars2 + 0] = i, a[q.scalars2 + 1] = t.nucleiDrift, a[q.scalars2 + 2] = t.paletteDrift, a[q.scalars2 + 3] = t.breathDepth, a[q.scalars3 + 0] = t.breathPeriod, a[q.scalars3 + 1] = n.strength, a[q.scalars3 + 2] = n.radius, a[q.scalars3 + 3] = t.vividness ?? 1, a[q.cursor + 0] = n.x, a[q.cursor + 1] = Dt(n.y), a[q.cursor + 2] = t.metalPolish ?? 1, a[q.cursor + 3] = t.metalHeightScale ?? 1, o[q.ints0 + 0] = Math.min(t.palette.length, 8);
|
|
2049
|
-
let c = Math.min(t.nuclei.length, 8);
|
|
2050
|
-
o[q.ints0 + 1] = c, o[q.ints0 + 2] = ft[t.warpMode], o[q.ints0 + 3] = t.noiseOctaves, o[q.ints1 + 0] = ct[t.medium], o[q.ints1 + 1] = lt[t.huePath ?? "shorter"], o[q.ints1 + 2] = 0, o[q.ints1 + 3] = 0, U(t.palette, 8, s);
|
|
2051
|
-
for (let e = 0; e < 8; e++) {
|
|
2052
|
-
let t = q.palette + e * 4;
|
|
2053
|
-
a[t + 0] = s[e * 3 + 0], a[t + 1] = s[e * 3 + 1], a[t + 2] = s[e * 3 + 2], a[t + 3] = 0;
|
|
2054
|
-
}
|
|
2055
|
-
for (let e = 0; e < 8; e++) {
|
|
2056
|
-
let n = q.nuc0 + e * 4, r = q.nuc1 + e * 4, i = q.nuc2 + e * 4;
|
|
2057
|
-
if (e < c) {
|
|
2058
|
-
let o = t.nuclei[e];
|
|
2059
|
-
a[n + 0] = o.x, a[n + 1] = Dt(o.y), a[n + 2] = o.radius, a[n + 3] = o.paletteBias, a[r + 0] = o.valueBias, a[r + 1] = o.driftRadius, a[r + 2] = o.driftPhase, a[r + 3] = o.elongation ?? 1, a[i + 0] = -(o.angle ?? 0) * Math.PI / 180, a[i + 1] = 0, a[i + 2] = 0, a[i + 3] = 0;
|
|
2060
|
-
} else a[n + 0] = 0, a[n + 1] = 0, a[n + 2] = 0, a[n + 3] = 0, a[r + 0] = 0, a[r + 1] = 0, a[r + 2] = 0, a[r + 3] = 1, a[i + 0] = 0, a[i + 1] = 0, a[i + 2] = 0, a[i + 3] = 0;
|
|
2061
|
-
}
|
|
2062
|
-
return a[q.scalars4 + 0] = t.strokeAmount, a[q.scalars4 + 1] = t.strokeScale, a[q.scalars4 + 2] = t.strokeAnisotropy, a[q.scalars4 + 3] = t.canvasGrain, a[q.scalars5 + 0] = t.wetEdge, a[q.scalars5 + 1] = t.granulation, a[q.scalars5 + 2] = t.brokenColor, a[q.scalars5 + 3] = t.kuwaharaQ ?? Et, a[q.kuwahara + 0] = t.kuwaharaRadius ?? wt, a[q.kuwahara + 1] = Tt, a[q.kuwahara + 2] = 0, a[q.kuwahara + 3] = 0, e;
|
|
2063
|
-
}
|
|
2064
|
-
var J = {
|
|
2065
|
-
scalars0: 0,
|
|
2066
|
-
scalars1: 4,
|
|
2067
|
-
scalars2: 8,
|
|
2068
|
-
image: 12,
|
|
2069
|
-
cursor: 16,
|
|
2070
|
-
ints: 20,
|
|
2071
|
-
nuc0: 24,
|
|
2072
|
-
nuc1: 56
|
|
2073
|
-
}, At = (e) => 1 - e;
|
|
2074
|
-
function jt() {
|
|
2075
|
-
let e = /* @__PURE__ */ new ArrayBuffer(352);
|
|
2076
|
-
return {
|
|
2077
|
-
buffer: e,
|
|
2078
|
-
f32: new Float32Array(e),
|
|
2079
|
-
i32: new Int32Array(e)
|
|
2080
|
-
};
|
|
2081
|
-
}
|
|
2082
|
-
function Mt(e, t, n, r, i, a = t.alpha) {
|
|
2083
|
-
let { f32: o, i32: s } = e;
|
|
2084
|
-
o[J.scalars0 + 0] = r, o[J.scalars0 + 1] = t.warpAmount, o[J.scalars0 + 2] = t.warpScale, o[J.scalars0 + 3] = t.warpDrift, o[J.scalars1 + 0] = t.softmaxBeta, o[J.scalars1 + 1] = t.nucleiDrift, o[J.scalars1 + 2] = n.strength, o[J.scalars1 + 3] = n.radius, o[J.scalars2 + 0] = t.saturation, o[J.scalars2 + 1] = t.paperGrain, o[J.scalars2 + 2] = a, o[J.scalars2 + 3] = t.vividness ?? 1, o[J.image + 0] = t.imageBlur?.min ?? .004, o[J.image + 1] = t.imageBlur?.max ?? .06, o[J.image + 2] = i, o[J.image + 3] = 0, o[J.cursor + 0] = n.x, o[J.cursor + 1] = At(n.y), o[J.cursor + 2] = 0, o[J.cursor + 3] = 0;
|
|
2085
|
-
let c = Math.min(t.nuclei.length, 8);
|
|
2086
|
-
s[J.ints + 0] = c, s[J.ints + 1] = t.noiseOctaves, s[J.ints + 2] = 0, s[J.ints + 3] = 0;
|
|
2087
|
-
for (let e = 0; e < 8; e++) {
|
|
2088
|
-
let n = J.nuc0 + e * 4, r = J.nuc1 + e * 4;
|
|
2089
|
-
if (e < c) {
|
|
2090
|
-
let i = t.nuclei[e];
|
|
2091
|
-
o[n + 0] = i.x, o[n + 1] = At(i.y), o[n + 2] = i.radius, o[n + 3] = i.valueBias, o[r + 0] = i.driftRadius, o[r + 1] = i.driftPhase, o[r + 2] = i.elongation ?? 1, o[r + 3] = -(i.angle ?? 0) * Math.PI / 180;
|
|
2092
|
-
} else o[n + 0] = 0, o[n + 1] = 0, o[n + 2] = 0, o[n + 3] = 0, o[r + 0] = 0, o[r + 1] = 0, o[r + 2] = 1, o[r + 3] = 0;
|
|
2093
|
-
}
|
|
2094
|
-
return e;
|
|
2095
|
-
}
|
|
2096
|
-
//#endregion
|
|
2097
|
-
//#region src/components/aurora/composables/wgpuSetup.ts
|
|
2098
|
-
var Y = 2, Nt = {
|
|
2099
|
-
color: {
|
|
2100
|
-
srcFactor: "one",
|
|
2101
|
-
dstFactor: "one-minus-src-alpha",
|
|
2102
|
-
operation: "add"
|
|
2103
|
-
},
|
|
2104
|
-
alpha: {
|
|
2105
|
-
srcFactor: "one",
|
|
2106
|
-
dstFactor: "one-minus-src-alpha",
|
|
2107
|
-
operation: "add"
|
|
2108
|
-
}
|
|
2109
|
-
};
|
|
2110
|
-
function Pt(e) {
|
|
2111
|
-
let { canvas: t, opaquePresentation: n, getCursorScalars: r, getConfig: i, getReducedMotion: a, getRenderTime: o, pointerField: s, getDecodedImage: c, registerImageUploader: l } = e, u = null;
|
|
2112
|
-
return function(e, d, f) {
|
|
2113
|
-
if (i().source === "image") return Ft(e, d, f, {
|
|
2114
|
-
canvas: t,
|
|
2115
|
-
opaquePresentation: n,
|
|
2116
|
-
getCursorScalars: r,
|
|
2117
|
-
getConfig: i,
|
|
2118
|
-
getReducedMotion: a,
|
|
2119
|
-
getRenderTime: o,
|
|
2120
|
-
pointerField: s,
|
|
2121
|
-
getDecodedImage: c,
|
|
2122
|
-
registerImageUploader: l
|
|
2123
|
-
});
|
|
2124
|
-
let p = e.createShaderModule({
|
|
2125
|
-
label: "[Aurora] aurora.wgsl",
|
|
2126
|
-
code: St
|
|
2127
|
-
}), m = e.createBuffer({
|
|
2128
|
-
label: "[Aurora] uniforms",
|
|
2129
|
-
size: 672,
|
|
2130
|
-
usage: 72
|
|
2131
|
-
}), h = e.createBindGroupLayout({
|
|
2132
|
-
label: "[Aurora] bind-group-0",
|
|
2133
|
-
entries: [{
|
|
2134
|
-
binding: 0,
|
|
2135
|
-
visibility: Y,
|
|
2136
|
-
buffer: { type: "uniform" }
|
|
2137
|
-
}]
|
|
2138
|
-
}), g = e.createRenderPipeline({
|
|
2139
|
-
label: "[Aurora] pipeline",
|
|
2140
|
-
layout: e.createPipelineLayout({ bindGroupLayouts: [h] }),
|
|
2141
|
-
vertex: {
|
|
2142
|
-
module: p,
|
|
2143
|
-
entryPoint: "vs_main"
|
|
2144
|
-
},
|
|
2145
|
-
fragment: {
|
|
2146
|
-
module: p,
|
|
2147
|
-
entryPoint: "fs_main",
|
|
2148
|
-
targets: [{
|
|
2149
|
-
format: f,
|
|
2150
|
-
blend: n ? void 0 : Nt
|
|
2151
|
-
}]
|
|
2152
|
-
},
|
|
2153
|
-
primitive: { topology: "triangle-list" }
|
|
2154
|
-
}), _ = e.createBindGroup({
|
|
2155
|
-
label: "[Aurora] bind-group",
|
|
2156
|
-
layout: h,
|
|
2157
|
-
entries: [{
|
|
2158
|
-
binding: 0,
|
|
2159
|
-
resource: { buffer: m }
|
|
2160
|
-
}]
|
|
2161
|
-
}), v = Ot();
|
|
2162
|
-
function y(e) {}
|
|
2163
|
-
function b(t) {
|
|
2164
|
-
let c = +!a(), l = u === null ? 0 : Math.max(0, (t - u) * 1e3);
|
|
2165
|
-
u = t, s.tick(c === 0 ? 0 : l);
|
|
2166
|
-
let f = V(s, r(), c), p = i();
|
|
2167
|
-
kt(v, p, f, o(t), n ? 1 : p.alpha), e.queue.writeBuffer(m, 0, v.buffer);
|
|
2168
|
-
let h = d.getCurrentTexture().createView(), y = e.createCommandEncoder({ label: "[Aurora] frame" }), b = y.beginRenderPass({ colorAttachments: [{
|
|
2169
|
-
view: h,
|
|
2170
|
-
clearValue: {
|
|
2171
|
-
r: 0,
|
|
2172
|
-
g: 0,
|
|
2173
|
-
b: 0,
|
|
2174
|
-
a: +!!n
|
|
2175
|
-
},
|
|
2176
|
-
loadOp: "clear",
|
|
2177
|
-
storeOp: "store"
|
|
2178
|
-
}] });
|
|
2179
|
-
b.setPipeline(g), b.setBindGroup(0, _), b.draw(3, 1, 0, 0), b.end(), e.queue.submit([y.finish()]);
|
|
2180
|
-
}
|
|
2181
|
-
function x() {
|
|
2182
|
-
return a() ? !1 : R(i()) ? !0 : H(s);
|
|
2183
|
-
}
|
|
2184
|
-
return {
|
|
2185
|
-
frame: b,
|
|
2186
|
-
shouldContinue: x,
|
|
2187
|
-
resize: y,
|
|
2188
|
-
teardown: () => {
|
|
2189
|
-
m.destroy();
|
|
2190
|
-
}
|
|
2191
|
-
};
|
|
2192
|
-
};
|
|
2193
|
-
}
|
|
2194
|
-
function Ft(e, t, n, r) {
|
|
2195
|
-
let { canvas: i, opaquePresentation: a, getCursorScalars: o, getConfig: s, getReducedMotion: c, getRenderTime: l, pointerField: u, getDecodedImage: d, registerImageUploader: f } = r, p = null, m = e.createShaderModule({
|
|
2196
|
-
label: "[Aurora] aurora-image.wgsl",
|
|
2197
|
-
code: Ct
|
|
2198
|
-
}), h = e.createBuffer({
|
|
2199
|
-
label: "[Aurora] image uniforms",
|
|
2200
|
-
size: 352,
|
|
2201
|
-
usage: 72
|
|
2202
|
-
}), g = e.createSampler({
|
|
2203
|
-
label: "[Aurora] image sampler",
|
|
2204
|
-
magFilter: "linear",
|
|
2205
|
-
minFilter: "linear",
|
|
2206
|
-
addressModeU: "clamp-to-edge",
|
|
2207
|
-
addressModeV: "clamp-to-edge"
|
|
2208
|
-
}), _ = e.createBindGroupLayout({
|
|
2209
|
-
label: "[Aurora] image bind-group-0",
|
|
2210
|
-
entries: [
|
|
2211
|
-
{
|
|
2212
|
-
binding: 0,
|
|
2213
|
-
visibility: Y,
|
|
2214
|
-
buffer: { type: "uniform" }
|
|
2215
|
-
},
|
|
2216
|
-
{
|
|
2217
|
-
binding: 1,
|
|
2218
|
-
visibility: Y,
|
|
2219
|
-
texture: {
|
|
2220
|
-
sampleType: "float",
|
|
2221
|
-
viewDimension: "2d"
|
|
2222
|
-
}
|
|
2223
|
-
},
|
|
2224
|
-
{
|
|
2225
|
-
binding: 2,
|
|
2226
|
-
visibility: Y,
|
|
2227
|
-
sampler: { type: "filtering" }
|
|
2228
|
-
}
|
|
2229
|
-
]
|
|
2230
|
-
}), v = e.createRenderPipeline({
|
|
2231
|
-
label: "[Aurora] image pipeline",
|
|
2232
|
-
layout: e.createPipelineLayout({ bindGroupLayouts: [_] }),
|
|
2233
|
-
vertex: {
|
|
2234
|
-
module: m,
|
|
2235
|
-
entryPoint: "vs_main"
|
|
2236
|
-
},
|
|
2237
|
-
fragment: {
|
|
2238
|
-
module: m,
|
|
2239
|
-
entryPoint: "fs_main",
|
|
2240
|
-
targets: [{
|
|
2241
|
-
format: n,
|
|
2242
|
-
blend: a ? void 0 : Nt
|
|
2243
|
-
}]
|
|
2244
|
-
},
|
|
2245
|
-
primitive: { topology: "triangle-list" }
|
|
2246
|
-
}), y = ve(e, d() ?? he()).texture;
|
|
2247
|
-
function b() {
|
|
2248
|
-
return e.createBindGroup({
|
|
2249
|
-
label: "[Aurora] image bind-group",
|
|
2250
|
-
layout: _,
|
|
2251
|
-
entries: [
|
|
2252
|
-
{
|
|
2253
|
-
binding: 0,
|
|
2254
|
-
resource: { buffer: h }
|
|
2255
|
-
},
|
|
2256
|
-
{
|
|
2257
|
-
binding: 1,
|
|
2258
|
-
resource: y.createView()
|
|
2259
|
-
},
|
|
2260
|
-
{
|
|
2261
|
-
binding: 2,
|
|
2262
|
-
resource: g
|
|
2263
|
-
}
|
|
2264
|
-
]
|
|
2265
|
-
});
|
|
2266
|
-
}
|
|
2267
|
-
let x = b();
|
|
2268
|
-
f((t) => {
|
|
2269
|
-
y.destroy(), y = ve(e, t).texture, x = b();
|
|
2270
|
-
});
|
|
2271
|
-
let S = jt();
|
|
2272
|
-
function C(e) {}
|
|
2273
|
-
function w(n) {
|
|
2274
|
-
let r = +!c(), d = p === null ? 0 : Math.max(0, (n - p) * 1e3);
|
|
2275
|
-
p = n, u.tick(r === 0 ? 0 : d);
|
|
2276
|
-
let f = V(u, o(), r), m = i.height > 0 ? i.width / i.height : 1, g = s();
|
|
2277
|
-
Mt(S, g, f, l(n), m, a ? 1 : g.alpha), e.queue.writeBuffer(h, 0, S.buffer);
|
|
2278
|
-
let _ = t.getCurrentTexture().createView(), y = e.createCommandEncoder({ label: "[Aurora] image frame" }), b = y.beginRenderPass({ colorAttachments: [{
|
|
2279
|
-
view: _,
|
|
2280
|
-
clearValue: {
|
|
2281
|
-
r: 0,
|
|
2282
|
-
g: 0,
|
|
2283
|
-
b: 0,
|
|
2284
|
-
a: +!!a
|
|
2285
|
-
},
|
|
2286
|
-
loadOp: "clear",
|
|
2287
|
-
storeOp: "store"
|
|
2288
|
-
}] });
|
|
2289
|
-
b.setPipeline(v), b.setBindGroup(0, x), b.draw(3, 1, 0, 0), b.end(), e.queue.submit([y.finish()]);
|
|
2290
|
-
}
|
|
2291
|
-
function T() {
|
|
2292
|
-
return c() ? !1 : R(s()) ? !0 : H(u);
|
|
2293
|
-
}
|
|
2294
|
-
return {
|
|
2295
|
-
frame: w,
|
|
2296
|
-
shouldContinue: T,
|
|
2297
|
-
resize: C,
|
|
2298
|
-
teardown: () => {
|
|
2299
|
-
f(null), y.destroy(), h.destroy();
|
|
2300
|
-
}
|
|
2301
|
-
};
|
|
23
|
+
function G(e, t = {}) {
|
|
24
|
+
return e !== "css" && !t.forceWebGLUnderSoftwareRaster && W() ? "css" : e === "auto" ? "webgl" : e;
|
|
2302
25
|
}
|
|
2303
26
|
//#endregion
|
|
2304
27
|
//#region src/components/aurora/composables/runtime.ts
|
|
2305
|
-
function
|
|
28
|
+
function re(e) {
|
|
2306
29
|
return e.mode === "capture" || e.initStrategy === "eager";
|
|
2307
30
|
}
|
|
2308
|
-
function
|
|
31
|
+
function ie(e) {
|
|
2309
32
|
return typeof e.preserveDrawingBuffer == "boolean" ? e.preserveDrawingBuffer : e.mode === "capture";
|
|
2310
33
|
}
|
|
2311
|
-
function
|
|
34
|
+
function ae(e = "live") {
|
|
2312
35
|
let t = e !== "capture";
|
|
2313
36
|
return {
|
|
2314
37
|
opaque: t,
|
|
@@ -2316,40 +39,40 @@ function Rt(e = "live") {
|
|
|
2316
39
|
contextAlpha: !t
|
|
2317
40
|
};
|
|
2318
41
|
}
|
|
2319
|
-
var
|
|
2320
|
-
function
|
|
42
|
+
var oe = (e) => Math.min(1, Math.max(0, e));
|
|
43
|
+
function K(e) {
|
|
2321
44
|
return e.interactivity?.swirl !== !1 || e.impasto > 0 && e.interactivity?.light === !0;
|
|
2322
45
|
}
|
|
2323
|
-
var
|
|
2324
|
-
function
|
|
2325
|
-
return r ?
|
|
46
|
+
var se = 3.7;
|
|
47
|
+
function q(e, t, n, r) {
|
|
48
|
+
return r ? se : e.interactivity?.scroll === !0 ? t + Math.min(1, Math.max(0, n)) * e.breathPeriod : t;
|
|
2326
49
|
}
|
|
2327
|
-
function
|
|
2328
|
-
let i =
|
|
2329
|
-
a.opaque && (e.style.opacity = String(
|
|
50
|
+
function J(e, t, r = {}) {
|
|
51
|
+
let i = ie(r), a = ae(r.mode), o = e.style.opacity, s = (t) => {
|
|
52
|
+
a.opaque && (e.style.opacity = String(oe(t)));
|
|
2330
53
|
};
|
|
2331
54
|
s(t.alpha);
|
|
2332
|
-
let
|
|
55
|
+
let l = !r.forceWebGLUnderSoftwareRaster && W(), u = t, d = 0, f = n({
|
|
2333
56
|
mass: 1,
|
|
2334
57
|
damping: .9,
|
|
2335
58
|
attractorResponse: .28,
|
|
2336
59
|
leadGain: .08,
|
|
2337
60
|
halfLifeMs: 110
|
|
2338
|
-
}),
|
|
2339
|
-
let e =
|
|
61
|
+
}), p = .8, m = .25, h = () => {
|
|
62
|
+
let e = u.interactivity, t = K(u);
|
|
2340
63
|
return {
|
|
2341
|
-
strength: t ?
|
|
2342
|
-
radius:
|
|
64
|
+
strength: t ? p : 0,
|
|
65
|
+
radius: m,
|
|
2343
66
|
amplitude: t ? Math.min(1, Math.max(0, e?.amplitude ?? .5)) : 0
|
|
2344
67
|
};
|
|
2345
|
-
},
|
|
2346
|
-
wake: () =>
|
|
68
|
+
}, g = null, _ = C({
|
|
69
|
+
wake: () => j.wake(),
|
|
2347
70
|
onError: r.onInitError
|
|
2348
|
-
}), v =
|
|
71
|
+
}), v = l ? /* @__PURE__ */ Error("[Aurora] GPU animation is unavailable under software rasterization") : null, y = r.forceBackend === "webgl2", b = !1;
|
|
2349
72
|
function x() {
|
|
2350
73
|
!v || b || (b = !0, r.onInitError?.(v));
|
|
2351
74
|
}
|
|
2352
|
-
let
|
|
75
|
+
let S = {
|
|
2353
76
|
backend: "webgl2",
|
|
2354
77
|
arm: x,
|
|
2355
78
|
armAsync: () => (x(), Promise.reject(v)),
|
|
@@ -2360,10 +83,13 @@ function Ht(e, t, r = {}) {
|
|
|
2360
83
|
renderAt: () => {},
|
|
2361
84
|
dispose: () => {},
|
|
2362
85
|
reducedMotion: !1
|
|
2363
|
-
}
|
|
86
|
+
}, w = null, E = null, D = null, k = null, A = (e, t) => {
|
|
87
|
+
if (!e) throw Error(`[Aurora] ${t} setup ran before its module loaded`);
|
|
88
|
+
return e;
|
|
89
|
+
}, j = l ? S : T(e, {
|
|
2364
90
|
mode: r.mode === "capture" ? "capture" : "live",
|
|
2365
91
|
alphaMode: a.alphaMode,
|
|
2366
|
-
dprPolicy:
|
|
92
|
+
dprPolicy: c,
|
|
2367
93
|
revealBloom: r.revealBloom ?? !1,
|
|
2368
94
|
contextAttrs: {
|
|
2369
95
|
antialias: !1,
|
|
@@ -2371,82 +97,85 @@ function Ht(e, t, r = {}) {
|
|
|
2371
97
|
premultipliedAlpha: a.contextAlpha,
|
|
2372
98
|
preserveDrawingBuffer: i
|
|
2373
99
|
},
|
|
2374
|
-
|
|
100
|
+
prepare: async (e) => {
|
|
101
|
+
e === "webgpu" ? k ??= await import("./wgpuSetup-CFuqd_RP.js") : D ??= await import("./glSetup-DMaDgrEj.js");
|
|
102
|
+
},
|
|
103
|
+
setupWGPU: y ? void 0 : (t, n, r) => (E ??= A(k, "WebGPU").createAuroraWGPUSetup({
|
|
2375
104
|
canvas: e,
|
|
2376
105
|
opaquePresentation: a.opaque,
|
|
2377
|
-
getCursorScalars:
|
|
2378
|
-
getConfig: () =>
|
|
2379
|
-
getReducedMotion: () =>
|
|
2380
|
-
getRenderTime: (e) =>
|
|
2381
|
-
pointerField:
|
|
106
|
+
getCursorScalars: h,
|
|
107
|
+
getConfig: () => u,
|
|
108
|
+
getReducedMotion: () => j.reducedMotion,
|
|
109
|
+
getRenderTime: (e) => q(u, e, d, j.reducedMotion),
|
|
110
|
+
pointerField: f,
|
|
2382
111
|
getDecodedImage: () => _.getDecodedImage(),
|
|
2383
112
|
registerImageUploader: (e) => _.setImageUploader(e)
|
|
2384
|
-
}),
|
|
2385
|
-
setupGL:
|
|
113
|
+
}), E(t, n, r)),
|
|
114
|
+
setupGL: (e) => (w ??= A(D, "WebGL 2").createAuroraGLSetup({
|
|
2386
115
|
opaquePresentation: a.opaque,
|
|
2387
|
-
getConfig: () =>
|
|
2388
|
-
getReducedMotion: () =>
|
|
2389
|
-
getRenderTime: (e) =>
|
|
2390
|
-
getCursorScalars:
|
|
2391
|
-
pointerField:
|
|
116
|
+
getConfig: () => u,
|
|
117
|
+
getReducedMotion: () => j.reducedMotion,
|
|
118
|
+
getRenderTime: (e) => q(u, e, d, j.reducedMotion),
|
|
119
|
+
getCursorScalars: h,
|
|
120
|
+
pointerField: f,
|
|
2392
121
|
imageCoordinator: _,
|
|
2393
122
|
registerConfigUploader: (e) => {
|
|
2394
|
-
|
|
123
|
+
g = e;
|
|
2395
124
|
}
|
|
2396
|
-
}),
|
|
125
|
+
}), w(e)),
|
|
2397
126
|
onInitError: r.onInitError ? (e) => r.onInitError?.(e instanceof Error ? e : Error(String(e))) : void 0,
|
|
2398
127
|
onStatus: r.onRendererStatus
|
|
2399
128
|
});
|
|
2400
|
-
v && r.onRendererStatus?.(
|
|
2401
|
-
function
|
|
2402
|
-
|
|
129
|
+
v && r.onRendererStatus?.(O("webgl2", "Software renderer", v));
|
|
130
|
+
function M(e, t, n = .8) {
|
|
131
|
+
K(u) && (p = n, f.setActive(!0), f.setPointer(e, t), j.reducedMotion || j.wake());
|
|
2403
132
|
}
|
|
2404
|
-
function
|
|
2405
|
-
|
|
133
|
+
function ee() {
|
|
134
|
+
f.setActive(!1), j.reducedMotion || j.wake();
|
|
2406
135
|
}
|
|
2407
|
-
function
|
|
2408
|
-
|
|
136
|
+
function N(e) {
|
|
137
|
+
m = e, j.reducedMotion || j.wake();
|
|
2409
138
|
}
|
|
2410
|
-
function
|
|
139
|
+
function P(e) {
|
|
2411
140
|
let t = Math.min(1, Math.max(0, e));
|
|
2412
|
-
t !==
|
|
141
|
+
t !== d && (d = t, u.interactivity?.scroll === !0 && !j.reducedMotion && j.wake());
|
|
2413
142
|
}
|
|
2414
|
-
function
|
|
2415
|
-
|
|
143
|
+
function F() {
|
|
144
|
+
j.armAsync().catch(() => void 0);
|
|
2416
145
|
}
|
|
2417
|
-
function
|
|
2418
|
-
return
|
|
146
|
+
function I() {
|
|
147
|
+
return j.armAsync();
|
|
2419
148
|
}
|
|
2420
|
-
return _.ensureDecoded(
|
|
2421
|
-
arm: () =>
|
|
2422
|
-
armAsync: () =>
|
|
149
|
+
return _.ensureDecoded(u), r.mode !== "capture" && re(r) && F(), {
|
|
150
|
+
arm: () => F(),
|
|
151
|
+
armAsync: () => I(),
|
|
2423
152
|
update: (e) => {
|
|
2424
|
-
|
|
153
|
+
u = e, s(e.alpha), K(e) || f.setActive(!1), g?.(e), _.ensureDecoded(e), j.wake();
|
|
2425
154
|
},
|
|
2426
|
-
setCursor:
|
|
2427
|
-
clearCursor:
|
|
2428
|
-
setCursorRadius:
|
|
2429
|
-
setScrollProgress:
|
|
155
|
+
setCursor: M,
|
|
156
|
+
clearCursor: ee,
|
|
157
|
+
setCursorRadius: N,
|
|
158
|
+
setScrollProgress: P,
|
|
2430
159
|
get reducedMotion() {
|
|
2431
|
-
return
|
|
160
|
+
return j.reducedMotion;
|
|
2432
161
|
},
|
|
2433
|
-
pause: (e = "manual") =>
|
|
2434
|
-
resume: (e = "manual") =>
|
|
2435
|
-
renderAt: (e) =>
|
|
162
|
+
pause: (e = "manual") => j.suspend(e),
|
|
163
|
+
resume: (e = "manual") => j.resume(e),
|
|
164
|
+
renderAt: (e) => j.renderAt(e),
|
|
2436
165
|
dispose: () => {
|
|
2437
|
-
|
|
166
|
+
j.dispose(), a.opaque && (e.style.opacity = o);
|
|
2438
167
|
}
|
|
2439
168
|
};
|
|
2440
169
|
}
|
|
2441
170
|
//#endregion
|
|
2442
171
|
//#region src/components/aurora/composables/configSource.ts
|
|
2443
|
-
function
|
|
172
|
+
function Y(e) {
|
|
2444
173
|
return typeof e == "function" ? e : e && typeof e == "object" && "value" in e ? () => e.value : () => e;
|
|
2445
174
|
}
|
|
2446
175
|
//#endregion
|
|
2447
176
|
//#region src/components/aurora/composables/useAurora.ts
|
|
2448
|
-
var
|
|
2449
|
-
function
|
|
177
|
+
var ce = 500;
|
|
178
|
+
function le(e) {
|
|
2450
179
|
if (typeof window > "u") return () => {};
|
|
2451
180
|
if (typeof window.requestIdleCallback == "function") {
|
|
2452
181
|
let t = window.requestIdleCallback(() => e(), { timeout: 2e3 });
|
|
@@ -2463,8 +192,8 @@ function Gt(e) {
|
|
|
2463
192
|
r = !0, cancelAnimationFrame(t), n !== void 0 && clearTimeout(n);
|
|
2464
193
|
};
|
|
2465
194
|
}
|
|
2466
|
-
function
|
|
2467
|
-
let o =
|
|
195
|
+
function X(t, n, i = {}, a = {}) {
|
|
196
|
+
let o = Y(n), s = a.renderMode === "css", c = null, l = null, u = null, d = null, f = null, p = null, m = !1, h = B(!1), g = B(!1), _ = 0, v = 0, y = !1;
|
|
2468
197
|
function b() {
|
|
2469
198
|
if (g.value = !1, typeof requestAnimationFrame != "function" || (v = performance.now() + 500, _ !== 0)) return;
|
|
2470
199
|
let e = (t) => {
|
|
@@ -2479,18 +208,18 @@ function Kt(t, n, r = {}, i = {}) {
|
|
|
2479
208
|
function x() {
|
|
2480
209
|
_ !== 0 && cancelAnimationFrame(_), _ = 0, g.value = !1;
|
|
2481
210
|
}
|
|
2482
|
-
let S =
|
|
211
|
+
let S = V(s ? D() : E("webgl2")), C = r({
|
|
2483
212
|
target: t,
|
|
2484
213
|
trackExit: !0,
|
|
2485
|
-
enabled:
|
|
214
|
+
enabled: A(() => !s && o().interactivity?.scroll === !0)
|
|
2486
215
|
});
|
|
2487
|
-
d =
|
|
2488
|
-
let w =
|
|
216
|
+
d = U(C, (e) => c?.setScrollProgress(e), { flush: "sync" });
|
|
217
|
+
let w = i.mode === "capture" || i.initStrategy === "eager";
|
|
2489
218
|
function T(e) {
|
|
2490
219
|
let t = e instanceof Error ? e : Error(String(e));
|
|
2491
|
-
S.value =
|
|
220
|
+
S.value = O(S.value.engine, S.value.adapter, t), i.onInitError?.(t);
|
|
2492
221
|
}
|
|
2493
|
-
async function
|
|
222
|
+
async function k() {
|
|
2494
223
|
if (m || !c) return;
|
|
2495
224
|
m = !0;
|
|
2496
225
|
let e = c;
|
|
@@ -2500,20 +229,20 @@ function Kt(t, n, r = {}, i = {}) {
|
|
|
2500
229
|
S.value.phase !== "error" && T(e);
|
|
2501
230
|
return;
|
|
2502
231
|
}
|
|
2503
|
-
c !== e || S.value.engine === "css" || (h.value = !0, e.update(o()), e.setScrollProgress(C.value), b(), y = !0, l =
|
|
232
|
+
c !== e || S.value.engine === "css" || (h.value = !0, e.update(o()), e.setScrollProgress(C.value), b(), y = !0, l = U(o, (t) => {
|
|
2504
233
|
e.update(t), b();
|
|
2505
234
|
}, { deep: !0 }));
|
|
2506
235
|
}
|
|
2507
|
-
return
|
|
236
|
+
return L(() => {
|
|
2508
237
|
let n = t.value;
|
|
2509
238
|
if (!n || s) return;
|
|
2510
239
|
try {
|
|
2511
|
-
c =
|
|
240
|
+
c = J(n, o(), {
|
|
2512
241
|
initStrategy: "deferred",
|
|
2513
|
-
...
|
|
242
|
+
...i,
|
|
2514
243
|
onRendererStatus: (e) => {
|
|
2515
244
|
let t = e.phase === "ready", n = t && !h.value && y;
|
|
2516
|
-
S.value = e, h.value = t, t ? n && b() : x(),
|
|
245
|
+
S.value = e, h.value = t, t ? n && b() : x(), i.onRendererStatus?.(e);
|
|
2517
246
|
}
|
|
2518
247
|
});
|
|
2519
248
|
} catch (e) {
|
|
@@ -2521,20 +250,20 @@ function Kt(t, n, r = {}, i = {}) {
|
|
|
2521
250
|
return;
|
|
2522
251
|
}
|
|
2523
252
|
if (w) {
|
|
2524
|
-
|
|
253
|
+
k();
|
|
2525
254
|
return;
|
|
2526
255
|
}
|
|
2527
256
|
p = e(t, {
|
|
2528
257
|
pause: () => c?.pause("off-screen-io"),
|
|
2529
258
|
resume: () => c?.resume("off-screen-io")
|
|
2530
259
|
}, { pauseWhenHidden: !1 });
|
|
2531
|
-
let
|
|
2532
|
-
u =
|
|
2533
|
-
!e || m || f || (f =
|
|
2534
|
-
f = null,
|
|
260
|
+
let r = p.isIntersecting;
|
|
261
|
+
u = U(r, (e) => {
|
|
262
|
+
!e || m || f || (f = le(() => {
|
|
263
|
+
f = null, r.value && k();
|
|
2535
264
|
}));
|
|
2536
265
|
}, { immediate: !0 });
|
|
2537
|
-
}),
|
|
266
|
+
}), te(() => {
|
|
2538
267
|
x(), f?.(), u?.(), l?.(), d?.(), p?.dispose(), c?.dispose(), c = null;
|
|
2539
268
|
}), {
|
|
2540
269
|
setCursor: (e, t, n) => c?.setCursor(e, t, n),
|
|
@@ -2543,9 +272,9 @@ function Kt(t, n, r = {}, i = {}) {
|
|
|
2543
272
|
renderAt: (e) => c?.renderAt(e),
|
|
2544
273
|
pause: () => c?.pause(),
|
|
2545
274
|
resume: () => c?.resume(),
|
|
2546
|
-
isArmed:
|
|
2547
|
-
isSettled:
|
|
2548
|
-
rendererStatus:
|
|
275
|
+
isArmed: z(h),
|
|
276
|
+
isSettled: z(g),
|
|
277
|
+
rendererStatus: z(S)
|
|
2549
278
|
};
|
|
2550
279
|
}
|
|
2551
280
|
//#endregion
|
|
@@ -2554,7 +283,7 @@ function Z(e) {
|
|
|
2554
283
|
let t = Math.max(0, Math.min(1, e));
|
|
2555
284
|
return t <= .0031308 ? t * 12.92 : 1.055 * t ** (1 / 2.4) - .055;
|
|
2556
285
|
}
|
|
2557
|
-
function
|
|
286
|
+
function ue([e, t, n]) {
|
|
2558
287
|
let r = .76, i = Math.min(e, Math.min(t, n)), a = i < .08 ? i - 6.25 * i * i : .04, o = e - a, s = t - a, c = n - a, l = Math.max(o, Math.max(s, c)), u = (e) => Math.max(0, Math.min(1, e));
|
|
2559
288
|
if (l < r) return [
|
|
2560
289
|
u(o),
|
|
@@ -2570,10 +299,10 @@ function qt([e, t, n]) {
|
|
|
2570
299
|
u(c + (f - c) * m)
|
|
2571
300
|
];
|
|
2572
301
|
}
|
|
2573
|
-
function
|
|
302
|
+
function de([e, t, n]) {
|
|
2574
303
|
return .2126 * e + .7152 * t + .0722 * n;
|
|
2575
304
|
}
|
|
2576
|
-
function
|
|
305
|
+
function fe(e, t) {
|
|
2577
306
|
let n = e.length;
|
|
2578
307
|
if (n === 0) return [
|
|
2579
308
|
0,
|
|
@@ -2588,7 +317,7 @@ function Yt(e, t) {
|
|
|
2588
317
|
s[2] + (c[2] - s[2]) * o
|
|
2589
318
|
];
|
|
2590
319
|
}
|
|
2591
|
-
function
|
|
320
|
+
function pe(e, t, n, r) {
|
|
2592
321
|
let i = 0, a = 0, o = 0;
|
|
2593
322
|
for (let s of e) {
|
|
2594
323
|
let e = n - s.x, c = r - s.y, l = (s.angle ?? 0) * Math.PI / 180, u = Math.cos(l), d = Math.sin(l), f = u * e + d * c, p = -d * e + u * c, m = f / Math.max(s.elongation ?? 1, .01), h = p, g = m * m + h * h, _ = Math.max(s.radius, .01), v = Math.exp(-t * g / (_ * _));
|
|
@@ -2600,33 +329,33 @@ function Xt(e, t, n, r) {
|
|
|
2600
329
|
valueMod: a / s
|
|
2601
330
|
};
|
|
2602
331
|
}
|
|
2603
|
-
function
|
|
2604
|
-
let r = e.palette.map((e) =>
|
|
2605
|
-
o[0] *
|
|
2606
|
-
o[1] *
|
|
2607
|
-
o[2] *
|
|
332
|
+
function me(e, t, n) {
|
|
333
|
+
let r = e.palette.map((e) => s(e)), { paletteId: i, valueMod: a } = pe(e.nuclei, e.softmaxBeta, t, n), o = fe(r, i), c = 1 + e.valueVariance * a, l = [
|
|
334
|
+
o[0] * c,
|
|
335
|
+
o[1] * c,
|
|
336
|
+
o[2] * c
|
|
2608
337
|
];
|
|
2609
|
-
return
|
|
2610
|
-
Math.max(0, Math.min(1,
|
|
2611
|
-
Math.max(0, Math.min(1,
|
|
2612
|
-
Math.max(0, Math.min(1,
|
|
338
|
+
return l = ue(l), l = [
|
|
339
|
+
Math.max(0, Math.min(1, l[0] * .985 + .008)),
|
|
340
|
+
Math.max(0, Math.min(1, l[1] * .985 + .008)),
|
|
341
|
+
Math.max(0, Math.min(1, l[2] * .985 + .008))
|
|
2613
342
|
], [
|
|
2614
|
-
Z(
|
|
2615
|
-
Z(
|
|
2616
|
-
Z(
|
|
343
|
+
Z(l[0]),
|
|
344
|
+
Z(l[1]),
|
|
345
|
+
Z(l[2])
|
|
2617
346
|
];
|
|
2618
347
|
}
|
|
2619
|
-
function
|
|
348
|
+
function he([e, t, n]) {
|
|
2620
349
|
let r = (e) => Math.round(Math.max(0, Math.min(1, e)) * 255);
|
|
2621
350
|
return `rgb(${r(e)}, ${r(t)}, ${r(n)})`;
|
|
2622
351
|
}
|
|
2623
|
-
function
|
|
2624
|
-
return
|
|
352
|
+
function ge(e) {
|
|
353
|
+
return de(e.map((e) => {
|
|
2625
354
|
let t = Math.max(0, Math.min(1, e));
|
|
2626
355
|
return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
2627
356
|
}));
|
|
2628
357
|
}
|
|
2629
|
-
function
|
|
358
|
+
function _e(e, t = {}) {
|
|
2630
359
|
let n = Math.max(2, Math.min(16, Math.round(t.grid ?? 8))), r = [], i = 0, a = [
|
|
2631
360
|
0,
|
|
2632
361
|
0,
|
|
@@ -2639,13 +368,13 @@ function en(e, t = {}) {
|
|
|
2639
368
|
0
|
|
2640
369
|
];
|
|
2641
370
|
for (let t = 0; t < n; t++) for (let s = 0; s < n; s++) {
|
|
2642
|
-
let c = (s + .5) / n, l = (t + .5) / n, u =
|
|
371
|
+
let c = (s + .5) / n, l = (t + .5) / n, u = me(e, c, l);
|
|
2643
372
|
r.push({
|
|
2644
373
|
x: c,
|
|
2645
374
|
y: l,
|
|
2646
375
|
color: u
|
|
2647
376
|
});
|
|
2648
|
-
let d =
|
|
377
|
+
let d = ge(u);
|
|
2649
378
|
i += d;
|
|
2650
379
|
let f = (l < .5 ? 0 : 2) + (c < .5 ? 0 : 1);
|
|
2651
380
|
a[f] += d, o[f] += 1;
|
|
@@ -2662,10 +391,10 @@ function en(e, t = {}) {
|
|
|
2662
391
|
];
|
|
2663
392
|
for (let e of r) l[0] += e.color[0], l[1] += e.color[1], l[2] += e.color[2];
|
|
2664
393
|
l[0] /= r.length, l[1] /= r.length, l[2] /= r.length;
|
|
2665
|
-
let u =
|
|
394
|
+
let u = ye(r, n);
|
|
2666
395
|
if (u) return {
|
|
2667
396
|
backgroundImage: `url("${u}")`,
|
|
2668
|
-
backgroundColor:
|
|
397
|
+
backgroundColor: he(l),
|
|
2669
398
|
metrics: {
|
|
2670
399
|
mean: s,
|
|
2671
400
|
quadrants: c
|
|
@@ -2677,14 +406,33 @@ function en(e, t = {}) {
|
|
|
2677
406
|
let t = (e.x * 100).toFixed(2), n = (e.y * 100).toFixed(2), r = (e) => Math.round(Math.max(0, Math.min(1, e)) * 255), [i, a, o] = e.color, s = `rgba(${r(i)}, ${r(a)}, ${r(o)}, 0.7)`, c = `rgba(${r(i)}, ${r(a)}, ${r(o)}, 0)`;
|
|
2678
407
|
return `radial-gradient(circle ${d.toFixed(2)}% at ${t}% ${n}%, ${s} 0%, ${c} 100%)`;
|
|
2679
408
|
}).join(", "),
|
|
2680
|
-
backgroundColor:
|
|
409
|
+
backgroundColor: he(l),
|
|
2681
410
|
metrics: {
|
|
2682
411
|
mean: s,
|
|
2683
412
|
quadrants: c
|
|
2684
413
|
}
|
|
2685
414
|
};
|
|
2686
415
|
}
|
|
2687
|
-
function
|
|
416
|
+
function ve(e) {
|
|
417
|
+
let t = e.palette.map((e) => [
|
|
418
|
+
e.L,
|
|
419
|
+
e.C,
|
|
420
|
+
e.h
|
|
421
|
+
]), n = e.nuclei.map((e) => [
|
|
422
|
+
e.radius,
|
|
423
|
+
e.elongation ?? 1,
|
|
424
|
+
e.angle ?? 0,
|
|
425
|
+
e.paletteBias,
|
|
426
|
+
e.valueBias
|
|
427
|
+
]);
|
|
428
|
+
return JSON.stringify([
|
|
429
|
+
t,
|
|
430
|
+
e.softmaxBeta,
|
|
431
|
+
e.valueVariance,
|
|
432
|
+
n
|
|
433
|
+
]);
|
|
434
|
+
}
|
|
435
|
+
function ye(e, t) {
|
|
2688
436
|
if (typeof document > "u") return null;
|
|
2689
437
|
let n;
|
|
2690
438
|
try {
|
|
@@ -2709,10 +457,10 @@ function tn(e, t) {
|
|
|
2709
457
|
}
|
|
2710
458
|
//#endregion
|
|
2711
459
|
//#region src/components/aurora/Aurora.vue?vue&type=script&setup=true&lang.ts
|
|
2712
|
-
var
|
|
460
|
+
var be = ["data-aurora-substrate", "data-aurora-settled"], xe = /*#__PURE__*/ t(/* @__PURE__ */ ee({
|
|
2713
461
|
__name: "Aurora",
|
|
2714
462
|
props: {
|
|
2715
|
-
config: { default: () =>
|
|
463
|
+
config: { default: () => u },
|
|
2716
464
|
runtimeOptions: {},
|
|
2717
465
|
onInitError: {},
|
|
2718
466
|
renderMode: { default: "auto" },
|
|
@@ -2720,15 +468,32 @@ var nn = ["data-aurora-substrate", "data-aurora-settled"], rn = /*#__PURE__*/ t(
|
|
|
2720
468
|
},
|
|
2721
469
|
emits: ["rendererStatus"],
|
|
2722
470
|
setup(e, { expose: t, emit: n }) {
|
|
2723
|
-
let r = n, i = e, a =
|
|
471
|
+
let r = n, i = e, a = G(i.renderMode, { forceWebGLUnderSoftwareRaster: i.runtimeOptions?.forceWebGLUnderSoftwareRaster ?? !1 }), o = A(() => String(Math.max(0, Math.min(1, i.opacityCeiling)))), s = B(null), c = N(), l = c?.appContext.config.errorHandler, u = l ? (e) => l(e, c?.proxy ?? null, "Aurora initialization") : void 0, d = X(s, () => i.config, {
|
|
2724
472
|
...i.runtimeOptions ?? {},
|
|
2725
473
|
onInitError: i.onInitError ?? i.runtimeOptions?.onInitError ?? u
|
|
2726
474
|
}, { renderMode: a });
|
|
2727
|
-
|
|
475
|
+
U(d.rendererStatus, (e) => r("rendererStatus", e), {
|
|
2728
476
|
immediate: !0,
|
|
2729
477
|
flush: "sync"
|
|
2730
478
|
});
|
|
2731
|
-
let f =
|
|
479
|
+
let f = V([null, null]), p = B(0), m = B(0);
|
|
480
|
+
U(() => ve(i.config), () => {
|
|
481
|
+
let e = _e(i.config);
|
|
482
|
+
if (!f.value[0]) {
|
|
483
|
+
f.value = [e, null];
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
let t = +(p.value === 0), n = [...f.value];
|
|
487
|
+
n[t] = e, f.value = n, p.value = t, m.value += 1;
|
|
488
|
+
}, { immediate: !0 });
|
|
489
|
+
let h = /* @__PURE__ */ new WeakMap(), g = (e) => {
|
|
490
|
+
if (!e) return;
|
|
491
|
+
let t = h.get(e);
|
|
492
|
+
return t || (t = {
|
|
493
|
+
"--aurora-ground-image": e.backgroundImage,
|
|
494
|
+
"--aurora-ground-color": e.backgroundColor
|
|
495
|
+
}, h.set(e, t)), t;
|
|
496
|
+
};
|
|
2732
497
|
return t({
|
|
2733
498
|
config: i.config,
|
|
2734
499
|
canvasRef: s,
|
|
@@ -2741,30 +506,39 @@ var nn = ["data-aurora-substrate", "data-aurora-settled"], rn = /*#__PURE__*/ t(
|
|
|
2741
506
|
isArmed: d.isArmed,
|
|
2742
507
|
isSettled: d.isSettled,
|
|
2743
508
|
rendererStatus: d.rendererStatus
|
|
2744
|
-
}), (e, t) => (
|
|
509
|
+
}), (e, t) => (R(), j("div", {
|
|
2745
510
|
class: "aurora-root h-full w-full overflow-hidden",
|
|
2746
|
-
"data-aurora-substrate":
|
|
2747
|
-
"data-aurora-settled":
|
|
2748
|
-
style:
|
|
2749
|
-
}, [
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
511
|
+
"data-aurora-substrate": H(a),
|
|
512
|
+
"data-aurora-settled": H(d).isSettled.value ? "" : void 0,
|
|
513
|
+
style: I({ "--aurora-ceiling": o.value })
|
|
514
|
+
}, [(R(!0), j(k, null, ne(f.value, (e, t, n, r) => {
|
|
515
|
+
let i = [
|
|
516
|
+
e,
|
|
517
|
+
p.value === t,
|
|
518
|
+
m.value
|
|
519
|
+
];
|
|
520
|
+
if (r && r.el && r.key === t && P(r, i)) return r;
|
|
521
|
+
let a = (R(), j("div", {
|
|
522
|
+
key: t,
|
|
523
|
+
class: "aurora-placeholder h-full min-h-0 w-full",
|
|
524
|
+
"aria-hidden": "true",
|
|
525
|
+
"data-aurora-ground-active": p.value === t ? "" : void 0,
|
|
526
|
+
"data-aurora-ground-fade": p.value === t && m.value > 0 ? "" : void 0,
|
|
527
|
+
style: I(g(e))
|
|
528
|
+
}, null, 12, ["data-aurora-ground-active", "data-aurora-ground-fade"]));
|
|
529
|
+
return a.memo = i, a;
|
|
530
|
+
}, t, 0), 128)), M("div", { class: F(["aurora-canvas-layer h-full min-h-0 w-full", { "aurora-canvas-layer--armed": H(d).isArmed.value }]) }, [M("canvas", {
|
|
2757
531
|
ref_key: "canvasRef",
|
|
2758
532
|
ref: s,
|
|
2759
533
|
"aria-hidden": "true",
|
|
2760
|
-
class:
|
|
2761
|
-
}, null, 2)], 2)], 12,
|
|
534
|
+
class: F(["aurora-canvas block h-full w-full", { "aurora-canvas--armed": H(d).isArmed.value }])
|
|
535
|
+
}, null, 2)], 2)], 12, be));
|
|
2762
536
|
}
|
|
2763
|
-
}), [["__scopeId", "data-v-
|
|
537
|
+
}), [["__scopeId", "data-v-1dfb5751"]]);
|
|
2764
538
|
//#endregion
|
|
2765
539
|
//#region src/components/aurora/composables/useCursorInteraction.ts
|
|
2766
|
-
function
|
|
2767
|
-
let r =
|
|
540
|
+
function Se(e, t, n) {
|
|
541
|
+
let r = Y(t), i = n.hitFraction ?? .35, a = null, o = null;
|
|
2768
542
|
function s(e, t) {
|
|
2769
543
|
let n = t.getBoundingClientRect();
|
|
2770
544
|
return {
|
|
@@ -2851,10 +625,10 @@ function an(e, t, n) {
|
|
|
2851
625
|
}, a = n.getBoundingClientRect(), o = l((i.clientX - a.left) / Math.max(a.width, 1), (i.clientY - a.top) / Math.max(a.height, 1));
|
|
2852
626
|
o !== null && r().nuclei.length > 1 && (r().nuclei.splice(o, 1), t.preventDefault());
|
|
2853
627
|
}
|
|
2854
|
-
return
|
|
628
|
+
return L(() => {
|
|
2855
629
|
let t = e.value;
|
|
2856
630
|
t && (t.addEventListener("pointermove", p), t.addEventListener("pointerleave", m), t.addEventListener("pointerdown", h), t.addEventListener("pointerup", g), t.addEventListener("pointercancel", g), t.addEventListener("contextmenu", _));
|
|
2857
|
-
}),
|
|
631
|
+
}), te(() => {
|
|
2858
632
|
let t = e.value;
|
|
2859
633
|
t && (t.removeEventListener("pointermove", p), t.removeEventListener("pointerleave", m), t.removeEventListener("pointerdown", h), t.removeEventListener("pointerup", g), t.removeEventListener("pointercancel", g), t.removeEventListener("contextmenu", _));
|
|
2860
634
|
}), { isDragging: () => a };
|
|
@@ -2885,7 +659,7 @@ var $ = {
|
|
|
2885
659
|
calm: 16,
|
|
2886
660
|
vivid: 44
|
|
2887
661
|
}
|
|
2888
|
-
},
|
|
662
|
+
}, Ce = {
|
|
2889
663
|
still: {
|
|
2890
664
|
nucleiDrift: 0,
|
|
2891
665
|
paletteDrift: 0,
|
|
@@ -2904,8 +678,8 @@ var $ = {
|
|
|
2904
678
|
warpDrift: .008,
|
|
2905
679
|
breathDepth: .05
|
|
2906
680
|
}
|
|
2907
|
-
},
|
|
2908
|
-
function
|
|
681
|
+
}, we = .61803398875;
|
|
682
|
+
function Te(e, t = "composed") {
|
|
2909
683
|
let n = Math.max(1, Math.min(8, Math.round(e))), r = [
|
|
2910
684
|
[.33, .33],
|
|
2911
685
|
[.67, .67],
|
|
@@ -2917,8 +691,8 @@ function cn(e, t = "composed") {
|
|
|
2917
691
|
[.67, .5]
|
|
2918
692
|
], i = (e) => {
|
|
2919
693
|
if (t === "scattered") {
|
|
2920
|
-
let t = e *
|
|
2921
|
-
return [
|
|
694
|
+
let t = e * we * Math.PI * 2, r = .12 + .3 * Math.sqrt((e + .5) / n);
|
|
695
|
+
return [l(.5 + r * Math.cos(t), .1, .9), l(.5 + r * Math.sin(t), .1, .9)];
|
|
2922
696
|
}
|
|
2923
697
|
if (t === "centred") {
|
|
2924
698
|
if (n === 1) return [.5, .5];
|
|
@@ -2940,33 +714,33 @@ function cn(e, t = "composed") {
|
|
|
2940
714
|
};
|
|
2941
715
|
});
|
|
2942
716
|
}
|
|
2943
|
-
var
|
|
2944
|
-
function
|
|
717
|
+
var Ee = .03;
|
|
718
|
+
function De(e, t, n) {
|
|
2945
719
|
let r = e.length;
|
|
2946
720
|
if (r === 0 || t <= 0) return;
|
|
2947
|
-
let i = e.reduce((e, t) => e + t.C, 0) / r,
|
|
721
|
+
let i = e.reduce((e, t) => e + t.C, 0) / r, o = Math.min(.22, i * 1.5), s = (e, t, n) => a({
|
|
2948
722
|
L: e,
|
|
2949
723
|
C: t,
|
|
2950
724
|
h: n
|
|
2951
725
|
}).C;
|
|
2952
726
|
if (e.forEach((e, n) => {
|
|
2953
|
-
let r = n % 2 == 0 ?
|
|
2954
|
-
e.C =
|
|
727
|
+
let r = n % 2 == 0 ? o : Ee;
|
|
728
|
+
e.C = s(e.L, l(Q(e.C, r, t), 0, .4), e.h);
|
|
2955
729
|
}), !n) return;
|
|
2956
|
-
let
|
|
2957
|
-
for (let t = 1; t < r; t++) e[t].L < e[
|
|
2958
|
-
let
|
|
2959
|
-
|
|
730
|
+
let c = 0;
|
|
731
|
+
for (let t = 1; t < r; t++) e[t].L < e[c].L && (c = t);
|
|
732
|
+
let u = e[c];
|
|
733
|
+
u.C = s(u.L, Ee, u.h);
|
|
2960
734
|
}
|
|
2961
|
-
function
|
|
735
|
+
function Oe(e) {
|
|
2962
736
|
return e < .4 ? "fbm" : e < .75 ? "hybrid" : "cellular";
|
|
2963
737
|
}
|
|
2964
|
-
function
|
|
2965
|
-
let n =
|
|
2966
|
-
e.warpAmount =
|
|
738
|
+
function ke(e, t) {
|
|
739
|
+
let n = l(t, 0, 1);
|
|
740
|
+
e.warpAmount = l(Q(.2, .6, n), 0, .6), e.warpScale = l(Q(1, 2.6, n), .5, 3), e.warpMode = Oe(n), e.noiseOctaves = n < .5 ? 3 : n < .85 ? 4 : 5;
|
|
2967
741
|
}
|
|
2968
|
-
function
|
|
2969
|
-
let r =
|
|
742
|
+
function Ae(e, t, n) {
|
|
743
|
+
let r = l(n, 0, 1);
|
|
2970
744
|
switch (t) {
|
|
2971
745
|
case "watercolor":
|
|
2972
746
|
e.wetEdge = r, e.granulation = r * .8;
|
|
@@ -2989,49 +763,49 @@ function pn(e, t, n) {
|
|
|
2989
763
|
break;
|
|
2990
764
|
}
|
|
2991
765
|
}
|
|
2992
|
-
function
|
|
766
|
+
function je(e, t) {
|
|
2993
767
|
switch (t) {
|
|
2994
|
-
case "watercolor": return
|
|
768
|
+
case "watercolor": return l(e.wetEdge, 0, 1);
|
|
2995
769
|
case "oil":
|
|
2996
770
|
case "vangogh":
|
|
2997
771
|
case "pastel":
|
|
2998
772
|
case "oil-pastel":
|
|
2999
773
|
case "crayon":
|
|
3000
|
-
case "kuwahara": return
|
|
774
|
+
case "kuwahara": return l(e.strokeAmount, 0, 1);
|
|
3001
775
|
case "metal":
|
|
3002
|
-
case "metal-gradient": return
|
|
776
|
+
case "metal-gradient": return l((e.metalPolish ?? 1) / 4, 0, 1);
|
|
3003
777
|
}
|
|
3004
778
|
}
|
|
3005
|
-
function
|
|
779
|
+
function Me(e) {
|
|
3006
780
|
return e.nucleiDrift + e.paletteDrift + e.warpDrift > .001 ? "drifting" : e.breathDepth > .001 ? "breathing" : "still";
|
|
3007
781
|
}
|
|
3008
|
-
function
|
|
3009
|
-
return n === t ? 0 :
|
|
782
|
+
function Ne(e, t, n) {
|
|
783
|
+
return n === t ? 0 : l((e - t) / (n - t), 0, 1);
|
|
3010
784
|
}
|
|
3011
785
|
//#endregion
|
|
3012
786
|
//#region src/components/aurora/composables/atoms.ts
|
|
3013
|
-
var
|
|
3014
|
-
function
|
|
787
|
+
var Pe = {};
|
|
788
|
+
function Fe(e = Pe, t = u) {
|
|
3015
789
|
let n = {
|
|
3016
790
|
...t,
|
|
3017
791
|
palette: t.palette.map((e) => ({ ...e })),
|
|
3018
792
|
nuclei: t.nuclei.map((e) => ({ ...e })),
|
|
3019
793
|
flow: { ...t.flow }
|
|
3020
|
-
}, r = e.colorEnergy === void 0 ? void 0 :
|
|
794
|
+
}, r = e.colorEnergy === void 0 ? void 0 : l(e.colorEnergy, 0, 1);
|
|
3021
795
|
if (e.seed !== void 0) {
|
|
3022
|
-
let t = e.hueSpread === void 0 ? r === void 0 ? void 0 : Q($.hueSpread.calm, $.hueSpread.vivid, r) :
|
|
3023
|
-
n.palette =
|
|
796
|
+
let t = e.hueSpread === void 0 ? r === void 0 ? void 0 : Q($.hueSpread.calm, $.hueSpread.vivid, r) : l(e.hueSpread, 0, 180);
|
|
797
|
+
n.palette = x(e.seed, {
|
|
3024
798
|
harmony: e.harmony ?? "analogous",
|
|
3025
799
|
stopCount: 4,
|
|
3026
800
|
temperatureShift: r === void 0 ? 0 : Q($.temperatureShift.calm, $.temperatureShift.vivid, r),
|
|
3027
801
|
...t === void 0 ? {} : { hueSpread: t },
|
|
3028
802
|
...e.lightnessScheme === void 0 ? {} : { scheme: e.lightnessScheme },
|
|
3029
803
|
...e.lBand === void 0 ? {} : { lBand: e.lBand }
|
|
3030
|
-
}), e.chromaVariance !== void 0 && e.chromaVariance > 0 &&
|
|
804
|
+
}), e.chromaVariance !== void 0 && e.chromaVariance > 0 && De(n.palette, l(e.chromaVariance, 0, 1), e.chromaCounterpoint ?? !1);
|
|
3031
805
|
}
|
|
3032
|
-
if (r !== void 0 && (n.saturation =
|
|
3033
|
-
let t =
|
|
3034
|
-
n.nucleiDrift =
|
|
806
|
+
if (r !== void 0 && (n.saturation = l(Q($.saturation.calm, $.saturation.vivid, r), .6, 1.3), n.valueVariance = l(Q($.valueVariance.calm, $.valueVariance.vivid, r), 0, .3), n.breathDepth = l(Q($.breathDepth.calm, $.breathDepth.vivid, r), 0, .15)), e.zones !== void 0 && (n.nuclei = Te(e.zones.count, e.zones.arrangement ?? "composed")), e.noise !== void 0 && ke(n, e.noise), e.medium !== void 0 && (n.medium = e.medium.kind, (e.medium.kind === "vangogh" || e.medium.kind === "oil-pastel") && (n.strokeOrient = "tensor"), e.medium.kind !== "smooth" && e.medium.amount !== void 0 && Ae(n, e.medium.kind, e.medium.amount)), e.motion !== void 0) {
|
|
807
|
+
let t = Ce[e.motion];
|
|
808
|
+
n.nucleiDrift = l(t.nucleiDrift, 0, .05), n.paletteDrift = l(t.paletteDrift, 0, .04), n.warpDrift = l(t.warpDrift, 0, .015), n.breathDepth = l(e.motion === "still" ? 0 : Math.max(n.breathDepth, t.breathDepth), 0, .15);
|
|
3035
809
|
}
|
|
3036
810
|
if (e.interactivity !== void 0) {
|
|
3037
811
|
let t = e.interactivity, r = e.medium?.kind !== void 0 && e.medium.kind !== "smooth" ? e.interactivity.light : void 0;
|
|
@@ -3039,33 +813,33 @@ function vn(e = _n, t = z) {
|
|
|
3039
813
|
...r === void 0 ? {} : { light: r },
|
|
3040
814
|
...t.scroll === void 0 ? {} : { scroll: t.scroll },
|
|
3041
815
|
swirl: t.swirl ?? !0,
|
|
3042
|
-
amplitude: t.amplitude === void 0 ? .5 :
|
|
816
|
+
amplitude: t.amplitude === void 0 ? .5 : l(t.amplitude, 0, 1)
|
|
3043
817
|
};
|
|
3044
818
|
}
|
|
3045
819
|
return n;
|
|
3046
820
|
}
|
|
3047
|
-
function
|
|
821
|
+
function Ie(e) {
|
|
3048
822
|
let t = e.medium, n = e.interactivity, r = n && (n.scroll !== void 0 || n.swirl !== void 0 || n.amplitude !== void 0) ? {
|
|
3049
823
|
...n.scroll === void 0 ? {} : { scroll: n.scroll },
|
|
3050
824
|
...n.swirl === void 0 ? {} : { swirl: n.swirl },
|
|
3051
825
|
...n.amplitude === void 0 ? {} : { amplitude: n.amplitude }
|
|
3052
826
|
} : void 0, i = {
|
|
3053
|
-
seed: e.palette.length > 0 ?
|
|
827
|
+
seed: e.palette.length > 0 ? o(e.palette[0]) : "#3a7bd5",
|
|
3054
828
|
harmony: "analogous",
|
|
3055
|
-
colorEnergy:
|
|
829
|
+
colorEnergy: Ne(e.saturation, $.saturation.calm, $.saturation.vivid),
|
|
3056
830
|
zones: {
|
|
3057
831
|
count: Math.max(1, Math.min(8, e.nuclei.length)),
|
|
3058
832
|
arrangement: "composed"
|
|
3059
833
|
},
|
|
3060
|
-
noise:
|
|
3061
|
-
motion:
|
|
834
|
+
noise: Ne(e.warpAmount, .2, .6),
|
|
835
|
+
motion: Me(e)
|
|
3062
836
|
};
|
|
3063
837
|
if (t === "smooth") return {
|
|
3064
838
|
...i,
|
|
3065
839
|
medium: { kind: t },
|
|
3066
840
|
...r ? { interactivity: r } : {}
|
|
3067
841
|
};
|
|
3068
|
-
let a =
|
|
842
|
+
let a = je(e, t);
|
|
3069
843
|
return t !== "oil" && t !== "vangogh" ? {
|
|
3070
844
|
...i,
|
|
3071
845
|
medium: {
|
|
@@ -3086,4 +860,4 @@ function yn(e) {
|
|
|
3086
860
|
};
|
|
3087
861
|
}
|
|
3088
862
|
//#endregion
|
|
3089
|
-
export {
|
|
863
|
+
export { ce as AURORA_SETTLE_MS, xe as Aurora, Pe as DEFAULT_ATOMS, u as DEFAULT_AURORA_CONFIG, _ as DEFAULT_VIVIDNESS, b as IMAGE_BLUR_MAX_DEFAULT, d as IMAGE_BLUR_MIN_DEFAULT, h as MAX_NUCLEI, S as MAX_STOPS, f as PAPER_WASH_GROUND, p as STILL_FIELD, v as VIVID_TARGET, _e as auroraFallbackGround, ve as auroraGroundKey, Ie as configToAtoms, J as createAurora, i as cssToOklch, x as deriveAurora, g as flattenPalette, y as hexToOklchStop, W as isSoftwareWebGLRenderer, pe as nucleiFieldStatic, Te as nucleiPrior, o as oklchStopToHex, s as oklchToLinear, m as paletteToCssGradient, de as relativeLuminance, Fe as resolveAtoms, G as resolveRenderMode, me as sampleAuroraField, X as useAurora, Se as useCursorInteraction };
|