2013-11-30 21:33:06 +00:00
|
|
|
uniform sampler2D tex;
|
|
|
|
|
|
|
|
uniform float fogmax;
|
|
|
|
uniform float startH;
|
|
|
|
uniform float endH;
|
|
|
|
uniform float start;
|
|
|
|
uniform float end;
|
|
|
|
uniform vec3 col;
|
|
|
|
|
2014-05-02 18:11:34 +02:00
|
|
|
out vec4 FragColor;
|
|
|
|
|
|
|
|
|
|
|
|
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
2014-01-08 23:11:10 +00:00
|
|
|
|
2013-11-30 21:33:06 +00:00
|
|
|
void main()
|
|
|
|
{
|
2014-06-03 20:28:42 +02:00
|
|
|
vec2 uv = gl_FragCoord.xy / screen;
|
2014-11-10 22:08:12 +01:00
|
|
|
float z = texture(tex, uv).x;
|
|
|
|
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
|
2013-11-30 21:33:06 +00:00
|
|
|
|
2014-11-10 22:08:12 +01:00
|
|
|
float dist = length(xpos.xyz);
|
|
|
|
vec3 fog = col * (1. - exp(- fogmax * .01 * dist));
|
2013-11-30 21:33:06 +00:00
|
|
|
|
2014-11-10 22:08:12 +01:00
|
|
|
FragColor = vec4(fog, 1.);
|
2013-11-30 21:33:06 +00:00
|
|
|
}
|