I want for one project to have this kind of bokeh effect but only in the background like in this picture from this previous forum post : Where can I find a Bokeh post effect?
You can try playing with the focus property to and also reduce aperture and maxBlur to get it to affect only the background.
There is also a trick by using a second camera to affect objects only on a specific layer, not sure if it’s going to look OK with bokeh, but you can give it a try:
Leonidas’ solution is the easiest one, but it may not bend properly or be noticiable if the distance between the camera and the objects in those 2 layers is dynamic or they are close between them.
You could also access the depth buffer and edit the postteffect you shared to add it as uniform and weight the effect depending on it.
I took a look to the project and the problem was that the character was not in the depthBuffer for some reason, so nothing to do with the shader itself.
I uploaded a new .fbx and it was recognized.
Do you have any idea of what the problem may be?
In the picture you can see how the original character doesn’t show up in the right, but the big one on the back does.
@vogloblinsky@dadiaar I don’t have a working example of this right now, but in the past when I had similar troubles with depth of field I used something like this to add support for near/far focus (glsl):
// updated bokeh factor to make focusing easier
// camera near/far are the camera clipping distances
// dof focus and dof range are user attributes to set the effect zone
float depth = getScreenDepth(vUv0);
float cFar = cameraFar / (cameraFar - cameraNear);
float sceneZ = ( -cameraNear * cFar ) / ( depth - cFar);
float factor = clamp((1.0 / dofFocus - 1.0 / sceneZ) / dofRange * 500.0, -1.0, 1.0);