Depth of Field and Depth Pass problem I seem to be having some trouble getting the look I need from DOF. Below is a render I did with DOF enabled:

At first, everything looks fine, but, the corners of the glass box is also blurring, which is not what I want. I only need the background objects to be blurred. So then I looked for other ways of doing this. I settled with using the Depth pass and Defocus node. This is the result:

So great, the glass box is in focus and the background blurred. The problem now is that objects behind the glass box, like the objects in the background, isn’t blurred when looking at them through the glass box, which isn’t surprising considering how depth maps work,
So my question is, is there a way to use the Depth map with the other passes like glossy to get the result I want?
Here is my blend file
help.blend
Using Blender 2.91.2
Any help would be greatly appreciated.
Thanks all
(Please note, this is a cross post from Blender Artist)
Depth of field requires a bit of knowledge to make it work to your advantage, as it is the combination of many factors:

Lens size

Sensor size

Focus distance

Aperture of the iris ($f$ stop)


Depth of field is not an absolute term, but is relative to the size of the final image, and there is also a subjective factor as it is usually defined by &quot;the area where things are acceptably sharp&quot;, based on the size of circles of confusion
What you need to find is a combination of lens, distance and F stop where the elements you want are in focus and the rest is not.
To have a smaller area that is sharp and selective focus, a trick is to use a much larger sensor size than the default one, which will force you to use longer lenses to keep the same field of view. Longer lenses will have a shallower depth of field.
To find the right combination there are quite a few online calculators for depth of field, use your favorite search engine to find one that you like.
There is an addon for blender, developed by @p2or, to visualize the depth of field in blender. Read:
How to display F-stop limits in viewport?
I don't know if this works correctly in current versions.
Additional links:
(https://en.wikipedia.org/wiki/Depth_of_field)
How do I set focus range?