Rain Simulator
a precipitation renderer
Felix Gonda
Final Project Report
Introduction to Computer Graphics
Instructor : Dr. Hanspeter Pfister Harvard Teaching Fellows: Moritz Baecher School of Engineering Kevin Dale & Applied Science Kalyan Sunkavalli Yuanchen Zhu Fall 2010

Table of Contents
• Abstract
• Motivation
• Approach
• Results
• Future Work
• Acknowledgements
• References

The impact of atmospheric effects is very important in creating realistic environments in movies or games. 
Effects such as rain, fire, and snow are quite often used as story elements to convey the mood and feeling 
of a scene. Simulating these effects, on the other hand is quite challening. This project presents an 
implementation of a system for rendering rain fall and its interaction with environment: rain drops, 
splashes, and wet surfaces.

Most rain system are implemented either as a particle system or a camera-centerd geometry with scrolling 
textures.  The former can be slow in real-time, while the latter, although fast, lacks the sense of depth 
and is difficult to exhibit local lighting such as street lights and secondary weather effects such as wind.

One of my biggest motivation is "ATI Toy Shop" demo that was created in 2005 to demonstrate capabilities of 
Radeon® X1800 graphics card. Although the Toy shop demo does include realistic rain, wind and collisions in 
their video, the realism came at a cost: it required 300 unique shaders dedicated to rain alone and is 
based on a manually designed rain mask.

This project creates a particle-based rain system with special focus on realism of the rain and its effects 
on objects in a virtual environment.   

Below is a description of the implementation of the rain and wetness system.

Rain Simulation Architecture
To simulate the rain environment, the engine represents the world as a virtual scene with objects, ground,
lights, and a camera system that can be moved about the scene. Objects of various texture surfaces are 
placed in the scene to depict the interaction of rain with wood, rock, leather and metal.  A dynamic light
is also placed in the scene which can be attached to the camera.  The dynamic light can be used to closely
inspect surface details of objects and observe per pixel lighting effects.

Precipitation is modeled as four particle systems (rain zones) surrounding the camera. Rain drops are 
spawned at a reasonalble random height above the scene ceiling within the rain zones and animated over time 
using gravity and wind as external force effectors. 

As the cemara moves, the rain zones surrounding it are recalibrated so newer rain drops spawn in the camera
vicinity. This is important because the camera will not be able to observe rain drops that are further away,
as such it is not necessary to spawn rain drops at that distance.  Rain zones within the camera frustum are
simulated and rendered; whereas those outside the view frustum are only simulated but not rendered so 
as the camera orientation changes the sense of immersion is felt.

Rain drop
A rain drop is rendered as a billboard (small quad always facing the camera).  Its appearance is determine 
by a translucent diffuse texture and the contribution of ligthing in the scene.  A single fragment shader 
is used to control the contribution of lighting and translucency of the rain drop. The trajectory of the 
rain drop is determined by its physical properties, namely, position, mass and velocity. These properties 
are further influenced by external forces such as gravity and wind which determines the velocity of the 
rain drop until it reaches terminal velocity.  At terminal velocity, the rain drop is animated at constant 
velocity until the end of its life span or it collides with objects in the environment; at which point it 
is re-spawned at a reasonable height above the scene ceiling.

Rain splash
When a rain drop collides with objects in the environment, a splash particle is spawned at the impact 
location and animated for a short time. The splashes are created based on the wetness level of the object 
the rain drop collided with. If the object is not wet enough, then a splash is not relevant.  No splashes 
are created for rain drops which do not collide with objects or are out of scene bounds.  The appearance 
of a rain splash is controlled by a translucent texture and the contribution of lighting in the environment.

Wet Surfaces
Each object in the scene, except for lights, reacts to rain over time by taking on the appearance of a wet 
object. As rain drop collides with an object, its wetness level increases and its surface starts to exhibits 
wetness. Each object reacts differently based on its surface characteristics.  For example, a stone gets wet 
quicker than a brick. A fragment shader is used to control the wetness appearance of objects.  The shader
takes as input a water bump texture and a detailed normal map texutre. These two textures are used to pertube
the surface normals of objects using texture coordinates tiling and panning based on time scale and surface
wetness level.

Rain sounds
Using fmod sound library, a sound interface is added to the renderer to play rain ambient and drop sounds.
This is a very straight-forward implementation, and gives the system another dimension of realism simulation.

The main scene takes place out door in a night-time rainy environment.  The scene consists of an ambient 
light, three point lights of different color grade, a dynamic light, a set of blocks of different material 
properties, and a camera placed at a vantage point. Thunder storm and rain ambient sounds plays in the 
back ground, and rain drop sounds can also be heard randomly on drops.

The camera can be move about the scene and is restricted within scene bounds.

The dynamic light can be attached to the camera and move about the scene.  The same restrictions applied
to the camera also applies to the dynamic light.  Furthermore, the dynamic light can be blink or unblink
and the color can be change by the user.

As of this writing, the demo runs at 120 frames per seconds.

Future Work Beyond this milestone, I intend to continue working on this renderer to improve frame rate performance by off-loading rain drop simulation to the GPU. I also would like to improve the rain splash generation system so its not collision-based. By building a smarter and performant render, it can be incorporated in real-time games to simulate rainy weather. Acknowledgement - Moritz Boecker for supervising project and giving feedback - Jeff Wilson for designing rain fall sounds - Hiro Hattori for giving valuable feedback and helping with textures - Henrik Halén for giving technical feedback and reviewing techniques - Paul Keet for giving technical feedback and reviewing - Erica Pinto for overall feedback References Research Materials & References: (1) ATI: ToyShop ATI: ToyShop Natalya Tatarchuk Natalya Tatarchuk ATI. (e.d.). (2005) http://developer.amd.com/media/gpu_assets/ToyShop-Eurographics_AnimationFestival.pdf (2) Tariq, S. (2007). Rain. NVIDIA Corporation, Retrieved http://developer.download.nvidia.com/SDK/10/direct3d/Source/rain/doc/RainSDKWhitePaper.pdf (3) The Columbia Encyclopedia. (e.d.). (2008). rain. http://www.encyclopedia.com/doc/1E1-rain.html (4) The Columbia Encyclopedia. (e.d.). (2008). rain. http://www.encyclopedia.com/doc/1E1-rain.html (5) Columbia rain texture database: http://www1.cs.columbia.edu/CAVE/databases/rain_streak_db/rain_streak.php (6) „Realistic real-time rain rendering” Pierre Rousseau, Vincent Jolivet and Djamchid Ghazanfarpour Computers & Graphics, Volume 30, Number 4, 2006 (7) „Creation and control of rain in virtual environments” Puig-Centelles, A., Ripolles, O. and Chover, M. The Visual Computer, Volume 25, Number 11, November 2009 (8) Water Flow in Portal 2 Alex Vlachos, Valve July 28, 2010 http://www.valvesoftware.com/company/publications.html