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
| Name | Type | Notes |
|---|---|---|
v | Val |
Example
const dir = normalize(sub(params.uniforms.target, params.uniforms.origin))
See also
Used by
Crystal, Frost, Goo, Hologram, Holographic, Irradiance, Plastic, ReactionDiffusion, Voxels, Water