godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.14k stars 96 forks source link

Add an option to emulate `viewport` stretch mode in the 2D editor #6187

Open Lucrecious opened 1 year ago

Lucrecious commented 1 year ago

Describe the project you are working on

I'm working on a 2D pixel art game. I am using the viewport stretch option to keep the sprite pixel aligned (pixel perfect).

It's often that I use shaders to enhance the look of the game. Most recently I've used a "clean edge" shader that allows for nicer pixel art rotations. I also am using line2d nodes and trying to make some cut out animations.

Describe the problem or limitation you are having in your project

The canvas item editor uses the device resolution, which is very high. This means the shaders and sprites are not pixel aligned. Due to the this, it's cumbersome to edit shaders and cut-out animations since the only way to see the real results is by starting the game.

Similarly with line 2d, it's very hard to know how it will look in game by looking at the editor because it's in a higher resolution.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

A "pixel perfect" mode for the canvas item editor that sets the viewport size to be the same size as set in the project settings.

Regular mode render would look something like this:

image

Even through we are looking at 160 by 90 sized screen, due to the stretch mode "canvas items", the sprite can rotate with more angles.

And pixel perfect mode would look like this:

image

Here I set the stretch mode to "viewport" and now it's "pixel perfect".

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Inside Editor -> Editor Settings -> (Editors) 2D -> Render Pixel Perfect

Simply as a toggle.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Cannot be worked around currently. Unless you can the resolution of your monitor I guess haha

Is there a reason why this should be core and not an add-on in the asset library?

A lot of pixel art games are creating using Godot. I think a good way of previewing the game in the editor as it would look once you run it would be nice!

vpellen commented 1 year ago

So I've been having a conversation with another user who actually ran into confusing graphical issues for want of this feature. I'd also like to suggest that 2D vertex/transform snap settings should probably be respected.