Search Unity

Unity Pixel Perfect Preview Package

Discussion in '2D Experimental Preview' started by rustum, May 28, 2018.

  1. exzizt

    exzizt

    Joined:
    Sep 30, 2017
    Posts:
    66
  2. VPellen

    VPellen

    Joined:
    Mar 15, 2018
    Posts:
    2
    No clue, sorry. I imagine you'd only need to do it once for each project. You could probably just save a copy of the modified file to your assets folder and use that one directly?
     
  3. exzizt

    exzizt

    Joined:
    Sep 30, 2017
    Posts:
    66
    It won't work. Can't find references to PixelPerfectCameraInternal or IPixelPerfectCamera even after including the using statements.
     
  4. exzizt

    exzizt

    Joined:
    Sep 30, 2017
    Posts:
    66
  5. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    This is fixed for 2019.3 (Universal RP v7.7.1). You can keep track of its progress using the Issue Tracker link.
     
  6. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,357
    I would love a bug fix release for pixel perfect at some point for the classic render pipeline.

    I'm not in a position to switch to URP yet
     
  7. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    157
    Thanks for the update! :)

    Is that the same issue as the one I posted a little while back, here: https://forum.unity.com/threads/pixel-perfect-preview-package.533433/page-6#post-4818494 ?

    Also, do you know if there's a rough ETA for 2019.3 release? I'm waiting on another major fix in that version too.
     
  8. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    They should be the same issue.

    The beta of 19.3 has already begun, so you can grab a 19.3 beta version now. The final release will happen in November.
     
  9. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    157
    Great, thank you for the info.
     
  10. SVC-Games

    SVC-Games

    Joined:
    May 21, 2013
    Posts:
    112
    Currently I'm using 2D Pixel Perfect package (preview 1.0.1) and works with classic renderer. I know that using LWRP/Universal there's the new 2D Renderer which includes 2D Pixel Perfect but that's not a solution to us since we use 3D cameras.

    We've seen in the roadmap that 2019.3 includes 2D Pixel Perfect as Verified Package. The question: Is it talking about the preview package 1.0.1 that we are currently using and works with the classic renderer (and is separate of the 2D Renderer)? Or is it talking about the 2D Renderer with Pixel Perfect built-in?
     
  11. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    The package that is verified for 2019.3 is the standalone 2D Pixel Perfect package. You will be able to upgrade v1.0.1 preview to the latest version (v2.0.2) once 19.3 releases.
     
  12. SVC-Games

    SVC-Games

    Joined:
    May 21, 2013
    Posts:
    112
    Oh, awesome then! We were worried that focus would be on the 2D renderer, which would be a loss since the standalone package works with 3D for that PSX/Saturn era 3D look. Is there a change log available? Just curiosity, we can wait for the release :)
     
    Lars-Steenhoff likes this.
  13. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    I'd really like to know more about your use case of using Pixel Perfect Camera for retro 3D graphics, as this component is never intended for 3D content.
    Although we bumped the major version number, there aren't a lot of changes from v1.0.1. The only noteworthy one is we improved the compatibility with Cinemachine by providing you with a new CM Virtual Camera extension.
     
  14. SVC-Games

    SVC-Games

    Joined:
    May 21, 2013
    Posts:
    112
    Actually, it's pretty straight forward. Just using the 2D Pixel Perfect Package:
    - New scene
    - Add a cube and rotate it to have some sides in an angle
    - Add Pixel Perfect Camera to Main Camera (we are using a Unity 3D project with built-in renderer) with this settings:
    upload_2019-11-12_11-26-46.png
    - Disable antialiasing in Quality settings
    - Run the scene

    When using sprites they will snap to the pixels and when using 3D elements they are renderer at that reference resolution. I'll send you some examples to your private inbox.

    We have noticed that Pixel Perfect Camera generates 368 B of garbage everyframe when running, created by GUIUtility.BeginGUI() as shown here:
    upload_2019-11-12_11-29-54.png
    If the Pixel Perfect Camera component is disabled, that GCAlloc disappear.

    Also, when using LWRP the "Upscale render texture" option apparently doesn't work, showing 3D models in their full non-aliased glory (that's one of the reasons we are using the default renderer, the other being stacking multiple cameras)
     
    Last edited: Nov 12, 2019
    SugoiDev and Lars-Steenhoff like this.
  15. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,357
    Last edited: Nov 12, 2019
    yuanxing_cai, SugoiDev and SVC-Games like this.
  16. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    287
    Lars-Steenhoff likes this.
  17. zapposh

    zapposh

    Joined:
    Nov 12, 2016
    Posts:
    77
    It gets even much worse when you use the Pixel Perfect component from the URP or LWRP package with a 2D render setup.
    Even without a single light source in the scene or illumination, , disabling all lights/shadows in the URP render pipeline, and without any usage of the sprite lit material, it adds a whole bunch of GC to the pixel perfect generated GC.

    Which makes you wonder if this is a sustainable path to take in production.
     
  18. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    What makes you not just use a low-res render texture with the camera? What other features do you need from Pixel Perfect other than automatically upscaling the low-res RT?
    In the latest version this GC alloc only shows up in the Editor and development build, not in the release build.
    We tested all the existing features when we ported Pixel Perfect Camera to Universal RP. I need to know your specific camera setup. Do you use multiple cameras? Camera stacking in URP is currently WIP, so you should soon be able to achieve you've done with built-in pipeline.
     
    Lars-Steenhoff likes this.
  19. SVC-Games

    SVC-Games

    Joined:
    May 21, 2013
    Posts:
    112
    Pixel snapping which works perfectly with Non-filtered sprites and can be overriden with polygons and filtered sprites. That way we can have pixel perfect and crisp sprites when needed, but also smooth polygon movement and some smooth scaling effects and rotations when using some sprites.

    I was suspecting that it was an editor only issue, thanks for clarifying.

    I'm attaching at the end of this post a sample project using Unity 2019.2.10f1 and the latest version of LWRP (6.9.2 according to Package Manager) and the 1.0.1 preview of 2D Pixel Perfect (Library folder have been removed to reduce size). Open "SampleScene" and you will find the camera settings as follows:

    upload_2019-11-14_12-23-1.png

    Just hit run in Unity Editor and the cube will appear crisp and without aliasing, as if the Pixel Perfect Camera wasn't used at all, as seen here:

    upload_2019-11-14_12-16-24.png

    But, without stopping the execution of the scene, go to Project Settings -> Graphics and remove the LWRP Asset from the "Scriptable Render Pipeline Settings" field so the Default renderer is used, and the cube will instantly change to this:

    upload_2019-11-14_12-18-45.png

    Don't mind the pink color, that's because the material is for LWRP, but notice how when LWRP is disabled the pixel perfect upscaling is applied, with jagged borders on the cube corresponding to the resolution set in the Pixel Perfect Camera component.
     

    Attached Files:

    Last edited: Nov 14, 2019
    Lars-Steenhoff likes this.
  20. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,357
    second one looks more what you expect in pixel art games
     
  21. SVC-Games

    SVC-Games

    Joined:
    May 21, 2013
    Posts:
    112
    That's the point. In the second one, once LWRP is disabled the cube is rendered using the default Unity renderer and thus the Upscale Render Texture option works correctly. With LWRP it doesn't work
     
    Lars-Steenhoff likes this.
  22. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    We should've done a better job communicating this, but let me try again :)

    The standalone Pixel Perfect package (shows up in Package Manager as "2D Pixel Perfect") does not work with Scriptable Render Pipelines (Lightweight/Universal included). We will make it a verified package for 2019.3 and continue supporting it with bug fixes for projects that don't/can't use SRP.

    Lightweight RP (re-branded to Universal RP in 19.3) features an experimental 2D Renderer in addition to the default Forward Renderer. This 2D Renderer is our answer to pixel perfect rendering in the SRP world. If you have Lightweight/Universal RP installed, you will see a new Pixel Perfect Camera (Experimental) in the Add Component menu. This is the component you should use with Lightweight/Universal RP. It's confusing because it has exactly the same icon and UI with the one in the standalone package. You also need to setup the 2D Renderer in the Render Pipeline Asset for the experimental Pixel Perfect Camera to work. See the doc for detailed steps.

    I hope this helps clear up the confusion a bit. Going forward we'll improve the docs/communications, and also add warning messages to the UI when you are using the wrong component.
     
  23. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,357
    Will the experimental 2D Renderer support camera stacking?

    So I can have a 3d background with a pixel perfect foreground?
     
    SVC-Games likes this.
  24. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    498
    +1 for supporting Pixel Perfect for 3D. I recently tried to update a project to URP and 2019.3, but I was unable to get the new 2D Pixel Perfect to work with the Forward Renderer. Interestly enough, 3D objects can be rendered with the 2D Renderer(and work with Pixel Perfect), but only show up unlit.
     
    SVC-Games likes this.
  25. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    Camera stacking is WIP for both the 2D Renderer and the Forward Renderer.
     
    SugoiDev and Lars-Steenhoff like this.
  26. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    Mixed 2D/3D content is something we want to properly support in the future. We'd like to know more about the use cases so we can take an approach that works well enough for everybody.
     
    SugoiDev and Lars-Steenhoff like this.
  27. digiwombat

    digiwombat

    Joined:
    Sep 26, 2013
    Posts:
    12
    I don't think I've seen anyone address this after reading through the thread and a few others trying to search it up, but I'd very much like access to the PixelCameraInternal zoom number. Or, far preferably, have the ability to set a minimum zoom level in the PixelPerfect camera. When my camera changes aspect ratio (landscape to portrait), I do not want to change pixel ratios along with it.

    A bit of FOV difference across platforms and resolutions and resizeable windows is fine, but a player suddenly zoomed way out and able to see beyond the bounds of my map isn't what I'm looking for. Black bars on the sides are very much not the look I'm going for either.

    Currently, I've got it handled via changing the hardcoded line 77 in PixelPerfectCameraInternal.cs from:

    Code (CSharp):
    1. zoom = Math.Max(1, Math.Min(verticalZoom, horizontalZoom));
    to

    Code (CSharp):
    1. zoom = Math.Max(3, Math.Min(verticalZoom, horizontalZoom));
    but obviously that's not gravy forever.

    Anyway! If I've missed something somewhere, please let me know so I can use the preferred method, but I didn't see it come up. Thanks for the camera, though! I really like how much it simplifies the pain all the old solutions.
     
    CrowbarSka and SugoiDev like this.
  28. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    We can definitely expose the minimum zoom level instead of fixing it to 1.
     
  29. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    9
    Hello! Quick question - if I do not check 'stretch fill' in the Pixel Perfect Camera there's a border around the camera in a build. I'd like to be able to change the color of that border as it's defaulting to an uncomplimentary grey color - how would I go about doing this? Is there something I can edit/add in the script that'll clear to a color of my choice?
     
  30. Coffein

    Coffein

    Joined:
    Jan 22, 2016
    Posts:
    19
    How would we go and implement a split-screen with the PixelPerfect camera? My initial thought would be to adapt the viewport rect of the cameras but it is overwritten by OnBeginCameraRendering..
     
  31. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    Are you using the 2D Renderer in URP or the standalone Pixel Perfect Camera?
     
  32. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    339
    Hi, I'm learning all the cool new Unity 2D features, so I installed the Lightweight RP package and added 2D lights to my game.

    The problem is that the Pixel Perfect Camera script does not seem to work anymore.

    Any help?
     
  33. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    9
    I'm using the 2D Renderer in the URP, getting risky with the experimental new features for that sweet 2D lighting! I think the grey colour I'm seeing in the build is the last frame of the 'Made With Unity' splash screen, as the pixel perfect camera is not clearing the whole render area, just the bit it's restricted to.

    I guess what I need to do is pop a Canvas behind the final rendered camera output somehow? Is there a way to do that?
     
  34. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    9
    Sorry, this turns out to have been a really dumb question. I've set up another camera with a lower rendering priority at -1000xyz etc that clears to whatever color I want.
     
  35. Notxius

    Notxius

    Joined:
    Jan 4, 2020
    Posts:
    1
    I cannot find this package in the package manager (it's not on the list of all packages)
    both in Version 2018.4 and 2019.2

    ....any help?
     
  36. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    339
    Hi,

    There is a drop-down button called Advanced in the Package Manager. Make sure you have chosen the Show Preview Packages.
     
  37. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    9
    I'd really love an option to select between point filtering and bilinear filtering when upscaling the rendertexture is selected. Potentially even an option to use a shader to do the rescaling - see Sonic Mania's options to do point, bilinear, and then two CRT-style soft and hard shaders.

    Also just to check - does re-scaling try and conform to the aspect ratio of your target resolution, or does it stretch both horizontally and vertically as far as it can to fill the screen?
     
  38. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    You'll have to use the Pixel Perfect Camera component from Universal (Lightweight) RP. You should also uninstall the standalone Pixel Perfect package as it won't work with any SRP.
     
    Nadan likes this.
  39. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    239
    It will keep the aspect ratio.