Quote:

Also, for calculating the sun. The code I'm basing mine on is matts light.
float3 Light1 = P - vecLightPos;
Out.Light1 = mul(worldToTangent, -Light1);

I replaced the light with sun, and instead of subtracting the two points, i simply input -vecSunDir (see above)...



Yes, P - vecLightPos will calculate a direction vector from the light to the vertex. Since with sunlight, the direction is always the same, you can just use the sun dir.

The tangent is a vector pointing in the u direction of the texture. The binormal is a vector perpendicular to the tangent and normal. Together, these form an axis system called tangent space or texture space. The normals in the normalmap are relative to the texture, so to have meaningfull comparisons we must transform the other vectors (light, view, etc) to tangent space aswell for normalmapping.

I found a good picture showing the tangent, binormal and normal here.