DepthDownscaleHalf.frag.glsl 676 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (C) 2009-2017, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include "shaders/Common.glsl"
  6. layout(ANKI_TEX_BINDING(0, 0)) uniform sampler2D u_depthRt;
  7. layout(location = 0) in vec2 in_uv;
  8. #define AVG
  9. void main()
  10. {
  11. vec4 depths = textureGather(u_depthRt, in_uv, 0);
  12. #if defined(MIN)
  13. vec2 mind2 = min(depths.xy, depths.zw);
  14. gl_FragDepth = min(mind2.x, mind2.y);
  15. #elif defined(MAX)
  16. vec2 max2 = max(depths.xy, depths.zw);
  17. gl_FragDepth = max(max2.x, max2.y);
  18. #elif defined(AVG)
  19. gl_FragDepth = dot(depths, vec4(1.0 / 4.0));
  20. #else
  21. #error See file
  22. #endif
  23. }