   Vertex Shader: cloth/hair spring?
  hello,been looking for some info on how to do this.some games have some sort of basic spring system, used to simulate hair and some of them cloth as well.I'm talking about the simple effect of vertexes that seem to be left behind when an object moves, and then catching up (some of them have an inertia rebound of sorts as well).now I'd like to see if this can be done in a vertex shader (DX9 HLSL, VS 2.0).I'm assuming the vertex shader can have a way of telling which verts are affected by the effect, and which not. a component in the mesh file, or maybe a black and white texture. is this the case?the theory for the basic "left behind" part I guess would be an interpolation of the last frame's position and the actual frame's position. the thing is, how do I get the old position?perhaps later I could think on how to do the rebound, but I mostly care about the "left behind" part.also notice I don't care about collisions at all.   
  Probably what you want to do has a lot in common with a gpu particle system implementation. Search for it and some good articles will show up.A quick overview: you would have color buffers with positions and velocities of each vertex in the system, then in the pixel shader apply some integrator (verlet, rk4, whatever you like) to find out the force applied between each pair of vertexes connected. The formula to calculate the force is f = -kx, basic physics formula (Hooke´s law, search for it). You would have to store the connection info and spring constants somewhere, though.So at the beginning of each frame, you have the buffers filled with last frame´s positions and velocities. You operate on them (integrating the equations of motion) to find current frame´s values, then render.EDIT: for this to work you need vertex texture fetch functionality available, which i believe exists since shader model 3...plus, if you want it working together with skeletal animation, things will get a bit nastier than usual. If i were you, i would first make a draft in 2D using flash, processing or any other language that allows quick prototyping. I happen to have made a small tutorial on the subject: http://www.thehiddenfactory.com/arkano/tut_fisica.htmbe warned that it is very beginner-oriented and i´m not using any decent integration scheme.[Edited by - ArKano22 on May 11, 2010 4:51:38 AM]