import { d } from './index'; /** * Cell coordinate → feature point in [0,1]², via the classic sin-fract hash * (`fract(sin(vec2(dot(p, k1), dot(p, k2))) · 43758.5453)`). * * GPU-only: `sin` at these argument magnitudes is driver-approximate and diverges from JS `Math.sin`, * so this cannot be golden-tested on the CPU. */ export declare const cellHash2: import('typegpu').TgpuFn<(p: d.Vec2f) => d.Vec2f>; /** * {@link nearest2Cells}'s options, as a discriminated union: only the two pairings the builder * actually implements are expressible. `distance` and `jitter` are NOT independent — pairing * `length` with `mix` (or `selectableSquared` with `none`) has no branch and would silently fall * through to the other form's emitted signature, so the type forbids it. * * - `{distance: 'length', jitter: 'none'}` — `length(delta)`, a true Euclidean distance per tap, and * the drifted feature point clamped into the cell interior and used directly. The fold carries real * distances, which is what a ratio reduction needs. * - `{distance: 'selectableSquared', jitter: 'mix'}` — computes Euclidean-SQUARED, Manhattan and * Chebyshev and selects between them on a runtime `metric` argument (Euclidean stays squared * through the fold; the sqrt is deferred to {@link cellReduceSelectable}), and lerps from the cell * centre (0.5, 0.5) toward the clamped point by a runtime `jitter` argument, so 0 gives a rigid * lattice and 1 full randomness. All three metric branches are always computed — see the note on * branchlessness below. */ export type Nearest2Options = { distance: 'length'; jitter: 'none'; /** Emitted WGSL identifier base. The option key is appended, so configs cannot collide. */ name?: string; } | { distance: 'selectableSquared'; jitter: 'mix'; /** Emitted WGSL identifier base. The option key is appended, so configs cannot collide. */ name?: string; }; /** * The 3×3 nearest-two-features fold, as a builder. Emits a `tgpu.fn` taking the SCALED cell-space * position and returning `vec2(d1, d2)` — the nearest and second-nearest feature distances (squared, * for `distance: 'selectableSquared'`). * * Emitted signature, by options: * - `{distance: 'length', jitter: 'none'}` → `(scaledUV: vec2f, animT: f32, seed: f32) → vec2f` * - `{distance: 'selectableSquared', jitter: 'mix'}` → * `(scaledUV: vec2f, animT: f32, seed: f32, jitter: f32, metric: f32) → vec2f` * (`metric`: 0 Euclidean-squared, 1 Manhattan, 2 Chebyshev) * * The feature points DRIFT: each is displaced by `sin/cos` of its own hash plus `animT` (the y axis * at 0.7× the rate, so the motion is not diagonal), then clamped away from the cell walls so a point * cannot cross into a neighbour and pop the topology. The phase constant is the full-precision TAU; * one consumer shipped a truncated `6.28` here and was corrected on adoption (Gate C). * * THE FOLD IS BRANCHLESS AND THAT IS DELIBERATE. `d2 = min(d2, max(dd, d1))` followed by * `d1 = min(d1, dd)` maintains the sorted pair without a conditional, because the d2 update reads * the PRE-update d1. It is exactly equivalent to the nested-select spelling — case `dd < d1` gives * `(d1, dd)`, case `dd ≥ d1` gives `(min(d2, dd), d1)` — and both spellings only ever SELECT * existing values, never arithmetic on them, so the choice is bit-neutral. The unified spelling is * why a consumer that only wants F1 can still use this fold: the extra d2 work leaves d1 untouched. * * Likewise `selectableSquared` computes all three metrics and selects, rather than JS-branching per * compile-time metric. That looks like waste but is not: the metric is a compile-time prop, so a * branch would recompile the pipeline on every change, and the dead arithmetic is a handful of ALU * ops the driver's dead-code pass largely removes. It is the FractalNoise "harmless waste" pattern. */ export declare function nearest2Cells(options: Nearest2Options): Nearest2Fn; /** {@link nearest2Cells}'s output. Trailing arguments exist only for the `selectableSquared` form. */ export type Nearest2Fn = (scaledUV: d.v2f, animT: number, seed: number, jitterAmount?: number, metric?: number) => d.v2f; /** Feature-combination modes for {@link cellReduceSelectable}, and the enum a `mode` prop maps to. */ export declare const CELL_MODES: Record; /** Distance metrics for `nearest2Cells({distance: 'selectableSquared'})`, and the prop enum. */ export declare const CELL_METRICS: Record; /** * Reduce a `(d1, d2)` pair to a scalar by {@link CELL_MODES} mode, taking the deferred Euclidean * square root when `metric` is 0. * * The sqrt lives HERE rather than in the fold so the fold can keep squared distances (one multiply * per tap instead of a sqrt), and taking it after the min-fold is exact: `sqrt` is monotonic and * correctly rounded, so `sqrt(min(a, b)) == min(sqrt a, sqrt b)`. * * `sd1`/`sd2` unify the squared and linear cases so every mode is one expression for both — e.g. * F1×F2 is `sd1·sd2`, which is `sqrt(d1·d2)`-equivalent for Euclidean and `d1·d2` otherwise. */ export declare const cellReduceSelectable: import('typegpu').TgpuFn<(d1: d.F32, d2: d.F32, metric: d.F32, mode: d.F32) => d.F32>; /** * The scale-invariant cell gradient: `pow(clamp(2·d1 / (d1 + d2)), power)`. * * The `2·d1/(d1+d2)` ratio is the reason to compute d2 at all for a fill gradient — it maps 0 at a * feature point to 1 at a cell boundary REGARDLESS of cell size, where a raw F1 would make large * cells read darker than small ones. `power` shapes how much of the interior the far colour claims. */ export declare const cellRatio: import('typegpu').TgpuFn<(d1: d.F32, d2: d.F32, power: d.F32) => d.F32>; /** * The cell-boundary line mask: `smoothstep(0, softness, (d2 − d1) / (d1 + d2))`, 0 ON the boundary * and 1 in the interior. * * `(d2 − d1)` alone would give boundary lines whose apparent width scales with cell size; dividing * by the sum normalizes it, so `softness` reads as a constant line width across the field. Callers * that expose softness in cell units should pre-scale it by the cell count. */ export declare const cellEdgeMask: import('typegpu').TgpuFn<(d1: d.F32, d2: d.F32, softness: d.F32) => d.F32>; //# sourceMappingURL=cellular.d.ts.map