Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Unity 2017.2 beta is now available for download.
    Dismiss Notice

Tile Map Tearing Problems

Discussion in '2D' started by mactinite77, Jan 31, 2014.

  1. mactinite77

    mactinite77

    Joined:
    Feb 14, 2012
    Posts:
    24
    Okay, first off I've been looking into this issue since the 2D tools surfaced for unity hoping these problems would have been rectified, but here we are. So the problem is this:

    $TileTearing.jpg

    As you can see I have a pretty noticeable line going in between my tiles. Also I have highlighted the Position of the camera, as you can see it is in integers (no floating point trickery here ;) ). I round the position I send the camera to an int. The tiles themselves are set up as 1 pixel to 1 unit. I have tried this in a multitude of numbers all producing the same effect. It also may be of use to note that my tiles are tiled in integers as well (0,16,32, etc).

    Aside from buying something like 2D toolkit, or subtracting the pixels to unit by one thousandth, is there any other way to solve my problem?
    Is anyone else encountering this issue no matter what kind of "magic" they use?
     
  2. Jorus

    Jorus

    Joined:
    Jan 21, 2013
    Posts:
    3
    Hiya,

    How are you laying the tiles out, if you are using an index of 0,16,etc try going from 0-15,16-31 etc.

    Cheers

    Craig
     
  3. mactinite77

    mactinite77

    Joined:
    Feb 14, 2012
    Posts:
    24
    Hi,
    I'm currently laying out the tiles using the built in unity tools. Each tile is 16x16 with each pixel equal to 1 unit. Thus a difference of 16 units is needed for perfect layout between the tiles. However this is a moot point as I just made this quick mock up to illustrate a point. I've been dealing with this problem in various applications, I have even used a 3rd party tool to layout the tiles and I still get the gaps. I've had some hints as it being a problem with floating points so I eliminated that from the equation entirely, but still does not give me the desired effect.

    I'm looking for the possibility of eliminating this without overlapping the tiles. Any ideas?

    Thanks,
    Hunter
     
  4. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,387
    You have your game view in free aspect... if your screen is 320 game units wide with your numbers you would expect 320 pixels... but if its in free aspect and your window is 400 pixels wide (for example) then each "pixel" of your image has to span 1.25 on screen pixels.

    Set a fixed resolution in which game units will map perfectly to pixels. If you really want to support any resolution (not just common multiple like 640, 960, etc) then you will need to add a script to change the camera settings to ensure the view always maps directly to a number of pixels (or set up your tiles to bleed).

    EDIT: I should add you also need to take in to account camera position. If you translate your camera you will need to make sure you quantise the movement to ensure alignment between pixels and world space.
     
    Last edited: Feb 1, 2014
  5. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    I'm using SpriteTile, and this seems to be a common problem no matter what plugin, texture type, or any setting you use.

    It just seems to be a problem in Unity, period.

    I fixed it in SpriteTile, by using tiles that are actually pixels larger than they're suppose to be. So while the tiles are 40x40, the texture is 42x42.

    The tiles still end up being 40x40, and all that is ever visible is 40x40. Yet whenever these stupid lines occur thanks to Unity's problematic 2D rendering, the extra pixels compensate and show up as they're suppose to because the edges are the exact same pixel as the adjacent pixel.

    A lot of the 2D problems that people have in Unity is not because of their settings, but because of Unity being a 3D engine with less-than-perfect 2D functionality. The engine just isn't coded correctly to compensate for a lot of 2D problems with which pixels should be drawn at what coordinates. Not that you can't fix this in your game in many different ways, but that it is not the fault of the user, it is the fault of the engine.

    SpriteTile fixes this for me because even though tiles are the size you want them to be, you're allowed to have a Tile's sprite be larger than the tile, but the overlap is correct so the tiles display as they should (only 40x40 pixels ever displayed, as the extra 2x2 is always covered up by the next tile.) I also use trillinear filtering for one of my steps because even though it should be Point, it simply refuses to display correctly for the most part.


    IMO, this (and nearly identical issues) is the worst and most problematic quirk in Unity, and if they care for 2D functionality, it should certainly be the first thing they fix in their next 2D-based update. This can even occur in pixel-perfect rendering with integer (rather than float) camera positioning. It's just silly, and the only reason I do not berate the devs for it is because Unity is a 3D engine, and was never intended to be a 2D one until recently. So they have time, IMO, to justify problems like this taking time to fix.
     
    Last edited: Feb 1, 2014
  6. mactinite77

    mactinite77

    Joined:
    Feb 14, 2012
    Posts:
    24
    Johnny, thank you very much for the reply I see what you're saying, but doesn't Unity change the camera viewport based on the window rect? It shouldn't be changing my pixels aspect ratio, or even attempting to right? Just adds a bit on each side in my experience. I also tend to have this problem no matter what the window size is unfortunately. Now I see you talk about tile bleeding, and that seems to be what I'm going to have to use to keep it as simple as it should be.

    Carter, Thank you for replying, I use SpriteTile as well, it is definitely a promising tool! It's looking more and more like I'll have to use your same method of tile bleeding. So far all the solutions I've come across seem very "hacky" and just don't feel right to my programmer instincts.
     
  7. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    This is exactly how I felt, you couldn't have described it better.
    And as a programmer who usually fixes stuff like this myself, I really don't like all the tearing/bleeding. If it were my engine, I would not allow this to happen, especially if other people were using it. It would probably be the highest priority to fix.

    I don't think I have the problem anymore though. Except with textures which don't have the overlap, in only some resolutions.

    edit: Seems as though one of my problems wasn't this, but that one of my tiles wasn't in a POT2 texture. Even though my tiles are 40x40, I import them in as 64x64 images with transparency around them.

    You can see that problem here http://forum.unity3d.com/threads/210497-Pixel-perfect-2d-in-4-3?p=1487216#post1487216
     
    Last edited: Feb 1, 2014
  8. Jorus

    Jorus

    Joined:
    Jan 21, 2013
    Posts:
    3
    Hi Hunter,

    I have create a basic 2d tile map using prefabs to load the tiles as game objects. I know this may not be the best method for fps but it does work for the items i am doing right now.

    All I do is place the tiles at 0.16f apart using the following formula to set the position;
    float x = ((xTiles/2)-xTile) * 0.16f;
    float y = ((yTiles/2)-yTile) * 0.16f;

    What is see is each tile being place at the correct position; however there is a small line with default settings on the sprite;
    $DefaultSprite.png

    If I change the Filter Mode on the Sprite to "Point" I get the correct pixel version of the tile.
    $DefaultSprite_withPoint.png

    Cheers

    Craig
     
  9. quarag

    quarag

    Joined:
    Nov 3, 2013
    Posts:
    16
  10. mactinite77

    mactinite77

    Joined:
    Feb 14, 2012
    Posts:
    24
    Hi Craig, thanks for the advice, unfortunately I use point filtering and it still is a problem for me. I will have to extrude my tiles a bit like previously mentioned.

    Quarag, I have seen that topic before and I used the "solution" he used and it did not work for me. I mentioned that in my original post. Thank you though.
     
  11. Kondor0

    Kondor0

    Joined:
    Feb 20, 2010
    Posts:
    508
    Point filtering solved the problem for me so thanks for the advice (I'm using UniTile and non power of 2 textures btw).
     
  12. mactinite77

    mactinite77

    Joined:
    Feb 14, 2012
    Posts:
    24
    Does UniTile work with the sprites in unity 4.3? or is it textured quads?

    Thanks.
     
  13. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    "I changed pixelToUnit value (now 1 unit is equal to 1 pixel). It almost completely eliminated the problem. Additionally I round the camera position to int values (Mathf.RoundToInt) in each frame. "

    That is interesting. I'd test that to see what the actual problem is, as that kindof hints at what it might be. Well, along with all the other solutions to the problem which seem to count in the hundreds. But IMO that is Unity's responsibility not mine.
    This problem has been around a long, long, looooooong time. I remember it back in version 1.6 dealing with that one (and only) 2D plugin.

    Honestly surprised this is still an extremely common problem. Or a problem at all.

    Really, one should be able to simply do the exact math and have it blit correctly. Not sure why it changes the math to blit the pixels oddly, resulting in the spacing inbetween what otherwise is perfect math. Even more perplexing is why Unity has no documentation acknowledging this problem, nor a fix despite how old the problem is.
     
    Last edited: Feb 3, 2014
  14. mactinite77

    mactinite77

    Joined:
    Feb 14, 2012
    Posts:
    24
    I did try this as one of my last attempts at rectifying this issue, the screenshot you see above is with his solution in place. I guess I should mention when in the scene view I don't see any type of tearing whatsoever, but as soon as I hit the play button I may or may not get tearing and if I start moving I will almost definitely see tearing right away.

    It's an interesting conundrum that I wish would handle itself as every solution I've tried seems counter-intuitive and not the "Unity Way", For all the amazing things Unity does right this is not one of them, unfortunately.

    Interesting little bit: Hearthstone, which seems to be developed in Unity, has this problem in their buttons. They use some sort of 9-slicing on the GUI and I regularly see tears on the buttons when I play.
     
  15. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    Wow, that is horrible for Hearthstone.

    I don't see how Unity doesn't see this as one of the major flaws in their engine, and something that should have top priority in fixing.

    Nothing kills immersion than obvious lines slicing through all the pretty graphics.
    To have this as a problem since the creation of Unity from v1.0 to 4.3, is just horrific. How can they sleep at night? lol, I'm serious.

    It is sad that the only thing that seems to work as a definite solution is extrusion. That is the only way I can resolve the issue as well. All other solutions seem to only solve it *sometimes*, or only in *some* resolutions, or only *some* camera angles.
     
  16. mactinite77

    mactinite77

    Joined:
    Feb 14, 2012
    Posts:
    24
    Maybe we'll see a solution to this along with native tile map support and 2D nav mesh generation. lol

    Jokes aside, I would like to see a fix to this in this cycle. That would be great.
     
  17. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    I figure I would organize all of the well known solutions in a single post, for people who need reference.

    The Solutions

    1) Extrusion. This seems to be the only solution that will resolve the problem universally. Other solutions seem to be iffy on whether or not they solve the problem or simply help to mend it. To extrude, have your tile be 1 pixel larger than it is suppose to be. So if you have a 40x40 tile, make it 41x41. The extra pixel can simply be identical to the adjacent pixel. TexturePacker has an option to "Extrude". I'm sure Photoshop can do it easily as well. This actually doesn't solve the problem of the 1pixel spacing between tiles. What this does, is that when the spacing does occur it is covered up by the extra 1x1 extrusion pixels, filling in the spacing but it will look fully natural.



    Other Possible Fixes

    2.) Power of Two textures. If your texture is NPOT (Not Power of Two) then Unity will butcher it. For example, even if your tile is 40x40, make sure the actual image you import is 64x64. The tile should remain the same size but have extra transparency around it.

    3.) Integer Camera Transform.Position. Instead of allowing the Camera to be moved using floats (1.4, 1.5, 1.6) have it move in whole numbers (1.0, 2.0, 3.0).

    4.) PixelToUnit Size of 1, so that 1 Pixel equates to 1 Unit.

    5.) Even Numbered Screen Resolution. I have heard people on the forums state that when the resolution ends in an odd number (ex. 555x555), to make sure it ends in even numbers. (ex. 556x556 or 554x554).

    6.) Point Filtering. Trillinear Filtering. Sometimes changing the filtering will fix the problem. Often changing it to POINT fixes an issue, but I have had it happen before where I had to change it to Trillinear- even though that makes absolutely no sense.

    7.) Don't Change Resolutions. This is a very bad fix, and not much of one. However, you can probably use one of the fixes above to make sure it works without problem in a specific resolution. Then in another resolution, check to make sure the problem is gone. This is a bad solution because it will require you to change everything based on what resolution is chosen by the user.

    Edit: 8) Pixel Snap
     
    Last edited: Aug 31, 2014
    Salyangoz, Hexusio, malkere and 3 others like this.
  18. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    The issue has been around since...well, probably the beginning.

    I would certainly not expect it to ever be fixed, honestly. If they didn't care about it back then, why would they care about it now? As odd as that is, it doesn't seem important in any way. Very strange, but Unity has been around for a few years and not a single mention of the problem in updates.
    There were plenty of posts about the problem back then just like there is today.
     
    Last edited: Feb 3, 2014
  19. mactinite77

    mactinite77

    Joined:
    Feb 14, 2012
    Posts:
    24
    The only reason I could see them fixing it now is because they have official 2D support and it is relatively brand-spanking-new. The only reason I see them not fixing it is because they are trying to be the all around good for everything engine. As of right now if I was going to make a 2D tile-based game I wouldn't use Unity's 2D offerings as they are still very much in their infancy and still very much "beta".
     
  20. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    That is a really good point, it is much like a "beta" as a 2D engine.

    I can definitely see them fixing it because you're right, the 2D functionality is pretty much brand new.
    Thank you for the practical optimism.

    Let's hear; Cheers towards them fixing it. We can definitely hope.
     
  21. Squabbler

    Squabbler

    Joined:
    Jan 11, 2013
    Posts:
    11
    I tried so long to find a solution to this, including doing everything posted above. HOWEVER, this DID finally work for me:
    1. Create a New Material in your Project Folder
    2. Click on the Material
    3. Change the Shader to "Sprites/Default"
    4. Drag the atlas or spritesheet you are having trouble with into the texture box
    5. Click "Pixel Snap"
    6. Apply this material to your individual sprites
     
    MD_Reptile and rakkarage like this.
  22. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    6,820

    Thanks for wrapping up all of these solutions in one post! This is still an issue as of today.
     
    CarterG81 likes this.
  23. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    I updated my all in one post to include pixel snap.
     
  24. ErnestoBananez

    ErnestoBananez

    Joined:
    Sep 23, 2014
    Posts:
    15
    Carter, Thank you SO much for this! I kept having problems with this for ages, and it's good to know it's just a flaw of Unity's and not some weird thing I'm doing wrong :/ at least now I understand what I have to do to 'fix' it.
     
    Last edited: Mar 26, 2015
    CarterG81 likes this.
  25. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    This really is something that needs to be fixed if Unity ever wants to support proper working 2D tile based games. The fact that these "hacks" are necessary makes is very difficult or time consuming to work with 2D tile based games.
     
    CarterG81 likes this.
  26. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    If you don't find this thread, then oh man- even MORE difficult & time consuming.

    Enough to abandon Unity quickly enough, or at least sour users towards it.
     
  27. ErnestoBananez

    ErnestoBananez

    Joined:
    Sep 23, 2014
    Posts:
    15
    I made a ticket about this problem. They sent me an email saying, quote: "We have fixed this and problem will not appear in the next major version." So... I guess let's all just look forward to 5.1.
     
    CarterG81 likes this.
  28. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    That's great! Ever since 4.6, they've been trying to crush these painfully obvious, unacceptable bugs. Not sure if these threads helped, but I really think they put the pressure on them. Shortly after I've posted about various 2D issues, by coincidence I'm sure, they've released fixes the next update. Good stuff. Unfortunately, some of the fixes are literally 5 years too late.

    Just to be fair though, I finally found a professionally made non-Unity game that had this problem in it.

    Bethesda's Fallout 3 had some serious hitching problems. I'm not sure if it's the same problem, but it appeared to be the same. Framerate would be perfectly high, but there would be this skipping. It was so bad and IMO unacceptable for such a successful company to produce such a S*** engine/product. Unfortunately, they never fixed it. Thankfully, modders put it in their hands and fixed the problem entirely themselves. Kind of pathetic that other people have to mod your engine to get it to render correctly. I also had to use Riva Statistics Server to cap fps at 60 (no other method worked) in Skyrim to get rid of this awful problem (I forgot what it was. Not related to this issue).

    Some game companies have flawless engines straight from the get go. (at least for this basic stuff, anyway. proper rendering is...you know...kindof a huge feature for a video game engine.) Others struggle even years after release. Console ports seem to be pretty awful culprits (*cough Bethseda cough*) It's quite sad.
     
    Last edited: Mar 30, 2015
    GarBenjamin likes this.
  29. Ivanskodje

    Ivanskodje

    Joined:
    Mar 29, 2015
    Posts:
    57
    Sweet!
    I thought I had fixed this problem in my project - however it quickly re-appeared after I added more overlapping textures and whatnot :(

    I have managed to remove it all together by not using tiles wherever possible (2D Game) :S
    Looking forward to the next version!
     
    CarterG81 likes this.
  30. Camsedin

    Camsedin

    Joined:
    Feb 15, 2014
    Posts:
    16
    i tried everything but could only fix this by using single sprites instead of sprite sheets.
    better than nothing i guess. lol
     
    Ivanskodje likes this.
  31. Ivanskodje

    Ivanskodje

    Joined:
    Mar 29, 2015
    Posts:
    57
    I've managed to fix this issue by avoiding creating any tiles in the Unity engine.

    I currently use a free 2D map creation software called "Tiled" with another tool called "Tiled2Unity" that makes it a dream! There are other softwares (29.95$ I believe) such as "SpriteTile" that also works - but it was missing a few features I really wanted that Tiled has :)

    The only sprites/textures I now place in Unity are entities, doors, and special items with scripts in it.
     
    GarBenjamin likes this.
  32. Camsedin

    Camsedin

    Joined:
    Feb 15, 2014
    Posts:
    16
    Ive fixed it now. just used TexturePacker by codeandweb and gave everything +2 padding and +1 extrude that sorted it out fine.
     
  33. Ivanskodje

    Ivanskodje

    Joined:
    Mar 29, 2015
    Posts:
    57
  34. Camsedin

    Camsedin

    Joined:
    Feb 15, 2014
    Posts:
    16
  35. Ivanskodje

    Ivanskodje

    Joined:
    Mar 29, 2015
    Posts:
    57
  36. K.L.R.G.

    K.L.R.G.

    Joined:
    May 22, 2015
    Posts:
    1
    Hi!
    I had the same problem with a tilebased battlemap and read through different forums, tested around for days and wanted to drop the whole thing, but I found a solution I haven't heard of in any other thread about that topic ... (Or maybe I'm just blind and stupid ...)

    But anyway: Go to Edit -> Project Settings -> QualitySettings and Disable "Anti Aliasing"!!!

    I tested around in multiple resolutions and the problem in my case was simply gone ...

    Atleast when you are only working with sprites this should solve the problem for most people I hope?
     
  37. TruffelsAndOranges

    TruffelsAndOranges

    Joined:
    Nov 9, 2014
    Posts:
    92
    AA is defo a problem but disabling AA does not solve the problem at all.

    The only solution I've found, as discussed earlier, is extrusion. You have to manually extrude every sprite in an external program because the built-in extrusion in the "Advanced" tab does not seem to work per sprite for sprite atlases. If I extrude my sprites, in say Photoshop, I do not get this problem!
     
  38. fadden

    fadden

    Joined:
    Feb 11, 2015
    Posts:
    13
    Just ran into this today, using some very simple rectangular tiles for walls of a maze. So long as I use point sampling and set the orthographic camera size such that the screen height is a multiple of the sprite pixels-per-unit, and use integral values for camera position, there are no gaps. I want to be able to zoom in and out, though, and as soon as I do that I get flickering gaps between the tiles.

    If I use a custom material with "pixel snap" (documentation for which seems scarce), I don't get the border gaps while zooming, but I do get artifacts around the sprites when changing the camera size (e.g. a straight horizontal edge gets bumped out a pixel for half its length).

    Using information from this other post, I changed the import for my sprite sheet from Sprite to Advanced, and set Sprite Mode to Multiple with Filter Mode set to Point. I found that the edge gaps disappeared, but I got the odd pixel snap artifacts when Mesh Type was set to Tight. Changing it to Full Rect fixed the issue. I currently have Extrude Edges set to zero, and it's still working fine. I do need the "pixel snap" material though; without it I get a different sort of artifact while zooming (in both the scene view and the game window).

    FWIW, Unity did a blog post back in June 2015 that includes many of the ideas listed in this thread.

    Using Unity 5.1.3f1.

    Update: now using Unity 5.3.2f1. I was going out of my mind for a bit because of nasty artifacts when I switched resolutions in the Unity editor. The trick turned out to be resizing the "game" window so that "Using resolution NxM" had even numbers (as mentioned in an earlier post). Also, don't use "maximize on play" with a resolution larger than the screen, as that can also lead to odd-sized resolutions and artifacts.

    While fiddling with this I briefly played with adding padding around the textures, but that wasn't useful -- cloning pixels at the edges seems necessary. The extrusion setting in the sprite importer didn't seem to have any effect. I still see no difference when fiddling with anti-aliasing, though that appears to be the most common solution. I hate using undocumented "magic" features like Pixel Snap, because I'm worried it'll break on random devices, but there isn't much choice.
     
    Last edited: Feb 26, 2016
  39. kdamica

    kdamica

    Joined:
    Aug 22, 2013
    Posts:
    1
    Using Unity 5.3.1f1, disabling AA worked for me!
     
  40. Fariel

    Fariel

    Joined:
    Feb 9, 2013
    Posts:
    22
    Necroing the crap out of this post to say that disabling AA worked for me as well, and that I would highly suggest Unity disables AA for 2D projects by default so users don't have to deal with this in the future.

    *Edit:Using power of two textures placed at powers of two with pixel snap on the material as well. None of that solved it. Disabling AA with these circumstances did.
     
    CarterG81 likes this.
  41. stuckwiththisname

    stuckwiththisname

    Joined:
    Nov 19, 2013
    Posts:
    8
    I render my map by creating a mesh at runtime. I used to have tiny holes between my tiles and I thought it was floating point errors or bleeding from the adjacent tiles in the atlas. But it turned out to be holes that were not being rendered. I almost ripped into my code (again) to try to fix this, but then I found this post.

    AA did it for me. I was using the correct orthographic size for my camera, power-of-2-sized textures with Point filtering. Pixel snap had no effect.

    This is what my problem looked like. I used to get around this by snapping my camera to my pixel grid, but that lead to weird visual disturbances when I started dithering some textures.

    [​IMG]
     
  42. mezzostatic

    mezzostatic

    Joined:
    Aug 18, 2016
    Posts:
    10
    If you send mesh objects with different positions to the graphics card, unity's precision is not high enough and the actual vertex positions in the graphics cards, the seams, will not be the same. hence you will see seams inside the graphics card. the further you go from origin, the bigger the rounding error will be.

    If you put all your cubes on 0,0,0 and instead change their vertex positions to the positions you want, and send them all to the graphics card, they will not contain seams. they will have identical object position and identical seam positions sent to the graphics card even after unity changes them.

    AFAIK i solved the issue after some time and puzzling, perhaps waster 50 hours to solve it, becaues i was told that my problem was inside the game engine not the graphics card.

    So... keep all cubes on zero zero zero, edit their vertex positions, rewrite all the vertices to the new positions you want the cubes to be in, otherwise the seam positions in the graphics card differ microscopically.

    Its a weird error inside Unity that no one else than me knows about because i am a lame coder who never managed to code a game but i am basically a genious:) iT WOULD HAVE HELPED ME TO FINISH A GAME IF UNITY TOLD US ABOUT THIS ERROR IN THE FORUMS!!!! NOT ME HAVING TO DETECTIVE IT!!!!
     
    CarterG81 likes this.
  43. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    Wow. It seems as if Unity's floating point precision strikes again.

    So is the solution to this the same as the solution for a lot of problems in Unity?

    The Farnsworth Solution?

    "I understand how the engines work now. It came to me in a dream. The engines don't move the ship at all. The ship stays where it is and the engines move the universe around it."
    --Cubert J. Farnsworth

    [​IMG]

    Very interesting!
     
  44. kerelolivier

    kerelolivier

    Joined:
    Aug 27, 2015
    Posts:
    1
    I found A fix. The problem is the orthographic size of the camera. To calculate the correct orthographic size use the following formula. Orthographic size = ((Vert Resolution)/(PPUScale * PPU)) * 0.5
    PPU = pixels per unit
    PPUscale = the scale of the

    Source:
    https://blogs.unity3d.com/2015/06/19/pixel-perfect-2d/
     
  45. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,594
    This is a very old / well known answer. However, it is rarely the only thing people need.
     
  46. Abelius

    Abelius

    Joined:
    Nov 11, 2016
    Posts:
    9
    Sorry for necroing this, but this could be useful for other people.

    After some experimentation, the simplest thing that worked for me was to set 'Wrap Mode' to 'Clamp', in the image import settings.

    The other action that certainly helped was to disable AntiAliasing, but horrible jagged edges showed up in my backgrounds, which IMHO it's aesthetically unacceptable for me.

    I'm using Unity 5.5.3f1, btw.
     
    Joccish likes this.
  47. Joccish

    Joccish

    Joined:
    Mar 18, 2015
    Posts:
    1
    Can provide an alternative solution that worked for me:

    Changing the sprite compression settings to High Quality.

    Magically removed all the gaps on my tiles.

    Unity 5.5.0f3
     
  48. Nkoeppel

    Nkoeppel

    Joined:
    Oct 28, 2016
    Posts:
    81
    I generally don't want my sprites compressed, my solution, assuming you have a camera that moves, is mostly to make sure my camera is never in between pixels, I move a parent object to my camera normally but have the camera itself snap to the nearest pixel. In addition setting wrap mode to clamp helps as well as setting your sprite material to pixel snap. There are some other techniques as well and you should always follow the pixel perfect ortho camera size rule where "Orthographic size = ((Vert Resolution)/(PPUScale * PPU)) * 0.5"