Tangents for indexed meshes?

Good morning everyone!

After hours of searching and researching I cannot dig up some valuable information on calculating correct tangent vectors for an indexed triangle mesh. I’ve had my experiences with non-indexed geometry so I’m familiar with the algorithm.

Obviously I’m already dealing with averaged vertex normals here, so is it the right strategy to take an arbitrary triangle sharing a vertex and calculating one tangent vector with respect to the smoothed vertex normal and the UVs of this triangle and then orthogonalize it?

Am I correct in thinking that by having the same base at this particular vertex for all connected triangles I will have correct lighting results? Apparently D3DX has a function which does just that so I assume it is quite possible.

Guess I need some math pro advice here. :slight_smile:

BTW, I tend to use the approach described in (Lengyel, 2005).

Thanks everyone!

Something like this http://www.terathon.com/code/tangent.html, this http://www.3dkingdoms.com/weekly/weekly.php?a=37 or this http://www.google.fr/url?sa=t&source…6EQ&cad=rja ?

The first link actually IS the text from (Lengyel, 2005). The second basically describes the same thing - if I didn’t miss anything, the author doesn’t take care of potentially different signs for the bitangent. So no gain here.

The GDC pres. by Mittring is more like it. Calculating the TS per Triangle is not a big deal. For step 2, correct vertex normals are already provided by Blender.

If I get step 3 correctly, this would still require knowledge about the neighbouring triangles, so I’m forced to build a corresponding data structure. Right?

Does someone have experience with this?

Again: Tangent per triangle isn’t a problem and my vertex normals are already smoothed.

Thanks again.

Connectivity/neighbouring between triangles/faces aren’t generally directly provided by the model, so effectively a corresponding data structure have generally to be [re]computed :frowning:

(Note that the stripping format can already directly provide the neightbouring informations into each independants strips, so only neighbouring between strips have to be computed …)

I have discovered on internet the Moebius strips :slight_smile:
http://www.cut-the-knot.org/do_you_know/moebius.shtml http://en.wikipedia.org/wiki/M%C3%B6bius_strip
=> the idea can perhaps to be extented for to handle a closed model instead a single band ?

Note too that sharing/averaging normals for each vertex doesn’t handle the simple case of the cube where we have three faces that share the same vertex but with differents and perpendiculars normals …

Sorry for my delayed reply. I guess I’m gonna give Schüler’s method of calculating the tangent frame in the fragment shader a try. I can’t really deal with extending my geometry processing methods right now.

Thanks for the input!