Rain and Snow

CMPS 161 - Final Project Winter 2010
Duy Dao


Description

Have you ever noticed how procedural many things in nature appear? Even though all clouds are unique, they really just look like slight variations of one another. Clouds have several easily identifiable visual characteristics that must be modeled to produce accurate images and animations. Initially I want to do project about cloud using Perlin Noise. After I read the instruction in side a web site (http://www.noisemachine.com/talk1/), I understand Perlin Noise is a hyper texturing with some translation to create animation.

After I have done project 3, I understand that my initial final project's idea is not right for animation. I decide to use particles system to create cloud and its effects (raining and snow) instead. Cloud is composed of many different particles. Each of these particles has 3 main different of attributes:
Cloud are composed of many different particles. Each of these particles has 3 main different of attributes:

All these particles are randomized in positions and size, so it fits in the idea of cloud (randomly shaped).
Raining:

The rain is made by creating a ripple with a random damp variable to control how big the wave is. The value at (x, y) depends on the average value of surrounding values. Creating a wave simulation is basically the same, but the value at (x, y) is calculated in a different manner. Our wave simulation works in three dimensions. Well, our third dimension is time. In other words: while calculating our wave simulation, we have to know how the waves looked like one moment earlier. The resulting map becomes the source map for the next frame.

This is the actual wave simulation algorithm (www.gamedev.net article 915):

ResultMap[x, y] := (( CurrentSourceMap[x+1, y] + CurrentSourceMap[x-1, y] + CurrentSourceMap[x, y+1] + CurrentSourceMap[x, y-1] ) DIV 2 ) - PreviousResultMap[x, y]

You'll notice that the first four values obtained from the current source map are divided by two. This results in a value twice the average. Next, we subtract the value at our working location (x, y) from the previous result map. This produces a new value. Look at figure a and b to learn how this effects the wave. (www.gamedev.net article 915)

Snow: The mass of each particle will affect its speed. There are gravity and wind act on the particle. Gravity makes the particles to move downward, and the wind makes the particles to move to the right. By holding "d" button, then the wind and gravity will be activated and made the particles' moving. Wind equation is very simple: Distance = Velocity*time. I use Euler equation for the gravity. Euler equation:

1) newVelocity = oldVelocity + time*acceleration.

2) newDistance = oldDistance + time*oldVelocity+ .5*time*time*acceleration.

All the particles have different speed. The bigger they are, the faster they fall. If you press 'e', then particles on the ground will show slightly bouncing up against the land then disappear to represent the act of vaporized. To do the vaporized part, I let the particles on the ground to slowly moving up. When they reach a certain distance (I called this the vaporized distance), they disappear. The mass of each particle are different, so they have different time to reach the vaporized distance.


Running Environment

To compile the Program in Linux, you type "%gmake final". To run the program type, you type "final".

To compile the program in Windows, I use Dev C++ to create this program. I create new project file in Dev C++ and copy and paste the code into the file. I click "compile and run".

Using keyboard for interaction with the program:

  • Hold "d": to drop the snow particles. Hold this button for first 2-3 seconds then it will be auto falling.
  • Press "e": to vaporized the snow. This happens only when the snow particles are on the ground. The particles have different masses, so some of them take a bit longer to be vaporized
  • Press "r": to reset everything back to the original point
  • Press "Esc": exit program
  • "Right Click" + "Moving the mouse”: to rotate the objects
  • "Left Click" + "Moving the mouse”: to zoom in/out
  • Press "Arrows keys" on the keyboard: to rotate the camera


  • Rain:


    Changing cloud particles:


    Snow falling:


    Snow on the ground


    Snow vaporized


    Program with source code



    Makefile, final.c, README.txt : Compile type "%gmake final" then type "final".
    finalproject1.exe, final : These are executive files for Windows and Linux.
    final.wmv: A video file from me.


    Refrences

    1. http://www.gamedev.net/reference/articles/article915.asp
    2. NeHe Productions, Lesson 19: Particle Engine Tutorial, http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19
    3. http://www.gamedev.net/reference/articles/article718.asp