I'm getting a bit confused on how calculate the light vector in tangent space basis so that it can be dotted with normal read from a normal map to get perpixel diffue lighting. As far as I know these are the basic steps to be followed
1) Set World Light Position
2) Subtract the current vertex's postion from world Light position
3) Multiply the reultant with the TBN Matrix to get the light vector in tangent space basis
4) Dot that vector (or whatever get's interpolated across vertices) with the normal read from the normal map.
My problem lies with step 2). Suppose the surface I'm trying to light (in this case, a simple quad) has a series of transformations applied to it, do I need to multiply the vertices position with that transformation matrix before I subtract it from the world light position. In other words
objectLightPosition = WorldLightposition - mul(TransformationMatrix,Vertex).
Or should I multiply the world light position with the inverse of the transformation matrix and then subtract the vertex position i.e.
objectLightPosition = mul(TransformationMatrixInverse,WorldLightposition ) - Vertex
I've tried both and it looks ok, but I find it somewhat unnatural especially when I move the light around. I assume I'm correct in that I'm using the transformation matrix and not the modelview matrix (which would be affected by calls to functions like glFrustum )
As a parting question, I also needed to make sure of one thing. The diffuse lighting should not depend at all upon where and in what direction the camera is oriented right ?
Thanks for reading this post, I know it's a quite lame



