Search Unity

Render Object at any Distance?

Discussion in 'Cinemachine' started by AnimusRex, Sep 30, 2019.

  1. AnimusRex

    AnimusRex

    Joined:
    Apr 26, 2019
    Posts:
    67
    I have a number of objects that I want to serve as visual landmarks in an open world game; I think I understand how I would have them appear at any distance using two nested cameras and some different layers, but I can't get it to work using cinemachine..

    Help?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Can you give a bit more detail about your setup? Can you explain exactly what isn't working? What do you expect, and what do you get?
     
  3. AnimusRex

    AnimusRex

    Joined:
    Apr 26, 2019
    Posts:
    67
    Absolutely, I'm trying to set two render ranges, one for the foreground/landscape, and one for landscape elements to render.

    Here's a screenshot of the visual landmark I was talking about;
    upload_2019-9-30_14-9-59.png

    I have two CM freelook cameras, A and B and each of them has a camera, A and B, attached.

    Camera A's settings are as follows;
    upload_2019-9-30_14-10-45.png

    And camera B is:
    upload_2019-9-30_14-11-6.png

    The island itself is about 8km^2

    As it is, Camera B doesn't seem to render the sword at all, even though I have it on the culling Mask "Infinite Range" and Camera A has Infinite Range disabled.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I think I'm beginning to understand your difficulty.

    Virtual cameras are not cameras - they're just game objects that the Camera uses (via the CinemachineBrain) to position itself. There is only one Camera, and it only has one layer mask. Setting the layers of the vcams just puts them on the layers - it doesn't affect the Camera's layer mask.

    You don't attach Cameras to virtual cameras - I'm not really sure what you mean when you say you have Cameras A and B attached. You should just have one Camera, with a Brain on it, as a separate game object (no parental or child relationship to the vcams).

    Note that the CinemachineBrain will only consider vcams on layers that the Camera can see (i.e. not filtered out by the mask). That's how you would "attach" a camera to a virtuual camera.

    If you want to set up a second Camera with a different mask, you can do that. You may or may not choose to use Cinemachine to control that camera as well. If you do, you can give it a CMBrain. In that case, you'll have to put the vcams that control the second camera on a layer that the second camera can see, and not on a layer that the first Camera can see.

    Does that make sense?
     
    AnimusRex likes this.
  5. AnimusRex

    AnimusRex

    Joined:
    Apr 26, 2019
    Posts:
    67
    So I have a CM FreeLook object, and it's the parent of a Camera with the Cinemachine Brain on it. I don't need these to have any parent-child relationship?

    I'll try and report back, thanks!
     
  6. AnimusRex

    AnimusRex

    Joined:
    Apr 26, 2019
    Posts:
    67
    Yeah, I'm not understanding something here. How does the CM FreeLook know which Camera to focus on? It seems to set clipping planes for both Cameras..
     

    Attached Files:

  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
  8. AnimusRex

    AnimusRex

    Joined:
    Apr 26, 2019
    Posts:
    67
    I looked at that thread, as far as I can tell I've set it up, but it still doesn't work.
    upload_2019-9-30_19-10-23.png

    upload_2019-9-30_19-10-43.png upload_2019-9-30_19-10-55.png
    upload_2019-9-30_19-11-18.png
    upload_2019-9-30_19-11-33.png

    I have the sword on layer B, and everything else on Layer A. The sword still won't render..

    The culling mask on Camera A is Layer A, and Camera B is layer B... Camera A's layer renders.
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Are both cameras rendering? Where does the output go? Can you, as an experiment, adjust the viewports so that each camera renders on a different half of the screen? I notice that FreeLook A is not live in its brain.
     
  10. AnimusRex

    AnimusRex

    Joined:
    Apr 26, 2019
    Posts:
    67
    Both cameras are able to render.

    I adjusted them so they render a different half of the screen, also set them to different culling layers, and it works in split screen mode;
    upload_2019-10-5_23-16-45.png

    When I change the viewport to go back to 1 camera view, however, I lose all rendering of the sword again.. Aaaaaa

    Where do you mean FreeLook A is not live?

    Thanks!
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    It's good that the sword is rendering.
    At this point I don't understand what you're expecting to see when you make the top camera occupy the whole screen, other than the top camera's output. Where are you wanting to see the sword?
     
  12. AnimusRex

    AnimusRex

    Joined:
    Apr 26, 2019
    Posts:
    67
    I'm also making the bottom camera occupy the whole screen.

    I'm looking to get the sword to render at any distance. It should be rendering in the distance regardless of how far away the player is because it's on a separate render layer that would be dedicated to far away objects/terrain that are large enough to matter visually.

    Does that make sense?
     
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    All Cinemachine does is to position the cameras. If you put the cameras in their respective positions and disable CinemachineBrains, does it render as you want it to? If not, then the problem is in your layering setup.