# LWJGL 3 - problem with flickering when rendering terrain with colors

For while now I m trying to built a terrain generator for my game engine and again I'm stuck with problem.

I'm trying to generate a terrain using colors, so no textures. In short my problem is flickering. Hope this pictures will describe better my problem.

The way I'm generating this is using shared vertices. If I'm generating 2*2 terraing, I'm actually only creating 9 points. Something like this.

For color , I made that every second point will get slightly darker green.

When I add height generation, there is no flickering.

EDIT: It probably got something to do with using shared points. I now tried using all unique points for each square and no flickering.

EDIT: I found was the cause. I was generating indices wrong way.

    public void generateSharedIndices(int rowVertices,int columnVertices){
for(int row = 0; row < rowVertices - 1 ; ++row){
for(int column = 0; column < columnVertices -1 ; ++column){
int leftDownPoint = ((row * columnVertices) + column);
int rightDownPoint = leftDownPoint + 1;
int rightUpPoint = rightDownPoint + columnVertices;
int leftUpPoint = rightUpPoint - 1;

}
}
}


In the end indices should look like this ( 0 1 5 5 4 0 ) ( 1 2 6 6 5 1 ) ( 2 3 7 7 6 2 ) ( 4 5 9 9 8 4 ) but I made mistake and it was generating them wrong.

• You need to show us some code, so we can at least guess where you went wrong – Bálint Aug 3 '19 at 23:27
• Thank you I thought problem was somewhere in some opengl flag that I forgot to turn on or off, but the moment I saw this comment I knew I made some mistake in my code for generating terrain. – Filip Cacic Aug 4 '19 at 16:17