Tiles in tilemap have edge issues while game is running, but not in editor

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By zdimaria

I have a tilemap that has edge issues on some of the tiles. I have checked both in gimp and in the editor that the tiles are pixel perfect.

When looking at the tilemap in the editor, there are none of these issues. They only exist while the game is running.

I’ve tried both filter and not filter on the texture flags, filter clip on the sprites and Use Pixel Snap in the project settings, but nothing has helped.

Are there any obvious things that I can check to help figure out what the issue is?

here is an imgur album with screenshots showing my issue:

in the editor, no issues:
in the editor, no issues

in the game grey edges == no good!
in the game grey edges == no good!

in gimp, 32x32 grid
in gimp, 32x32 grid

1x1 grid in editor
1x1 grid in editor

32x32 grid in editor
32x32 grid in editor

32x32 grid in texture region selector
32x32 grid in texture region selector

:bust_in_silhouette: Reply From: Socrates

Have you tried the trick of creating a 1 pixel border around tiles that duplicate the pixel next to it? Assuming your problem is the usual artifact seen in games with tilemaps, this is the best (if most complicated) way to handle it. I believe this tool from libgdx can do it automatically: GitHub - crashinvaders/gdx-texture-packer-gui: A simple way to pack and manage texture atlases for libGDX game framework. , but you might have to fool around with the settings a bit to be able to use the output textures with godot. A simple way to test if it is the usual problem would be to use separate pngs for all the tiles and see if the problem disappears (you can do this in your project too, but it might get a little heavy if you have too many separate tiles).

:bust_in_silhouette: Reply From: rybadour

FYI if you running Godot 3.1 you can solve this by selecting the asset used for the tileset and disable “Filter” and re-import the asset then it removes all the anti-aliasing and fixes the issue.

I have the exact same problem but can’t find how to disable Filter

zhadeOak | 2019-11-17 05:39

FWIW, filtering doesn’t solve it for me. I already had it off and I’m still getting issues with tile edges bleeding at certain camera zoom levels. I’ve made sure that the tile boundaries in the tileset are correct (they are indeed pixel-perfect), there seems to be deeper issues with the UV coordinates or sampling. Would love to have a better solution than adding extra padding to my texture pack.

Adam Gausmann | 2020-05-31 17:37

:bust_in_silhouette: Reply From: Serafij

This could be helpful

Offset and scaling artifacts
When using a single texture for all the tiles, scaling the tileset (or even moving to a non pixel-aligned location) will most likely result in filtering artifacts like so:
enter image description here
…/…/_images/tileset_filter.png This is unavoidable, as it is the way the hardware bilinear filter works. So, to avoid this situation, there are a few workarounds. Try the one that looks better for you:

  • Disable filtering and mipmaps for either the tileset texture or all tile textures if using separate images (see the Importing Images
    asset pipeline tutorial).
  • Enable pixel snap (Set Project > Project Settings > Rendering > Quality > 2d > Use Pixel Snap to true, you can also search for Pixel
    Snap).
  • Viewport Scaling can often help with shrinking the map (see the Viewports tutorial). Simply adding a camera, setting it to Current
    and playing around with it’s Zoom may be a good starting point.
  • You can use a single, separate image for each tile. This will remove all artifacts but can be more cumbersome to implement and is
    less optimized.
:bust_in_silhouette: Reply From: Erfa

I had a very similar issue when having textures tiled like this. I was able to solve it by disabling the “Repeat” flag in the texture import. Hopefully this can help someone else as well.

:bust_in_silhouette: Reply From: rakkarage

In Godot 4 enabled by default:

If true, generates an internal texture with an additional one pixel padding around each tile. Texture padding avoids a common artifact where lines appear between tiles.