纹理映射和坐标

Filtering

Texture maps are square or rectangular, but after mapped to a polygon or surface and transformed into screen coordinates, the individual texels of a texture rarely correspond to individual pixels of the final screen image. Depending on the transformations used and the texture mapping applied, a single pixel on the screen can correspond to anything from a tiny portion of a texel (magnification) to a large collection of texels (minification), as shown in Figure 9-8. In either case, it’s unclear exactly which texel values should be used and how they should be averaged or interpolated. Consequently, OpenGL allows you to specify any several filtering options to determine these calculations. The options provide different trade-offs between speed and image quality. Also, you can specify independently the filtering methods for magnification and minification.

过滤

纹理映射是矩形或者正方形,但是当映射到一个多边形或者表面上并转换成平面坐标之后,纹理的单独纹理元素与最后的屏幕图片的像素是没有什么联系的。随着应用到纹理映射上的转换,屏幕上的单一像素可以与很小部分的纹理元素相关联(放大),或者与一个很大结合的纹理元素相关联(缩小)。无论是哪一种情况,我们都不能确定使用哪一个具体的纹理元素值,是应该要取平均数呢,还是做插值。因此,在OpenGL中,你可以定义好几个过滤选项来决定这些计算。但是速度和图像质量是成反比滴。同理,你也可以为放大和缩小定义独立的过滤方法。

In some cases, it isn’t obvious whether magnification or minification is called for. If the texture map needs to be stretched (of shrunk) in both the x- and y- directions, then magnification (or minification) is needed. If the texture map needs to be stretched in one direction and shrunk in the other, OpenGL makes a choice between magnification and minification that in most cases gives the best result possible. It’s best to try to avoid these situations by using texture coordinates that map without such distortion.

在一些情况下,是放大或者缩小被调用是不明显的。如果纹理映射需要在xy的方向上延展或者缩小,此时就需要放大或缩小。如果纹理映射需要在一个方向上延展而另一个方向上进行收缩,OpenGL会在放大和缩小中做出一个最优结果的选择。所以尽量避免这些情况。

插入一段:

Computing Appropriate Texture Coordinates

Two-dimensional textures are square or rectangular images that are typically mapped to the polygons that make up a polygonal model. In the simplest case, you’re mapping a rectangular texture onto a model that’s also rectangular – for example, your texture is a scanned image of a brick wall, and your rectangle represents a brick wall of a building. Suppose the brick wall is square and the texture is square, and you want to map the whole texture to the whole wall. The texture coordinates of the texture square are (0, 0), (1, 0), (1, 1), and (0, 1) in counter clockwise order. When you’re drawing the wall, just give those four coordinate sets as the texture coordinates as you specify the wall’s vertices in counter clockwise order.

计算合适的纹理坐标

二维的纹理一般都是正方形或矩形图像,一般都是把这些图像映射到多边形上构成一个多边形模型。最简单的例子,把一个矩形的纹理映射到一个同样是矩形的模型上——例如,纹理是一个砖墙的扫描图像,而矩形就代表了建筑的砖墙。假设砖墙和纹理都是正方形的,并且是把整个纹理都映射到砖墙上。纹理坐标应该是(0, 0), (1, 0), (1, 1), (0, 1)这样的反时钟顺序。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值