[3D Basics] theory of space-cutting (3)

Source: Internet
Author: User

This article is part 1 of 3D basics. It mainly describes the calculation principle of vertex tangent vectors. I believe many people do not have a deep understanding of the tangent component in the shader.ArticleIt is helpful for everyone. We use the concave-convex ing as an example to explain the principle of today.

In fact, the disturbance values stored in the concave and convex textures are actually based on x y in the figure (for details about the concave and convex Mappings, see other related articles ). Therefore, a transformation is required to convert the texture coordinate system to the world coordinate system. This conversion is actually a base transformation process (see 3d basics 2 ), to put it bluntly, we need to find out how textures are placed in the world space and how the texture changes in the direction. To obtain this point, we need to calculate the vectors corresponding to the u v axis in the world coordinate system. If the texture is mapped evenly to the triangle from time to time, the tangent vector and the binormal vector are certainly not orthogonal. Known: the coordinates of three spatial triangles are (XA, ya, za) (XB, Yb, ZB) (XC, YC, ZC), and the texture coordinates are (SA, ta) (SB, Tb) (SC, TC), therefore:

Condition:
Texture vector (Sb-SA), (Tb-Ta) => world vector (XB-XA), (Yb-Ya), (zb-za ))
Texture vectors (SC-SA), (TC-Ta) => world vectors (XC-XA), (YC-Ya), (ZC-za ))

Requirements:
(1, 0) => tangent
(0, 1) => binormal

D indicates any point in the triangle: D-A = (S-sa) * t + (t-Ta) * B, Set
P = B-
Q = C-

(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 |

Finally, the calculated t B n is likely not orthogonal, so strictly speaking, they cannot be directly used for base conversion, but as long as the angle between t B n is close to the vertical, OK, in the end, there will not be much visual impact, especially when t B and n are perpendicular. After all, it is equivalent to converting the disturbance normal around n to an angle. Generally, Gram-Schmidt is used first.AlgorithmLet TBN be orthogonal before processing:
T' = T-(N * t) N
B '= B-(N * B) N-(t' * B) t'
N' = N

Tip: when the basic axes are not orthogonal to each other, VX * x + Vy * Y + VZ * z is incorrectly expressed by splitting space into the world space, when the angle is acute, the result model is too large and the direction is incorrect. The result model of the acute angle is too small and the direction is incorrect.

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.