3D hexagone representation with XNA

Started by
3 comments, last by reoxthen 15 years, 9 months ago
Hey guys, I'm working on a little game together with some friends and we want to integrate something like a (flat) 3D hexagonal tilemap. Our first idea was to model a 3D hexagon and display it as one tile. The problem is, we want to draw lots of them...2000+.... This ended in too many draw-calls... So we need another technique here... I thought about a heightmap, representing the environment, and our tiles represented by a huge plane in the center of that heightmap. So all tiles are at the same level. Now my idea was to map some kind of texture on it, as a kind of multi-texturing... To advance this a little, I thought about using stencil-buffers, to color over the heightmap, but this would again result in many thousand draw-calls, wouldn't it?! My last idea was to use deferred shading, because I have heard, that the geometry data is sent to the shader only once...but I don't know that much about shaders...so this could be wrong... NOW: What would you do? Do you have an idea to represent a large 3D tile map? (all tiles should be kind of outlined that you can see, where the next tile begins. And one of these tiles is always highlighted, so that the gamer knows, which tile he currently would modify...this is kind of a strategy-game... Thanks for help! Stefan
Advertisement
I don't have experience on hexagonal tiling and I'm pretty sure someone will give you a better answer but as an instant answer; your hexagon-heightmap approach might be used as:

- each pixel of heightmap represents a tile
- a tile engine produces & holds the tile nodes which contain face and vertex data, using heightmap.
- tile engine creates a vertex and index buffer using the nodes and you can draw all tiles as a single primitive in one draw call
- you can also highlight the selected tile using the buffer indices.
- you can also check the elevation difference between two adjacent tiles usign the heightmap data to create a blocking-tile logic.

sure eleminating (culling) the out-of-los tiles is the job of your tile engine again.

[Edited by - reoxthen on July 21, 2008 2:56:45 AM]
1) get all the hew textures into a single texture
2) instead of drawing hexes one by one, batch them (except the selected hex) into a vbuffer+ibuffer (as an indexed triangle list for example) and draw the bacth once.
3) draw the selected hex.

This will help you to solve your "many draw call" problem.

2000 hexes == 2000*6 triangles using 2000x6 vertices. Unless you have many different textures, you can handle this with a single draw call without any problem. A 16-bit index buffer allows you to draw more than 20,000 triangles at once - and obviously, a 32-bit index buffer will spit even more triangles.

If you don't want to batch all the textures into one single texture, you can create also draw all the hexes that use the same texture at once. The number of draw calls is then equal to the number of textures you are using.
Hey...thanks both of you!
I just want to here you opinion about whether to use dynamic oder static vertex / index buffers for your approaches...

Although my data is not updated >every< frame, I would tend to use the dynamic one, because I expect my level to be very huge...thousands of tiles...and think, it would be a bottleneck to destroy it whenever an update (change of color of one tile) comes.

Do u agree??
Quote:Original post by stefan5000
Although my data is not updated >every< frame, I would tend to use the dynamic one, because I expect my level to be very huge...


you may want to update your buffers nearly every frame in respect of culling since there will be a different set of tiles to be displayed as player moves his mouse around.

This topic is closed to new replies.

Advertisement