Tilemap seams and tearing (fix that works for me)

I noticed a few days ago that my background tilemaps had seams and were flickering when the player was moving in front of them. People who have experienced this know what I’m talking about; I don’t know how to describe this problem best for the others, sorry.

I searched the web for a solution and found a thread on gamedev or stack overflow, I don’t remember, saying “deselect “generate mip maps” in your sprites”. I checked, they were already deselected. Okay.

I kept searching and found an answer saying “use 2D Pixel Perfect”. I installed 2D Pixel Perfect and tried it but things didn’t improve.

Out of despair, I checked my sprites again. My tilemaps use materials so that they can react to lighting (I don’t use the brand new 2D lighting feature.) These materials have normal and specular maps. Taking a closer look, I noticed that the normal maps had “generate mip maps” selected. I decided that generating mip maps in the sprites was worth a shot. So I did, and my problem is solved!

Never been so happy in my life (well, maybe not). Bye bye seams and tearing!!! :slight_smile:

Just wanted to share this with you, in hope it would help.

The tilemaps that were problematic, the background walls:

1 Like

@

There are several reasons for “seams” in Tilemaps. I’m not too technical so sorry for some inaccuracies.

Unity is a 3D engine, and Tilemap is created from a 3D mesh, and a tile is created from a face consisting of 2 triangles. You can see this with shaded wireframe Scene view mode. This quad is mapped with UV coordinates that are used to render the textures to tiles, so the same rules apply as to any GPU rendered textured meshes.

Pixel padding - you will have to have enough pixel padding around your tile texture. Especially if you are going to use mipmaps. See tutorials on this topic. How much texture bleeding is evident also depends on how different the neighbor pixels of edge pixels are in source texture. You can find many discussions, here is one example:
http://wiki.polycount.com/wiki/Edge_padding

Sampling - Also, I don’t think we have any control over how close to edge of edge pixels tile’s face edges are placed and how texture coordinates are sampled, there might be some inaccuracy that causes texture bleeding. See articles like this one:
https://gamedev.stackexchange.com/questions/46963/how-to-avoid-texture-bleeding-in-a-texture-atlas

Mipmaps - this texturing / sampling technique reduces size of a texture in distant / glancing angle faces. So you’ll have to have padding, if you want to avoid moire effects in textures but don’t want texture bleeding (but you will get some bleeding with further mipmaps most likely).

Anti-alias - is like trying to smooth a scratched surface, no matter what you do, you are applying a post effect to
image, that depending on contrast between neighboring tiles might help or not, but it is not correcting the underlying issue - AFAIK.

Camera movement - AFAIK pixel perfect camera can make a difference, as camera can be set to move pixel by pixel. Especially if you see gaps between tiles.

Texture sheets / packed textures or nowadays “atlas” textures - same rules apply:
http://wiki.polycount.com/wiki/Texture_atlas
https://tiled2unity.readthedocs.io/en/latest/fixing-seams/

All of these things apply to all textures applied to tiles, not just to color texture.

3 Likes

@eses Good to know, thanks!