Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

How do I simulate water droplets realistically falling, gathering, and flowing down a window? For example, see http://www.youtube.com/watch?v=4jaGyv0KRPw. In particular, I want to simulate how smaller droplets merge together to form larger droplets that have enough weight to oppose the surface tension and flow downward, leaving a trail of water.

I'm aware of fluid simulation, but how would it be applied in this situation?

share|improve this question
add comment

5 Answers

up vote 2 down vote accepted

There was a good rain-on-glass simulation in the ATI Toy Shop demo from a few years ago. See the video starting at 1:30; presentation slides on the whole demo are here and there are course notes (mostly the same material as the slides) in Chapter 5 of this document.

share|improve this answer
add comment

Metaballs in 2D. A great raindrop example (3D) here, while this shows how metaballs look in motion. You can write this as a shader, if you want to use the GPU.

Alternatively, in late 80's / early 90's demos they sometimes just use transparent sprites and move them down the screen irrespective of one another. It doesn't look too bad, but it's not very realistic. However kudos to those guys back in the day for keeping things simple. I think there are some blendmodes on some platforms that do not add to each other's effect, i.e. they will just merge. This would look somewhat better, using the same approach.

share|improve this answer
    
That seems useful, but how do I simulate the streaks that droplets leave when they flow down, and how do I simulate the droplets merging into larger droplets that have enough mass to resist the surface tension and flow down? –  skyuzo Nov 17 '11 at 21:51
    
Streaks are just smaller droplets, aren't they? Just as in real life, the streak is left behind, as erstwhile parts of the original droplet volume. If you need more volume than that, you can have each metaball growing in volume even as it is losing volume to smaller metaballs it is trailing behind itself. Presumably your mass is a function of the current metaball's diameter, and you do conditional logic based on that, to resist merges? Seems straightforward to me. You're not going to know anything for sure until you get stuck into the code. That's a fact of life! –  Nick Wiggill Nov 17 '11 at 22:28
add comment

Unless rain is especially important in your game I'd go with a fairly simple simulation like the one described at http://blogs.msdn.com/b/shawnhar/archive/2009/04/13/motogp-raindrops-keep-falling-on-my-lens.aspx

share|improve this answer
add comment

I found a good paper related to this topic: "Realistic real-time rain rendering" by Rousseau, et. al. They survey several current techniques (with references) and describe a new algorithm and their GPU based implementation

share|improve this answer
    
Perhaps you could add a link to it for easy access. :) –  Richard Marskell - Drackir Nov 17 '11 at 13:57
    
Google turns up a number of hits, including: cse.iitb.ac.in/graphics/~pisith/references/… –  amb Nov 17 '11 at 14:29
    
Sorry, maybe my question was unclear. I'm specifically looking for simulating water sitting on a window due to surface tension and interactions related to surface tension and merging. I've edited my question. –  skyuzo Nov 17 '11 at 21:56
add comment

Just maybe, you already spelled out your solution, it will just be your job to implement it.

Looking at what you've mentioned, you have the following things to implement:

  1. Metaballs in 2D
  2. Estimated mass from size of Metaball
  3. Estimated surface tension (a constant)
  4. Whether F=mg is enough to overcome the surface tension.

This will give you the desired effect; a more advanced implementation may then introduce metaballs which are "left behind" when the source metaball has a non-zero velocity. Then just apply a function that randomly generates impacting raindrops by throwing metaballs at your surface from a specified vector.

As for the performance of this, your on your own :P.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.