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

Dynamic Split Screen, Help Needed

Discussion in 'Cinemachine' started by BurningHeroG, Jun 24, 2019.

  1. BurningHeroG

    BurningHeroG

    Joined:
    Aug 18, 2013
    Posts:
    33
    Hello to all,

    I am working on a 2D fighter using a splitscreen effect similar to the one used in the Dragon Ball Z Butoden series for the Super Famicom. I am at the point where I have the splitscreen set up but it doesn't have a separator line and the splitscreen doesn't quite move how I want. I would like to know if I can have this type of camera effect using Cinemachine? I have enclosed a video demonstrating the look I am after. If this is possible let me know of a tutorial or a way to get it going in my project. I am using Unity 2017, Playmaker for scripting.
     
    Last edited: Jun 24, 2019
  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    I want to know too.
     
  3. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    They do a pretty cool split screen, animating the cut angle and doing a line draw.... that would take some figuring out, we don't support the screen window outline directly.

    Have you seen this?

    https://twitter.com/CiroContns/status/1064256255420702724?s=19

    I know this isn't a complete response, hopefully this helps a bit. We will think about how to do the frame draw around the screen
     
    BurningHeroG and Gregoryl like this.
  4. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    I was compel to google a bit existing solution, given unity's popularity people would have tried it:
    It's not always cinemachine but just for documentation sake:
    asset store (unity 4 ...):
    https://assetstore.unity.com/packages/tools/camera/magic-splitscreen-12721
    https://assetstore.unity.com/packages/tools/camera/dynamic-split-screen-14553


    overall talk, generic not unity based:
    at 26:59
    From an unity show off thread
    https://www.reddit.com/r/Unity3D/comments/94nwcd/made_a_dynamic_split_screen_effect_for_the_tanks/
    and here are the slides
    http://www.mathforgameprogrammers.com/gdc2016/GDC2016_Eiserloh_Squirrel_JuicingYourCameras.pdf

    implementation notes:
    https://mattwoelk.github.io/voronoi_split_screen_notes/ (unreal but generic advices)
     
  5. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,513
    @Adam_Myhill Any updates on the "dynamic" split screen and Cinemachine?

    The asset that @neoshaman linked to is the asset I am also using, and I am trying to integrate them together, if possible. The way Magic Splitscreen works is that the second camera uses a split screen mask. The first camera does a full render, and the second camera renders with the depth only clear flag, to maintain the first rendered image, and then renders the second camera only where the mask is not. The mask also uses a separate layer, and I'm not sure how that works with the layers used for the cinemachine virtual cameras.
     
    BurningHeroG likes this.
  6. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,513
    Er, sorry for the double post, but I just got Cinemachine working with Magic SplitScreen a bit ago. Maybe I'll write up a blog entry about it, but for those of you who are struggling with it, the main key that I was missing was that the GameObject that has the MagicSplitScreen script on it, assign that to one of the two camera layers used to distinguish the two split cameras for Cinemachine. I applied it to Cam2, and everything seemed to work as expected.
     
  7. BurningHeroG

    BurningHeroG

    Joined:
    Aug 18, 2013
    Posts:
    33
    Please write a blog post or elaborate here. Please.
     
  8. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,513
    Since a blog entry would probably take a month or three, I'm willing to continue discussion here. Basically, I'm using two cameras for Cinemachine and nearly stock MagicSplitScreen (MSS). I say nearly stock, because I wasn't really interested in MSS's logic to rotate the splitter bar based on player location. I have it fixed at a slight angle, say 10-15 degrees, so that it's a stylized split, much like that freezeframe of DBZ in the first post.

    I started out with setting up Cinemachine much like the Unity-provided example. Using layers "Cam1" and "Cam2".

    Then, I added MSS, and the GameObject that has the SplitScreen script is assigned the layer "Cam2".
    And that's pretty much it.

    There are a lot of gotchas along the way while setting up.
    For one thing, I actually have 3 separate cameras (well, even more, but for simplicity's sake, I'll say 3). The MainCamera, and then BattleCam1 and BattleCam2. When my game goes into a "BattleScene", I disable the MainCamera and activate BattleCam1 and BattleCam2, each of which has a CinemachineBrain. I had to be careful adding Cinemachine Virtual Cameras while the MainCamera was active, because I don't want CinemachineBrain on it, and Cinemachine automatically adds a brain once you drop a vcam in.

    I frequently ran into warning about FlareLayer not found or too many AudioListeners. You just have to handle those accordingly, but ultimately, they don't completely affect the outcome of the split screen.

    On a theoretical level, this is how it all works.
    Cinemachine controls properties of existing UnityCameras, but never controls how it's rendered to the screen. That is why MagicSplitScreen can interact with Cinemachine. With the 2 BattleCams active, Unity will render both camera views, but technically, you could only see the last rendered view. This is where MagicSplitScreen comes in. The second camera introduces a depth mask, such that only the parts that aren't blocked by the mask are rendered to the screen.

    As far as layers go, I'll repeat the setup for Cinemachine: BattleCam1 has "Cam1" layer, and its Unity Camera excludes "Cam2" layer in its Culling Masks. BattleCam2 has "Cam2" layer, and its Unity Camera excludes "Cam1" layer in its Cullling Masks. Then, any Virtual Cameras you create, just set the appropriate layer for the respective camera that you want to control. Then, for MSS, the SplitScreen object gets set to the "Cam2" layer, so that it knows to operate on that camera. It won't work if you apply it to "Cam1" because BattleCam1 is rendered first, which doesn't use the mask.

    Well, I typed a lot more than I thought I would. It's mainly just preparing to write a more formal blog entry on the subject, so I think this will help all of us.
     
    Gregoryl likes this.
  9. BurningHeroG

    BurningHeroG

    Joined:
    Aug 18, 2013
    Posts:
    33

    Thank you.