posted January 12, 2000 01:33 PM
Real volumetric fog is an effect that you need to code yourself; neither OpenGL nor Direct3D can do volumetric fog internally.The basic idea is to make a second "fog pass" over every triangle in your scene, and render fog in the second pass at a density based on the amount of fog between the camera and the vertex being rendered. You will need some way to represent your fog volume, which could be as simple as a height value for the top of the fog if you wanted it to sit over everything at a certain altitude (like water), or it could be a list of fog spheres which would be points with radii, or it could be a 3D array of fog density values, or just about anything else. Then when rendering each vertex in the fog pass, evaluate how much fog the line between the camera and the vertex passes through (this calculation will be different depending on your fog data structures), and set the alpha value for the fog pass vertex based on the amount of fog passed through. Thus if there is no fog between the camera and the vertex, the fog pass will do nothing, and if there is a lot of fog, the fog pass may color the vertex mostly or all fogged.
If you're only doing single-pass rendering normally, you could do the fog pass using Multi-Texture, using texture coordinates on the second texture unit with a gradiated texture (from transparent/no fog on one side to opaque on the other) to control the fogging amount.
------------------
-- Seumas McNally, Lead Programmer, Longbow Digital Arts