Effect : TEXCOORD0 not interpolated ?

I have a custom effect who manage lighting on my 2D scene with a mask. The effect worked perfectly on XNA but since I used it with MonoGame, it gives me only black screens and by moment gray or white screens.

I have used RenderDoc for proceed to a graphic debug. Everything is okay except that my TEXCOORD0 give a [0,0] vector for all the pixels. So it process only with the first pixel of my textures and apply the result on all screen.

I read and tested a lot of things but I can’t understand why my TEXCOORD0 isn’t interpolate. I’m quite a novice with shaders so I’ll be glad if someone can answer my problem.

Here is the .fx file :

texture lightMask;
sampler mainSampler : register(s0);
sampler lightSampler = sampler_state{ Texture = lightMask; };

float4 PixelShaderFunction(float2 TexCoord : TEXCOORD0) : COLOR
{
    float4 mainColor = tex2D(mainSampler, TexCoord);
    float4 lightColor = tex2D(lightSampler, TexCoord);

    return mainColor * lightColor;
}

technique Technique1
{
    pass Pass1
    {
        PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
    }
}

I guess you are using SpriteBatch to draw. Your pixel shader function signature has to be this:
float4 PixelShaderFunction(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0

1 Like

It works perfectly. Thanks a lot. :slight_smile:
Are there other aspects where MonoGame differs from XNA on effects ?