From 4af61aba47d4a91b09b414aa1ed60f7a336dc877 Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Thu, 15 Mar 2012 21:06:45 +0200 Subject: [PATCH] Shaders/include_fog.frag: better fix for the common fog function Signed-off-by: Emilian Huminiuc --- Shaders/include_fog.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shaders/include_fog.frag b/Shaders/include_fog.frag index 69dc17257..3837f8358 100644 --- a/Shaders/include_fog.frag +++ b/Shaders/include_fog.frag @@ -6,7 +6,7 @@ vec3 fog_Func(vec3 color, int type) //if (type == 0){ const float LOG2 = 1.442695; //float fogCoord =length(PointPos); - float fogCoord = gl_FragCoord.z / gl_FragCoord.w; + float fogCoord = gl_ProjectionMatrix[3].z/(gl_FragCoord.z * -2.0 + 1.0 - gl_ProjectionMatrix[2].z); float fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); if(gl_Fog.density == 1.0)