0 votes

recently I wanted to add a camera shake to my project so I added a Camera2d-Node but in this way my GUI does move too because the camera has impact on all nodes in the current scene.
This is why I moved the Game-Scene into one viewport (+container) and the menu into another viewport. This works perfectly at first, but as soon as I scale the window, the viewport does not.
What I mean:
I set the display/window/stretch/aspekt setting on keep so all nodes are automatically scaled and black corners appear if the window-relation changes, so the format keeps the same. The problem: the viewport is streched on a bigger amount of pixels but still renders the old format. In this way it seems unsharp.
When I do not implement any viewport at all the keep-setting works perfectly. Is there any setting for viewports that can handle the pixel stretch like the main scene does?
Mhm, I hope you see the problem,
thank you,
Olaf ;)

asked Jan 15 in Engine by Olaf007 (12 points)

1 Answer

0 votes

If you scale a viewport up it will stay in its original resolution but is just bigger. The resolution of the viewport will stay the same if you scale up. It is like a photo on your smartphone, the more you zoom the more it will get unsharp. That si how a viewport behave.
If you could send some pictures of your work I might can help you :)

answered 1 day ago by MrMrBlackDragon (24 points)

Okay thanks, I recently published my Game in a GameJam ;) --> "Bounty Rain"

So what I had first:
--> The scene is rendered on the main viewport as the menu too.
--> Edges of the sprite-textures are very sharp and automatically change their resolution when the window size changes. I cannot manually change the resolution because the game runs in the Browser, so there is no OS.window_size - that is why I use the strech aspect project setting.
--> I cannot implement a Camerashake because it would shake the GUI too.

This is how I thaught it would solve my problem:
--> Scene is now in a extra Viewport, so the shaking camera does not impact on the menu - works perfectly!
--> Sadly, as you can see, the sprite textures are unsharp - because the view in the editor is smaller than the actual resolution of the viewport. (As you say, the viewport is scaled)
In game, this problem gets even worse if you set the window size on a way bigger amount then the viewport resolution. Ofcourse this scales the viewport, so it is unsharp.
But how can I solve the problem? I cannot reset the viewport.rectsize in code because I have no OS.windowsize when I run the Game in the Browser! :)

Hope you have an idea? :)) And thanks.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.