Need Help calcualting Tangent and Bi-normals using normals

I am having difficulties implementing bump maps on 3D objects.

I want to use the plane’s smoothed normals to calculate the tangent and then do a crossproduct to get the bi-normal.

I have been over the entire web (or it feels like it), looking for an equation that will do this, but have found nothing :frowning: All the tutorials and source everywhere that I have found use either the TBN loaded from the model (like POF models, which mine aren’t, nor do i have SMax), or calculate the TB.N while calculating the geometry.

If I take the standard approach of delta p1->p2 cross delta p1->p3, I loose the smoothed normal and end up with flat looking surfaces.

Cas, if your out there… you said this was easy (and I agreed)…I correct us (or at least me)…XY plane parallel bump mapping with generated quads or triangles is easy - complex surface bump mapping with accurate normals is not the same. :’(

Can anyone help?

The tangent is calculated per triangle (just like the normal). It depends on the vertex positions and their UVs. You’ve apparently found how to calculate this and it’s what gives the triangulated look of your objects. Then, just like normals, you have to calculate the average tangent for each vertex, by averaging the tangents of the surrounding triangles. Same for the binormal, unless you calculate it on the fly (using a cross in a vertex shader). The difficult part is to decide how to smooth your tangents (e.g. the problem with mirrored UVs).

Thanks for your reply Spasi, but I have figured out what’s gong on.

It was a 12-IFK (12 inches from the keyboard)… me.

I am embarrased to say that I having been using the WRONG crossproduct method for a WEEK! My vector class has several cross product versions, they all work correctly, but they each do different assignments to either the vector itself, or the vectors sent to the them as parameters. The one I was using stores the result back into the first parameter and I thought I was using the one that stores it back into the vector itself! DOH!!!

This exaplains why I was having so many unexplainable problems. I relearned an old lesson - don’t take anything for granted, especially when debugging.