Announcement

Collapse
No announcement yet.

Depth of field blur in a material?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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?
    Last edited by Coldscooter; 10-03-2020, 07:49 PM.

    #2
    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.
    Last edited by Nathaniel3W; 10-04-2020, 02:56 AM.
    Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.

    Comment

    Working...
    X