Search Unity

How To Get The Depth Texture of Objects That Drawed By "Graphics.DrawProceduralNow"?

Discussion in 'Image Effects' started by wechat_os_Qy04BOtPPpaGNpcdWAjICbXTo, Sep 21, 2019.

  1. wechat_os_Qy04BOtPPpaGNpcdWAjICbXTo

    wechat_os_Qy04BOtPPpaGNpcdWAjICbXTo

    Joined:
    Sep 21, 2019
    Posts:
    1
    Hi,
    I use this shader to get depth texture ,It worked when camera rendering common models,but failed when I use
    Graphics.DrawProceduralNow() in "OnRenderObject()",
    Code (CSharp):
    1. half4 frag (v2f i) : COLOR{
    2.    float depthValue =Linear01Depth (tex2Dproj(_CameraDepthTexture,UNITY_PROJ_COORD(i.scrPos)).r);
    3.    half4 depth;
    4.    depth.r = depthValue;
    5.    depth.g = depthValue;
    6.    depth.b = depthValue;
    7.    depth.a = 1;
    8.    return depth;
    9. }