# What's the difference between length function and distance function in Unity Shader?

I'm confused about the two functions, do they return the same thing?

## 2 Answers

length() takes in one vector and returns the magnitude of that.

distance() takes in two and returns the distance between those. Basically, distance(a, b) is the same as length(a - b)

• Will it be different in some cases? Aug 20, 2018 at 9:48
• @OtakuFitness No, both are mathematically equivalent. The former is probably implemented as the latter. Aug 20, 2018 at 10:25

Distance is the length between two vectors. Length is the magnitude of one vector.