Foggy foggy day - Final project

Matt Smith / msmith@cats

 

OVERVIEW

Proposal: Implement a real-time fog simulation by texture-mapping semitransparent noise textures on to a plane.

Background: The impetus for my final project was the prohibitive computational cost of animating a dense particle system fog. In video games, for instance, fog is often just implemented as a distance based dropoff, and doesn't react at all to environmental stimuli. I wanted to implement a fog system that was cheap enough computationally to implement in such an environment.

 

The approach I chose was to use a noise texture generated with Ron Perlin's noise functions, obtained from http://www.planetquake.com/gg/textures/open.html . Originally, I wanted to generate this on the fly, with the alpha transparency varying in tandem with the noise value, but due to my unfamiliarity with the GL_RGBA format, it didn't work properly. The pregenerated texure worked fairly well, in any case, at least to demonstrate the effectiveness of such an approach.

The original texture:

 

The vortex effect was implemented rather simply. All the points making up the plane were seeded at rectangular coordiates, which were then converted to polar. Every timestep, theta was incremented by an amount scaled to r. Though it's not really noticable, the Z value was also changed according to a negative exponential function -2^-r +C.

 

A vortex in action.

USE

 

The program basically runs on its own, but for kicks I implemented some rudimentary controls to change the lookat parameters, and to change the speed of the vortex. I and K control the Y parameter in the lookat, while J and L control the X. W and S control the speed of the vortex.

Angled look at the plane.

A neat side effect of the vortex function was the gradual decay of the rectangular boundaries of the plane. This led to a sort of 'milky way' effect.

 

The "milky way".

 

mpeg movie of fog in action.

I WISH...

 

While the project looked fairly interesting, the end result was hardly what I had in mind. As a proof-of-concept, it essentially works, since it looks like fog swirling. However, the first thing I'd fix given the opportunity would be to get the transparency working properly, by properly implementing the on-the-fly texture generation. The artifacts in the middle of the vortex would perhaps be reduced, or not quite as noticable. Second on the wish list is poly destruction at the critical point, and generation of new polys on the borders. Finally, implementing new vortices with the mouse or some such would have made this project live up to my original goal, or at least have satisfied me.

 

CONCLUSION

This project was a limited success. I didn't implement everything, but the project worked well enough to show that given a large enough plane, or a poly destruction/construction routine, relatively cheap fog or smoke can be simulated in real time. Additionally, this implementation would be easy to integrate into a physics or collision detection system, deforming the fog plane according to environmental input.