Choosing the Right Texture Filter in Love2D: Nearest, Linear, or Mipmap
Learn how to choose and configure Love2D’s texture filters—nearest, linear, and mipmap—with a working code example, platform limits, and common pitfalls to avoid.
30 Jan 2026, 14:52 UTC

When to use each filter mode
If your game relies on pixel‑art graphics that must stay sharp at any size, set the filter to nearest. For smooth scaling of photographs or UI elements where a little blur is acceptable, use linear. When you render large textures that are often viewed from a distance (e.g., terrain, background sprites), enable mipmap to reduce aliasing and let the GPU sample lower‑resolution versions of the texture.
Worked configuration: enabling mipmap on a sprite
The following snippet loads a 256×256 pixel texture, activates mipmap filtering with one mipmap level, and draws the sprite scaled to four times its original size. The code assumes Love2D 11.5 or later.
-- main.lua
function love.load()
-- Load the image (must be a power‑of‑two size for mipmaps)
local img = love.graphics.newImage('assets/terrain.png')
-- Enable mipmap filtering: mode, mipmapLevel
img:setFilter('mipmap', 1)
-- Store for drawing
terrainImg = img
end
function love.draw()
-- Draw the texture at 4× scale, rotated slightly to show sampling
love.graphics.draw(terrainImg, 400, 300, 0, 4, 4, terrainImg:getWidth()/2, terrainImg:getHeight()/2)
-- Optional: show current filter in the corner
love.graphics.print('Filter: mipmap (level 1)', 10, 10)
end
Explanation:
love.graphics.newImagecreates a texture object.image:setFilter('mipmap', 1)tells Love2D to use mipmap sampling and to generate one lower‑resolution level (level 1). The second argument is optional; omitting it defaults to 0, which disables mipmapping.- When the sprite is drawn at a scale of 4, the GPU can sample from the lower‑resolution mip level if the texel size exceeds a pixel, reducing shimmering.
Limits and platform considerations
Mipmap filtering requires OpenGL 2.0+ (or OpenGL ES 3.0 on mobile). If the underlying driver does not support mipmap generation, Love2D silently falls back to the nearest available filter—usually linear. This fallback produces no error message, so the visual result may look blurrier than expected without any warning in the console.
Because the filter setting is stored with the texture object, changing it after the image has already been rendered may not affect the cached GPU representation until the texture is re‑uploaded. To avoid inconsistent frames, set the filter immediately after loading the image, before any draw calls that use it.
Common mistakes
- Assuming mipmap works on all mobile devices. Many older Android GPUs only support OpenGL ES 2.0, which lacks mipmap sampling; the filter will be ignored and you may see unexpected blurring.
- Calling
image:setFilteron a canvas that has already been drawn to. The new filter takes effect only for subsequent rendering to that canvas; already‑rendered content retains the old filter. - Forgetting the second parameter when you intend to use a specific mipmap level. If you write
image:setFilter('mipmap'), Love2D treats the missing argument as 0, disabling mipmaps. - Specifying a mipmap level larger than the texture’s actual chain (e.g., level 3 on a 64×64 image). The extra levels have no effect, but the code can mislead readers into thinking higher levels improve quality.
Practical verification
To confirm that mipmap is active on your target hardware:
- Load a texture with dimensions that are a power of two (e.g., 512×512).
- Set the filter to
mipmap, 2. - Render the texture at a very large scale (e.g., 8×) or far away in a 3D‑like scene.
- Observe whether the image shows reduced aliasing compared to the same texture filtered with
linear. If the image looks identical to thelinearcase, the device likely fell back to linear filtering.
No special tools are required; visual inspection is sufficient for most 2D projects.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.