next up previous contents
Next: 18 Tuning Your OpenGL Up: 17 Natural Phenomena Previous: 17.9.6 Particle Systems in   Contents

17.10 Precipitation

Precipitation effects such as rain and snow can be modeled and rendered using the particle techniques described above. The task can be broken down into several tasks:

  1. Realistic particle rendering.
  2. Computing particle dynamics.
  3. Managing particle lifetime.

The basic particle rendering techniques are described in the preceding section. Using snowflakes as an example; individual flakes can be rendered as white colored points. Ideally the particle size should be rendered correctly under perspective projection as discussed for light points in Section 17.7. Since the real-life particles are subject to the effects of gravity, wind, thermal convection, etc, the modeled dynamics should include these effects. However, much of the complexity lies in the management of the particle lifetime. Again, considering the snow example, a running simulation must be maintained for the entire world, not just the portion that is currently visible. Particle dynamics may cause particles to move from a portion of the world which is not currently visible to the visible portion or vice versa. In the snow example, particles may shrink and disappear to mimic the melting effects of the sun.

One of the more difficult problems with managing the lifetime of particles is the end of life of the particle. Usually snowflakes accumulate to form a layer of snow over the objects upon which they fall. One way to model this is to terminate the particle dynamics when the particle strikes a surface (using a collision detection algorithm), but continue to draw it in its final position. A difficulty with this solution is that the number of particles which need to be drawn each frame will grow without bound. Another way to solve this problem is to draw the surfaces upon which the particles are falling as textured surfaces and when a particle strikes the surface, remove the particle from the dynamic system and incorporate it into the texture map used to render the surface. This solution allows the number of particles in the system to reach a steady state, but creates a new problem of efficiently managing the texture maps for the collision surfaces.

One way to maintain these texture maps is to use the rendering pipeline to update the maps. At the beginning of a simulation the texture map for a surface is clean. At the end of each frame, the particles which are to be retired this frame are drawn with an orthographic projection onto the textured surface (the viewpoint is perpendicular to the surface) using the current version of the texture and the resulting image replaces the current texture map. In order to avoid rendering artifacts when transitioning a particle from its live state to the texture map, it may be necessary to fade the live particle away over a few frames introducing a new limbo state for particles during this transition period.

Using a texture map for collided snow particles provides an efficient mechanism for maintaining a constant number of particles in the system and it works well for simulating the initial accumulation of precipitation on an uncovered surface. However, it does not serve as a realistic model for continued accumulation since it only simulates a one dimensional layer. To simulate continued accumulation, the model must be enhanced.

Changing our example from snow to rain, some of the properties of the precipitation change. Rain particles typically contain more mass than snow particles and are thus affected differently by gravity and wind. Heavy rain may be better simulated using short antialiased line segments rather than points to simulate motion blurring.

The initial accumulation of rain is a more complex problem than snow. In the case of snow, an opaque accumulation is built up over time. For rain, the rain drops are semi-transparent and they affect the surface characteristics and thus the surface shading of the collision surface in a more subtle manner. One way to model this effect is to create a texture map similar to the one created for the snow model. However, this map is used in conjunction with a multipass shading technique for the rest of the scene, partitioning the scene into two collections of pixels: those which are wet and those which are dry. The scene is drawn twice using two different shading models, one which renders objects which appear wet and another which renders objects with a dry appearance. The texture map is used to choose which computation to store in the framebuffer on a pixel by pixel basis.

Another method to reduce the rendering workload and increase the performance of the simulation is to reduce the number of particles using a ``hollywood'' technique. In this scheme rather than rendering particles throughout the entire volume a ``curtain'' of particles is rendered in front of the viewer. The use of motion blurring and fog along with lighting to simulate an overcast sky can make the illusion more convincing. It is still possible to simulate simple accumulation of precipitation by choosing points on collision surfaces at random (within the parameterization of the simulation) and blending them into texture maps as described above.

next up previous contents
Next: 18 Tuning Your OpenGL Up: 17 Natural Phenomena Previous: 17.9.6 Particle Systems in   Contents