Scrambled pixel sprites in viewport Godot 4

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

I am making a small pixel art space shooter. The problem is that every time I start the game, the player and enemy sprites are all messed up. Maybe It’s something from the project settings, I have no idea.

In editor:


In viewport:

:bust_in_silhouette: Reply From: malaska

That looks like you have set your projects window settings to a size that doesn’t jive well with your pixel art style, or a Window Stretch Mode that doesn’t work well with your viewport size.

Here are 2 things I would check:
– If you have a viewport size of say 480x270, your Window Height/Width should be the same, or double, or even multiples larger for a good pixel result.
– You can also achieve cleaner looking pixels at odd size mismatches using the canvas_items stretch mode rather than the viewport stretch mode

These 2 things in combination are what helped me get the look I wanted for my game.

Sadly, the Godot 3.x pixel snap setting seems to not be present in Godot 4. But while that seemed to fix the issue, it presented other effects that weren’t always desireable.