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

Supersample Rendering using Cinemachine

Discussion in 'Cinemachine' started by DavidAvenue, Oct 2, 2018.

  1. DavidAvenue

    DavidAvenue

    Joined:
    Dec 27, 2016
    Posts:
    6
    Hey,

    We have were having this issue and went on to use this supersampling script and it worked fine with the Unity's default camera, but haven't been able to make it work when using cinemachine, would you please tell me if there's some way in cinemachine to achieve this? or what I might need to change to make it work.

    Thanks.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    You can make that script work with the Cinemachine camera.
    Just follow the instructions. Make a new Camera that will be your final camera. Deactivate the Camera component on your old main camera, the one with the brain (leave the brain active). Attach the script to the new camera, as directed, and link the brain's deactivated camera to the script. No reason why it shouldn't work.
     
  3. DavidAvenue

    DavidAvenue

    Joined:
    Dec 27, 2016
    Posts:
    6
    Hey, thanks for your input but still couldn't get it to work. I guess should start by saying I have the MainCamera (with Camera component, Cinemachine Brain, and tagged as MainCamera), and a CM vcam (with Cinemachine Virtual Camera component) -- all which is just a 2D Camera.

    I tried but was getting these:
    - Can't add component 'Camera' to MainCamera because such a component is already added to the game object!
    - NullReferenceException: Object reference not set to an instance of an object SupersamplingCamera.Start().
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    It's not clear what you tried. Given your description of your setup, I see no reason why the supersampling script you posted wouldn't work if you followed the instructions correctly.

    Maybe you could be a little more specific about what exactly you tried to do?
     
  5. DavidAvenue

    DavidAvenue

    Joined:
    Dec 27, 2016
    Posts:
    6
    Hi, these are the steps I did:
    1. I created a scene and added a Cinemachine 2D Camera.
    2. Added the SupersamplingCamera script Main Camera.

    This results in:
    Can't add component 'Camera' to Main Camera because such a component is already added to the game object!

    Any suggestions would be greatly appreciated.
     
    Last edited: Oct 23, 2018
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Looks to me as though you're not following the instructions given with the script you linked to, namely:

    1) deactivate your main camera
    2) create a new camera and set culling mask to none and clear flags to solid color
    3) attach this script [...]
    4) link your main camera to the script
    You're supposed to end up with 2 Unity cameras:
    1. The Main Camera, with the CM brain, and the Unity Camera component deactivated
    2. A second camera, with the supersampling script, and the Main Camera linked in the "cam" field
     
  7. DavidAvenue

    DavidAvenue

    Joined:
    Dec 27, 2016
    Posts:
    6
    Thank you very much.

    I'd like to add that for it to work I had to remove the "using UnityStandardAssets.ImageEffects" and had to set the Clear Flags to 'Depth only' because otherwise it woudln't show anything on the Game view while in Edit Mode.
     
    Last edited: Jan 14, 2019
    Gregoryl likes this.