Search Unity

Transparent Rendering With DoF?

Discussion in 'General Graphics' started by SweetBro, Nov 28, 2019.

  1. SweetBro

    SweetBro

    Joined:
    Jan 14, 2013
    Posts:
    69
    So in short I'm trying to making some walls that become 50% transparent when the player avatar moves behind them. The problem however is that due me running DoF any object that's set in Transparent rendering mode will get hit by the DoF effect regardless of camera distance. I've read somewhere that this is due to the Transparent rendering mode not being able to write some rendering buffer (rendering pipeline aren't my area of expertise).

    Now my current in-elegant solution would just be to swap the rendering mode to transparent when necessary since for this particular effect the blur isn't too big of an issue. However, I imagine this becoming a problem when I eventually start implementing windows and other semi-transparent objects. Surely there is some kind of sane workaround for this limitation? I find it hard to imagine that this isn't a solved issue.

    While on a semi-related subject, is there a way to make an entirely transparent object cast shadows?
     
    Last edited: Nov 28, 2019
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Indeed it is. It is one of the significant unsolved problems for real time rendering. There are a few solutions (really work arounds) used by AAA games.

    Option 1: Just ignore it. Lots of games don’t use DoF outside of cutscenes, and they just try to make sure there’s not too many things with transparency in view.

    Option 2: Render transparent objects after depth of field is applied. This ends up with the opposite problem of they’re always in focus and have hard edges when behind or intersecting with opaque stuff that’s blurred. Kind of the flip side of “just ignore it”.

    Option 3: Multi pass rendering systems where far, in focus, and near objects are rendered separately. Far objects are blurred based on the depth buffer, just like before. In focus objects aren’t blurred at all, and near objects are blurred by the depth buffer or assumed to be fully blurred if not over an opaque object in the near range. This is what several games from the PS3/Xbox 360 and even late PS2 era did.

    Option 4: Don’t use any transparency ever, or use it as rarely as possible. This is pretty common now, especially with the advent of TAA being used by almost everyone. Instead you use opaque dithered transparency with noise and let the TAA blur it into something that looks like transparency.
     
    SweetBro likes this.
  3. SweetBro

    SweetBro

    Joined:
    Jan 14, 2013
    Posts:
    69
    Can you clarify what you mean by TAA?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
  5. SweetBro

    SweetBro

    Joined:
    Jan 14, 2013
    Posts:
    69
    I see. Thank you very much for the insight!