Keep Love2D pixel art crisp with setDefaultFilter
Set nearest-neighbor filtering before loading images so scaled pixel art stays sharp in Love2D.
12 Oct 2026, 02:50 UTC

The problem and the fix
A 16×16 pixel-art sprite often turns soft and smeared when you draw it at two or four times its original size. Love2D applies smooth texture filtering by default, which blends neighboring pixels and destroys hard edges.
Useful takeaway: call love.graphics.setDefaultFilter("nearest", "nearest", 1) in love.load before any love.graphics.newImage call. This makes every new image and canvas use nearest-neighbor filtering, so scaled pixels remain crisp squares instead of blurred smears.
How default texture filtering works
Texture filtering determines how the GPU samples a texture when a pixel on screen does not line up exactly with a pixel in the image. Minification happens when the drawn sprite is smaller than the source image; magnification happens when it is larger. Anisotropy improves sharpness for textures viewed at sharp angles, but it is mainly relevant for 3D-style rendering.
love.graphics.setDefaultFilter(minFilter, magFilter, anisotropy) sets the default for images and canvases created after the call. It does not change images that are already in memory. This API is available in Love2D 11.0 and later.
Worked configuration
Place this in your project's main.lua. No special permissions are required beyond normal read access to the image file.
function love.load()
-- Set the default before creating any image resources.
love.graphics.setDefaultFilter("nearest", "nearest", 1)
-- Replace with your actual asset path.
player = love.graphics.newImage("assets/player.png")
end
function love.draw()
love.graphics.clear(0.05, 0.05, 0.08)
-- Draw a 16×16 sprite at 4× scale: it occupies 64×64 screen pixels.
love.graphics.draw(player, 200, 150, 0, 4, 4)
end
The 4, 4 arguments scale the sprite horizontally and vertically. With nearest filtering, each source pixel becomes a 4×4 block of solid color. With linear filtering, the edges would blend into intermediate colors.
Verify the result
- After
setDefaultFilter, calllove.graphics.getDefaultFilter(). It should return"nearest", "nearest", 1. - Confirm the Love2D runtime is version 11.0 or newer at startup.
- Run the game and inspect the sprite at 4× scale. Nearest filtering should show crisp pixel squares; linear filtering would show softened edges.
Because this example describes expected behavior rather than a captured test run, treat the visual result as something to confirm on your own machine.
Limits and common mistakes
- Calling it too late. If you load
player.pngbefore callingsetDefaultFilter, that image keeps whatever filter was active when it was created. Move the filter call to the top oflove.load. - Assuming it updates existing images. Already loaded images and canvases retain their original filter. Reload the resource or call
image:setFilter("nearest", "nearest")on an individual image to override it. - Using linear filtering for pixel art.
"linear"is useful for smooth photographs, but it blurs sharp pixel edges at any scale. - Anisotropy on old hardware. Values above 1 require GPU support. On older devices the setting may silently fall back to linear filtering.
Rollback
setDefaultFilter changes global state for subsequently created resources. To restore a previous default, capture the return value of getDefaultFilter before changing it, then call setDefaultFilter again with those saved values.
Bottom line
For pixel-art games in Love2D 11.0+, set nearest-neighbor filtering before loading images, verify with getDefaultFilter, and remember that the setting applies only to new resources.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.