crackGeom
How much crack there is at a pixel, and which way the shard under it has moved.
crackGeom(
uv: v2f,
nPosX: number,
nPosY: number,
sPosX: number,
sPosY: number,
dispX: number,
dispY: number,
crackWidth: number,
): { crackIntensity: number; edgeNormal: v2f; displacedUV: v2f; disp: v2f; }
Import effects from shaders/std and use effects.fracture.crackGeom.
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).
Parameters
| Name | Type | Notes |
|---|---|---|
args | [uv: v2f, nPosX: number, nPosY: number, sPosX: number, sPosY: number, dispX: number, dispY: number, crackWidth: number] |
Example
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 also
crackRefractUV— Where to sample one color channel so the crack bends the light and splits it like a prism.crackShardCompose— The finished glass: the three refracted channels blended into the crack, with a hint of light on tilted shards.cellLaneUVFor— Where one shard's value sits in a one-row data texture.