# Calculate bitangent in vertex vs pixel shader

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

## 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 on other sites

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 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).

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
A4L
13
5. 5

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633744
• Total Posts
3013658
×