Search Unity

_CameraDepthTexture in vertex: tesselation dx11 2017.10 (forward shader)

Discussion in 'Shaders' started by Quatum1000, Jul 19, 2017.

  1. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Hi

    I tried to get the _CameraDepthTexture in vertex:disp but that cause an error:
    Code (CSharp):
    1. SubShader{
    2.        Tags{ "Queue" = "Transparent" }
    3.        LOD 300
    4.        Zwrite On
    5.        GrabPass{ "_GrabTexture" }
    6.        CGPROGRAM
    7. #pragma surface surf StandardSpecularWater vertex:disp tessellate:tessDistance nolightmap keepalpha nofog
    8.  
    9. #pragma target 4.6
    10. #include "Tessellation.cginc"
    11.  
    12. struct Input {
    13.        float3 worldPos;
    14.        float4 screenPos;
    15.        float3 worldNormal;
    16.        INTERNAL_DATA
    17.    };
    18.  
    19. float4 tessDistance(appdata v0, appdata v1, appdata v2)
    20.     {
    21.         return UnityDistanceBasedTess(...);
    22.     }
    23.  
    24. void disp(inout appdata v)
    25.     {
    26.              float depth = LinearEyeDepth(tex2Dlod(_CameraDepthTexture, float4(screenPos, 0.0, 0.0)).r);
    27.    // undeclared identifier '_CameraDepthTexture' at line 149 (on d3d11)
    28.              half edgeBlendFactor = saturate(_InvFadeParameter * (depth - screenPos.w));
    29.     }
    undeclared identifier '_CameraDepthTexture' at line 149 (on d3d11)

    Id like to smooth out the vertex height based on the depth info.

    How can I get this lines of code to work?
    Thank you..
     
    Last edited: Jul 19, 2017