Resolution snapping on resize

Godot Version

v4.2.stable.official [46dc27791]

Question

Hi!

When resizing the window of my game the game doesn’t sit flush against either the top and bottom or sides and larger than necessary black borders appear.

Here is a video showing the issue better than I can describe it.

I’m using Godot 4.2 on macOS Catalina (10.15.7) and I have the following settings for Project Settings > General > Display > Window:

  • Viewport Width: 640
  • Viewport Height: 360
  • Window Width Override: 2560
  • Window Height Override: 1440
  • Stretch Mode: canvas_items
  • Aspect: keep
  • Scale: 1
  • Scale Mode: integer

I’ve downloaded other games that have these settings and they don’t appear to snap like this one and the content typically keeps its aspect ratio whilst filling the width or height of the window rather then snapping further into the window than necessary.

I’ve tried setting stretch mode to viewport which is recommended for 2d pixel art games but the issue still persists and movement of my character becomes blurry so I’ve stuck with canvas_items.

Thanks for any help you can provide!

That happens because you set the window stretch scale mode to Integer. You need to set it to Fractional for it to scale with the window. More information here Multiple resolutions — Godot Engine (stable) documentation in English

1 Like

Note that fractional scaling will result in uneven pixel scaling, as viewport stretch mode always uses nearest-neighbor filtering. There’s currently no option to use sharp bilinear filtering instead, which would alleviate the issue (at the cost of overall slight blurriness).

Therefore, I really don’t recommend using fractional for pixel art games.

1 Like

I honestly thought I’d tried that along with other combinations but you’re absolutely right!

Thank you so much!

I’m using canvas_items as it appears to be much more crisp than the viewport scaling option even though it goes against the docs recommendations. I assume it’s due to what you’ve mentioned.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.