0

i'm try doing fluid simulation using particles in 2d game.but something i can't get it through. situation like this, i have larger particles, which interactive each other physically,and applying constraint on particles, cause it's more like water,then use those particles to collide with environment(e.g wall,obstacles) but draw things doesn't go well,because by using particles-based fluid simulation, it exsits gap,or hole between circle particles, anyway,i would prefer to do some graphics trick to get rid of it.as you know, maybe use blur shader,or something else to smooth particles, but it's definitely infeasible, it makes particle size,radius visualization such changed,undetermined that can't use original information of particle to collide with environment anymore. please give some hint on fluid simulation in 2d games,thank you.

EDIT:

enter image description here

too bad, it's apparently that "water" fluid was composed of several cicrle sprites.....

enter image description here

better but still gaps,holes.

i uploaded the image to illustrate this visually. as the above figures shows, green circle particle was positioned separetely.it dosn't looks like water fluid. blurring the particles it's not my choice. how can i fixed this.

qxsl2000
  • 74
  • 5
  • From a previous project I found that modelling each particle as a circle and then drawing them twice the size of the actual body of the particle gives quite a nice effect but that may not be what you are looking for – Sinkingpoint Nov 27 '14 at 04:30
  • 1
    This is kind of broad for stackoverflow. Might be a better fit for gamedev? – Reto Koradi Nov 27 '14 at 04:38
  • Using longer range falloff function can create smoother surfaces. Image space [metaballs](http://en.wikipedia.org/wiki/Metaballs) can be drawn pretty easily in 2D as well. [This game](https://play.google.com/store/apps/details?id=com.mediocre.sprinkle&hl=en) does a pretty good job of it. I did a similar thing [here](http://goanna.cs.rmit.edu.au/~pknowles/blob/) a while ago too. – jozxyqk Nov 27 '14 at 07:25
  • @jozxyqk: thank you, metaball?, is it feasible to program this on mobile phone, and is it friendly with collision, interaction.. – qxsl2000 Nov 28 '14 at 01:57
  • well in 2D it's more of a metacircle :P. Yes, in image space they're quite cheap. It's a way of drawing and not related to collision or interaction, but is a very common method to draw fluid and will blob together close particles hopefully to form a single smooth surface/perimeter. – jozxyqk Nov 28 '14 at 03:11

1 Answers1

-3

You can do it solving the Navier-Stokes equation.

Google a little deeper and then you can find some examples and implementations. This is equivalent to the Netwon's F = M x A, but for fluid dynamics.

Wagner Patriota
  • 5,494
  • 26
  • 49
  • thank your replay, yes,i'm using particle-based instead of fluid dynamics. – qxsl2000 Nov 27 '14 at 05:04
  • hummm, sorry... I just know Navier-Stokes... with particles I never worked with... have you tried to check the samples in Cocos2D? they will probably have a fluid particle-based sample. – Wagner Patriota Nov 27 '14 at 06:51
  • why downvote here? The Navier–Stokes equations are used in games all the time... He asked for a hint on fluid simulation and I worked with fluid simulation (in games as well) in the past. I used Navier-Stokes for it all the time... – Wagner Patriota Nov 28 '14 at 23:11