• 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
9
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
0

Answer by shopguy · Mar 14, 2014 at 11:08 PM

When I had this problem, I had to change the "Filter Mode" of my textures to "Point" instead of the default "Bilinear". I don't really understand it, I know it has something to do with quality though, and I imagine "Point" is similar to "Pixel Perfect" -- which is what you need in this case.

If this is your problem and you care enough to research it, I'm sure there is info on that setting in the docs.

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
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
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
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)
  • ‹
  • 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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

Pixel Perfect 2 Answers

How to performantly render 1000s of sprites? 0 Answers

Make Tiled Sprite expand in all directions 0 Answers

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

Issue with outline size using sprite tiles 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges