Antorian

07-18-2003, 03:16 PM

I'm implementing a dot3 Bump mapping using 3 texture unit with Normal Cube Map.

So I've got a problem with Tangent & binormal Vectors Generation.

with Google I've found that:

Tangent_List = new CVector3D[Num_Vertices];

Binormal_List = new CVector3D[Num_Vertices];

for(unsigned int j=0; j<Num_Faces*3; j+=3)

{

CVector3D vec1, vec2;

int i = FaceIndex_List[j];

int i1 = FaceIndex_List[j+1];

int i2 = FaceIndex_List[j+2];

vec1 = Vertex_List[i2] - Vertex_List[i];

vec2 = Vertex_List[i1] - Vertex_List[i];

float d_u1 = Mapping_List[i2].x - Mapping_List[i].x;

float d_u2 = Mapping_List[i1].y - Mapping_List[i].y;

Tangent_List[i] = (vec1 * d_u1) - (vec2 * d_u2);

Tangent_List[i].Normalize();

Tangent_List[i1] = Tangent_List[i];

Tangent_List[i2] = Tangent_List[i];

Binormal_List[i] = Normal_List[i].CrossProduct(Tangent_List[i]);

Binormal_List[i1] = Normal_List[i1].CrossProduct(Tangent_List[i1]);

Binormal_List[i2] = Normal_List[i2].CrossProduct(Tangent_List[i2]);

}

But when Rendering, the bumped object (sphere cylinder torus etc..) doesn't look weel.

Someplaces bump is inverted....

How must it be done?

Suggestions Are welcome.

Thanks.

So I've got a problem with Tangent & binormal Vectors Generation.

with Google I've found that:

Tangent_List = new CVector3D[Num_Vertices];

Binormal_List = new CVector3D[Num_Vertices];

for(unsigned int j=0; j<Num_Faces*3; j+=3)

{

CVector3D vec1, vec2;

int i = FaceIndex_List[j];

int i1 = FaceIndex_List[j+1];

int i2 = FaceIndex_List[j+2];

vec1 = Vertex_List[i2] - Vertex_List[i];

vec2 = Vertex_List[i1] - Vertex_List[i];

float d_u1 = Mapping_List[i2].x - Mapping_List[i].x;

float d_u2 = Mapping_List[i1].y - Mapping_List[i].y;

Tangent_List[i] = (vec1 * d_u1) - (vec2 * d_u2);

Tangent_List[i].Normalize();

Tangent_List[i1] = Tangent_List[i];

Tangent_List[i2] = Tangent_List[i];

Binormal_List[i] = Normal_List[i].CrossProduct(Tangent_List[i]);

Binormal_List[i1] = Normal_List[i1].CrossProduct(Tangent_List[i1]);

Binormal_List[i2] = Normal_List[i2].CrossProduct(Tangent_List[i2]);

}

But when Rendering, the bumped object (sphere cylinder torus etc..) doesn't look weel.

Someplaces bump is inverted....

How must it be done?

Suggestions Are welcome.

Thanks.