Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Using mesh subsets vs. a single mesh


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 mrheisenberg   Members   -  Reputation: 356

Like
0Likes
Like

Posted 13 October 2012 - 04:10 PM

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.

Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 8175

Like
2Likes
Like

Posted 13 October 2012 - 06:09 PM

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.

Edited by mhagain, 13 October 2012 - 06:09 PM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 hupsilardee   Members   -  Reputation: 487

Like
1Likes
Like

Posted 18 October 2012 - 05:46 AM

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.

#4 Hodgman   Moderators   -  Reputation: 31214

Like
1Likes
Like

Posted 18 October 2012 - 06:55 AM

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

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 u 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.

#5 hupsilardee   Members   -  Reputation: 487

Like
0Likes
Like

Posted 18 October 2012 - 09:06 AM

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.

#6 Hodgman   Moderators   -  Reputation: 31214

Like
0Likes
Like

Posted 18 October 2012 - 07:19 PM

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 if 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.

Edited by Hodgman, 18 October 2012 - 07:23 PM.


#7 mrheisenberg   Members   -  Reputation: 356

Like
0Likes
Like

Posted 20 October 2012 - 09:14 AM

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

Posted Image

Edited by mrheisenberg, 20 October 2012 - 12:44 PM.


#8 hupsilardee   Members   -  Reputation: 487

Like
0Likes
Like

Posted 24 October 2012 - 03:08 PM

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

#9 mrheisenberg   Members   -  Reputation: 356

Like
0Likes
Like

Posted 25 October 2012 - 04:13 PM

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?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS