[Help] Techniques for scaling

General discussion about LÖVE, Lua, game development, puns, and unicorns.
RNavega
Party member
Posts: 270
Joined: Sun Aug 16, 2020 1:28 pm

Re: [Help] Techniques for scaling

Post by RNavega »

Getting back to the issue of tearing, which I imagine it's these weird lines in your 1440_810.mov video:

_.png
_.png (216.7 KiB) Viewed 336 times

Have you tried a very slow zooming out effect instead of randomly walking around? I think this would let you find an exact zoom level that makes the problem appear, so you can write it down and keep using it until you debug this problem.

About the green grass tiles, are they part of a larger "tileset" (a larger image with many tiles)? If so, this would make it a texture sampling issue, where the rounded texture coordinates end up sampling the regions at the border of the tile and the rest of the image (like empty background).
You can test this by changing the image background to red, magenta, yellow or anything easily identifiable, and seeing if the lines change to that color.
The solution to this is to pad your tiles with a 1 or 2 pixel border. I know you said you wanted to avoid this, but it's the cost of using texture atlasing.

Others have had the same problem: https://forum.unity.com/threads/tilemap ... ap.499154/
RNavega
Party member
Posts: 270
Joined: Sun Aug 16, 2020 1:28 pm

Re: [Help] Techniques for scaling

Post by RNavega »

* To clarify on what this safety padding should be.

There's no easier way than importing your PNG texture into Photopea, have a transparent background, then go to Filter > 3D > Texture Dilation and drag the slider until you're satisfied.
Then File > Export As > PNG to download the result.
No account needed, they have ads.
_.png
_.png (52.74 KiB) Viewed 334 times
glass2d
Prole
Posts: 14
Joined: Thu Apr 18, 2024 11:40 pm

Re: [Help] Techniques for scaling

Post by glass2d »

pgimeno wrote: Sat May 11, 2024 6:56 am
glass2d wrote: Sat May 11, 2024 2:29 am When you say it "works for you" did you add this with no other rounding (Such as the player's physics body)
That's right. The character seems to jitter due to rounding problems and animation problems, but these are unrelated to the movement.
Interesting, so I should also deal with the rounding and animation problems. Conceptually, do you know what could be the underlying cause of the rounding and animation issues?
glass2d
Prole
Posts: 14
Joined: Thu Apr 18, 2024 11:40 pm

Re: [Help] Techniques for scaling

Post by glass2d »

RNavega wrote: Sat May 11, 2024 6:58 am Getting back to the issue of tearing, which I imagine it's these weird lines in your 1440_810.mov video:


_.png


Have you tried a very slow zooming out effect instead of randomly walking around? I think this would let you find an exact zoom level that makes the problem appear, so you can write it down and keep using it until you debug this problem.

About the green grass tiles, are they part of a larger "tileset" (a larger image with many tiles)? If so, this would make it a texture sampling issue, where the rounded texture coordinates end up sampling the regions at the border of the tile and the rest of the image (like empty background).
You can test this by changing the image background to red, magenta, yellow or anything easily identifiable, and seeing if the lines change to that color.
The solution to this is to pad your tiles with a 1 or 2 pixel border. I know you said you wanted to avoid this, but it's the cost of using texture atlasing.

Others have had the same problem: https://forum.unity.com/threads/tilemap ... ap.499154/
Awesome, this is very helpful. The tiles are part of a larger tileset. I'll take your advice and troubleshoot in the way you described. I'm happy to pad the tiles if after troubleshooting I find that padding is the issue.
User avatar
pgimeno
Party member
Posts: 3581
Joined: Sun Oct 18, 2015 2:58 pm

Re: [Help] Techniques for scaling

Post by pgimeno »

glass2d wrote: Sat May 11, 2024 3:41 pm Interesting, so I should also deal with the rounding and animation problems. Conceptually, do you know what could be the underlying cause of the rounding and animation issues?
I don't know the cause of the animation issues because I haven't looked into how you animate; I just saw the animation to change in a somewhat unpredictable way.

As for the rounding problems, they are inherent to having a non-integer scale. With nearest neighbour filtering, some pixel rows/columns are going to be narrower than others, there's just no way around that. Since the image's coordinates change, the narrower rows/columns change position, producing visual jitter.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests