Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Strange behaviour of Depth texture in URP 7.3.1

Discussion in 'Shaders' started by alexispolak, Apr 9, 2020.

  1. alexispolak

    alexispolak

    Joined:
    Mar 3, 2013
    Posts:
    39
    Hi ! I'm trying to make a water shader for my game, I'm targeting mobile so nothing fancy but I really want to make the foam on the edges (where the water touchs the floor). I followed a lot of shader tutorials, some with shadergraph some by code (like the one from Joyce Minionsart) but in every case I get the same strange result.



    The last tutorial I followed was this one, that "fixed" some problems of using ortographic camera like I do, but doesn't seem to work either, the nodes of the shadergraph are like this.



    So I'm starting to think that it's some kind of bug. This is my camera config:



    By the way, if I use a simple depth-shader-material like this

    Code (CSharp):
    1. fixed4 frag (v2f i) : SV_Target
    2.             {
    3.                 float depth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.scrPos)); // depth
    4.  
    5.                 fixed4 col;
    6.                 col.r = depth;
    7.                 col.g = depth;
    8.                 col.b = depth;
    9.                 col.a = 1;
    10.  
    11.                 return col;
    12.             }
    The results I get are this ones:

     

    Attached Files:

    • Bugs.png
      Bugs.png
      File size:
      104.3 KB
      Views:
      340