Sign in to follow this  
beebs1

Instancing?

Recommended Posts

Hiya, I've been thinking about using instancing in my renderer, and I was wondering if anyone can comment on my plan? Say I have 50 identical trees in a scene, all with different positions and rotations. When they are drawn, each tree object will put a handle to the vertex/index buffers they use into a render queue, along with a material ID. This queue is then sorted, so that these 'render-commands' all end up together in the queue. I'm thinking of extending this, so that the renderer can determine that several queued objects are the same, and draw them all in one call using hardware instancing. This should result in fewer API drawing calls, and should be more efficient... *crosses fingers* I've been looking through the Direct3D docs, but my understanding of instancing is still a bit dodgy so - does this sound like a good idea? Apparently I'll need to create a new vertex buffer every frame to hold the per-instance data, which is my main concern (speed-wise). Can anyone comment? Many thanks in advance [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by beebs1
Say I have 50 identical trees in a scene, all with different positions and rotations. When they are drawn, each tree object will put a handle to the vertex/index buffers they use into a render queue, along with a material ID. This queue is then sorted, so that these 'render-commands' all end up together in the queue.

I'm thinking of extending this, so that the renderer can determine that several queued objects are the same, and draw them all in one call using hardware instancing. This should result in fewer API drawing calls, and should be more efficient... *crosses fingers*
Rather than trying to reconstruct instancing late in the pipeline, it would be better to have a 'Forest' class, which holds all the trees, and can tell the renderer to render all the visible trees as a single instanced batch.

Share this post


Link to post
Share on other sites
Thanks for your reply.

I think you're right. I'll try to think of a more general solution which works as you say.

Maybe I could replace the render-queue with a queue of instance-groups. If I sort this, then I can still take advantage of any coherency between materials, textures, etc - but each queued-item would represent more than one object to be draw.

I'm not sure how I'd construct the queue given that objects can drawn by the client in any order, without doing it late during rendering. Could you elaborate a little?

I wonder, is there any performance hit for using hardware-instancing to draw just one instance? I might some objects to drawn in the normal way if there's only one of them.

Thanks for your input.

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