Blending between two virtual camera causes depth of field jitter

Hello,

I have a problem with two cinemachine camera I blend in the timeline.
Both cameras have a volume attached, with depth of field and vignette.
When the fading from camera 1 to camera 2 is finished, I get for short moment a jitter with bokeh of the background. What causes this and how can I avoid it? That cleary distracts my movie.
So it seems Unity is for one frame not taking both volumes into account?

Anyone? Can I expect that this get fixed?

We have not seen this before. Can you repro this effect in a small test project and send it to me?

Confirming this issue - it happens for me during the first and last 2 frames of a transition - so if I have two virtual cameras in the same position with a different PP volume for each but the same DOF settings applied, there are 2 frames at the start and end of the transition where the DOF becomes noticeably blurrier and gives it a ‘pop’ effect.

1 Like

Thanks, I assumed the bug is not only in my project. So either it is an interpolation error in the Cinemachine code or it is complete by design in the DoF shader in HDRP. I may wait what HDRP 7.2.0 brings this week before submitting a bug case but I’m not sure if it is just Cinemachine related. Would be interesting to try DoF blending with traditional Unity cameras.

You can remove the jitter by adding a default Volume (Depth of Field) setting to your Main Camera.

The reason, why this works:
When blending from camera A to camera B, at the first frame of the blend, the weight of A = 1 - epsilon, and the weight of B = epsilon. So we ignore B, but this causes A to blend to a default dof, which has extremely large values, and so causes a noticeable flicker. We’ll fix it in a future patch, but for now, you can use the above workaround.

1 Like

I already have a global volume with Depth of Field. So I need to add another global volume as a component to my main camera? With a higher priority? And then which settings should the Depth of Field have for this profile?

See the image for the volume, I used on my main camera. It is different from the ones I had on my vcams. But, you could use the Depth of Field volume of one of your vcams.

5463969--558489--Screen Shot 2020-02-10 at 12.27.21 PM.png

I’m afraid this does not solve the issue. Still get the jitter.

Can you repro this in a small project and send it? At this point it’s getting hard for us to diagnose.

1 Like

I can confirm this fix works - but only when I set the main camera DoF quality to ‘Custom’ - even if I don’t actually change any exposed settings… But thanks!!

1 Like

If I make it like in his screenshot, it just overrides the DoF profiles I set up for my cutscene cameras, which is even more worse, because then I have no bokehs at all.

Weird, for me it doesn’t seem to matter what I put into the main camera settings, it doesn’t affect the scene DoF at all (which is driven by the VCams). For reference, my setup is to have 2 VCams with individual volumes on both, that only contain a DoF effect, and then a single volume on the main camera with only a DoF effect - I haven’t adjusted weights or priorities at all.

The thing is, I already have a global volume, which contains more effects than DoF.
But the global volume is not attached to the main camera.
Even if I give the volume for the main camera a higher priority, it fixes nothing.

The bug seems to come from different DoF quality settings. The DoF quality of the global scene volume can be tweaked in my game in a settings menu. But for cut scenes, I force the virtual cams to use high quality for DoF, otherwise I don’t get good bokehs.
Nevertheless, between the two virtual cams, which have both high quality DoF, the single frame fallback to the main global volume quality setting should not happen (in case the player decides to toggle the DoF quality to anything than high.)
So the workaround is to have the same quality of the DoF the scene’s global volume until a bug fix arrives. I made a little script that changes the global volumes DoF quality to high before a cutscene and after that switched back the player’s setting.


if (Engine.globalVolumeProfile != null)
{
if (Engine.globalVolumeProfile.TryGet(out DepthOfField depthOfField))
{
depthOfField.quality.value = 2;
}
}

// Start cutscene.

Engine.cinematicActive = true;```

Despite the issue with DoF, I also noticed there is no smooth blending for the Lens Distortion effect. It simply turns off between cam 1 to cam 2 despite I have a blending curve of several seconds in the timeline. So this looks really bland.

![5464893--558630--main_camera_volume.png|464x330](upload://s9MDKWRwavPVNOAZWFBYSyxXgzj.png)
![5464893--558633--global_scene_volume.png|456x470](upload://b3hqmojOFDdHpiasrTZYYRlEtKw.png)
1 Like

Your global scene volume is using Physical Camera, whereas your main camera volume is using Manual focus mode. Focus mode values are not lerpable (enums). I could reproduce a jitter with different focus mode settings. The jitter went away, when I switched to the same focus mode on my volumes.

Moreover, as opposed to what I said earlier, you do not need to set a volume on your main camera. Instead you can change the Default Settings in HDRP using the HDRP Default Settings tab in Unity’s Project Settings window (see here).

I understand that the different focus mode is a problem. But again, the problem is, that Cinemachine takes the global volume into account while it should only lerp the Cinemachine volumes between two cameras in the timeline.

So my question is, will you fix it, should I submit a bug request or do you have it already on the track?

@Bordeaux_Fox Some things are blendable, and some are not. It’s not a Unity bug, it’s just math. You need to take care with your volume profiles to keep them blendable, if you expect to have smooth blends between them. If they are not blendable (e.g. have settings for different modes), then you will need to cut instead of blend.

It don’t want the focus mode to be blended. I have for all my cut scene camera the same DoF mode, which is manual. The problem is just Cinemachine switches back to the global volume between camera blending in the timeline for one tiny frame. It should just blend the Cinemachine Volume settings in the timeline. I’m fully aware that some things cannot be blended, but I expect Cinemachine to take Cinemachine volumes into account when blending. So a Cinemachine volume should be a global override.

Cinemachine Cam 1 Volume → blend (ignore global scene volume when override is active) → Cinemachine Cam 2 Volume

and not:

Cinemachine Cam 1 Volume → blend → short jitter global scene volume → blend → Cinemachine 2 Volume

@Bordeaux_Fox No need to submit a bug report. We have already fixed it, and the fix should be available in the next release.

1 Like

Ok, thank you, I will stay tuned for this update and inform you.

1 Like