Triangles appear transparent under certain angles

Hi guys, I’ve started using MonoGame over the weekend and I love it! After doing the Hello World of graphics programming, I want to dive a little deeper. I have implemented the diamond square algorithm to procedurally generate some low poly terrain. I generate a heightmap and then group three of the vertices to a triangle together. It works like a charm, except that some of my triangles, usually high ones, appear transparent under certain camera angles.

Video where it shows the problem

Because of the way I numbered the triangles in my head, I had to flip every other triangles normal, because it appeared only black. But in the video, it doesn’t seem to follow a pattern, other than its the highest triangles that have this transparency problem. Now that I think about it. The “highest” triangles are the only ones that are in front of other triangles. So is this maybe a problem of the order I draw the triangles in?
Does someone have an idea where this problem might come from? Is it a lighting problem? Or is it the Normals?

These are my lighting settings:

basicEffect = new BasicEffect(GraphicsDevice)
            {
                Alpha = 1.0f,
                VertexColorEnabled = false,
                LightingEnabled = true,
                DiffuseColor = new Vector3(0.949f, 0.854f, 0.431f),
                SpecularColor = new Vector3(0.2f, 0.2f, 0.2f),
                SpecularPower = 5f,
                //AmbientLightColor = new Vector3(0.5f, 0.5f, 0.5f),
                Texture = Content.Load<Texture2D>("terrain_texture"),
                TextureEnabled = true,
            };
            basicEffect.DirectionalLight0.Direction = Vector3.Normalize(new Vector3(1, -1, 0));
            basicEffect.DirectionalLight0.DiffuseColor = Color.Yellow.ToVector3();
            basicEffect.DirectionalLight0.SpecularColor = Color.Red.ToVector3();
            basicEffect.DirectionalLight0.Enabled = true;

try

        GraphicsDevice.RasterizerState = RasterizerState.CullNone;
        GraphicsDevice.DepthStencilState = DepthStencilState.Default;
        GraphicsDevice.BlendState = BlendState.Opaque;
        
        //GraphicsDevice.Draw......

This worked perfectly, thank you very much, PumpkinPudding!

GraphicsDevice.DepthStencilState = DepthStencilState.Default;

I guess this line is telling the graphics card to draw only the vertices that are nearest to the camera? I wonder why, as I didn’t specify a DepthStencilState, it didn’t use the default one. That’s kinda the point of a default setting, isn’t it? :smiley:

GraphicsDevice.BlendState = BlendState.Opaque;

what does this line do? I don’t really notice a different.

spritebatch
here…

Oh wow, I would have never guessed the 2D text is the cause.
Thanks mate, I appreciate it.