I’ve been investigating tangent space bump mapping lately and I have put together a demo showing how it’s done. I have included shaders for all 3 light types: directional, point, and spot lights. I have also included code to calculate the tangent, bitangent, and normal vectors.
For further details and download links please visit www.dhpoware.com
It is error to normalize the lightDir and viewDir vectors within the vertex shader. If you do that, the interpolated direction will be incorrect. Additionally you are calculating attenuation from the normalized lightDir which is not correct.