View Full Version : Fluid Demo
LemonScented
03-20-2009, 02:07 AM
Hi,
I'm new here, and was told that this might be a good place to start posting. My name is Jack, I'm working on a game for a new indie dev house called Lemon Scented Games ( http://www.lemonscentedgames.com/ ), and we've just put out our first video of our fluid test code, which you can see a video of here:
http://www.youtube.com/watch?v=j3HpzPAgbkc
The game is all about paint, so fluid physics is a major part of it. The game doesn't quite run at the framerate hinted at by the videos (that's 3000 particles, which in the video is at 30 frames per second but in reality is at a framerate which is interactive but not quick enough for a game), and there are some stability bugs in there (which we left in the video because they looked kinda cool, but they need fixing). Any advice or feedback would be welcome.
Colescheffler
03-20-2009, 02:53 PM
That looks pretty cool! I can't wait until you go further with this "fluid test code" ;)
UberGimp
03-20-2009, 03:09 PM
That looks friggin awesome! :D
Cant wait!
The composition in the video was awesome aswell!
Treacle109
03-22-2009, 08:00 PM
I love the way that the paint changes colour when it mixes, Are you planning to have a gameplay sort of like Mercury?
LemonScented
03-23-2009, 12:39 AM
The paint mixing was just something we did in the video editing, we're planning on showing that off properly at some other point. But to answer your question, yes, we're planning on some of the gameplay being a bit like mercury - splitting up paint streams and mixing them into new colours.
samysam
03-23-2009, 01:22 AM
Hey, this looks simply astonishing! Are you using a similar technique as Kot?
Treacle109
03-23-2009, 04:26 PM
Great! Loved the puzzles in mercury :P How is the paint going to be controlled in your game?
LemonScented
03-24-2009, 02:43 AM
@ samysam: Not a million miles away from what Kot's doing - the underlying maths is the same, but some of the finer details are a bit different (I've been asking him about some of how he does it by email 'cos he's clearly better than me at this! ;) ). Kot's videos on Youtube are what led me to this site, and I'm quite excited because not many people seem to be taking this type of use of fluid in games seriously yet. The theory has been around for a while, but it's only recently that computers have got powerful enough to really do interesting things with fluid in games.
@Treacle109: A lot of stuff has yet to be decided (we haven't coded it yet!), but we're thinking in terms of what we call "toys" - pieces of factory machinery that you control with buttons or switches. I suppose the trapdoors in the video count as toys, and the wheels are a simple way to split streams of paint up into seperate ones for mixing or redirecting, but we're hoping to have some more sophisticated things as well.
It's cool that people seem to be interested in this. We've obviously still got a long way to go to make a full game out of it, but in the meantime it's important to us that people are excited about what we're trying to do.
Treacle109
03-24-2009, 07:12 PM
Fun-Motion is a great place to chat about games you've found or games that your making, Glad we have a new developer here :P
h4tt3n
03-25-2009, 07:23 PM
The paint mixing was just something we did in the video editing, we're planning on showing that off properly at some other point. But to answer your question, yes, we're planning on some of the gameplay being a bit like mercury - splitting up paint streams and mixing them into new colours.
Very intersting - and very british - demo :-)
I noticed that color mixing currently is additive ( f.inst. yellow + purple = white) whereas real paints mix subtractively ( yellow + purple = gray / black).
Is this going to be changed?
Cheers,
Mike
(Lemon, if you're intersted I made a (grid based) fluid dynamics paint mixing demo with subtractive colours using opengl. wouldn't mind posting source.)
GreyMario
03-25-2009, 07:30 PM
Have you noticed that the particles spaz out when compressed?
UberGimp
03-25-2009, 07:56 PM
I noticed that color mixing currently is additive ( f.inst. yellow + purple = white) whereas real paints mix subtractively ( yellow + purple = gray / black).
Is this going to be changed?
I noticed that aswell.
Only light mixes additive like that, so you should definently change it (:
LemonScented
03-25-2009, 11:13 PM
h4tt3n, I'm always interested in seeing source ;) It's my favourite way to learn new stuff or see how other people like to do things - much better than white papers or reference books. For what it's worth, we've already got more paint-like mixing working, it's just at the time we did the video it was running so slowly that we weren't sure if it'd make it into the final game. A couple of days after the video I got it working as a pixel shader so it's definitely going in now, and should show up in any future videos or screenshots.
@GreyMario - Yeah, there are still some stability issues that we're working out. We ended up leaving the bugs in the video because even though they're bugs, it looks suitably dramatic. We're itching to get onto adding in a bunch of physics toys to interact with the paint, but right now the priority has to be getting it all stable and running quicker.
h4tt3n
03-26-2009, 09:58 PM
I'll first need to translate the code into c++, which will be during this weekend. The gist of the subtractive colour thing would in your case be something like: make your particles overlap and use this blending method to find the color of the overlapping area:
glblendfunc(GL_DST_COLOR , GL_SRC_COLOR)
If you want a less "perfect" and more lifelike mix, give the particles an alpha value of ~0.1f and use this blending method instead:
glblendfunc(GL_DST_COLOR , GL_SRC_ALPHA)
Btw I might have a useful tip on how to apply very stiff springs = stable, non-wobbly fluid. (assuming your simulation is force based?). The sceme spends as much cpu resource as the RK4 but allows for much higher stiffnes coefficients.
EDIT: arh, what the heck. Here's (http://www.jernmager.dk/stuff/freebasic/fluid_hack.zip) the code + exe as-is. In the fluid sim, press left, middle, and right mouse to add paint and stir the fluid. Have fun!
Cheers,
Mike
RayzaB
03-27-2009, 05:07 AM
Nice code there H4tt3n.
h4tt3n
03-27-2009, 06:22 AM
Hey thanks! Forgot to mention that the actual fluid dynamics is done with Jos Stam's famous method. I just added more densities, one for each colour, and subtractive colours. Btw. don't look at the code, It's so messy it'll make you blind :-)
LuizZak
05-03-2009, 05:26 AM
I like the relaxation and tension, makes the fluid even more realistic :]
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.