- Home /
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.
I have the same problem and have not found a solution. Still looking.
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!
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
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.
Had the same issue with a $$anonymous$$ecraft-like project. There were thin lines visible between blocks. Disabling the Anti-Aliasing solved that issue. Tested with Unity 5.1.2f1.
This solved my issue, thanks! Though the settings are now under Edit ins$$anonymous$$d of File.
Ah, nice. I have updated the answer to reflect your comment.
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).
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.
Hi I have the same problem, exept i need my sprite to be transparent. Here a picture of the problem right there :
Any advice ?
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.
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.