2014-05-12 12:45:41 +00:00
|
|
|
in vec4 pixelpos;
|
|
|
|
in vec2 glowdist;
|
2013-06-23 09:13:01 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Main shader routine
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2014-07-13 10:14:12 +00:00
|
|
|
#ifndef NO_DISCARD
|
|
|
|
// clip plane emulation for plane reflections. These are always perfectly horizontal so a simple check of the pixelpos's y coordinate is sufficient.
|
|
|
|
if (pixelpos.y > uClipHeight + 65536.0) discard;
|
|
|
|
if (pixelpos.y < uClipHeight - 65536.0) discard;
|
|
|
|
#endif
|
|
|
|
|
2013-06-23 09:13:01 +00:00
|
|
|
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);
|
|
|
|
gl_FragColor = vec4(uFogColor.rgb, 1.0 - fogfactor);
|
2013-06-23 09:13:01 +00:00
|
|
|
}
|
|
|
|
|