Search Unity

Bug Pixel Perfect Camera Distorting Pixel Art Sprites

Discussion in 'General Graphics' started by Xenon27, Feb 22, 2023.

  1. Xenon27

    Xenon27

    Joined:
    Oct 13, 2020
    Posts:
    3
    Using Unity 2021.3.11f1

    While working on a project involving the pixel perfect camera, I've encountered an issue that results in certain sprites becoming distorted, even though these sprites have the same pixels per unit as specified in the camera settings.

    Here is a clear example of what happens:
    View attachment 1201435
    The top or right edge of the sprites are chopped off, and then the bottom or left edge is doubled in length. This appears to happen exclusively to a dimension that is an odd number of pixels.

    My Camera is configured as shown:
    View attachment 1201438
    With the pixel perfect component configured to a 320:180 reference resolution, and 16 pixels per unit. Additionally, it is important I use the upscale render texture, for the sake of non-pixel art assets being properly pixelated.

    My import settings for the sprites are:
    View attachment 1201441

    Worth noting that the issue persists when running the project as a build.

    Also worth noting that a potential workaround I discovered was that changing the scale of the sprite ever so slightly (something like 1.0001 or 0.9999) would often fix the issue. But this doesn't work very well on larger sprites, as even the slight change in scale results in the pixel perfect camera causing distortions elsewhere on the sprite as it tries to maintain the 16 pixels per unit resolution.

    I have been trying for days to figure out what the cause of this issue is or how to solve it, but I have not been able to find anyone else with the same problem or any documentation on it existing at all. If anyone has encountered this issue or has some idea what could fix it, it would be much appreciated.