Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Virtual resolution -> Window size scaling is a bit wonky

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 1st Nov 2019 06:36 Edited at: 1st Nov 2019 06:39
I have set default min mag filter to zero so it should stay pixely.
I have set the Virtual resolution to half the resolution of the window. Window=768*1024 Resolution=384*512
My pacman sprite scales ok but my ghosty boy sprite goes a bit wonky.

Left=In window Right=png

Attachments

Login to view attachments
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 1st Nov 2019 06:48
are you using the same sprite dimensions for the ghost ?

fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 1st Nov 2019 06:58
Pac is 16x16 (Only 14x14 pixels are coloured)
Ghosty is 16x16 and uses all the pixels

I'm not going to worry about it too much but i would love o know why it's happening
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 1st Nov 2019 07:00
ive had similar issues scaling up like this
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 1st Nov 2019 12:20 Edited at: 1st Nov 2019 12:23
On low resolutions like that, scaling will always mess up at some point.
Imagine a 8x8 tiles chessboard @16x16px. Each tile has 2x2 px. Now lets scale it down 25% so it's 12x12px.
4 tiles on each dimension will have 2px, while the other 4 tiles will have 1px.
It's bound to look wonky. Same goes for upscaling, too.

The higher the resolution, the less noticable the scaling.

If you're scaling full integer factor, like 16x16 to 32x32, it should work, though.


I've never though about this, so correct me if I'm wrong. But right now, it makes sense to me


PSY LABS Games
Coders don't die, they just gosub without return
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 1st Nov 2019 18:19 Edited at: 1st Nov 2019 18:22
Quote: "Left=In window Right=png"

vs
Quote: "Pac is 16x16 (Only 14x14 pixels are coloured)
Ghosty is 16x16 and uses all the pixels"


not following you there. the pac png is (literally) 48x56 while the ghost is 64x64? are you scaling somewhere else, too?

also, are they separate png images? or, are you pulling from a sprite sheet/atlas?

SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 1st Nov 2019 18:43 Edited at: 1st Nov 2019 18:44
Upscaling can cause that kind of quirky interpolation. You'll notice the same effect occurs on your pacman character vertically with the pixel below its tongue. Sometimes, the interpolated stepping has to select which offset to round to, which can pinch or expand a section in either direction. Usually, the best thing you can do is provide dedicated up-sampled versions of the images or just change the pixel layout in the smaller version so that it rounds differently to remove the quirky interpolation.
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 1st Nov 2019 21:01
If you are upscaling by an integer amount (ie 16x16 to 32,32/64,64/128,128) etc then you should get pixel perfect results if you do it right



so every image pixel becomes 2x2 pixels...or 3x3 or 4x4 etc...

Theres a couple of things that might stop that from happening:

- Ensure your sprite dimensions are an integer and are the same as the image dimensions or an integer multiple of the image. Using SetSpriteScale() can be useful

- If your using atlases or subimages then make sure to set your sprite border to zero SetSpriteUVBorder(spr,0) otherwise the 0.5 border makes you loose a pixel that affects the image when scaling

-Ensure that your virtual resolution is the same as your devicewidth & deviceHeight, or an integer multiple of those dimensions
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 1st Nov 2019 21:43 Edited at: 1st Nov 2019 21:45
Attached project

Quote: "not following you there. the pac png is (literally) 48x56 while the ghost is 64x64? are you scaling somewhere else, too?"


I scaled up the image because the board was adding AA to the image.

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Nov 2019 01:27
Anyone have anything else i could try
Qugurun
Valued Member
9
Years of Service
User Offline
Joined: 8th Dec 2014
Playing: AppGameKit
Posted: 6th Nov 2019 02:04 Edited at: 6th Nov 2019 02:19


or



or

https://www.instagram.com/qugurun/

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Nov 2019 03:23
The beauty of setting the virtual resolution is i don't have to worry about all that scaling.
If virtual resolution isn't going to scale the sprite properly, what's the point of using virtual resolution?
Using the second method does not give me a 16x16 grid. Which i need to make a tile based game.
What grid size would you use for your last solution.

Is there something wrong with using 384x512? It is exactly half the window size 768x1024
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 6th Nov 2019 03:32 Edited at: 6th Nov 2019 03:39
Is this a problem only with android or is it a windows problem aswell ?

The only thing I can think of is using another sprite changed with paint proggy
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Nov 2019 03:42
It's windows. Haven't tested mobile.
Have a look at the project i posted.
Qugurun
Valued Member
9
Years of Service
User Offline
Joined: 8th Dec 2014
Playing: AppGameKit
Posted: 6th Nov 2019 03:53
SetWindowSize( 768, 1024, 0 )
GetDeviceWidth() ->750

I just noticed that the command returns an invalid value, or should it be so?
Maybe this is somehow connected?
https://www.instagram.com/qugurun/
Qugurun
Valued Member
9
Years of Service
User Offline
Joined: 8th Dec 2014
Playing: AppGameKit
Posted: 6th Nov 2019 04:08 Edited at: 6th Nov 2019 04:09
Very strange, but apparently it still affects.



https://www.instagram.com/qugurun/

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Nov 2019 04:39
It makes no sense. If i want a pixel perfect render and a grid i could work with i can't see a solution using virtual resolution.
I think this has implications for using the 2D physics where you need to set the virtual resolution small in order to get objects moving fast
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 6th Nov 2019 11:46 Edited at: 6th Nov 2019 11:49
Quote: "It makes no sense. If i want a pixel perfect render and a grid i could work with i can't see a solution using virtual resolution.
I think this has implications for using the 2D physics where you need to set the virtual resolution small in order to get objects moving fast"


It does work properly, the problem is that your setting a window size and assuming that the windows dimensions...(device width and height) are what you set those values to. They arent though...most likely due to the window being too large to actually fit on your screen so agk opens the largest that it can. This is described in the AppGameKit documentation:
Quote: "By default the window size will be adjusted so it always fits on screen, including making room for the taskbar on Windows. This means that your final window size may be slightly smaller than your chosen size. You can override this by setting the allowOverSized parameter to 1, which will remove all bounds checks and allow you to create windows larger than the current screen."


Your window size (device width and height) probably are not what you think they are. (Qugurun spotted that above)

In my post above i said " -Ensure that your virtual resolution is the same as your devicewidth & deviceHeight, or an integer multiple of those dimensions" .... but you haven't done that.

Either allow the window area to oversize or just ensure that your virtual resolution maps to actual integer numbers of pixels....

Try Using: SetVirtualResolution( GetDeviceWidth()/2, GetDeviceHeight()/2 )

That way one virtual pixel maps to 2x2 actual screen pixels.

Ive tried this in Classic and studio and the graphics lines up correctly - no odd scaling - just a simple 2x2 area per sprite pixel.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Nov 2019 19:50 Edited at: 6th Nov 2019 20:19
Ok. I got it. windows height was too big.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-25 15:06:49
Your offset time is: 2024-11-25 15:06:49