2014-01-19 12:53:35 -05:00
|
|
|
uniform sampler2D tex;
|
2014-01-27 13:42:48 -05:00
|
|
|
uniform sampler2D dtex;
|
2013-12-31 12:25:10 -05:00
|
|
|
uniform mat4 invproj;
|
2014-05-16 20:39:55 -04:00
|
|
|
|
|
|
|
layout (std140) uniform MatrixesData
|
|
|
|
{
|
|
|
|
mat4 ViewMatrix;
|
|
|
|
mat4 ProjectionMatrix;
|
|
|
|
mat4 InverseViewMatrix;
|
|
|
|
mat4 InverseProjectionMatrix;
|
|
|
|
mat4 ShadowViewProjMatrixes[4];
|
|
|
|
vec2 screen;
|
|
|
|
};
|
2013-12-31 12:25:10 -05:00
|
|
|
|
|
|
|
in float lf;
|
2013-12-31 15:39:00 -05:00
|
|
|
in vec2 tc;
|
2014-03-15 13:35:51 -04:00
|
|
|
in vec3 pc;
|
2014-04-03 08:46:35 -04:00
|
|
|
out vec4 FragColor;
|
2013-12-29 13:23:36 -05:00
|
|
|
|
2013-12-31 15:39:00 -05:00
|
|
|
|
2013-12-29 13:23:36 -05:00
|
|
|
void main(void)
|
|
|
|
{
|
2013-12-31 12:25:10 -05:00
|
|
|
vec2 xy = gl_FragCoord.xy / screen;
|
|
|
|
float FragZ = gl_FragCoord.z;
|
2014-01-27 13:42:48 -05:00
|
|
|
float EnvZ = texture(dtex, xy).x;
|
2013-12-31 12:25:10 -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-27 13:42:48 -05:00
|
|
|
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
|
2014-04-03 08:46:35 -04:00
|
|
|
vec4 color = texture(tex, tc) * vec4(pc, 1.0);
|
2014-05-10 14:58:43 -04:00
|
|
|
FragColor = color * alpha * smoothstep(1., 0.8, lf);
|
2013-12-29 13:23:36 -05:00
|
|
|
}
|