length

The length of a vector.

length(v: Val): Expr

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

The distance from the origin, or from a center when you pass the offset from it.

Parameters

NameTypeNotes
vVal

Example

const dist = length(sub(uv, params.uniforms.center))

See also

  • distance — The distance between two points.
  • normalize — The vector scaled to length 1.

Used by

Chrome, LiquidMetal, MeshGradient, Water