2014-01-04 19:08:00 -05:00
|
|
|
#version 130
|
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;
|
|
|
|
uniform vec3 campos;
|
|
|
|
uniform mat4 ipvmat;
|
|
|
|
|
2014-01-08 18:11:10 -05:00
|
|
|
in vec2 uv;
|
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
void main()
|
|
|
|
{
|
2014-01-08 18:11:10 -05:00
|
|
|
float z = texture2D(tex, uv).a;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
vec3 tmp = vec3(gl_TexCoord[0].xy, z);
|
|
|
|
tmp = tmp * 2.0 - 1.0;
|
|
|
|
|
|
|
|
vec4 xpos = vec4(tmp, 1.0);
|
|
|
|
xpos = ipvmat * xpos;
|
|
|
|
xpos.xyz /= xpos.w;
|
|
|
|
|
|
|
|
float dist = distance(campos, xpos.xyz);
|
|
|
|
float fog = smoothstep(start, end, dist);
|
|
|
|
fog *= 1.0 - smoothstep(startH, endH, xpos.y);
|
|
|
|
|
|
|
|
fog = min(fog, fogmax);
|
|
|
|
|
|
|
|
gl_FragColor = vec4(col, fog);
|
|
|
|
}
|