Any other transforms req'd for tangent space?

I’m investigating tangent space diffuse bump mapping.

I have my tangents, normals and binormals calculated per vertex.

I have a light position, in world space, that I convert to object space in a Vertex State program.

Now, in the vertex program I need to convert my light postion, which is now in Object Space, into tangent space. I initially thought that a simple matrix transform upon this XYZ object space position would result in the right values.

A few things that need ironing out if you please.

  1. I was looking at And their tangent space Vertex Shaders look f****d up to me! Do I need to transform my tangent/binormal/normal matrix by any other transforms before it is ready to transform the object space light into tangent space? If so, what?

For instance, does rotating the bump mapped object with the modelview matrix, require any transformations to be applied to the tengent space transformation matrix? (Where transformation matrix is the tangent, binormal, and normal vectors)

  1. I’m using a normal map generated by an Nvidia utility. (Takes bump maps, and creates normal maps) However, my current lighting seems to indicate that the Y component (green) is the wrong way round.

Let me explain this one. I have a facet, with a bump map applied to it. And a light source directly in front of it. Everything is nicely aligned. If I rotate the facet to the sides, then where you get a depression, faces the light source, and is highligted. However it seems to be inverted on tilting up and down. Manually reversing the Y component of the light vector in the vertex shader fixes this, but so would flipping the Green component of the normal map. Is this a bug in the Nvnormal map program, or am I doing some stupid?

I also noticed this when Delphi OpenGL website did a DOT3 bump mapping demo. The lighting was inverted in the Y on that also. That was ages ago tho.

  1. Any other titbits of info, or pitfalls to watch out for appreciated also.


You need to rotate your tangent space when your object rotate.

If your object rotates, the normal rotates. This means your tangent space also has rotated.

I don’t know about 2.

Your problem with item 2) would indicate that your binormal is pointing the wrong way. Try reversing the sign on it’s components.

You say I need to rotate them? What with? The DX website code seems to use the tanspose of the modelview matrix, but when doing standard vertex lighting in a VP, I always used inverse transpose modelview.

I’m sure I’ve tried both of these, and non seem to give correct results.

I’ll have another look.

Given a tangent of (1,0,0), and a normal of (0,0,1) (Pointing into positive Z) Then shouldn’t the binormal be (0,1,0)? I’m sure it should, and thats what I get.


The binormal should follow the texture derivative. Of corse with a color style bump map the direction of texture becomes important, perhaps the mapping of the t coordinate is reversed on the surface.

This is a good example of why T and B follow texture derivatives.