Smooth Depth of Field Transitions In Gameplay

Hello all, I’m trying to make a smooth depth of field transition based on where the character is looking, and although I’ve found tutorials on this and followed them, I noticed one common issue with all of them. They smooth the transition from far to near, but it’s only one way. Meaning when you are focused on something up close, then look far away, the depth of field snaps to that distance instantly. Not the effect I’m looking for at all. I want both ways to be smooth.

I’ve seen the tutorials do this with timelines, with lerps, finterp to, finterp ease in out, etc. I’m at a loss for how to do it on a two way street if you will.

Below is how I’ve been doing the smoothing.

Below is doing it without any smoothing.

The DOF tracing works great, as seen below.

But snaps from…

To…

Instantly!.. and visa-versa.

Any help would be appreciated, I am sure I’m not the only one stuck on something like this.

1 Like

this does the job, but surely there is a solution with more math :sweat_smile:

I used 1 in F-stop, you will have to adjust the values according to what you have

I’m not sure I’m clear on this. The “set variable parameter value” you’re using. Is that a material parameter collection? Then you’re using a post process material?

it is a collection of material parameters I simply put it so as not to make the reference to the post process, taking advantage of the fact that this variable can be called globally,… so in short it is not a post process material, the distance variable modifies the focus distance on another BP just to avoid the cast