문제

I have basic knowledge on interpolation: It is a method to estimate a value for a given position depending on its surrounding. So nearest neighbour interpolation is, depending on the given position P, to choose the nearest neighbour in the grid and copy its value(s). Given two grid points where P is inbetween, linear interpolation is a (linear) mixture of both values of the grid points. If P is right on the half position, 0.5 from the first value, and 0.5 of the second value are summed up to the resulting value. For two dimension this is called bilinear interpolation and for three dimensions trilinear interpolation.

So I know that the Min Mag filters are used to define interpolation for e.g. OpenGL textures. E.g. on this page http://gregs-blog.com/2008/01/17/opengl-texture-filter-parameters-explained/ the following table is given:

Filter Combination                     | Bilinear | Bilinear | Mipmapping
(MAG_FILTER / MIN_FILTER)              | (Near)   | (FAR)    |
---------------------------------------+----------+----------+------------
GL_NEAREST / GL_NEAREST_MIPMAP_NEAREST | Off      | Off      | Standard
GL_NEAREST / GL_LINEAR_MIPMAP_NEAREST  | Off      | On       | Standard
GL_NEAREST / GL_NEAREST_MIPMAP_LINEAR  | Off      | Off      | Trilinear filtering
GL_NEAREST / GL_LINEAR_MIPMAP_LINEAR   | Off      | On       | Trilinear filtering
GL_NEAREST / GL_NEAREST                | Off      | Off      | None
GL_NEAREST / GL_LINEAR                 | Off      | On       | None
GL_LINEAR / GL_NEAREST_MIPMAP_NEAREST  | On       | Off      | Standard
GL_LINEAR / GL_LINEAR_MIPMAP_NEAREST   | On       | On       | Standard
GL_LINEAR / GL_NEAREST_MIPMAP_LINEAR   | On       | Off      | Trilinear filtering
GL_LINEAR / GL_LINEAR_MIPMAP_LINEAR    | On       | On       | Trilinear filtering
GL_LINEAR / GL_NEAREST                 | On       | Off      | None
GL_LINEAR / GL_LINEAR                  | On       | On       | None

The same page explains that the Min Filter is for objects, smaller than the texture (far objects) and the Mag filter, for objects bigger than the texture (near objects). I though, given a 3D texture, the interpolation method should always be trilinear if GL_LINEAR is set to both filters.

도움이 되었습니까?

해결책

Texture interpolation only works if a single pixel of the texture is spread across multiple pixels of the display. If the texture is far enough away that display pixels are larger than texture pixels, some texture pixels will not be displayed at all, leading to a jagged, messy appearance.

This is where mipmapping comes in: instead of a single version of a texture, you have multiple versions, each smaller than the previous, created by downscaling the texture and blending adjacent pixels together. This is called a mipmap, and the different versions are traditionally each half the size of the last. When displaying the texture, the renderer will select the largest version that spreads texture pixels across multiple display pixels, and interpolates on that.

But this in turn has a problem: the transition between texture versions produces an abrupt line in the display. The solution to this is trilinear filtering: instead of simply interpolating between pixels in a texture, the renderer also interpolates between versions of the texture.

다른 팁

Texture mipmaps are different versions of the texture. For example distant objects would use smaller resolution version of the texture in a common scenario which helps with performance and can even resolve aliasing artifacts withe the cost of increasing memory usage. You can even set interpolation methods for mipmaps in a sampler, for example nearest neighbor swaps mipmaps, but linear fades between them.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top