Tilemap has tearing between tiles, even with pixel snap

Hey, I have a problem where my tiles have lines between them when moving around. I have tried pixel snap materials which just changes where and how frequently these occur.

Anyone have a solution to this issue?

You can round the cameraā€™s position to values that are not problematic, so relative offset of each pixel to camera is always the same. This will depend on your pixels per meter, so depending on that you need to find the rounding point at which the inaccuracies donā€™t appear.

This is what Iā€™m doing.

1 Like

Makes sense. Iā€™ll give that a go then! thanks.

In relation to @danbrani reply, here is a related blog post. Unity Blog
Also, packing the tiles into a Sprite Atlas will also help remove the problem during runtime.

5 Likes

So Iā€™ve tried all of these suggestions, but I still have this problem.

Even if my camera is at an integer value (no decimal place), My PPU is 16, and my ortho size is 8, so that should be a clean multiple at 1080p. In fact, no matter what I change the ortho size to the tearing stays. Iā€™m at a loss!

Edit I hadnā€™t done the sprite atlas thing actually, I am not familiar with that. I tried just making a sprite atlas and putting the spritesheet in there and it actually seems to have improved the situation somehow? Iā€™m not certain but it seems that way. Why does putting this in an atlas help?

This is what fixed it for me as well. Itā€™s due to the fact that packing adds ā€œpaddingā€ around each tile.

Spritesheets are traditionally densely packed (i.e. no padding between sprites), but this doesnā€™t translate well to a 3D engine since it works by sampling textures coordinates (0-1), not pixels. The tearing comes from oversampling a tile by a tiny bit (i.e. 0.0001), and into an adjacent tileā€™s content. Padding repeats the border pixels of a tile to ensure the effects of oversampling canā€™t be seen, even though itā€™s still happening.

Itā€™s the same reason we add padding around UV islands in textures.

2 Likes

Dear Johaness, what should be done to solve the problem if I want non pixel-perfect, for example need to zoom in and out!

1 Like

@auroraDev Even with non pixel-perfect you should pack the sprite tiles into an atlas. Reason is as snugsound mentioned above.

I fixed this problem by unchecking the ā€˜Allow MSAAā€™ box in the camera component.

14 Likes

This is a different problem.

Anti aliasing gives you static lines that reposition when you move or zoom out. They appear as solid, black verticals and horizontals.

This camera problem is flickering lines when the camera moves.They appear to all be vertical in my experience.

Any luck solving this issue? Iā€™m seeing the same thing. I got this asset from the store 2D Hand Painted - Town Tileset | 2D Environments | Unity Asset Store

It includes a sample scene that doesnā€™t use the tilemap system, it just has hundreds of sprites manually laid out. I added a test character and follow cam and can move around and it has no issues. I made my own scene with a tilemap and a test map and I get vertical black lines quite frequently. I even copied my tilemap into their test scene so I know itā€™s using same camera etc all the same. Looking at the frame debugger, their multiple sprites cause hundreds of drawcalls but no tearing. The tilemap only has a couple dozen but tears all over the place, it doesnā€™t make any sense to me.

2 Likes

@furroy Iā€™m the creator of that asset. What I did was just using this guide: https://blogs.unity3d.com/2015/06/19/pixel-perfect-2d/
So it should just be a matter of setting up the camera, make sure the sprite asset itself has correct import settings. Another thing (although maybe a stupid suggestion), make sure the game window when you run the game has correct dimensions and is 1x scale. I noticed it started tearing if you didnā€™t have full resolution size in the game window.

The asset was created before the Unity 2D tools, but I donā€™t think that should make a difference.
I hope it was of some help.

3 Likes

Maybe I wasnā€™t clear in my post. I have two towns in the same scene in the same project side by side. Your original town renders flawless and the equivalent one I made in a tilemap gets vertical tears all over. They are using same anti-aliasing settings (none), same orthographic camera etc, so I donā€™t see it is an issue with those things, I think there is something inherently goobered with the tilemap implementation.

Your assets are amazing! Iā€™m making a thing to procedurally generate maps from them and having a lot of fun!

Here is tear even visible in the editor:

@furroy Ah ok, strange for sure. My latest tileset ā€œMinesā€ I did the example level in the Unity tileset tool and it worked perfectly. So maybe there is something is up with the scene itself? Did it work better if you started a new from scratch?

i had some more time to poke at this. my camera is locked to follow the x&y of my character. the tearing is only ever vertical, never horizontal. the funny thing is, it reproduces only when my character (and hence camera) is at an exact integer X value. So it looks fine at 29.9 and 30.1, but camera at 30 shows tearing. This happens for every integer value of X.

I just updated to current unity version, but it looks like the problem i had on my project using mesh plane.
IIRC the fix was to disable anti aliasing Edit ā†’ Project Settings ā†’ Quality

But now that iā€™m using the current version it seems like it no longer does this issue with anti aliasing on.

My question to Unity is;
Does the Tilemap system uses quads/mesh to render texture?

Is current unity version is 2017.4.0f1 ?
Iā€™m having this issue with tilemap / tiles too. Disabling anti aliasing helped a lot, but black lines still appear sometimes when moving.

@vovx
Make sure that the elementsā€™ size in your sprite atlas matches the grid size and/or maybe try Filter Mode: Point (no filter).

I was using unity 2016. Iā€™m new to unity tilemap but the lack of information on what system it uses to render is bothering me, since I also want to make an in-game editor and want to know at least the basics of whatā€™s going on behind the scene.
So I donā€™t have much experience with it and therefor did not encounter that problem using that system.

(current version is 2017.3.1f1)

Iā€™ve done all that and like I said, another map made from same sprites manually laid out in the same scene doesnā€™t have. If it was a projects settings or camera setting, both would have the issue. I had to upgrade to the 2018 beta because tilemaps donā€™t even show up on iphone in 2017.x and still same issue

Turns out it does happen on horizontal as well, finally saw an instance of it.