3
0

SpecularReflectionsComponentConfig.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. ->ClassElement(AZ::Edit::ClassElements::Group, "Ray Tracing")
  53. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  54. ->DataElement(Edit::UIHandlers::CheckBox, &SSROptions::m_rayTracing, "Hardware Ray Tracing", "Enable Hardware Ray Tracing for Hybrid SSR-RT, which improves hit detection quality and provides fallback data for occluded or off-screen surfaces")
  55. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree)
  56. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsEnabled)
  57. ->DataElement(Edit::UIHandlers::CheckBox, &SSROptions::m_rayTraceFallbackData, "Ray Trace Fallback Data", "Generate fallback image data using hardware raytracing when the hit point is off-screen of obstructed by an object closer to the camera")
  58. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree)
  59. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsRayTracingEnabled)
  60. ->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")
  61. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsRayTracingFallbackEnabled)
  62. ->ClassElement(AZ::Edit::ClassElements::Group, "Temporal Filtering")
  63. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  64. ->DataElement(Edit::UIHandlers::CheckBox, &SSROptions::m_temporalFiltering, "Temporal Filtering", "Reduce artifacts with temporal filtering over multiple frames")
  65. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree)
  66. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsEnabled)
  67. ->DataElement(Edit::UIHandlers::Slider, &SSROptions::m_temporalFilteringStrength, "Temporal Filtering Strength", "Higher strength reduces motion artifacts but increases temporal lag")
  68. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsTemporalFilteringEnabled)
  69. ->Attribute(AZ::Edit::Attributes::Min, 0.1f)
  70. ->Attribute(AZ::Edit::Attributes::Max, 2.0f)
  71. ->Attribute(AZ::Edit::Attributes::Step, 0.1f)
  72. ->Attribute(AZ::Edit::Attributes::Decimals, 1)
  73. ->ClassElement(AZ::Edit::ClassElements::Group, "Luminance")
  74. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  75. ->DataElement(Edit::UIHandlers::CheckBox, &SSROptions::m_luminanceClamp, "Luminance Clamp", "Reduce specular artifacts by clamping the luminance to a maximum value")
  76. ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree)
  77. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsEnabled)
  78. ->DataElement(Edit::UIHandlers::Slider, &SSROptions::m_maxLuminance, "Maximum Luminance", "Maximum luminance value")
  79. ->Attribute(AZ::Edit::Attributes::Visibility, &SSROptions::IsLuminanceClampEnabled)
  80. ->Attribute(AZ::Edit::Attributes::Min, 0.0f)
  81. ->Attribute(AZ::Edit::Attributes::Max, 5.0f)
  82. ->Attribute(AZ::Edit::Attributes::Decimals, 3)
  83. ;
  84. }
  85. }
  86. }
  87. void SpecularReflectionsComponentConfig::Reflect(ReflectContext* context)
  88. {
  89. SpecularReflectionsComponentSSRConfig::Reflect(context);
  90. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  91. {
  92. serializeContext->Class<SpecularReflectionsComponentConfig, ComponentConfig>()
  93. ->Version(1)
  94. ->Field("SSR", &SpecularReflectionsComponentConfig::m_ssr)
  95. ;
  96. }
  97. }
  98. } // namespace Render
  99. } // namespace AZ