Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

How're you supposed to use vertex buffers?

Say you have 500 distinct deformable shapes/models in the world (ie you want to be able to change/delete vertices from the models somewhat arbitraily as the game progresses). The requires you refresh the vertex buffers in the frames the model has become dirty, at least.

So how should you handle your vertex buffer, assuming D3D11 interfaces (so vertex buffers are your only option to draw anything):

  • Store model vertices in CPU RAM. Create one vertex buffer at program start. For each model, copy the vertices into the single vertex buffer, render
  • Create 500 vertex buffers, update each when necessary, render.
share|improve this question
1  
I'm going to guess a single buffer with one update call. You really should run a profiler on either case and see what the real world says, though. –  Patrick Hughes Jul 29 '11 at 20:31
    
Just to mention - vertex buffers aren't really designed for this situation. It's quite rare to have a huge number of deformable shapes/models. Most rendering occurs with a relatively small number of fixed models, which are then animated via vertex shaders. –  ZorbaTHut Jul 29 '11 at 21:44
2  
Wow, the only answer you ever accepted is your own. That's weird! –  Maik Semder Jul 29 '11 at 22:07
    
Best laugh I've had all day, thanks @Maik Semder =) –  Patrick Hughes Jul 29 '11 at 22:13
    
add comment

1 Answer

At the bottom of this article, there are references to how to make dynamic vertex buffers.

http://msdn.microsoft.com/en-us/library/windows/desktop/ff476899(v=vs.85).aspx

This particular solution is "supposed" to dynamically "optimize" itself based on how frequently you are updating the vertices, etc. In other words, just let the DirectX API manage it for you.

I have had a similar problem rendering chained deformations where one object's deformation affects another, and so on, until it becomes cyclical.

In this case, maintaining the original vertex points is completely useless.

However, if your deformable objects retain somewhat of their original shape, you may be able to rely completely on geometry shaders, or other types as you need, and not have to update the vertices.

Without knowing your particular scenario, and the extent of the deformations, relative interval of the deformations, a specific architecture is pretty much impossible to recommend.

HTH.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.