# Vertices in index buffer not rendered

I'm beginning with the 3D rendering in Monogame and i'm facing not a real issue because i already find a way to bypass it but more of a question. I'm rendering a simple cube with 8 vertices like that:

_vertices[0] = new VertexPositionColor(new Vector3(-1, 1, -1), Color.Red);
_vertices[1] = new VertexPositionColor(new Vector3(-1, -1, -1), Color.Red);
_vertices[2] = new VertexPositionColor(new Vector3(1, -1, -1), Color.Red);
_vertices[3] = new VertexPositionColor(new Vector3(1, 1, -1), Color.Red);
_vertices[4] = new VertexPositionColor(new Vector3(-1, 1, 1), Color.Green);
_vertices[5] = new VertexPositionColor(new Vector3(-1, -1, 1), Color.Green);
_vertices[6] = new VertexPositionColor(new Vector3(1, -1, 1), Color.Green);
_vertices[7] = new VertexPositionColor(new Vector3(1, 1, 1), Color.Green);


But i'm also using an index buffer to draw each triangle for each faces and this is where my issue is. When i'm doing the following:

_indices = new int[] // 6 faces, each containing 2 triangles of 3 vertices
{
0, 1, 2, 0, 2, 3, // front
3, 2, 6, 3, 6, 7,
4, 0, 3, 4, 3, 7,
1, 5, 6, 1, 6, 2,
4, 5, 1, 4, 1, 0,
4, 7, 6, 4, 6, 5 // back
};


The render is perfect and every edge is rendered as you can see on this gif:

https://imgur.com/h7Kn4uH

But when i changed the order inside the index buffer of the back part, like the following:

_indices = new int[] // 6 faces, each containing 2 triangles of 3 vertices
{
0, 1, 2, 0, 2, 3, // front
3, 2, 6, 3, 6, 7,
4, 0, 3, 4, 3, 7,
1, 5, 6, 1, 6, 2,
4, 5, 1, 4, 1, 0,
4, 6, 7, 4, 5, 6 // back, update is here
};


The only thing that was updated is the order of the last column and the result is the following:

https://imgur.com/aCR3QXc

Why does the render is not done on the second case when the only change made is the order of two vertices ? I know that I can do a rasterize state to render each side of a triangle but one solution is working without it, so i'd like to avoid using it.

Thanks!

• Your second example actually looks correct, given that one of your faces now has bad data. This would be expected behaviour with backface culling enabled; i.e triangles facing away from the camera are not rendered. So if your expected behaviour is to be able to see the inside of your cube, then you'll need to disable backface culling. As you do indeed note this in your question, you seem to actually understand what's happening here, and I'm not certain what your problem is. Mar 10 '19 at 12:59