Search Unity

Depth of field makes transparent shaders blurry?

Discussion in 'Shaders' started by Juice-Tin, Jan 25, 2015.

  1. Juice-Tin

    Juice-Tin

    Joined:
    Jul 22, 2012
    Posts:
    244
    Hello, my problem is simple:
    1. I have a tilt shift depth of field on my camera.
    2. There are transparent blocks in the scene (red)
    3. If nothing is behind the block, the block+edges become blurry. (the red one up close)
    The red block should stay sharp since it's very close, but it blurs because it's transparent.



    Any way around this? Thanks!

    Bonus: The sky is also blurry with depth of field, it should stay sharp.
     
  2. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    I think the tilt shift uses the depth buffer to blur objects. Unfortunately transparent shaders don't write to the depth buffer which makes them "invisible" to the post effect. You can see this problem a lot in modern games also.

    If you think about it the red block should be sharp and whatever is seen through it should be blurry.

    One solution is maybe just to blur the backdrop using a second camera or pull back the depth of field so it's less noticeable.