FadeIn/FadeOut using Cinemachine !?

Hi, how one could add a black or white FadeIn/FadeOut with Cinemachine ?
Want to start a cinematic cut with a fade in from black for example.

I think one way could be adding a world space canvas to the camera with animator and toggle the canvas and animator components in timeline. In fact i just tried it but can not figure out how to toggle the animator component attached to the camera. I only can toggle the camera game object !

Is there any more generic way of doing FadeIns and FadeOuts ?

Thanks !

3 Likes

If you’re using CM 2.1.12, you can do it with a Storyboard extension on the vcam. Under the hood it’s just a canvas, so it’s a quick and easy way of doing what you’re doing. To fade in/out, create an animation track for the vcam and animate the StoryboardExtension’s alpha.

8 Likes

Thank You !
That works perfect !

1 Like

Glad to hear it.

Come to think of it, there’s an even easier way: create a dummy vcam with a Storyboard extension on it. Use a black or white image. That vcam will be your “fade out” vcam - use it whenever needed. Make sure you check the “Mute Camera” checkbox, that will ensure that the vcam’s transform will be ignored during blends:

3465043--274973--upload_2018-4-17_10-57-23.png

Now, in the timeline, you can create fades wherever you want by overlapping clips of this vcam with other shot clips. You don’t need to create animation tracks for the alpha.

15 Likes

Yes, that should be a bit cleaner as i am having now animator components and a storyboard components on all 3 virtual cameras. This way i will manage a single fade camera !

1 Like

Hi Gregory,

I wonder if you may assist me with this a little. I am fairly new to cinemachine, in fact, just looking at it today.

The scenario I have is a 2D platformer. Entry/Exit points on the left and right of the screen. I’ve managed to wire up the fade out based on your instuctions above, the player collides with a boxcollider2d on the right hand side, an animation trigger is set, the camera fades to black. What I can’t seem to work out is how to do the reverse, not using Cinemachine anyway.

I can create the same triggering based on the player arriving in the scene, but I can’t seem to find a way to change the alpha from 1 to 0?

Any help would be really appreciated.

If you’re not using timeline, it’s simply a matter of setting the “black” vcam to a higher priority, and enabling it when you want to fade to black, and disabling it when you want to fade back in. Let CM’s blending handle it.

4 Likes

Hey Gregory,
Thank you for Helping, I want to make fade in and out animation when the camera changes. Right now I am just fading the alpha of an image using script when player collide with cinemachine camera change collider. I want to achieve this.

Time :- between 2:48 sec to 2:53 sec.

Is there any way I can do that using cinemachine using storyboard or with anything else?
Thank you.

Yes. Do as it says here: FadeIn/FadeOut using Cinemachine !?

To fade to black, enable the “black” storyboard vcam. To fade back out, disable it and enable some other vcam.

You can to the enabling/disabling from script, or by just activating a new vcam for the new shot, and playing a short timeline just before with a CM track that has a clip with the black vcam fading in and out, masking the cut.

Thank you so much. Now I think I am able to grasp what you are saying. Sorry I haven’t use timeline before so I don’t know It’s functionality much. Thank you so much for your guidance.

Hey.
1.On assets store is only CM 2.1.10 version. So I cant add new storyboard script to my camera:( Ant others idea how i can add FadeIn/Out ?
2. I want smooth blend transition between two camera, is possible? like in this movie

1 Like

Don’t take CM from the asset store. Take it from the Package Manager.
To upgrade: first delete CM from your assets (this is important), then import it from Package Manager.

And for 2, see here: Is it possible for a blend to interpolate between images instead of position? - Unity Engine - Unity Discussions

hi, i am using cnimachine version 2.3.4 and i can not find storyboard script in CM package. why is that??

I don’t know. Where are you looking? It’s here:

5069378--498335--upload_2019-10-15_10-0-12.png

2 Likes

found it
thank you so much

Edit: Okay when I play it in the editor it blends. It just didn’t do it when playing the timeline.

I’ve read post #2 and #4 a couple of times but can’t figure it out. I have a vcam with a timeline. I have added another vcam to the timeline and want to fade between these two. I’ve created a third vcam with a Storyboard with alpha 1. I then add it to the timeline (by activating and deactivating it) overlapping the other ones but it just makes a clean cut without blend. What do I miss?

I don’t really understand. Are you just trying to get vcam A to blend to vcam B? If so, just create a CM clip for each, and overlap them. It will blend when the timeline runs. In this case, blend means that the position/orientation of the camera will lerp.

If you want a cross-dissolve, that’s another story. CM isn’t designed to handle cross-dissolves, as that requires a separate render texture. However. it’s possible to set it up. Look here: https://forum.unity.com/threads/is-it-possible-for-a-blend-to-interpolate-between-images-instead-of-position.541865/#post-3573211

Simple and effective. Thank you @Gregoryl

1 Like

If you are using UWRP Put this script On the Main Camera, and add Signal (FadeIn or fadeOut) in your Timeline

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
public class FadeOut : MonoBehaviour
{

    Volume volume;

    VolumeProfile volprofile;
    UnityEngine.Rendering.Universal.LiftGammaGain gamma;

    // Start is called before the first frame update
    void Start()
    {
        volume = GetComponent<Volume>();
        volprofile = volume.profile;
      
        volprofile.TryGet(out gamma);

        Debug.Log(gamma);
    }

    public void doFadeOut()
    {
        StartCoroutine(doFade(-1));
      
    }

    public void doFadeIn()
    {
        StartCoroutine(doFade(0.1f));
    }

    IEnumerator doFade(float i)
    {
        for (float a = 0; a <= 1; a += Time.deltaTime*5)
        {
            float b;
            if (i < 0)
            {
                b = i * a;
                if (b < -0.85f) { b = i; }
                   }

          
            else
            {
                b = -1+a;
              
                if (b > -0.05f) { b = 0;}
                Debug.Log(b);
            }
          

            gamma.gain.Override(new Vector4(0, 0, 0, b));
            yield return null;
        }


      

    }
}

I tried this trick with HDRP and in general it works, but I have an ugly 1 pixel border that is not covered by the black image of the virtual storyboard camera. I tried different scale modes for the image and also different image resolutions. I don’t know, if this is a rounding bug in the boudaries of the image, or intentional, or just a stupid mistake by me :wink:

1 Like