I just want to be sure that I understand the calculation of the TBN matrix correctly
In the vertex shader, we usually use:
vec3 n = normalize(gl_NormalMatrix * gl_Normal); vec3 t = normalize(gl_NormalMatrix * Tangent.xyz); vec3 b = normalize(gl_NormalMatrix * Bitangent.xyz); mat3 tbn = mat3(t, b, n);
As I understand it, this tbn matrix converts a vector space from Tangent space to Eye . In fact, we want the opposite - to transform the vector from the space of the eyes into the space of touch. Thus, we need to invert the tbn matrix:
tbn = transpose(tbn);
note: tbn - should contain only rotations, for this case we can use transpose to invert the matrix.
And we can transform our vectors:
vec3 lightT = tbn * light_vector; ... = tbn * ...
In several source code tutorials, I found that the authors used something like this:
light.x = dot(light, t); light.y = dot(light, b); light.z = dot(light, n);
The above code does the same thing as transposed(tbn) matrix multiplication.
Question:
Should I use the transposed tbn matrix in the same way as I explained above? Or maybe I'm missing something?
Note In this solution, we have vectors (light_vector) converted to TBN in the vertex shader, then in the fragment shader we should get a normal normal map. Another option is to create a TBN matrix, which is transformed from the TBN space to the eye space, and then to transform the fragment shader, each of which reads the normal from a normal map.