Issues with models not showing in the right way

I’ve made a model in Blender and imported it to Monogame with Aether.Extras CPU_AnimatedModel.

Then I’m drawing the model through this method:

public void DrawModelCameraFromList(FirstPersonCamera camera, IEnumerable<Entity> entities)
        {
            foreach (Entity entity in entities)
            {
                Matrix[] transforms = new Matrix[entity.Model.Bones.Count];
                entity.Model.CopyAbsoluteBoneTransformsTo(transforms);

                foreach (ModelMesh mesh in entity.Model.Meshes)
                {
                    foreach (ModelMeshPart part in mesh.MeshParts)
                    {
                        ((BasicEffect)part.Effect).SpecularColor = Vector3.Zero;

                        ConfigureEffectMatrices((IEffectMatrices)part.Effect, Matrix.CreateRotationY(entity.Rotation.Y) * entity.RenderCollisionPositionMatrix, camera.View, camera.Projection);
                        ConfigureEffectLightning((IEffectLights)part.Effect);

                        if (entity is AnimatedEntity animatedEntity)
                            part.UpdateVertices(animatedEntity.Animations.AnimationTransforms);
                    }

                    mesh.Draw();
                }
            }
        }

The models are drawn, and the animation are looping, but the models different parts overlap each other, and the eyes and nose are shown from behind.

From front:

From behind:

I am also running this code every Update:

graphicsDevice.BlendState = BlendState.Opaque;
graphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
graphicsDevice.DepthStencilState = DepthStencilState.Default;
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

Need some tips how to fix this problem. :slight_smile:

My best guess is that you’re changing the value of your DepthStencilState somewhere else before you draw your model.

It might be worth noting that the InfiniteGridComponent in Aether.Extras will actually change it to DepthStencilState.None every time you call Draw() on it. I don’t see the infinite grid drawn in your pics, but something similar may be going on here.

1 Like

Thank you for pointing that out!

Seems like I was setting PreferredDepthStencilFormat = DepthFormat.None when initiating the Game1 class. (I got this from another tutorial I was following, wish I knew the reason as to why it was used there…)

After removing it, the models are rendered the right way.

Thanks!