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.