normalize

The vector scaled to length 1.

normalize(v: Val): Expr

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

A zero vector gives NaN, so keep the input non-zero.

Parameters

NameTypeNotes
vVal

Example

const dir = normalize(sub(params.uniforms.target, params.uniforms.origin))

See also

  • length — The length of a vector.
  • dot — The dot product of two vectors.

Used by

Crystal, Frost, Goo, Hologram, Holographic, Irradiance, Plastic, ReactionDiffusion, Voxels, Water