Sign in to follow this  
AvengerDr

Best way to render a lot of slightly different objects?

Recommended Posts

Hi,

I am building an information visualization system similar to a 3D treemap (i.e.: using stacked boxes to represent the proportional size of nodes in a tree). So basically I need to render a lot of 3D boxes. What techniques can I use to improve performance, beside occlusion culling?


Right now, being a prototype, I'm using a very brute force approach: every object has its own VB/IB etc. So when I have to render several hundreds of them, things begin to slow down. I was thinking about having only one VB/IB and just modify the translation and scaling matrices (to obtain different sizes). Is there any other better way?

Share this post


Link to post
Share on other sites

What techniques can I use to improve performance, beside occlusion culling?

Instancing is the way to go. There are several techniques available, here's an article to get a basic understanding of instancing and different techniques to archieve it (the article is ~7 years old, using modern API like DX11 will ease instancing a lot).

Edited by Ashaman73

Share this post


Link to post
Share on other sites

I was thinking about having only one VB/IB and just modify the translation and scaling matrices (to obtain different sizes).

That is definitely the first step you should take. Rendering all from one vertex/index buffer is going to be faster than switching buffers for each object.

 

After that, you should be in good shape to tackle instancing, which should be ideally suited to your use-case.

Share this post


Link to post
Share on other sites
I agree, a few pointers:

- create separate classes for mesh and meshinstance
- keep track of all properties per instance, rotation, translation, scale, material maybe
- make an index and render by material and then by mesh

Ealrly rejections of meshes you wont't draw is always best and reduces state and buffer changes

Share this post


Link to post
Share on other sites

You may also make some per-instance parameters affect the material. If the differences between the boxes are small (such as diffuse color changes), you may have a diffuse color as a instance parameter. If you are able to use texture array, it is possible to have per-instance index to the texture array slice so you can actually have a lots of variation for each instance.

 

Cheers!

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