Cameron Fischer
Advanced Computer Graphics

Clouds, Fog, and Smoke

Introduction

This paper presents an alternative algorithm for simulating the visual effects of fog or smoke in such a way as to allow for efficient simulation of the density's motion. The algorithm creates a volumetric fog effect by interpreting a variable number of points that are responsive to their environment. The idea is that a large number of points would not be necessary to produce appealing results.

Related Works

Fog in graphics rendering can be accomplished through a variety of techniques. The OpenGL libraries include functionality that allows someone to create linear or quadratic interpolation of a fragment's color and the fog color based on the Z value of the fragment. This allows for a very cheap and easy fog that in many cases is good enough.

Smoke and fog simulations have been performed before through the use of the Navier-Stokes equations [1]. These simulations work well for incompressible fluids such as water and other liquids. An interesting smoke simulation and rendering involves the use Euler equations as an alternative to the Navier-Stokes equations to calculate across a large number of cells [2]. The smoke was approximated by considering densities within these cells and the rendering is done by photon scattering based on a probability derived from these densities. A more interesting fog effect can be created through the use of volumetric fog. This is a slightly more expensive technique that can fog interpolations for given regions. Particle systems can be used to produce very realistic smoke, fog, or cloud simulations.

Motivation

I wanted to pursue a volumetric smoke, cloud, and fog simulation that combines particles and ray tracing in order to produce visually pleasing results with fewer particles. By reducing the number of particles, effective simulation of the particle's motion through a simulation could be calculated more quickly and respond more to external effects such as wind or impassable bodies. The simulation of these particles could be done in real time. Although the rendering of the particles can be substituted with voxels for the simulation, a full simulation would involve the use of ray tracing and could not be used in real time. To determine the distance between the point and the ray, we consider the origin of the ray, the direction of the ray, and the origin of the point.

Technique

Point and Ray Distance

The focus of this paper was on the rendering of visually pleasing fog based off of a limited number of free floating points. When a scene is rendered through ray tracing, the particles will effect the results of any ray given their distance from the ray. The over all algorithm interpolates the fog color based of factors such as distance and strength. To consider the shortest distance between the ray and point, we first consider the shortest distance between a line and a point [3]. First we define some location on the line:


where is the direction of the ray, is the origin, and is some value. Then the shortest distance between the point, and the line will be parallel to the line so that the dot product between the line and the distance will be zero.


If we consider the point of intersection of these lines to be I, then combining the equations give you...


If you solve for u...


The distance between the point and the line is the length of the vector P - I.


Now we consider the differences if we were to compare a point to a ray instead of a point to a line. If u is less than 0, then the intersection point falls behind the ray. To adjust, all you have to do is set u equal to 0. If u is greater than T, where T is the set length of the ray, then set u equal to T. After readjusting I, then you can calculate I and get the length of P - I.

Fog Interpolation

The interpolation of the fog color for any given ray trace takes a number of factors into consideration. The strength of the fog particle is one of these factors. In the case of my simulation, the fog strength was determined by the remaining life of the particle over its initial life.


Another factor is , which is a constant that controls that maximum opacity of a particle. I found that a value of 0.2 worked well for fogs and higher values near 1 for smoke. The radius is a factor which gets considered in conjunction with the distance between the ray and the point.


This will give a value from negative infinity to one depending on the distance. This value needs to be capped to the range of [0, 1]. Multiply all of these factors together to get the opacity of a fragment. Subtract 1 by the opacity to get the clarity.


Then multiply the clarity of all the relevant particles in order to get the clarity of the given ray. This clarity can be used to interpolate between the ray's incoming fragment color and the fog color. The interpolation equations is the standard interpolation equation.


Do this for every ray trace.

Results

To demonstrate the technique. I created a few scenes where anywhere from 20 to 200 voxels were used for computing. The movement simulation of these voxels was set up so they would all start at the same location. They would all take on the same general direction with slight variations. Then they would all also have a random life from 8 to 16 steps for smoke to 64 to 128 steps for fog. A simplistic collision detection and response system was set up that involved the same ray tracing functions that the renderer used.

The following shows a voxel interpretation of a foggy scene as well as its rendered counter part using the distance product algorithm.

The focus of this paper was on the rendering of the fog from a limited number of points. The code in the source has a very limited and stripped down features regarding the interaction of the particles with their environment. However, it should be enough to get the particles in relatively good locations for rendering. Along with the source code, there are a number of shell scripts that have certain premade scenarios ready to go.

Conclusion

This paper demonstrated a different technique for generation fog and smoke simulations within ray traced environments. The techniques are greatly simplified from using the Navier-Stokes equations with a cell-based environment yet still provides pleasing results. The physical environment created by this algorithm is easy to simulate in real time using more complicated physics simulations that are more responsive to the environment. These simulations are less expensive due to the decreased amount of particles that are required to create an effective scene. The rendering system integrates well with any other ray tracing environment while avoiding some of the artifacts that voxel-based rendering would have with such few particles. These avoided artifacts involve an effect that occurs when textured points or voxels are near other geometry. If the voxels intersect the geometry, then a noticeable crease will appear where the fog texture disappears into the wall.

I do not believe that this technique is very effective for simulating clouds. Although a cloud effect could easily be created using these algorithms, this would be far to elaborate for the quality of clouds you would get. However, for smoke and fog, I believe that this algorithm would work nicely in combination with other systems.

This algorithm could easily be extended to factor in features such as photon scattering. This would allow for the fog or smoke to be more responsive to any light sources. The fog would have shades more reflective of the amount of light cast upon it and smoke could be self-shaded. Also, the shadow casting could be altered to take fog into consideration. This would allow for smoke and fog to cast shadows onto the ground and to effect the lighting of everything within the fog.

Bibliography

[1] Foster, Nick. Metaxas, Dimitri. "Realistic Animation of Liquids" June 3, 1996: 24-. Center for Human Modeling and Simulation. University of Pennsylvania, Philadelphia, PA 19104 <http://www.cis.upenn.edu/~fostern/pdfs/gmip96.pdf>

[2] Fedkiw, Ronald. Stam, Jos. Jensen, Henrik Wann. Visual Simulation of Smoke Date: 8-. Computer Graphics Laboratory Jensen, Henrik Wann. CSE 4116, 9500 Gilman Drive, La Jolla, CA 92093-0404. April 2007 <http://graphics.ucsd.edu/~henrik/papers/smoke/smoke.pdf>

[3] Bourke, Paul. Minimum Distance Between A Point And A Line: October 1988. University of West Alabama. Livingston, AL 35470. <http://local.wasp.uwa.edu.au/~pbourke/geometry/pointline>