[3D Foundation] tangent space Derivation principle (3)

Source: Internet
Author: User

This is the 3rd part of the 3D Foundation, mainly about the vertex tangent vector calculation principle, I believe that many people are shader in the tangent components do not have in-depth understanding, I hope this article can help you understand the cutting space. We use the bump mapping as an example to explain today's principles.

In fact, the found perturbation value stored in the bump map is actually based on X y in the figure (for the bump mapping is not familiar, please refer to other relevant articles first). So a transformation is needed to transform the texture coordinate system into the world coordinate system, which is actually a base transformation process (see 3D base 2), which is to find out how the texture is placed in the world space, and how the texture changes in the direction. To get this, you need to compute the vectors of the U-v axis corresponding to the world coordinate system respectively. Tangent vectors and binormal vectors are certainly not orthogonal if the textures are mapped to a triangle that is uniformly constant. Known: The space triangle has 3 vertex coordinates (XA, Ya, Za) (Xb, Yb, Zb) (Xc, Yc, Zc), texture coordinates (SA, Ta) (Sb, Tb) (Sc, Tc) respectively, and therefore:

Conditions:

Texture vectors ((sb-sa), (Tb-ta)) => World vectors ((xb-xa), (Yb-ya), (Zb-za))

Texture vectors ((sc-sa), (Tc-ta)) => World vectors ((xc-xa), (Yc-ya), (Zc-za))

Need to request:

( 1, 0 ) => Tangent
( 0, 1 ) => Binormal

D means any point within the triangle: D-a = (S-SA) * T + (t-ta) * B, set

P = B - A
Q = C - A

( S1, T1 ) = ( (Sb - Sa), (Tb - Ta) )
( S2, T2 ) = ( (Sc - Sa), (Tc - Ta) )

| Px Py Pz |  | S1 T1 |  | Tx Ty Tz |
         =      *
| Qx Qy Qz |  | S2 T2 |  | Bx By Bz |

In the end, we can calculate that the T B N is probably not orthogonal, so that they are not directly used for base conversion, but as long as the angle between T B N is close to perpendicular, it will not have much effect on the final vision, especially when T B and n are perpendicular. After all, only the equivalent of the perturbation normal around n small turn angle, generally first use the GRAM-SCHMIDT algorithm to TBN orthogonal after processing:

T' = T - (N*T)N
B' = B - (N*B)N - (T'*B)T'
N' = N

Tip: When the base axis is not orthogonal to each other, vx*x + Vy*y + vz*z is not the correct tangent space to the world space, when the angle is sharp, the result model will be large, and the direction is wrong, the result of the obtuse-point model will be small, direction is not.

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.