RenderDebugEditorComponent.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 <Debug/RenderDebugEditorComponent.h>
  10. namespace AZ::Render
  11. {
  12. void RenderDebugEditorComponent::Reflect(AZ::ReflectContext* context)
  13. {
  14. BaseClass::Reflect(context);
  15. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  16. {
  17. serializeContext->Class<RenderDebugEditorComponent, BaseClass>()
  18. ->Version(0);
  19. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  20. {
  21. editContext->Class<RenderDebugEditorComponent>(
  22. "Debug Rendering", "Controls for debugging rendering.")
  23. ->ClassElement(Edit::ClassElements::EditorData, "")
  24. ->Attribute(Edit::Attributes::Category, "Graphics/Debugging")
  25. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg") // [GFX TODO ATOM-2672][PostFX] need to create icons for PostProcessing.
  26. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Component_Placeholder.svg") // [GFX TODO ATOM-2672][PostFX] need to create icons for PostProcessing.
  27. ->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Level"))
  28. ->Attribute(Edit::Attributes::AutoExpand, true)
  29. ;
  30. editContext->Class<RenderDebugComponentController>(
  31. "RenderDebugComponentController", "")
  32. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  33. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  34. ->DataElement(AZ::Edit::UIHandlers::Default, &RenderDebugComponentController::m_configuration, "Configuration", "")
  35. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  36. ;
  37. editContext->Class<RenderDebugComponentConfig>("RenderDebugComponentConfig", "")
  38. ->ClassElement(Edit::ClassElements::EditorData, "")
  39. ->DataElement(Edit::UIHandlers::CheckBox, &RenderDebugComponentConfig::m_enabled,
  40. "Enable Render Debugging", "Enable Render Debugging.")
  41. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree)
  42. // Render Debug View Mode
  43. ->DataElement(Edit::UIHandlers::ComboBox, &RenderDebugComponentConfig::m_renderDebugViewMode,
  44. "Debug View Mode", "What debug info to output to the view.")
  45. ->EnumAttribute(RenderDebugViewMode::None, "None")
  46. ->EnumAttribute(RenderDebugViewMode::BaseColor, "Base Color")
  47. ->EnumAttribute(RenderDebugViewMode::Albedo, "Albedo")
  48. ->EnumAttribute(RenderDebugViewMode::Roughness, "Roughness")
  49. ->EnumAttribute(RenderDebugViewMode::Metallic, "Metallic")
  50. ->EnumAttribute(RenderDebugViewMode::Normal, "Normal")
  51. ->EnumAttribute(RenderDebugViewMode::Tangent, "Tangent")
  52. ->EnumAttribute(RenderDebugViewMode::Bitangent, "Bitangent")
  53. ->EnumAttribute(RenderDebugViewMode::CascadeShadows, "CascadeShadows")
  54. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  55. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  56. // Lighting
  57. ->ClassElement(Edit::ClassElements::Group, "Lighting")
  58. ->Attribute(Edit::Attributes::AutoExpand, true)
  59. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  60. ->DataElement(Edit::UIHandlers::ComboBox, &RenderDebugComponentConfig::m_renderDebugLightingType,
  61. "Lighting Type", "Controls whether diffuse or specular lighting is displayed.")
  62. ->EnumAttribute(RenderDebugLightingType::DiffuseAndSpecular, "Diffuse + Specular")
  63. ->EnumAttribute(RenderDebugLightingType::Diffuse, "Diffuse")
  64. ->EnumAttribute(RenderDebugLightingType::Specular, "Specular")
  65. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  66. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  67. ->DataElement(Edit::UIHandlers::ComboBox, &RenderDebugComponentConfig::m_renderDebugLightingSource,
  68. "Lighting Source", "Controls whether direct or indirect lighting is displayed.")
  69. ->EnumAttribute(RenderDebugLightingSource::DirectAndIndirect, "Direct + Indirect")
  70. ->EnumAttribute(RenderDebugLightingSource::Direct, "Direct")
  71. ->EnumAttribute(RenderDebugLightingSource::Indirect, "Indirect")
  72. ->EnumAttribute(RenderDebugLightingSource::DebugLight, "Debug Light")
  73. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  74. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  75. ->DataElement(AZ::Edit::UIHandlers::Color, &RenderDebugComponentConfig::m_debugLightingColor,
  76. "Debug Light Color", "RGB value of the debug light if used.")
  77. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  78. ->Attribute(Edit::Attributes::ReadOnly, &RenderDebugComponentConfig::IsDebugLightReadOnly)
  79. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  80. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_debugLightingIntensity,
  81. "Debug Light Intensity", "Intensity of the debug light")
  82. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  83. ->Attribute(AZ::Edit::Attributes::Max, 25.0f)
  84. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  85. ->Attribute(Edit::Attributes::ReadOnly, &RenderDebugComponentConfig::IsDebugLightReadOnly)
  86. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  87. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_debugLightingAzimuth,
  88. "Debug Light Azimuth", "Azimuth controlling the direction of the debug light")
  89. // A range of [0, 360] creates a hard edge that the user can't keep rotating along, forcing them to push the slider to the opposite side
  90. // This isn't user friendly if the user wants to test lighting angles around the 0 degree mark, therefore we set the range to [-360, 360]
  91. // This provides the user with two full rotations and lets them gradually test around any angle without hitting the wall mentioned above
  92. ->Attribute(AZ::Edit::Attributes::Min, -360.0f)
  93. ->Attribute(AZ::Edit::Attributes::Max, 360.0f)
  94. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  95. ->Attribute(Edit::Attributes::ReadOnly, &RenderDebugComponentConfig::IsDebugLightReadOnly)
  96. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  97. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_debugLightingElevation,
  98. "Debug Light Elevation", "Elevation controlling the direction of the debug light")
  99. ->Attribute(AZ::Edit::Attributes::Min, -90.0f)
  100. ->Attribute(AZ::Edit::Attributes::Max, 90.0f)
  101. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  102. ->Attribute(Edit::Attributes::ReadOnly, &RenderDebugComponentConfig::IsDebugLightReadOnly)
  103. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  104. // Base Color Override
  105. ->ClassElement(Edit::ClassElements::Group, "Base Color")
  106. ->Attribute(Edit::Attributes::AutoExpand, true)
  107. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  108. ->DataElement(Edit::UIHandlers::CheckBox, &RenderDebugComponentConfig::m_overrideBaseColor,
  109. "Override Base Color", "Whether to override base color values on materials in the scene.")
  110. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  111. ->DataElement(AZ::Edit::UIHandlers::Color, &RenderDebugComponentConfig::m_materialBaseColorOverride,
  112. "Base Color Value", "RGB value used to override base color on materials in the scene.")
  113. ->Attribute(Edit::Attributes::ReadOnly, &RenderDebugComponentConfig::IsBaseColorReadOnly)
  114. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  115. // Roughness Override
  116. ->ClassElement(Edit::ClassElements::Group, "Roughness")
  117. ->Attribute(Edit::Attributes::AutoExpand, true)
  118. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  119. ->DataElement(Edit::UIHandlers::CheckBox, &RenderDebugComponentConfig::m_overrideRoughness,
  120. "Override Roughness", "Whether to override roughness values on materials in the scene.")
  121. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  122. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_materialRoughnessOverride,
  123. "Roughness Value", "Roughness value used to override materials in the scene")
  124. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  125. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  126. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  127. ->Attribute(Edit::Attributes::ReadOnly, &RenderDebugComponentConfig::IsRoughnessReadOnly)
  128. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  129. // Metallic Override
  130. ->ClassElement(Edit::ClassElements::Group, "Metallic")
  131. ->Attribute(Edit::Attributes::AutoExpand, true)
  132. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  133. ->DataElement(Edit::UIHandlers::CheckBox, &RenderDebugComponentConfig::m_overrideMetallic,
  134. "Override Metallic", "Whether to override roughness values on materials in the scene.")
  135. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  136. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_materialMetallicOverride,
  137. "Metallic Value", "Metallic value used to override materials in the scene")
  138. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  139. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  140. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
  141. ->Attribute(Edit::Attributes::ReadOnly, &RenderDebugComponentConfig::IsMetallicReadOnly)
  142. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  143. // Normal Maps
  144. ->ClassElement(Edit::ClassElements::Group, "Normals")
  145. ->Attribute(Edit::Attributes::AutoExpand, true)
  146. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  147. ->DataElement(Edit::UIHandlers::CheckBox, &RenderDebugComponentConfig::m_enableNormalMaps,
  148. "Enable Normal Maps", "Whether to use normal maps in rendering.")
  149. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  150. ->DataElement(Edit::UIHandlers::CheckBox, &RenderDebugComponentConfig::m_enableDetailNormalMaps,
  151. "Enable Detail Normal Maps", "Whether to use detail normal maps in rendering.")
  152. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  153. // Custom Debug Variables
  154. // Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code
  155. // Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code
  156. ->ClassElement(Edit::ClassElements::Group, "Custom Debug Variables")
  157. ->Attribute(Edit::Attributes::AutoExpand, false)
  158. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  159. ->DataElement(Edit::UIHandlers::CheckBox, &RenderDebugComponentConfig::m_customDebugOption01,
  160. "Custom Option 01", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  161. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  162. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  163. ->DataElement(Edit::UIHandlers::CheckBox, &RenderDebugComponentConfig::m_customDebugOption02,
  164. "Custom Option 02", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  165. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  166. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  167. ->DataElement(Edit::UIHandlers::CheckBox, &RenderDebugComponentConfig::m_customDebugOption03,
  168. "Custom Option 03", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  169. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  170. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  171. ->DataElement(Edit::UIHandlers::CheckBox, &RenderDebugComponentConfig::m_customDebugOption04,
  172. "Custom Option 04", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  173. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  174. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  175. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_customDebugFloat01,
  176. "Custom Float 01", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  177. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  178. ->Attribute(AZ::Edit::Attributes::SoftMin, 0.0f)
  179. ->Attribute(AZ::Edit::Attributes::SoftMax, 1.0f)
  180. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  181. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_customDebugFloat02,
  182. "Custom Float 02", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  183. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  184. ->Attribute(AZ::Edit::Attributes::SoftMin, 0.0f)
  185. ->Attribute(AZ::Edit::Attributes::SoftMax, 1.0f)
  186. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  187. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_customDebugFloat03,
  188. "Custom Float 03", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  189. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  190. ->Attribute(AZ::Edit::Attributes::SoftMin, 0.0f)
  191. ->Attribute(AZ::Edit::Attributes::SoftMax, 1.0f)
  192. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  193. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_customDebugFloat04,
  194. "Custom Float 04", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  195. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  196. ->Attribute(AZ::Edit::Attributes::SoftMin, -1.0f)
  197. ->Attribute(AZ::Edit::Attributes::SoftMax, 1.0f)
  198. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  199. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_customDebugFloat05,
  200. "Custom Float 05", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  201. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  202. ->Attribute(AZ::Edit::Attributes::SoftMin, -1.0f)
  203. ->Attribute(AZ::Edit::Attributes::SoftMax, 1.0f)
  204. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  205. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_customDebugFloat06,
  206. "Custom Float 06", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  207. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  208. ->Attribute(AZ::Edit::Attributes::SoftMin, -1.0f)
  209. ->Attribute(AZ::Edit::Attributes::SoftMax, 1.0f)
  210. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  211. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_customDebugFloat07,
  212. "Custom Float 07", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  213. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  214. ->Attribute(AZ::Edit::Attributes::SoftMin, 0.0f)
  215. ->Attribute(AZ::Edit::Attributes::SoftMax, 10.0f)
  216. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  217. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_customDebugFloat08,
  218. "Custom Float 08", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  219. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  220. ->Attribute(AZ::Edit::Attributes::SoftMin, 0.0f)
  221. ->Attribute(AZ::Edit::Attributes::SoftMax, 10.0f)
  222. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  223. ->DataElement(AZ::Edit::UIHandlers::Slider, &RenderDebugComponentConfig::m_customDebugFloat09,
  224. "Custom Float 09", "Custom variables are accessible from the Scene SRG for shader authors to use directly in their azsl code"
  225. "Please use these only for local debugging purposes and DO NOT leave their usage in when submitting code")
  226. ->Attribute(AZ::Edit::Attributes::SoftMin, 0.0f)
  227. ->Attribute(AZ::Edit::Attributes::SoftMax, 10.0f)
  228. ->Attribute(Edit::Attributes::Visibility, &RenderDebugComponentConfig::GetEnabled)
  229. ;
  230. }
  231. }
  232. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  233. {
  234. behaviorContext->Class<RenderDebugEditorComponent>()->RequestBus("RenderDebugRequestBus");
  235. behaviorContext->ConstantProperty("RenderDebugEditorComponentTypeId", BehaviorConstant(Uuid(RenderDebug::RenderDebugEditorComponentTypeId)))
  236. ->Attribute(AZ::Script::Attributes::Module, "render")
  237. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  238. }
  239. }
  240. RenderDebugEditorComponent::RenderDebugEditorComponent(const RenderDebugComponentConfig& config)
  241. : BaseClass(config)
  242. {
  243. }
  244. u32 RenderDebugEditorComponent::OnConfigurationChanged()
  245. {
  246. m_controller.OnConfigChanged();
  247. return Edit::PropertyRefreshLevels::AttributesAndValues;
  248. }
  249. }