Search Unity

Question Unity equivalent of UE4's Depth Fade node?

Discussion in 'Shader Graph' started by The-Wand3rer, May 29, 2020.

  1. The-Wand3rer

    The-Wand3rer

    Joined:
    May 14, 2019
    Posts:
    34
    Hi, I was trying to implement an equivalent of UE4s' Depth Fade node. In the source code they define it as
    Opacity * saturate((SceneDepth - PixelDepth) / max(FadeDistance, DELTA))


    Here's what I got in the Shader Graph editor
    upload_2020-5-29_15-59-40.png

    On the left I have pasted UE'4 color output for that node. However the result of those nodes look completely black. Does anybody know how to fix that? Thanks in advance.
     
    veritassidorares likes this.
  2. The-Wand3rer

    The-Wand3rer

    Joined:
    May 14, 2019
    Posts:
    34
    Solved it by myself: apparently the URP does not generate Depth textures by default. It needs to be enabled in the SRP options. Posting this for posterity :)
     
    Last edited: May 30, 2020
  3. veritassidorares

    veritassidorares

    Joined:
    Aug 24, 2020
    Posts:
    1
    Thanks for the implementation, but what does delta equal to?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    A very small value above zero, like 0.000001, because dividing by zero is bad.
     
    veritassidorares likes this.
  5. pwalters34

    pwalters34

    Joined:
    Oct 23, 2014
    Posts:
    7
    Did you get this to work like the UE Depth node? Were the results good?