Add mipmapping support to images

#18 Merged at 357ab7b
  1. Alex Szpakowski

Both rendering performance and perceived image quality can benefit greatly from the use of hardware mipmapping (as described here: when drawing downscaled images.

Mipmapping support has been added to LÖVE in the form of an optional third argument to Image:setFilter which specifies the mipmap filtering mode when an image is downscaled - "nearest" or "linear", as usual. Mipmaps are auto-generated if not present when a mipmap filter is set. Image:setFilter called without a third argument will disable mipmapping. Image:getFilter has been modified to match the new Image:setFilter behaviour.

Due to driver/GPU issues on some older video cards when generating mipmaps for NPOT textures, LÖVE will produce a friendly error if mipmap filtering is enabled on an image with non power-of-two dimensions. Because of this, has not been changed to accept a mipmap filter argument - you can only enable mipmapping via Image:setFilter after the image has been created.

Two new Image methods have also been added: Image:setMipmapSharpness(sharpvalue) and Image:getMipmapSharpness. A positive value means the GPU will use a larger-sized (less blurry) mipmap than normal when downscaling, and vice versa for a negative value. It is 0.0 by default. Internally, this sets the texture LOD bias of the image to the negated value of the sharpness."mipmap") has been added as well, although nearly every system should support OpenGL's mipmap generation.

Performance improvements when drawing downscaled images with mipmap filtering are very impressive, especially when using an integrated GPU. Here's a screenshot comparison of a test .love using my Intel HD 3000 (the image was downscaled from 512x512 and repeated across the screen). Performance was increased even further when the mipmap sharpness was 0, however the image appeared slightly blurrier.

The performance benefits of mipmapping are even greater when using a single repeating quad instead of a spritebatch or separate images.

An improved version of the changes from issue #542 ( is also included. Font graphics objects have mipmap filter and sharpness support as well.

  • Issues #542: Texture filtering inconsistencies resolved

Comments (2)

  1. Alex Szpakowski author

    Font graphics objects now have mipmap filter and sharpness support to match Image graphics objects.