Search Unity

HDRP Splitscreen & Cinemachine Volume Settings Extension Issue

Discussion in 'Cinemachine' started by DanielColina, Jan 22, 2021.

  1. DanielColina

    DanielColina

    Joined:
    Jan 28, 2019
    Posts:
    2
    Unity Version: 2020.1.3f1
    Cinemachine Version: 2.6.3
    HDRP Version: 8.2.0

    Currently working on a project utilizing the splitscreen technique shown in this video (two cameras, each rendering to 50% of the viewport, separate virtual cameras controlling them with proper layering).

    However, when I attach a Cinemachine Volume Settings extension to the virtual camera (settings pictured below) controlling the left viewport's camera, the volume's settings affect the whole screen, and not just that camera's viewport. I'm currently using a very high film grain on the volume to visualize the issue, which is why it may look like a grainy image. I attached a non-volume image for reference as well.
     

    Attached Files:

  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    The way it's implemented, CinemachineVolumeSettings are global volumes under the hood. You can control which cameras see what effects by setting the Volume Layer Masks on the cameras. The vcam global volumes will follow suit.

    upload_2021-1-22_15-51-44.png
     
  3. DanielColina

    DanielColina

    Joined:
    Jan 28, 2019
    Posts:
    2
    Gregoryl likes this.
  4. SimonsCat

    SimonsCat

    Joined:
    Mar 11, 2015
    Posts:
    49
    Hi, I want to borrow this thread for a closely related topic, maybe ? :)
    Unity: 2019.4.10f1
    Cinemachine: 2.6.3 (tried also in 2.5.0)
    HDRP: 7.5.1

    We have the following setup:
    A local Volume with certain DOF settigns. The Box Collider extends over the entire scene. In theory you cannot go outside this local box :)


    Then I set up a Cinemachine VC with a Cinemachine Volume Settings extension. Camera Status: Disabled!


    Then I put the VC on my timeline inside the scene, as a last camera on the timeline.


    Ok, so this is the setup.

    I start the scene in editor playmode. I enable the Brain on the main camera and the Timeline starts to play and all looks good. The DOF effect looks like expected. The timeline enables and animates the cameras as expected. However, at the end when the director stops, we go back to the game. The VC camera linked to the timeline is disabled, as expected. We also turn off the Brain on the MainCamera as soon as the director stops (director.stopped action). Our game camera does not have an active VC nor the Brain enabled.

    I was expecting that the DOF settings will go back to the settings of the local volume (Box collider), but no, the DOF settings remain the same as they were when the VC camera was enabled. I would expect that when the VC cam gets disabled by the Timeline the CinemachineVolumeSettings are turned off and the other global or local volumes do their thing. Am I doing something wrong?

    The VC Volume Settings remain active even if I uncheck this component:


    The finally turn off if I untick this checkbox:


    I'm not sure I understand the behavior of the CinemachineVolumeSettings. I now know they act as a global volume, but why is this global volume still active when the camera is disabled? Its a VC extension so the camera should control when the volume is active?

    Does anyone has any idea?

    Cheers,
    Simon.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    That is the correct expectation. One thing you didn't mention: when the CM vcam is disabled, where is the camera? In the local box? If not, then the settings of the local box won't have any effect.

    There is no built-in "default" settings for DoF. So, when all DoF volumes are disabled, it is indeterminate what the result should be. It's good practice to make a global volume with the default settings you want, and have that overridden by the local box and the vcam. What happens if you try that?
     
  6. SimonsCat

    SimonsCat

    Joined:
    Mar 11, 2015
    Posts:
    49
    Thank you for the feedback.

    Yes, when the CM vcam is disabled the camera is located in the local volume, that contains the entire scene. I double checked and the camera is 100% inside the box collider, somewhere in the center.

    I'm also sure of this because if I manually uncheck the DOF checkbox (in my last image above), then I actually see the DOF settings of that local volume.

    Tried another two things:
    1. HDRP Defult Settings in Project Settings: Set the default DOF override "default" off - same result (the vcam DOF still on)
    2. Created a global volume with DOF settings off - same result (the vcam DOF still on)

    (I use HDRP Defult Settings in Project Settings as my default GLOBAL settings for volumes when needed)

    The only solution that I have so far is this (but this can't be it):
    I created an additional "new" CM vcam without the Volume Settings extenstion and added the "new" camera on the last frame of the timeline and blended the previous vcam (the one with DOF settings) to this empty one. With this hack, the DOF effect of the vcam goes off and the game resumes with the DOF settings of the local scene volume.
    It solves the problem with the current timeline(cutscene) but I have 179 other to do this way :| That is why I would like to solve the root or the problem, or at least know what I'm doing wrong.
     
  7. SimonsCat

    SimonsCat

    Joined:
    Mar 11, 2015
    Posts:
    49
    I'm attaching a unitypackage with a test scene where I can observe this bug ?!.

    Import this package after you install Cinemachine and HDRP (I used HRDP 7.5.1 (+tested in 7.3.1.) and CM 2.6.3) so you won't loose the links.

    There is one scene: CinemachineTestBug. If you load it, there is a plane and a cube. A local Volume makes the furthest edge a bit blurry (BUT it also happened that after I clicked on the timeline gameobject in the sample scene tha vcam Volume became active and the whole image becomes blurry)
    When you hit play, the timeline starts and makes the vcam active -> the vcam volume becomes active and the whole scene becomes blurry. When the timeline stops playing, the vcam gets disabled, but the vcam Volume is still active.
     

    Attached Files:

  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I haven't yet looked at your project, but I'd like to clear something up.

    When I suggested that you add a global volume with default DoF seetings, I meant that you have to have some valid settings in the DoF profile. "Off" doesn't count. The problem is that as the vcam's DoF blends out, there's nothing to blend to. Can you put some valid settings in your default DoF profile and try it again? You shouldn't need the extra vcam hack.
     
  9. SimonsCat

    SimonsCat

    Joined:
    Mar 11, 2015
    Posts:
    49
    Yes, I tried with a global volume with the Focus mode Off, and one test with focus mode Manual, with a proper Near and Far Blur settings but the results are always the same. And I tried with a local volume, making sure the camera is always in.

    The test package I made was recreated in the HDRP template scene from Unity Hub, with only one camera, one vcam, one timeline with only this CMvcam (VolumeSettings set) and one volume (local in the scene - tried to set to global but got the same result)
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thank you for preparing that project. Indeed you are right, the Volumes don't get cleaned up properly in the case when the last vcam is deactivated.

    We've scheduled a fix for this, it will be available in an upcoming release.

    Many thanks for your input on this issue!
     
  11. SimonsCat

    SimonsCat

    Joined:
    Mar 11, 2015
    Posts:
    49
    Thank you! Looking forward to see it... meanwhile I will use another empty vcam or other "hacks".
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    The bug occurs when the last vcam is deactivated and there are no active vcams left. The simplest workaround is to ensure that there is always an active vcam. An easy way to to this is to turn your main camera into a vcam by replacing the Camera component in your camera rig with a passive CinemachineVirtualCamera component containing DoNothing in Aim and Body. Put your actual camera in a separate object with a CinemachineBrain. It will then exactly track the passive vcam when that vcam is active.
     
  13. CoBraLorD

    CoBraLorD

    Joined:
    Feb 3, 2020
    Posts:
    7
    Hi Gregory, would it be possible to make the actual layer configurable?

    The problem is that the volume owner object that gets created attaches itself to the first layer in the volume layer mask.
    I have a setup where both cameras use the Default layer and each has a player specific layer. In my case if the volume owner could be on the player specific layer, it works fine; otherwise I have to remove the Default layer and create overall volume settings per player.

    Currently I hack around the code by searching for the hidden volume owner and setting the layer on it manually whenever the camera is updated, which seems to do exactly as I want.

    I'm not sure if there's something I'm missing, but a way to make the layer configurable or to specify a custom volumes owner would make this a more powerful feature for multiscreen scenarios.
     
    Gregoryl likes this.
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thanks for that suggestion. We'll look into this for a future release.
     
  15. CoBraLorD

    CoBraLorD

    Joined:
    Feb 3, 2020
    Posts:
    7
    Hi Gregory, we noticed another something that could be improved.
    The volumes created have a very high priority, which does not allow us to add another global volume that overrides the value.

    Our case is the following:
    We have several volume settings for different cameras that might for example specify a level of chromatic aberration. But we want the user on a global level to be able to disable chromatic aberration.

    We do this by adding a global volume on the shared layer with the highest priority, which overrules the possible individual camera settings.

    But also here, in order to do this we iterate over the Cinemachine created volumes and reduce their priority a little bit, just so we could add a priority with max value. For this as well, more transparency on the values and/or the ability to control them would be very useful.
     
    Gregoryl likes this.
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    We have reduced the default volume priority in CM to 1000, and it is also configurable via
    CinemachineVolumeSettings.s_VolumePriority
    . This will be available in CM 2.8.
     
    CoBraLorD likes this.
  17. SimonsCat

    SimonsCat

    Joined:
    Mar 11, 2015
    Posts:
    49
    Just a follow up: For a while I thought this bug was fixed, but now in 2019.4.26 it seems to be still there.
    The issue is that if a vcam with volume settings was running on a timeline and the timeline gets disabled the volume settings overrides still remain active.

    What we do: playing a timeline sequence (cut scene)
    The player has the possibility to skip the cutscene.

    Then we do (among other things):
    director.Stop
    brain.enabled = false

    Then the volume override setting (in our example DoF) remains active even if the current main active volume does not have the DoF set.

    So if there are no active vcams left and the brain is disabled the disabled volumes still remain active in the 2019.4.26 version of Unity or is this supposed to be fixed?

    Btw... If I let the timeline play to the end the timeline vcam volumes are disabled properly.
     
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    This is because the CM Volume settings work by creating hidden global volumes parented to the Camera. When the associated vcam is deactivated, the volumes get cleaned up. If you just pull the plug on the Brain, then the cleanup code is never executed.
     
  19. SimonsCat

    SimonsCat

    Joined:
    Mar 11, 2015
    Posts:
    49
    Ok, got it! Thank you very much.

    We need to be careful about the Brain dead :D