I try to implement a position based cloth simulation using hardware tesselation. This means I want to just upload a control quad to the graphics card and then use tesselation and geometry shading to create the nodes in the cloth.

This idea follows the paper:

Huynh, David, "Cloth simulation using hardware tessellation" (2011). Thesis. Rochester Institute of Technology http://scholarworks.rit.edu/theses/265/

I know how to use tesselation to create the simulated points. What I don't know is how to store the computated information into a framebuffer.

The geometry and also the tesselation evaluation shaders have informations needed for the per-vertex computations. But can they directly write into the framebuffer?

The fragment-shader I know can write to the framebuffer, but my information would be interpolated and I would no longer know what to write at which position.

  • $\begingroup$ transform feedback buffers $\endgroup$ – ratchet freak Jan 16 '16 at 17:02
  • $\begingroup$ Sounds very good. The constraints of the cloth simulation make it necessary that I can access all neighbours of a particle (to calculate the spring forces). Can this be done with such buffers? In a geometry shader maybe? to pervent the feedback buffer to print each vertex multiple times I would like to use GL_POINTS. After a first look it seems that this makes it harder to calculate the springs. $\endgroup$ – Dragonseel Jan 16 '16 at 19:18

Based on the comment of "ratchet freak" I researched Transform Feedback Buffers and solved my problem that way.

I now generate the simulated points on the CPU and put them into a VertexBufferObject. I generate a second VBO for the points (along with some others for velocity). The connectivity of the cloth is given as an vertex-attribute in ivec4.

Using the transform feedback buffers and a Double-buffering trick using the two VBOs i can always read from the last step (using the connectivity info) and write to another buffer. This is in order to solve problems with concurrency.

The calculations are done in the vertex-shader as GL_POINTS. Binding the output of the first shader into another regular shader using additional index-buffer to generate triangles I can without trouble render the cloth any way I want.

This idea follows the transform feedback buffer example made in the book "OpenGL Superbible" http://www.openglsuperbible.com/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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