Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Feedback [Feature request] Depth of field through transparent ray traced reflections

Discussion in 'HDRP Ray Tracing' started by m0nsky, Nov 22, 2021.

  1. m0nsky

    m0nsky

    Joined:
    Dec 9, 2015
    Posts:
    257
    Hi,

    I'm working with a couple of cinematics that involve ray traced glass and depth of field. Currently, depth of field is lost after enabling "Receive SSR Transparent".

    I would like to suggest support for depth of field through transparent ray traced reflections.

    Thanks,
    m0nsky

    Examples:





     
    Last edited: Nov 22, 2021
  2. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    765
    Hey, thanks for bringing that up.

    First, receive transparent SSR force a depth pre pass by default so the problem seems to be coming from that. And it seems to have nothing to do with SSR itself, nor raytracing (the same happens with classic version)

    I did investigate a little bit and what's surprising is that it seems to be working as expected when the transparent in in the near blur, but not in the far blur. The two should technically behave the same way.

    I'll poke a few people and see if there's something to do about it.
     
    newguy123, Lex4art and m0nsky like this.
  3. m0nsky

    m0nsky

    Joined:
    Dec 9, 2015
    Posts:
    257
    The weird thing is, it does work after disabling SSR/RTR (or setting the Rendering Pass to "Low resolution")

    However, there won't be sharp reflections on the glass itself (which you would expect?)

     
  4. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    765
    This is kind of expected because SSR on transparent forces transparent to write their depth, so it's related but indirectly.

    In HDRP, one pixel can only have one depth, so either, so you let transparents and they inhenrit the depth from what's behind them (cubemap or geometry), or force them to write their depth but what's behind the transparent will also have the same depth, so there's no perfect solution here.

    The reason why "it works" it the low resolution transparent pass, is that low resolution transparent pass never write their depth and they are rendered later in the pipeline so they cannot receive SSR either.

    However, there's two hacky workaround for your cases:
    1. Use Pathtracer with Depth Of Field with Focus Mode property in Physical Camera. That way, the Depth Of Field is also path traced (not rendered as a post process), which should gives the proper result. But that doesn't really work for realtime situation.
    2. Use HDRP Compositor with multiple layers. That way, you could manage your background and foreground separately. That should give you more flexibility about what to blur and what not to blur.
     
    Lex4art and m0nsky like this.
  5. m0nsky

    m0nsky

    Joined:
    Dec 9, 2015
    Posts:
    257
    Thanks for the detailed explanation @chap-unity , I'm not sure if the compositor would work for this. For now I'll stick to the following:

    Desktop : DoF + no transparent SSR
    VR : no DoF + transparent SSR

    Would love to see this working as intended in the future, I think more people are going to be running into this.
     
    chap-unity likes this.
  6. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    *just a random unqualified thought*
    Maybe it's possible to use traveled distance of those transparent-reflective rays as some kind of depth override for those transparent pixels?