Snap 2D Transforms to Pixel

Hello !! I have a problem: when I reduce the size of a PNG graphic, for example, to 0.3 and the object is moving, there’s a slight flicker. When I enable the “Snap 2D Transforms to Pixel” option, the problem disappears, but the object shakes slightly while moving.

That’s kind of fundamental to how the underlying math works. Your screen (or any screen you’re likely to encounter, unless you start messing with vector CRTs…) is fundamentally a grid of pixels. Your image is also a grid of pixels. You can’t have partial pixels.

When trying to put an image on the screen at an arbitrary position and scale, mathematically the grid of the source image may not match up with the grid of the screen; if you’ve scaled it, the pixels are different sizes, and if you’ve moved it the grid cell centers may not line up.

“Snap 2D Transforms to Pixel” says “force the source image to a position where hopefully the grids line up if they’re at the same scale”. That gives you the most accurate rendition of the image each frame, but it means (potential) jitter as it moves because it’s being snapped to fit the grid, and that’s pulling it away from where it would ideally be if the pixels were infinitely small.

Without the snap, instead each screen pixel winds up being a weighted average of the (up to) four source pixels from the image that intersect with it. This tends to smear a bit, and you get fuzzy edges.

It’s a “pick your poison” situation, really. There’s no perfect fix unless you make it so all your image pixel sizes are 1:1 with screen pixel sizes, and you only ever move images in ways that are integer distances in both dimensions.

Thanks for the answer! So I guess I’ll have to change the size in Photoshop, there’s no other solution, do I understand correctly?

If you can scale in photoshop (or gimp, or whatever art package works for you) ahead of time you’ll likely get better results than scaling on the fly, but it won’t fix everything; the fundamental underlying problem is still there. With scaling in an art package you just get (typically) a higher quality scaling algorithm, since it can take as long as it wants.