0
\$\begingroup\$

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.

enter image description here

enter image description here

enter image description here

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.

enter image description here

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

When I add height generation, there is no flickering.

enter image description here

enter image description here

enter image description here

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

enter image description here

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;

            addNewValueToCurrentPointer(leftDownPoint);
            addNewValueToCurrentPointer(rightDownPoint);
            addNewValueToCurrentPointer(rightUpPoint);
            addNewValueToCurrentPointer(rightUpPoint);
            addNewValueToCurrentPointer(leftUpPoint);
            addNewValueToCurrentPointer(leftDownPoint);
        }
    }
}

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.

\$\endgroup\$
  • \$\begingroup\$ You need to show us some code, so we can at least guess where you went wrong \$\endgroup\$ – Bálint Aug 3 at 23:27
  • \$\begingroup\$ 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. \$\endgroup\$ – Filip Cacic Aug 4 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.