PDA

View Full Version : wrong texture matrix or bug in normal map plugin?



jozo
02-08-2003, 08:31 AM
Hello everybody!
I'm trying to bump map simple quad(draw it using tris_strip) using ARB_tex_env_dot3 and vertex program.
I calculate lights position in object space and then calculate light vector (lights position in object space vertex.position), normalize vector and transform it in tangent space. For my quad facing viewer texture matrix looks like this:
T 1,0,0
B 0,1,0
N 0,0,1
I store this vector in result.color and store vertex.texcoord[0] in result.texcoord[0].
Well, problem is that when I try to use normal map generated with Nvidias Photoshop plugin I get incorect results when I try to rotate quad around x-axis. It seems that I get correct results when I invert green chanel in normal map or if I use (0, -1, 0) for binormal.
I think that texture matrix is correct, but in SimpleDot3 demo on ATIs website they use 0, -1, 0 for binormal and they use only one quad just like me. I even tried using NVMeshMender for generating tangent and binormal and I get 1,0,0 and 0,1,0.
So question is is this texture matrix correct for this quad:
//vertices
V0 0.5, -0.5, 0.0
V1 0.5, -0.5, 0.0
V2 0.5, 0.5, 0.0
V3 0.5, 0.5, 0.0
// texcoords
VT0 0.0, 0.0
VT1 1.0, 0.0
VT2 0.0, 1.0
VT3 1.0, 1.0
//normal
VN 0.0, 0.0, 1.0
or there is bug in normal map plugin, or something else?
Thanks!

ehart
02-08-2003, 08:55 AM
The choice of a basis for tangent space is somewhat arbitrary, so it is just a matter of keeping your code and art in synch.

It is reasonable to have the tangent vector point in the direction of s, -s, t, or -t. The only thing that is important is to stay self consistent.

-Evan

knackered
02-08-2003, 05:34 PM
...like always using blue for 'up'. http://www.opengl.org/discussion_boards/ubb/smile.gif