Skip to content

background: Limit mipmap levels to avoid loss of visible detail

Daniel van Vugt requested to merge vanvugt/mutter:bg-texture-max-level into master

When the wallpaper image is larger than the monitor resolution we already use mipmapping to scale it down smoothly in hardware. We use GL_TEXTURE_MIN_FILTER = GL_LINEAR_MIPMAP_LINEAR for the highest quality scaling that GL can do. However that option is designed for 3D use cases where the mipmap level is changing over time or space.

Since our wallpaper is not changing distance from us we can improve the rendering quality even more than GL_LINEAR_MIPMAP_LINEAR. To do this we now set GL_TEXTURE_MAX_LEVEL (if available) to limit the mipmap level or blurriness level to the lowest resolution (highest level) that is still equal to or higher than the monitor itself. This way we get the benefits of mipmapping (downscaling in hardware) and retain the maximum possible sharpness for the monitor resolution -- something that GL_LINEAR_MIPMAP_LINEAR alone doesn't do.

Example:

Monitor is 1920x1080
Wallpaper photo is 4000x3000
Mipmaps stored on the GPU are 4000x3000, 2000x1500, 1000x750, ...

Before: You would see an average of the 2000x1500 and 1000x750 images.
After: You will now only see the 2000x1500 image, linearly sampled.

Prerequisite: !1004 (merged)

Trivia: This seems to be the same approach as YouTube uses for its video thumbnails.

Before After
before after
Edited by Robert Mader

Merge request reports