Exactly! from the same article
Code:
void ComputeTangentBasis(
const Vec3& P1, const Vec3& P2, const Vec3& P3,
const Vec2& UV1, const Vec2& UV2, const Vec2& UV3,
Vec3 &tangent, Vec3 &bitangent )
{
Vec3 Edge1 = P2 - P1;
Vec3 Edge2 = P3 - P1;
Vec2 Edge1uv = UV2 - UV1;
Vec2 Edge2uv = UV3 - UV1;
float cp = Edge1uv.y * Edge2uv.x - Edge1uv.x * Edge2uv.y;
if ( cp != 0.0f ) {
float mul = 1.0f / cp;
tangent = (Edge1 * -Edge2uv.y + Edge2 * Edge1uv.y) * mul;
bitangent = (Edge1 * -Edge2uv.x + Edge2 * Edge1uv.x) * mul;
tangent.Normalize();
bitangent.Normalize();
}
}
This is exactly the education I was looking for. Thank you very much
Re Berengario I. I'm am deeply in your debt.
Bookmarks