As you can see there are 3 types of light defined above.But to create the spotlight,it creates a pointlight and then it needs to actually make that pointlight a spotlight,the thing is,I don't understand why on this line:

float3 lightVec = normalize(L.pos - v.pos)

it uses normalize?Why use normalize? Wouldn't it be the same thing without normalize?!

From the mathematical point of view it is not the same. L.pos - v.pos is calculating the vector from v.pos to L.pos so you end up with a vector which has a length that is the distance between those two points. Normalizing it brings it to the length of one. So as jeffery said the dotproduct in the spotlight factor will be scaled and will have a different value.

When you normalize the light vector and dot it with the surface normal of a poly, you get the angle of between the light and surface which determines the intensity of the light. If the light vector wasn't unit length, you'd the the light vector projected along the surface normal, which isn't the same.

The light vector is a direction, it just points in a certain direction, hence it should have no length, so you normalize it... and it becomes a unit directional vector {1, 1, 1}. Now you can do the dot product for your lighting without it being over scaled.
Further more, the dot product requires both vectors to be unit vectors to acquire the cosine angle between them.

Remember that when you calculate a "directional vector", you will most of the time want it normalized.

For the point light, you can see that it isn't normalized right away since the equation needs the length from the light position to the vector position to validate its range first. If it does pass, it just divides by the distance to normalize. This is done for efficiency reasons since the normalize function would need to recalculate the length of the vector anyways.

Just to be clear: normalized V = V / length(V).

Also, due to interpolation done by the GPU from the vertex shader to pixel shader, you will need to re-normalize your vectors in the pixel shader.

It is rough to get used to the linear algebra required for 3d graphics. But once you understand the general idea of what each function does visually, you won't really need to remember the exact formulas to do what you envision.

One last question,is it needed that at least 1 vectorin the dot product is normalized? If you look above in the sourcecode you will see that in every dot product there is one simple vector and a normalized one.

But at spotlight at the dot product L.dir is not normalized...?! float s = pow(max(dot(-lightVec, L.dir), 0.0f), L.spotPower);Also on ParallelLight too: float diffuseFactor = dot(lightVec, v.normal); as you can see there lightVec is not normalized.I don't understand....

L.dir is a member of the light. It is set in the C++ side, and it must be normalized there. So the shader assumes it already is normalized (which it should be anyways).

Again, if you want proper cos angle out the dot product, both vectors must be normalized. In your shader, it is assumed that the light direction is already normalized.

I'm sorry to say, but you will need to learn at least the basics of linear algebra to understand what's going on there in the pixel shader. On the other hand it's not that complicated.
I'd say if you're confident in programming you will grasp the math pretty easily.

So the final advice is to normalize every vector that I use in dot product no matter what?

No, there are plenty of cases where you don't want to normalize a vector used in a dot product. It depends on what you're trying to do. In this case you're interested in the angle between the vectors, the dot product of two normalized vectors gives you the cosine of that angle. So in this case, you want both vectors to be normalized.