Search Unity

Is it possible for a blend to interpolate between images instead of position?

Discussion in 'Cinemachine' started by Sendatsu_Yoshimitsu, Jul 23, 2018.

  1. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    It appears as if all of cinemachine's current blend types involve physical interpolation of the camera between the original and destination VCAM. I currently have a lot of cinematic match cuts that I execute by making the change in a single frame, so the camera snaps to the matching shot. This works, but it's a bit jarring- does Cinemachine have any existing functionality through which it can interpolate from one camera image to the other over a certain number of frames?

    I'm assuming this is a non-starter since CM's core functionality is based around moving a single camera in space, but it can't hurt to ask. :)
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You mean a dissolve?
     
  3. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    Yeah, exactly that. I'm guessing that CM doesn't support this, since by definition it would seem to require two actively rendering cameras.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You are right, you need 2 cameras. CM doesn't provide this functionality out of the box since, as you say, it's essence is to move a single camera around.

    Of course you could always have 2 cameras, with CM brains, that you drive with CM vcams, but the dissolve part will still be up to you.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Oh! I take that back. You could do it like this:

    Have a second camera (CM-controlled or not) rendering to a render texture. Then use that texture as input to a vcam with a Storyboard Extension. Check the "Mute Camera" checkbox on the Storyboard extension.

    upload_2018-7-23_11-20-9.png

    Now when you blend to that vcam, you get a nice dissolve! (sorry for the low color res on the gif, but you get the idea)

    dissolve.gif
     
  6. Sendatsu_Yoshimitsu

    Sendatsu_Yoshimitsu

    Joined:
    May 19, 2014
    Posts:
    691
    Oh man that is super slick, and considerably more performant than any of the workarounds I'd been considering- thank you! That does the trick perfectly :)
     
    Gregoryl likes this.
  7. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    very slick, storyboard extension is called what in CM 2.5?
    upload_2020-1-27_18-26-6.png
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
  9. sirglider

    sirglider

    Joined:
    Jul 10, 2013
    Posts:
    5
    Really like this way of cross-fading between two cameras. I'm seeing something which I'm not sure is intentional though.

    With the cross fade, the second camera's image fades in okay, but the first camera's image does not fade out. Could I be missing something in how Priority should be animated?
     
    Last edited: Sep 17, 2020
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    That's right, the first image doesn't fade out. The second image blends in by having its alpha move from 0 to 1. When it's 1, it should completely hide the first image, which can then be deactivated. Is it possible that your second image has transparent pieces in it?
     
  11. sirglider

    sirglider

    Joined:
    Jul 10, 2013
    Posts:
    5
    Yes, it does. I ended up creating two virtual cameras with Render Textures and blending between them. It works great! Thanks for the quick response.
     
  12. MikeGDev

    MikeGDev

    Joined:
    Dec 19, 2017
    Posts:
    53
    This works nicely, however when the Render Texture is displayed in the Storyboard its on top of everything. I would like to retain information from higher depth cameras such as VFX and UI. Is there a way to achieve this?
     
  13. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    We put our Storyboard on a canvas with default sort order (0). If you change the sort order on your UI to a bigger number (for example 1), then it will be drawn on top of the Storyboard. See the attached images (the chess board pattern is displayed with CinemachineStoryboard and the UI button is displayed over it).

    This doc may also be useful: https://docs.unity3d.com/ScriptReference/Renderer-sortingOrder.html
     

    Attached Files:

    MikeGDev and Gregoryl like this.
  14. MikeGDev

    MikeGDev

    Joined:
    Dec 19, 2017
    Posts:
    53
    Thanks for the quick reply! I can manage to get the UI on top like you showed by having a "Screen Space - Overlay" Canvas. However, I would like to be able to use "Screen Space - Camera" and also having another camera render on top with additional VFX. I'm guessing the Storyboard is put on a "Screen Space - Overlay" canvas? Is there a way to achieve this?

    I basically want to avoid rendering the same effects on both cameras, so the idea was to have a top camera for the effects and 2 cameras below it.
     
    Last edited: Feb 11, 2021
  15. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Yes, that's correct.

    Changing the storyboard canvas to different render modes (e.g. screen space - camera) is not yet supported by our UI. But we noted the feature request ;)
     
    MikeGDev likes this.
  16. MikeGDev

    MikeGDev

    Joined:
    Dec 19, 2017
    Posts:
    53
    Thank you! That would be very helpful and definitely offer more flexibility :)
     
  17. MikeGDev

    MikeGDev

    Joined:
    Dec 19, 2017
    Posts:
    53
    @gaborkb I have tested the new render mode for storyboards in the preview package for 2.8.0. It works very well :) however, it would be nice if it was possible to select which camera to use for the canvas as well, since it is not always desirable to use the main camera. For instance after cross fading between 2 cameras it would be nice to be able to disable the first camera (which can be the main camera) for performance reasons. Are there any plans for such a feature?
     
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You can use multiple cameras with CM. You associate a vcam with a camera by using the layer culling mask in the Camera. The CMBrain will only see vcams that are on layers not filtered out by the culling mask.
    See here: https://docs.unity3d.com/Packages/com.unity.cinemachine@2.8/manual/CinemachineMultipleCameras.html
     
    andreyefimov2010 likes this.