Unity-Technologies / 2d-renderer-samples

Samples for Unity's 2D Renderer
Other
170 stars 24 forks source link

The Pixel Perfect example is very jittery #5

Open DVonk opened 2 years ago

DVonk commented 2 years ago

Hi,

I've just downloaded the project and I feel like all of the examples are really helpful - but the Pixel Perfect ones just don't look right, at all. I've taken videos, so you can see what I mean. I activated the Pixel Perfect checkbox on each one.

Sprite Renderer: https://streamable.com/otkwo6 Especially evident on the Animated SpriteRenderer, but the others aren't much better. Yes, the sprites are rendered perfectly, but the movement is terrible jittery. Especially when moving diagonally. I don't think I would be able to use this in a real game, as I'd want smooth motion to go along with the pixel perfect rendering.

Tilemap: https://streamable.com/adm79x I think this one is worse than the other, since now there's camera movement, which makes the entire screen jitter. To me this feels almost headache-inducing when moving diagonally.

The problem seems to be that, while the camera is rounded to the next pixel, the objects themselves are not. So they are actually always somewhere in between pixels in world units, and the camera tries to round them to the nearest pixel. But that creates a terrible jitter effect. Especially the follow camera has this problem, since its speed is not constant.

When you skip through frames in the Sprite Renderer demo you can also see what is happening. Sometimes the character moves by one pixel and sometimes by two. And diagonally it seems really random. Which is what leads to the jitter: https://streamable.com/qh99ny This absolutely cannot happen if you want smooth movement without this jittering effect. In the Sprite Renderer you'd probably need to round the character position to the nearest PPU value, and in the camera follow you probably also need to do that for the camera object itself.

I feel like you definitely need examples that don't have this jitter. I personally can't think of any actual pixel art games that have this problem.

kennytann commented 2 years ago

Hi, thanks for sharing your feedback. You are correct in the sense we are snapping the camera to the closest pixel, and we do not support smooth pixel perfect camera movement yet. Rounding Sprite Renderers position maybe a too invasive solution, as it will affect other systems like Physics. We will look into improving and adding this feature.