Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

NormalMap Theory

Started by Eitsch 2 replies 700+ views
Original Post
Eitsch
Eitsch
i need a dynamic solution for bumpmapping and i dont want to recalculate the tbn matrix...my theory - calculate TBN once - transform normal of the normalmap with this TBN into object space - transform light into object space by the inverse modelview matrix -> so every data is static... is there a mistake in my theory? why do most peopple transform the light into tangent space (this would mean after an object rotation i have to recalculate the TBNmatrix)? is my approach correct?
Demus79
Demus79
I think that your theory is a bit flawed, normally you don't need to recalculate the TBN matrix, unless your geometry changes somehow (but this doesn't mean rotation / translation)

- It is a more expensive to transform every normal to object space by TBN matrix since the operation will be done for every fragment. You can transform the light to the tangent space.

The theory:

- TBN matrix usually transforms vectors from tangent space to object space so actually you'll need the inverse of the TBN matrix. The inverse TBN matrix will transform vectors from object space to tangent space.

Per-vertex:

- Transform light from world space to object space by inverse world matrix
- Transform object space light to tangent space by the inverse TBN matrix

Per-pixel

- Light and normal are now in the same space (tangent space) - do what ever kind of lighting you wish.

As you can see, the rotation of the object has been taken in account by the inverse world matrix.

[edit]

The normal must be in tangent space of course. So the same map can be used on some other objects too.

[Edited by - Demus79 on June 2, 2006 7:39:19 AM]
arbuckle911
arbuckle911
if youre going to do that you may as well use a tool like melody (somewhere on nVidia) to calculate the objectspace normal map for you.

The reason most people don
t use this technique, even if it saves ALOT of space and calculation time is that when useing the actual texture you can only use it on one object, without reuseing texture space, because the object space normal depends on the objects shape.

Nothing wrong with either way, I`m giving you the facts.
Eitsch
Eitsch
perfect...clearer now

i hope this is no doublepost because the server is bugging around....

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.