Dot Product Question

I am trying to understand Dot Product and how to use it.
I am trying to follow/re engineer a shader that I have found.
(Acid Jelly from either Shadertoy or Shaderific, I think).
The line of shader code is ‘uv /= dot(uv, uv);’.
So I comment that line out and I can see that line of code is really making this shader do what it does.

I did a little grey/ one color study sketch in 2D and I see we get black at 0, 0 and it gradients to white as we right and/or down. So you pass a vector as parameter1 and the same vector as parameter2 and you get a changing result. I have not done heavy math in decades and this changing result has me struggling to understand. I have researched Dot Product in Wikipedia and other sites but still not clear at all.

If anyone has some enlightenment then I would appreciate it.

Say you have two vectors a and b each with x and y values. Your dot product is a.x * b.x + a.y * b.y.. So a self dot product of vector uv is uv.x * uv.x + uv.y * uv.y. Assuming ordinary dot calculation (not dot product of vectors representing imaginary numbers, which you may also encounter in shadertoy). So basically you are expecting scalar result.

1 Like

Thanks for your insight