Problem with TangentSpace (Tangent & Binormal calculatio

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
chromdragon
Posts: 101
Joined: Wed Feb 15, 2006 4:22 pm
Location: RO

Problem with TangentSpace (Tangent & Binormal calculatio

Post by chromdragon »

I have problems with calculating the tangent and binormal (bitangent) vector!

Can any body help me pls!

:: IMG WITH MY PROBLEM ::
Image

:: REFERENCES ::
Engine: Irrlicht
http://irrlicht.sourceforge.net/

Bump Mapping Using CG (3rd Edition)
http://www.blacksmith-studios.dk/projec ... ing_cg.php

Derivation of the Tangent Space Matrix
http://www.blacksmith-studios.dk/projec ... vation.php

:: CODE ::

Code: Select all

core::vector3df& normal,
core::vector3df& tangent,
core::vector3df& binormal,
core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3 // vertices
core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3 // texture coords

#ifdef USE_BOGDAN_VERSION

normal.set(0,0,0);
tangent.set(0,0,0);
binormal.set(0,0,0);

// normal
core::vector3df v1 = vt1 - vt2;
core::vector3df v2 = vt3 - vt1;
normal = v2.crossProduct(v1);
normal.normalize();

// tangent & binormal
core::vector3df deltaV2V1 = vt2 - vt1;
core::vector3df deltaV3V1 = vt3 - vt1;
f32 deltaC2C1T = tc2.X - tc1.X;
f32 deltaC2C1B = tc2.Y - tc1.Y;
f32 deltaC3C1T = tc3.X - tc1.X;
f32 deltaC3C1B = tc3.Y - tc1.Y;
f32 mTex = 1.0f / (deltaC2C1T*deltaC3C1B - deltaC3C1T*deltaC2C1B);

tangent = (deltaV2V1 * deltaC3C1B - deltaV3V1 * deltaC2C1B) * mTex;
tangent.normalize();

binormal = (deltaV2V1 * deltaC3C1T * -1.0f + deltaV3V1 * deltaC2C1T) * mTex;
binormal.normalize();

#endif // USE_BOGDAN_VERSION
WhiteNoise
Posts: 27
Joined: Wed Apr 19, 2006 5:10 pm
Contact:

Post by WhiteNoise »

I can't see what the problem is from that picture. Also, what's wrong with Irrlicht's binormal computation?
chromdragon
Posts: 101
Joined: Wed Feb 15, 2006 4:22 pm
Location: RO

Post by chromdragon »

Is anyone who had correct calculated the normal/tangent/bitagent for TangetSpace? (normal-maps generated but ATI NormalMapper or NVIDIA Melody)

Computing tangents on GameDev
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

cool link , thanks....
what is this thing...
Post Reply