Quad Strip Texturing Distortion

时光怂恿深爱的人放手 提交于 2019-12-01 09:11:00

This is a classical problem when texturing a simple quad. It is due to the fact (like you guessed correctly) that the quad is broken down into individual triangles. These triangles are in turn textured independently.

The problem is, that the texture coordinates inside the triangle are interpolated linearly from the vertices (though perspective correct, but this doesn't help here). You can image it as the rasterizer not knowing the fourth vertex of this trapezoid, it only sees the individual triangles. Thus it assumes the transformation of the triangles into texture space to be completely affine, and thus for the triangle to be part of a parallelogram.

What you have to do to tackle this is to move away from the simple 2D affine texture space into a projective texture space, by using complete 4-dimensional texture coordinates instead of the simple 2D texcoords, like explained here. You basically do what the GL already does with perspective correct interpolation, but using your own perspective projection for the texture coordinates (in addition to the perspective projection already done for the vertex positions).

Does each section render correctly when it is rendered head-on (so as to be completely square)?

You could potentially try the following command before rendering:

glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

GL_PERSPECTIVE_CORRECTION_HINT Indicates the quality of color, texture coordinate, and fog coordinate interpolation. If perspective-corrected parameter interpolation is not efficiently supported by the GL implementation, hinting GL_DONT_CARE or GL_FASTEST can result in simple linear interpolation of colors and/or texture coordinates.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!