2014-05-12 12:45:41 +00:00
|
|
|
in vec4 pixelpos;
|
|
|
|
in vec2 glowdist;
|
2014-07-14 23:05:53 +00:00
|
|
|
out vec4 FragColor;
|
2013-06-23 09:13:01 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Main shader routine
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
float fogdist;
|
|
|
|
float fogfactor;
|
|
|
|
|
|
|
|
//
|
|
|
|
// calculate fog factor
|
|
|
|
//
|
2014-05-12 12:45:41 +00:00
|
|
|
if (uFogEnabled == -1)
|
2014-05-11 11:27:51 +00:00
|
|
|
{
|
2013-06-23 09:13:01 +00:00
|
|
|
fogdist = pixelpos.w;
|
2014-05-11 11:27:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-12 12:45:41 +00:00
|
|
|
fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz));
|
2014-05-11 11:27:51 +00:00
|
|
|
}
|
2014-05-12 12:45:41 +00:00
|
|
|
fogfactor = exp2 (uFogDensity * fogdist);
|
2014-07-14 23:05:53 +00:00
|
|
|
FragColor = vec4(uFogColor.rgb, 1.0 - fogfactor);
|
2013-06-23 09:13:01 +00:00
|
|
|
}
|
|
|
|
|