Depth of Field with Manual Focal Lenth Positioning

Heya,

I am trying to create a simple DoF effect for my game. I am trying to make it so it should blur everything out of its focal depth/length. Every DoF shader I have seen uses the center of the viewport as its focal (using a ray I think…).
I’ve seen martinsh’s DoF with bokeh, but it’s really resource heavy and far more advanced for what I am trying to create.

I think the best way to do this would to be to get the x y and z coords of an empty then take the distance between the camera and object to set the focal length, however I don’t know how to do this properly nor how to make the 2d filter.

What is the easiest and most effective way of accomplishing this?

Thanks