Wrong depth detection in Depth of field effect

I’m using Post Processing with a depth of field effect, but he isn’t working correctly in some ways. My objects in border of mountains get blurred, why its happens?


One of the most typical reasons for an object to be blurred “erroneously” like that is because its shader doesn’t write to the depth buffer. This typically applies to shaders featuring any amount of transparency, in order to properly allow the objects behind them to receive their intended depth-driven effects themselves.

By extension, since you mention this is using a Post Processing depth of field effect, this means that the depth of field only has one shot at making the effect look as good as it can, since it’s not being handled during any interim stage of the rendering process (i.e. before transparent objects are handled)

What this effectively means is that you can either look at changing your implementation of Depth of Field to place it in the middle of the rendering process (in other words, not as part of the Post Processing shaders), or this could be possible to alleviate with changes to the shaders on transparent objects, but this would likely result in unblurred background objects instead.