DepthDownsample.azsl 896 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Atom/Features/SrgSemantics.azsli>
  9. #define THREADS 16
  10. ShaderResourceGroup PassSrg : SRG_PerPass
  11. {
  12. Texture2D<float> m_depthFullRes;
  13. RWTexture2D<float> m_depthHalfRes;
  14. }
  15. [numthreads(THREADS, THREADS, 1)]
  16. void MainCS(uint3 dispatch_id: SV_DispatchThreadID)
  17. {
  18. uint2 targetPixel = dispatch_id.xy;
  19. // Take the upper left pixel in the 2x2 quad. This has two advantages:
  20. // 1) It gives us a real depth value instead of an averaged depth
  21. // 2) It preserves equal distance properties between pixels (necessary for SSAO)
  22. uint2 sourcePixel = targetPixel * 2;
  23. PassSrg::m_depthHalfRes[targetPixel] = PassSrg::m_depthFullRes[sourcePixel];
  24. }