how to simulate the physical camera focusing and defocusing

Hi

I would like to simulate the physical camera - focusing and defocusing of objects. I have one object close to the camera and other object far way from the camera. At the begining I have to define the plane of the camera where the first object is on focus. The other (second) object is out of the focal plane and it is defocused. When I move the first object for or back to the camera it is focused or defocused and at the same time the other (second) object is still defocused. I would like to make the same procedure with the second object too.

I tried the image effect Depth of Field but without success at the moment.

Could you please help me to resolve the problem.

Regards

With Depth-of-field, things get blurry after they reach a certain distance from the camera. What you want is for things to blur based on distance from your focus distance, meaning you’ll want closer objects to get blurry too.

You’ll probably have to write the shader yourself, but basically have a depth value that you’re “focussing” on, and make pixels blurry based on how far their depth value is from your “focus” value.

I also recommend changing the camera FoV as you change the focus value to simulate a moving physical camera lens. (FoV is how cameras zoom in real life)