Heightmap confusion

I just noticed something today with my heightmap, and I'm hoping someone can explain it to me. 

I made a 400 x 400 px heightmap, all middle greyish so it's flat.  When I check the dimensions it turns out to be 318402 triangles… 399 x 798, yet it looks like a square.  Can someone tell me why it would be using more triangles in one direction than the other, and also why it seems to be a square when technically it should be a rectangle - since each two triangles seem to form a square if I zoom in close enough.


Try pressing 't' if you are using SimpleGame or DebugGameState to toggle wire frame and check in detail what is going on.

I'm actually working in StandardGame in wireframe mode.  I've done everything possible to verify my findings were correct, including drawing lines to different points on the TerrainBlock to verify that the size it was reporting included the entire block I was looking at on the screen.

Somehow my 400 x 400 px heightmap does indeed get loaded into the TerrainBlock as a 399 x 798 triangle map that looks square.  I am using the ImageBasedHeightMap to read the heightmap into the TerrainBlock.  Let me know if you need to see any of the code.  I just figured there was a standard reason for it that I just wasn't comprehending since I am not that familiar with 3D graphics.

It may be that part of the terrainpage is outside of the frustrum and is being culled at the point of when you measure how many triangles it contains.

Ensure you can see the whole terrain page when taking triangle counts

Well, it might simply be the following:

You need (n-1)(n-1) squares to cover the area of a nn vertices in a latice. For instance: if you had a 3*3 latice:

| | |
| | |

You only need 4 squares... and if you calculate triangles, well:


You need 2 rows of 4 triangles each.... Extrapolating: You need 399 rows of 798 triangles each for your terrain to be 400*400.

Oh now I feel stupid - I need to draw myself pictures instead of trying to work it out in my head I guess :stuck_out_tongue:

Thanks duenez


I went lol when I read the 'solution'