Jump to content
  • Advertisement
Sign in to follow this  
namwkim

When deriving tangent space vectors for bump mapping.

This topic is 3614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I calculated the tangent vector for each face (*tangent) = (texU[1]-texU[0])*(pos[1]-pos[0]) + (texU[2]-texU[0])*(pos[2]-pos[0]); and, like calculating normals, make sum and normalize(average) for each vertex. then, in shader, binormal = cross(normal, tangent) rotmat = float3x3(tangent, binormal, normal) Now, I have a question. When I render bumpmapped terrain, I saw some white wholes. I suspect that it happens when averaged tangent becomes zero. is there any way to handle this problem?

Share this post


Link to post
Share on other sites
Advertisement
Hi!

I think the main problem is that you don't calculate the tangent vector at all, but something else.

I really like the derivation of how to calculate tangent/bitangent-vectors found at http://www.terathon.com/code/tangent.html . There is also source code for how to do it!

Hope this helps!

Share this post


Link to post
Share on other sites
Hm one more point though. It is often true that

TxB=N

but in case the winding of the triangle in UV-space is different form the winding in worldspace, it should be

TxB=-N

You must calculate both tangent and bitangent. You could do

calculate T,B
calculate N
calculate TxB
calculate f=(TxB) dot N
sign = f>0

and store N,T,f (just one bit!). Then you can flip the sign of B based on f. Where t store that one bit is another matter, not sure what is best ;)


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!