Collect Draw Calls

Jun 11, 2010 at 10:09 PM
Edited Jun 11, 2010 at 10:13 PM
Hey there, I switched to normal terrain (heightmap based) for a reason of simplicity and texturing and have a new problem now. I got a class name TiledTerrain, which handels a number of TerrainTiles and cull them before drawing. The problem is now that i get a lot of drawcalls when using this technique. I would like to know if there is a method to "collect" the tiles to be drawn (in a list or something like this) and draw them at once. The draw code looks like this at the moment.
 public void Draw(DrawState state)
            //push the world matrix, multiplying by the current matrix if there is one
            state.PushWorldMatrixMultiply(ref worldMatrix);
            foreach (TerrainGeometry g in geometry)
                //cull test the custom geometry
                if (g.CullTest(state))
                    //bind the shader

                    //draw the custom geometry
            //always pop the matrix afterwards
king regards floAr
Jun 11, 2010 at 11:39 PM
Edited Jun 11, 2010 at 11:40 PM

How many tiles are you drawing?

If it's a lot, then the simpler answer may be to make the tiles bigger. Typically, if your draw call is less than ~4,000 triangles then chances are you'll be CPU bound. At least double this number on the 360, where the GPU is a geometry monster - and the CPU is obviously severely limited by the compact framework.

You may find that simply drawing the terrain in one huge batch is actually faster :-)

Jun 12, 2010 at 9:06 AM
Edited Jun 12, 2010 at 9:09 AM

I testet some tile numvers this morning and in seems to run smoother than yesterday =) dont know why -.-

here are my results

Nr.tiles | FrameR | DrawCalls

1x1 | 45 | 0-1

5x5 | 45-58 | 0-25

10x10 | 45-59 | 0-100 //never really reaches 100 because of the clip plane

25x25 | 56 | 0-625 //56 frames are nearly constant and i reach about 500 draw calls when moving over terrain

so for me it seems 25x25 patches are the best solution.. if i increase the number framerate drops (bevause of culler.BoxTest i think) the only bad think is that the game freezes fro am momen when i first look at the terrain.

to explain this: terrain starts at Vectro3.Zero and camera start with looking at this point from some high. so when i start the game i can just see a small amount of the terrain. when i know move the camerea up to capture the whole thing the game freezes fro a moment, and the more tiles i got , the longer this moment last. any ideas on that?