Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Has DepthPyramidTexture been removed from HDRP in Unity 2019.3 ?

Discussion in 'Graphics Experimental Previews' started by nasos_333, Mar 21, 2020.

  1. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    I was using DepthPyramidTexture to get the scene depth in Unity 2019.2 and this texture is no longer recognized by the new HDRP and Unity.

    Is there a way to get the depth without using the shadergraph libraries, since i do not need them besides only the depth texture.

    Also is there still the DepthPyramidTexture or was removed ?

    Thanks
     
  2. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Hello,
    Thanks unity, they just remove "sampler2D _CameraDepthTexture" and "sampler2D DepthPyramidTexture" and right now it's should be declared as arrays. And it doesn't say anywhere =/
    For old language CG you need use this code right now.

    Code (CSharp):
    1. UNITY_DECLARE_TEX2DARRAY(_CameraDepthTexture);
    2. float4 _DepthPyramidScale;
    3. UNITY_DECLARE_TEX2DARRAY(_ColorPyramidTexture);
    4.  
    5. //vertex
    6. o.projPos = ComputeScreenPos(o.vertex);
    7. o.projPos.xy *= _DepthPyramidScale.xy;
    8. COMPUTE_EYEDEPTH(o.projPos.z);
    9. o.uvgrab = ComputeGrabScreenPos(o.vertex);
    10.  
    11. //frag
    12. float sceneZ = LinearEyeDepth(UNITY_SAMPLE_TEX2DARRAY_LOD(_CameraDepthTexture, float4(i.projPos.xy / i.projPos.w, 0, 0), 0));
    13. half4 grabColor = UNITY_SAMPLE_TEX2DARRAY_LOD(_ColorPyramidTexture, float4(i.uvgrab.xy / i.uvgrab.w, 0, 0), 0);
     
    nasos_333 and eizenhorn like this.
  3. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Thanks a lot for the insight !!! :)

    I will start working with those and see if can get the same result as in 2019.2.
     
  4. Scifidynamic

    Scifidynamic

    Joined:
    Feb 11, 2016
    Posts:
    5
    Thank you for this. It took me 3 days but im finally sampling depth in HDRP, i still got one problem though. this does not seem to sample it per pixel, once the camera looks into the sky the screen is completely white and if it looks at the edge of something the screen is a dark gray(depending on the distance obviously).