I was trying to implement GLSL per-pixel fog in my game engine.  However, there is a problem.  When I enable linear or exp2 fog, the whole scene goes black, and when I implement exp fog, nothing happens to the scene. 

In this case, you will receive inverse of expecting result (flip "fog_color"<->"color")... 4.  gl_FragCoord.z is already divided to gl_FragCoord.w by OpenGL and clamped to [0,0 .. 1.0] (glDepthRange parameters)...