2013-06-23 09:13:01 +00:00
|
|
|
uniform int fogenabled;
|
|
|
|
uniform vec4 fogcolor;
|
|
|
|
uniform vec3 camerapos;
|
|
|
|
varying vec4 pixelpos;
|
|
|
|
varying vec4 fogparm;
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Main shader routine
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
float fogdist;
|
|
|
|
float fogfactor;
|
|
|
|
|
|
|
|
//
|
|
|
|
// calculate fog factor
|
|
|
|
//
|
2014-05-11 11:27:51 +00:00
|
|
|
if (fogenabled == -1)
|
|
|
|
{
|
2013-06-23 09:13:01 +00:00
|
|
|
fogdist = pixelpos.w;
|
2014-05-11 11:27:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fogdist = max(16.0, distance(pixelpos.xyz, camerapos));
|
|
|
|
}
|
2013-06-23 09:13:01 +00:00
|
|
|
fogfactor = exp2 (fogparm.z * fogdist);
|
|
|
|
gl_FragColor = vec4(fogcolor.rgb, 1.0 - fogfactor);
|
|
|
|
}
|
|
|
|
|