When deriving tangent space vectors for bump mapping.

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

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 on other sites
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 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 ;)

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• Forum Statistics

• Total Topics
633767
• Total Posts
3013735
×