Jump to content


- - - - -

tangent space normal map generation


  • You cannot reply to this topic
3 replies to this topic

#1 Remdul

    New Member

  • Members
  • PipPip
  • 29 posts

Posted 28 April 2008 - 01:56 PM

I'm writing an program that converts world space normal maps to tangent space normal maps, given a model that has pre-computed normal/tangent/bi-tangent data.

I am able to construct a 3x3 matrix per vertex, then rasterize (interpolate+normalize) that for each triangle, but I get lost thereafter. I don't understand what I have to do to get the tangent space texel normal (which will be stored in the resulting normal map). Do I subtract the world space normal map rotation from the per-vertex tangent space rotation, or some sort of inverse?

Can someone give me a hint? :)

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4979 posts
  • LocationBellevue, WA

Posted 28 April 2008 - 06:13 PM

Well, what matrix are you constructing? If you construct the world-to-tangent rotation matrix for each triangle, just multiply it by the world-space normal at each texel and out pops the tangent-space normal.

You shouldn't need to subtract anything or invert anything.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2336 posts

Posted 29 April 2008 - 11:57 AM

Just calculate the tangent space. then just multiply through the world space normals through it interpolated, and thats all you have to do.

It helps if you are calculating the tangent space yourself, because then it means you know more than a guy using someone elses calculator.

#4 Remdul

    New Member

  • Members
  • PipPip
  • 29 posts

Posted 29 April 2008 - 02:18 PM

Ok, I was thinking to complicated again. :)

Quote

It helps if you are calculating the tangent space yourself, because then it means you know more than a guy using someone elses calculator.
That's exactly the problem. I have some models exported with known tangent space basis, but the normal maps are rendered in 3dsmax, which uses a different tangent space basis calculation, so the maps don't work the exported models. I probably could have figured out how 3dsmax calculates the tangents, but there's a vast number of bugs in the 3dsmax tangent space normal baking tool anyway, so I deemed it better to render them in world space (which is less buggy in 3dsmax) and convert them to tangent space afterwards.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users