Search Unity

Cinemachine fighting with Pixel Perfect Camera

Discussion in 'Cinemachine' started by Egg0, Nov 10, 2019.

  1. Egg0

    Egg0

    Joined:
    Jul 31, 2019
    Posts:
    4
    With pixel perfect and cinemachine both installed in my project, it seems to work ok when I press Run In Edit Mode but the zoom level of my cinemachine virtual cameras are overrided by pixel perfect when pressing the Run button. I added the Cinemachine Pixel Perfect extension to the cameras and it didn't seem to fix anything.

    Is it possible to make cinemachine control camera zoom while still using pixel perfect?

    Versions: Unity 2019.3.0b10, Cinemachine 2.3.4, 2D Pixel Perfect 2.0.2
     
  2. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    The Cinemachine Pixel Perfect extension will try to correct the ortho size from the active vcam so that you can still get a pixel perfect image, the corrected size is close to the original but it's not the exact ortho size you type into the inspector of the vcams.
     
  3. Egg0

    Egg0

    Joined:
    Jul 31, 2019
    Posts:
    4
    Ok, so is there a way to properly transition between two camera zooms when using pixel perfect through cinemachine or is the only way to adjust the Pixels per unit on the Pixel Perfect Camera? I'm using two cameras of pretty different size but it never seems to update. For reference: I want to smoothly transition between this zoom:
    upload_2019-11-17_14-51-16.png
    And this one:
    upload_2019-11-17_15-2-57.png

    It would be ok if it's not pixel perfect in the middle, as long as the start and end are pixel perfect.
     
  4. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    This is not recommended because you'll have to carefully manage the PPU value (keep it a multiple of the asset PPU).
    This is exactly how the Cinemachine Pixel Perfect Extension works. Each vcam will have its own pixel perfect ortho size, but when in transition between two vcams, you temporarily the pixel perfectness.
     
  5. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    You can send me a repro project if you wish. That way we can help you identify what's going on.
     
  6. Egg0

    Egg0

    Joined:
    Jul 31, 2019
    Posts:
    4
    Sorry for the late reply, yeah I can send a sample project that has the problem I was talking about! I have a gameobject called Cams that has the main camera with the pixel perfect attached to it, along with the cinemachine brain and two extra cinemachine vcams. When the pixel perfect is on and I change the priority of the two vcams (zoomed in and out) nothing seems to change, so maybe you'd be able to help figure out what's going on?

    Thank you, I appreciate it! I just uploaded the project as a zip to google drive.

    https://drive.google.com/file/d/1qZ0PT48JE2_lLUQCTfLa95HK8H8b95KO/view?usp=sharing
     
  7. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    Hi! Thanks for sharing your project! There are a few issues here.

    1. We recently moved the CM Pixel Perfect extension to the Cinemachine package itself. This requires you to replace the extension in your project with the one in the latest CM v2.4.0 preview.

    2. You have Universal RP installed and yet you're not actually using it. This confuses the extension about which version of the Pixel Perfect Camera to support (the standalone package version or the URP version).

    3. This test project actually helped me uncover a bug with the Pixel Perfect Camera. The problem is the CM extension only works when the Update Method of your CinemachineBrain is Late Update (you're using Smart Update). I'll get this fixed in the next version of the Pixel Perfect Camera.
     
  8. Egg0

    Egg0

    Joined:
    Jul 31, 2019
    Posts:
    4
    Ok thanks for checking on that! How do you think I should proceed then, Should I remove URP from the project and change it to use Late Update?
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Yes, remove URP if you're not using it.
    Changing to LateUpdate should correct your issue.
     
  10. luiks

    luiks

    Joined:
    Aug 23, 2017
    Posts:
    15
    Hi,
    Hi, what if I want to use the new light 2D system (i.e. URP) and I also want to use: Cinemachi and pixel perfect camera, when I build de game, I have jittering problems when I move, over and over again, doesn't matter if I put LateUpdate. Any solutions, please?
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @luiks You can use URP, which has PixelPerfect support built-in. In that case, remove the unnecessary PixelPerfet package, and you should be ok.
     
  12. luiks

    luiks

    Joined:
    Aug 23, 2017
    Posts:
    15
    @Gregoryl Thanks for the reply! Maybe you can have a look at the other forums discussion (just for no repetition).
    https://forum.unity.com/threads/2d-pixel-perfect-is-out-of-preview-for-2019-3.818742/#post-6107226
    However, having in mind what you say it is clear that maybe my problem is not with pixel-perfect then, is something else. Here a video of my main problem (is like a horizontal pixel "wave" that comes from bottom to top)

     
  13. SDRShadow

    SDRShadow

    Joined:
    Jan 15, 2022
    Posts:
    1
    I still have this issue, I've spent a few hours trying different methods and none are working for me. I am using URP cinemachine and the URP pixel perfect.
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Maybe you can start a new thread with a complete description of your setup and the exact issue you are having.