22 lines
444 B
GLSL
Raw Normal View History

uniform sampler2D tex;
uniform float density;
uniform vec3 col;
out vec4 FragColor;
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
void main()
{
2014-11-11 22:43:25 +01:00
vec2 uv = 2. * gl_FragCoord.xy / screen;
2014-11-10 22:08:12 +01:00
float z = texture(tex, uv).x;
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
2014-11-10 22:08:12 +01:00
float dist = length(xpos.xyz);
vec3 fog = col * (1. - exp(- density * dist));
2014-11-10 22:08:12 +01:00
FragColor = vec4(fog, 1.);
}