Depth of field blur in a material?

I’d like to add a depth of field fx to translucent materials (for example a glass material that blurs the view behind it).

Does anyone know how to do this, or have any ideas or references?

This might work:

Set up your material similar to the start of https://docs.unrealengine.com/udk/Th…Detection.html, which detects SceneDepth at the ScreenPosition, compares it to SceneDepth at some offset, and then draws a black line if the difference in depth is above a certain threshold. I think you can do the same thing, taking SceneTexture at ScreenPosition, SceneTexture at some offset, and averaging the two together to make a blurry mix of the two.

Take ScreenPosition and mask R, G. Add some amount of offset to that, like 1/(screen resolution scalar parameter, which you can update in Uscript) for a 1-pixel offset. Take the SceneTexture at the offset, and then take SceneTexture at ScreenPosition, and average the two. Output that to emissive.

Then you could do something like multiply the offset by SceneDepth and some multiple to make the material blurrier as it gets deeper.