Using mesh subsets vs. a single mesh

Started by
7 comments, last by mrheisenberg 11 years, 5 months ago
Which do you think is the better choice to implement?The way I see it - using a single vertex buffer is the easier way,cause it's easier to texture and easier to organize shaders in the render loop according to materials.However,with splitting the mesh into subsets,you can have for instance a character getting his limbs blown off,but then it sounds like it'll be hell for the artist and for organizing batching when rendering.
Advertisement
The better choice is the one that best meets the objectives you wish to achieve. If you want limbs blown off then you will have to compromise.

One potential compromise is a layout that allows the mesh to be contained in a single buffer, and drawn with a single call, but with which components of the mesh also have their own separate ranges within that buffer. So, for example, elements 0...127 of the buffer may be a left leg, 128...256 a right leg, and so on. That would let you draw either the entire mesh or individual components as you wish, but at a cost of some vertex duplication.

As always, there is no absolute right answer to this. You pick the solution that does what you need.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

You can blow the limbs off a character and still draw him in one DrawIndexed.

1. Give him a skeleton and assign different vertices.
2. Separate the elements of the mesh that you want blown off. Eg, make sure there are no faces connecting vertices from the arm to vertices of the shoulder etc.
3. When the arm gets shot (or chopped with an axe, samurai sword etc), mark the arm's skeleton joint (or bone) as "Separated"
4. When you collapse the bone transforms, any bones marked as "Separated" should have their world transforms calculated separately. Eg you could use a physical simulation to provide the transforms from then on.

I understand this is a lot of conceptually difficult stuff - the main point to take away from it is that you can easily have parts of a mesh use different world transforms, all you have to do is give each vertex a component that indexes the world transform from an array (Preferably in the vertex shader). You can provide this array in several different ways - in D3D10 the options are constant buffer, shader-buffer, texture1D, texture2D... Once you understand this technique there is a whole range of effects you can achieve using it - characters having their limbs separated, instancing, etc.
using a single vertex buffer is the easier way
Multiple sub-meshes can all share the same vertex buffer.
with splitting the mesh into subsets,you can have for instance a character getting his limbs blown off,but[/quote]There's lots of ways you could go about this. You could split the mesh into many draw-calls, and only submit the draw-calls for the sections you want. You could create many different sets of indicies (in one index buffer, or in multiple buffers) -- e.g. one for whole mesh, one missing A, one missing B, one missing A+B, etc -- and then use a single draw call with the appropriate set of indices. You could have your artist create a 2nd tex-coord set, where the [font=courier new,courier,monospace]u[/font] coordinate is an integer representing the "sub mesh" ID, and then in the vertex shader, if this number matches a "missing" mesh you can multiply the position by zero to make it disappear.

The best solution depends on the situation.

multiply the position by zero to make it disappear.


Surely this will lead to horrible artifacts? Unless the topologies of the different limbs were separate, as I described above? But even then you would still want that part of the mesh to be visible. Shot-off limbs dont disappear, they fall to the ground or roll down the hill.
Yeah that was just another option for hiding sub-meshes - it would require each sub-mesh to not share any verts with other sub-meshes (but that's guaranteed because the per-sub-mesh UV coordinates make the verts unique).

You could apply the same trick to your already mentioned bone-based sub-meshes, where if you wanted to hide a sub-mesh after it's been on the floor for some time, you could replace that bone's transform matrix with a scale=zero matrix.


I've only used the multiply-by-zero trick in a few cases, such as:
* Tile-based post processing. Instead of using a full-screen quad for post effects, you can use a grid of quads. If a quad doens't need to be processed (e.g. it's entirely in-focus when performing DOF) you can hide that quad.
* Shader LOD on sub-meshes. We had an expensive pixel shader and a cheap LODed version of that pixel shader. We first used a per-pixel [font=courier new,courier,monospace]if[/font] to choose which one would be used, based on distance, but then found that on our target GPU it was quicker to draw the mesh twice (once with each shader) and then hide one of the meshes if it's beyond a certain distance, and hide the other if it's closer than a certain distance -- so that when the mesh's centre point gets a certain distance away, it automatically starts using a cheaper pixel shader.


There's practically endless options for mesh rendering, depending on what your situation is. So, different games would be best suited to different mesh rendering schemes.
thanks for the replies,I think you're right that a single vertex buffer is better,the blown off limb will be a totally different mesh anyway,since it would require for instance - having torn off skin and blood at the place where it was attached to the body and exposed bones on the texture.

EDIT:how do you think it's done in Dead Space 2?I think they have a different mesh type for each limb and for the body for each type of limb blown off?How else would they add the bloody torn off flesh at the torn off joints otherwise

fake-achv-deadspace2.jpg
What Valve did was to render a separate bloody-mess mesh around the wound. So you could have bones poking out etc

http://www.valvesoftware.com/publications/2010/gdc2010_vlachos_l4d2wounds.pdf

What Valve did was to render a separate bloody-mess mesh around the wound. So you could have bones poking out etc

http://www.valvesoft..._l4d2wounds.pdf


one thing that bothers me = aren't there going to be seams between the limbs if you have a different subset for each limb?

This topic is closed to new replies.

Advertisement