Search Unity

shot transition from perspective to orthographic?

Discussion in 'Cinemachine' started by tdemelle_unity, Nov 15, 2019.

  1. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    I'd like to transition from a cinematic intro (which uses a perspective camera) directly to gameplay (which uses an orthographic camera). Is cinemachine able to accomplish this shot?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    You can't lerp from one to the other, so technically, no.

    However, you can fake it with the knowledge that an ortho camera can be approximated by a perspective camera with a very very small FOV, placed far enough away so that the screen size at the target matches the screen size of your ortho camera. You can use CM to blend to that fake camera, then cut to the real ortho camera at the end, and it will approximate a believable blend.
     
    Last edited: Nov 17, 2019
    tdemelle_unity likes this.
  3. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    Thanks for the quick, definitive and helpful response! I'll give it a shot.
     
  4. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    I took a shot at what you suggested, Gregoryl, but wasn't able to get a smooth transition between even relatively narrow FOVs (18-20) and 1 FOV (to simulate ortho). Even using linear blends, I wasn't able to get the FOV change to layer smoothly with camera position change. So I just ended up going with a pop from perspective to ortho after the camera movement. (If this is something you've gotten to work and can offer any pointers, I'd appreciate it!)

    Now I'm running into a related issue. I can't seem to get an ortho cam to co-exist in a scene with a perspective cam so that I can switch over to it for gameplay after the initial transition. I tried creating an ortho camera with a virtual brain in the scene with the perspective camera with a virtual brain. Then, when I made a virtual cinemachine camera, it had an 'orthographic size' field under lens in the inspector, so I thought it would behave as an orthographic camera, but the image it captures is in perspective.

    Is it possible to have both ortho and perspective cameras with cinemachine brains in the same scene?
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    Getting the perspective-to-ortho blend is a little tricky, and may not work with all content. If your ortho is looking diagonally at your content then you might be out of luck, but if it's straight down or head-on you can do it with a little filddling. Import the attached and play the scene for a working example. It blends from perspective to ortho, then at the end of the blend it just changes the Camera to ortho and cuts to a properly set up ortho vcam. No need to have 2 separate cameras. You have to play the scene - the event that changes the camera mode only fires in play mode. Look at the timeline to see how it's set up.

    persp2ortho.gif

    As for setting up with 2 cameras and 2 brains, you can do it, but there's a gotcha: the vcams themselves don't store the ortho vs perspective mode. Instead, they take that info from the Camera currently attached to whatever Brain they can be activated on. If there are 2 such brains with different settings then the results will be indeterminate.

    Follow the instructions in the docs for setting up 2 Cameras with 2 CM brains. Pay special attention to the instructions surrounding the layers. Make sure that the ortho vcams can only be seen by the ortho brain, and the perspective vcams can only be seen by the perspective brain. Then the vcams will show the appropriate mode consistently,

    How to set up 2 brains:
     

    Attached Files:

    Last edited: Nov 19, 2019
    tdemelle_unity likes this.
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    Actually, it works for oblique views too, I don't know why I said it might not. Here it is at 45 degrees

    persp2Ortho2.gif
     
    Last edited: Nov 19, 2019
    Flavelius and tdemelle_unity like this.
  7. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    Thanks for following up on this in such detail, Gregoryl!! I'll dig in with this info and let you know how I fare!
     
    Gregoryl likes this.
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    It was fun :)
     
    tdemelle_unity likes this.
  9. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    Gregoryl, are you using an actual ortho cam in this shot at the end? In the package you attached above (thank you again!), the final cam is a perspective cam. The shot I'm trying to create transitions from perspective to orthographic isometric. X:30, Y:330. I'm currently looking into how I might set up the two cinemachine brain cameras (one perspective and one ortho) on layers and then switch between them after the transition so I can carry on showing gameplay from a true orthographic camera.
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    You need to play the scene - in play-mode - not just playing the timeline. The Camera starts out being perspective, but the ortho vcam has a behaviour on it that exposes an event handler for when the vcam is enabled. The handler changes the Camera to ortho. So yes, it's a real ortho camera, but only in play-mode because the event doesn't happen otherwise.

    The idea is, when you cut to the ortho vcam, at the same time change the Camera to ortho. My event handler is just one way to do it. In your context you might want to do it differently.
     
    tdemelle_unity likes this.
  11. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    Ok, the solution is starting to emerge from the mist. :) A HUGE piece of the puzzle was finding the Cinemachine Follow Zoom Component in the package you sent. I wasn't using it before. In fact, it doesn't show up in my cinemachine components, so I copied and pasted it from your example camera. That solved the big issue of keeping the framing and composition smooth and consistent as FOV changed. It was exactly what I was looking for!!

    After a couple trial runs, I determined I wasn't getting the shot I wanted by just blending between two virtual cameras. So I set up a dolly cam thinking I could just animate the FOV property on the cam as it moved along its track. I'm getting much better camera movement, but the dollycam lens doesn't seem to reflect the FOV settings in its properties. The property animates and updates correctly in the inspector and goes from 18 FOV to 1 FOV, but the shot in the game view stays in perspective. I've been fiddling with different properties to see if I can find what may be influencing or overriding the FOV, but haven't been able to get it to look like an orthographic view. Any ideas what may be causing that? Should that be a workable solution?

    If I can get that piece of the puzzle in place and then follow through on the switch to true ortho cam with help from your guidance in your last post, I think I'll have my solution!

    Thanks yet again for your expertise and all your help. It's been incredibly timely and is much appreciated!
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    You should find the FollowZoom in the Extensions dropdown of the vcam inspector. Is it not there?

    upload_2019-11-20_14-41-55.png

    If you have a FollowZoom extension installed on the dolly vcam, then it will want to drive the FOV, so will overwrite whatever you try to animate for that field. That's its job. Why do you need to animate the FOV? Why not let FollowZoom do its thing?
     
    tdemelle_unity likes this.
  13. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    a-ha! I thought the FollowZoom was just stabilizing between two positions with different FOVs. And I was trying to add it as a component as opposed to adding it as an extension. I'm leveling up fast here! :p

    This new revelation has given me a concept I need to digest... I'm not *quite* grocking how to set up FollowZoom to do what I need it to do. Let me try to talk it through...

    I want the camera to go from an exact (close-up) perspective shot at the start of the timeline (FOV 18), to an exact (distant overhead) ortho shot at the end (FOV 0). I have the initial shot set up as the first position on a dolly track and it's looking right.

    I *thought* what I would need to do at that point was to set the FOV on the camera to 1 at the end shot of the timeline, enable FollowZoom and then manually nudge around the second position on the dolly until it matches my ortho target (and that FollowZoom would take care of keeping the shot stable in between). But now I see I need to somehow arrive at the end shot by figuring out how far away and where the camera would need to be with FollowZoom set with max FOV 18 and min FOV 1 so that it gets the right framing when FOV 1 is triggered by distance from the target?? Am I close? :)
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    FollowZoom dynamically adjusts the FOV so that the world-space width of the screen plane at the target's position remains constant. The intent is to preserve the screen size of the target, regardless of the distance between the target and camera. Imagine dynamically adjusting your camera's zoom as you move the camera, to keep the target a constant size. That's what it does.

    The width parameter says how big the screen rect should be, in world coords, at the depth of the LookAt target.

    upload_2019-11-20_15-29-43.png

    In the example image, that's 2 m. This is the same concept as the ortho screen size. That's how big the screen is. So, you should set up your FollowZoom to have a width that matches the ortho screen size of your final ortho cam (it might be off a bit, because one is screen size and the other is screen half-size, or maybe one is vertical size and the other is horizontal size, I don't remember). The min and max just clamp how much the FollowZoom is willing to adjust the FOV before giving up, to avoid extreme outcomes. You don't need those in this case, so set the range as wide as possible.

    So, to find the right distance for your fake ortho vcam: put the FollowZoom on it, set it up for the right width and camera angle, then start moving the vcam away until it looks right. The FollowZoom will automatically control the FOV to preserve the framing - you just want the distance to be large enough that it looks sufficiently ortho-ish.

    Does that make sense?
     
    tdemelle_unity likes this.
  15. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    Yeah, I think so. Let me go see! Thanks again, G!
     
  16. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    I thought for a moment the FOV wasn't kicking in, but I just hadn't moved the camera far enough away! (Because my camera is aimed isometrically, at such large distances it's difficult to 'zoom' it since it means translating on all three axes. Is there a way to translate the camera relative to the direction it's facing? That would be super helpful at the moment!)

    So now I've got it set up so my endpoints are correct, but the dolly track is so long (to get enough distance to simulate ortho) that the Follow Zoom script seems to be having trouble keeping up and maintaining a smooth, stable focus.
     
  17. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    Once you have the vcam aimed, you can switch your scene view to show local axes, then drag back the vcam's local Z.
    You might be pushing the dolly track beyond its precision.
    Maybe you could show me some pictures of your setup. It's getting hard for me to visualize.
     
    tdemelle_unity likes this.
  18. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    Thanks, Gregory. Switching to local axes was exactly what I was looking for. Right in front of me!

    I think you're right. I may be pushing the dolly track beyond its precision. I'm not sure if these shots help clarify. I can send you more specific details non-publicly if you're interested and able to take a look. I recognize I've already soaked up a lot of your time! Thank you again!

    2019-11-21_1235.png

    2019-11-21_1238.png

    2019-11-21_1245.png
     
  19. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    Looks like you're just making a linear transition from your start vcam to your fake ortho. If I were you I'd get rid of the dolly track, get rid of the animator, set up a static FakeOrtho vcam where your dolly rack currently ends and just let CM blend to it. It will give the same result but without the complexity. You don't even need the timeline - just activate the fake ortho and let CM blend it in. If you want to make a custom blend curve to control the timing then you can set that up in the CM brain.

    If the setup that I'm suggesting (which is essentially what I sent you in the project) is not giving the results you expect, we can look into it.
     
    tdemelle_unity likes this.
  20. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    Thanks, Gregory. I'll give that a shot. Stay tuned!
     
  21. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    That's the cleanest solution so far! The end shots are right and the transition is clean and smooth... BUT, the camera rotation from eye level to birds eye is quite abrupt at the outset. This is something the dolly cam was starting to help address (I know it looked straight in the distant screen shot, but there was a bit of a flat ramp out close to the ground).

    I tried a couple things to influence the virtual camera blend... layering some camera animation on the eye level cam with the transition between cams, but wasn't quite able to get the effect I was looking for. I also tried turning off 'center on activate' on the far cam and playing with aim properties, but wasn't able to get the camera to stop immediately turning its focus downward directly at the follow target... so figured that wasn't the right tool for the job.
     
  22. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    Show me the inspectors for the near and var vcams that are transitioning.
    Also can you post a little video or gif of the result you're getting - just the blend, no extra animation please.
     
    tdemelle_unity likes this.
  23. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    Maybe you just want a blend curve that looks like this:

    upload_2019-11-21_13-55-18.png

    You can set that up for this transition in the brain, with a custom blend asset
     
    tdemelle_unity likes this.
  24. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    Here's the shot I'm getting using the player and ground from your example package.
    Screen Recording 2019-11-21 at 02.56.47.27 PM.gif

    The curve you show is more like what I'm going for... I'll do a little homework on custom blend assets. Thank you yet again!
     
  25. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    ok, read what I could find about custom blend assets and set one up on my main camera. It doesn't look like it's having any effect on the blend in the timeline and playing the scene doesn't seem to trigger it either. What am I missing?

    2019-11-21_1553.png
     
  26. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    ahh... you're using timeline. Timeline controls its own blending, overriding the Brain settings (which makes sense, when you think about it). Brain settings (which you seem to have set up correctly) take effect when triggering a blend outside of timeline by activating a new vcam.

    To change the way the timeline clips blend into each other when they overlap, click on the clip in timeline and look at the top part of the inspector:

    upload_2019-11-21_16-0-38.png
     
    tdemelle_unity likes this.
  27. tdemelle_unity

    tdemelle_unity

    Joined:
    Jul 1, 2019
    Posts:
    16
    Thanks again, G. I truly appreciate all your help.

    As you may have gathered, I fall more onto the artist side than the engineering side of things :) Timelines make more sense to me than activating a second vcam through script. So I tried playing with the blend curves on the cinemachine shots in the timeline, but wasn't seeing them effect the movement much. (I set 'out' on the first clip to 'ease out' and 'in' on the second clip to 'ease out' and then to 'linear', but really didn't see much change in the motion. Transition too fast maybe?)

    Here's a quick vid showing where I am at this point. First it shows the shot using the vcam blending in the timeline. Second it shows the shot using the dolly track and flipping over to ortho cam at the end. If I can hide it with fx and other things going on in the scene (we have a character pop in at this point), I will likely go with the latter solution (spending a bit more time fine tuning the dolly track tangents) because I think the camera movement is much nicer (the difference is a bit more pronounced in the fully deco-ed scene)

    Screen Recording 2019-11-21 at 05.41.04.69 PM.gif
     
  28. lagruise

    lagruise

    Joined:
    Feb 23, 2017
    Posts:
    12
    Is there something missing in the package? For timeline I get the error "script missing" and I dont get any playable assets for the playable director.
     
  29. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,394
    CM 2.4.0 and up is only compatible with Unity 2018.4.17f1 and up. Perhaps you need to upgrade Unity.
     
  30. lagruise

    lagruise

    Joined:
    Feb 23, 2017
    Posts:
    12
    That should explain it. I am 2018.3.6 .

    Thanks /m
     
unityunity