I have tried reading up on tangents, but the only resources I can find are either pages full of matrix formulas or long source codes for general purpose tangent calculations. What I need is to generate very simple tangents - preferably without out all the overhead a general purpose solutions brings.
What I need boils down to two different kinds of geometry:
a) Simple primitives with sharp edges (i.e. a cube, a plane, a tetrahedron etc.). I assume I’ll be splitting the vertices on the sharp edges.
b) Strips/Grids with smooth edges.
Some really simple cases:
a) Let’s go with something extremely simple: 2 triangles forming a quad. Let’s assume the texture u,v coordinates are (0,0) in the top left corner and (1,1) in the bottom right corner of the quad. What would the tangent be for each of the four corners?
b) Let’s go with a grid of quads (of 2 triangles) making up a simple terrain. I assume I need to average up the surrounding grid points to find the average tangent, but isn’t that already done with the normals from RecalculateNormals()?
Are the follow assumptions correct?
-
The tangent vector is usually orthogonal (90 degrees) to the normal vector?
-
The tanget vector is rotated so it lines up with the 2D coordinates of u and v?
-
The tangent needs to be specified in object space?
-
The tangent vector consists up 4 components, the last being either 1 or -1?
Also… Do I want to use the normals from RecalculateNormals() before I make the tangents? Or is it better to call Recalc afterwards? (or create the normals myself)