Title says it all.
What's efficient way to draw a lot of textured cubes in XNA4?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
I guess it is for another minecraft-inspired game, so "a lot" means several million cubes :) Well, be it minecraft, warcraft, XNA, OGL or whatever else, the task of drawing "a lot of anything" consists of two parts:
It's possible to write an entire book about these problem facets, so let's keep it simple.
How to reduce the amount of the cubes you need to worry about? Use octrees and perform frustum culling for visibility determination.
How to optimize the draw method for lots of cubes? Large number of cubes (maybe even all of them depending on your approach) will share the same material, so it will be easy to utilize instancing.
Then again, depending on how much "a lot" actually is, you may want to stop caring about rendering optimizations at all. With the modern hardware you can draw like ten million of textured cubes easily with almost no hassle: just divide them into large chunks and draw with basic batching and a simple index buffer.
Have a look at this SunBurn instancing example: http://indiefreaks.com/2011/01/27/hardware-instancing-with-igf-sunburn-rd-part-1/ and then part 2 http://indiefreaks.com/2011/01/28/hardware-instancing-with-igf-sunburn-rd-part-2/ It handles massive amounts of instanced objects.