由三角形条组成的四边形上的OpenGL ES 1.1中纹理变形的问题 [英] Problems with texture deformation in OpenGL ES 1.1 on quad made out of triangle strips
问题描述
我正在使用三角带创建一个四边形.问题是当我尝试使用要在形状上均匀插值的矩形纹理进行绘制时.
I'm using triangle strips to create a quad. The problem is when I try to paint it using a rectangular texture that I want to have evenly interpolated over the shape.
只要形状是矩形或矩形的仿射变换,我将拥有两个相同的三角形来构建形状,一切都会顺利进行.但是,对于任意形状,三角形具有不同的形状,并且沿三角形的公共边缘自然会发生变形.
As long as the shape is a rectangle or an affine transform of a rectangle, I'll have two identical triangles that build the shape and everything goes well. But with arbitrary shapes, the triangles have different shapes and a distortion naturally occurs along the common edge of the triangles.
_____ ______ _____
| | / / \ /
|_____| /_____/ \_/
Ok Ok Not Ok
我想在ES 2.0中使用自定义着色器解决此问题将非常简单,但是如何在ES 1.1中实现呢?
I imagine it would be fairly straightforward to work around this with custom shaders in ES 2.0, but how do I achieve it in ES 1.1?
推荐答案
直截了当,如果您不提供纹理坐标的深度/深度信息,则硬件只能对纹理坐标进行线性插值.
Put bluntly, the hardware can only do linear interpolation of texture coordinates if you don't provide it with perspective/depth information.
线性插值不能正确处理导致问题的情况.
Linear interpolation does not allow to properly handle the case that causes you problems.
要在边缘上进行适当的插值,必须在四边形中引入透视信息.
To have a proper interpolation on you edge, you have to introduce perspective information in your quad.
您应该在此NVidia白皮书中找到更多信息:投影纹理映射.
You should find more information in this NVidia whitepaper : Projective Texture Mapping.
这篇关于由三角形条组成的四边形上的OpenGL ES 1.1中纹理变形的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!