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

Question Pixel Perfect Camera Crop Border Content

Discussion in '2D' started by rypl, Dec 30, 2020.

  1. rypl

    rypl

    Joined:
    Oct 21, 2020
    Posts:
    1
    Using the pixel perfect camera with the cropped frame boxes ticked, how do you fill, or, preferably, keep empty, the space in the cropped out border area?

    I noticed when transitioning from a scene with an uncropped camera to one with cropping, the area around the active area was filled by the edges of the render from the previous scene, like so:


    (the uncropped camera area stops at the grey/dirt edge, with the cloudy sky being left over from the previous screen)

    When running on mobile, the results were far more distracting, as what was in the edges was for some reason moving with the rest of the scene:


    (happens in landscape too, but portrait makes it much more apparent)

    For the transition case I tried manually calling GL clear on scene load (both depth and color buffer), but it didn't seem to make a difference. I'm not sure what else to try, all I really want is for the border area to be black or some other solid color, anything more interesting or dynamic would be a bonus.

    I did a lot of searching but couldn't find a solution if this has been asked before, struggled with the wording so maybe I missed it..? Thanks for any help in advance.
     
  2. galactichyperstar

    galactichyperstar

    Joined:
    Jun 4, 2018
    Posts:
    11
    BUMPING! I'm having the exact same problem.
     
  3. B4ttleCat

    B4ttleCat

    Joined:
    Mar 31, 2014
    Posts:
    18
    I've just run into an issue where in my builds—regardless of platform—aren't being cropped as per the Pixel Perfect Camera component settings. I'm using the URP and have tried both versions of the Pixel Perfect Camera component. The one labelled "experimental" behaves oddly and is definitely not cropping with black bars.

    WARNING: strobing in clip below



    Would love to figure this out for the end of my game jam in 48 hours.

    (Unity 2020.2.1f1 on macOS Big Sur 11.1)
     
    Last edited: Jan 22, 2021
    RedHillbilly likes this.
  4. GiantBoar

    GiantBoar

    Joined:
    Mar 27, 2021
    Posts:
    2
    Having the exact same issue for the past few months now. Wrote a pretty detailed bit of code so that the reference texture is exactly the ratio of the game window, but would still like to know if there is a way to clear the entire frame buffer or something.
     
  5. RedHillbilly

    RedHillbilly

    Joined:
    Mar 24, 2014
    Posts:
    39
    Same here, this showed up when the package moved to URP.
     
  6. FlyingFeesh

    FlyingFeesh

    Joined:
    Jul 17, 2022
    Posts:
    1
    That border area is undefined so calling those graphics functions won't affect them. Easy fix for this is to have a second camera under your main one with a black background. That way the border area will be drawn black.
     
  7. JoyousFrog

    JoyousFrog

    Joined:
    Apr 24, 2021
    Posts:
    1
    The black bars do not go away, as far as I can tell it is not possible to layer cameras while using the pixel perfect camera. Is there anything more to this solution that you haven't described?