ColorInvertCS.azsl 889 B

123456789101112131415161718192021222324252627282930313233
  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. ShaderResourceGroup PassSrg : SRG_PerPass
  10. {
  11. Texture2D<float4> m_inputTexture;
  12. RWTexture2D<float4> m_outputTexture;
  13. }
  14. [numthreads(8,8,1)]
  15. void MainCS(uint3 dispatch_id: SV_DispatchThreadID)
  16. {
  17. // Calculate which pixel this thread maps to
  18. uint2 textureDimensions;
  19. PassSrg::m_inputTexture.GetDimensions(textureDimensions.x, textureDimensions.y);
  20. uint2 pixel = min(dispatch_id.xy, textureDimensions.xy);
  21. // Sample the color
  22. float4 color = PassSrg::m_inputTexture[pixel];
  23. // Invert the color
  24. color = 1.0f - color;
  25. // Output the color
  26. PassSrg::m_outputTexture[pixel] = color;
  27. }