When I saw an implementation of normal mapping that computed the TBN matrix in the vertex shader and converted everything (in particular the view vector and light vector) to tangent space at that stage, it seemed like the proper way to do. This way there is no matrix-vector multiplication left to do in the fragment shader.
Enters image based lighting: for each fragment we want to fetch from an image, typically one or more cube map textures, the light intensity coming from certain directions. I assume this data is in world space.
My question is: is it possible to use IBL while retaining the vertex shader transform optimization mentioned above?
- It seems to me we still need to transform our fetch direction from tangent space to world space (or whichever space the cube map is in).
- Conversely, if we want to work in world space, like with deferred shading, we need to transform the normal for each fragment.
Does IBL necessarily imply at least one matrix vector multiplication per fragment and the optimization I mentioned is an uncommon case, or am I missing something?