[SOLVED]New to 3D in Monogame, custom shader missing vertex elements

I’ve used XNA and monogame quite a lot for 2D based game design but i’ve decided to make my first 3D game. I want to use a flat shading technique for my lighting and have found a shader that should do the job (here, at the end of the thread). I’ve tried applying this effect to a cube exported straight out of Blender as an fbx. The code below is my draw code.

public override void GameDraw(GameTime gameTime) {
        GraphicsDevice.Clear(Color.CornflowerBlue);

        foreach (ModelMesh mesh in modelobject.Model.Meshes) {

            foreach (ModelMeshPart part in mesh.MeshParts) {
                part.Effect = flatShadedEffect;
                part.Effect.Parameters["View"].SetValue(camera.GetView());
                part.Effect.Parameters["Projection"].SetValue(camera.GetProjection());
                part.Effect.Parameters["World"].SetValue(modelobject.GetWorld());
            }

            mesh.Draw();
        }

    }

My issues is that when i try and run this code i get the following error:

Additional information: An error occurred while preparing to draw. This is probably because the current vertex declaration does not include all the elements required by the current vertex shader. The current vertex declaration includes these elements: SV_Position0, NORMAL0, TEXCOORD0, COLOR0.

No i’ve done a bit of digging and i think this is due to missing data in the model that i need to provide when drawing it. Can someone please point me in the direction of a solution? Or explain what i have done wrong/haven’t done and how to fix it.

Try to replace the semantic POSITION0 in the VertexShaderInput with SV_Position.

1 Like

Thanks that solved the issue!

Hi All! I hope you can me as well … I have a nice FBX model, which I convert using the Pipeline tool, but when I try to draw it the .Draw(); gives me the foloowing error:

“An error occurred while preparing to draw. This is probably because the current vertex declaration does not include all the elements required by the current vertex shader. The current vertex declaration includes these elements: SV_Position0, BLENDINDICES0, BLENDWEIGHT0, TEXCOORD0.”

Unfortunately I have no clue what to fix here. I am not using shaders for example, nothing special, just simply load a FBX model into Pipeline tool, convert it like evey other models, load it into my MonoGame game, and try to draw it.

Anyone any idea?

Thanks in advance!

Which shader do you use? The SkinnedEffect? The vertex declaration is determined by the current shader. In this case the shader requires

  • positions
  • blend indices/weights
  • texture coordinates

In your 3D modeling tool, check whether your model is exported with a skeleton for animation and UV texture coordinates.
In the MonoGame content pipeline, you need to set a content processor that supports skeletal animations. The default model processor does not handle skeletal animations.