Jump to content
  • Advertisement
Sign in to follow this  

Question on normal mapping - averaging the TBN space

This topic is 3623 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

Hi At the moment I am studying on normal mapping. I have a large terrain structure on which I am going to apply a normal map. I have a question about TBN space calculations. In my current code, I traverse all the triangles of my terrain and calculate the T,B and N vectors for the three vertices of the related triangle. I store the calculated data per-triangle in a structure like this:
struct VertexNormal
	D3DXVECTOR3 Tangent;
	D3DXVECTOR3 Binormal;
	D3DXVECTOR3 Normal;
	int NumberOfContributingTriangles;
The general working of my code is like:
for(every triangle T of the Terrain)
   Find out the vertices v1,v2 and v3 of T;
   Calculate T,B and N vectors;

   for(i=0 to i=2)
      VertexNormal[vi].Tangent +=T;
      VertexNormal[vi].Normal  +=N;
After obtaining per-vertex TBN data a code similar to the following runs:
for(every vertex v of the Terrain)
    int N=VertexNormal[v].NumberOfContributingTriangles;
    VertexNormal[v].Tangent /=N;
    VertexNormal[v].Normal  /=N; 

My problem lies at this point.At this stage, by a very high possibility, Tangent,Binormal and Normal vectors of a vertex is no more orthogonal to eachother. (Not orthonormal.) But as the T,B and N vectors suppose to represent a seperate coordinate frame and will be used for transforming light vectors to the texture space, they obviously should. Now my question is; how can I ensure that the TBN vectors will stay or become orthonormal after averaging them per vertex? Thanks in advance

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!