fract

The fractional part of a value, 0..1.

fract(x: Val): Expr

Import math from shaders/std and use math.fract.

Repeats a coordinate every whole unit, which is how a pattern tiles.

Parameters

NameTypeNotes
xVal

Example

const inCell = fract(mul(uv, params.uniforms.tiles)) // 0..1 inside each tile

See also

  • floor — The value rounded down to a whole number.

Used by

CarbonFiber, Crystal, Heatmap, Hologram, Waveform