How to create fog using Open GL ES 2.0 or WebGL?

I would like to create a fog effect for my game but I can’t find any tutorials on how to do it using OpenGL ES 2.0. If anyone has links to tutorials, can provide an explanation, or source code I would be grateful.

Check these out:

If you have the Red Book, you can read about the equations in there, along with a good description of how they work. But it’s not complex. Compute the eye-space distance to the fragment, use that to compute a “fog factor” (a 0…1 blend factor between the fog color and the fragment color), and then do a “mix( fog_color, frag_color, fog_factor)” to apply the fog.

There are of course more complicated atmospheric attenuation functions, but start with the standard, simple uniform fog equations. If that’s all you need – great!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.