DepthDownscaleQuarter.frag.glsl 709 B

123456789101112131415161718192021222324252627282930
  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. layout(location = 0) out float out_depth;
  9. #define AVG
  10. void main()
  11. {
  12. vec4 depths = textureGather(u_depthRt, in_uv, 0);
  13. #if defined(MIN)
  14. vec2 mind2 = min(depths.xy, depths.zw);
  15. out_depth = min(mind2.x, mind2.y);
  16. #elif defined(MAX)
  17. vec2 max2 = max(depths.xy, depths.zw);
  18. out_depth = max(max2.x, max2.y);
  19. #elif defined(AVG)
  20. out_depth = dot(depths, vec4(1.0 / 4.0));
  21. #else
  22. #error See file
  23. #endif
  24. }