2019-03-01 01:40:02 +00:00
|
|
|
layout(location=2) in vec4 pixelpos;
|
2018-06-12 21:52:33 +00:00
|
|
|
layout(location=0) out vec4 FragColor;
|
2019-05-13 19:15:10 +00:00
|
|
|
#ifdef GBUFFER_PASS
|
|
|
|
layout(location=1) out vec4 FragFog;
|
|
|
|
layout(location=2) out vec4 FragNormal;
|
|
|
|
#endif
|
2013-06-23 09:13:01 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Main shader routine
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
float fogdist;
|
|
|
|
float fogfactor;
|
2023-01-15 07:54:54 +00:00
|
|
|
|
2013-06-23 09:13:01 +00:00
|
|
|
//
|
|
|
|
// calculate fog factor
|
|
|
|
//
|
2018-09-16 20:38:20 +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);
|
2019-05-13 19:15:10 +00:00
|
|
|
#ifdef GBUFFER_PASS
|
|
|
|
FragFog = vec4(0.0, 0.0, 0.0, 1.0);
|
|
|
|
FragNormal = vec4(0.5, 0.5, 0.5, 1.0);
|
|
|
|
#endif
|
2013-06-23 09:13:01 +00:00
|
|
|
}
|
|
|
|
|