What is the difference between the Length node and Vector Length nodes in the material graphs?

I am making a material for a sky sphere and I am creating a mask of the stars in a particular part of the sky. To do this I am trying to make use of the length node, to do what it says it should, but it produces a very strange result. The VectorLength node on the other hand works as intended.

This is what the VectorLength node produces which is exactly what is desired:

And this is what the Length node produces which seems to somehow highlight my mask of the region in the sky that I am targeting:

This behavior is extremely bizarre and my attempts to get Length working through clamping and maxing have not had an effect. Anyone have an explanation of this?

I’m not actually sure what the ‘length’ node does, but the ‘vector length’ just uses ‘distance’

In any case, you have to feed it a vector 3. You can’t have the length of a float, which is what you currently have.

Or rather, you can, but then Y and Z are assumed to be 0 :slight_smile:

In any case, you have to feed it a vector 3. You can’t have the length of a float, which is what you currently have.

The graph off to the left is a vec3 so a vec3 goes into VectorLength. Unless the Max node somehow casts to a float and takes the max of each value of the vec3? That would be a strange implementation of Max and I assumed Max is the same as in glsl (as well as clamp). It would be nice to be able to see what exactly is going on under the hood of Length though.

1 Like

Yes, it’s a bit ‘vague’ :rofl:

Length is happy to work with a scalar, v2, v3 and v4. Vector Length only works with v2 & v3. You can debug both nodes but they should return identical values in OP’s example - a vector whose every component has the same scalar value (length).


So yeah, the result is unexpected (to me, at least).

1 Like