Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Pixel Perfect Camera

Discussion in '2D' started by cgraf1, Feb 3, 2021.

  1. cgraf1

    cgraf1

    Joined:
    Jan 11, 2015
    Posts:
    35
    Hey everyone,

    I am in early stages of making a new game in Unity that will be using pixel art. I want to make sure to get the early setup correct to save me from having to fix resolution and other issues later.

    I did some research for setting up sprites and using the Pixel Perfect Camera. Basically, you are supposed to make the Pixels Per Unit on each sprite the same and then that same number for the Pixels Per Unit on the Pixel Perfect Camera. This creates a consistent unit grid within your game, but also limits your sprites.

    So I am wondering, is this the only way to properly make a pixel art game in Unity? Is there a way to use pixel art properly but have a wide variety of sprite sizes?
     
  2. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    you can do like stardew valley which doesnt use pixel perfect
     
  3. cgraf1

    cgraf1

    Joined:
    Jan 11, 2015
    Posts:
    35
    Well it is certainly good to know what Stardew Valley looks as good as it does without Pixel Perfect tricks. So, is there any other specific setup to that or is it just the same stuff you would normally do to make your 2D game look as good as possible?
     
  4. adehm

    adehm

    Joined:
    May 3, 2017
    Posts:
    369
    I like to use 1 ppu as it makes more sense to me but don't believe it has any effect on the visuals in any way. Visually you need to lock an aspect ratio and don't use filters or compression.
     
    cgraf1 likes this.
  5. lincore

    lincore

    Joined:
    Dec 9, 2013
    Posts:
    3
    I don't quite understand what you find limiting about constant ppu. Unless you have a good (artistic) reason to violate that rule, mixing artwork with different pixel densities just doesn't look good, in my opinion.

    I'm in a similar position right now although I haven't really put that much thought into it until I read your question. From the little experience I have, there seem to be roughly three options:
    1. Pixel Perfect Camera with reference resolution and frame cropping. Looks crisp, but only scales to multiples of the reference resolution.
    2. Same as above but with stretch fill. Occupies as much space as possible while maintaining aspect ratio. Depending on the resolution this looks somewhat blurry.
    3. Same as 1, but don't crop the image. I think this is probably the best solution, but comes with the drawback that the pixel-perfect component cannot handle odd-numbered resolutions.
    See also: https://blogs.unity3d.com/2019/03/1...up-your-unity-project-for-retro-8-bits-games/
     
    Last edited: Feb 5, 2021
    cgraf1 likes this.
  6. cgraf1

    cgraf1

    Joined:
    Jan 11, 2015
    Posts:
    35
    I mistakenly thought that setting up the PPU on the sprite and Pixel Perfect camera to something like 32 meant that I could not have a sprite much larger than that, like 120x80 for example.

    I now see that doing this just means that actually sets up a consistent unit grid, but does not limit sprites from being larger than this one unit. Thanks very much for helping me realize this
     
    lincore likes this.
  7. lincore

    lincore

    Joined:
    Dec 9, 2013
    Posts:
    3
    Ah, now I understand your confusion. Yes, you can have sprites of arbitrary size, the pixels per unit only determines how many pixels fit into one unit, unless you scale the sprite, of course. :)