import { GpuComputeNode } from '../../gpu/contract'; import { d } from '../../gpu/kit/index'; interface VoronoiGraph { layout: ReturnType['layout']; kernel: ReturnType['kernel']; } declare function makeVoronoiGraph(count: number, size: number): { layout: import('typegpu').TgpuBindGroupLayout<{ cellPos: { storage: d.WgslArray; access: "readonly"; }; voronoiTex: { storageTexture: d.WgslStorageTexture2d<"rgba16float", string>; }; }>; kernel: import('typegpu').TgpuFn<(cx: d.U32, cy: d.U32) => d.Void>; }; /** @internal The cached per-(count, size) nearest-two compute graph behind `voronoiRegionField`. */ export declare function voronoiNearest2Graph(count: number, size: number): VoronoiGraph; /** * Where one shard's value sits in a one-row data texture. * * Lay the texture out as four values per shard, so `laneWidth` is the shard count times four. * The returned GPU function takes a shard index and a value index (0 to 3) and gives the uv to * sample with `'nearestClamp'`. Built once per width. * * @example * ```ts * const cellLaneUV = cellLaneUVFor(16 * 4) * const dataAt = (idx: Expr, field: number) => dataKit.sample(call(cellLaneUV, 'cellLaneUV', [idx, floatE(field)]), 'nearestClamp').member('r') * ``` * @see voronoiRegionField, crackGeom */ export declare function cellLaneUVFor(laneWidth: number): import('typegpu').TgpuFn<(idx: d.F32, field: d.F32) => d.Vec2f>; /** @internal The record `crackGeom` returns. */ export declare const CrackGeom: d.WgslStruct<{ crackIntensity: d.F32; edgeNormal: d.Vec2f; displacedUV: d.Vec2f; disp: d.Vec2f; }>; /** * How much crack there is at a pixel, and which way the shard under it has moved. * * Takes the pixel's uv, the nearest and second-nearest shard positions (x and y, in uv), the * nearest shard's displacement (x and y, in uv) and `crackWidth` (about 0.5 to 5). Returns a * record with `crackIntensity` (0 to 1, and 0 until the shard has actually moved), * `edgeNormal` (the direction across the crack), `displacedUV` (where to sample the layer * inside) and `disp` (the displacement again, for `crackShardCompose`). * * @example * ```ts * const geom = call(crackGeom, 'crackGeom', [ctx.uv, dataAt(nearest, 0), dataAt(nearest, 1), dataAt(second, 0), dataAt(second, 1), dataAt(nearest, 2), dataAt(nearest, 3), uniforms.crackWidth]) * ``` * @see crackRefractUV, crackShardCompose, cellLaneUVFor */ export declare const crackGeom: import('typegpu').TgpuFn<(uv: d.Vec2f, nPosX: d.F32, nPosY: d.F32, sPosX: d.F32, sPosY: d.F32, dispX: d.F32, dispY: d.F32, crackWidth: d.F32) => d.WgslStruct<{ crackIntensity: d.F32; edgeNormal: d.Vec2f; displacedUV: d.Vec2f; disp: d.Vec2f; }>>; /** * Where to sample one color channel so the crack bends the light and splits it like a prism. * * `channel` is 1 for red, 0 for green and -1 for blue; the three samples land slightly apart. * `refractionStrength` (0 to 10) bends the sample across the crack and `chromaticSplit` (0 to 5) * spreads the channels. Both fade with `crackIntensity`, so unbroken glass is untouched. * * @example * ```ts * const red = child.sample(call(crackRefractUV, 'crackRefractUV', [geom.member('displacedUV'), geom.member('edgeNormal'), geom.member('crackIntensity'), uniforms.refractionStrength, uniforms.chromaticSplit, floatE(1)])) * ``` * @see crackGeom, crackShardCompose */ export declare const crackRefractUV: import('typegpu').TgpuFn<(displacedUV: d.Vec2f, edgeNormal: d.Vec2f, crackIntensity: d.F32, refractionStrength: d.F32, chromaticSplit: d.F32, channel: d.F32) => d.Vec2f>; /** * The finished glass: the three refracted channels blended into the crack, with a hint of light on tilted shards. * * Pass the plain sample at `displacedUV`, the red, green and blue samples from * `crackRefractUV`, then `crackIntensity` and `disp` from `crackGeom`, and `shardLighting` * (0 to 0.5). The samples come from the layer's texture, so unpremultiply the result before * returning it. * * @example * ```ts * const glass = call(crackShardCompose, 'crackShardCompose', [plain, red, green, blue, geom.member('crackIntensity'), geom.member('disp'), uniforms.shardLighting]) * ``` * @see crackRefractUV, crackGeom */ export declare const crackShardCompose: import('typegpu').TgpuFn<(normalColor: d.Vec4f, rFinal: d.Vec4f, gFinal: d.Vec4f, bFinal: d.Vec4f, crackIntensity: d.F32, disp: d.Vec2f, shardLighting: d.F32) => d.Vec4f>; /** * Splits the canvas into shards around random sites and records, per pixel, its shard and the next-nearest one. * * A compute hook for the `compute:` field. `count` is the number of shards, `size` the field's * resolution in pixels, `sites(seed)` your function returning the shard positions as * `[x, y, x, y, …]` in uv, and `seedProp` the prop that re-rolls them. The field only * recomputes when the seed changes. In the fragment, sample `computeOutputs[output]` with * `'nearestClamp'`: `.r` is the nearest shard's index, `.g` the second-nearest. * * @example * ```ts * compute: voronoiRegionField({count: 16, size: 1024, sites: shardSites, seedProp: 'seed', seedDefault: 2, output: 'voronoiField'}) * ``` * @tip Fill your shard data texture from the same `sites` function, or the cracks drift off their shards. * @see cellLaneUVFor, crackGeom */ export declare function voronoiRegionField(opts: { count: number; size: number; sites: (seed: number) => Float32Array; seedProp: string; seedDefault: number; output: string; }): GpuComputeNode; export {}; //# sourceMappingURL=fracture.d.ts.map