5
\$\begingroup\$

To my understanding, mipmaps exist to save on computations and memory when textures are far away. In an ideal world, we wouldn't want them. We'd just use the same high quality textures far away and not care about wasted resources.

But in reality, we need anisotropic filtering to smooth the disconnect between varying LOD mipmaps (or so I think).

However, do images using mipmaps with anisotropic filtering look better than no mipmaps without anisotropic filtering? See here (the first image looks worse than the third even though the first has no mipmaps). Is it because anisotropic filtering has anti-aliasing built in? And if we didn't have mipmaps, but added anti-aliasing, would the resulting image look better?

\$\endgroup\$
  • 2
    \$\begingroup\$ Nominated to re-open. I've edited the headline to remove the "which is better?" opinion focus. I think there's a legitimate question here about how mipmapping, anisotropic filtering, and anti-aliasing combine to reduce rendering artifacts, and also some common misconceptions about mipmapping worth clarifying in an answer. \$\endgroup\$ – DMGregory May 15 '15 at 18:55
  • \$\begingroup\$ @DMGregory Thanks for adjusting the title. Hopefully, it will be re-opened. \$\endgroup\$ – Jake May 15 '15 at 19:10
7
\$\begingroup\$

Firstly, texture filtering and anti aliasing are two different ways of improving image quality. You can apply them both independently.

Anti aliasing is primarily done to smooth the joins where two separate triangles overlap. Depending on how it's done it can also benefit texturing quality indirectly too.

Texture filtering is done to improve the image quality inside each triangle.

Mip mapping is done to make texture filtering efficient. To take it to extremes let's say you had a GPU that could filter textures perfectly without mip maps. If you had a square textured with a 1024x1024 texture that occupied a single pixel on screen, that theoretical GPU would have to read all of the 1,048,576 pixels in the texture to work out the colour of that one pixel on screen. With a mip map it can read one pixel from the smallest mip level to do the same thing and get the same result.

Of course in reality without mip maps a GPU will actually only look at a very small number of pixels in the texture it's sampling (four of them with bilinear filtering, one with point filtering). This generally causes the result to be very noisy, and also gives a performance hit because of cache misses as those pixels are scattered all over the texture. The only places where it can be sensible not to use mip maps are for things like 2D sprites where you don't scale the image significantly.

The cost of adding a mip map to a texture is that it gets about 33% bigger, which is a relatively low memory overhead given the benefits.

Anisotropic filtering kicks in if instead of one pixel in that previous example it was say a 1x8 pixel square. What happens if you use the 1x1 mip level is that the result has no detail and looks blurry. However the 8x8 mip level has 64 pixels in it, which need to map to 8 pixels on screen. With anisotropic filtering the GPU will read some extra pixels from a bigger mip level to make the result less blurry. Reading those extra pixels has a performance cost compared to bilinear or trilinear filtering.

In a more realistic scene the anisotropic filtering makes things that aren't square on to the camera like floors less blurry. Anisotropic filtering example image

Image is from http://en.wikipedia.org/wiki/Anisotropic_filtering

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Just to add to Adam's excellent answer. WRT "This generally causes the result to be very noisy, and also gives a performance hit because of cache misses as those pixels are scattered all over the texture." If you use texture compression but then don't use MIP mapping, it'll undo the benefit of using texture compression in the first place! There are some notes here: computergraphics.stackexchange.com/a/419/209 \$\endgroup\$ – Simon F Dec 5 '19 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.