How to calculate projection texture coordinates-Supplement

Source: Internet
Author: User

See: http://www.cnblogs.com/Pointer/archive/2004/12/20/79323.html

Recently, by studying the raster process of the Fixed rendering pipeline, I finally understood the cause of the distortion.

Let's first set V = the vertex before the projection transformation, V '= the Qi vertex after the projection transformation.

In the screen space, the properties of V are not linear, but 1/VZ is linear, other vertex attributes, such as VB and VZ, are linearly distributed. (Mathematics for 3D game programming & Computer Graphics provides detailed proof ), therefore, we should first perform linear interpolation on 1/VZ during interpolation, and then perform linear interpolation on VB/VZ, at last, multiply the interpolation result of VB/VZ by the reciprocal of the interpolation result of 1/VZ to obtain the interpolation result of VB.

Because v'w =-VZ (derivation of projection matrix), we generally use 1/V' W to replace 1/VZ.

During Texture projection, the homogeneous vertex coordinates after projection transformation are projected into three-dimensional space (that is, <v 'x/V' W, V 'y/V' W, V 'z/V' W>), and then use glvertex3f to pass the coordinates to the Fixed rendering pipeline, in this way, the interpolation of texture coordinates is changed from non-linear interpolation to linear interpolation, resulting in distortion of the final result.

In fact, if you directly use glvertex4f to pass V' into the Fixed rendering pipeline and use the Fixed rendering pipeline for perspective correction, this distortion can be eliminated.

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.