Monogame Effect/MGFX

Hello,

I’ve posted a problem here Codeplex. I’m not sure if that site is still in use for supporting monogame’s issues, so I re-post the link here. Hope someone can help me with the issue. Thank you!

Does anyone know what’s wrong with the pixel shader I posted in the link above? Thanks

Pixel Shader code:

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

struct PixelShaderInput
{
    float4 TextureCoords: TEXCOORD0;
};

float4 PixelShaderFunction(PixelShaderInput input) : COLOR0
{
	float2 texCoord = input.TextureCoords;

	float4 mainColor = tex2D(mainSampler, texCoord);
	float4 lightColor = tex2D(lightSampler, texCoord);

    return mainColor * lightColor;
}

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

Drawing code:
private void drawMain(GameTime gameTime)
{

        GraphicsDevice.SetRenderTarget(mainScene);
        GraphicsDevice.Clear(Color.Black);

        spriteBatch.Begin();

        // Draws a background image.
        spriteBatch.Draw(background, new Vector2(-300, -200), Color.White);

        // Lays out some torches based on torch positions and mouse
        foreach (var position in torchPositions)
        {
            spriteBatch.Draw(torch, position, Color.White);
        }
        spriteBatch.Draw(torch, mousePosition, Color.White);

        //// Lay out some ground.
        for (var idx = 0; idx < 25; idx++)
        {
            spriteBatch.Draw(ground, new Vector2(32 * idx, 450), Color.White);
        }

        spriteBatch.End();

        GraphicsDevice.SetRenderTarget(null);
    }

    private void drawLightMask(GameTime gameTime)
    {
        GraphicsDevice.SetRenderTarget(lightMask);
        GraphicsDevice.Clear(Color.Black);

        // Create a Black Background
        spriteBatch.Begin();
        spriteBatch.Draw(blackSquare, new Vector2(0, 0), new Rectangle(0, 0, 800, 800), Color.White);
        spriteBatch.End();

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

        // Draw out lightmasks based on torch positions.
        foreach (var position in torchPositions)
        {
            var new_pos = new Vector2(position.X - LIGHTOFFSET, position.Y - LIGHTOFFSET);
            spriteBatch.Draw(lightmask, new_pos, Color.White);
        }
        spriteBatch.Draw(lightmask, new Vector2(mousePosition.X - LIGHTOFFSET, mousePosition.Y - LIGHTOFFSET), Color.White);

        spriteBatch.End();

        GraphicsDevice.SetRenderTarget(null);
    }

    protected override void Draw(GameTime gameTime)
    {
        drawMain(gameTime);
        drawLightMask(gameTime);

        GraphicsDevice.Clear(Color.Black);

        spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
        lightingEffect.Parameters["lightMask"].SetValue(lightMask);
        lightingEffect.CurrentTechnique.Passes[0].Apply();
        spriteBatch.Draw(mainScene, new Vector2(0, 0), Color.White);
        spriteBatch.End();

        base.Draw(gameTime);
    }

This works well on Windows project. But in monogame windows store project, it doesn’t give the same result.

The only change I made to effect file in order to be loaded by monogame ContentManager"

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

See here