Help getting a simple effect running on win7 gl, build 3_6_70_99

Ok i haven’t done any shader stuff with spritebatch in monogame so i basically wanted to give it a shot. I used yesterdays build, created a default fx using the pipeline tool, added a image and a sprite font, dropped in the basic code i thought used to work in 4.0 but, Im getting nothing drawing. The background is cleared but text and image disappear…

What am i missing here ?

`    public class Game1 : Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        SpriteFont myfont;
        Effect myeffect;
        Texture2D tpic01;
        
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            myfont = Content.Load<SpriteFont>("MyFont");
            myeffect = Content.Load<Effect>("MyEffects");
            tpic01 = Content.Load<Texture2D>("tpic01");
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            //spriteBatch.Begin();
            
            // drop in my effect and text and image disappear.

            spriteBatch.Begin(0, BlendState.NonPremultiplied, null, null, null, myeffect);       
            spriteBatch.Draw(tpic01, new Rectangle(100, 100, 300, 300), Color.White);
            spriteBatch.DrawString(myfont, "hello", new Vector2(20, 20), Color.AntiqueWhite);
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }

, the basic stuff the pipeline tool outputs for a fx file it shouldn’t change anything
`

    SV_POSITION POSITION
    VS_SHADERMODEL vs_3_0
    PS_SHADERMODEL ps_3_0
matrix WorldViewProjection;

struct VertexShaderInput
{
    float4 Position : SV_POSITION;
    float4 Color : COLOR0;
};

struct VertexShaderOutput
{
    float4 Position : SV_POSITION;
    float4 Color : COLOR0;
};

VertexShaderOutput MainVS(in VertexShaderInput input)
{
    VertexShaderOutput output = (VertexShaderOutput)0;

    output.Position = mul(input.Position, WorldViewProjection);
    output.Color = input.Color;

    return output;
}

float4 MainPS(VertexShaderOutput input) : COLOR
{
    return input.Color;
}

technique BasicColorDrawing
{
    pass P0
    {
        VertexShader = compile VS_SHADERMODEL MainVS();
        PixelShader = compile PS_SHADERMODEL MainPS();
    }
};`

Try using only a pixelshader. Spritebatch will handle the WVP matrix for you. Or set the matrix as it is done in SpriteEffect.

Edit: lol never mind doh, i just realized why there is a effect and spriteeffect option in the pipeline tool menu i thought that was some sort of bug didn’t realize one was for spriteBatch and the other for 3d drawing.

Ya i do want to be able to alter the vertices using the shader, Ill give what you posted below a shot.

This is the one for spritebatch has the sampler state set up.

    define SV_POSITION POSITION
    define VS_SHADERMODEL vs_3_0
    define PS_SHADERMODEL ps_3_0

Texture2D SpriteTexture;

sampler2D SpriteTextureSampler = sampler_state
{
    Texture = <SpriteTexture>;
};

struct VertexShaderOutput
{
    float4 Position : SV_POSITION;
    float4 Color : COLOR0;
    float2 TextureCoordinates : TEXCOORD0;
};

float4 MainPS(VertexShaderOutput input) : COLOR
{
    return tex2D(SpriteTextureSampler,input.TextureCoordinates) * input.Color;
}

technique SpriteDrawing
{
    pass P0
    {
        PixelShader = compile PS_SHADERMODEL MainPS();
    }
};`

If you also want to do stuff in the vertex shader you need to set the matrix like in SpriteEffect for it to work. SpriteBatch doesn’t do this because it expects the effect to handle it.

var projection = Matrix.CreateOrthographicOffCenter(0, viewport.Width, viewport.Height, 0, 0, 1);

really weird i cant tell whats going on if its getting the matrix or not.
Just having the line in the shader that takes the matrix is causing nothing to draw

in load…

projectionOrth = Matrix.CreateOrthographicOffCenter(0, this.GraphicsDevice.Viewport.Width, this.GraphicsDevice.Viewport.Height, 0, 0, 1);

in draw…

spriteBatch.Begin(0, BlendState.NonPremultiplied, null, null, null, myspeffect, projectionOrth);

in the shader now.

`Texture2D SpriteTexture;

matrix WorldViewProjection; // test

sampler2D SpriteTextureSampler = sampler_state
{
    Texture = <SpriteTexture>;
};

//
struct VertexShaderInput
{
    float4 Position : SV_POSITION;
    float4 Color : COLOR0;
    float2 TextureCoordinates : TEXCOORD0;
};

struct VertexShaderOutput
{
    float4 Position : SV_POSITION;
    float4 Color : COLOR0;
    float2 TextureCoordinates : TEXCOORD0;
};


VertexShaderOutput MainVS(in VertexShaderInput input)
{
    VertexShaderOutput output = (VertexShaderOutput)0;

    output.Position = mul(input.Position, WorldViewProjection);
    output.Color = input.Color;
    output.TextureCoordinates = input.TextureCoordinates;

    return output;
}

float4 MainPS(VertexShaderOutput input) : COLOR
{
    return tex2D(SpriteTextureSampler,input.TextureCoordinates) * input.Color;
}

technique SpriteDrawing
{
    pass P0
    {
        VertexShader = compile VS_SHADERMODEL MainVS();//
        PixelShader = compile PS_SHADERMODEL MainPS();
    }
};`

This won’t work because the matrix you pass in spriteBatch.Begin is applied in the vertex shader of SpriteEffect. Since you use your own vertex shader, this doesn’t do anything. Instead you should set the matrix in your effect so it does what the SpriteEffect vertex shader normally does.

myEffect.Parameters[“WorldViewProjection”].SetValue(projectionOrth);