1
votes

I'm implementing tangent space normal mapping in my OpenGL app, and I have a few questions.

1) I know that, naturally, the TBN matrix is not always orthogonal because the texture co-ordinates might have skewing. I know that you can re-orthogonalize it using the Gramm-Schmidt process. My question is this - Does the Gramm-Schmidt process introduce visible artifacts? Will I get the best visual quality by using pure unmodified normal/tangent/bitangent?

2) I notice that in a lot of tutorials, they do the lighting calculations in tangent space instead of view space. Why is this? I plan to use a deferred renderer, so my normals have to be saved into a buffer, am I correct in that they should be in view space when saved? What would I be missing out on by using view space instead of tangent space in the calculations? If I'm using view space, do I need the inverse of the TBN matrix?

3) In the fragment shader, do the tangent and bitangent have to be re-normalized? After multiplying the incoming (normalized) bump map normal, does that then have to be renormalized? Would the orthogonality (see question 1) affect this? What vectors do or do not need to be renormalized within the fragment shader?

1
For deferred shading, you generally perform tangent-space to world/view-space transformation when you write the normal G-Buffer. Some post-processing algorithms are more efficient in world-space, so some engines store it in world-space. View-space has some advantages too in terms of precision, so there is no mass consensus on what to do... but you definitely cannot store your G-Buffer in tangent-space, because there would be missing information necessary to transform the normals during lighting.Andon M. Coleman
Thank you, I'm storing them in view space for now, but might change to world space in the future.Haydn V. Harach

1 Answers

3
votes

Does the Gramm-Schmidt process introduce visible artifacts?

It depends on the desired outcome. But the usual answer would be yes, since normal map vectors are in tangent space. Orthogonalizing tangent space will skew normal mapping calculations if the texture coordinates define a nonorthogonal base.

I notice that in a lot of tutorials, they do the lighting calculations in tangent space instead of view space. Why is this?

Doing normal mapping in view space would require each normal map texel to be transformed into view space. This is more expensive, than transforming lighting vectors into tangent space in the vertex shader and let the barycentric interpolation stage (which is far more efficient) to its work.

In the fragment shader, do the tangent and bitangent have to be re-normalized?

No. You should normalize the individual vectors after transforming them (normal map, direction to light source and viewpoint) but before doing the illumination calculations.