Box2D Forums

It is currently Sat May 25, 2013 3:43 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 97 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 10  Next
Author Message
 Post subject: Re: Fluid Simulation
PostPosted: Sun Apr 20, 2008 12:54 pm 
Offline

Joined: Sun Apr 20, 2008 12:44 pm
Posts: 2
Hi everyone.
I'm currently working on a sequel to a past project of mine (http://www.avocaladventure.com sorry it's only in french) that will make heavy use of Box2D AND fluid simulation.
So I'll be playing around a bit with this SPH idea and return with whatever I can find.

BTW thanks for Box2D, it's pretty awesome :!:


Top
 Profile  
 
 Post subject: Re: Fluid Simulation
PostPosted: Sun Apr 20, 2008 2:44 pm 
Offline

Joined: Sun Sep 23, 2007 2:35 pm
Posts: 803
Bobb - sounds cool, let us know how it works! It looks like you're already doing some sort of height-field water - are you planning to mix that with SPH for breaking waves and stuff like that?

Also, now that this topic has been bumped, I realize I forgot to mention this - while searching around for pre-fab SPH code (realizing that I'm just not going to have the time to envision, write, and debug it myself any time soon), I found that Keith Vertanen and Brian Schlatter wrote some C++ SPH code a while ago and put it up on the web (http://www.keithv.com/project/index.html). I e-mailed Keith and he agreed to let us use it under zlib if it turns out to be useful for Box2d, so I'm playing around with it to see if it will integrate well. Still not sure if it will work for real time fluids in a game (to get enough incompressibility it might be necessary to either drop the time step drastically or switch to an integrator other than symplectic Euler), but I'll report back either way.


Top
 Profile  
 
 Post subject: Re: Fluid Simulation
PostPosted: Mon Apr 21, 2008 7:39 am 
Offline

Joined: Sun Apr 20, 2008 12:44 pm
Posts: 2
Yes, the first version was actually a height-field generated water surface. (it is a simple b-spline with no underlying physics). And I faked archimedae response to obtain a "pretty" result. No physics simulation at that time, really.

Right now I'm still not sure I will use a real physics simulation, cause I want the game to look quite arcade and funny. I'll play a little and report back my results.


Top
 Profile  
 
 Post subject: Re: Fluid Simulation
PostPosted: Tue Apr 22, 2008 3:14 pm 
Offline

Joined: Tue Sep 18, 2007 6:17 am
Posts: 155
Location: Western Cape, South Africa
Have you guys seen the new videos for Gish 2?

It seems that Gish is now going to be made with some sort of fluid, my theory is that they're using SPH, check the video below, it's quite impressive.

Gish 2 Fluid Dynamics


Top
 Profile  
 
 Post subject: Re: Fluid Simulation
PostPosted: Fri May 09, 2008 2:23 am 
Offline

Joined: Sun Sep 23, 2007 2:35 pm
Posts: 803
I did play around with simple pseudo-fluids like this in JBox2d, in the most recent SVN there's a very simple test of something like that (actually I also used a spring force and some sensors to cut down on the number of actual contacts). The applet demo for that update is not online yet, I'll post a note here when it is. Simple circle + optional force methods work okay for some things - you could certainly reproduce the type of stuff you see in that video without too much trouble, though slowly. The problem is that it takes a lot of particles to get decent results - if you look at the comment on that video, you'll see the following: "This didn't happen in real time; by the end of the long section each frame took about six seconds to calculate. There were about 3000-4000 particles in that scene." 3000 particles is a huge amount, especially when they're all piled up. It's really tricky to get running well in real time - I've gotten quite a few particles going, but when you end up with such a massive contact graph, you can't hope for miracles. With SPH you at least don't have to handle solid contacts and interpenetration constraints, which means you don't need, for instance, 10 iterations over every contact. However, stability is always tough, as it is a force based method, and to get nearly incompressible fluids requires very high force constants, which in turn requires tiny time steps. Tuning is everything.

I still haven't gotten SPH working in Box2d yet, though I've started playing around with it, so maybe in a while (read that as a few weeks, at least - this is somewhat low on my todo list at the moment) I'll have something to show.

It's worth noting that even with that, you're not going to get results that are too fantastic. Phun has, to my knowledge, SPH fluids, and once you start to use more than small amounts of fluid, things really get slow. I think for a lot of purposes, buoyancy methods like the one Erin wrote about are going to be more useful, perhaps with a little particle based stuff around the edges for effect.

BTW, re: Gish 2, I'm pretty sure that stuff is not fluid based, it's just a clever system of spring connections with some interesting controls. I'll be interested to see if they can make that type of scheme work well in the game, it could be very cool if they get the user interaction down so that it looked cool and was still easy to play.


Top
 Profile  
 
 Post subject: Re: Fluid Simulation
PostPosted: Fri May 09, 2008 2:28 am 
Offline

Joined: Tue Sep 18, 2007 6:17 am
Posts: 155
Location: Western Cape, South Africa
Agreed, Gish might be a lot harder if you keep breaking into smaller bits... but it sure looks cool :D


Top
 Profile  
 
 Post subject: Re: Fluid Simulation
PostPosted: Thu Jun 19, 2008 5:44 pm 
Offline

Joined: Sun Sep 23, 2007 2:35 pm
Posts: 803
I finally got a chance to put some code down on this and now have a demo running (it's a Java applet): http://www.jbox2d.org/liquid/

Very rough, a lot of tuning needed, not optimized, doesn't look quite like water, too "gloppy," etc. - yup, I know. Basically, this is not ready for release or use, nor is it actually integrated into the engine (I hard coded this example). It's also not physically accurate, as I'm using a simplified solver at the moment. And I can't even release the code yet because I may have used a couple things I don't have permission to redistribute source for, so there's a lot to do on this...

But it's 1000 particles, and it runs decently fast (graphics slow it down quite a bit, but the simulation itself is pretty quick), so that's encouraging as a proof-of-concept. To be truly useful this type of simulation would have to be supplemented by a cheaper buoyancy solver, maybe one that does some simple wave mechanics, too, so that you can simulate larger bodies of water, since this simulation method gets unstable when the pressure gets too high.

Is there much interest in this type of thing? I'm also working on some soft body blob stuff if anyone thinks that should be higher priority.


Top
 Profile  
 
 Post subject: Re: Fluid Simulation
PostPosted: Thu Jun 19, 2008 5:47 pm 
Offline

Joined: Tue Feb 12, 2008 4:54 pm
Posts: 130
That looks very cool, it'll be great to play around with.

Bill


Top
 Profile  
 
 Post subject: Re: Fluid Simulation
PostPosted: Thu Jun 19, 2008 5:52 pm 
Offline

Joined: Wed May 21, 2008 9:08 am
Posts: 47
Wow, that is very cool... I enjoyed dragging the box around and messing with the flow.

Can't wait until you're ready to release!


Top
 Profile  
 
 Post subject: Re: Fluid Simulation
PostPosted: Thu Jun 19, 2008 6:09 pm 
Offline

Joined: Fri Mar 14, 2008 12:18 am
Posts: 58
Very cool.

What you have is 80% of what I would need for my game. Because of the scale, insect size, the goopy water makes sense. 1000 particles is very promising.

I plan to use fluids as an interactive effect, no large bodies of water.

I'd be most interested to see what you've done. I say, work on getting it stable and free.

-nick


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 97 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 10  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group