四边形纹理变形 [英] Quad Strip Texturing Distortion

查看:100
本文介绍了四边形纹理变形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GL_QUAD_STRIP,它是纹理贴图.四边形条会自身折回以形成UV球.本质上,四边形通常不是由矩形组成,而是由梯形组成.

I have a GL_QUAD_STRIP that I am texture mapping. The quad strip folds back on itself to form a UV sphere. Essentially, the quad strip is not generally made of rectangles--instead, trapezoids.

我遇到纹理变形问题.纹理坐标是正确的(例如,它们在应该放置的位置很好地对齐).问题在于梯形的面孔本身.

I am getting texture distortion issues. The texture coordinates are correct (for example, they line up nicely where they should). The issue is on the trapezoidal faces themselves.

我希望朝向梯形面较大端的texel会占据较大的面积,但该面似乎分成两个三角形.它看起来类似于仿射纹理贴图(但我不认为这是正确的;它似乎仍然是正确的透视图,而且我也不希望被使用).

I would expect texels towards the larger end of a trapezoidal face to subtend larger area, yet the face seems broken into two triangles. It looks similar to affine texture mapping (but I don't think it is; it still seems perspective correct, and I wouldn't expect that to be used anyway).

我知道图形卡通常在内部将四边形缩小为三角形,但是我不希望这会影响纹理. .

I am aware that graphics cards usually reduce quads down into triangles internally, but I wouldn't expect that to affect texturing . . .

所以,我不知道这是怎么回事.有什么想法吗?

So, I don't know what's going on here. Any thoughts?

这是不良行为的一个示例.低分辨率球体纹理,最近的滤波,无mipmap或各向异性:

Here is an example of the undesired behavior. Low resolution globe texture, nearest filtering, no mipmaps or anisotropy:

推荐答案

对简单的四边形进行纹理处理时,这是一个经典问题.正是由于这样的事实(就像您猜对了一样),四边形才分解成各个三角形.这些三角形又是独立纹理的.

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.

要解决此问题,您需要使用完整的4维纹理坐标而不是简单的2D texcoords,从简单的2D仿射纹理空间移至投影纹理空间,如所解释的

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).

这篇关于四边形纹理变形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆