Try to send a value in post-processing Shader to C# script

Hi, I’m using scriptable render pipeline asset to find a specific pixel on camera render UV.

So I made a shader code, which find pixel’s uv coordinate if it’s color is red.

I found that it works as I added a code to change the pixel’s color to green if it’s red.

But when I tried to get that pixel’s uv coordinate, it always be (0,0).

Does anyone know why it is always (0,0), and how I can solve this problem?

I used the shader code below (find red and save it’s coordinate then turn in to green)

        HLSLPROGRAM
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
        #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"

        #pragma vertex Vert
        #pragma fragment frag

        TEXTURE2D_X(_CameraOpaqueTexture);
        SAMPLER(sampler_CameraOpaqueTexture);

        float _Scale;
        float _BIdistance;
        float GroupSize;
        bool AdjustingEye;
        float GazeUV_Found_x;
        float GazeUV_Found_y;
         

        half4 frag (Varyings input) : SV_Target
        {
            UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);

            float2 uv = input.texcoord;
            float2 texelSize = 1.0 / _ScreenParams.xy;

            float4 colorCenter = SAMPLE_TEXTURE2D_X(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, uv);

            if ((colorCenter.r >= 0.7) )
            {
                GazeUV_Found_x = uv.x;
                GazeUV_Found_y = uv.y;
                return float4(0, 1, 0, 0);

            }
            else{
                GazeUV_Found_x = 0.5;
                GazeUV_Found_y = 0.5;
            }

            return colorCenter;

        }

        ENDHLSL
    }
}

and used this code to try to get that uv coordinate.

void Update()
{
    float GazeUV_x = material.GetFloat("GazeUV_Found_x");
    float GazeUV_y = material.GetFloat("GazeUV_Found_y");
    Shader.SetGlobalFloat("GazeUV_x", GazeUV_x);
    Shader.SetGlobalFloat("GazeUV_y", GazeUV_y);

    Debug.Log("GazeUV_x: " + GazeUV_x + " GazeUV_y: " + GazeUV_y);
}