Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Depth of field and transparent shader

Discussion in 'Editor & General Support' started by Pabi, Oct 29, 2016.

  1. Pabi

    Pabi

    Joined:
    Feb 13, 2016
    Posts:
    48
    I know it has been ask before but i've never seen a CLEAN ANSWER to this question. Is there ANYWAY to make this work?

    My solution was to use 2 camera and make sure all my transparent are on the first camera in order... but i can't have anything in FRONT of them. It does work but it doesn't feel right. Why i can't have a shader or something transparent that STILL write to z-buffer correctly. Is this only unity or all engine in the world is this way? Will there ever be a solution to this or only hack , like using second camera or using opaque shader.

    Thanks!
     
  2. Pabi

    Pabi

    Joined:
    Feb 13, 2016
    Posts:
    48
    Just to be clear, my transparent on my second camera aren't in DOF, so i created a script that alpha them on and off when camera get closer to create the feeling it's get in focus. It does kind of work but nothing can be in front of those item and it just doesn't feel right.
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,936
    It's something all engines do. It's a hard problem, there aren't many great solutions.

    Since something is transparent, you would need two z values in order to do it properly. (since, the background is visible, so is the z-depth of that pixel where the transparent mesh is, or where the background is? it's both, right?).

    With that said, you can use a custom shader and turn z-writes on. It will still look wrong with dof, just different wrong.
     
  4. Pabi

    Pabi

    Joined:
    Feb 13, 2016
    Posts:
    48
    yes i tried, and what is in the back of the panel isn't in DOF! ;) so i guess my solution is the best ? 2 camera with transparency on the second and trigger alpha on my item ?