2022-11-12 19:27:10 +00:00
|
|
|
#version 450
|
|
|
|
|
|
|
|
layout (location = 0) in vec2 TexCoord;
|
|
|
|
layout (location = 0) out vec4 FragColor;
|
|
|
|
|
2024-06-06 05:47:06 +00:00
|
|
|
layout(set = 2, binding = 0) uniform sampler2D Sampler;
|
2022-11-12 19:27:10 +00:00
|
|
|
|
2024-06-06 05:47:06 +00:00
|
|
|
layout (set = 3, binding = 0) uniform UniformBlock
|
2022-11-12 19:27:10 +00:00
|
|
|
{
|
|
|
|
float zNear;
|
|
|
|
float zFar;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Calculation taken from http://www.geeks3d.com/20091216/geexlab-how-to-visualize-the-depth-buffer-in-glsl/
|
|
|
|
float linearizeDepth(float originalDepth)
|
|
|
|
{
|
|
|
|
return (2.0 * zNear) / (zFar + zNear - originalDepth * (zFar - zNear));
|
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
float d = texture(Sampler, TexCoord).r;
|
|
|
|
d = linearizeDepth(d);
|
|
|
|
FragColor = vec4(d, d, d, 1.0);
|
|
|
|
}
|