Jump to content
  • Advertisement
Sign in to follow this  
IrYoKu1

Calculate bitangent in vertex vs pixel shader

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

Hey guys,

 

I'm wondering what is the best approach to create the tangent frame:

 

- Pass normal, tangent and bitangent, and normalize all three in pixel shader [9 instructions]

 

- Pass normal, tangent and handedness, and do handedness * cross(normal, tangent) [9 instructions]

 

From the performance side you save two float slots in the interpolators if you use the second approach.

 

From the quality side, I wonder. I suppose there is no correct approach, and it all depends on how the normal map was baked: if using a orthogonalization before or after interpolation (per vertex or per pixel). If that is true, I wonder what approach popular tools like Maya, xNormal or Zbrush uses.

 

I'd love to have some input on the topic!

 

Thanks

Jorge

Share this post


Link to post
Share on other sites
Advertisement

On the particular platform that I work with it's generally a win to minimize interpolants, so I've been going with the latter approach. I'm honestly not sure what Maya or the other DCC packages do, I've never taken a close look.

Share this post


Link to post
Share on other sites

Thanks for the reply!

 

My question was motivated by this document:

http://page.mi.fu-berlin.de/block/htw-lehre/wise2012_2013/bel_und_rend/skripte/mikkelsen2008.pdf

 

There is a lot of useful information in there regarding normal mapping, it's amazing how it can break in some many ways I could not even imagine.

 

I discovered that xnormal uses unnormalized normals for the tangent basis (normal, tangent and bitagent), and only uses the cross in the pixel shader when a certain option turned on. But I don't know how much of a difference doing the cross in one place or the other can be (regarding visuals).

 

MJP, you usually normalize normals of the tangent basis in the pixel shader (before transforming the normal from the normal map)? I used to, but now I'm wondering about it as well. It requires a some instructions to do so, and it seems it will only match normal maps generated by some software but not others (being xNormal an important example).

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!