Search Unity

Jittering / Flickering

Discussion in 'Cinemachine' started by luispedrofonseca, Aug 7, 2017.

  1. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    Hi, I'm having a very weird issue that I can't really pinpoint nor replicate consistently.
    In my project I want to focus over a group of objects and for that I'm creating 2 virtual cameras with group composers. Then I switch between them to create the transitions. It's all good and works very well.

    However, sometimes after switching targets a few times the camera will start shaking/jittering. While that is happening if I disable the CinemachineBrain component the jitter stops, but if I enable it, it comes back. So, it's definitely related to the brain somehow.

    Here's a video showing the problem:


    And here's the project that you can use to replicate the problem: https://dl.dropboxusercontent.com/u/883485/Cinemachine/Cinemachine-Test.zip

    Please notice that sometimes it takes a few target changes for the issue to occur.

    Looking forward for feedback!
     
    Last edited: Aug 7, 2017
  2. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Great find. Some high frequency low amplitude noise. Can't quite tell if it's rotation or translation but I'm going to guess rotation as the distant objects appear to have a little more movement.

    Gregory and I will discuss this and get back ASAP
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Thanks for the project. I can't repro the jitter, even after repeated target switching. Is there any special way I should be switching (e.g. mid-blend, or something like that)?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    oh wait - I'm getting it now
     
  5. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    Yeah, it's a bit tricky to replicate on this project but glad you guys got it too. It seems to be easier to replicate on the actual project for some weird reason.
     
  6. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    While you're at it, another thing that I've noticed is that sometimes the transitions between virtual cameras do not blend as expected. Instead you get a quick cut and then you see like the end of the blend.

    Any idea what's happening there? Do you want me to open a new thread for this issue?
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Yes, best to open a new thread for that one. I have not seen it before.
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    About the jitter. Very interesting... hard to pinpoint exactly what's happening.
    I'm getting the feeling that it's a combination of the high framing damping in the group composer, floating-point precision issues, and a feedback loop created by CameraGroupComposerManager.LookAt().
    I've managed to attenuate it somewhat by addressing some of these things, but it will still be sometimes slightly visible during the framing damping time. It's very subtle. If I push back some mods to you, can you test it in your larger project, where it's more visible?
     
  9. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    Sure.
    The Framing Damping is set to a high value because I need to "orbit" around the targets and while the orbiting is happening the camera zooms in and out (due to the changes of the targets' bounding box I guess) and it gives a weird feel. Do you happen to know a better way to do it?
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Yes, the bounding box of the group is dependent on the viewing angle. For your purposes, a bounding sphere would probably be more suitable. You could fake that my making a group with only one member, and giving it the position and radius that you calculate separately. Then you could get rid of the slow damping, which carries its own annoyances.
     
    Last edited: Aug 7, 2017
    luispedrofonseca likes this.
  11. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    It's on hold for now, but in our queue. I suggest for the time being that you adjust your settings and your strategy to minimize the jitter. I know it's not the greatest, but we're about to do a release and our queue is full up. Have you tried with a bounding sphere? That should do something to reduce the jitter.
     
  13. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    Unfortunately there's not much I can do to minimise it. It's more noticeable the further the camera is from the targets. To make it even worse in our case, we're using a wireframe shader.

    1) What do you mean with a bounding sphere? On the group composer? I don't see that option.

    2) My next idea is to disable the CinemachineBrain after the camera completes a transition, but I don't see that event. Is there a way to do this?
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    1) Bounding sphere idea mentioned in this post: https://forum.unity3d.com/threads/jittering-flickering.487102/#post-3175418

    2) There is no event for transition completion - only for transition start. In any case, disabling the brain is probably not a great idea.

    The thing is, I'm not seeing the ongoing jitter you've described. I'm suspecting it might be something in the way you've set up your scene. I'm just shooting in the dark at this point. Have you tried implementing the change in CameraGroupComposerManager.cs that I suggested, to reduce the feedback loop?

    Also, what happens if you change the GroupComposer framing method to ZoomOnly? Does the jitter go away?
     
  15. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    1) What I did was instead of using a GroupComposer with multiple targets, I added just one with a larger radius. This way when orbiting the camera doesn't zoom in-out based on the targets boundaries. This issue is fixed.

    2) Can you explain further why it's a bad idea. Basically I want that after the camera transitions end, the camera stays fixed.

    3) I don't think the jitter is dependent on the scene setup. You can see it happening on the demo project I uploaded above. Changing to a ZoomOnly GroupComposer doesn't remove the jitter.
     
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    1) good :)

    2) would be a bad idea in the context of most games. You seem to be saying that you just want to use CM to choose static vcam positions, and blend between them. If that's all you need, then go ahead.

    3) I can make the jitter disappear by setting the composer's Soft and Dead zone width and height to 0. Could that work for you?

    upload_2017-8-11_14-29-12.png
     
  17. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @Gregoryl Setting the Soft and Dead zones to zero solved the jittering and in my case it doesn't make any difference in the camera movement. Thanks for the tip!
     
  18. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    Spoke too soon. Didn't solve it and now it's the other way around. When the jitter is present if I make the Dead Zone Width larger than zero, the jitter stops! :O
     
  19. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    This is very strange. I'm beginning to suspect a precision issue deep in the bowels of Composer Damping. If you don't need composer damping, you can make a little hack to force a different code path. I'm curious to know whether that fixes the issue.

    In CinemachineGroupComposer.cs, around line 185, try this hack:
    Code (CSharp):
    1.             // Now compose normally
    2.             return base.MutateCameraState(state, statePrevFrame, -1);
    3.  
     
  20. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    That seems to have to fixed it! *fingers crossed* Thanks!