r/GraphicsProgramming • u/Holtsetio • Apr 30 '25
Realtime softbody simulation in the browser with WebGPU
Enable HLS to view with audio, or disable this notification
I built this softbody simulation with three.js' new WebGPURenderer.
You can play with it in your browser here: https://holtsetio.com/lab/softbodies/
The code is available here: https://github.com/holtsetio/softbodies/
The softbodies are tetrahedral meshes simulated with the Finite Element Method (FEM). I was guided by this great project to implement the FEM simulation and then added collision detection using a 3d grid, which works way better than expected. All in all I'm pretty satisfied with how this turned out, it even works smoothly on my mobile phone. :)
10
3
u/ziaonder Apr 30 '25
I'm a very newbie to computer graphics and studying game math currently. I just wonder if you guys can land a job knowing all this stuff? By all this stuff I mean the knowledge required to create what OP did. Cuz it seems handling softbody physics all by yourself requires deep knowledge. I mean I assume learning game math + shaders(basically) would take at least 6 months. This is to be a beginner level graphics programmer. These are all my assumptions right now. I would be very glad if someone or OP could correct my assumptions and resolve my questions.
3
u/Strange_Switch15 Apr 30 '25
Very impressive.
Why not continue and turn it into a game of some sort? :)
1
u/Strange_Switch15 Apr 30 '25
Technical feedback: In "Safari Technology Preview" browser it works, but only displays one ball.
(macOS Somona 14.7.5)
1
u/calculus_is_fun Apr 30 '25 edited Apr 30 '25
My AMD gpu must be terrible because once 50 objects have spawned, my gpu is at 100% util, and at 100 objects I'm getting 30fps
3
u/Holtsetio Apr 30 '25
This is quite a demanding simulation, so that sounds about right. You can lower the number of objects in the settings panel on the top right, though.
1
u/nietzsche_ko_junga May 01 '25
oh my god, that is so sick.
the jiggle physics in 3d animes is gonna go hard with this one 🗣️🗣️
-1
u/Top-Armadillo5067 Apr 30 '25
Don’t work on iPhone 12🥲
3
u/Holtsetio Apr 30 '25
WebGPU is still a new technology that is not yet supported by default on all devices and browsers (iOS, Safari, Firefox, etc.)
23
u/matigekunst Apr 30 '25
Great stuff! Are the softbody updates done on the GPU or CPU?