Liquid Stimulation

Synthos

Newbie
Joined
Apr 24, 2004
Messages
593
Reaction score
0
Hard physics simulation (contact between solid or even springy objects) is not too bad.
Liquid simulation is tough. Why? Well, think about it...
Take a situation when you're driving your car in the rain. The droplets land on your car and form little pools, but because of your motion, they make water streaks towards the back of your car from the wind. Now, that's not so bad a situation. But there are so many others. Say you have one of those water towers in HL2. You blow a hole in it with a rocket. THINK of all that water, it's interaction with buildings, crevices, etc... You're in for a lot of calculations just figuring out where it's going to go, let alone render the water surfaces...

I'm proposing an alternative that just might work. I guess I'll call it "water-balls".
What you do is have many tiny hard-physically simulated balls, which have the same properties as normal objects, except between each other, they have a mild attraction and zero friction between them. Now, the number of balls would be relative to the volume of the water. You would have to tweak that ratio for physical accuracy and performance. These balls would simulate basic movement of water in a 3d environment. So when you blew that hole in the water tower, they would spill out everywhere.

To render the water surface, you would do some calculations and find specific groups of balls, then stretch a water graphic (maybe with some alpha channels) around all the balls. This would ensure that you get surface deformation (when something steps in water) as well as water displacement (think of the greek guy in the bathtub, the eureka story thing).

As a bonus, it would be fairly easy to have sponging effects as well, since you could just kill a couple balls that come into contact with a porous surface.

Earlier I mentioned adding a mild attraction affect to the balls, and you may be wondering why. This is because if you put a little bit of water on a flat surface, it beads up (due to the polar attraction of water molecules).



I'm curious as to people's thoughts on this and I'd like to hear your suggestions, criticisms and questions
 
I think the size of the balls would be limited, they would need to be chunky/large because the smaller you go, the more of them is needed and the more calculation then need to be done. its not a bad idea and it has been mentioned many times before.. I think what needs to be done is to somehow link each one together and then make them kinda expand so they dont touch each other, that way you dont have it fully solid, but you have that skin that wraps around them all, which in effect would cut down on the number of them.. or, you could make all the inner ones that dont touch the skin have very inaccurate physics calculations so that cuts down on the number of calculations that need to be made..

now thinking more about it, I think that would be good: to have a skin wrapped around all the invisible balls or points and then have the inner points very innaccurate or dumb, and have only the ones that touch the skin (the ones against any surface or air) more accurate.. maybe have the parts where the skin touches surfaces not rendered so only the top is rendered..
 
This method is just particle physics. And for it to pass as anything close to -basic- liquid effect, the number of particles, or in your case balls would be so great it would have to pass the engine entity limits five or six times over.

But even then, the effect would be similar to that of one of those ball pits in a fairground or funhouse.
 
How about dynamically sized and generated balls? If they all find themselves in something like a bucket, they could become one big ball with a bunch of smaller ones filling up the cracks? Then if you pour them out, they resize and renumber to simulate a puddle? Or is this me grasping the wrong end of the stick?
 
Brian Damage said:
How about dynamically sized and generated balls? If they all find themselves in something like a bucket, they could become one big ball with a bunch of smaller ones filling up the cracks? Then if you pour them out, they resize and renumber to simulate a puddle? Or is this me grasping the wrong end of the stick?
Thats a similar method Realflow uses for generating a liquid mesh around particles for importing into other apps. Well actually its not similar really heh.

Anyhoo these methods, while the basics of pre-calculated liquid dynamics. Are currently too intensive to be used in realtime without looking a bit naff. The low particle number method has been used before in a few games, but comes off looking like well.. a low number of particles.

If you want something to resemble liquid (not including bodies of liquid which is fine as source does it at the moment), for now atleast, you should model the liquid and animate it as a single object, and script area's where it will occur.

Or just use sprites. You can get a nice looking waterfall by using a number of layered single thickness polygons with rushing water texture over them, and some gas like misty particles at the bottom. That can work fine. For splashes then a spire sequence will do the trick. In some cases on pre-rendered footage the same methods are used. In the movies and TV, more often than not a scene with water is a mix of live footage and CG particles along with other edited effects.
 
Fenric said:
But even then, the effect would be similar to that of one of those ball pits in a fairground or funhouse.

Well, that's why you have no friction between the balls
That way when something enters the water, it breaks before them. So, it would react like water in that respect...

Who knows... but once pentium 5s come out and become standards (64 bit, 2 meg L2 cache, 5-6 ghz) we may be able to have some wicked liquid simulation
 
Like what Brain Damage said, what is needed is to take an Adaptive approach. This involves doing calculations until a certain error bound is met.

Lets take an example of a cylindrical cup full of water. When there's no object in the cup and the water is undisturbed the calculation to get beneath an error bound is one step. As the water is disturbed, the number of iterations at certain points is increasing as the amplitude of wave height increases.

When water is first disrupted, the water at the sides of the cup can still be computed in one step since it is still flat. Of course the time period where calculations are nice only lasts a tenth of a second.

Getting into fully dynamic water that behaved accurately would need to involve things like water pressure too. It should be able to be modeled with decent accuracy as long as the methods of approximation are well thought out.

Previous research in this area has probably already been done in simulations of the subdynamics of ships.
 
well, water pressure would be accounted for in the model, since those balls have mass and would push down just as the ones below push up.

The thing with my model is that it would work where most others don't: flowing water. Because, I don't know of any (even real flow) that can handle say, a fire hose, since they mostly deal with standing water. You can avoid flowing water by use of sprites and whatnot, and have cool looking standing water effects but eventually it will be nice to have water that behaves very closely to real-life
 
Synthos said:
well, water pressure would be accounted for in the model, since those balls have mass and would push down just as the ones below push up.

The thing with my model is that it would work where most others don't: flowing water. Because, I don't know of any (even real flow) that can handle say, a fire hose, since they mostly deal with standing water. You can avoid flowing water by use of sprites and whatnot, and have cool looking standing water effects but eventually it will be nice to have water that behaves very closely to real-life
Realflow was built for firehose type effects, it uses particles and in the right hands is very powerful. Realwave is the wave and water body simulator. Used together they give some wonderful results.

Still though, we're talking hundreds of thousands of particles to make it passable. What your suggesting is simply impossible in Source or at the moment in realtime anyway. You could push it to do the simulation at that level in realtime. But it wouldn't work in an actual game environment where there's tons of other things to calculcate aswell.. So a small limited demo might work, in a game, nope not for a while.
 
Of course it doesn't. It looks to me like they just put a physically simulated mesh on the surface. It won't flow or splash, it's more like a jello simulation.
 
ElFuhrer said:
Of course it doesn't. It looks to me like they just put a physically simulated mesh on the surface. It won't flow or splash, it's more like a jello simulation.


oh. Well it looks good enough, more ppl should use it.
 
I'm not saying it's possible, definetly not in source, this thread is just about the theory. With this you would not necessarily have to have a seperate body for simulating water effects, you would incorporate it into your rigid-physics engine
 
Ya it's nice to think about this kind of thing right now so it can be implemented in a future engine. By the time it takes to code this idea, the computing power will be much greater.
 
I think simulating the entire volume of a liquid would be wasting a lot of clock cycles. To simulate fluids all you need to do is maintain the volume of the fluid. You can do that by only simulating the surface of the fluid.

This could be done by creating several vertecies and making sure that each vertex has a connection to all the vertecies within a given radius of it. This would create polygons between the vertecies. You then texture them with the proper texture. Then you apply forces to the vertecies. You apply gravity to them. You maintain a repeling force between the verticies, so that they don't all collapse onto each other, and if left unbounded by a ridged object, they spread out as much as possible, as real liquid does. You establish an attraction force so that holds the volume together. You also establish a break point for the connections and a friction force for the vertecies so the volume will drag on other surfaces. This way if an object collides with the fluid mass and some vertecies are pushed away, they will break apart and form smaller volumes of liquid. These smaller volumes may even stick to the object that collided with the fluid. You could even code it so that each vertex makes sure that it has at least a certain number of vertecies around it. If it doesn't it spawns some more vertecies around it to maintain the fluid properties of the volume. In a situation where the volume is broken apart by another object, this would automaticly spawn smaller simulated volumes of fluid, creating a splash effect. You could even code it so that when another simulated body gets close to a vertex it creates more vertecies around that vertex to increase the simulation accuracy only around other bodies. Since you don't really need it to be super accurate when nothing is interacting with the fluid. Also, the fluid could seep though small cracks since the vertecies are just points in space with no size of their own. It could even drip or ooze out once it got through the crack since gravity is pulling on the verticies but friction with the sides of the crack and the attraction force between vertecies is still trying to hold the volume together.

This system would also be highly scaleable. Once you've defined the volume to maintain, you can specify a number of vertecies to use in simulating that volume. The more you use, the more accurate the simulation. If you don't need high accuracy, don't use very many. You could simulate a lake or a puddle with the same number of vertecies.

There are games with realistic liquid physics. For example, Black & White 2 has dynamic lava flows. So it's not like it isn't possible.
 
One question though. Whats the point

Apart from a visual "ooooh" moment the first few times you watch it. I don't see how it can actually be all that useful in a game. CG yes, cause it needs to be realistic. Games no, can't see how it would benefit the game other than impressing people, but that never lasts anyway. Morrowind has a neat water effect, but after the first few games you don't even notice it.
 
Fenric said:
One question though. Whats the point

Apart from a visual "ooooh" moment the first few times you watch it. I don't see how it can actually be all that useful in a game. CG yes, cause it needs to be realistic. Games no, can't see how it would benefit the game other than impressing people, but that never lasts anyway. Morrowind has a neat water effect, but after the first few games you don't even notice it.

Just what I was thinking. The only time water should need to be simulated is when something huge happens in a story i.e.

"Tidal Wave run for you n00bish lives"

Other than that I see no need to simulate water. Sure it'd be nice to see the rain build up on the ground, but why?
 
Kyo said:
Just what I was thinking. The only time water should need to be simulated is when something huge happens in a story i.e.

"Tidal Wave run for you n00bish lives"

Other than that I see no need to simulate water. Sure it'd be nice to see the rain build up on the ground, but why?
Exactly, all looks good but thats about it. And for every bit of water simulated accurately, it takes away from something else. So could end up with amazing water thats seen for a few seconds, and the rest of the game has terrible AI or low res textures.

The tidal wave even could be faked rather well without using any real simulation.
 
cyanide, I really like your theory... but how would you simulate say a water tank with a hole in the bottom? because unless you want the vertices on all sides of the water, even in standing water, it'd be really hard to simulate that.

I suppose what you could do is spawn vertices whenever water encounters air, but how exactly would you predict that?


And how exactly would you simulated volume displacement, like the eureka thing.. someone steps into a tub of water and water spills out. I'm not sure how you could get it to keep volume...
 
Fenric said:
The tidal wave even could be faked rather well without using any real simulation.

I recall C&C: Generals doing it pretty well with that movie from when that dam breaks. Add some pretty pixelshaders to that and it would suffice in most cases.
 
Back
Top