Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Unity 2D Pixel Perfect is out of preview for 2019.3

Discussion in '2D' started by rustum, Jan 30, 2020.

  1. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    110
    2D Pixel Perfect.png
    From 2019.3 onwards the 2D Pixel Perfect package is out of preview and verified. This means that the 2D Pixel Perfect package is stable and will receive regular bug fixes. We will continue to add new functionality and this will be clearly marked as experimental to distinguish it from the more stable features.

    Overview
    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 needed to scale the viewport with resolution changes, removing the hassle from the user.

    You can adjust the definition of the pixel art rendered within the camera viewport through the component settings, as well preview any changes immediately in Game view by using the Run in Edit Mode feature.

    Getting Started
    1. Install latest Unity 2019.3
    2. Open Package Manager by going to Window > Package Manager
    3. Choose 2D Pixel Perfect from the list and click on Install at the bottom right of the Package Manager window. 2D Pixel Perfect in Package Manager.png
     
    Last edited: Jan 30, 2020
    Lars-Steenhoff and APSchmidt like this.
  2. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    430
    This is awesome, been following for the last couple of years and it really is an excellent package. I've been waiting for the possibility of stretching the viewport post-upscale similar to how ScummVM and DOSBox simulate the old 320x200 stretched to 320x240 mode of old vga cards. @yuanxing_cai was working on this part, it was working okay at one point with some modifications, but it broke any UI stretching as all of the raycasts were in the wrong place. Is it possible this will be developed further in future verisons? The modifications were documented here: https://forum.unity.com/threads/pixel-perfect-preview-package.533433/page-4#post-4032814
     
    Lars-Steenhoff likes this.
  3. Ennothan

    Ennothan

    Joined:
    Oct 17, 2013
    Posts:
    49
    I tried it with URP but it isn't compatiple, it says to use the pixel perfect camera from URP (it is still tagged "experimental") and that one doesn't work properly, crop doesn't work, upscaled render texture neither.

    Could you please fix that?
     
  4. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    The 2019.3 verified standalone package is not designed to be compatible with URP. About the one in URP, in which version of URP did you encounter the problems you mentioned?
     
  5. Ennothan

    Ennothan

    Joined:
    Oct 17, 2013
    Posts:
    49
    URP 7.1.8
    With more tests I'm seeing the crop actually works, but don't clear properly beyond the crop. The problem is with Stretch Fill active, when I start play mode it doesn't work, but if I uncheck and recheck the Stretch Fill option it starts working (still not clearing beyond the crop).

    About the Upscale Render Texture I placed high resolution images to test it, and they should be pixelated, but I see no difference. With the main 2D Pixel Perfect package it works.
     
    exzizt likes this.
  6. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    863
    I'm slightly confused. Are there multiple PixelPerfect solutions? Is the one mentioned here only for the default (deprecated?) renderer?
     
  7. desukarhu

    desukarhu

    Joined:
    Jun 14, 2017
    Posts:
    12
    I tried to search the previous thread about ways to zoom the pixel perfect camera in and out but didn't find any conclusive help. Is the case different now? How would I go about zooming the camera? In the previous thread there was a mention of post process zooming, how can I do that?
     
    DungDajHjep and Lars-Steenhoff like this.
  8. Koru

    Koru

    Joined:
    Feb 14, 2012
    Posts:
    40
    Is it possible to anchor a camera's view to a screen's border? Currently, the view is centered but I want to have a portrait screen aspect ratio with camera view on bottom and UI on top. Any advice on how to achieve it without a render texture?
     
  9. mromerogames

    mromerogames

    Joined:
    Feb 25, 2020
    Posts:
    1
    This is awesome!
     
  10. exzizt

    exzizt

    Joined:
    Sep 30, 2017
    Posts:
    78
    Hope this package gets more work!
     
  11. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    There is still only one solution, but we have slightly different implementations for the built-in render pipeline (the standalone Pixel Perfect package) and URP 2D Renderer (built into URP itself).

    And yes, we are talking about the standalone package for the built-in render pipeline here.
     
  12. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    The current recommended way of doing zoom is to use Cinemachine and its Pixel Perfect Extension. https://docs.unity3d.com/Packages/com.unity.cinemachine@2.5/manual/CinemachinePixelPerfect.html
     
  13. thomak-dev

    thomak-dev

    Joined:
    Mar 8, 2015
    Posts:
    16
    Is it possible to make Canvas work properly with URP Pixel Perfect Camera? I tried setting Render Mode to Camera and assigned my Pixel Perfect Camera and tried all the options of the Canvas Scaler but only got poor results. Then I tried the Custom Scaler Script from https://forum.unity.com/threads/canvas-with-pixel-perfect-camera.768377/, the result is slightly better (UI Image with assigned Sprite seems to behave like other sprites) but Text is jittering when I move the camera. I set the mode to Scale With Screen Size and the reference resolution and PPU to the same values that the Pixel Perfect Camera uses.
     
  14. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    So your main issue is jittering text? Anything else?
     
  15. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    430
    Please allow us to disable bilinear on stretch fill, it's ridiculous to have to manually change the file every time we open Unity.
     
  16. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    430
    What is this error caused by? I copied the folder from Package Manager into my assets folder and removed it from package manager:
    Code (CSharp):
    1. Assets\com.unity.2d.pixel-perfect@2.0.4\Tests\Runtime\PixelPerfectCameraTests.cs(7,58): error CS0246: The type or namespace name 'IPixelPerfectCamera' could not be found (are you missing a using directive or an assembly reference?)
    2.  
     
  17. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    430
    @yuanxing_cai Is it still possible to fork PPC from package manager into the /Assets folder? I'm getting the above error, and until bilinear toggle is added, this is my only long-term solution.
     
  18. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    548
    Any chance the URP version could remove the dependency on the 2d renderer? I need to work with the normal 3d renderer.
     
  19. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    You can remove all the files under the Tests folder if you copy the package into your Assets folder.
     
  20. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    Currently only the 2D Renderer has the necessary logic to properly support Pixel Perfect Camera. May I know why you want to use Pixel Perfect Camera with the Forward Renderer?
     
  21. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    430
    The last thread also went into detail when you last asked (https://forum.unity.com/threads/pixel-perfect-preview-package.533433/page-7#post-5165333) about this:
    https://forum.unity.com/threads/pixel-perfect-preview-package.533433/page-7#post-5165954
    https://forum.unity.com/threads/pixel-perfect-preview-package.533433/page-7#post-5166080
    https://forum.unity.com/threads/pixel-perfect-preview-package.533433/page-7#post-5171159
    https://forum.unity.com/threads/pixel-perfect-preview-package.533433/page-7#post-5174294

    PPC is a good, solid solution for getting an accurate retro 3D look (although I think there were solutions on the asset store that were a little more thorough).
     
  22. Cody-Rauh

    Cody-Rauh

    Joined:
    Oct 12, 2013
    Posts:
    252
  23. Valorware

    Valorware

    Joined:
    Aug 25, 2016
    Posts:
    69
    I updated to 2019 today from 2018 preview, and I'm really disappointed to see there is still no easy zooming functionality with this package. I made my own very simple fix in 2018 and I'm really shocked it isn't a standard yet.

    Here's how to introduce a simple fix:
    1) Open PixelPerfectCamera script in Packages\2D Pixel Perfect\Runtime
    2) Add this around line 16:
    Code (CSharp):
    1.      public float extraOrthoZoom { get { return m_ExtraOrthoZoom; } set { m_ExtraOrthoZoom = value;} }
    2.  
    3) Add this around line 139:
    Code (CSharp):
    1. [SerializeField]
    2. private float m_ExtraOrthoZoom = 0f;
    4) Modify the OnPreCull method "m_Camera.orthographicSize = m_Internal.orthoSize" line to:
    Code (CSharp):
    1. m_Camera.orthographicSize = m_Internal.orthoSize + m_ExtraOrthoZoom;
    5) Done! Now all you do is anywhere in your normal code, just set extraOrthoZoom to whatever you want (lerp this value for smooth zooming)
    Code (CSharp):
    1. (mCamera.GetComponent<UnityEngine.U2D.PixelPerfectCamera>()).extraOrthoZoom= 0.15f;

    -----

    Can we please get an official inclusion of this to the PixelPerfectPackage? It's really simple and is an expected standard, and not everyone wants to use Cinemachine. Modifying the package like I said isn't really user friendly and it doesn't work in Unity Cloud Build since it uses the default package.

    Thank you
     
    Last edited: Jun 10, 2020
  24. Valorware

    Valorware

    Joined:
    Aug 25, 2016
    Posts:
    69
    Argh, now it seems everytime I close/reopen Unity those modifications I mentioned in the above post don't get saved (or they are just overwriten by the package default). This didn't happen in 2018

    Is there any way to change this behaviour? This is now a a huge inconvenience for me
     
  25. luiks

    luiks

    Joined:
    Aug 23, 2017
    Posts:
    15
    @yuanxing_cai or @rustum I've been struggling for almost two weeks to have pixel-perfect using cinemachine (and I dont know if it matters, but I am also using corgi engine and tilemap). I have read the manual multiple times, today I just create a new project and just try the demo of corgi engine "retrovania" and did nothing more than build this scene (i didn't change anything). So, as you can see in the videos there is an annoying jittering when I try the build on 1920x1080 resolution. And there is a horizontal line "wave" when the camera moves on 1366x768 resolution. I also try on a 1360x768 monitor, the problems are not so annoying but are still there (btw, I have these 3 laptops resolution coincidently). I kind of solve the 1920x1080 and 1360x768 resolution ticking the Vsync count to "Every V Blank". However, that horizontal line "wave" that you can see in the second video is still there. I only have 3 laptops with those resolutions I mentioned, maybe it also happens in other resolutions. Do you have any solution for this problem?

    Keep in mind that this problem is only visible (at least for me) when you build the scene, in the game window everything looks crispy!



     
  26. luiks

    luiks

    Joined:
    Aug 23, 2017
    Posts:
    15
    @luispedrofonseca I just realize you are the creator of Pro Camera 2D. I was about to buy your asset, but I was wondering if it has the same issues I put before. I´ve asked some indie developer that use your asset and looks that it does not have these issues. However, I was trying to know if your assets have a way to change room (but no one of your videos, but those that for example you enter a house (so you don't see the camera moving but you just appear inside the house, of curse trigger by a bottom). Thanks for your reply.

    PD: It will be wonderful to know also if it have any problems with the corgi engine (that I am using)
     
    Last edited: Jul 19, 2020
  27. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    The horizontal line "wave" definitely looks like screen tearing caused by not having v-sync. Please double check v-sync is indeed turned on for the quality level that you're using and you don't override v-sync settings in your graphics driver.
     
  28. luiks

    luiks

    Joined:
    Aug 23, 2017
    Posts:
    15
    @yuanxing_cai Thanks for the reply. I am not sure I understood what you mean by override ....in my graphics driver (should I set anything outside unity software). Here my quality settings for your feedback:
    upload_2020-7-20_9-8-38.png
     
  29. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    Your quality settings look correct (VSync Count is set to Every V Blank).

    Both nVidia and AMD offer a way (at least on Windows) to override application v-sync settings in their graphics driver control panel. If you force v-sync off in the graphics driver, then whatever you set in Unity doesn't matter, v-sync will always be off in any game. So you should make sure you didn't accidentally do this.
     
    luiks likes this.
  30. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    173
    Hi!

    How do I use the scripting API for this package?

    I'd like to get a reference to a PPC in the scene, then look at the current Pixel Ratio so I can scale UI elements by the same amount.

    I'm struggling to figure out how to access anything from my scripts.
     
  31. Valorware

    Valorware

    Joined:
    Aug 25, 2016
    Posts:
    69
    Hopefully this, based on my post a few posts up:
    (mCameraComponent.GetComponent<UnityEngine.U2D.PixelPerfectCamera>()).pixelRatio

    Although I agree. its hard to use and access. Hope it helps
     
  32. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    173
    Thank you for the help. I did try something like that already, but it doesn't compile:

    The type or namespace name 'PixelPerfectCamera' does not exist in the namespace 'UnityEngine.U2D' (are you missing an assembly reference?)
     
  33. Valorware

    Valorware

    Joined:
    Aug 25, 2016
    Posts:
    69
    Strange, sorry I can't help ~ it's working correctly for me using that namespace :( If you go to your Unity project browser, where your assets are, and look in "Packages", then "2D Pixel perfect->Runetime" then open the "PixelPerfectCamera" script, it should say the namespace at the top, mine says namespace UnityEngine.U2D
     
  34. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    173
    Yup that's exactly what I tried to begin with! ‍♂️ So I copied and pasted the references. The namespace U2D namespace is identified just fine, but the PixelPerfectCamera class is not.

    Maybe @yuanxing_cai can help?
     
  35. unity_OjJ7_qfKWYKiqA

    unity_OjJ7_qfKWYKiqA

    Joined:
    Jul 29, 2019
    Posts:
    6
    Sorry but I am having this problem with the Pixel Perfect Camera when I attach it to my main camera I get one sometimes two errors which makes the game screen grey and unplayable:

    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)


    (The error below this text actually is constanly repeated but this number >481.399658< is different)
    Screen position out of view frustum (screen pos 481.399658, 140.606964) (Camera rect 0 0 512 216)
    UnityEngine.SendMouseEvents:DoSendMouseEvents (int)

    Is there some way I can fix it the errors please?

    Edit: Sorry for the emojis but the way the errors are set up the text turns into emojis.
     
  36. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    430
    @yuanxing_cai if I copy the folder into assets, delete Tests folder and remove the package, it still gives me errors:

    Code (CSharp):
    1. Assets\com.unity.2d.pixel-perfect@3.0.2\Editor\PixelPerfectCameraEditor.cs(7,26): error CS0246: The type or namespace name 'PixelPerfectCamera' could not be found (are you missing a using directive or an assembly reference?)
    2.  
    3. Assets\com.unity.2d.pixel-perfect@3.0.2\Editor\CinemachinePixelPerfectEditor.cs(3,42): error CS0234: The type or namespace name 'CinemachinePixelPerfect' does not exist in the namespace 'UnityEngine.U2D' (are you missing an assembly reference?)
    4.  
    5.  
    I just want to remove the bilinear from stretch fill, I used to be able to, but I can't anymore. If the package was updated to allow this, I wouldn't have to do this.
     
  37. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    430
    Change the PixelPerfectCamera.cs script in
    C:\Users\[username]\AppData\Local\Unity\cache\packages\packages.unity.com\com.unity.2d.pixel-perfect@3.0.2\Runtime

    and it will be persistent.
     
  38. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    The recommended way of modifying the source of a package is to copy the content of the package from the cache to your project's Packages folder, then make changes in the Packages folder.
     
  39. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    430
    Have you read all the others posts I’ve made about this? It doesn’t work, if I copy, it gives errors, no one mentioned any way of resolving those errors so I found a way that worked correctly (until the asset is actually updated to include this universally requested fix).
     
    Valorware likes this.
  40. Valorware

    Valorware

    Joined:
    Aug 25, 2016
    Posts:
    69
    I would also really like an easier way to modify the package too, that works with CLOUD BUILD! (cloud build uses the default package no matter what).

    If it were just imported like a regular AssetStore package that would be perfect, im not sure why it has to install very separate from the project
     
  41. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    You were copying the files to the Assets folder, right? If yes, you should instead use the Packages folder (a sibling of the Asset folder in your file system).
     
  42. Sekhwek

    Sekhwek

    Joined:
    Aug 31, 2020
    Posts:
    1
    Last edited: Sep 6, 2020
  43. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    430
    9 months out of preview and still no bilinear toggle, is there something keeping this from being updated? @yuanxing_cai @rustum
     
    SVC-Games likes this.
  44. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    430
  45. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    330
    We are slow in updating Pixel Perfect Camera due to different priorities, but rest assured this package is not abandoned or anything. As the bilinear filtering option is trivial to add, I'll try to find a bit of time to address it in the coming weeks.
     
    GliderGuy likes this.
  46. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    48
    I want to add an old tv/crt effect to my 2d pixel art game. I bought Retro Look Pro.
    Now this asset has it's own render data for the universal render pipeline. I added that one to my Universal Render Pipeline Asset, my 2D Render Data is also in there, and I created an overlay camera that uses this render data. I then added this overlay camera to my camera that is already in the scene, and which has the pixel perfect camera object attached to it. Now the effect looks great, but this also breaks my pixel perfect camera. As soon as I turn this overlay camera off the pixel perfect camera works fine.
    Now there is a warning in the pixel perfect camera that says it doesn't work properly when stacked, but is there a way to get the pixel perfect camera working and adding an overlay effect on top of it?
     
  47. Arjunpulika

    Arjunpulika

    Joined:
    Nov 15, 2020
    Posts:
    1
    Thanks for this such an excellent post! Keep up!
    cell info
     
    Last edited: Nov 20, 2020
  48. shuskry

    shuskry

    Joined:
    Oct 10, 2015
    Posts:
    314
    Hi !

    I have some problem with pixel since a few day and I don't understand what I'm doing wrong...

    I'm using the last Unity LTS : 2019.4.14f1 with URP 7.5.1 installed.

    -First I created a new Pipeline Asset and 2D renderer, assign the renderer to Pipeline, then assign it to graphic settings.
    -All my spritesheet are set to 32 PPU, ant Point set on Filter mode with compression set to "none"
    -All sprite have a pivot point set with Pixel pivot
    -I set 1/32 in Snap settings for "move", then apply all axis
    -I added the experimental Pixel perfect script to the camera with settings :

    Assets Pixel per Unit :32
    Reference resolution: 320 / 180
    Upscale Render Texture : none
    Pixel Snapping: none

    With all of this, my game is always blurry when the camera move....
    I don't know if I can give more information that can be help :/
    I tried Upgrade my project to newer version of unity, and nothing change ..

    I'm stick with this since too long so if someone can help me i'll really appreciate :D !

    Have a good day ! :)

    EDIT: My bad... Pixel perfect seems to work perfectly, My problem of Blurry seems to be a other problem independent of Pixel Perfect Script
     
    Last edited: Nov 16, 2020
unityunity