We started from a three.js cloth simulation example and made a bunch of modifications. The cloth is modeled as a grid of point masses (particles) connected by springs. We've got options for horizontal & vertical springs (simulating cross grain, where the cloth threads run parallel to the edges), diagonal springs (simulating bias grain, where the cloth threads run diagonally), and springs that connect particles two units apart (simulating drape / bending stiffness, similar to a starched tablecloth). It's kind of amazing how a simple system of particles and springs can result in such rich cloth-like behavior. Other than the springs (which are modeled as constraints on the distance between particles), the only forces on the particles are wind and gravity. In addition we have constraints that account for collisions and simulate friction-like behavior.
We've submitted a paper that explains the details of how this works which I'll share once it's published, but for now if you're interested in learning more here are a few references, or google 'verlet integration constraints'. Also happy to try to answer your questions.
Avoiding self intersections results in more realistic cloth behavior like folds and wrinkles. The problem is, iterating through all pairs of points comes at a computational cost, and can really drop the frame-rate, particularly for large cloths. So I decided to keep this setting off by default until I have a smarter way to implement this (e.g. using quadtrees).
The state-of-the-art in commercially available cloth/clothing creation simulation these days is Marvelous Designer and it is available for ~$400. It does produce results that are pretty phenomenal and hard to tell from real-life.
Those knots are gnarly!
So far the most impressive example I've seen is ZEITGUISED's geist.xyz: https://vimeo.com/150824660 Undulating impossible fabrics with photo-realistic shaders (and a soundtrack that makes my head hurt).
It's definitely an experimental art film but it feels more like an impressive tech demo for what they've been able to accomplish with textile simulation. Sadly like most art pieces, there's very little in the way of technical on how they pulled off such interesting stuff.
I am fairly sure they were not using custom software, rather off the shelf tools for both rendering and simulation.
If you want to look into more rigorous and advanced version, reading position based dynamics papers (http://matthias-mueller-fischer.ch) will give you a lot to chew on. Generally speaking Googling "verlet physics" or "position based dynamics" will give you a lot of resources.
This is Verlet Integration, Verlet is good for cloth as Euler tends to tear cloth.
Solving so many constraints simultaneously would be rather intractable so an approximation is achieved iteratively.
This iterative approximation to simultaneous equations is termed Relaxation, more precisely Gauss-Seidel or Jacobi iteration depending on whether the constraints are applied sequentially or in parallel.
For the sequential version each constraint is applied one after another and this repeated a few times, thus 'relaxing' toward a solution that satisfies all the constraints.
Particle movement may be modelled in a variety of ways, Euler, Verlet, Runge-Kutta, (&c.) each with their own pros and cons.
Euler is the most familiar and tracks position and speed, updating the position with speed times time. Basic Euler applies forces to the velocity vector. Sometimes Euler tracks acceleration and forces are applied as changes in acceleration and updates the velocity vector by acceleration times time.
Verlet Integration does not track speed only last and current positions, speed is implicit. In Verlet Forces are applied simply by moving a particle. Basic Verlet Integration thus has a fixed timestep( variable timestep Verlet and other refinements exist).
The problem with Euler integration is that speed and position can lose sync and so the particle is in the wrong place and the cloth stretches and tears.
As Verlet Integration tracks only position it is more stable (and faster to calculate). Long used in molecular dynamics and galaxy formation simulations, Verlet broke into the mainstream with Thomas Jakobsen's work on Hitman where he used it for fast 'realistic enough' rag doll simulations. Verlet tends to correct itself over time and produces fast 'good enough' simulations, the sweet spot for games.
 Jakobsen - Advanced Character Physics http://www.cs.cmu.edu/afs/cs/academic/class/15462-s13/www/le...
Author's github page also has links to a list of cloth simulation resources.
Not sure if bug or if those parameters are not in the space of valid options.
Cool project btw!
I left that in as allowable behavior, because our goal with this was not necessarily to model a realistic cloth but more to experience interesting and unusual movements and behaviors. So glitch away!
Can't seem to find much besides this video though: https://www.youtube.com/watch?v=eoCbSL2kis4
It is cloth with tearing and verlet integration. Nothing fancy or even difficult but it is probably a nice starting point.
I'm not sure if there's something that I've done wrong, or what.
I wouldn't have thought 80°C is anything to worry about from the computer's point of view, but if using it on your actual lap I'd advise a degree of caution.
Last time you cleaned it?
Seems like a great HN submission.
My guess is that you know a lot about WebGL programming and don't see anything new or special in this. If so, you should use your superior knowledge to teach others, e.g. by making interesting suggestions, pointing to other work, and so on. Then we all learn something. If you don't want to, that's fine, but please don't post purely dismissive comments.
Most topics that appear here (even the ones on particle physics!) are old hat to somebody or other; HN has experts on a lot of things. If they all expressed their expertise by putting others down, this would be a much sorrier place, with many fewer opportunities to learn.
We detached this subthread from https://news.ycombinator.com/item?id=11833245 and marked it off-topic.