Fluid simulation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nomeyho
:warning: Old Version Published before Godot 3 was released.

Hi!

I would like to develop a physic-based game which requires fluid simulations (flows). I might be wrong but I didn’t find an explicit way to use fluids in the documentation.

Since Godot has its own physic engine but is open source, here are the two approaches I can think of:

  • Create a large number of collision shapes (e.g. triangular) and use the Godot’s embedded physic engine. There is a risk to have performance issue if too many shapes are used.
  • Use a physic engine dedicated to fluid simulations (liquidfun, a box2d extension). It would be added as a custom C++ module. In that case, two physic engines would be integrated to Godot.

If you have any suggestion, please don’t hesitate!

:bust_in_silhouette: Reply From: VitaZheltyakov

Thank you for the link, didn’t know it (I’m quite new to game development in general). I will try this method. I need particles to be quite small to allow them to flow through pipes and therefore a quite large number of them. Hope the performances will stay good.

Nomeyho | 2017-08-08 21:12

:bust_in_silhouette: Reply From: eons

If you think that worth the effort, try to add Box2D (somebody already added Bullet and is being discussed to include it in future versions), Box seems to lack of some features, you should talk with core devs about that (IRC).

May be easier to try to adapt liquidfun to the current physics engine.

Depending on the mechanics of your game, you could opt for another approach, like polygon based elements(maybe just areas, joining and separating shapes), using shaders to simulate the visual part.

ps: something like this may (or may not) be planned for 3.1, try to talk to devs, maybe you can join them.

:bust_in_silhouette: Reply From: SIsilicon

While this question is a little old, I thought might just leave this here in case others see this.
https://godotengine.org/asset-library/asset/226
It’s a demo project I made of Smooth Particle Hydrodynamics based Water: SPHater
It runs on purely gdscript though so there’s definitely some untapped performance here.