Window resize/set_view_size issue

I’m trying to use high res images (4k) in my project, but then scale the window to a reasonable resolution for my laptop. My understanding is that in the game.project I should set the width and height to 4k and then I can use either DefOS set_view_size or https://defold.com/ref/render/#resize to resize the window to something reasonable along with use_fixed_fit_projection to keep the aspect ratio.

For some reason this doesn’t work and it breaks specifically as I go over some limit on the width/height in the game.project, i.e. it works if say width and height are 1000, but doesn’t if it’s 2000.

Any advice is welcome, including if I’m going about the whole thing wrong :slight_smile:

Something you can potentially do is set your game.project file to half the resolution you plan, and then in your GUI nodes and so on set the base scale to 0.5 to half them too (make sure it’s uniform across x,y,z and not only x,y). This is what we do in our games. You’ll likely need to disable mipmaps / use something like this instead of the standard materials Sharp Sprite - RGSS for Defold

Not sure if it’s an issue with the game.project setting or elsewhere.

2 Likes

At that point doesn’t it make sense to just scale all the images down? Seems like carrying the scale factor everywhere is a hassle…

Also seems like I’d need to actually quarter everything rather than half, and then scale back up on higher res devices.

It’s not that bad, I usually organize UI around either a central pivot point (or the corners) that has the scale rather than every individual node. The benefit is it makes the game look generally good no matter the resolution of the device / window view.

What’s the max texture size possible on your device’s graphics card?

GL_MAX_TEXTURE_SIZE = 8192

Just to confirm if I understand correctly - the engine logic does not build in the scaled downed assets, but rather saves the original and then uses appropriate scaling on runtime, so you don’t get
(original image) -> (scaled down 0.25 image) -> (scaled up to fit screen image with loss of quality)
but rather
(original image) -> (scaled to viewport image) ?

I’m not sure I’m quite familiar with Defold enough to understand how this is done. I can kinda see that for general game objects they obey the scaling in the hierarchy, so if I scale and move the collection, everything seems fine, but the GUI and all the objects in the GUI seem to ignore the position and scaling of the parent collection.

If you want your game to use mipmaps and you enable their generation in your texture profiles then when you scale assets that’s when the mipmap versions will be used. That is why I disable them in texture profiles / materials in my games. The Sharp Sprite materials linked before can help make your assets look smoother at lower scales even without mipmaps.

For GOs you can have root nodes which are also scaled and then have other children GOs which inherit the scale. When you spawn GOs with factories or from within collections you can scale them easily.

GUI components do not use the transform of parent GOs, they have their own rendering. You can create organization GUI nodes by adding a 1px transparent pixel to your GUI atlas and then assigning that sprite to a node for which you can use as a pivot / scale parent.

2 Likes