Difficulty with matrixs passed to shaders

Ok so i have 1 of 4 problems squashed here is the second which has me totally stumped especially since i cant see whats going on in the gpu.

Whats the difference between this bit of shader code which works.

float4x4 gworldviewprojection;

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    // regular________________
    VertexShaderOutput output;
    output.Position = mul(input.Position, gworldviewprojection);
    output.Color = input.Color;
    output.TexureCoordinate = input.TexureCoordinate;
    //________________________
    return output;
}

And this which doesn’t.

the matrix’s appear in the xnb i would think this would work.
but i get nothing cornflower blue.

float4x4 world;
float4x4 view;
float4x4 projection;

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    // ________________
    VertexShaderOutput output;
    float4x4 vp = mul(view, projection);
    float4x4 wvp = mul(world, vp);
    output.Position = mul(input.Position, wvp);
    output.Color = input.Color;
    output.TexureCoordinate = input.TexureCoordinate;
    //________________________
    return output;
}

The order of multiplication order is important,

If you multiply position with world, then with view then with projection it will work.

Edit: actually your code should work i think

I used to pass all 3 matrices before and it should be no problem.
Maybe you don’t pass the updated matrices or something

That or something else is going on what i have no clue.

because this worked i manually set up the perspective matrix set the view to identity, redid the shader again and all of a sudden its working.
but i have no idea why it didn’t work before.

Though the width height is now messed up i dunno.

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    // ________________
    VertexShaderOutput output;

    float4x4 vp = mul(view, projection);
    float4x4 wvp = mul(world, vp);
    output.Position = mul(input.Position, wvp);

    output.Color = input.Color;
    output.TexureCoordinate = input.TexureCoordinate;
    return output;
}

1 unit length centered quad

public void DrawEffectAOrtho(float xpos, float ypos, float width, float height)
        {
            world = Matrix.CreateScale(new Vector3(width, height, 1f));
            world.Translation = new Vector3(xpos, -ypos, 1f);
            //
            view = Matrix.Identity;
            //
            projection.M11 = 2f / (float)(graphics.GraphicsDevice.Viewport.Width);
            projection.M22 = 2f / (float)(graphics.GraphicsDevice.Viewport.Height);
            projection.M33 = 1f;
            projection.M44 = 1f;
            //
            GetConsoleInfoJustOnce();
            //
            TestEffectA.Parameters["world"].SetValue(world);
            TestEffectA.Parameters["view"].SetValue(view);
            TestEffectA.Parameters["projection"].SetValue(projection);
            foreach (EffectPass pass in TestEffectA.CurrentTechnique.Passes)
            {
                pass.Apply();
                GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, 4, indices, 0, 2);
            }
        }

if i try sending all 3 in like so i get nothing

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
// ________________
VertexShaderOutput output;

float4 w = mul(world, input.Position);
float4 wv = mul(w, view);
output.Position = mul(wv, projection);
output.Color = input.Color;
output.TexureCoordinate = input.TexureCoordinate;
return output;

}

The correct order is world, view, projection.

                Matrix worldViewProjection;
                
                Matrix.Multiply(ref world, ref view, out worldView);
                Matrix.Multiply(ref worldView, ref projection, out worldViewProjection);
                
                worldViewProjParam.SetValue(worldViewProjection);

Also I don’t know exactly what is your goal here. Sure doesn’t seem like it is to create a game. I suggest you consult computer graphics material on coordinate systems. There are tons of resources out there on the Internet or in textbooks. A quick search even found a good article: http://www.codinglabs.net/article_world_view_projection_matrix.aspx

If you look at the very top post you’ll see were my problem started i was trying to do just as you describe but within the gpu.

Initially i was going to see if i couldn’t recode reimers xna shader for monogame that uses the world view perspective matrixs and transforms inside the shader as well as orthographic.

Though ultimately id like to see if i can’t move the vertexs in the vertex shader individually. But i kinda got side tracked with the shader under orthagraphic not behaving the way i expected it to and doing some other weird things when passing in the matrixs.

In manually calculating the numbers on the cpu side before i pass them to the gpu, they weren’t matching the results expected, the matrixs mults and transforms that i was seeing. So i was trying to get a better grasp on what i was misunderstanding.