stk-code_catmod/data/shaders/fog.frag
2014-02-28 17:29:05 +01:00

38 lines
589 B
GLSL

uniform sampler2D tex;
uniform float fogmax;
uniform float startH;
uniform float endH;
uniform float start;
uniform float end;
uniform vec3 col;
uniform mat4 ipvmat;
#if __VERSION__ >= 130
in vec2 uv;
out vec4 FragColor;
#else
varying vec2 uv;
#define FragColor gl_FragColor
#endif
void main()
{
float z = texture(tex, uv).x;
vec3 tmp = vec3(uv, z);
tmp = tmp * 2.0 - 1.0;
vec4 xpos = vec4(tmp, 1.0);
xpos = ipvmat * xpos;
xpos.xyz /= xpos.w;
float dist = length(xpos.xyz);
float fog = smoothstep(start, end, dist);
fog = min(fog, fogmax);
FragColor = vec4(col, fog);
}