Search Unity

Help fixing a major flaw in Unity2D.

Discussion in '2D' started by CarterG81, May 3, 2014.

  1. Douvantzis


    Mar 21, 2016
    I don't think that the described problem should be considered as a Unity flaw. The engine shouldn't make any guarantee about not seeing artifacts when you render sprites with point-sampling. It's up to you to adjust the scale of the sprite relative to the camera.

    The cause of the problem is that if you don't adjust the orthographic camera's size appropriately, a texture pixel could get rendered in a non integer amount of screen pixels. Thus, producing all the artifacts that you see. You can read a more in-depth explanation of the problem in my blog post.

    I have created a simple free camera script that adjusts the orthographic camera's size so that each texture pixel gets rendered to an integer amount of screen pixels. This will solve all the mentioned problems. You can get it for free from the asset store or check out the HTML5 demo.
  2. CarterG81


    Jul 25, 2013
    Thank you for the article, but that is not the problem we are discussing. The fix for the orthographic correct size has been around for as long as Unity has been around. Long before this thread was ever created. And those problems exist in all engines because that's just the way it is.

    This specific problem (thread) resides with Unity, as other engines (or custom engines) do not have this problem when everything is done correctly.

    Also I believe this bug has been fixed.

    If your solution works perfectly without any issue, it's probably because the bug was fixed. There's plenty of ways to manually cause this problem (and thus it being a problem with the user's code), but that was in ADDITION to the unity bug that also caused sub-pixel errors when it should not.

    Although I don't remember if that actually did or not. Or if future updates fixed it past that.

    I just stuck with that Pixel Perfect, as it would automatically adjust the transform (very tiny decimal-change in position) to fix the issue. It was always perfect with that asset, even though the transform.position would be incredibly odd looking.

    Although I've never taken a look at what Pixel Perfect's code actually does to fix the problem. Or if the problem even still exists. We are quite a ways out from Unity 4.3.4.

    I haven't looked into this problem since, because I am not working on a pixel art project anymore & because that asset solves the problem instantly. I am curious though if others have the same issue even with all the correct settings. With your post, I assume they do not & the problem is now long since resolved.
    Last edited: Jul 14, 2016