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 / Tiles bleeding at edges when window is resized

Author
Message
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 8th Feb 2018 12:09
I'm trying to make a tiled game. When the window resolution matches the virtual resolution, everything looks great. When I try to resize the window, adjacent tiles bleed together at the edges. When I try placing a 1 pixel border around the tiles, I get a gap when resizing the window.

In the example below, everything looks fine at first. try resizing the window and lines appear. Replace test.png with testpadded.png and change the SetSpriteAnimation parameters to 129,129 to compensate for the padding. Then you will see a gap when the window is resized.

First screenshot shows what the screen should look like, second is when the window is resized, third is when tiles are padded with 1 pixel

Attachments

Login to view attachments
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 8th Feb 2018 12:34 Edited at: 8th Feb 2018 12:35
This is typically due to mipmapping...turning off mipmapping should solve it, you may actually want the smoothing effect that gives though elsewhere in your app

You can try using SetImageMinFilter() to 0=nearest so the sampler picks a single pixel too.

You can also slightly adjust your tile UV's to compensate for this but that should be a last resort.

You can also render to a renderimage and then scale your render image to your window and that would also solve this issue but id look at the first two options first as this is a bit more technically challenging.
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 8th Feb 2018 13:10
Using SetImageMinFilter() looks good on my PC, but doesn't seem to have an effect on my Android. Can't find anywhere in the docs for turning off Mipmapping.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 8th Feb 2018 13:34
Mipmap generation is controlled with SetGenerateMipmaps(0) right before you load the tile tile textures. You can turn it back on again for other images.


If your using SetImageMinFilter() you should also consider setting SetImageMagFilter() to the same value as it depends on the display device resulution as to whether the texture is getting stretched or compressed when on the screen. Both of these appear to work on the android devices I have tested with.
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 8th Feb 2018 16:15 Edited at: 8th Feb 2018 16:16
It looks a bit like the discussion I've seen about terrains.
https://forum.thegamecreators.com/thread/221265

Perhaps the images should be like that:
"should be a (power of 2) -1"
in effect: 255 x 255?

Or no, actually:
setspriteanimation(sprite,127,127,4)
I do not see the issue anymore using above line.





No need for the other commands also so it seems, if this is the intended end result of course.
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 9th Feb 2018 10:42 Edited at: 9th Feb 2018 11:02
Finally figured out the solution.Using both SetImageMinFilter(ImageID,0) and SetImageMagFilter(ImageID,0), along with SetSpriteUVBorder(SpriteID,0) works. Thanks for the help.
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 10th Feb 2018 08:48
I think I might have found a bug in the Android AGKPlayer. According to the docs, SetSpriteUVBorder defaults to either 0 or 0.5 depending on whether it is used on a full image or sub image. Setting the parameter manually to either 0 or 0.5 fixes my problem with the lines. Leaving it alone so it is set to default causes the lines. This would indicate that the parameter defaults to neither 0 nor 0.5 as the docs would indicate.

Login to post a reply

Server time is: 2024-03-29 06:26:00
Your offset time is: 2024-03-29 06:26:00