Migrated custom effect sample problem

I am working with a migrated project from XNA, and one of the shaders is no longer working. It looks like the texcoords to the pixel shader always sample the same pixel, resulting in screen-sized output of just one color.

Effect/shader code (edited):

sampler SceneSampler : register(s0);

float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR0
{
	
    return float4(texCoord.x, texCoord.y, 1, 1); // test shows constant color

    // Look up the original color from the main scene.
    float3 scene = tex2D(SceneSampler, texCoord).xyz;
    return float4(scene, 1); // always the same color

}

// Compile the pixel shader for doing edge detection.
technique EdgeDetect
{
    pass P0
    {
        PixelShader = compile ps_4_0_level_9_3 PixelShaderFunction();
    }
}

Calling code:

 edgeDetect.CurrentTechnique = edgeDetect.Techniques["EdgeDetect"];

 spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque);

 edgeDetect.CurrentTechnique.Passes[0].Apply();
 spriteBatch.Draw(EdgeDetectSceneRenderTarget, Vector2.Zero, Color.White);
                        
 spriteBatch.End();

I am doing some render target swaps also, before and after this code. But I have verified that the texture/render target called EdgeDetectSceneRenderTarget contains actual image data.

Do you use SV_POSITION or SV_TARGET somewhere ?

No, I don’t.
I think this error occurs on all of my full-screen effects.

I found the solution here:

I had to change this:
float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR0

to:
float4 PixelShaderFunction(float4 position : SV_Position, float4 col : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0

to make it work.

I will now go over the rest of the effects files and do the same.

I had a thought about pixel shader parameters, but wasn’t certain what was actually required.

I think I have a similar problem on some of my other shaders, which don’t use SpriteBatch. They also output a single color (black). I am looking into it now.

For this effect:

 technique NormalDepth
    	{
    		pass P0
    		{

    			VertexShader = compile vs_4_0 NormalDepthVertexShader();
    			PixelShader = compile ps_4_0 NormalDepthPixelShader();
    						
    		}
    	}

I had to change this definition:

float4 NormalDepthPixelShader(float4 color : COLOR0) : COLOR0
{
	return color;
}

to this:

float4 NormalDepthPixelShader(NormalDepthVertexShaderOutput input) : COLOR0
{
	return input.Color;
}

The pixel shader input must equal the vertex shader output.