Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question Pixel Perfect Camera can't handle uneven sprite sizes?

Discussion in '2D' started by AlexaStar, Jul 13, 2022.

  1. AlexaStar

    AlexaStar

    Joined:
    Dec 28, 2015
    Posts:
    5
    Hi everyone,

    I'm using this and would be thankful for for short help.
    Unity version 2021.1.7f1
    URP: 11.0.0 with Pixel Perfect Camera

    When sprites have an uneven image file size (like 13x21 pixels), then it happens that some of the pixels (see screenshot below, the black outline pixels on top are missing) are "cutted" away. Or they are shifted from one side of the Sprite (top) to the other one (bottom).

    When changing the image file size to an even number of pixels (like 14x22 pixels by adding transparent pixels), this issue effect is gone and all works fine.

    Of course this would be an easy solution but for our art asset pipeline it would be easier if we could allow also uneven sprite pixels.

    Therefore my question is: Does Pixel Perfect Camera demand sprites to have an even number of pixels? Or can I change some settings I'm not aware of? Or is this a bug maybe?

    Thanks for help,
    Alexa
     

    Attached Files:

  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    530
    I personally haven't experienced any issues with pixel perfect camera and sprites with odd number dimensions. But they can cause issues for UI and Canvas stuff if you try to center them, but not as bad as what you observed. Also Pixel perfect camera doesn't like when display dimensions are odd numbers and it displays a warning, but that's for display size not sprite size.

    Can you describe your setup in more details? What exact configuration for pixel perfect camera are you using? It has a couple of different modes and settings which function completely differently. What kind of components are you using drawing the sprites? Is it a SpriteRenderr is it an Image in Canvas, or is it something else? Unity has many different ways for drawing a sprite each with completely different rules and behevior. How are you positioning the sprite? How does the object hierachy looks like?

    Anything else you can tell about your setup? How does the sprite config look like? Are the bounds in sprite editor correct? Are you using any custom shaders?

    Do those sprites look correct if you zoom in Scene panel while the game is running and Game panel shows wrong output?
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,779
    Look closely at where the sprite pivot is placed... if it isn't precisely on the bounds of a pixel, I imagine it might cause issues for you in pickle-perfect mode.

    Viz:
    Screen Shot 2022-07-13 at 11.56.46 AM.png Screen Shot 2022-07-13 at 11.56.57 AM.png
     
    karliss_coldwild likes this.
  4. AlexaStar

    AlexaStar

    Joined:
    Dec 28, 2015
    Posts:
    5
    Thank you both for your quick replies. I need to gather feedback with my developer and get back when we have more facts.