Simple Custom Render Pass in URP (Invert colors)

Hello, I followed this simple tutorial to write a basic Custom render pass in URP:

The tutorial uses a Shadergraph material, while I wanted to write by hand the shader. I used this HLSL shader to invert screen colors:

Shader "Custom/_RenderPassInvertH"
{
    Properties
    {
        _MainTex ("Main texture", 2D) = "white" {}
    }

    Subshader
    {
        Tags
        {
            "RenderPipeline"="UniversalRenderPipeline" "Queue" = "Opaque"
        }

        Pass
        {
            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma target 3.0

            #include "HLSLSupport.cginc"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

            uniform sampler2D _MainTex;
            uniform float4 _MainTex_ST;

            struct vertexInput
            {
                float4 vertex : POSITION;
                float4 texcoord : TEXCOORD0;
            };
            struct vertexOutput
            {
                float4 pos : SV_POSITION;
                float4 texcoord : TEXCOORD0;
            };

            vertexOutput vert(vertexInput v)
            {
                vertexOutput o;
                o.pos = TransformObjectToHClip(v.vertex);
                o.texcoord.xy = v.texcoord.xy;
                return o;
            }
            half4 frag(vertexOutput i): SV_Target
            {
                half4 texColor = tex2D(_MainTex, i.texcoord);
                return half4(1-texColor);
            }

            ENDHLSL
        }
    }
}

Everything seems to work, but the Game view output is flipped on the y axis (while Scene view is correct), like you can see in the attached image.

Where am I wrong?

Thanks

7940440--1018855--flip.jpg

Anyone?

at least unity has this define, could try:
#if UNITY_UV_STARTS_AT_TOP

An easy fix is in your shader change this line:
half4 texColor = tex2D(_MainTex, i.texcoord);
to:
half4 texColor = tex2D(_MainTex, float2(i.texcoord.x, 1.0-i.texcoord.y));

That should invert the uvs in Y direction.

the logical part:
#if UNITY_UV_STARTS_AT_TOP && !SHADER_API_METAL
i.uv.y = 1 - i.uv.y;
#endif

I tried your suggestion: now the gameView is correct, the scene view isn’t (see the attached img). They still are flipped! Why is this happening? Is it possible that scene view and gameview uses different y texture coordinates?

7956237--1019358--flip2.jpg

Anyone? Maybe it is a Unity bug? I’m using 2021.2.7f1