Cubyz/assets/cubyz/shaders/depth_copy.fs
2024-12-06 21:48:06 +01:00

16 lines
331 B
GLSL

#version 430
out vec4 fragColor;
in vec2 texCoords;
uniform float zNear;
uniform float zFar;
layout(binding = 5) uniform sampler2D depthBuffer;
float zFromDepth(float depthBufferValue) {
return zNear*zFar/(depthBufferValue*(zNear - zFar) + zFar);
}
void main() {
fragColor.r = zFromDepth(texture(depthBuffer, texCoords).r);
}