#version 430 out vec4 FragColor; in vec2 TexCoords; layout (location = 0) uniform sampler2D depthMap; // required when using a perspective projection matrix float LinearizeDepth(float depth) { float z = depth * 2.0 - 1.0; // Back to NDC return (2.0 * 0.1 * 100.0) / (100.0 + 0.1 - z * (100.0 - 0.1)); } void main() { float depthValue = texture(depthMap, TexCoords).r; // FragColor = vec4(vec3(LinearizeDepth(depthValue) / 100.0), 1.0); // perspective FragColor = vec4(vec3(depthValue) * 10.0, 1.0); // orthographic }