0

I'm recently learning the stuffs related to TBN Matrix. I already got that how this TBN Matrix is calculated and in which way we're going to use it to convert normals from tangent space into object/world space(depends on the basis vector of TBN) so that they're able to be computed by lights in the same space.

But I also noticed that almost in every tutorial teaching this subject, there is always a section telling how to calculate the inverse of TBN so that you can convert lights into tangent space as an option.

Well really, this is just an option, but is there any reason we do as such? Is there any difference between converting normals from tangent space to object/world space AND converting lights from object/world space to tangent space? Can we gain some performance or can we save a lot of memory or calculation cost? I just can't figure it out, since I think they have the same quantity of calculations, due to each vertex having a unique TBN Matrix on its own.

Thanks for your help~

1
  • Check out the normal mapping tutorial in learnopengl.com. answered all my questions.
    – vexe
    Nov 3, 2015 at 19:59

1 Answer 1

2

Normal maps are usually stored in tangent space for various reasons (better precision, maps can be shared between multiple objects, objects can be animated, etc.). If you want to light in world space you have to transform your normal per-pixel into world space using the TBN matrix. A common optimization is to instead transform your light into tangent space per vertex and interpolate it across the triangle. This saves a relatively expensive matrix transform per-pixel and instead only does the transform per vertex.

This optimization was more popular on older hardware where pixel shader performance and complexity had to be very strictly managed. It also makes most sense when you only have one light in your rendering pass as with multiple lights you have to transform each light into world space and you quickly eat into any savings and burn up interpolators. Nowadays you're more likely to see deferred renderers which transform all normals into world space and write them out to a G-Buffer, or forward / forward-plus renderers which apply multiple lights in a single pass and so are generally going to be more efficient doing lighting calculations in world space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.