You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
627 B

  1. #version 330
  2. // Input vertex attributes (from vertex shader)
  3. in vec2 fragTexCoord;
  4. in vec4 fragColor;
  5. // Input uniform values
  6. uniform sampler2D texture0; // Depth texture
  7. uniform vec4 fragTintColor;
  8. // Output fragment color
  9. out vec4 finalColor;
  10. // NOTE: Add here your custom variables
  11. void main()
  12. {
  13. float zNear = 0.01; // camera z near
  14. float zFar = 10.0; // camera z far
  15. float z = texture(texture0, fragTexCoord).x;
  16. // Linearize depth value
  17. float depth = (2.0*zNear)/(zFar + zNear - z*(zFar - zNear));
  18. // Calculate final fragment color
  19. finalColor = vec4(depth, depth, depth, 1.0f);
  20. }