2016-09-02 03:45:00 +00:00
|
|
|
|
|
|
|
in vec2 TexCoord;
|
|
|
|
out vec4 FragColor;
|
|
|
|
|
|
|
|
uniform sampler2D AODepthTexture;
|
|
|
|
|
2016-09-21 00:04:56 +00:00
|
|
|
#if defined(MULTISAMPLE)
|
2016-10-05 05:57:27 +00:00
|
|
|
uniform sampler2DMS SceneFogTexture;
|
2016-09-21 00:04:56 +00:00
|
|
|
#else
|
2016-10-05 05:57:27 +00:00
|
|
|
uniform sampler2D SceneFogTexture;
|
2016-09-21 00:04:56 +00:00
|
|
|
#endif
|
|
|
|
|
2016-09-02 03:45:00 +00:00
|
|
|
void main()
|
|
|
|
{
|
2016-09-21 00:04:56 +00:00
|
|
|
vec2 uv = Offset + TexCoord * Scale;
|
2016-10-09 04:17:48 +00:00
|
|
|
|
2016-09-21 00:04:56 +00:00
|
|
|
#if defined(MULTISAMPLE)
|
2016-10-05 05:57:27 +00:00
|
|
|
ivec2 texSize = textureSize(SceneFogTexture);
|
2016-09-21 00:04:56 +00:00
|
|
|
#else
|
2016-10-05 05:57:27 +00:00
|
|
|
ivec2 texSize = textureSize(SceneFogTexture, 0);
|
2016-09-21 00:04:56 +00:00
|
|
|
#endif
|
2016-10-09 04:17:48 +00:00
|
|
|
ivec2 ipos = ivec2(uv * vec2(texSize));
|
2016-09-21 00:04:56 +00:00
|
|
|
|
|
|
|
#if defined(MULTISAMPLE)
|
|
|
|
vec3 fogColor = vec3(0.0);
|
|
|
|
for (int i = 0; i < SampleCount; i++)
|
2016-10-05 05:57:27 +00:00
|
|
|
fogColor += texelFetch(SceneFogTexture, ipos, i).rgb;
|
2016-09-21 00:04:56 +00:00
|
|
|
fogColor /= float(SampleCount);
|
|
|
|
#else
|
2016-10-05 05:57:27 +00:00
|
|
|
vec3 fogColor = texelFetch(SceneFogTexture, ipos, 0).rgb;
|
2016-09-21 00:04:56 +00:00
|
|
|
#endif
|
|
|
|
|
2016-09-02 03:45:00 +00:00
|
|
|
float attenutation = texture(AODepthTexture, TexCoord).x;
|
2016-09-21 00:04:56 +00:00
|
|
|
FragColor = vec4(fogColor, 1.0 - attenutation);
|
2016-09-02 03:45:00 +00:00
|
|
|
}
|