Jun 24, 2013

Mipmap Quality

So mipmaps are often blurry and artists think we are bunch of morons making their awesome artwork so blurry.. :-) You know, most of the time we see lower mips all the time in the game. It depends on camera settings, but I found it's very rare that we see highest mip in most of the games out there.

3 Widely Used Tricks

I know there are 3 widely used ways: 1) increased texture size, 2) mipmap bias or 3) use of kaiser filter when generating mip chain.

First way can be only used selectively because it increase the memory footprint. Probably this is more viable with next-gen consoles with way bigger memories.

Second way usually introduces too much aliasing because it only pushes back when the mip starts to change. If there's a way to control the curve when consecutive mips kick in, I would love it more. (I can do all this in HLSL of course)

Third way is something I didn't see any improvement personally. Some people say kaiser filter would make mipmap so much better than box filter. But when I tired it, i didn't really see much improvement.

Less Used But More Effective Trick - Sharpening Filter

And there's another way that is not as widely used, but I found this works really well: apply sharpening. (This is why I contributed a generic convolution filter to Nvidia Texture Tools 2. There were a couple of people requesting this feature, but the maintainer didn't see this feature important, so I had to make it by myself)

The concept is very simple. You just do this for a few top mips while generating the mipchain, hopefully in your texture baker.

  1. Generate mip 1 from original texture(mip 0) by using box filter
  2. Apply sharpening filter on mip 1
  3. Generate mip 2 from the result from Step 2 by using box filter
  4. Apply sharpening filter on mip 2
  5. Repeat....

So which technique do you use to increase mipmap quality? Or is there any other trick that I'm not aware of?


  1. What do you mean by bilinear filter? Bilinear interpolation can be seen as upsampling with a tent filter, but tent filters often produce very blurry results for downsampling. Or do you mean box filter instead? Personally, for LDR textures I've gotten best results with a Kaiser or Lanczos-windowed sinc filter. The negative lobes can cause excessive ringing with HDR textures, so for those cases I use a regular box filter.

    It would be interesting to pre-convolve the sharpening and downsampling kernels to see what the kernel values would look like. I wouldn't be surprised if the result were similar to the discrete Kaiser filter.

    1. doh stupid me! I meant to say box filter. fixed the main article. thanks! :)

      When I tried the nvtt2 Kaiser filter for mipmaps, there was really not much improvement over the box filtering. But the sharpen filter did the job. Unfortunately, I don't have the access to the sharpening kernel I used that time (not with that company anymore).

  2. There can also be scope for adjusting the filter on a more ad-hoc basis based on the context in which the texture is used. I did a little experimentation with mipmaps for white lines on roads here: http://johnwhigham.blogspot.co.uk/2011/08/note-on-texture-filtering.html

  3. There is always some loss of quality and sharpness no matter what technique you use.

    The best way to combat this is what you suggest - make sure you have high quality and sharp textures to begin with and try to limit the blur or counteract it with a slight sharpening.

    One very overlooked technique I see no one use is to use a screen-space sharpening shader on the final image (but before the UI) to mitigate the loss of sharpness that is unavoidable.
    I do this in my SweetFX mod, and it's very effective and probably the most popular effect in the mod.

    1. postfx sharpening is an interesting idea.. actually i saw a pretty big game doing it as part of their FXAA. :)