简体   繁体   English

在最近邻插值OpenGL像素中心的情况下会发生什么

[英]What happens in the case of nearest neighbour interpolation OpenGL centre of pixels

What happens when a nearest neighbour interpolation occurs where the pixel for which the nearest neighbour interpolation is being calculated in texture is at the same distance from two neighbouring pixels, and the pixel falls equal distance in length from the two pixels that it is trying to correctly interpolate for a new pixel in the case of magnification. 当最近邻插值发生时,在纹理中计算最近邻插值的像素距离两个相邻像素的距离相同,并且像素距其正在尝试正确的两个像素的距离相等在放大的情况下插入新像素。

Does OpenGL take the two pixels and interpolate a colour from the texture by taking an average value from the two at same length distance or something else happens? OpenGL是否采用两个像素并从纹理中插入一种颜色,方法是从相同长度的两个平均值中取出一个平均值或其他什么?

The spec is very clear about how texels are selected from a texture coordinate: 规范非常清楚如何从纹理坐标中选择纹素:

Minification 缩小

Section 8.14 specifies the minification behaviour (I skip here a lot of things regarding wrap modes etc. and explain the 2D case): 第8.14节规定了缩小行为(我在这里跳过很多关于包裹模式等的事情并解释2D情况):

Let [s(x,y), t(x,y)] be the texture coordinates at screen position (x,y). 令[s(x,y),t(x,y)]为屏幕位置(x,y)处的纹理坐标。 Now we define u(x,y) = s(x,y) * texture_width and v(x,y) = t(x,y) * texture_height. 现在我们定义u(x,y)= s(x,y)* texture_width和v(x,y)= t(x,y)* texture_height。 In case of nearest neighbor interpolation, the texel is given by the integer coordinates (i,j), where i = floor(u(x,y)) and j = floor(v(x,y)). 在最近邻插值的情况下,纹素由整数坐标(i,j)给出,其中i = floor(u(x,y))并且j = floor(v(x,y))。

Lets do an example: Assuming we have a texture of size 2x1 and a lookup position of [0.5, 0.5]. 让我们举一个例子:假设我们的纹理大小为2x1,查找位置为[0.5,0.5]。 In this case u(x,y) = 0.5 * 2 = 1 and v(x,y) = 0.5 * 1 = 0.5. 在这种情况下,u(x,y)= 0.5 * 2 = 1并且v(x,y)= 0.5 * 1 = 0.5。 Now we get i = floor(1) = 1 and j = floor(0.5) = 0. So, the result will be the color of the right texel. 现在我们得到i = floor(1)= 1并且j = floor(0.5)= 0.因此,结果将是右纹理元素的颜色。

Magnification 放大

Section 8.15 states the the magnification behaves exactly as the minification. 第8.15节规定放大率的行为与缩小完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM