EditorLightingPreset.cpp 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. #undef RC_INVOKED
  9. #include <Atom/Feature/Utils/EditorLightingPreset.h>
  10. #include <Atom/Feature/Utils/LightingPreset.h>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. #include <AzCore/RTTI/BehaviorContext.h>
  13. #include <Atom/RPI.Edit/Common/ColorUtils.h>
  14. namespace AZ
  15. {
  16. namespace Render
  17. {
  18. void EditorExposureControlConfig::Reflect(AZ::ReflectContext* context)
  19. {
  20. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  21. {
  22. if (auto editContext = serializeContext->GetEditContext())
  23. {
  24. editContext->Class<ExposureControlConfig>(
  25. "ExposureControlConfig", "")
  26. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  27. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  28. ->DataElement(Edit::UIHandlers::ComboBox,
  29. &ExposureControlConfig::m_exposureControlType,
  30. "Control Type",
  31. "How to control a exposure value.")
  32. ->EnumAttribute(ExposureControlConfig::ExposureControlType::ManualOnly, "Manual Only")
  33. ->EnumAttribute(ExposureControlConfig::ExposureControlType::EyeAdaptation, "Eye Adaptation")
  34. ->DataElement(AZ::Edit::UIHandlers::Slider, &ExposureControlConfig::m_manualCompensationValue, "Manual compensation", "Manual exposure compensation value.")
  35. ->Attribute(AZ::Edit::Attributes::Min, -16.0f)
  36. ->Attribute(AZ::Edit::Attributes::Max, 16.0f)
  37. ->DataElement(AZ::Edit::UIHandlers::Slider, &ExposureControlConfig::m_autoExposureMin, "Minimum Exposure", "Minimum exposure value for the auto exposure.")
  38. ->Attribute(AZ::Edit::Attributes::Min, -16.0f)
  39. ->Attribute(AZ::Edit::Attributes::Max, 16.0f)
  40. ->DataElement(AZ::Edit::UIHandlers::Slider, &ExposureControlConfig::m_autoExposureMax, "Maximum Exposure", "Maximum exposure value for the auto exposure.")
  41. ->Attribute(AZ::Edit::Attributes::Min, -16.0f)
  42. ->Attribute(AZ::Edit::Attributes::Max, 16.0f)
  43. ->DataElement(AZ::Edit::UIHandlers::Slider, &ExposureControlConfig::m_autoExposureSpeedUp, "Speed Up", "The speed at which auto exposure adapts to bright scenes.")
  44. ->Attribute(AZ::Edit::Attributes::Min, 0.01)
  45. ->Attribute(AZ::Edit::Attributes::Max, 10.0f)
  46. ->DataElement(AZ::Edit::UIHandlers::Slider, &ExposureControlConfig::m_autoExposureSpeedDown, "Speed Down", "The speed at which auto exposure adapts to dark scenes.")
  47. ->Attribute(AZ::Edit::Attributes::Min, 0.01)
  48. ->Attribute(AZ::Edit::Attributes::Max, 10.0f)
  49. ;
  50. }
  51. }
  52. }
  53. void EditorLightConfig::Reflect(AZ::ReflectContext* context)
  54. {
  55. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  56. {
  57. if (auto editContext = serializeContext->GetEditContext())
  58. {
  59. editContext->Class<LightConfig>(
  60. "LightConfig", "")
  61. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  62. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  63. ->DataElement(AZ::Edit::UIHandlers::Default, &LightConfig::m_direction, "Direction", "")
  64. ->DataElement(Edit::UIHandlers::Color, &LightConfig::m_color, "Color", "Color of the light")
  65. ->Attribute("ColorEditorConfiguration", AZ::RPI::ColorUtils::GetLinearRgbEditorConfig())
  66. ->DataElement(Edit::UIHandlers::Default, &LightConfig::m_intensity, "Intensity", "Intensity of the light in the set photometric unit.")
  67. ->ClassElement(AZ::Edit::ClassElements::Group, "Shadow")
  68. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  69. ->DataElement(Edit::UIHandlers::Default, &LightConfig::m_shadowFarClipDistance, "Shadow Far Clip", "Shadow specific far clip distance.")
  70. ->DataElement(Edit::UIHandlers::ComboBox, &LightConfig::m_shadowmapSize, "Shadowmap Size", "Width/Height of shadowmap")
  71. ->EnumAttribute(ShadowmapSize::Size256, " 256")
  72. ->EnumAttribute(ShadowmapSize::Size512, " 512")
  73. ->EnumAttribute(ShadowmapSize::Size1024, "1024")
  74. ->EnumAttribute(ShadowmapSize::Size2048, "2048")
  75. ->DataElement(Edit::UIHandlers::Slider, &LightConfig::m_shadowCascadeCount, "Cascade Count", "Number of cascades")
  76. ->Attribute(Edit::Attributes::Min, 1)
  77. ->Attribute(Edit::Attributes::Max, Shadow::MaxNumberOfCascades)
  78. ->DataElement(Edit::UIHandlers::CheckBox,
  79. &LightConfig::m_enableShadowDebugColoring, "Enable Debug Coloring?",
  80. "Enable coloring to see how cascades places 0:red, 1:green, 2:blue, 3:yellow.")
  81. ;
  82. }
  83. }
  84. }
  85. void EditorLightingPreset::Reflect(AZ::ReflectContext* context)
  86. {
  87. EditorExposureControlConfig::Reflect(context);
  88. EditorLightConfig::Reflect(context);
  89. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  90. {
  91. if (auto editContext = serializeContext->GetEditContext())
  92. {
  93. editContext->Class<LightingPreset>(
  94. "LightingPreset", "")
  95. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  96. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  97. ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_iblDiffuseImageAsset, "IBL Diffuse Image Asset", "IBL diffuse image asset reference")
  98. ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_iblSpecularImageAsset, "IBL Specular Image Asset", "IBL specular image asset reference")
  99. ->DataElement(AZ::Edit::UIHandlers::Slider, &LightingPreset::m_iblExposure, "IBL exposure", "IBL exposure")
  100. ->Attribute(AZ::Edit::Attributes::SoftMin, -5.0f)
  101. ->Attribute(AZ::Edit::Attributes::SoftMax, 5.0f)
  102. ->Attribute(AZ::Edit::Attributes::Min, -20.0f)
  103. ->Attribute(AZ::Edit::Attributes::Max, 20.0f)
  104. ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_skyboxImageAsset, "Skybox Image Asset", "Skybox image asset reference")
  105. ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_alternateSkyboxImageAsset, "Skybox Image Asset (Alt)", "Alternate skybox image asset reference")
  106. ->DataElement(AZ::Edit::UIHandlers::Slider, &LightingPreset::m_skyboxExposure, "Skybox Exposure", "Skybox exposure")
  107. ->Attribute(AZ::Edit::Attributes::SoftMin, -5.0f)
  108. ->Attribute(AZ::Edit::Attributes::SoftMax, 5.0f)
  109. ->Attribute(AZ::Edit::Attributes::Min, -20.0f)
  110. ->Attribute(AZ::Edit::Attributes::Max, 20.0f)
  111. ->DataElement(AZ::Edit::UIHandlers::Slider, &LightingPreset::m_shadowCatcherOpacity, "Shadow Catcher Opacity", "Shadow catcher opacity")
  112. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  113. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  114. ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_exposure, "Exposure", "Exposure")
  115. ->DataElement(AZ::Edit::UIHandlers::Default, &LightingPreset::m_lights, "Lights", "Lights")
  116. ->Attribute(AZ::Edit::Attributes::ClearNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
  117. ->Attribute(AZ::Edit::Attributes::AddNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
  118. ->Attribute(AZ::Edit::Attributes::RemoveNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
  119. ;
  120. }
  121. }
  122. }
  123. } // namespace Render
  124. } // namespace AZ