stk-code_catmod/data/shaders/fog.frag

28 lines
527 B
GLSL
Raw Normal View History

uniform sampler2D tex;
uniform float fogmax;
uniform float startH;
uniform float endH;
uniform float start;
uniform float end;
uniform vec3 col;
out vec4 FragColor;
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
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;
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
float dist = length(xpos.xyz);
float fog = smoothstep(start, end, dist);
fog = min(fog, fogmax);
FragColor = vec4(col, fog);
}