Fluid Simulations!
Happy Three Months of Development! ◡̈
When I started planning Empty Cups, I really wanted the drink mixing mechanic to include all those pretty swirls that you see when mixing matcha in milk, or espresso in water. Initially, I considered using animations and tested out a few, but most of them were unsatisfying and a little boring to look at.
I thought maybe this week I could actually put my engineering degree to use and program a real fluid simulation! There are a couple options you have when it comes to the implementation you choose, primarily the Eulerian approach or the Langragian approach. I won’t bore you too much with the math behind it, you can simply see the simulations I made to understand them more intuitively.
Langragian Method
Eulerian Method
I decided to go with a Eulerian simulation. There are a few limitations with this method and I would’ve preferred to have the pouring mechanic simulated within this chunk of code, however that comes at the cost of performance so I decided to stick to using animations instead.
Luckily for me, a lot of very smart people have already converted all the complicated equations into C. Aside from porting it into GDScript, most of my time actually went into rendering the simulation effectively.
I’m pretty happy with how it’s turned out! Hopefully next week we’ll actually be able to make some drinks ◡̈
Special thanks to:
Jos Stam for his lovely paper on Fluid Dynamics
Mike Ash for dumbing it down for me
Daniel Shiffman (The Coding Train) for helping me figure out how to render it all