#version 330 core out vec4 FragColor; float near = 0.1; float far = 100.0; float LinearizeDepth(float depth) { float z = depth * 2.0 - 1.0; // back to NDC return (2.0 * near * far) / (far + near - z * (far - near)); } void main() { float depth = LinearizeDepth(gl_FragCoord.z) / far; // 爲了演示除以 far FragColor = vec4(vec3(depth), 1.0); } --------------------- 做者:cqltbe131421 來源:CSDN 原文:https://blog.csdn.net/cqltbe131421/article/details/82906652 版權聲明:本文爲博主原創文章,轉載請附上博文連接!