OpenGL Library for Delphi,
maintained by Eric Grange,
based on Mike Lischke's GLScene.

 

Articles - How Fog works


Fog

Implementing fog into your project is a simple task.

When dealing with fog using OpenGL, you have to keep the following in mind.

Color   What color the fog should be.
 
   
Mode   The mode of the fog will determine the quality of the fog.
There are three different fog modes.

1)
GL_EXP
2) GL_EXP2
3) GL_LINEAR

GL_EXP is a basic fog. It covers the whole screen, but does not give much of a fog effect.
GL_EXP2 is one step up from GL_EXP and gives a better fog effect.

The best quality fog can be achieved by using linear fog (GL_LINEAR). Better quality = more resources.

   
   
   
   
   
   
   
   
   
   
Density   How dense is the fog, directly affecting the visibility of scene objects.
Needless to say, the less dense the fog, the further you can see.
 
   
   
Start Position   How close to the current view port does the fog start.
 
   
End Position   How far away from the current view port does the fog end.

How to implement fog in GLScene

The  GLSceneViewer's FogEnvironment property as found under "Buffer" contains all you need to implement fog in your scene.

The FogEnvironment has five properties that can define fog in the scene:

FogColor   You can change the color of the fog with this property.
Changing the alpha value of the color between 0 and 1, will set the fog density. 1 being absolute density and 0 being zero density.

Hint: Setting the fog color the same as the background, will achieve a better effect.
 
 
 
FogStart   Minimum distance for fog, what is closer is not affected.
FogEnd   Maximum distance for fog, what is farther is at 100% fog intensity.
 
FogMode   The formula used for converting distance to fog intensity.

The effect of fmLinear, fmExp, fmExp2 is explained above.
 
 
 
FogDistance   This option is honoured if and only if the OpenGL ICD supports the GL_NV_fog_distance extension, otherwise, it is ignored.
1) fdDefault: let OpenGL use its default formula
2) fdEyeRadial: uses radial "true" distance (best quality)
3) fdEyePlane: uses the distance to the projection plane (same as Z-Buffer, faster)
 

After setting up all you require for your fog, you need to set the EnableFog property of the GLSceneViewer to True before the fog will take affect.

Other Fog Effects

This document only dwelt on basic fog effects for your scene. There are other ways of implementing fog and fog effects.
Unfortunately they are much more complex to implement than this one.

Fog types for further revision are:

1) Volumetric fog.
2) Multi density / layer fog.
3) Multi color fog.
4) Fog movement.

GLScene

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.2
Page was generated in 0.0494 seconds