Home Game Development opengl – TBN matrix for normal and parallax mapping

opengl – TBN matrix for normal and parallax mapping

0
opengl – TBN matrix for normal and parallax mapping

[ad_1]

I’d like to refer to this question because I didn’t completely answer to my problem.

I’ve implemented normal and parallax mapping but because of some assumptions I have to use two different TBN matrices for each effect.

One of the most important assumptions is that I have deferred renderer with normals encoding and light calculations in view space.

This implies that I have to convert data from normal maps (which are in tangent space) to view space using below TBN matrix:

mat3 NormalMatrix = transpose(inverse(mat3(ModelViewMatrix)));
vec3 T = normalize(NormalMatrix * Tangent);
vec3 N = normalize(NormalMatrix * Normal);
vec3 B = normalize(NormalMatrix * Bitangent);

mat3 TBN = mat3(T, B, N);

On the other hand parallax mapping required view direction vector in tangent space. To compute that I use camera position and fragment position (in world space) multiplied by following TBN matrix to move this vectors from world space to tangent space:

T = normalize(mat3(ModelMatrix) * Tangent);
N = normalize(mat3(ModelMatrix) * Normal);
B = normalize(mat3(ModelMatrix) * Bitangent);

mat3 TBN = transpose(mat3(T, B, N));

I’m looking for a way to optimize that. Is it possible to make it better?

[ad_2]

Previous article Where to watch How the Grinch Stole Christmas
Next article GTA 6 Trailer Proves 2023’s Best Gaming Trend Is Here To Stay
Hello there! My name is YoleeTeam, and I am thrilled to welcome you to AmazonianGames.com. As the premier destination for all things related to Amazon Games' universe, we are dedicated to providing you with the most exciting and immersive gaming experiences out there. From captivating visuals to exhilarating gameplay, our website is packed with comprehensive insights, updates, and reviews to keep you ahead of the game. Whether you're a seasoned gamer or new to the scene, I am here to guide you through this virtual frontier. If you have any questions or suggestions, feel free to reach out to me at john@yoleesolutions.com. Embark on your Amazon gaming journey today with AmazonianGames.com and let the adventure begin!