Sign in to follow this  
coder13

Most efficient method to render a bunch of cubes?

Recommended Posts

Hello, I have been troubled by this for quite a bit. I understand some basics to rendering a cube. So I would just put it in a class, then come render time, just translate it depending on its location. I was wondering if this is the most efficient way to to render a bunch of cubes?

Share this post


Link to post
Share on other sites
No, it's not the best way. In fact, that will be extremely slow. You want to reduce your total number of draw calls. Drawing each cube individually results in a LOT of draw calls. You want to cull the non-visible cubes so that they are not drawn at all, cull the non-visible faces, and batch up the visible faces into as few draw calls as you can manage. You might want to check out [url="http://www.sea-of-memes.com/LetsCode1/LetsCode1.html"]this series of articles[/url] by a guy named Michael Goodfellow, written as he worked his way through this same thing.

Share this post


Link to post
Share on other sites
Hello coder
Maybe could you be interested by [url="http://en.wikipedia.org/wiki/Geometry_instancing"]geometry instancing[/url] ?
This way, you provide the mesh of the cube (only once) and the world matrices of all the instances (and eventually other data you need for rendering each instance).
With this technique all the cube instances would be rendered within a single draw call.

Sorry I can't be more specific, I only use DirectX10 [img]http://public.gamedev.net//public/style_emoticons/default/unsure.png[/img] , but I'm sure you'll find easily some documentation on OpenGL instancing [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]
Bye

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this