PDA

View Full Version : Tangent space: negative area polys?



Teofuzz
10-07-2002, 10:32 PM
This is not really really an ogl related question, but since I use it and I need your help, let's go!

I'm computing (for dot3 use) for every triangle the local tangent (or texture) space, then for every vertex averaging the triangle ones.
But before averaging them, I need to discover if a triangle in object space has opposite area than in texture space, so I can reverse the normal to ensure proper lighting.
How can I detect this?
I have, for every triangle:
Vert coord (x1y1z1 x2y2z2 x3y3z3)
Tex coord (u1v1 u2v1 u3v3)
Then using some algebra, I get tangent, normal and binormal.
I also have the normal for standard lighting per vertex...
How can I use this information to discover if I have to negate the normal?

Thx in advance!!
fz

SirKnight
10-08-2002, 05:35 AM
If the dot product of the face normal and the normal created from the tangent space calcs is < 0 (ie negative) then you need to negate the tangent space normal. You might wanna have a look at the function in nv_algebra.cpp called "tangent_basis."

-SirKnight