Using Mipmapping to Improve Quality and Performance

Using mipmaps can improve rendering speed and visible graphical quality

Mipmaps are smaller, pre-filtered variants of a texture image, representing different Levels of Detail (LOD) of a texture. A minification filter mode that uses mipmaps must be used. The graphics core can then be set up to automatically calculate which LOD comes closest to mapping the texels of a mipmap to pixels in the render target, and use the right mipmap for texturing.

Advantages

Using mipmaps has two important advantages:

  • Increases performance by massively improving texture cache efficiency, especially in cases of strong minification.
  • Improves image quality by countering the aliasing that is caused by the under-sampling of textures that do not use mipmapping.

The single limitation of mipmapping is that it requires approximately a third more texture memory per image. Depending on the situation, this cost may be minor when compared to the benefits in terms of rendering speed and image quality.

There are some exceptions where mipmaps should not be used. Specifically, mipmapping should not be used where filtering cannot be applied sensibly, such as for textures that contain non-image data such as indices or depth textures. It should also be avoided for textures that are never minified, for example with UI elements where texels are always mapped one-to-one to pixels.

Generation

Ideally mipmaps should be created offline using a tool like PVRTexTool, which is available as part of the PowerVR Graphics SDK. It is possible to generate mipmaps at runtime, which can be useful for updating the mipmaps for a render to texture target. In OpenGL ES this can be achieved using the function glGenerateMipmap. In Vulkan there is no such built in function, and they must be generated manually.

This will not work with PVRTC textures which must have their mipmaps generated offline. A decision must be made as to which cost is the most appropriate - the storage cost of offline generation, or the runtime cost (and increased code complexity in the case of Vulkan) of generating mipmaps at runtime.

Filtering

The lack of filtering between mipmap levels can lead to visible seams at mipmap transitions, in the form of an artefact known as mipmap banding. Tri-linear filtering can be enabled by setting the filter mode as follows:

  • OpenGL ES - use GL_LINEAR_MIPMAP_LINEAR.
  • Vulkan - use VK_SAMPLER_MIPMAP_MODE_LINEAR.

This can effectively eliminate these seams, for a price (see Texture Filtering), which achieves an even higher image quality.