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 mat4 ipvmat;
|
|
|
|
|
2014-02-28 11:29:05 -05:00
|
|
|
#if __VERSION__ >= 130
|
2014-01-08 18:11:10 -05:00
|
|
|
in vec2 uv;
|
2014-01-19 13:31:00 -05:00
|
|
|
out vec4 FragColor;
|
2014-02-28 11:29:05 -05:00
|
|
|
#else
|
|
|
|
varying vec2 uv;
|
|
|
|
#define FragColor gl_FragColor
|
|
|
|
#endif
|
|
|
|
|
2014-01-08 18:11:10 -05:00
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
void main()
|
|
|
|
{
|
2014-01-27 13:31:03 -05:00
|
|
|
float z = texture(tex, uv).x;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-01-27 13:31:03 -05:00
|
|
|
vec3 tmp = vec3(uv, z);
|
2013-11-30 16:33:06 -05:00
|
|
|
tmp = tmp * 2.0 - 1.0;
|
|
|
|
|
|
|
|
vec4 xpos = vec4(tmp, 1.0);
|
|
|
|
xpos = ipvmat * xpos;
|
|
|
|
xpos.xyz /= xpos.w;
|
|
|
|
|
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
|
|
|
}
|