TonemappingResources.glsl 940 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. // Tonemapping resources
  6. #pragma once
  7. #include <AnKi/Shaders/Common.glsl>
  8. #if !defined(TONEMAPPING_RESOURCE_AS_WRITE_IMAGE)
  9. # define TONEMAPPING_RESOURCE_AS_WRITE_IMAGE 0
  10. #endif
  11. #if TONEMAPPING_RESOURCE_AS_WRITE_IMAGE
  12. layout(set = 0, binding = TONEMAPPING_BINDING) ANKI_RP uniform coherent image2D u_tonemappingImage;
  13. #else
  14. layout(set = 0, binding = TONEMAPPING_BINDING) ANKI_RP uniform readonly image2D u_tonemappingImage;
  15. #endif
  16. #if TONEMAPPING_RESOURCE_AS_WRITE_IMAGE
  17. void writeExposureAndAverageLuminance(ANKI_RP F32 exposure, ANKI_RP F32 avgLuminance)
  18. {
  19. imageStore(u_tonemappingImage, IVec2(0), Vec4(exposure, avgLuminance, 0.0f, 0.0f));
  20. }
  21. #endif
  22. ANKI_RP Vec2 readExposureAndAverageLuminance()
  23. {
  24. return imageLoad(u_tonemappingImage, IVec2(0)).xy;
  25. }