Skip to main content
Version: 5.x

Nodes > Math > Geometric > Normalize

Normalize

Returns the input vector normalized so that its length equals 1.

To guard against NaNs, which behave differently across devices, we implement Normalize as:

vec3 Normalize(vec3 v) {
float lengthSquared = dot(v, v);
float l = (lengthSquared > 0.0) ? 1.0 / sqrt(lengthSquared ) : 0.0;
return v * l;
}

Inputs

NameTypeDescription
AfloatInput vector

Outputs

NameTypeDescription
normalize( A )floatA normalized with a length of 1
Was this page helpful?
Yes
No