EditorCubeMapRenderer.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #pragma once
  9. #include <AzCore/std/parallel/atomic.h>
  10. #include <AzCore/Component/Entity.h>
  11. #include <AzCore/IO/SystemFile.h>
  12. #include <Atom/Utils/DdsFile.h>
  13. #include <Atom/Feature/CubeMapCapture/CubeMapCaptureFeatureProcessorInterface.h>
  14. namespace AZ
  15. {
  16. namespace Render
  17. {
  18. enum class CubeMapCaptureType : uint32_t
  19. {
  20. Specular,
  21. Diffuse
  22. };
  23. enum class CubeMapSpecularQualityLevel : uint32_t
  24. {
  25. VeryLow, // 64
  26. Low, // 128
  27. Medium, // 256
  28. High, // 512
  29. VeryHigh, // 1024
  30. Count
  31. };
  32. static const char* CubeMapSpecularFileSuffixes[] =
  33. {
  34. "_iblspecularcm64.dds",
  35. "_iblspecularcm128.dds",
  36. "_iblspecularcm256.dds",
  37. "_iblspecularcm512.dds",
  38. "_iblspecularcm1024.dds"
  39. };
  40. static_assert(AZ_ARRAY_SIZE(CubeMapSpecularFileSuffixes) == aznumeric_cast<uint32_t>(CubeMapSpecularQualityLevel::Count),
  41. "CubeMapSpecularFileSuffixes must have the same number of entries as CubeMapSpecularQualityLevel");
  42. static constexpr const char* CubeMapDiffuseFileSuffix = "_ibldiffusecm.dds";
  43. // Mixin class that provides cubemap capture capability for editor components
  44. class EditorCubeMapRenderer
  45. {
  46. protected:
  47. EditorCubeMapRenderer() = default;
  48. // initiate the cubemap render and update the relative path if necessary
  49. AZ::u32 RenderCubeMap(
  50. AZStd::function<void(RenderCubeMapCallback, AZStd::string&)> renderCubeMapFn,
  51. const AZStd::string dialogText,
  52. const AZ::Entity* entity,
  53. const AZStd::string& folderName,
  54. AZStd::string& relativePath,
  55. CubeMapCaptureType captureType,
  56. CubeMapSpecularQualityLevel specularQualityLevel = CubeMapSpecularQualityLevel::Medium);
  57. private:
  58. // save the cubemap data to the output file
  59. void WriteOutputFile(AZStd::string filePath, uint8_t* const* cubeMapTextureData, RHI::Format cubeMapTextureFormat);
  60. // flag indicating if a cubemap render is currently in progress
  61. AZStd::atomic_bool m_renderInProgress = false;
  62. };
  63. } // namespace Render
  64. } // namespace AZ