PDA

View Full Version : Any other transforms req'd for tangent space?



Nutty
01-15-2002, 01:47 PM
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndrive/html/directx11192001.asp 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)

2) 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.

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

cheers!
Nutty

Gorg
01-15-2002, 04:15 PM
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.

dorbie
01-15-2002, 04:45 PM
Your problem with item 2) would indicate that your binormal is pointing the wrong way. Try reversing the sign on it's components.

Nutty
01-16-2002, 12:28 AM
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.

Nutty

dorbie
01-16-2002, 02:05 AM
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.