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

Feedback Virtual camera volumes get not removed after playing

Discussion in 'Cinemachine' started by Bordeaux_Fox, Jan 30, 2020.

  1. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    When I attached a cinemachine volume setting to virtual camera, the post process effects does not disappear after the camera finished playing. Deactivating the game object itself, the cinemachine brain, the cinemachine volume setting scripts also does not reset it. I even try to set the m_profile to null, which also does not nothing.
    So how I'm supposed to get my default post process effect back after my cutscene finished?
    Cinemachine should really do it automatically or expose some option in the timeline.

    That internal script does not work at all.

    static void OnCameraCut(CinemachineBrain brain)
    {
    //Debug.Log($"Camera cut to {brain.ActiveVirtualCamera.Name}");

    #if CINEMACHINE_HDRP_7_0_0
    // Reset temporal effects
    var cam = brain.OutputCamera;
    if (cam != null)
    {
    #if CINEMACHINE_HDRP_7_1_0
    HDCamera hdCam = HDCamera.GetOrCreate(cam);
    #else
    HDCamera hdCam = HDCamera.GetOrCreate(cam, new XRPass());
    #endif
    hdCam.volumetricHistoryIsValid = false;
    hdCam.colorPyramidHistoryIsValid = false;
    hdCam.Reset();
    }
    #endif
    }
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Cinemachine does do it automatically.
    Perhaps there is an error in your setup.

    1. What versions of Unity, HDRP, and Cinemachine are you using?
    2. Can you show an image of your Main Camera inspector, of your default volume, and of your vcam volume settings?
     
  3. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    I forgot to say after my cutscene I come back to NON cinemachine camera. You're right, if everything is a cinemachine camera, it does work.

    I'm using Unity 2019.3.0f5 and HDRP 7.1.8.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    That isn't a use-case that we normally encounter.
    Is there a reason why you can't leave CM on all the time?
     
  5. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    Yes, we use a custom third person controller and don't want Cinemachine to mess with it's behaviour. So right now we only using Cinemachine for Cutscenes and not Gameplay. I'm not sure if I can convert it to behave the same with Cinemachine camera.

    Can you provide me snippet so I can clear the cinemachine volumes manually?
    As I see it Cinemachine is changing somehow the volume mask, so I have to revert it somehow.
     
    Last edited: Jan 30, 2020
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    It's not difficult to use CM with a custom controller. You just put a passive vcam in the controller, instead of the Camera component. The vcam will be 100% controlled by the controller script. Then a separate main camera object, with a CM Brain, will track it exactly. It is completely passive, and has the advantage of being able to blend nicely with CM-controlled cutscenes and PP volumes etc.

    If you can't remove the Camera component from the custom controller, it often works to just disable it, and add a CinemachineVirtualCamera component in its place, with DoNothing in both Aim and Body to make it passive.

    If you really don't want to do that, and want to just clear the dynamic volumes, they are stored in a hidden GameObject child of the Brain, called "__CMVolumes". Don't delete that child, but delete its Volume components (if any) and that should work.
     
    Bordeaux_Fox likes this.