3
\$\begingroup\$

I am trying to understand the basics of normal mapping using this tutorial : http://ogldev.atspace.co.uk/www/tutorial26/tutorial26.html

What I don't get there is the following equation : E1 = ( U1 - U0 ) * T + ( V1 - V0 ) * B

How do they came to this equation? This it out of nowhere for me. What is E1? The tutorial say that E1 is one edge of the triangle. But I don't get it, in the equation E1 seems to be a real number, not a vector ( which an edge is supposed to be right? he have a x and y component ).

\$\endgroup\$
  • 2
    \$\begingroup\$ E1, T and B are vectors, U0, U1, V0, V1 are scalars. The equation represents a linear combination of T and B to get to E1. \$\endgroup\$ – Gigo Feb 18 '15 at 4:14
  • 2
    \$\begingroup\$ related gamedev.stackexchange.com/questions/63832/… \$\endgroup\$ – concept3d Feb 18 '15 at 7:28
  • \$\begingroup\$ But how do they come to this equation? What is a linear combination? ( I've read a bit about this but I don't get how it helps ). I've never heard about this before. The scary thing is since they dont say anything about this, it is considered easy math? \$\endgroup\$ – Aulaulz Feb 18 '15 at 16:33
1
\$\begingroup\$

You have 3 points, P01, P1 and P2. (Look at the figure right above the equation.) The points create a triangle. This triangle lies on a plane and on this plane are the two vectors T and B. (Tangent and Bitangent) These vectors are more or less random, optimally they are at a right angle, but this may not be the case, the only requirement is that they are not the same.

With all this you can define the edges (E1 and E2) in respect to T and B.

P0 = (U0, V0)
P1 = (U1, V1)
P3 = (U2, V2)

E1 = (U1 - U0) * T + (V1 - V0) * B
E2 = (U0 - U2) * T + (V0 - V2) * B

Going from there:

Now since you know T and B in world space (and the normal N), you can construct the matrix TBN that will convert the normal from tangent space (as in the normal map) into world space (as required from lighting). The following equations basically outline the mathematical principles based on TB matrix. (The normal N is added later to also account for Z value of the normal.)

For arbitrary meshes the tangent and bitangent are vectors along the surface of the mesh. These need to be computed during construction/loading of the mesh. (You can skip the bitangent if you allow to simply do B = T x N)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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