Calculate the tangent space

Source: Internet
Author: User

Tangent space:

Because the video card is generally used as the smallest rendering unit, we assume that the three points of the triangle are P1, P2, and P3, and set the space corresponding to the triangle to (T, B, n ), where T and B constitute the plane where the triangle is located, and T and B correspond to the u and v directions respectively.
The function is to convert any vector from the tangent space to the world space (in fact, what we ultimately need is the reverse, so we can describe it first, and finally find the inverse)

Then the vector p of P2-P1 must be in the plane of T and B, which is introduced as follows:

P2-P1 = (U2-U1) * t + (V2-V1) * B
P3-P1 = (U3-U1) * t + (V3-V1) * B

V1 = P2-P1; v2 = P3-P1; S1 = U2-U1; S2 = U3-U1; T1 = V2-V1; t2 = V3-V1
The following matrix is obtained:

| V1 | S1 T1 | T |
| = | * |
| V2 | S2 T2 | B |

V1 V2 S1 S2 T1 T2 are known, so that T and B can be obtained, and N can be obtained using the cross multiplication of T and B.

Finally, we need T, B, and N to convert the vectors from World Space to tangent space. We only need to reverse the vectors.

Well, with this, we can change the light to the tangent space and then multiply the normal line in the noraml diagram when processing the normal map.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.