Correct the fog distance calculations.

It turns out the pixel's z coord is correctly obtailed by
gl_FragCoord.z/gl_FragCoord.w.
This commit is contained in:
Bill Currie 2012-07-17 19:10:10 +09:00
parent c4309e7abc
commit 7d8b0f96d6
9 changed files with 9 additions and 9 deletions

View file

@ -27,7 +27,7 @@ fogBlend (vec4 color)
float f;
vec4 fog_color = vec4 (fog.rgb, 1.0);
f = exp (-sqr (fog.a / gl_FragCoord.w));
f = exp (-sqr (fog.a * gl_FragCoord.z / gl_FragCoord.w));
return vec4 (mix (fog_color.rgb, color.rgb, f), color.a);
}

View file

@ -19,7 +19,7 @@ fogBlend (vec4 color)
float f;
vec4 fog_color = vec4 (fog.rgb, 1.0);
f = exp (-sqr (fog.a / gl_FragCoord.w));
f = exp (-sqr (fog.a * gl_FragCoord.z / gl_FragCoord.w));
return vec4 (mix (fog_color.rgb, color.rgb, f), color.a);
}

View file

@ -21,7 +21,7 @@ fogBlend (vec4 color)
float f;
vec4 fog_color = vec4 (fog.rgb, 1.0);
f = exp (-sqr (fog.a / gl_FragCoord.w));
f = exp (-sqr (fog.a * gl_FragCoord.z / gl_FragCoord.w));
return vec4 (mix (fog_color.rgb, color.rgb, f), color.a);
}

View file

@ -17,7 +17,7 @@ fogBlend (vec4 color)
float f;
vec4 fog_color = vec4 (fog.rgb, 1.0);
f = exp (-sqr (fog.a / gl_FragCoord.w));
f = exp (-sqr (fog.a * gl_FragCoord.z / gl_FragCoord.w));
return vec4 (mix (fog_color.rgb, color.rgb, f), color.a);
}

View file

@ -16,7 +16,7 @@ fogBlend (vec4 color)
float f;
vec4 fog_color = vec4 (fog.rgb, 1.0);
f = exp (-sqr (fog.a / gl_FragCoord.w));
f = exp (-sqr (fog.a * gl_FragCoord.z / gl_FragCoord.w));
return vec4 (mix (fog_color.rgb, color.rgb, f), color.a);
}

View file

@ -15,7 +15,7 @@ fogBlend (vec4 color)
float f;
vec4 fog_color = vec4 (fog.rgb, 1.0);
f = exp (-sqr (fog.a / gl_FragCoord.w));
f = exp (-sqr (fog.a * gl_FragCoord.z / gl_FragCoord.w));
return vec4 (mix (fog_color.rgb, color.rgb, f), color.a);
}

View file

@ -20,7 +20,7 @@ fogBlend (vec4 color)
float f;
vec4 fog_color = vec4 (fog.rgb, 1.0);
f = exp (-sqr (fog.a / gl_FragCoord.w));
f = exp (-sqr (fog.a * gl_FragCoord.z / gl_FragCoord.w));
return vec4 (mix (fog_color.rgb, color.rgb, f), color.a);
}

View file

@ -19,7 +19,7 @@ fogBlend (vec4 color)
float f;
vec4 fog_color = vec4 (fog.rgb, 1.0);
f = exp (-sqr (fog.a / gl_FragCoord.w));
f = exp (-sqr (fog.a * gl_FragCoord.z / gl_FragCoord.w));
return vec4 (mix (fog_color.rgb, color.rgb, f), color.a);
}

View file

@ -25,7 +25,7 @@ fogBlend (vec4 color)
float f;
vec4 fog_color = vec4 (fog.rgb, 1.0);
f = exp (-sqr (fog.a / gl_FragCoord.w));
f = exp (-sqr (fog.a * gl_FragCoord.z / gl_FragCoord.w));
return vec4 (mix (fog_color.rgb, color.rgb, f), color.a);
}