algorithmeffects

Algorithm for creating rain effect / water drops?


What is the principle behind creating rain effect or water drops regardless of using any particular language. I've seen a few impressive rain and water effects done in Flash, but how does it actually work?

Rain Effect Example

Rain Drop Water Effect Example


Solution

  • You are asking a question as if the two examples were related, but you actually have

    1) simulating drops of rain as seen in air (drop trails; simple but the realism depends on lighting very much)

    for this you to simulate following events:

    for each time step:
        create new drops
        move existing drops vertically down
        remove (or/and animate) the drops hitting the ground
    

    as pointed in other answers new drops (size and position) can be created with various algorithms. as for speed they move with constant speed. finally to show your trails you need to look at simple projections

    2) simulating splash waves (water simulation, and in the example a reflective surface is shown)

    For this you only need to know where the drops fall and how big they are, the rest is wave propagation. However that's only really visible if there is a reflection and that can be a bit tricky.

    NOTES: There are many things that determines realism, but mostly it boils down to detail. For example rain is usually seen clearly only in strange lighting conditions - close to lamps or on high contrast background. Otherwise it is quite bleak.

    Also the details in interaction - splashing on surfaces that it hits, which can leave bubbles (if close enough to notice), or create waves.

    Another example - if you look at this tutorial, which is not really realistic, but it does illustrate one point, you will see that even though the rain looks more like a snow it exposes the 'flatness' of your first example (which has absolutely no depth).

    So, it is all about detail.

    Try to model what you have in terms of events that you have to simulate and then solve simulating each one separately - for example using fractals for seeding rain might be an overkill, but if you nicely model your work you start with random seeding and latter substitute with more accurate/complex methods.