Lines appear between sprites from sprite sheets

I’m having this strange bug where lines appear between sprites from a sprite sheet:


I encountered a similar issue and found that the cause was the “Anti Aliasing” setting on the Quality Settings for the project. The default for my project was “2x Multi Sampling” for the “Beautiful” and “Fantastic” build settings. Setting this to “Disabled” removed the lines.



Do you create the sprite sheet inside unity? Or do you import a sprite sheet from outside?

The reason for this OpenGL. There are a bunch of ways to fix the issues - one or more of them should fix your problem:

  1. If you build the tile atlas yourself make sure to surround each tile with a 1 pixel border that repeats the tiles outer pixels. Pixels from neighbor tiles might be dragged in otherwise. This is what I would expect is your main issue here. I guess under the tile with the green line is a grass tile inside your atlas.

  2. Texture’s “Filter Mode”: Set it to “Point” - linear or bilinear might drag in pixels from neighbor tiles.

  3. Make sure your coordinates and sizes are all full pixels. Don’t try to draw a tilemap at a pixel position 0.5 - this will create artifacts at the sprite borders - you’ll see the background flashing through. But this is not the case here - the line would be gray not green.

For me, the combination of the answer of @NiceNinja and @CodeAndWeb worked:

  1. Go to Edit > Project Settings > Quality and disable Anti Aliasing for all quality settings
  2. Select all images/sprites/textures in the project explorer and set Filter Mode to Point (no filter)

Only when both were changes, all artifacts at the edges disappeared.

If the textures give you a “Weird line” at the border Go to that texture and go to Advanced:
in Filter mode choose “Point (no filter)”

Hopefully this helps speed up this tedious process:

This is a problem in Unity. I also have this behaviour.

This is floating point precision, it is not Unity-specific, and the solution is usually to add a bleed pixel around the edge of each tile. It isn’t something Unity can itself fix as various filtering rules will blend those pixels anyway, so fixing it for nearest neighbour point sampling won’t have an effect on, say, bilinear filtering.

Add a bleed pixel and offset your tile positions to account for it.