clothtitle

Dynamic & Scalable API for realtime/offline simulation

Cloth Simulation from Abhishek Sagi on Vimeo.

Motivation

Even today in video games, accuracy and level of detail for soft bodies such as cloth in game is coarse; I believe this is mainly due to complex non linear physical properties and computing budget required to simulate it realistically.

With emergence of GPGPU ( General-purpose computing on graphics processing units ) languages such as OpenCL, Compute Shaders with OpenGL, Soft body simulation is a perfect candidate to parallelize computing which would allow us to enhance usage in games, this really motivated me to perform research and develop a platform independent realistic and scalable soft body simulation framework to overcome its limited use in games

Some of the other main motivations for picking this research area :  

  • Passionate about exploring and solving mathematics and physics concepts involved in cloth simulation
  • Investigate efficient graphics rendering techniques for rendering cloth efficiently
  • Learn GPGPU languages
  • Explore different application benefits apart from usage in games such as cloth and animated film industries 

Research

To ensure that the framework I develop is robust and future proof it needs to have solid foundations both from theory and practical implementation standpoint. From October 5th I began my research to get better understanding about current state of softbody simulation. I primarily divided my research into 2 categories : Cloth simulation and setting up a platform independent framework to benchmark and run the simulation.

Soft body Simulation

Over the past decade, a lot of research has been put into this area from various fields in computer science. [1] laid the foundations for simulating a soft body such as cloth. I was able to deduce that there are two approaches to simulate cloth they are : Finite element and Mass spring model. By reading [2] it was observed that Finite element method is much more sophisticated in contrast with Mass spring model. Therefore after careful consideration I decided to go ahead with Mass-spring model as it is widely used technique in many games today due to it's simplicity and efficiency.

After choosing Mass-spring model for simulating cloth I began to further investigate deeply about various techniques that are available to solve physical forces. I was able to deduce that for any cloth simulation technique there are some common similarities such as :

  1. Calculating external forces
  2. Calculating internal forces ( constraints )
  3. Integration of positions and velocities

With mass spring system approach positions can be solved using 2 methods namely implicit and explicit. With implicit method solution is found by solving for position involving both current time step and next time step.Therefore if Y(t) is current state of an object and Y(t + Δt) would be the next state at later time. 

For explicit method :

Y(t + Δt) = F(Y(t))

But with Implicit method :

G(Y(t), Y(t + Δt)) = 0  ( To find Y(t + Δt) )

For above equations it was obvious that implicit methods require more computation to get the results and can be harder to implement in contrast to explicit methods. But accurate results can be achieved with less computational time by using implicit method with larger time steps. It was observed that in real life; clothing strongly resists stretching, and as a result explicit methods are unsuitable for solving newtons forces because they require many small time steps for numerical stability and avoid stretching[1].

To overcome this limitation and get accurate results (stiffness) with limited stretching; I will also considered looking further into usage of implicit method for solving states and also I believe, through more literature review and as I make more progress with implementation overtime I will a get an in-depth understanding of these two approaches which would help me to identify limitations and come up with a solution to overcome.

In addition to looking at techniques for implementation I also tried some of the popular physics engines such as PhysX, Bullet physics and OpenCloth; and their approach towards cloth simulation to get a general understanding and feel of how they work.

Precision Framework

Simultaniously as I was doing research about soft body simulation techniques I also began setting up framework which would aid me for demonstrating the cloth simulation. You might wonder why I have chosen to setup a cross platform framework from scratch when there are many open source frameworks/engines at my disposal such as OGRE3D, Unity3D, Unreal Engine etc. There were couple of strong reasons :

  1. Developing framework from scratch will allow me to better understand the implications of soft body simulation on various aspects such as rendering, collision detection, input, loading geometry etc.
  2. Based on above point I can also ensure that developed cloth simulation API can be easily integrated with other modern engines without to much effort by ensuring abstraction where necessary.
  3. I personally believe that in near future consoles, smart phones and personal computers will be unified and indistinguisable in terms of power, therefore by developing simultaniously on OSX (Unix) and Windows I can ensure that the framework I develop is platform independent.

Therefore precision framework was first developed and used for implementing a robust soft body simulation API.