2
\$\begingroup\$

I see many examples of particle system in old style OpenGL with falling raindrops. Examples of rainfall that can interact with environment lighting and look realistic are hard to find. How to create realistic rainfall animation in modern OpenGL using shaders?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ This: shadertoy.com/view/XdSGDc ? \$\endgroup\$ – mythos Sep 20 '16 at 14:51
  • \$\begingroup\$ @LukGus but I was referring to a standalone OpenGL and shader based examples. SharderToy is good to experiment with post-processing in fragment shader but hides a lot of details and provide only minimal user control. \$\endgroup\$ – Asif Sep 25 '16 at 21:51
1
\$\begingroup\$

No one is going to give you a detailed solution because it's too much work but I can give an overview.

You would probably want to use a geometry shader to create a sort of elongated teardrop shape. You will have to create quite a lot of them obviously for a big scene and to be realistic, and to keep them in a particle system that moves and updates them.

Here is a tutorial that goes over the basic ideas: http://mbsoftworks.sk/index.php?page=tutorials&series=1&tutorial=26

It will also be important to apply specular mapping, environmental mapping and refraction on top of that.

You can also detect collisions and then create splatter in a similar manner to how you created the original drops.

\$\endgroup\$
1
  • \$\begingroup\$ you are right, it does seem a lot of work. Thanks for the tutorial link. \$\endgroup\$ – Asif Sep 27 '16 at 4:51
1
\$\begingroup\$

There are multiple ways to go about this. At different distances you will probably want to use different solutions.

At a very close distance you might want to add an animated overlay with refraction. This simulates raindrops hitting the camera lens, so its a cinematic style effect, not fit for all games.

For the medium distance you might want particle effects, but single drop particles are really costly, so you might want to consider handling multiple droplets as a single particle.

For making things look wet you could probably apply an overlay to the surfaces themselves. First making the colors darker, increasing specular, and adding a smoother bump map, that could be animated, which would simulate water flowing over the surface.(Take a look at Dungeon Defenders dragon level as an example of this)

Finally making the lighting more smooth and darker can add a lot to the atmosphere, making it feel as if it was really raining. A good HDR cubemap can do a lot for this.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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