• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
8
Question by rastating · Jan 05, 2014 at 04:17 PM · 2dspritetilesalignmentz-fighting

Gaps sometimes appearing between 2D sprites

When the camera is moving, both in game and in the Unity editor, 1 pixel wide gaps between my sprites will appear (see enlarged example below). I've read this is potentially due to z-fighting, and I have tried altering the clipping settings on the camera but the problem still persists.

Can anyone shed some light on why this may be occurring?

Extra info that may be of use:

  • The sprites pictured have been imported using a single sprite sheet which has a texture type of "Sprite" and a sprite mode of "Multiple" and the filter mode is set to "Point".

  • The background that can be seen bleeding through occasionally (the 1 pixel gap) is also imported as a sprite but with a sprite mode of "Single". I have tried with the filter mode set to both "Point" and "Bilinear" but both produce the same problem.

  • When positioning the tiles, I held down the "V" key to make them snap together, I have zoomed in as far as possible and can't see any gap between the tiles when doing this.

alt text

gap.png (3.4 kB)
Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · Jan 05, 2014 at 04:48 PM -1
Share

Nothing at all to do with z-fighting.

avatar image Corbeau · Feb 10, 2014 at 04:48 AM 0
Share

I have the same problem and have not found a solution. Still looking.

avatar image ARN · Mar 11, 2014 at 07:03 PM 0
Share

same problem here... I tried "pixel snap", "point" vs compression, playing with AA, different camera setups, ... to no avail. This really needs some clear answering from someone!

avatar image TrevorP · Mar 11, 2014 at 07:24 PM 0
Share

What are your Pixel To Units field set at on your imported sprites? Are you scaling them in game? I'm thinking it might have something to do with a combination of Pixels To Units and the size of the object on screen. $$anonymous$$ight cause a rounding issue where it's shaving a pixel off the sprite when rendering to the screen in game

14 Replies

· Add your reply
  • Sort: 
avatar image
40

Answer by kvadd · May 21, 2015 at 09:42 AM

I found an answer to this issue that solved it for me, turn off Anti Aliasing in Edit -> Project Settings -> Quality.

It might not be the solution for everyone, but it worked for the issue I had.

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Taza494 · Oct 11, 2015 at 03:56 AM 1
Share

Worked for me, massive thanks!

avatar image Turboloser · Jan 07, 2016 at 06:01 PM 0
Share

Had the same issue with a minecraft-like project. There were thin lines visible between blocks. Disabling the Anti-Aliasing solved that issue. Tested with Unity 5.1.2f1.

avatar image gchandel · Feb 03, 2016 at 07:45 PM 0
Share

Fixed the issue like magic- thank you!

avatar image fadden · Feb 26, 2016 at 07:41 PM 0
Share

See also http://blogs.unity3d.com/2015/06/19/pixel-perfect-2d/ and postings in this forum thread: http://forum.unity3d.com/threads/tile-map-$$anonymous$$ring-problems.225777/#post-1507246 http://forum.unity3d.com/threads/tile-map-$$anonymous$$ring-problems.225777/#post-2375703

avatar image Arangarx · Aug 01, 2016 at 02:30 AM 1
Share

This solved my issue, thanks! Though the settings are now under Edit ins$$anonymous$$d of File.

avatar image kvadd Arangarx · Feb 27, 2018 at 11:40 AM 1
Share

Ah, nice. I have updated the answer to reflect your comment.

Show more comments
avatar image
10

Answer by Corbeau · Mar 14, 2014 at 07:24 PM

We had this same problem in our project (as I posted before) and eventually fixed it by adding a bleed zone of one extra pixel on each side of each sprite on our sheets. Unity will, as mentioned by others, sometimes display one extra pixel beyond the defined zone on the spritesheet. If that pixel is transparent, it will create gaps (or, depending on the spritesheet, cause other undesirable bleed-over from sprites not meant to be adjacent).

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
6

Answer by Chrominance · Mar 12, 2014 at 11:50 PM

This could be happening because your sprite sheet has a transparent background. When the camera moves or zooms in/out some pixels outside of your sprite's region can show up due to inaccuracies.

Change your sprite's texture type to advanced, then you can change the format to RGB 24 bit. Now your sprite sheet no longer has a transparent background.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MikeBaldwin · Mar 12, 2015 at 03:00 AM 0
Share

Excellent! This was exactly it. Thank you sir.

avatar image The-Gabo · Sep 20, 2015 at 01:48 PM 0
Share

Hi I have the same problem, exept i need my sprite to be transparent. Here a picture of the problem right there :

Any advice ?

alt text

sprite-gaps.png (373.8 kB)
avatar image
3

Answer by ARN · Mar 14, 2014 at 03:20 PM

finally fixed a similar issue on my own project. It was down to the camera orthographic size!

here are the steps I followed to solve this: - make sure you are using point filtering - use power of 2 textures - adapt the screen resolution and the camera orthographic size to prevent floating point imprecision (see rocket5 tutorial and related post) which helped me find the right formula.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by bitCulture · Jul 03, 2015 at 07:33 AM

I was using a tiling method to build levels with sprite rendered prefabs. When I created the generic sprite-diffuse material so the light would work, I had turned on the "pixel snap" option (I'm not sure why... seemed like a good idea at the time?) This was causing gaps between all the tiles even when nothing was moving in any way, in fact, it did this even without the lighting effect.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • 3
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

46 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to performantly render 1000s of sprites? 0 Answers

Issue with outline size using sprite tiles 1 Answer

Pixel Perfect 2 Answers

Is there another way of making a Top-Down-2D Map other than generating hundreds of Spriterenderes? 1 Answer

Sprite/ Atlas/ Memory limit in 2D Mobile Games? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges