Pixel Perfect scaling

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Oen44

Any tips on what to do if pixel perfect scaling adds/removes pixels from sprites on higher resolutions?
Pixel Snap is On
Base resolution 1280x720
Stretch Mode 2d, Aspect Keep
Filter is disabled in Import settings
16x16 default image size, sprites are rendered using NinePatch
Game is running in 1920x1080 resolution

2000% zoom non-scaled (original, from editor)

2000% zoom scaled (from game)

if youre scaling pixel art, it probably isnt the best idea to turn on pixel snap. that’s why it looks better from the editor.

dustin | 2020-07-12 07:53

Without Pixel Snap, it’s even worse.
enter image description here

Oen44 | 2020-07-12 10:38

:bust_in_silhouette: Reply From: Sagn

You need to scale it using integer (whole number) factors.
When you are scaling from 1280x720 to 1920x1080, you are scaling by a factor of 1.5, which results in some pixels ending up larger than others.

To keep pixel size consistent you could for example change the base resolution to 960x540, which scales to 1920x1080 by a factor of 2.

There are more resolutions than 1920x1080, I can’t make it work just with one. I need this to be responsive.

Oen44 | 2020-07-12 16:53

Yes, it was just meant as an example, and I tried to make it as close to your original as possible. Seems you landed one that worked out better for multiple resolutions.

Sagn | 2020-07-13 12:19

:bust_in_silhouette: Reply From: JimArtificer

Since you aren’t dealing with a 1:1 set of resolutions you have to address sub-pixel rendering in some way to get a smooth result.

Here’s a tutorial about jitter-free pixel art scaling:

:bust_in_silhouette: Reply From: Oen44

Changing base resolution to 640x360 solved this, now it scales properly with 16:9 resolutions.