How to exclude a mesh from Depth of Field?

I know one method: Apply a translucent material to the mesh, this will make it excluded from DoF by default.
… But translucent materials are more demanding performance-wise and have some limitations. Is there any other way to exclude a mesh from DoF?

Enable “Separate Translucency” for it.

It looks like this setting is gone in 4.25, I only see the “Mobile Separate Translucency” which doesn’t seem to work on Opaque material.

1 Like

“Render After DOF” is the setting, I’m sorry. It requires Separate Translucency is enabled in Project Settings, but it’s for excluding translucent objects from DOF. The DepthofFieldFunction might be the one. I haven’t used it, but in its property tooltip it says 0=In Focus and 1=Near or Far (for the Near or Far property option), and its a mask. I’m not sure how it works so far.

1 Like

Yes, it’s enabled by default and it’s only available for translucent materials, unfortunately. Thanks though.

I saw someone with similar problem with a RadialBlur PP Shader, they “fixed” by capturing a RenderTarget and adding to the scenetexture after the effect.

Interesting. For post process materials this could also work by e.g. using the custom depth buffer to mask the DoF out for objects with custom stencil value.
But the DoF i not a post process material, so we would need a way to mask out the default PP/camera effects with custom depth. I wonder if that’s possible at all.