Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Title says it all.

What's efficient way to draw a lot of textured cubes in XNA4?

share|improve this question
6  
This seems very broad. Have you tried anything yet? Did you try to do it yourself and it's working too slowly? –  Richard Marskell - Drackir Aug 5 '11 at 2:23
1  
How many is "a lot"? A thousand and a million are both "a lot" to draw. Expanding on what Drackir said, what is your current approach and what is wrong with it? –  doppelgreener Aug 5 '11 at 3:12
    
This question is probably a good place to start. –  Andrew Russell Aug 5 '11 at 6:09
    
The answer will always boil down to the same thing : Instancing. Whether that's hardware instancing, or shader instancing, or transforming everything on the cpu and cramming it into a big vertex buffer, it'll still be : Instancing. –  Blecki Aug 5 '11 at 12:38
    
See also –  BlueRaja - Danny Pflughoeft Aug 7 '11 at 5:26

2 Answers 2

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:

  • Reducing the size of the task.
  • Making the actual drawing efficient.

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.