Nodes > Math > Geometric > 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
Name | Type | Description |
---|---|---|
A | float | Input vector |
Outputs
Name | Type | Description |
---|---|---|
normalize( A ) | float | A normalized with a length of 1 |
Was this page helpful?