   Generating tangents
  I was wondering if anyone knew of a good algorithm for taking a DirectX vertex buffer filled with data, and a DirectX index buffer filled with data, to calculate the tangent of each vert.  I am not using DirectX format meshes.  The triangles are triangle strips.Basically I want to use this to do normal mapping.ThanksAdam   
  Not sure if there exists any specific algorithms.First thing you have to do naturally is to compute vertex normals if you haven't all ready.And that is basically the normalized sum of all the triangles where it is used.So you need to do some iteration and making triangles from your strip and compute.When you have your normals you can find tangents and binornals by dotting your normal with the appropriate axis. This is the fast and easy way to do that.I found this:http://www.ozone3d.net/tutorials/mesh_deformer_p2.phpWhich holds a code snippet down the page how to compute tangent and binormal.Here is a general article on tangent space computation:http://www.terathon.com/code/tangent.htmlHere is a article on vertex normal computation:http://www.codeguru.com/cpp/g-m/opengl/article.php/c2681[Edited by - Annoyed on June 14, 2009 4:00:30 AM];Quote:When you have your normals you can find tangents and binornals by dotting your normal with the appropriate axis. This is the fast and easy way to do that.No, that is utterly wrong and will not generate anything even close to the correct tangents that you need for bump mapping. Please delete that tutorial on ozone3d.net from your mind.Quote:Here is a general article on tangent space computation:http://www.terathon.com/code/tangent.htmlThat is the right way to compute tangents.;  Do you need tangents?  Object space normal mapping doesnt require tangent space.But if you need tangents, compute the normals first.This method is if you dont understand the professional way to compute tangents, but it works just as well and I think its easier to understand.You need to find the direction in object space that points in the U direction of the texture, orientating the texture in 3d space.Once youve got that you just cross with the normal to get the V.Take the first leg of the triangle, it has a uv gradient.What you need is something like the direction of the first leg, but it actually points horizontally along the texture, instead of diagonally along the texture. (like the leg does.)So take the normal of the whole triangle (not the corner of the triangle) and use this as an axis for a general axis rotate.calculate the angle in 2d of the uv gradient the leg is making on the uv map, and use this as the angle for the general axis rotate, and the triangle leg should rotate to make the 3d coordinate for the u coordinate.Normalize this. And do this for every vert in the mesh, and you should have tangent space.   