3
0

EditorDeferredFogComponent.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 <AzCore/RTTI/BehaviorContext.h>
  9. #include <ScreenSpace/EditorDeferredFogComponent.h>
  10. namespace AZ
  11. {
  12. namespace Render
  13. {
  14. void EditorDeferredFogComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. BaseClass::Reflect(context);
  17. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serializeContext->Class<EditorDeferredFogComponent, BaseClass>()
  20. ->Version(1);
  21. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  22. {
  23. editContext->Class<EditorDeferredFogComponent>(
  24. "Deferred Fog", "Controls the Deferred Fog")
  25. ->ClassElement(Edit::ClassElements::EditorData, "")
  26. ->Attribute(Edit::Attributes::Category, "Graphics/Environment")
  27. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg") // [GFX TODO ATOM-2672][PostFX] need to create icons for PostProcessing.
  28. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Component_Placeholder.svg") // [GFX TODO ATOM-2672][PostFX] need to create icons for PostProcessing.
  29. ->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
  30. ->Attribute(Edit::Attributes::AutoExpand, true)
  31. ->Attribute(Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/atom/deferred-fog/") // [TODO][ATOM-13427] Create Wiki for Deferred Fog
  32. ;
  33. editContext->Class<DeferredFogComponentController>(
  34. "DeferredFogComponentController", "")
  35. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  36. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  37. ->DataElement(AZ::Edit::UIHandlers::Default, &DeferredFogComponentController::m_configuration, "Configuration", "")
  38. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  39. ;
  40. editContext->Class<DeferredFogComponentConfig>(
  41. "DeferredFogComponentConfig", "")
  42. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  43. ->DataElement(Edit::UIHandlers::CheckBox,
  44. &DeferredFogComponentConfig::m_enabled,
  45. "Enable Deferred Fog",
  46. "Enable Deferred Fog.")
  47. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  48. ->DataElement(AZ::Edit::UIHandlers::Color, &DeferredFogComponentConfig::m_fogColor,
  49. "Fog Color", "The fog color.")
  50. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  51. ->DataElement(AZ::Edit::UIHandlers::Slider, &DeferredFogComponentConfig::m_fogStartDistance,
  52. "Fog Start Distance", "The distance from the viewer when the fog starts")
  53. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  54. ->Attribute(AZ::Edit::Attributes::Max, 5000.0f)
  55. ->Attribute(AZ::Edit::Attributes::SoftMin, 0.0f)
  56. ->Attribute(AZ::Edit::Attributes::SoftMax, 10.0f)
  57. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  58. ->DataElement(AZ::Edit::UIHandlers::Slider, &DeferredFogComponentConfig::m_fogEndDistance,
  59. "Fog End Distance", "At what distance from the viewer does the fog take over and mask the background scene out")
  60. ->Attribute(AZ::Edit::Attributes::Min, &DeferredFogComponentConfig::m_fogStartDistance)
  61. ->Attribute(AZ::Edit::Attributes::Max, 5000.0f)
  62. ->Attribute(AZ::Edit::Attributes::SoftMin, 0.0f)
  63. ->Attribute(AZ::Edit::Attributes::SoftMax, 100.0f)
  64. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  65. // Fog layer properties
  66. ->DataElement(Edit::UIHandlers::CheckBox,
  67. &DeferredFogComponentConfig::m_enableFogLayerShaderOption,
  68. "Enable Fog Layer",
  69. "Enable Fog Layer")
  70. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  71. ->DataElement(AZ::Edit::UIHandlers::Slider, &DeferredFogComponentConfig::m_fogMinHeight,
  72. "Fog Bottom Height", "The height at which the fog layer starts")
  73. ->Attribute(AZ::Edit::Attributes::Min, -5000.0f)
  74. ->Attribute(AZ::Edit::Attributes::Max, 5000.0f)
  75. ->Attribute(AZ::Edit::Attributes::SoftMin, -100.0f)
  76. ->Attribute(AZ::Edit::Attributes::SoftMax, 1000.0f)
  77. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  78. ->DataElement(AZ::Edit::UIHandlers::Slider, &DeferredFogComponentConfig::m_fogMaxHeight,
  79. "Fog Max Height", "The height of the fog layer top")
  80. ->Attribute(AZ::Edit::Attributes::Min, -5000.0f)
  81. ->Attribute(AZ::Edit::Attributes::Max, 5000.0f)
  82. ->Attribute(AZ::Edit::Attributes::SoftMin, -100.0f)
  83. ->Attribute(AZ::Edit::Attributes::SoftMax, 1000.0f)
  84. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  85. // Fog turbulence properties
  86. ->DataElement(Edit::UIHandlers::CheckBox,
  87. &DeferredFogComponentConfig::m_useNoiseTextureShaderOption,
  88. "Enable Turbulence Properties",
  89. "Enable Turbulence Properties")
  90. ->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  91. ->DataElement(AZ::Edit::UIHandlers::LineEdit, &DeferredFogComponentConfig::m_noiseTexture,
  92. "Noise Texture", "The noise texture used for creating the fog turbulence")
  93. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  94. // First noise octave
  95. ->DataElement(AZ::Edit::UIHandlers::Vector2, &DeferredFogComponentConfig::m_noiseScaleUV,
  96. "Noise Texture First Octave Scale", "The scale of the first noise octave - higher indicates higher frequency / repetition")
  97. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  98. ->DataElement(AZ::Edit::UIHandlers::Vector2, &DeferredFogComponentConfig::m_noiseVelocityUV,
  99. "Noise Texture First Octave Velocity", "The velocity of the first noise octave UV coordinates")
  100. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  101. // Second noise octave
  102. ->DataElement(AZ::Edit::UIHandlers::Vector2, &DeferredFogComponentConfig::m_noiseScaleUV2,
  103. "Noise Texture Second Octave Scale", "The scale of the second noise octave - higher indicates higher frequency / repetition")
  104. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  105. ->DataElement(AZ::Edit::UIHandlers::Vector2, &DeferredFogComponentConfig::m_noiseVelocityUV2,
  106. "Noise Texture Second Octave Velocity", "The velocity of the second noise octave UV coordinates")
  107. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  108. ->DataElement(AZ::Edit::UIHandlers::Slider, &DeferredFogComponentConfig::m_octavesBlendFactor,
  109. "Octaves Blend Factor", "The blend factor between the noise octaves")
  110. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  111. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  112. ->Attribute(AZ::Edit::Attributes::SoftMin, 0.0f)
  113. ->Attribute(AZ::Edit::Attributes::SoftMax, 1.0f)
  114. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  115. ;
  116. }
  117. }
  118. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  119. {
  120. behaviorContext->Class<EditorDeferredFogComponent>()->RequestBus("DeferredFogRequestsBus");
  121. behaviorContext->ConstantProperty("EditorDeferredFogComponentTypeId", BehaviorConstant(Uuid(DeferredFog::EditorDeferredFogComponentTypeId)))
  122. ->Attribute(AZ::Script::Attributes::Module, "render")
  123. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  124. }
  125. }
  126. EditorDeferredFogComponent::EditorDeferredFogComponent(const DeferredFogComponentConfig& config)
  127. : BaseClass(config)
  128. {
  129. }
  130. u32 EditorDeferredFogComponent::OnConfigurationChanged()
  131. {
  132. m_controller.OnConfigChanged();
  133. return Edit::PropertyRefreshLevels::AttributesAndValues;
  134. }
  135. }
  136. }