OpenCloth: A new opensource project for cloth simulation

mobeen
Posts: 122
Joined: Thu May 05, 2011 11:47 am

OpenCloth: A new opensource project for cloth simulation

Post by mobeen »

Hi all,
I have just created a new opensource project "OpenCloth".

Repository: http://code.google.com/p/opencloth/

This project has been started to prevent beginners from reinventing the wheel and shows them how to implement cloth simulation. Focus is on how to handle the bare minimum required to implement the techniques. Rather than wrapping code into classes, we implement the whole code in a single source file. Specifically, this project covers the following integration schemes,
  • Explicit Euler Integration
    Implicit Euler Integration
    Implicit Integration (Baraff & Witkins Model)
    Verlet Integration
    Semi-Implicit (Simplectic Euler) and
    Position based Dynamics (in progress)
I hope it is useful for others. Comments and critics welcome. I would like others to contribute in the project too by letting me know if there are any issues.

Kindest regards,
Mobeen
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: OpenCloth: A new opensource project for cloth simulation

Post by Dirk Gregorius »

Instead of trying arbitrary integrators you should decide for your project whether it is for real-time cloth simulation or offline simulation. For real-time cloth I would argue position-based dynamics is the current favorite implementation since it is unconditionally stable and allows you to manipulate positions directly. Much more important than this is the coupling to the animation system. So make sure your cloth can handle very fast simulations, large rotations and teleportations of characters. Personally I would even argue that the integration of a cloth simulator in a game engine is much more difficult since the position-based dynamics is so trivial to implement. Other interesting aspects are auhoring in Maya/Max/Blender and *maybe* simulation on the GPU. This is why I am very skeptical about any value of any cloth middleware or open source library in general.

Non-realtime simulation is very interesting and in my opinion good cloth simulation comes from high stiffness and energy conservation. This is where the spring based simulations run short in my opinion - no matter what integrator is used. Here is an interesting PhD if you want to research in this area and learn about some more recent approaches:

http://www.cs.columbia.edu/cg/pdfs/131-ESIC.pdf
http://www.ronyfx.com/ronygold/AdrianGo ... Thesis.pdf
mobeen
Posts: 122
Joined: Thu May 05, 2011 11:47 am

Re: OpenCloth: A new opensource project for cloth simulation

Post by mobeen »

Hi Drik,
Thanks for your response.
Instead of trying arbitrary integrators you should decide for your project whether it is for real-time cloth simulation or offline simulation.
Well the idea is to create a simplistic realtime cloth simulation library. Currently, I am trying to make sure that the library is implementing the core algorithms correctly and we have a basic knowledgebase for beginners.
For real-time cloth I would argue position-based dynamics is the current favorite implementation since it is unconditionally stable and allows you to manipulate positions directly. Much more important than this is the coupling to the animation system. ... Personally I would even argue that the integration of a cloth simulator in a game engine is much more difficult since the position-based dynamics is so trivial to implement.
Indeed, position based dynamics is also in my mind and I m trying to do that too however I am having some problems in my implementation and I hope guys like you might help me with them.

Thanks for your response. I value your feedback greatly and I do hope that you would support me as u have done just now.

Regards,
Mobeen
saggita
Posts: 13
Joined: Tue Apr 19, 2011 11:46 pm

Re: OpenCloth: A new opensource project for cloth simulation

Post by saggita »

I briefly took a look at the source code and believe your code provides great value to many people out there.

I am personally interested in cloth simulation and have been working on it for a while. I believe there are not many 'clean' code which implements implicit integration. Especially Baraff & Witkins model is not easy one to understand. The Jacobian and Hessian matrices make the PCG solver complicated since the matrix has 3x3 block elements.

I haven't looked at your semi-implicate code yet. Do you calculate your inverse matrix first and reuse it? As far as I know, there are two IMEX methods. Both ignore Jocobian and Hessian. Since they are ignored, the 'A' matrix becomes constant. One IMEX solves the inverse matrix first and reuses it later. The other one is solving Conjugate Gradient at each frame but the iteration will be very short since the matrix is always guaranteed to be positive definite. And the preconditioner is constant. Below papers explain these methods.

http://www.multires.caltech.edu/pubs/GI99.pdf
http://citeseerx.ist.psu.edu/viewdoc/do ... 1&type=pdf

Many people believe implicit method is slow and only for offline simulation but it might not be true. As the first method suggests, implicit method can be done without iteration and the computation is much more parallel process friendly. The position based method is more like Gauss–Seidel style and it is not easy to break it into parallel process. Also the convergence is not as fast as PCG.

If you add good collision detection and response, it will become a good cloth simulation.

Below are links to my cloth videos. It is a long term personal project.

http://www.youtube.com/saggitasaggita#p/u/2/YVhD2d2wWHU
http://www.youtube.com/saggitasaggita#p/u/1/Q3sxamRYkcA
http://www.youtube.com/saggitasaggita#p/u/6/yhkZ8htCsU4

Good luck.

Dongsoo Han
mobeen
Posts: 122
Joined: Thu May 05, 2011 11:47 am

Re: OpenCloth: A new opensource project for cloth simulation

Post by mobeen »

Hi Saggita,
Thanks for the detailed response. My implementation is exactly following the Desbrun et. al paper (GI99) that u have linked. Infact if u look at the code, i have kept the same variable names. My implicit code is following the Baraf and Witkins model with preconditioned conjugate gradient solver. In this case too I have kept the same variable names as in the original paper so that it is easier to follow.

I have seen your videos the results are quite impressive. Which method do u use for collision detection and response could u link the papers/references for this? Currently, I have not added any collision detection/response in the codes and I was thinking of asking more experienced ppl like you to guide on which method is the best.

I would like to have more feedback from ppl like you so that in the end we have a solid codebase for cloth simulation.
I hope you will go through the rest of my cloth sim. algorithms and give feedback.

Regards,
Mobeen