Water drops like the DriveClub's.

UPDATE 2017: This thread is too old and obsolote, new visitors be aware!!


Hello.

Have you seen the water drops on a car windshield of “DriveClub” video game for PS4? if no, please have a look at the GIF below:

(http://media.giphy.com/media/3ohzdGteRdT4Gvhzby/giphy.gif)
(C) GIF BY:Eric Chadwick

So here is what I’ve made so far:

(http://media.giphy.com/media/xUPGcvSuHjg9uV7Bzq/giphy.gif)

ATTENTION: This is only a first try of making metaballs, And is simulating one water drop (metaball) in a bigger scale, because of performance issues. Otherwise it is possible to spawn a lot of them in a smaller scales but frame rate would be 4-5 FPS.

but the problem is that when a car with that water drops goes a bit fast in my game, the water drops goes upward super fast, have a look at the GIF below:

(http://media.giphy.com/media/xUPGctsq8p9v3lZqdG/giphy.gif)

Simply it is a particle emitter that emits particles (the emitter is placed near the pointer in the last GIF image) and each particle has a collider, windshield has a collider,too. so when they collide they act as water, with a shader and a script those particles appear as water. As the car increases it’s speed, the particle goes upward which is correct but the water drops act as if the car has a supersonic speed.

Then to solve this problem, I increased frictions for both windshield and water drops, reduced and even increased wights of water drops and added force in (new vector3(0f,-100f,0f); ) to the water drops, still the problem is happening. Both windshield and the custom 2D Particles (with 3D colliders) have rigidbody.

For more information about how did I create this effect, visit this address:
http://www.polycount.com/forum/showthread.php?p=2337044#post2336924

(C)Copyrights and notes:
Shader: Rodrigo Fernández
rest of the things and the new shader me.
Images links are updated.
If you the GIFs don’t show up, try clicking on the hyperlinks.
Thanks to Obscura and MrChadwick for their helps.

Maybe it seems stupid but I just tried a 2D collider with a new script but obviously it wasn’t working.

Physics for raindrops on a windshield?

no.

1 Like

Read the first post here it’s a 2D particle. Still needs some more things to be done.
However I think this thread became a bit complicated for visitors, Apologize for that.

This :slight_smile:

Not trying to be a comedian, just trying to suggest that using colliders and all this stuff is probably not the way to go.

I’ve solved the problem and finished creating this recently, still needs some tweaks but the problem is now fixed. Here’s a GIF:

However, since I’ve used big particles due to lower CPU usage, this effect became a bit less realistic, for more realistic effect smaller sphere mesh is recommended.

Hardly going off topic. Its clever, but pointless and a waste of resource for an effect that doesnt look real at all (yet)…

The original link you posted will be completely faked. No-one would simulate individual rain drops in a car racing game.

1 Like

I found an interesting note on this Eurogamer website:

1 Like

There you have it: Screen space effects. It’s not going to be 3D rigidbody dynamics with mesh collisions for each individual droplet with impulses in 3D and all that. Physics simulations can be done at many levels, I’ve written a system that runs at 500,000 Hz on a compute shader to simulate gas dynamic flows for a real time internal combustion engine simulation, but it’s not done the way you’d think.

No doubt they did an incredible job, very clever, but it wasn’t some “drag and drop a particle system and turn on the colliders and go PhysX, go” type of thing. When you’re only getting 4 or 5 fps with very little rain, it’s time to consider the possibility that they put a little more brilliance into their rain than we would be doing by just dropping some particles onto a windscreen and thinking it’ll do the same thing.

At some point it’s like trying to do a car simulation by modelling every single molecule in the car as a separate rigid body and then wondering why the frame rate is 0.0000000000001 fps.

Just to be clear, I’m not trying to discourage you from doing rain on a windscreen, I’m just saying that a system like that is not doing quite what you think it is. There’s something fundamentally different about their system that isn’t likely to be replicated with some PhysX particles and colliders. It’s a custom physics model written solely for the purpose of producing that rain effect. This is why you’re having performance problems.

I’d love to see you make great rain effects like that, I’ll root for you, but chances are that you’re going to have to think of some other way to do it than using the built in physics.

1 Like

If I had to take a wild guess at how they did it, or if I were to take a first stab at it, it would go something like this:

The windscreen simulation would probably be a 2D grid of fluid flow. They model some outside rain somehow, and when a drop (which is not actually a rigid body with much if any physics per se) strikes the windshield, the value in the cell goes up, filling it partially. Do fluxes across the cell boundaries and pseudo forces up the windscreen depending on wind, and you can get water to flow from one cell to the next. The wipers would form a simple boundary (notice how straight they are) that can move stuff between the cells. Maybe not all of it, so you get a smear. It’s all probably done in a compute shader. If it isn’t, it should be.

It’s probably something along those lines, a flow simulation something like CFD (or my engine simulations) but in 2D, not a bunch of individual rain droplet particles. Do you see how the droplets collect on each other, pool up near the edges, smear out when wiped and all that nice stuff? You won’t get that nice with particles. It’s just not the way to even try to do it, quite frankly.

Study up on water flow simulations done on grids, CFD type stuff. Then you’ll be heading down the right track and one day might do something as good as they did.

Before answering your posts, please note that I am not professional and I’m just learning, some professional artists helped achieving this effect in an other forum (mentioned in the first post), then one of them helped me to make this particle, so I am not emphasizing and I won’t emphasize that this is the only way to recreate the effect, yet I’ll be glad to show me other ways of creating this effect, of course this thread would be useful for other people if useful contents be here.

Now this is an informative reply, comparing to your last reply. And yes, it is not that much realistic, but this isn’t totally unrealistic! Thanks for your reply,though.

great, thanks so much.

Thanks for your informative reply, so you say that Grids and non-PhysiX physics are used? I will study them when possible,though.Also I get around -4 fps for each 180 particles, so there is no 0.00000001 fps.

I don’t know anybody at that company so don’t really know how they did the rain effects. I was just guessing and suggesting how I would begin to go about solving the problem: Fluid simulations, not rigid bodies with collision meshes with very expensive collision detection/response computations. So I don’t know for sure, but to me it seems very unlikely that they’re using PhysX or anything like that. It’s most likely an internally developed, proprietary, purpose built system just for the windshield rain effects. I could be wrong, but I’d put my money on it being a fluid simulation. To my eye, it looks too good not to be. :stuck_out_tongue:

0.0000001fps - I didn’t mean to suggest that that’s what you were getting. I was making a point about the relatively large amount of computations that need to be done by simulating systems like that with rigid bodies. Fluid simulations like those are usually something like finite volume techniques. You can’t model every molecule or tiny, tiny little dot of water independently (how do you smear them, get them to stick together, etc?). CFD like that works in a fundamentally different way.

Anyway, you might want to look to see how water and fluid simulations work instead of using particles. There are definitely physics going on in that windshield/rain simulation, it’s just a different type of simulation than you might be aware of at this point. You might get there some day, but I’d suggest changing course on the whole approach.

1 Like

It’s probably something more along these lines:

http://http.developer.nvidia.com/GPUGems/gpugems_ch38.html

This is dated and written before compute shaders were around. So don’t pay too much attention to the trickery they’re doing with the fragment and vertex shaders. Back then you had to do it that way because that’s all there was. It’s a lot more straightforward today because of compute shaders.

If you’re not a shader guy at all yet, that’s ok. What I’d do is try to write the simulation on the CPU like you’re doing now. Don’t worry too much if it’s not super fast. When you pop it over into a compute shader it’ll really fly.

Here’s an example from my engine simulation work:

This is a real time engine simulation that produces audio in real time. It’s not mixing sound files together, it’s computing the wave form on the fly as the simulation runs and then running some of that information through the speaker. It’s computing all of the exhaust cell states 500,000 times per second (imagine setting Unity’s physics time step to only 0.000002).

This would not be possible to do outside of a shader. One of the smaller engines I did, think it was a 4 or 8 cylinder, ran 43,000,000,000 (43 billion) calculations per second. This 11 cylinder is quite a bit higher than that. Your CPU can do a little better than 1 billion per core. So to do this on a CPU in real time like this you’d need a cluster of at least 10 or 11 quadcore machines. Even then I think the data transfer rate probably wouldn’t allow it (not sure).

So yeah, compute shaders are VERY fast for problems like fluid flow, anything that can be parallelized massively enough and if you can do some tricks to get rid of all the branching/if statements and that kind of thing. So just remember in the back of your mind that there are options to get massively more speed than you might even think is possible.

1 Like

Great post @Todd-Wasson , what you’ve said is completely new for me, Is it possible to use these “compute shading” stuff out side of making games, like for example data analyzing or something like that? are those engine sounds for a game or for a automotive manufacture?

Since I don’t know writing shaders (I make game for fun right now), I’ll use this current particle system but when I get into the shaders, I will definitely use them instead of this.

Yes, absolutely. It almost seems like that’s what they were invented for. It’s called GPU computing and is used for scientific purposes all the time.

https://www.google.com/webhp?sourceid=chrome-instant&rlz=1C1GIWA_enUS615US615&ion=1&espv=2&ie=UTF-8#q=gpu%20computing

https://www.youtube.com/results?search_query=gpu+computing
https://www.youtube.com/results?search_query=scientific+gpu+computing+

My understanding is that supercomputers these days are all being built around GPU’s with scientists using compute shaders (CUDA mainly, but DirectCompute like we have in Unity is good too).

I had video games in mind for it, but it could have applications in the automotive industry as well. That industry does audio simulations too, but they operate differently and aren’t usually (if ever) real time like this. It’s the same goal in mind though.

I did try the audio simulation in the boat sim about a year ago to see if it would work. Surprisingly it did:

https://www.youtube.com/watch?v=hAO7SMqUfI0

Unfortunately it’s still too hungry for power to run a game on top of it, even with the GPU doing all the work. It starts hitting the frame rate pretty hard and in my opinion doesn’t sound as good (yet) as some professionally mastered and recorded samples. Here’s an example of recorded samples by a pro that does engine audio for a lot of today’s racing games:

https://www.youtube.com/watch?v=7hG47hpvD4A

It sounds better overall to me than my system, unfortunately. As much as I’d like my audio simulation to be able to replace good audio samples some day, it’s just not there yet. I have some ideas on how to improve it, but that’ll have to wait awhile. Maybe some day.

Sure, good idea. This is just stuff to keep in the back of your mind while you’re playing with your particles. That’s how good ideas develop. You start with what you know how to do, and while you’re playing around with it, other ideas come to mind, sometimes in the middle of the night. So if the idea excites you, just keep going with it. Who knows later what new, brilliant thing you may come up with? :slight_smile:

1 Like

Heh, the abrasiveness/helpfulness of my posts depends on my mood at the time of post (was definitely not trying to discourage you from doing what you’re doing). Im just very… up front about what I think (sometimes looking like a jerk in the process)

I got a kick out of it and was thinking pretty much the same thing. :wink:

1 Like

No problem guys, People are different. We just should remember to respect each other and that’s it, I’ve learned new things here, hopefully other people like me will learn those things here,too.

Peace.