2013-11-30 16:33:06 -05: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 12:11:34 -04:00
|
|
|
out vec4 FragColor;
|
|
|
|
|
|
|
|
|
|
|
|
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
2014-01-08 18:11:10 -05:00
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
void main()
|
|
|
|
{
|
2014-06-03 14:28:42 -04:00
|
|
|
vec2 uv = gl_FragCoord.xy / screen;
|
2014-01-27 13:31:03 -05:00
|
|
|
float z = texture(tex, uv).x;
|
2014-05-02 12:11:34 -04:00
|
|
|
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-02-03 13:35:37 -05:00
|
|
|
float dist = length(xpos.xyz);
|
2013-11-30 16:33:06 -05:00
|
|
|
float fog = smoothstep(start, end, dist);
|
|
|
|
|
|
|
|
fog = min(fog, fogmax);
|
|
|
|
|
2014-01-19 13:31:00 -05:00
|
|
|
FragColor = vec4(col, fog);
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|