No Description

quad.frag 549B

123456789101112131415161718192021222324
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (binding = 1) uniform sampler2D samplerColor;
  5. layout (location = 0) in vec2 inUV;
  6. layout (location = 0) out vec4 outFragColor;
  7. float LinearizeDepth(float depth)
  8. {
  9. float n = 1.0; // camera z near
  10. float f = 128.0; // camera z far
  11. float z = depth;
  12. return (2.0 * n) / (f + n - z * (f - n));
  13. }
  14. void main()
  15. {
  16. float depth = texture(samplerColor, inUV).r;
  17. outFragColor = vec4(vec3(1.0-LinearizeDepth(depth)), 1.0);
  18. }