Search Unity

Question Display1, Display2, vCam1, vCam2 - how to assign?

Discussion in 'Cinemachine' started by Unifikation, Jan 21, 2023.

  1. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    I've only recently discovered that this is a thing, that multiple cameras can be used to project to different displays that can be shown concurrently in the Editor.

    How do I set respective cameras of the Cinemachine type (vCams) to their respective Displays via their "respective Main Cameras" given that there's only seemingly one priority system for vCam... priority... so that I can see the same scene/game from multiple points of view at the same time, via Cinemachine vCams?

    Not interested in this as a gameplay feature, though this will, obviously, be seen through Game Views in the Editor, merely wanting to do this for the purposes of better insight into the game world whilst editing in the Editor.
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    In Cinemachine 2.9.4 (and previous versions):
    From our docs:
    Multiple Unity cameras
    Split-screen and picture-in-picture effects require the use of more than one Unity camera. Each Unity camera presents its own view on the player’s screen.

    To use a multi-camera split-screen for two players:
    1. For each player, create a layer. For example, for two players, create layers named P1 and P2.
    2. Add two Unity cameras to your Scene, set up their viewports, and give each one its own Cinemachine Brain component.
    3. For each Unity camera, set the Culling Mask to the appropriate layer while excluding the other layer. For example, set the first Unity camera to include layer P1 while excluding P2.
    4. Add 2 Virtual Cameras, one to follow each player to follow the players. Assign each Virtual Camera to a player layer.
    You can have a look at our Anywhere Door sample scene. It shows how to render on a texture.



    In Cinemachine 3:
    You no longer need to use the built in Layers, Cinemachine has its own layering built-in.

    CinemachineBrain has a field called Channel Mask and CmCamera's have a Channel.
    CmBrainChannelMask.png CmCameraChannel.png

    For example, if you set CinemachineBrain Channel Mask to Channel 03, then it will only accept input from CmCamera's that are outputting to Channel 03.

    You can have a look at our Brain Update Modes or Split Screen samples.



    Viewport Rect example:
    Half screen Camera1 and half screen Camera2.
    Set the Camera's Viewport Rect's W to 0.5 on Camera1, and set Viewport Rect W to 0.5 and X to 0.5 on Camera2.

    Viewport1.png Viewport2.png
     
    Last edited: Jan 23, 2023
  3. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    I think you might have misunderstood the question.

    Am not concerned with multiplayer or even having this work in Game Mode.

    In the Editor, whilst editing (not in Play mode) it's possible to have multiple Game views into the game world with multiple Unity cameras.

    I want to use this... but with Cinemachine cameras unique to each Display (1 and 2 in the example given, for vCam's 1 and 2, respectively).

    Is this possible, so that I can have multiple vCams to edit, in Edit mode, that I can look through via multiple Game views?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
  5. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Sadly, I don't think anyone's familiar with the multidisplay features of Unity. It seems completely unused, by just about everyone. I'd only just recently realised what it was and what it could do.

    Sadly, the ideal use case for it is that which I can't do with it: compare the animation and blends of different CMvCams side by side in different Game Views, and their respective differences in Post Processing... because only one hierarchy of CMBrain "priorities" exists.

    I think, for multiDisplay (multiple Game Views) to work with independent choosing of CMvCams in each, each Unity Camera with each CMBrain would need to have a unique hierarchy of priorities... or... unique range:

    eg.

    CMBrain 1 on MainCam 1 for Display 1 (GameView 1) shows CMvCams with priorities between 0 - 100
    CMBrain 2 on MainCam 2 for Display 2 (GameView 2) shows CMvCams with priorities between 101 - 200
    CMBrain 3 on MainCam 3 for Display 3 (GameView 3) shows CMvCams with priorities between 201 - 300
    etc

    That, alone, would be amazing for prepping for cam switching and moves and post processing and lighting analysis and comparisons in the Editor. Just in the Editor, not in Play Mode, just using unique Game Views for each "Display".

    Where this would go to an entirely different level and become irreplaceably useful outside the mere "editor" applications and transcend -- Play Mode and Builds for installations. eg. all the different ad boards/screens around stadiums and other live venues, each having a different view into an ads graphics/animations, score graphics/animations, celebration animations, replayss and their overlays, etc.

    This could transform that industry, which is currently hobbled by a need to make custom applications each time with one of the C++ graphics frameworks like openFrameworks or Vvvv etc
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
  7. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    This only helps if the whole view is only through one master camera, and then traditional split screens are done.

    As I replied to that post... that's not the intention here... it's to have unique views into the Scene via unique Displays (a Unity feature in the top left of the Game View) of unique Game Views, with unique priorities for unique use of vCams.

    I'm repeating myself. Again.

    Try this drop down in the top left of the Game View:

    Screen Shot 2023-01-26 at 5.14.02 am.png
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    I do understand what you want to do. I'm trying to tell you that Cinemachine is not an obstacle for that. If you can render to multiple displays using multiple Unity cameras, then you can use Cinemachine to drive those cameras, whether they are on the same display or not.
     
  9. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Are you sure? How? Unique cameras (CMCams) per Unity Cam, in Unique Game Views, each in their respective Display.

    I don't see how this is possible.
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    This is 100% possible, using layers to filter the CMcams. CMBrain will ignore all CMcams not on layers included in the camera's culling mask. It's just a question of assigning the CMcams to dedicated layers, and setting the culling masks of the Unity cameras.

    This is the part I don't know about. CM just pushes transforms around, it doesn't care about displays or game views. If you can get multiple Unity Cameras to render into multiple gameviews on different displays, then you can use CM to drive those cameras independently.
     
    gaborkb likes this.
  11. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    So layers, in this CM sense, are not layers in the other ways we think of layers in Unity?
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    They are the same layers.
     
  13. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    argh... so Unity. I have to compromise between physics layers, masking layers and camera/culling layers, from a pool of less than 32.

    I feel Unified.

    And Volumes have some kind of integration with layers? I'll figure it out.

    What I can't figure out...
    The single most useful value on any Post Processing Volume is its "weight", that which determines the total amount of effect of the Post Processing... would be even more useful on vCams, but isn't there.

    Can I get at it through the API?

    Or is it not a thing for CinemachinePostProcessing to have a weight factor for the post processing?

    // asking because I'd tuned all my volumes to work at a weighting of .75, so I had some headroom. But they're now all too strong as CinemachinePostProcessing "Profiles", and not easy to recalibrate with colour grading, bloom, vignetting and motion blur etc.
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    We agree with you about this. In CM3, CM layers are a separate thing.

    When you attach a post-processing profile to a CM vcam, the weight is procedurally controlled to match the blend weight of the vcam, so that it blends in and out along with the vcam. We don't expose an additional "gain" parameter, although with some effort you could probably hack that in. I would recommend adjusting your CM post-processing profiles to look good at a weight of 1.
     
  15. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Sadly, a lot of very unfun work that will not be accurate... I've been trying with just one profile for about an hour, and not getting close, due to interesting extreme behaviours with blooms and colour grading.

    Also... this is a one way trip. Once they're good at a weight of 1... they're no good for me to do the previous tricks with blending with volumes before.

    Very annoying compromise has to be made... all vCams with their Post Processing and without the ability to easily change/animate weights, or the volumes and have to include 3D physics just for this... which is not nearly as performant as it should be for this "isolated" use of layers of physic objects etc...

    Please, can you give me the way to hack the weight of the CinemachinePostProcessing on individual cameras?

    // I've already realised I can probably have two identical vCams, one with and one without post processing, and blend between them, but that's not going to work with actual gameplay blending of cameras in any fun ways.
     
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    That looks like a red flag. What weird stuff are you up to? Is it really necessary, or is there a cleaner way?

    You can create a custom CM PostProcessing extension by copying CinemachinePostProcessing.cs to your assets, renaming it, and adding a "Gain" field that gets multiplied into the weight. Use the gain in PostPipelineStageCallback() instead of the 1, in this line:
    Code (CSharp):
    1. state.AddCustomBlendable(new CameraState.CustomBlendableItems.Item{ Custom = profile, Weight = 1 });
    Use your custom extension instead of CinemachinePostProcessing.
    Does that make sense?
     
  17. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Re Layers... I had seen that you and the Marky Marc put out a video talking about 3, but haven't got around to watching it... mostly because that'd mean "upgrading" to a newer version of Unity...
     
  18. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    I think so... will have a tinker. Have had a bit of success modding TMP lately, so might be able to do this... and get it to work.

    THANK YOU!!!
     
    Gregoryl likes this.
  19. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Some of the colour grading and bloom is pretty strong to get that 80's look, and then to animate it through pushing around weights values. Not extreme use, just more than might be considered normal for "realistic games".

    eg:

    upload_2023-2-4_1-32-33.jpeg
     
    Last edited: Feb 3, 2023
  20. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    in the version I've got, of CM, that line, I think... looks like this:

    state.AddCustomBlendable(new CameraState.CustomBlendable(profile, 1));


    Is it much the same, that that 1 at the end is weight?
     
  21. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    yes
     
  22. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    It sort of works... in that I can get an extension available and add it to the Camera, but it's only got the Gain variable showing, not the usual extras to make it work... ABO = modified version:

    upload_2023-2-4_2-11-21.png
     
  23. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    oh yeah, you'll need an Editor.
    Copy CinemachinePostProcessingEditor.cs in the same manner, rename it, and replace all instances of CinemachinePostProcessing with your class. Remove the #if CINEMACHINE_BLABLA conditionals.
     
  24. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Brilliant. THANK YOU!!! That did it

    I wasn't looking far enough down through the conditionals. Ripped them all out, and things are working.

    AND the gain. Amazing. It just works!

    THANK YOU!!!!!!!!!!!!!!!
     
    Gregoryl likes this.
  25. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Almost... this is entirely an:

    upload_2023-2-4_2-38-1.jpeg


    But I still haven't got the settings showing for the Post Processing Effects. I can load a profile and adjust the gain, and that all works, but the editors for the different post processing effects (color grading, bloom, vignette etc) aren't showing.

    Any tips on what else I might be doing wrong?

    upload_2023-2-4_2-38-58.png
     
  26. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    You can double-click on the profile and get a standalone editor for it. Not ideal, but it should allow you to function.
     
  27. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Very cool! Actually better, as can lock a inspector doing this, and just this, and then mess with the cameras at will.

    For anyone else doing this, there's a line about documentation that needs to be deleted, as it seems to be an internal call:

        [HelpURL(Documentation.BaseURL + "manual/CinemachinePostProcessing.html")]


    That link is broken, too. Even when it was in the actual cs file.
     
    Gregoryl likes this.
  28. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Another workaround for the inability to show the full GUI in the Inspector for the Post Processing Effects:

    Add "back" the original CinmachinePostProcessing Extension, deactivate and pick the same Profile as used in the new WeightEnabled gain driven extension. Now editing is available in the deactivated original Extension and is live.
     
    Gregoryl likes this.
  29. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Bug?

    Going into Play Mode, everything works fine, the first time.

    Exiting Play Mode, the Post Processing turns off, somehow throughout the project. No amount of deactivating and re-activation of components and game objects (cameras and their associated Post Processing stacks etc) reinvigorates the Editor Mode running of the Post Processing stack(s).

    Entering PlayMode, they come back on. Exiting again, they're off again.

    EDIT: additional info - making any changes to the script extension and reloading reinitiates the Post Processing, but upon next exit of Play Mode, all Post Processing is off and problem returns.

    EDIT- MORE INFO:

    This is almost certainly a Unity and Post Processing bug. Deleted my custom CinemaMachinePostProcessing cs file, restarted etc... and this behaviour still occurs, everytime.

    ie Post Processing is only available in the Editor in Edit Mode prior to the first time Play Mode is entered. After that, there's no Post Processing in the Editor in Edit Mode.
     
    Last edited: Feb 3, 2023
  30. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    It works for me. You might have done something screwy when making your custom class and editor.
    Here is my custom copy (without the "Gain" mod). Works fine, even the editor shows the full profile.
     

    Attached Files:

    Last edited: Feb 3, 2023
  31. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    I've cleaned out all my (one) class extension.

    This is definitely a bug. I've found a lot of complaints about this online, and even recall my prior endeavours, when first trialing Post Processing, being shocked to find it worked in Play Mode, but not in the Editor. This is a thing, for sure, for normal users of 2019.LTS, and seemingly 2020.LTS, and 2021.LTS... judging by some quick googling. Some have even discovered a way to add a camera to reinitialise it, with a new post processing volume, etc.

    Others work around it by using a Volume based approach and never go back to trying to use CinemachinePostProcessing.
     
  32. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    I'm using 2021.3.9f1 and cannot repro your problem. If you'd like to make a repro project and send it to me, please do.
     
  33. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Do you have 2019.LTS?
     
  34. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Yes. Made a quick project with 2019.4.17f1. Works perfectly, cannot repro your issue.
     

    Attached Files:

  35. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Could be like that bug where it's only possible to edit a dolly rail if you've only got one Inspector open - wherein there's how users use Unity versus how the developers test it.

    Like you've chosen .17f1... what's special about that one that's better than those that precede it?

    I'm on an earlier version due to a bug that happens in TMP in later versions.
     
  36. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    2019.4.17f1 is the version I happen to have.
    There are unlikely to be any issues if you open my project with a slightly earlier version. Did you try?
    I tried with 2 inspectors. Doesn't seem to be a problem.
     
  37. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    I get a stream of red ink in the console:

    type of namespace cinemachine not found etc etc... lots of them. issing in Assembly reference etc.
     
  38. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Just to be perfectly clear... mine, and everyone else, seems to work first time on load/start Unity - post processing visible in the Editor in Edit Mode.

    However, enter Play Mode... exit Play Mode... there's the problem. Now no Post Processing in Editor, only upon re-entering Playmode does it reappear.

    this is all over Reddit, SO and other sites.

    Search for "Post Processing not working" Unity. There's a lot of other issues, too. But this one pops up about 1 in 10, and is particular to the usage of the Post Processing Extension on a CM
     
  39. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    It's going to try to fetch CM 2.9.5 and PostProcessing packages. Was there an error doing that? Which version of CM do you have in your package cache?
     
  40. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Can you give me a specific link or two?
     
  41. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    2.6.4 here. I don't even see 2.9.5, only up to 2.9.4
     
  42. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    You're using some old stuff. You can edit the project's manifest directly and change the CM version to 2.9.5, which is the most recent. If that doesn't work, 2.9.4 is fine.
     
  43. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    You might be able to do that, and consider that normal. I have no idea what it means.

    I've started a reboot. And am watching a "Resolving packages... " dialog snail its way across the screen...
     
  44. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    My experience with Unity has led me to using the oldest of everything I can get away with.

    Annoyingly, CM 2.9.5 and PP 3.2.2 of post processing are not causing the dropped connection when coming out of Play Mode.

    Annoying, because this combination runs 10+ Celsius hotter on my laptop, even with this minimalist scene, and the motion blur is significantly inferior to the earlier version I was using, and there seems no way to get anywhere near back to the smearing in the earlier version.

    Thank you... sort of... ;)

    Yeah.. yeah... yeah... I know.

    ----------------

    UDPATE:
    For those following along and wondering "how's this going", to all none of you:

    Updated CM to 2.9.5, restarted Unity, but DID NOT update Post Processing. Just doing this fixed the issue of losing Post Processing in Editor Edit Mode after Play Mode session.
     
    Last edited: Feb 3, 2023
  45. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Great news. So there was some bug in the old version of CM that you were using.
     
    Unifikation likes this.
  46. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Indeed!

    How do I send you back a tiny (no extraneous stuff) project with the couple of little additions I've aded (animation and some more post processing) ?
     
  47. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    The same way I sent you mine. Zip it up, having first deleted all the directories except the ones I included.
     
  48. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,087
    Here it be....

    A little animation of the camera to show the issues with the motion blur, and minor collection of post processing...
     

    Attached Files:

  49. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    I'm not seeing any issues. What should I be looking for?
    Also, the project is using PP 3.2.2. Is that intended? If not, what version of PP are you using?
     
  50. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Playing around with this a little: you might have to make another change to your CustomPP for blending to work properly. Change this line to #if false instead of #if true:
    Code (CSharp):
    1. #if true // set this to true to force first weight to 1