Search Unity

Official 2D Pixel Perfect 5.0 released for Unity 2021.1

Discussion in '2D' started by rustum, May 10, 2021.

  1. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    190
    2D Pixel Perfect 5.0 released for Unity 2021.1

    2D Pixel Perfect.png

    About Pixel Perfect Camera
    The 2D Pixel Perfect package contains the Pixel Perfect Camera component, which ensures your pixel art remains crisp and clear at different resolutions, and stable in motion.

    It is a single component that makes all the calculations Unity needs to scale the viewport with resolution changes, so that you don’t need to do it manually. See the 2D Pixel Perfect documentation here.

    Getting Started
    In an existing project in Unity 2021.1:
    1. Open Package Manager by going to Window > Package Manager
    2. Select Unity Registry in the Packages drop-down menu.
    3. Choose 2D Pixel Perfect 5.0 from the list and click on Install at the bottom right of the Package Manager window. 2D Pixel Perfect Package.png
    Creating a new project in Unity 2021.1 by selecting the 2D Template in Unity Hub will also install 2D Pixel Perfect 5.0 by default.

    Explore the Samples
    2D Pixel Perfect comes with Samples showing the features in action.

    To get the samples:
    1. Open Package Manager by going to Window > Package Manager
    2. Select Unity Registry in the Packages drop-down menu.
    3. Expand the Samples section.
    4. Click the Import button next to the sample you want to import. 2D Pixel Perfect Samples.png

    Important Note:
    As a reminder: While the stand-alone Pixel Perfect Camera component will continue to receive bug fixes, the Pixel Perfect Camera component in the Universal RP is the new home for Pixel Perfect Camera. New features will only be added to the component in Universal RP. Please join the discussion for the 2D Graphics in URP here.

    What can you do?
    Try it out and let us know what you think of the package. We want to know what works as expected and what doesn’t.
     
  2. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    upload_2021-6-28_22-5-35.png

    I am using URP 2DRenderer, and I am getting this warning. Is this mean this package is not working with the URP 2Drenderer? Have I misunderstood something?
     
    dayzex0 and masalootten like this.
  3. Viole

    Viole

    Joined:
    Dec 29, 2015
    Posts:
    38
    Hey,
    Good job on the package so far. One feature I would like to suggest though:
    Pixel Perfect package absolutely needs an option to upscale render texture and still have a smooth camera (that moves in the higher resolution). There's a huge demand for that kind of thing in pixel art gamedev community. Here's a video describing the theory behind it:


    Personally, I would also like to be able to upscale just some layers and not others, but the feature above is far more important. Without it, every upscaled game feels super jittery. In many cases, it makes the upscaling feature unusable.
     
  4. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    Thanks for keeping this going, it's very handy!

    I've not been able to use in a project yet though due to the Canvas resolution missmatch issue, was this ever addressed? I feel it really holds back the asset for 2D games in a production environment using LTS Unity versions. (Unity 2020.3)

    I make 2d pixel art games almost exclusively and I'm still using a custom render texture solution because of this issue.
     
    Last edited: Nov 9, 2021
  5. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    102
    You are right, this is something that is missing from Unity. Let's hope this is something that wil be added.
     
  6. useraccount1

    useraccount1

    Joined:
    Mar 31, 2018
    Posts:
    275
    While the package is great and saves a lot of time, I have noticed some basic use cases that aren't covered by the tool.

    One thing already mentioned is that the tool doesn't support a smooth camera. Another issue I had to fix by myself is the lack of proper support for various screen ratios by default.

    For example, I'm making a game targeted at desktop computers, so in my case, people will play with monitors whose ratios range from 16:10 to 21:9. There are cases when the screen might get wider or thinner, but they are so rare we don't consider them seriously. I think it's worth noting that the steam deck also has a 16:10 screen.

    The tool I have made simply checks the scale of the game's window, then the script takes the Y value of the Reference Resolution (as it is constant in my case), then the script applies the correct X in Reference Resolution. This works perfectly, actually, this is the only solution that works properly in my case. I have tried to do the same by changing values in "Crop Frame" and "Grid snapping", but in my opinion, the results are unacceptable.


    The second feature I have added is the support for zooming in and out by changing Reference Resolution. This is the wrong approach, as how far you can zoom out depends on the game's window resolution (the Reference resolution can't be higher than the game's resolution).

    My point is that it would be nice to have these features by default.
     
    bollowzzz likes this.
  7. juicedup

    juicedup

    Joined:
    Aug 18, 2019
    Posts:
    47
    Is it possible to edit the render texture that the pixel perfect creates when upscale render texture is ticked?
    edit: to add on to this, i'm wondering if other 2D tools will get opened up for the user to customize? such as being able to edit how unity renders shadows
     
    Last edited: Apr 24, 2022
    bollowzzz and Zanthous like this.
  8. Valorware

    Valorware

    Joined:
    Aug 25, 2016
    Posts:
    91
    Agreed with this - the support for different aspect ratios is really poor at the moment. the difference between 16:9 and 16:10 can be huge - with certain reference resolution values - to the point where it's just left to guesswork to find one that *kindof* works, far from "This is the original resolution your Assets are designed for."

    The reference resolution should just take into account Height (for landscape games)
     
    bollowzzz likes this.
  9. Valorware

    Valorware

    Joined:
    Aug 25, 2016
    Posts:
    91
    In particular, this line of code causes a lot of heacahes for varying screen resolutions:

    Code (CSharp):
    1. PixelPerfectCameraInternal.cs
    2.  
    3.             // zoom level (PPU scale)
    4.             int verticalZoom = screenHeight / refResolutionY;
    5.             int horizontalZoom = screenWidth / refResolutionX;
    6.             zoom = Math.Max(1, Math.Min(verticalZoom, horizontalZoom));
    We should have a tickbox to prioritize verticalZoom, so that "zoom" will always end up being 1 or verticalZoom, so we will have much more consistent results across any screen resolutions (for landscape games, portrait should be opposite!)

    The current code is just unhelpful
     
    bollowzzz likes this.
  10. Valorware

    Valorware

    Joined:
    Aug 25, 2016
    Posts:
    91
    Regarding extra layer of zooming, just please expose an extra zoom value for us to use, internally just add it to orthosize- I can't seem to find any reason why not. I added an extra bit of code to do exactly this in a 2020 game and it worked flawlessly. Most usecases would just be a quick little zoom in/out for some juice, so it doesn't have to be absolutely perfect

    At the moment this package is quite unusable for varying screen resolutions. I'm finding it better to avoid this package write a small custom script for similar/better results

    Please take the above into consideration, Unity - it's been in a bit of a poor state for years now!
     
    Last edited: Nov 22, 2023
    bollowzzz likes this.