Access Depth Texture for STEREO_MULTIVIEW_ON

Hi, I am trying to make an edge shader for VR but it seems like the depth texture is always returning zero.
This only happens when I build and launch the app on Quest 2.

Here is the shader code (I removed irrelevant details):

Pass
{
    Tags { "Queue" = "Transparent" "RenderType" = "Transparent" }

    CGPROGRAM
    #pragma vertex vert
    #pragma fragment frag
    #include "UnityCG.cginc"

    struct appdata_t
    {
        float4 vertex : POSITION;
        float2 uv : TEXCOORD0;
        float3 normal : NORMAL;

        UNITY_VERTEX_INPUT_INSTANCE_ID
    };

    struct v2f
    {
        float2 uv : TEXCOORD0;
        float4 vertex : SV_POSITION;
        float3 worldPos : TEXCOORD1;
        float3 normal : TEXCOORD2;
        float3 viewDir : TEXCOORD3;
        float4 screenSpace : TEXCOORD4;
        float eyeIndex : TEXCORRD5;

        UNITY_VERTEX_OUTPUT_STEREO
    };

    uniform sampler2D _MainTex;
    uniform float4 _MainTex_ST;
    uniform float4 _MainTex_TexelSize;
    //uniform sampler2D _CameraDepthTexture;
    uniform float4 _CameraDepthTexture_TexelSize;

    UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);

    v2f vert(appdata_t v)
    {
        v2f o;

        UNITY_SETUP_INSTANCE_ID(v);
        UNITY_INITIALIZE_OUTPUT(v2f, o);
        UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

        o.vertex = UnityObjectToClipPos(v.vertex);
        o.uv = TRANSFORM_TEX(v.uv, _MainTex);
        o.normal = normalize(UnityObjectToWorldNormal(v.normal));
        o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
        o.viewDir = normalize(WorldSpaceViewDir(v.vertex));
        o.screenSpace = ComputeScreenPos(o.vertex);
        o.eyeIndex = unity_StereoEyeIndex;

        return o;
    }

    float GetEdgeValue(float4 screenSpace, float eyeIndex) {
        float2 pos = (screenSpace.xy / screenSpace.w);

#if STEREO_MULTIVIEW_ON

        if (eyeIndex == 0) {
            pos.x = pos.x;
        }
        else {
            pos.x = pos.x;
        }

#endif

        float depthCenter = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, pos));

        float2 leftOffset = float2(-1 / _ScreenParams.x, 0);
        float2 rightOffset = float2(1 / _ScreenParams.x, 0);
        float2 upOffset = float2(0, 1 / _ScreenParams.y);
        float2 downOffset = float2(0, -1 / _ScreenParams.y);

        float depthLeft = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, pos + leftOffset));
        float depthRight = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, pos + rightOffset));
        float depthUp = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, pos + upOffset));
        float depthDown = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, pos + downOffset));

        float vCurvature = (depthDown - depthCenter) - (depthCenter - depthUp);
        float hCurvature = (depthLeft - depthCenter) - (depthCenter - depthRight);
        float curvature = abs(vCurvature) + abs(hCurvature);

        float eyeDepth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, pos));
        float stepThreshold = LinearDepthFunction(eyeDepth);
        //0.0001
        return step(stepThreshold, curvature);
    }

    half4 frag(v2f i) : SV_Target{
        UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);

        float edge = GetEdgeValue(i.screenSpace, i.eyeIndex);

        return half4(0, 0, 0, 1);
    }
    ENDCG
}

Here is some frame debugger information:
I connected the build with the profiler and in the textures section of the frame debugger I can see a _CameraDepthTexture that only has “vs” stage, no size, so sampler Type, no color format etc.
Also in the keywords section, I can only see STEREO_MULTIVIEW_ON and not UNITY_SINGLE_PASS_STEREO.

I actually can’t find the STEREO_MULTIVIEW_ON keyword anywhere in UnityCG.cginc.

Setup Info:
I am using OpenGLES3 although I also tried it on Vulkan.
My camera is using Depth info.
My URP settings also has Depth enabled.
Also keep in mind that the edges work fine in the editor, when I run in the editor via Quest 2 then I see a very interesting thing, the left eye is receiving right eye’s depth and vice versa.

Please help me out :slight_smile: