Sign in to follow this  
Ebola0001

is swarm rendering a model worth it?

Recommended Posts

Strange way to phrase the question, but I didn't know what else to call it.. The question comes from rendering large numbers of low face count objects. (4 to 20 faces) and the question is would it be more efficient to just render them as seperate mesh objects or to make a supermesh where it is one call to a mesh with all the sets of faces moved as individual objects If I am not explaining it well enough I'll try to make a graphic describing it.

Share this post


Link to post
Share on other sites
Your talking about stuffing a whole heep of models into a single buffer.

Not a bad idea, but there will be some sort of limit as to how effective it is.
I would suggset profiling it, to find out at what point managing the buffer overrides just blasting smaller buffers.

If your able to use shaders, and are blasting a singel type of mesh, you might want to check out HLSL instancing. There is a tut in the DX docs. (there should also be an open GL equivilent.

Armand

Share this post


Link to post
Share on other sites
Amand is correct, you should never draw just 4-20 faces per draw call if you can avoid it. The break-off point where making the draw call actually takes longer than the GPU drawing the actual faces depends on your hardware and renderstates, but on most modern hardware is around 500-2500 faces.

If you don't plan to target SM3.0 HW, you can try shader instancing instead of hardware instancing. It's works similar to skinned meshes: for each vertex you store an index into a list of matrices, specifying which of the matrices should be used to transform that vertex.

That way you can duplicate the object a number of times (say 8 for example) in the vertex buffer, and specify a different index for each object, so that all the vertices in first object have index 0, in the next all have index 1, etc. Your vertex shader has to be modified to use an indexed array of matrices, but that's really simple, similar to changing mul( pos, xform ) to mul( pos, xform[index] ).

Now you can send a bunch of matrices to the shader at the same time, and draw all objects in just one draw call. The nice thing is that it works for even the lowest shader models, so even GeForce3/Radeon 8k-class cards can use it. You can control the number of objects being drawn (1-8 in the example)simply by adjusting the number of primitives-parameter of IDirect3DDevice9::DrawIndexedPrimitive() to num_objects*num_prims_per_object (or similar in OpenGL).

Hope this helps!

Cheers,
Simon

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