Performance issues with grid based terrain

Hello! I’m making a turn based strategy game with a grid-style combat arena (think Final Fantasy Tactics/Civilization). Each arena is a grid of cubes, which can vary in size from 8x8x3 to 40x40x3. This works fine up to about 20x20x3, where I notice some significant frame drops. Some comparisons are below;

10x10x1 - ~80fps   5.6k  Tris    12k    Verts   1000  Draw Calls
20x20x1 - ~55fps   22.4k Tris    50.4k  Verts   4000  Draw Calls
30x30x1 - ~26fps   50.4k Tris    113.4k Verts   9000  Draw Calls
40x40x1 - ~15fps   89.6k Tris    201.6k Verts   16000 Draw Calls

Using just a simple base. All blocks use the same five materials (One for the top, one for the bottom, one for the four sides near the top, one for the four sides in the middle, and one for the four sides towards the top). In the actual game, I plan on there being many more materials being capable of being used, this is just for the above performance test.

I’m aware of texture batching, but haven’t been able to get it to work. My levels are instantiated from code, so this may be the cause. If it’s not possible to get texture batching to work in that circumstance, I can look into other options.

Here is the primary code I am using to instantiate the base of the level;

function MakeBase()
{
    for(var j=0;j<boardSize.x;j++)
	{
		for (var k=0;k<boardSize.y;k++)
		{
			var block = Instantiate(boardPiecePrefab, Vector3(j,-1,k), Quaternion.identity);
			floorPieces[j][k][0] = block as Transform;
		}
	}
}

If anyone has any suggestions on how I can improve performance or get texture batching to work properly, I would be very appreciative.

Thanks,
Brandon

To reduce the number of draw calls, you’re going to need static batching. Static batching is an optimization that is applied in the Editor. If you instantiate the environment at run-time, you’ll loose static batching on those objects. Additionally, if you modify the object by swapping or otherwise modifying any property of the object’s materials, you’ll also loose static batching.

IMO, you really shouldn’t use cubes.
Instead, you should create “cube looking” mesh instead.
(think of mine craft, having millions of “cubes”)

I’m working on a project which uses that type of world generation, and with that system, 40x40x3 should be like 4 draw calls. (say 10x10x3 being one chunk)