Search Unity

Grayscale Depth Surface Shader

Discussion in 'Shaders' started by Boris1998, Nov 28, 2015.

  1. Boris1998

    Boris1998

    Joined:
    Jul 5, 2013
    Posts:
    82
    I need a surface shader that displays depth as grayscale. I think zbuffer is needed here.
    What I want to achieve is similar to this:

    Except, it is done using Vizualize option on new Depth Of Field image effect, and is, later on, not compatibile with other Image Effects because it just shows Depth Texture over Camera's rendering.

    I need 3 shaders:
    1. Just plain grayscale depth surface shader. Example: http://answers.unity3d.com/questions/847344/increasing-the-level-of-detail-with-a-depth-render.html
    Except the shader there is not working in UNITY 5.
    2. Standard shader combined with depth grayscale shader over it which transparency can be altered through slider. I think I could combine Standard and 1st shader myself.

    I want to make something similar to the game "WHICH". Screenshot:


    Thank you all for your time, and help. Cheers!
     

    Attached Files:

  2. StevenGerrard

    StevenGerrard

    Joined:
    Jun 1, 2015
    Posts:
    97
    First normalize your depth buffer.
    Then convert it to gray scale color output, for example " return float4(normalizedDepth.xxx, 1); "
    Maybe in your case you need some other curve to achieve effect you need.
     
  3. Boris1998

    Boris1998

    Joined:
    Jul 5, 2013
    Posts:
    82
    Care explaining a little bit more? I am not really good with shaders.
    What do you mean exactly by "normalizing depth buffer", and how could it be done?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    Couldn't you just use fog?