Pull requests

#18 Merged
Repository
slime73/love-mipmap love-mipmap
Branch
default
Repository
rude/love love
Branch
default

Add mipmapping support to images

Author
  1. Alex Szpakowski avatarAlex Szpakowski
Reviewers
Description

Both rendering performance and perceived image quality can benefit greatly from the use of hardware mipmapping (as described here: http://en.wikipedia.org/wiki/Mipmap) 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, love.graphics.setDefaultImageFilter 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.

love.graphics.isSupported("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 (https://bitbucket.org/rude/love/issue/542/texture-filtering-inconsistencies) is also included. Font graphics objects have mipmap filter and sharpness support as well.

Comments (2)

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.