From: Clint Brewer []
Sent: Wednesday, February 11, 2004 2:56 AM
To: Ben Discoe
Subject: Re: Fog & Haze

If you are rendering your sky as a skybox, or skydome, you can also use that as your fog directly

You create your render target as a format that has an alpha channel.  For instance in D3D you could create your render target with a format  of D3DFMT_A8R8G8B8, or in OpenGL on Windows you would specify an RGBA type with a given number of alpha bits in your PIXELFORMATDESCRIPTOR. Basically you just need to get a back buffer/main color buffer that supports an alpha channel of 8 bits.

Then in a pixel shader/fragment program you can calculate the fogfactor however you want: linear, bilinear etc. and explicitly output that to the alpha channel of your color buffer.

Then set your alpha blending modes to

srcblend= destalpha

destblend = invdestalpha    aka one minus dest alpha

and render your skybox.