Unity Tilemap White Line Issue

Published September 04, 2019
Advertisement

One of the issues we ran into is this fairly well documented Unity Tilemap white line issue. When you have a tilemap in unity, with really a large repeating area you''ll usually end up with a pretty glaring issue coming from the tilemap. You'll notice long, weirdly colored lines appearing vertically (as I've seen it) on your tilemap.

tileset_spacing_error.thumb.PNG.aab8287a0632cc6939b10fed3b32a030.PNG

According to what I've been able to tell this comes from your camera not snapping to a whole number pixel count, which seems to be the issue in my case. My camera follows the character in a pretty slow way, approaching the character quickly than slowing down the closer it gets. There's basically two solutions that I've found to fix this issue and they're both pretty straight forward.

The first fix is the fastest, and usually works, you simply find your container grid for your tilemap and give the cell gap a bit of a negative offset, in this case -.01:

image.png.01baab952cc02552fb09355e928f77fc.png

This is the fastest way to solve this problem, but I've noticed that it doesn't always work. If the above solution isn't working you're going to need to get dirty and add a 1px padding to all of your tilesets that show this problem. Since it would be a massive effort to redo all of your tilesets, I'd recommend finding the offending tile and testing if something like this works. Take the tile that's causing the issue, and surround it with copies of itself like so:

image.png.baeb1440d875f57e6912ce6fcd2d6703.png

Simply apply that center tile to the whole map you're trying to test and you'll be able to tell if this is the issue and dedicate more of your time to getting each one of your offending tiles that 1px buffer. In my case, there needed to be BOTH of these solutions in order for the tilemap to look correct. Overall this is going to be one of those problems that you poke and prod at until you find something that works for you, just make sure you run around your map and make that camera move in weird directions to see if you can get your issue to reproduce!

 

0 likes 1 comments

Comments

Antonsem

There is actually a better solution. Just create a new material, set it to Sprites/Default, and toggle on the "Pixel snap" option. Use this material for the tile map and you should be good to go :)

 

image.png.eeeb202e89e4cf883677ad26fc3bebee.png

September 04, 2019 11:07 AM
Whistling Alpaca Studios
On 9/4/2019 at 7:07 AM, Antonsem said:

There is actually a better solution. Just create a new material, set it to Sprites/Default, and toggle on the "Pixel snap" option. Use this material for the tile map and you should be good to go :)

 

image.png.eeeb202e89e4cf883677ad26fc3bebee.png

Antonsem,

This solution didn't end up working for me. The Anti-Aliasing solution you see all over the web when you search for this issue reduced the occurrence by quite a bit, then the pixel snap reduced it some more (to almost nothing). Then I swapped over to the LWRP material pipeline and never really got the pixel-perfect camera working (yet).

Our current workflow has simplified this down REALLY well though, since it's an RPG top-down style game we're able to just create a single tilesheet that has all our ground tiles, then we add a 2px boarder to all sides of the ground tiles. Since we have significantly fewer ground tiles than anything else, this process is very low effort.

Sidenote: The LWRP 2D lights are really fun/easy to work with.

September 06, 2019 07:37 PM
Antonsem
On 9/6/2019 at 9:37 PM, Whistling Alpaca Games said:

Sidenote: The LWRP 2D lights are really fun/easy to work with.

Yeah, the only thing that is missig is the shadow support. Otherwise it is great :)

image.png

September 09, 2019 09:05 AM
Whistling Alpaca Studios

I know this isn't a new article, but if you're using LWRP and looking for some pixel snap, consider using the pixel perfect camera component, it seems to solve some white-line issues:

https://blogs.unity3d.com/2019/08/02/2d-pixel-perfect-how-to-set-up-your-unity-project-for-retro-16-bit-games/

January 01, 2020 09:27 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement