Games
Why does pixel art look blurry? Smoothing, scale or position
Pixel art looks blurry or uneven for one of three reasons: a smoothing filter blends neighbouring pixels, the scale is not a whole number, or the art sits between two screen pixels. On phones the second is hard to avoid. Purrhoop draws on a grid 120 art pixels wide, so a 1,080-pixel-wide screen gives each one exactly 9 screen pixels, and a 1,170-pixel-wide screen gives 9.75. Knowing which cause you have tells you which setting to change, or which trade-off you are choosing.
Why does pixel art look blurry when you scale it up?
Usually because a smoothing filter is on. When an image is drawn larger than it was made, the renderer has to fill in the screen pixels between the art pixels. A smoothing filter, often called bilinear filtering, blends each of those from the art pixels around it. On a photo that hides jagged edges, but on pixel art it turns every hard edge into a soft ramp.
The fix is nearest-neighbour sampling. Each screen pixel takes the colour of the single art pixel it falls in, with no blending at all. In a game engine this is usually the texture filter setting. It has to be off on every layer you draw, because a background or interface layer left on the default still goes soft.
In a browser, the CSS property image-rendering: pixelated does the same job.
MDN’s reference page for image-rendering describes it as scaling with the
nearest-neighbour method or something similar.
Purrhoop draws every layer with smoothing switched off: the beach, the interface layer, the cat’s house between rounds and the home button. That removes the first cause completely, which is exactly what leaves the second one visible.
Why are some pixels wider than others?
Because the scale is not a whole number. Nearest-neighbour sampling can only hand out whole screen pixels. If each art pixel should be 9.75 screen pixels wide, some get 9 and some get 10. Nothing is blurred, but a row of identical blocks comes out in two sizes.
On a still image it shows as the odd column that is one pixel narrower than its neighbours. In motion it is easier to spot. A sprite sliding sideways changes width slightly as it crosses the narrower columns, which can read as a wobble rather than a blur.
The only complete fix is a whole-number scale: 2, 3, 4 and so on. Every art pixel then gets the same number of screen pixels, and the grid is perfectly even. The catch is that a whole number rarely fills a phone screen exactly.
Why does pixel art shimmer when it moves?
Because something is placed between two screen pixels. Game positions are often fractions, and a sprite at x = 10.4 has no whole pixel to start on. With smoothing on, the renderer blends it across both, so moving sprites look softer than still ones. With smoothing off, its edge flips between neighbouring columns from one frame to the next.
The fix is to round positions to whole pixels before drawing. Rounding to whole art pixels keeps every sprite on the same grid as the background. Rounding only to screen pixels is smoother, but lets a sprite sit part-way across an art pixel, so it no longer lines up with the grid.
In Purrhoop this cause cannot arise inside the art. Everything is drawn into a pixel buffer, a grid of cells where a sprite can only land on a whole cell. The finished frame is then placed on the screen at a whole-pixel offset.
Why can’t a phone game just use a whole-number scale?
Because phone screens are rarely a whole multiple of a small canvas. Pixel art is drawn small, so a game’s canvas is often only a few hundred pixels wide. Screen widths vary from phone to phone, and most of them do not divide evenly by the canvas.
So a game with a fixed canvas has to choose. It can scale by the largest whole number that fits and leave borders. Or it can fill the screen and accept uneven pixels. A third route is to change the canvas itself, drawing more art columns on wider screens, which costs extra art and layout work for every screen shape.
Take Purrhoop’s art on a 1,170-pixel-wide screen. The largest whole scale is 9 screen pixels per art pixel, which covers 1,080 pixels. That leaves 90 pixels of border, 45 on each side, to keep every block exactly even.
What did Purrhoop choose?
Purrhoop fills the screen width. Its art is drawn on a grid 120 art pixels wide and 200 tall. Each art pixel is doubled into a 2-by-2 block, giving a frame 240 pixels wide and 400 tall. That frame is scaled by the smaller of two ratios, screen width over 240 and screen height over 400. The result is not rounded to a whole number.
On any screen narrower than the frame’s own 3:5 shape, the width runs out first. The beach then spans the full width. A taller screen shows more sand below the beach instead of a border. When the height runs out first, the side bars repeat or stretch the edge of the background, so the sky and sand still reach the screen edges.
The doubling step is also where colour is decided. The art is painted in material codes such as sky, sea and cat fur, and each code becomes a colour as the grid is doubled. That is how one set of art can be shown in more than one look.
Mono look
NES look
How wide is each pixel on your screen?
Divide the screen width by 120, the width of Purrhoop’s art grid. If the answer is a whole number, every art pixel is the same size. If it is not, art pixels come out in the two whole numbers either side of it.
| Screen width | Screen pixels per art pixel | Art pixel widths |
|---|---|---|
| 720 | 6 | all 6 |
| 960 | 8 | all 8 |
| 1,080 | 9 | all 9 |
| 1,170 | 9.75 | 90 at 10, 30 at 9 |
| 1,440 | 12 | all 12 |
At 1,170 the split follows from the total. 120 art pixels have to fill 1,170 screen pixels, which is 1,080 plus 90, so 90 of them are 10 wide and 30 are 9 wide. That is one narrow art pixel in every four. Which columns get the 9 depends on exactly where the renderer samples, but the count does not.
The 1,080 row hides a detail. The 240-pixel frame is scaled by 4.5 there, so the frame’s own pixels come out 4 and 5 wide. Because each art pixel is a 2-by-2 block, every pair adds up to 9, and the art stays even.
These widths are arithmetic from the game’s code, not measurements taken from a phone. We checked them with a short script that repeats the scaling rule and nearest-neighbour sampling, under two different sampling conventions, and counts the width of every art pixel. The table assumes the game fills the screen’s full width, which it does whenever the width runs out first.
Purrhoop's art grid is 120 art pixels wide and fills the screen width. On which screen do the art pixels come out in two sizes?
Answer: A screen 1,170 pixels wide — Right. 1,170 divided by 120 is 9.75, so 90 art pixels come out 10 wide and 30 come out 9 wide.
What happens to the pixels while you aim?
They go uneven on every screen, by design. While you hold to aim, the camera eases in to 1.15 times its normal size, then eases back out when you let go. 1.15 times a whole number is almost never whole, so even a screen with perfectly even pixels loses that for a moment.
On a 1,080-pixel-wide screen, each art pixel becomes 10.35 screen pixels during the zoom, so they come out 10 and 11 wide. On a 960-pixel-wide screen they come out 9 and 10. While the camera eases in and out, the widths change every frame.
The interface is not zoomed. The clock, the coins and the catch count sit on their own layer, drawn at the normal scale. On a screen with even pixels they stay even while the beach zooms behind them. The zoom trades perfect blocks for a closer view while you aim.
How do you tell which cause you have?
Take a screenshot and zoom in on a hard edge. A soft ramp of in-between colours means a smoothing filter. Hard edges with some blocks wider than others mean a scale that is not whole. Hard edges that shift as a sprite moves, while the background stays put, mean positions between pixels.
Then check the arithmetic. Divide the width your game draws into by your canvas width. If the result is not whole, the phone choice is in front of you: borders, uneven pixels, or a canvas that changes width.
Purrhoop is the game behind every number here: a wordless cat-fishing arcade game in pixel art, with 60-second rounds, on iPhone and Android. It is free, shows no ads and needs no sign-in, with optional one-time purchases. The rest of the shelf is on the Games page.
Frequently asked questions
- Why does pixel art look blurry?
- For one of three reasons. A smoothing filter is blending neighbouring pixels, the art is scaled by a number that is not whole, or the art is drawn at a position between two screen pixels. The first makes edges soft, the second makes some pixels wider than others, and the third makes moving sprites soft or jittery.
- How do I make pixel art not blurry?
- Switch the smoothing filter off on every layer you draw, so each screen pixel takes the colour of one art pixel. In an engine that is the texture filter setting; in a browser it is the CSS property image-rendering: pixelated. Then round positions to whole pixels, and scale by a whole number where the screen allows it.
- What is integer scaling for pixel art?
- Scaling by a whole number, such as 3 or 4, so every art pixel covers the same number of screen pixels. It is the only way to keep a pixel grid perfectly even. On a phone it usually leaves borders, because screen widths are rarely an exact multiple of a small canvas.
- Why are some pixels bigger than others in a pixel-art game?
- Because the art is scaled by a number that is not whole. Nearest-neighbour sampling can only hand out whole screen pixels, so at 9.75 screen pixels per art pixel some come out 9 wide and some 10. In Purrhoop on a 1,170-pixel-wide screen, that works out to 30 art pixels at 9 and 90 at 10.
- Does Purrhoop use integer scaling?
- No. Purrhoop scales its 240-by-400 frame to fill the screen width, and the scale is not rounded to a whole number. Art pixels come out the same size when the screen width divides evenly by 120, and in two sizes otherwise. While you aim, a 1.15 times zoom makes them uneven on every screen.