2014-05-13 13:40:30 -04:00
|
|
|
uniform sampler2D tex;
|
|
|
|
uniform float zn;
|
|
|
|
uniform float zf;
|
|
|
|
|
2014-06-03 13:56:59 -04:00
|
|
|
layout (std140) uniform MatrixesData
|
|
|
|
{
|
|
|
|
mat4 ViewMatrix;
|
|
|
|
mat4 ProjectionMatrix;
|
|
|
|
mat4 InverseViewMatrix;
|
|
|
|
mat4 InverseProjectionMatrix;
|
|
|
|
mat4 ShadowViewProjMatrixes[4];
|
|
|
|
vec2 screen;
|
|
|
|
};
|
|
|
|
|
2014-05-13 13:40:30 -04:00
|
|
|
out float Depth;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2014-06-03 13:56:59 -04:00
|
|
|
vec2 uv = gl_FragCoord.xy / screen;
|
2014-05-13 13:40:30 -04:00
|
|
|
float d = texture(tex, uv).x;
|
|
|
|
float c0 = zn * zf, c1 = zn - zf, c2 = zf;
|
|
|
|
Depth = c0 / (d * c1 + c2);
|
|
|
|
}
|