2013-12-26 21:50:25 -05:00
|
|
|
#version 130
|
2013-11-30 16:33:06 -05:00
|
|
|
uniform sampler2D tex;
|
2013-12-23 19:33:57 -05:00
|
|
|
uniform sampler2D normals_and_depth;
|
|
|
|
uniform mat4 invproj;
|
|
|
|
uniform vec2 screen;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-01-19 13:31:00 -05:00
|
|
|
out vec4 FragColor;
|
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
void main()
|
|
|
|
{
|
2013-12-23 21:47:33 -05:00
|
|
|
vec2 xy = gl_FragCoord.xy / screen;
|
2013-12-23 19:33:57 -05:00
|
|
|
float FragZ = gl_FragCoord.z;
|
2014-01-19 12:53:35 -05:00
|
|
|
float EnvZ = texture(normals_and_depth, xy).a;
|
2013-12-23 19:33:57 -05:00
|
|
|
vec4 FragmentPos = invproj * (2. * vec4(xy, FragZ, 1.0) - 1.);
|
|
|
|
FragmentPos /= FragmentPos.w;
|
|
|
|
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
|
|
|
|
EnvPos /= EnvPos.w;
|
2014-01-19 12:53:35 -05:00
|
|
|
float len = dot(vec3(1.0), abs(texture(normals_and_depth, xy).xyz));
|
2013-12-23 19:33:57 -05:00
|
|
|
float alpha = (len < 0.2) ? 1. : clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
|
2014-01-19 13:31:00 -05:00
|
|
|
FragColor = texture(tex, gl_PointCoord.xy);
|
|
|
|
FragColor.a *= alpha;
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|