Weather Effects
By Matthew Bague
Project Background
For my final project, I made weather effects for a scene. The scene has a lighthouse with a rotating light that the user can toggle on and off. The three weather affects I wanted to target were the following:
- Fog
- Rain
- Snow
Controls
- w = Zoom in
- s = Zoom out
- a = Rotate left
- d = Rotate right
- r = Move up
- f = Move down
- 1 = Default scene
- 2 = Fog scene
- 3 = Rain scene
- 4 = Snow scene
- z = Toggles lighthouse's rotating light beam
- p = Toggles rain/snow particle system
- v = Make lighthouse light the default yellowish color
- b = Make lighthouse light blue
- n = Make lighthouse light red
- m = Make lighthouse light green
- q = To quit
Light House
The lighthouse was handmade by me using VBOs and IBOs. The geometry for the lighthouse is made up with:
- A square frustum for the bottom/base.
- A hexagonal prism for the glass windowed room.
- A four-sided pyramid for the roof.
Light Beam Effect
The inspiration for the lighthouse and light beam came from The Legend of Zelda: The Wind Waker. If you've played the game, recall
the lighthouse on Windfall Island. Below is a picture from in-game of the lighthouse with its light turned on.
Since OpenGL doesn't have a built-in function to make an actual beam of light, I had to "fake" it using geometry and
modifying the alpha value. As the light beam gets farther from the source (the center of the lighthouse), notice how its intensity
drops off. This was done by using the gl_FragCoord to determine the alpha value. Also, I made it so the light could be several colors.
Fog Effect
While there exists a glFog effect function, I had trouble getting it to work (also, this function is deprecated in later versions of
OpenGL) so I decided to just do the work directly in the shaders. At the center, you'll notice that there really isn't a fog effect. That's because
the function works based on how far the viewer is from the center. As you move farther from the center, the fog effect becomes more
prevalent. See images below.
Rain Effect
The rain was made using a particle system that used instancing. Each particle is a billboarded slim rectangle and has its own properties, such as life, velocity, position,
color, transparency, and so on. Particles are shot out from an emitter that I placed above the lighthouse (see image below on the right).
The maximum number of particles I allowed in the system was 100000. Coincidentally, the rain and snow effects look very similar to the one used in Minecraft.
When the particle system was turned on, I was getting around 30 FPS on my netbook, compared to the 150+ FPS I was getting when it was turned off.
So it definitely takes a bit of processing power.
Snow Effect
The snow effect uses the same particle system as the rain effect. The only difference is that particles are white and billboarded squares.
Also, I rotated the emitter so the snow blows to the side as if it was being pushed by the wind.