- Home /
Black lines between tile sprites
I have a tile engine I've built myself. Every tile on the screen is a game object with a SpriteRenderer. I set these renderers with sprites created using Sprite.Create(Texture2D, Rect, Vector2, float), passing a Sprite with all the map tiles as parameter.
It doesn't matter what I do, I keep getting these weird 1px black lines between rows of tiles every now and then. How do I fix this? What's causing it?
Additional info:
When I set the filter mode to Bilinear or Trilinear I get black lines between every row and column of tiles.
The lines I get with Point filtering keep blinking as I move around the map and only stay fixed when the camera is not moving. The ones I get using Bilinear or Trilinear filtering are static, even when I move around, although their width change a little.
Here is my project running on the web player:
I don't know much about sprites and I havent messed with the new 2d stuff at all but any time I have issues with edges I set the wrap mode to clamp in the import settings
I can't choose between clamp and repeat when using Sprite mode for textures. But I've tried to use Texture mode ins$$anonymous$$d and I've tried with both Clamp and Repeat to no success. At least, do the lines appear to you in the web player example I posted?
You are copying the texture from a spritesheet, correct? If so, try having one pixel wide spaces between all sprites on the spritesheet image. This fixed it for me when I had this issue.
I'm not sure but the way it changes everytime you move and you can see horizontal and vertical lines depending on you position makes it look like a z-fighting issue. Is it posible that they are overlapping a bit between them?
Answer by Cleve Blakemore · Mar 19, 2014 at 12:02 PM
You need to create a material, apply one of the default sprite shaders and then click "Snap To Pixel" checkbox. Use this material to render your sprite.
Wow, this literally fixed every issue I had with this problem. Thank you so much!
I've tried so many resolutions, pixel sprite sizes, camera sizes with formula, etc... and this simple material solved every issue for every resolution.
This solution worked perfectly for me. Needs to be easier to find. Took me a while to get to your answer. Thank you!
Have been struggling against this for a while. HUGE help! Thank you!
this DID work for me, but then some lines reappeared when i added light and shadow effects on the sprite, think theres something else i could to to fix this?
Logged in just to upvote this. I have been working on this for over 3 hours. Thanks so much!
Answer by Mijdax · Mar 15, 2016 at 09:09 PM
Turn on Pixel Snap in the Renderer Material of your object and turn of anti aliasing in Edit/Projectsettings/Quality
This one worked for me. I had lines all over the place and adding a pixel snap material fixed most of them, but I still had thin lines on the bottom of an all-alpha sprite. Turning off anti-aliasing fixed it.
Answer by StillLearnin · Dec 31, 2013 at 05:44 PM
I had this same problem and changed the "Pixels to Units" size to a slightly smaller value, caused the line flickering to disappear.
Answer by Romano · Feb 14, 2014 at 06:22 AM
This might explain at least some of the lines: http://answers.unity3d.com/questions/10302/messy-alpha-problem-white-around-edges.html
Answer by nervu0 · Mar 04, 2016 at 08:11 PM
Try marking them as Static so Unity knows that they aren't moving.
Your answer
Follow this Question
Related Questions
Sprites and textures appears black on Samsung Galaxy Grand I9082 0 Answers
tiling texture on multiple planes 1 Answer
Tilemap: Resizing Tiles? 1 Answer
Texture UVs Shift with Camera Movement (ortho) 0 Answers
Sprite texture flickering. 2 Answers