   Recreating fixed-function-pipeline fog using GLSL
  Heyya,I've just started playing with GLSL and now I need to implement fog into one of my shaders. I'm not really sure what to do with gl_Fog, gl_FogCoord and gl_FogFragCoord. If there is anybody here who have any experience with this or can give me pointers where to find more info about this, please help me.A full implementation of the fixed function pipeline written in GLSL would be nice to have, maybe this already exists? If not, any other high-level language would be nice too (HLSL maybe?).Thanks.   
  The Orange Book contains an implementation of the fixed function pipeline. I don't have it here with me, or I'd look up fog. If you're working with GLSL, I'd strongly recommend picking up the book.   ;  From the Orange Book:Linear Fogfog = (gl_Fog.end - gl_FogFragCoord)) * gl_Fog.scale;gl_Fog.scale is a precomputed 1.0 / (gl_Fog.end - gl_Fog.start).Exponential Fogconst float LOG2E = 1.442695; // = 1 / log(2)fog = exp2(-gl_Fog.density * gl_FogFragCoord * LOG2E);Exponential Fog (Squared)fog = exp2(-gl_Fog.density * gl_Fog.density * gl_FogFragCoord * gl_FogFragCoord * LOG2E);The LOG2E constant is used to turn the exp base(2) into exp base(e).  Also, if you're going to use GL_EXP2 fog, it recommends precomputing (-gl_Fog.density * gl_Fog.density * LOG2E) and passing it in as a uniform.--Buzzy   ;  Thanks a lot, it works now. Though, I should've been able to do it myself since I knew where to find the equations. Anyway, I will look into buying that book.   