Calculating tangent coords for arbitrary poly meshes - Printable Version +- iDevGames Forums ( http://www.idevgames.com/forums)+-- Forum: Development Zone ( /forum-3.html)+--- Forum: Graphics & Audio Programming ( /forum-9.html)+--- Thread: Calculating tangent coords for arbitrary poly meshes ( /thread-3210.html) |

Calculating tangent coords for arbitrary poly meshes - TomorrowPlusX - Jun 25, 2007 01:59 PM
I imagine some of the better modeling tools will calculate tangent coords automatically, but as far as I can tell Wings3D does not, or the OBJ format doesn't support it so Wings doesn't write them out. So, I'm in a pickle. I'd like meaningful tangent coords for bumpmapping, but the attempts I've made to calculate them have produced really crappy output. Does anybody have any suggestions? Calculating tangent coords for arbitrary poly meshes - OneSadCookie - Jun 25, 2007 05:58 PM
NVidia has an open-source C++ library which'll do it for you. Calculating tangent coords for arbitrary poly meshes - Hog - Jun 26, 2007 07:27 AM
I've once tried to come up with methods myself. However I don't currently remember much of the last method i used. Some of my theory behind it if anyone is interested: I assume that for a triangle (which is easier to work with) you can get the general tangent space which is aligned to the face normal (as when it's flat) and to get per vertex space you just need to align it to the vertex normal (by rotating). To get the space of a flat triangle (A,B,C) I just solved linear equations for: (TBN * (TexCoordOffsetAC.h,TexCoordOffsetAC.v,0) = C - A) and (TBN * (TexCoordOffsetAB.h,TexCoordOffsetAB.v,0) = B - A) which is the same as (TB * TexCoordOffsetAC = C - A) and (TB * TexCoordOffsetAB = B - A) (or BT instead of TB depending on how you define it) (or i suppose you could include the per vertex normal in the equation, or maybe not (as B and T aren't orthogonal to N that way) ) This was quite some time ago when i didn't find much useful stuff, so i'd go with NVidias stuff. Calculating tangent coords for arbitrary poly meshes - TomorrowPlusX - Jun 26, 2007 01:12 PM
Where is this C++ lib from NVidia? I'm going to start searching, but their dev site is huge. AARG! Searching NVidia's site I see a tool called NVMeshMender, which seems to be exactly what I want. But the download link is dead. Calculating tangent coords for arbitrary poly meshes - Duane - Jul 1, 2007 12:49 PM
google "nvmeshmender download" then look for the 'koders' link; I haven't looked at them (because I don't know what to look for), but that looks promising. Calculating tangent coords for arbitrary poly meshes - reubert - Jul 1, 2007 03:30 PM
let us know when you figure it out, I spent hours trying to create valid tangents and gave up! Calculating tangent coords for arbitrary poly meshes - TomorrowPlusX - Jul 2, 2007 07:06 AM
Thanks Nayr, I got the source. It's going to take a little work to figure out how best to integrate it into my mesh code, but I'm confident I can! Calculating tangent coords for arbitrary poly meshes - TomorrowPlusX - Jul 9, 2007 12:11 PM
So, many days later. I did manage to integrate NVMeshMender, but really to no avail. The output wasn't any better than my own, since both my code and NVMM are doing the same thing ( generating "good enough" automatic texture coords if none already exist and then running established algorithms to create tangents from them ). So, that being said, I did fix a bug in my own implementation, and the normalmapped rendering is... presentable... now. But I'm at the point now where I think my GLSL is at fault. It's hard to debug graphics code when you're not certain where the bug is. Are my tangents bad? Is my GLSL bad? Or are both bad? Who knows!? All I can say for certain is that my specular lighting looks pretty broken. That is to say, if you look closely, it's not really in the right place. With a non-critical eye, it looks fine. Calculating tangent coords for arbitrary poly meshes - Hog - Jul 9, 2007 03:10 PM
draw little lines along your tangents to see if they look correct. You may also just have some axes swapped. |