I am new to graphics and physics simulation.

I am trying to perform a mass-spring simulation on CPU on individual vertices inside a mesh, and wondering how to best handle this.

If working with a rigid body, this is easy as every vertex is translated/rotated in the same way, so we can just supply a single transformation matrix with glUniformMatrix4fv and don't have to touch the VBO for the positions.

With the mass-spring system, however, I'm a little lost. Am I just supposed to buffer entirely new vertex position data into the VBO on every frame? That's the only way I can see of doing it, but it feels very inefficient to have to replace the data for every single model in the scene on every draw call. Is there some better way of handling this?

I have thought of potentially being able to do the physics simulation on GPU inside the vertex shader, but then am not sure of how I would handle things like collision detection.

How are these kinds of simulations usually handled for real time rendering/game engines/etc? Is there a better way of handling this kind of per-vertex updating?

  • 1
    $\begingroup$ Yes, uploading the complete vertex data is necessary. The simulation itself might be more time consuming, of course depending on the simulation algorithm. You might want to measure the time for simulation and upload. $\endgroup$
    – dweber
    Feb 8 at 14:14


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.