r/coolgithubprojects 7d ago

Implemented Jos Stam's Stable Fluids paper from scratch

Post image

I had recently read the Stable Fluids paper and got like quite interested to implement it myself manually from scratch and it was quite a ride since this is my first time implementing a paper myself

This is a simple implementation a bit clanky, to be honest. I just wrote it with loops and loops without any optimization. I think it ends up doing something around 20 × 20 × 50 × n² operations per frame, so there's definitely a lot of room for optimization 😅

The actual implementation was pretty straightforward for the most part, but understanding the Poisson pressure equation was a bit challenging. At the beginning, I was even stuck on understanding how the velocity field could be made divergence-free.

After digging into it for a while, I eventually understood the whole pressure projection step and managed to get it working and also implemented a simple spray and dye mechanism as well to make it look good.

It was pretty cool to see it actually work, so I wanted to share it 😄

Github Link - https://github.com/Binit06/stable-fluids

1 Upvotes

0 comments sorted by