Anisotropic filtering

From DmWiki

Anisotropic filtering is related to mipmapping. While mipmapping effectively reduces texture aliasing by deliberately blurring the texture, sometimes it blurs it too much; anisotropic filtering is a more accurate filtering method that allows the texture to appear sharp and crisp while still being free of aliasing.

How mipmapping works

When we render a square, say 256x256 pixels, and we use a square texture of the same size, it will look splendid. But if we tilt that square backward, it becomes more like a rectangle, being more wide than heigh. Let's say its dimensions are 256x32, roughly. This means that the texture that we map onto it is compressed 8 times in the vertical direction. In other words, we would skip 7 out of every 8 lines. All that information is lost. It also causes flickering, aliasing, because when you shift the tilted square up and down, other horizontal lines will become visible and others dissapear. To avoid the flickering, mipmapping uses a 32x32 version of the texture, where blocks of 8x8 pixels of the original texture are nicely averaged together. This is also a loss of information, but it stops the flicker. This is what is done with regular mip-mapping. The biggest disadvantage is that we now have 32 pixels horizontally in the texture, mapped onto 256 pixels on the screen. So we're stretching it out, making it look blurry.

How anisotropic filtering works

What we really wanted is to average 1x8 pixels together, so we'd get a 256x32 texture. But that doesn't work when we start rotating the square. And it also requires a lot of extra memory. The alternative, is to sample the texture 8 times per pixel, in the direction in which the polygon is tilted. That's anisotropic filtering. It doesn't matter how the square is rotated, it can take 8 samples in the texture in any direction required, and average them together. It's called anisotropic because the degree of filtering in one direction (the direction in which the polygon is tilted) is greater than the degree of filtering in the direction perpendicular to that.

Comparison with texture supersampling

Supersampling, or rendering at a higher resolution, would also be a method of avoiding aliasing for textures. However, supersampling works in a fixed pattern. Regular 4X super-sampling takes two samples vertically, and two horizontally. When the square is tilted backward, we don't care (much) about the extra samples horizontally. We only really need the samples in the vertical direction, to avoid aliasing and blur. Furthermore, the lighting calculations would be done multiple times per pixel when using super-sampling, while once suffices. With anisotropic filtering, the only cost is taking the extra samples in the texture and averaging them together. This is not that expensive in hardware, much easier than using eight times more complete pipelines.

This page would benefit from the use of an image. You can help improve the article by creating one.


DevMaster navigation