Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

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

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2010
    Location
    us
    Posts
    12

    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.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,183
    Quote Originally Posted by xman84 View Post
    ...fog effect ... can't find any tutorials on how to do it using OpenGL ES 2.0. If anyone has links to tutorials, ...
    Check these out:

    * http://www.ozone3d.net/tutorials/glsl_fog/
    * http://www.geeks3d.com/20100228/fog-in-glsl-webgl/

    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!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •