3
0

SpecularReflectionsComponentConfig.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*7
  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 <SpecularReflections/SpecularReflectionsComponentConfig.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include <AzCore/Serialization/EditContext.h>
  11. namespace AZ
  12. {
  13. namespace Render
  14. {
  15. void SpecularReflectionsComponentSSRConfig::Reflect(ReflectContext* context)
  16. {
  17. SSROptions::Reflect(context);
  18. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  19. {
  20. serializeContext->Class<SpecularReflectionsComponentSSRConfig>()
  21. ->Version(1)
  22. ->Field("Options", &SpecularReflectionsComponentSSRConfig::m_options)
  23. ;
  24. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  25. {
  26. editContext->Class<SSROptions>("Screen Space Reflections (SSR)", "Screen Space Reflections (SSR) Configuration")
  27. ->ClassElement(Edit::ClassElements::EditorData, "")
  28. ->DataElement(Edit::UIHandlers::CheckBox, &SSROptions::m_enable, "Enable SSR", "Enable Screen Space Reflections (SSR)")
  29. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree)
  30. ->DataElement(Edit::UIHandlers::Slider, &SSROptions::m_maxRayDistance, "Maximum Ray Distance", "The maximum length of the rays to consider for hit detection")
  31. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsEnabled)
  32. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  33. ->Attribute(AZ::Edit::Attributes::Max, 100.0f)
  34. ->Attribute(AZ::Edit::Attributes::Step, 1.0f)
  35. ->DataElement(Edit::UIHandlers::Slider, &SSROptions::m_maxDepthThreshold, "Maximum Depth Threshold", "The maximum delta between the ray depth and depth buffer value which will be considered a hit. Also known as thickness.")
  36. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsEnabled)
  37. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  38. ->Attribute(AZ::Edit::Attributes::Max, 5.0f)
  39. ->Attribute(AZ::Edit::Attributes::Step, 0.1f)
  40. ->DataElement(Edit::UIHandlers::Slider, &SSROptions::m_maxRoughness, "Maximum Roughness", "Surfaces at or below this roughness value will have SSR applied")
  41. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsEnabled)
  42. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  43. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  44. ->Attribute(AZ::Edit::Attributes::Step, 0.1f)
  45. ->DataElement(Edit::UIHandlers::Slider, &SSROptions::m_roughnessBias, "Roughness Bias", "Bias applied to the surface roughness")
  46. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsEnabled)
  47. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  48. ->Attribute(AZ::Edit::Attributes::Max, 1.0f)
  49. ->Attribute(AZ::Edit::Attributes::Step, 0.1f)
  50. ->DataElement(Edit::UIHandlers::CheckBox, &SSROptions::m_halfResolution, "Half Resolution", "Use half resolution in the reflected image, improves performance but may increase artifacts during camera motion")
  51. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsEnabled)
  52. ->DataElement(Edit::UIHandlers::ComboBox, &SSROptions::m_reflectionMethod, "Reflection Method",
  53. "Screen-space: Use screen-space reflections only\n\n"
  54. "Hybrid SSR-RT: Use ray tracing for hit detection and screen-space data for surface evaluation\n\n"
  55. "Hybrid SSR-RT + Ray Tracing fallback: Use screen-space reflection data when available and ray tracing when not\n\n"
  56. "Ray Tracing: Use hardware ray tracing only")
  57. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree)
  58. ->EnumAttribute(SSROptions::ReflectionMethod::ScreenSpace, "Screen Space")
  59. ->EnumAttribute(SSROptions::ReflectionMethod::Hybrid, "Hybrid SSR-RT")
  60. ->EnumAttribute(SSROptions::ReflectionMethod::HybridWithFallback, "Hybrid SSR-RT + Ray Tracing fallback")
  61. ->EnumAttribute(SSROptions::ReflectionMethod::RayTracing, "Ray Tracing")
  62. ->DataElement(Edit::UIHandlers::CheckBox, &SSROptions::m_rayTraceFallbackSpecular, "Apply Fallback Specular Lighting", "Apply specular lighting in the fallback image, improves fallback image accuracy but may reduce performance and increase artifacts")
  63. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsRayTracingFallbackEnabled)
  64. ->ClassElement(AZ::Edit::ClassElements::Group, "Temporal Filtering")
  65. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  66. ->DataElement(Edit::UIHandlers::CheckBox, &SSROptions::m_temporalFiltering, "Temporal Filtering", "Reduce artifacts with temporal filtering over multiple frames")
  67. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree)
  68. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsEnabled)
  69. ->DataElement(Edit::UIHandlers::Slider, &SSROptions::m_temporalFilteringStrength, "Temporal Filtering Strength", "Higher strength reduces motion artifacts but increases temporal lag")
  70. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsTemporalFilteringEnabled)
  71. ->Attribute(AZ::Edit::Attributes::Min, 0.1f)
  72. ->Attribute(AZ::Edit::Attributes::Max, 2.0f)
  73. ->Attribute(AZ::Edit::Attributes::Step, 0.1f)
  74. ->Attribute(AZ::Edit::Attributes::Decimals, 1)
  75. ->ClassElement(AZ::Edit::ClassElements::Group, "Luminance")
  76. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  77. ->DataElement(Edit::UIHandlers::CheckBox, &SSROptions::m_luminanceClamp, "Luminance Clamp", "Reduce specular artifacts by clamping the luminance to a maximum value")
  78. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree)
  79. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsEnabled)
  80. ->DataElement(Edit::UIHandlers::Slider, &SSROptions::m_maxLuminance, "Maximum Luminance", "Maximum luminance value")
  81. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsLuminanceClampEnabled)
  82. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  83. ->Attribute(AZ::Edit::Attributes::Max, 5.0f)
  84. ->Attribute(AZ::Edit::Attributes::Decimals, 3)
  85. ;
  86. }
  87. }
  88. }
  89. void SpecularReflectionsComponentConfig::Reflect(ReflectContext* context)
  90. {
  91. SpecularReflectionsComponentSSRConfig::Reflect(context);
  92. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  93. {
  94. serializeContext->Class<SpecularReflectionsComponentConfig, ComponentConfig>()
  95. ->Version(1)
  96. ->Field("SSR", &SpecularReflectionsComponentConfig::m_ssr)
  97. ;
  98. }
  99. }
  100. } // namespace Render
  101. } // namespace AZ