Cloth Simulation
208 points
4 months ago
| 22 comments
| cloth.mikail-khan.com
| HN
clbrmbr
3 months ago
[-]
The tearing was unexpectedly disturbing!

Suggestion: use an accelerometer data on mobile and use that to directly replace gravity. I expect to be able to tip the phone to drape the cloth, and shake the phone to get waves of motion.

reply
eddieroger
3 months ago
[-]
I think the little tears were fine, but my expectation of the weight of the cloth wasn't so much that it would start to rip on its own after a certain point. It felt more like a wet dough at a certain point than cloth.
reply
Hobadee
3 months ago
[-]
This.

I can tear real cloth if I try, but I need to try. A flick of the finger has never once in my life torn cloth.

reply
fainpul
3 months ago
[-]
Literally unplayable
reply
brookst
3 months ago
[-]
It feels a bit like shooting at cloth.
reply
afandian
3 months ago
[-]
Clear you must bite your nails!
reply
cloudfudge
3 months ago
[-]
It's rust compiled to wasm. Dude's got a lot of interesting stuff on his projects page: https://mikail-khan.com/portfolio
reply
atan2
3 months ago
[-]
A very nice article by Marian Pekár on Verlet integration and cloth simulation:

https://pikuma.com/blog/verlet-integration-2d-cloth-physics-...

reply
jeffreygoesto
3 months ago
[-]
For me, "Large Steps in Cloth Simulation" [0] made implicit methods accessible... Seminal paper.

[0] https://dl.acm.org/doi/10.1145/280814.280821

reply
chombier
3 months ago
[-]
For inextensible cloth there's also "Efficient simulation of inextensible cloth" [0] that is particularly clever and efficient

[0] https://dl.acm.org/doi/10.1145/1276377.1276438

reply
OptionOfT
3 months ago
[-]
I remember the first time playing Splinter Cell.

Walking back and forth through a curtain to see how it wraps around the body. So cool.

reply
bogtog
3 months ago
[-]
It tearing when I waved my mouse around was a nice surprise
reply
eternityforest
3 months ago
[-]
I wonder if cloth simulation could be integrated as a CAD primitive that somehow outputs reasonable BRep geometry?

Could you take an AI 3D scan of someone's face, virtually lay a heavy cloth over it, then add whatever you wanted to make a mask?

Could you make the deformed cloth surface into one side of a cube, where the other side was flat for easily working with it, and use that to make custom pseudo-vacumformed cases for things?

Or just stack up boxes and simple shapes, and use the cloth simulation to build organic looking industrial design within a more traditional CAD workflow?

reply
xnx
3 months ago
[-]
Thought this was going to be a repost of https://oimo.io/works/cloth/, which is also excellent.
reply
Miraltar
3 months ago
[-]
Exactly as discussed in Sebastian Lague's video https://www.youtube.com/watch?v=PGk0rnyTa1U
reply
TwoFx
3 months ago
[-]
I highly recommend watching the relevant section of that video (4:38 to 8:59) and then implementing it yourself in whatever system you know that can draw lines and circles (I did it in Godot; it took only a few minutes to learn enough Godot to start on the algorithm).

It's absolutely mind-blowing that so little code can produce such a beautiful result. It's also fun to play with the parameters and see how they affect how the cloth feels.

reply
mclau153
3 months ago
[-]
would you share your godot code to github?
reply
taeric
3 months ago
[-]
First, kudos on this. Really cool to play with.

Reminds me of a great video not long ago that went over the main ideas behind weaving and knitting. Feels like you almost certainly have to take some of those ideas in mind when doing a simulation like this. Would be curious to read a breakdown of how this was made and how it incorporates the concepts that go into different fabric.

reply
fiiisssh
3 months ago
[-]
There's actually really no knowledge of cloth involved, it's just a bunch of spring constraints: https://github.com/mkhan45/clothsim

AFAIK more advanced realism-focused cloth sims are still mostly bundles of spring constraints, and most fabric behaviors are encoded as different spring tolerances, forces, and friction.

Cloth self-collision and friction seem to be a very difficult problem in which progress has been made recently: https://graphics.cs.utah.edu/research/projects/ogc/Offset_Ge...

reply
flet
3 months ago
[-]
I like it!

I made this a bit ago for fun and funnies to test the idea of tearaway ads. It's very prototype but still pretty satisfying (desktop only but there's a gif on the repo)

https://github.com/Flet/tearaway

reply
sliken
3 months ago
[-]
Nice first approximation. The cloth has no momentum, a piece of cloth that clearly would swing down, past vertical, and then swing up just damps down and stops at vertical.

Also the falling pieces don't accelerate downward, which looks unnatural

reply
LyalinDotCom
3 months ago
[-]
I was curious and was able to build something very similar quickly using Gemini 3 via Google AI Studio. Never would have imagined a few years ago how easy some of this has become to prototype.
reply
cyber_kinetist
3 months ago
[-]
There's a lot of simple cloth sim examples on the internet, so I see why LLMs can code these kinds of demos easily.
reply
LyalinDotCom
3 months ago
[-]
yeah makes sense. Im sitting here evolving my little prototype its too much fun.
reply
jcims
3 months ago
[-]
The 'Build' feature in AI studio has been pretty incredible for a few use cases I've thrown at it.
reply
samcheng
3 months ago
[-]
This is great! The only part that broke the immersion (for me) was that the cloth bits fell at a constant rate - I'd expect them to accelerate due to gravity, and maybe flutter as they fell.

Nice art!

reply
iberator
3 months ago
[-]
Maya and Cloe 3D and almost all fashion design software have it for decades already. Niche and fascinating software. Check out some demos.

Cool stuff in software you don't even know exists:)

reply
zokier
3 months ago
[-]
Of course cloth sims of varying fidelity are everywhere. Even games have had cloth sims for decades at this point.

But it is also something that remains a research problem how to do efficiently and with good results; pretty much every year in siggraph you see couple of new papers around cloth sims. For example this year we got this https://youtu.be/d9TZhtXeMio

reply
ChrisMarshallNY
3 months ago
[-]
As an artist, I needed to get it right. Wasn't as easy as I thought it would be. I had to think in 3D, to make 2D.

https://littlegreenviper.com/art/Tarsus.png

https://littlegreenviper.com/art/Gym.png

reply
fao_
3 months ago
[-]
One of the best ways to practice this is just throwing a towel on a chair, sitting down opposite it, and sketching it
reply
regularfry
3 months ago
[-]
The cloth sim in Blender remains one of the most frustratingly un-updated features. I would dearly love to see it get an algorithmic refresh.
reply
brontosaurusrex
3 months ago
[-]
At least solver seems faster (if not better) in later versions? p.s. My try at 'flag in the wind' in Blender from around 2022: https://0x0.st/s/aJ6DNj2pEHzRdBiscEIsbQ/KCsK.mp4 I do remember it took me all day to get somehow realistic motion.
reply
hoppersoft
3 months ago
[-]
I spent entirely too much time finding out exactly how much "cloth" could be supported by two "strings."
reply
zenoprax
3 months ago
[-]
I'm going to assume it is "more than you think; not as much as you'd like" because I don't have the time to burn this morning to replicate your research.
reply
RankingMember
3 months ago
[-]
Pretty cool! I kept trying to cut the piece I had just cut again by doing a "Zorro"-style motion, but no such luck.
reply
jakemanger
3 months ago
[-]
That's super cool (and FAST -> hard to do from my personal attempts).

But, please, give us some nitty gritty of how you made it

reply
fiiisssh
3 months ago
[-]
The repo is at https://github.com/mkhan45/clothsim, it's pretty compact and most of the relevant code is in src/main_state.rs
reply
raylad
3 months ago
[-]
Feels more like a spiderweb simulation. The fibers are sticky and stretchy.
reply
jan_Sate
3 months ago
[-]
Looks like that I can cut it without right click by swiping fast enough.
reply
robertheadley
3 months ago
[-]
I wonder how far away we are from realtime Marvelous designer in games.
reply
mrkramer
3 months ago
[-]
Reminds me of Fruit Ninja but this one is Cloth Ninja.
reply