cellLaneUVFor

Where one shard's value sits in a one-row data texture.

cellLaneUVFor(laneWidth: number): TgpuFn<(idx: F32, field: F32) => Vec2f>

Import effects from shaders/std and use effects.fracture.cellLaneUVFor.

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.

Parameters

NameTypeNotes
laneWidthnumber

Example

const cellLaneUV = cellLaneUVFor(16 * 4)
const dataAt = (idx: Expr, field: number) => dataKit.sample(call(cellLaneUV, 'cellLaneUV', [idx, floatE(field)]), 'nearestClamp').member('r')

See also

  • voronoiRegionField — Splits the canvas into shards around random sites and records, per pixel, its shard and the next-nearest one.
  • crackGeom — How much crack there is at a pixel, and which way the shard under it has moved.

Used by

Shatter