From 5b88d96eec29a5b6359243f5413693f3acf619f0 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Mon, 2 Aug 2021 13:36:10 -0700 Subject: [PATCH 01/17] Exposed fields to the mesh component giving greater Lod control from the editor Signed-off-by: Kyle B --- .../Atom/Feature/Mesh/MeshFeatureProcessor.h | 12 ++- .../Mesh/MeshFeatureProcessorInterface.h | 7 ++ .../Code/Source/Mesh/MeshFeatureProcessor.cpp | 74 +++++++++++++++++-- .../Code/Include/Atom/RPI.Public/Culling.h | 5 ++ .../CommonFeatures/Mesh/MeshComponentBus.h | 6 ++ .../Code/Source/Mesh/EditorMeshComponent.cpp | 7 ++ .../Source/Mesh/MeshComponentController.cpp | 32 ++++++++ .../Source/Mesh/MeshComponentController.h | 7 ++ .../Code/Source/AtomActorInstance.cpp | 20 +++++ .../Code/Source/AtomActorInstance.h | 4 + 10 files changed, 167 insertions(+), 7 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index a2d9517ec4..3cdff52ba7 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -63,8 +63,12 @@ namespace AZ void SetRayTracingData(); void SetSortKey(RHI::DrawItemSortKey sortKey); RHI::DrawItemSortKey GetSortKey(); - void SetLodOverride(RPI::Cullable::LodOverride lodOverride); + void SetLodOverride( RPI::Cullable::LodOverride lodOverride); RPI::Cullable::LodOverride GetLodOverride(); + void SetMinimumScreenCoverage(float minimumScreenCoverage); + float GetMinimumScreenCoverage(); + void SetQualityDecayRate(float qualityDecayRate); + float GetQualityDecayRate(); void UpdateDrawPackets(bool forceUpdate = false); void BuildCullable(); void UpdateCullBounds(const TransformServiceFeatureProcessor* transformService); @@ -158,6 +162,12 @@ namespace AZ void SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) override; RPI::Cullable::LodOverride GetLodOverride(const MeshHandle& meshHandle) override; + void SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) override; + float GetMinimumScreenCoverage(const MeshHandle& meshHandle) override; + + void SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) override; + float GetQualityDecayRate(const MeshHandle& meshHandle) override; + void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) override; void SetRayTracingEnabled(const MeshHandle& meshHandle, bool rayTracingEnabled) override; void SetVisible(const MeshHandle& meshHandle, bool visible) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index 4e74302276..b71b420625 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -98,6 +98,13 @@ namespace AZ virtual void SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) = 0; //! Gets the LOD override for a given mesh handle. virtual RPI::Cullable::LodOverride GetLodOverride(const MeshHandle& meshHandle) = 0; + + virtual void SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) = 0; + virtual float GetMinimumScreenCoverage(const MeshHandle& meshHandle) = 0; + + virtual void SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) = 0; + virtual float GetQualityDecayRate(const MeshHandle& meshHandle) = 0; + //! Sets the option to exclude this mesh from baked reflection probe cubemaps virtual void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) = 0; //! Sets the option to exclude this mesh from raytracing diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index c6362f3a5d..ce8ead9318 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -380,6 +380,48 @@ namespace AZ } } + void MeshFeatureProcessor::SetMinimumScreenCoverage( const MeshHandle& meshHandle, float minimumScreenCoverage) + { + if (meshHandle.IsValid()) + { + meshHandle->SetMinimumScreenCoverage(minimumScreenCoverage); + } + } + + float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) + { + if (meshHandle.IsValid()) + { + return meshHandle->GetMinimumScreenCoverage(); + } + else + { + AZ_Assert(false, "Invalid mesh handle"); + return 0; + } + } + + void MeshFeatureProcessor::SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) + { + if (meshHandle.IsValid()) + { + meshHandle->SetQualityDecayRate(qualityDecayRate); + } + } + + float MeshFeatureProcessor::GetQualityDecayRate(const MeshHandle& meshHandle) + { + if (meshHandle.IsValid()) + { + return meshHandle->GetQualityDecayRate(); + } + else + { + AZ_Assert(false, "Invalid mesh handle"); + return 0; + } + } + void MeshFeatureProcessor::SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) { if (meshHandle.IsValid()) @@ -1001,6 +1043,26 @@ namespace AZ return m_cullable.m_lodData.m_lodOverride; } + void MeshDataInstance::SetMinimumScreenCoverage(float minimumScreenCoverage) + { + m_cullable.m_lodData.m_minimumScreenCoverage = minimumScreenCoverage; + } + + float MeshDataInstance::GetMinimumScreenCoverage() + { + return m_cullable.m_lodData.m_minimumScreenCoverage; + } + + void MeshDataInstance::SetQualityDecayRate(float qualityDecayRate) + { + m_cullable.m_lodData.m_qualityDecayRate = qualityDecayRate; + } + + float MeshDataInstance::GetQualityDecayRate() + { + return m_cullable.m_lodData.m_qualityDecayRate; + } + void MeshDataInstance::UpdateDrawPackets(bool forceUpdate /*= false*/) { AZ_PROFILE_FUNCTION(Debug::ProfileCategory::AzRender); @@ -1036,13 +1098,11 @@ namespace AZ cullData.m_drawListMask.reset(); const size_t lodCount = lodAssets.size(); + for (size_t lodIndex = 0; lodIndex < lodCount; ++lodIndex) { //initialize the lod RPI::Cullable::LodData::Lod& lod = lodData.m_lods[lodIndex]; - //[GFX TODO][ATOM-5562] - Level of detail: override lod distances and add global lod multiplier(s) - static const float MinimumScreenCoverage = 1.0f/1080.0f; //mesh should cover at least a screen pixel at 1080p to be drawn - static const float ReductionFactor = 0.5f; if (lodIndex == 0) { //first lod @@ -1051,17 +1111,19 @@ namespace AZ else { //every other lod: use the previous lod's min - lod.m_screenCoverageMax = AZStd::GetMax(lodData.m_lods[lodIndex-1].m_screenCoverageMin, MinimumScreenCoverage); + lod.m_screenCoverageMax = AZStd::GetMax(lodData.m_lods[lodIndex - 1].m_screenCoverageMin, lodData.m_minimumScreenCoverage); } + if (lodIndex < lodAssets.size() - 1) { //first and middle lods: compute a stepdown value for the min - lod.m_screenCoverageMin = AZStd::GetMax(ReductionFactor * lod.m_screenCoverageMax, MinimumScreenCoverage); + lod.m_screenCoverageMin = + AZStd::GetMax(lodData.m_qualityDecayRate * lod.m_screenCoverageMax, lodData.m_minimumScreenCoverage); } else { //last lod: use MinimumScreenCoverage for the min - lod.m_screenCoverageMin = MinimumScreenCoverage; + lod.m_screenCoverageMin = lodData.m_minimumScreenCoverage; } lod.m_drawPackets.clear(); diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h index bcc4dfb89f..30cf091735 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h @@ -88,6 +88,11 @@ namespace AZ //! Suggest setting to: 0.5f*localAabb.GetExtents().GetMaxElement() float m_lodSelectionRadius = 1.0f; + // the minimum possibe area a sphere enclosing a mesh projected onto the screen should have before it is culled. + float m_minimumScreenCoverage = 1.0f / 1080.0f; + // The screen area decay between 0 and 1, i.e. closer to 1 -> lose quality immediately, closer to 0 -> never lose quality + float m_qualityDecayRate = 0.5f; + LodOverride m_lodOverride = NoLodOverride; }; LodData m_lodData; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h index ff75f7f45a..baef507b7a 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h @@ -39,6 +39,12 @@ namespace AZ virtual void SetLodOverride(RPI::Cullable::LodOverride lodOverride) = 0; virtual RPI::Cullable::LodOverride GetLodOverride() const = 0; + virtual void SetMinimumScreenCoverage(float minimumScreenCoverage) = 0; + virtual float GetMinimumScreenCoverage() const = 0; + + virtual void SetQualityDecayRate(float qualityDecayRate) = 0; + virtual float GetQualityDecayRate() const = 0; + virtual void SetVisibility(bool visible) = 0; virtual bool GetVisibility() const = 0; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index fc62690cc4..bdbf445b7f 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -76,6 +76,13 @@ namespace AZ ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodOverride, "Lod Override", "Allows the rendered LOD to be overridden instead of being calculated automatically.") ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodOverrideValues) ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) + ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") + ->Attribute(AZ::Edit::Attributes::Min, 0.f) + ->Attribute(AZ::Edit::Attributes::Max, 1.f) + ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", + "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") + ->Attribute(AZ::Edit::Attributes::Min, 0.f) + ->Attribute(AZ::Edit::Attributes::Max, 1.f) ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_excludeFromReflectionCubeMaps, "Exclude from reflection cubemaps", "Mesh will not be visible in baked reflection probe cubemaps") ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_useForwardPassIblSpecular, "Use Forward Pass IBL Specular", diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 29bd9a839b..5fde185e4c 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -40,6 +40,8 @@ namespace AZ ->Field("ModelAsset", &MeshComponentConfig::m_modelAsset) ->Field("SortKey", &MeshComponentConfig::m_sortKey) ->Field("LodOverride", &MeshComponentConfig::m_lodOverride) + ->Field("MinimumScreenCoverage", &MeshComponentConfig::m_minimumScreenCoverage) + ->Field("QualityDecayRate", &MeshComponentConfig::m_qualityDecayRate) ->Field("ExcludeFromReflectionCubeMaps", &MeshComponentConfig::m_excludeFromReflectionCubeMaps) ->Field("UseForwardPassIBLSpecular", &MeshComponentConfig::m_useForwardPassIblSpecular); } @@ -116,10 +118,16 @@ namespace AZ ->Event("GetSortKey", &MeshComponentRequestBus::Events::GetSortKey) ->Event("SetLodOverride", &MeshComponentRequestBus::Events::SetLodOverride) ->Event("GetLodOverride", &MeshComponentRequestBus::Events::GetLodOverride) + ->Event("SetMinimumScreenCoverage", &MeshComponentRequestBus::Events::SetMinimumScreenCoverage) + ->Event("GetMinimumScreenCoverage", &MeshComponentRequestBus::Events::GetMinimumScreenCoverage) + ->Event("SetQualityDecayRate", &MeshComponentRequestBus::Events::SetQualityDecayRate) + ->Event("GetQualityDecayRate", &MeshComponentRequestBus::Events::GetQualityDecayRate) ->VirtualProperty("ModelAssetId", "GetModelAssetId", "SetModelAssetId") ->VirtualProperty("ModelAssetPath", "GetModelAssetPath", "SetModelAssetPath") ->VirtualProperty("SortKey", "GetSortKey", "SetSortKey") ->VirtualProperty("LodOverride", "GetLodOverride", "SetLodOverride") + ->VirtualProperty("MinimumScreenCoverage", "GetMinimumScreenCoverage", "SetMinimumScreenCoverage") + ->VirtualProperty("QualityDecayRate", "GetQualityDecayRate", "SetQualityDecayRate") ; } } @@ -325,6 +333,8 @@ namespace AZ m_meshFeatureProcessor->SetTransform(m_meshHandle, transform, m_cachedNonUniformScale); m_meshFeatureProcessor->SetSortKey(m_meshHandle, m_configuration.m_sortKey); m_meshFeatureProcessor->SetLodOverride(m_meshHandle, m_configuration.m_lodOverride); + m_meshFeatureProcessor->SetMinimumScreenCoverage(m_meshHandle, m_configuration.m_minimumScreenCoverage); + m_meshFeatureProcessor->SetQualityDecayRate(m_meshHandle, m_configuration.m_qualityDecayRate); m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_meshHandle, m_configuration.m_excludeFromReflectionCubeMaps); m_meshFeatureProcessor->SetVisible(m_meshHandle, m_isVisible); @@ -426,6 +436,28 @@ namespace AZ return m_meshFeatureProcessor->GetSortKey(m_meshHandle); } + void MeshComponentController::SetMinimumScreenCoverage(float minimumScreenCoverage) + { + m_configuration.m_minimumScreenCoverage = minimumScreenCoverage; + m_meshFeatureProcessor->SetMinimumScreenCoverage(m_meshHandle, minimumScreenCoverage); + } + + float MeshComponentController::GetMinimumScreenCoverage() const + { + return m_meshFeatureProcessor->GetMinimumScreenCoverage(m_meshHandle); + } + + void MeshComponentController::SetQualityDecayRate(float qualityDecayRate) + { + m_configuration.m_qualityDecayRate = qualityDecayRate; + m_meshFeatureProcessor->SetQualityDecayRate(m_meshHandle, qualityDecayRate); + } + + float MeshComponentController::GetQualityDecayRate() const + { + return m_meshFeatureProcessor->GetQualityDecayRate(m_meshHandle); + } + void MeshComponentController::SetVisibility(bool visible) { if (m_isVisible != visible) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 80b483452f..f94771b3e5 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -46,6 +46,8 @@ namespace AZ Data::Asset m_modelAsset = { AZ::Data::AssetLoadBehavior::QueueLoad }; RHI::DrawItemSortKey m_sortKey = 0; RPI::Cullable::LodOverride m_lodOverride = RPI::Cullable::NoLodOverride; + float m_minimumScreenCoverage = 1.0f / 1080.0f; + float m_qualityDecayRate = 0.5f; bool m_excludeFromReflectionCubeMaps = false; bool m_useForwardPassIblSpecular = false; }; @@ -97,6 +99,11 @@ namespace AZ void SetLodOverride(RPI::Cullable::LodOverride lodOverride) override; RPI::Cullable::LodOverride GetLodOverride() const override; + void SetMinimumScreenCoverage(float minimumScreenCoverage) override; + float GetMinimumScreenCoverage() const override; + void SetQualityDecayRate(float qualityDecayRate) override; + float GetQualityDecayRate() const override; + void SetVisibility(bool visible) override; bool GetVisibility() const override; diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp index 4c6045d7ce..63912aa8a6 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp @@ -415,6 +415,26 @@ namespace AZ return m_meshFeatureProcessor->GetLodOverride(*m_meshHandle); } + void AtomActorInstance::SetMinimumScreenCoverage(float minimumScreenCoverage) + { + m_meshFeatureProcessor->SetMinimumScreenCoverage(*m_meshHandle, minimumScreenCoverage); + } + + float AtomActorInstance::GetMinimumScreenCoverage() const + { + return m_meshFeatureProcessor->GetMinimumScreenCoverage(*m_meshHandle); + } + + void AtomActorInstance::SetQualityDecayRate(float qualityDecayRate) + { + m_meshFeatureProcessor->SetQualityDecayRate(*m_meshHandle, qualityDecayRate); + } + + float AtomActorInstance::GetQualityDecayRate() const + { + return m_meshFeatureProcessor->GetQualityDecayRate(*m_meshHandle); + } + void AtomActorInstance::SetVisibility(bool visible) { SetIsVisible(visible); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h index c854fed3c1..bd9afc668e 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h @@ -140,6 +140,10 @@ namespace AZ RHI::DrawItemSortKey GetSortKey() const override; void SetLodOverride(RPI::Cullable::LodOverride lodOverride) override; RPI::Cullable::LodOverride GetLodOverride() const override; + void SetMinimumScreenCoverage(float minimumScreenCoverage) override; + float GetMinimumScreenCoverage() const override; + void SetQualityDecayRate(float qualityDecayRate) override; + float GetQualityDecayRate() const override; void SetVisibility(bool visible) override; bool GetVisibility() const override; // GetWorldBounds/GetLocalBounds already overridden by BoundsRequestBus::Handler From 1a48118ece6816993409a08a90a0f2161b2229de Mon Sep 17 00:00:00 2001 From: Kyle B Date: Mon, 2 Aug 2021 14:01:38 -0700 Subject: [PATCH 02/17] Added comments and formatted as close to the original Signed-off-by: Kyle B --- .../Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h | 2 +- .../Atom/Feature/Mesh/MeshFeatureProcessorInterface.h | 7 ++++--- .../Common/Code/Source/Mesh/MeshFeatureProcessor.cpp | 4 +--- .../Code/Source/Mesh/EditorMeshComponent.cpp | 1 + .../Code/Source/Mesh/MeshComponentController.h | 1 + 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index 3cdff52ba7..e7e794c76e 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -63,7 +63,7 @@ namespace AZ void SetRayTracingData(); void SetSortKey(RHI::DrawItemSortKey sortKey); RHI::DrawItemSortKey GetSortKey(); - void SetLodOverride( RPI::Cullable::LodOverride lodOverride); + void SetLodOverride(RPI::Cullable::LodOverride lodOverride); RPI::Cullable::LodOverride GetLodOverride(); void SetMinimumScreenCoverage(float minimumScreenCoverage); float GetMinimumScreenCoverage(); diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index b71b420625..dd64472161 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -98,13 +98,14 @@ namespace AZ virtual void SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) = 0; //! Gets the LOD override for a given mesh handle. virtual RPI::Cullable::LodOverride GetLodOverride(const MeshHandle& meshHandle) = 0; - + //! Sets the minimum screen percentage for a given mesh handle. This property is the minimum screen percentage the object can take up before culled. virtual void SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) = 0; + //! Gets the minimum screen percentage for a given mesh handle. virtual float GetMinimumScreenCoverage(const MeshHandle& meshHandle) = 0; - + //! Sets the quality decay rate. This property is the speed at which the quality of the mesh with degrade if you are linearly moving away. virtual void SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) = 0; + //! Gets the quality decay rate. virtual float GetQualityDecayRate(const MeshHandle& meshHandle) = 0; - //! Sets the option to exclude this mesh from baked reflection probe cubemaps virtual void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) = 0; //! Sets the option to exclude this mesh from raytracing diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index ce8ead9318..7d1d7ed851 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -1098,7 +1098,6 @@ namespace AZ cullData.m_drawListMask.reset(); const size_t lodCount = lodAssets.size(); - for (size_t lodIndex = 0; lodIndex < lodCount; ++lodIndex) { //initialize the lod @@ -1117,8 +1116,7 @@ namespace AZ if (lodIndex < lodAssets.size() - 1) { //first and middle lods: compute a stepdown value for the min - lod.m_screenCoverageMin = - AZStd::GetMax(lodData.m_qualityDecayRate * lod.m_screenCoverageMax, lodData.m_minimumScreenCoverage); + lod.m_screenCoverageMin = AZStd::GetMax(lodData.m_qualityDecayRate * lod.m_screenCoverageMax, lodData.m_minimumScreenCoverage); } else { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index bdbf445b7f..d46017af16 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -79,6 +79,7 @@ namespace AZ ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") ->Attribute(AZ::Edit::Attributes::Min, 0.f) ->Attribute(AZ::Edit::Attributes::Max, 1.f) + ->Attribute(AZ::Edit::Attributes::Suffix, " percent") ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") ->Attribute(AZ::Edit::Attributes::Min, 0.f) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index f94771b3e5..888d4bb154 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -101,6 +101,7 @@ namespace AZ void SetMinimumScreenCoverage(float minimumScreenCoverage) override; float GetMinimumScreenCoverage() const override; + void SetQualityDecayRate(float qualityDecayRate) override; float GetQualityDecayRate() const override; From 3db93a564d1a7b5e8c7b87eccb56ce6009a4dd47 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Tue, 3 Aug 2021 18:28:55 -0700 Subject: [PATCH 03/17] Made formatting changes per pull comments, incuding adding comments, changing spacing, and changing the ui type of component fields Signed-off-by: Kyle B --- .../Include/Atom/Feature/Mesh/MeshFeatureProcessor.h | 8 ++++---- .../Common/Code/Source/Mesh/MeshFeatureProcessor.cpp | 12 ++++++------ Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h | 2 +- .../Code/Source/Mesh/EditorMeshComponent.cpp | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index e7e794c76e..08f2dde474 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -62,13 +62,13 @@ namespace AZ void BuildDrawPacketList(size_t modelLodIndex); void SetRayTracingData(); void SetSortKey(RHI::DrawItemSortKey sortKey); - RHI::DrawItemSortKey GetSortKey(); + RHI::DrawItemSortKey GetSortKey() const; void SetLodOverride(RPI::Cullable::LodOverride lodOverride); - RPI::Cullable::LodOverride GetLodOverride(); + RPI::Cullable::LodOverride GetLodOverride() const; void SetMinimumScreenCoverage(float minimumScreenCoverage); - float GetMinimumScreenCoverage(); + float GetMinimumScreenCoverage() const; void SetQualityDecayRate(float qualityDecayRate); - float GetQualityDecayRate(); + float GetQualityDecayRate() const; void UpdateDrawPackets(bool forceUpdate = false); void BuildCullable(); void UpdateCullBounds(const TransformServiceFeatureProcessor* transformService); diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 7d1d7ed851..286724b06a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -380,7 +380,7 @@ namespace AZ } } - void MeshFeatureProcessor::SetMinimumScreenCoverage( const MeshHandle& meshHandle, float minimumScreenCoverage) + void MeshFeatureProcessor::SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) { if (meshHandle.IsValid()) { @@ -388,7 +388,7 @@ namespace AZ } } - float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) + float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) const { if (meshHandle.IsValid()) { @@ -1028,7 +1028,7 @@ namespace AZ } } - RHI::DrawItemSortKey MeshDataInstance::GetSortKey() + RHI::DrawItemSortKey MeshDataInstance::GetSortKey() const { return m_sortKey; } @@ -1038,7 +1038,7 @@ namespace AZ m_cullable.m_lodData.m_lodOverride = lodOverride; } - RPI::Cullable::LodOverride MeshDataInstance::GetLodOverride() + RPI::Cullable::LodOverride MeshDataInstance::GetLodOverride() const { return m_cullable.m_lodData.m_lodOverride; } @@ -1048,7 +1048,7 @@ namespace AZ m_cullable.m_lodData.m_minimumScreenCoverage = minimumScreenCoverage; } - float MeshDataInstance::GetMinimumScreenCoverage() + float MeshDataInstance::GetMinimumScreenCoverage() const { return m_cullable.m_lodData.m_minimumScreenCoverage; } @@ -1058,7 +1058,7 @@ namespace AZ m_cullable.m_lodData.m_qualityDecayRate = qualityDecayRate; } - float MeshDataInstance::GetQualityDecayRate() + float MeshDataInstance::GetQualityDecayRate() const { return m_cullable.m_lodData.m_qualityDecayRate; } diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h index 30cf091735..4a39a21e0b 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h @@ -89,7 +89,7 @@ namespace AZ float m_lodSelectionRadius = 1.0f; // the minimum possibe area a sphere enclosing a mesh projected onto the screen should have before it is culled. - float m_minimumScreenCoverage = 1.0f / 1080.0f; + float m_minimumScreenCoverage = 1.0f / 1080.0f; //For default, mesh should cover at least a screen pixel at 1080p to be drawn // The screen area decay between 0 and 1, i.e. closer to 1 -> lose quality immediately, closer to 0 -> never lose quality float m_qualityDecayRate = 0.5f; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index d46017af16..3308767de9 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -76,11 +76,11 @@ namespace AZ ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodOverride, "Lod Override", "Allows the rendered LOD to be overridden instead of being calculated automatically.") ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodOverrideValues) ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) - ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") + ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") ->Attribute(AZ::Edit::Attributes::Min, 0.f) ->Attribute(AZ::Edit::Attributes::Max, 1.f) ->Attribute(AZ::Edit::Attributes::Suffix, " percent") - ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", + ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") ->Attribute(AZ::Edit::Attributes::Min, 0.f) ->Attribute(AZ::Edit::Attributes::Max, 1.f) From 9c5c2e7de651c2d4c643ec2859ee763af5cc063b Mon Sep 17 00:00:00 2001 From: Kyle B Date: Tue, 3 Aug 2021 19:34:17 -0700 Subject: [PATCH 04/17] un-did const on function that did not need it Signed-off-by: Kyle B --- .../Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 286724b06a..166c5610b1 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -388,7 +388,7 @@ namespace AZ } } - float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) const + float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) { if (meshHandle.IsValid()) { From baab204c0bf79a7932ad5ddbb57931e68c47802c Mon Sep 17 00:00:00 2001 From: Kyle B Date: Thu, 5 Aug 2021 00:07:54 -0700 Subject: [PATCH 05/17] updated Mock with new interface values Signed-off-by: Kyle B --- .../Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 72e547fc1b..0eea0df514 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -32,9 +32,13 @@ namespace UnitTest MOCK_METHOD2(SetLocalAabb, void(const MeshHandle&, const AZ::Aabb&)); MOCK_CONST_METHOD1(GetLocalAabb, AZ::Aabb(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); - MOCK_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); + MOCK_CONST_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); MOCK_METHOD2(SetLodOverride, void(const MeshHandle&, AZ::RPI::Cullable::LodOverride)); - MOCK_METHOD1(GetLodOverride, AZ::RPI::Cullable::LodOverride(const MeshHandle&)); + MOCK_CONST_METHOD1(GetLodOverride, AZ::RPI::Cullable::LodOverride(const MeshHandle&)); + MOCK_METHOD2(SetMinimumScreenCoverage, void(const MeshHandle&, float)); + MOCK_CONST_METHOD1(GetMinimumScreenCoverage, float(const MeshHandle&)); + MOCK_METHOD2(SetQualityDecayRate, void(const MeshHandle&, float)); + MOCK_CONST_METHOD1(GetQualityDecayRate, float(const MeshHandle&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance&)); MOCK_METHOD2(SetRayTracingEnabled, void (const MeshHandle&, bool)); From 51271fa15bec613f96c269d0cf1487e9ed524876 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Fri, 6 Aug 2021 16:57:00 -0700 Subject: [PATCH 06/17] Created group for Lod component data Signed-off-by: Kyle B --- .../Atom/Feature/Mesh/MeshFeatureProcessor.h | 18 +--- .../Mesh/MeshFeatureProcessorInterface.h | 16 +--- .../Code/Mocks/MockMeshFeatureProcessor.h | 8 +- .../Code/Source/Mesh/MeshFeatureProcessor.cpp | 86 +++---------------- .../Code/Include/Atom/RPI.Public/Culling.h | 16 +++- .../RPI/Code/Source/RPI.Public/Culling.cpp | 6 +- .../CommonFeatures/Mesh/MeshComponentBus.h | 3 + .../Code/Source/Mesh/EditorMeshComponent.cpp | 40 +++++---- .../Source/Mesh/MeshComponentController.cpp | 73 ++++++++++++---- .../Source/Mesh/MeshComponentController.h | 29 +++++-- .../Code/Source/AtomActorInstance.cpp | 30 +++++-- .../Code/Source/AtomActorInstance.h | 2 + 12 files changed, 167 insertions(+), 160 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index 08f2dde474..daf4a493c2 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -63,12 +63,8 @@ namespace AZ void SetRayTracingData(); void SetSortKey(RHI::DrawItemSortKey sortKey); RHI::DrawItemSortKey GetSortKey() const; - void SetLodOverride(RPI::Cullable::LodOverride lodOverride); - RPI::Cullable::LodOverride GetLodOverride() const; - void SetMinimumScreenCoverage(float minimumScreenCoverage); - float GetMinimumScreenCoverage() const; - void SetQualityDecayRate(float qualityDecayRate); - float GetQualityDecayRate() const; + void SetMeshLodConfiguration(RPI::Cullable::LodConfiguration meshLodConfig); + RPI::Cullable::LodConfiguration GetMeshLodConfiguration() const; void UpdateDrawPackets(bool forceUpdate = false); void BuildCullable(); void UpdateCullBounds(const TransformServiceFeatureProcessor* transformService); @@ -159,14 +155,8 @@ namespace AZ void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override; - void SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) override; - RPI::Cullable::LodOverride GetLodOverride(const MeshHandle& meshHandle) override; - - void SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) override; - float GetMinimumScreenCoverage(const MeshHandle& meshHandle) override; - - void SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) override; - float GetQualityDecayRate(const MeshHandle& meshHandle) override; + void SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig); + RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const; void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) override; void SetRayTracingEnabled(const MeshHandle& meshHandle, bool rayTracingEnabled) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index dd64472161..8c7a200ff5 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -94,18 +94,10 @@ namespace AZ virtual void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) = 0; //! Gets the sort key for a given mesh handle. virtual RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) = 0; - //! Sets an LOD override for a given mesh handle. This LOD will always be rendered instead being automatically determined. - virtual void SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) = 0; - //! Gets the LOD override for a given mesh handle. - virtual RPI::Cullable::LodOverride GetLodOverride(const MeshHandle& meshHandle) = 0; - //! Sets the minimum screen percentage for a given mesh handle. This property is the minimum screen percentage the object can take up before culled. - virtual void SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) = 0; - //! Gets the minimum screen percentage for a given mesh handle. - virtual float GetMinimumScreenCoverage(const MeshHandle& meshHandle) = 0; - //! Sets the quality decay rate. This property is the speed at which the quality of the mesh with degrade if you are linearly moving away. - virtual void SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) = 0; - //! Gets the quality decay rate. - virtual float GetQualityDecayRate(const MeshHandle& meshHandle) = 0; + //! Sets LOD mesh configurations to be used in the Mesh Feature Processor + virtual void SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig) = 0; + //! Gets the LOD mesh configurations being used in the Mesh Feature Processor + virtual RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const = 0; //! Sets the option to exclude this mesh from baked reflection probe cubemaps virtual void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) = 0; //! Sets the option to exclude this mesh from raytracing diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 0eea0df514..0c03e767e7 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -33,12 +33,8 @@ namespace UnitTest MOCK_CONST_METHOD1(GetLocalAabb, AZ::Aabb(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_CONST_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); - MOCK_METHOD2(SetLodOverride, void(const MeshHandle&, AZ::RPI::Cullable::LodOverride)); - MOCK_CONST_METHOD1(GetLodOverride, AZ::RPI::Cullable::LodOverride(const MeshHandle&)); - MOCK_METHOD2(SetMinimumScreenCoverage, void(const MeshHandle&, float)); - MOCK_CONST_METHOD1(GetMinimumScreenCoverage, float(const MeshHandle&)); - MOCK_METHOD2(SetQualityDecayRate, void(const MeshHandle&, float)); - MOCK_CONST_METHOD1(GetQualityDecayRate, float(const MeshHandle&)); + MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, RPI::Cullable::LodConfiguration)); + MOCK_CONST_METHOD1(GetMeshLodConfiguration, RPI::Cullable::LodConfiguration(const MeshHandle&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance&)); MOCK_METHOD2(SetRayTracingEnabled, void (const MeshHandle&, bool)); diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 166c5610b1..679e64e283 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -359,66 +359,24 @@ namespace AZ } } - void MeshFeatureProcessor::SetLodOverride(const MeshHandle& meshHandle, RPI::Cullable::LodOverride lodOverride) + void MeshFeatureProcessor::SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig) { if (meshHandle.IsValid()) { - meshHandle->SetLodOverride(lodOverride); + meshHandle->SetMeshLodConfiguration(meshLodConfig); } } - RPI::Cullable::LodOverride MeshFeatureProcessor::GetLodOverride(const MeshHandle& meshHandle) + RPI::Cullable::LodConfiguration MeshFeatureProcessor::GetMeshLodConfiguration(const MeshHandle& meshHandle) const { if (meshHandle.IsValid()) { - return meshHandle->GetLodOverride(); + return meshHandle->GetMeshLodConfiguration(); } else { AZ_Assert(false, "Invalid mesh handle"); - return 0; - } - } - - void MeshFeatureProcessor::SetMinimumScreenCoverage(const MeshHandle& meshHandle, float minimumScreenCoverage) - { - if (meshHandle.IsValid()) - { - meshHandle->SetMinimumScreenCoverage(minimumScreenCoverage); - } - } - - float MeshFeatureProcessor::GetMinimumScreenCoverage(const MeshHandle& meshHandle) - { - if (meshHandle.IsValid()) - { - return meshHandle->GetMinimumScreenCoverage(); - } - else - { - AZ_Assert(false, "Invalid mesh handle"); - return 0; - } - } - - void MeshFeatureProcessor::SetQualityDecayRate(const MeshHandle& meshHandle, float qualityDecayRate) - { - if (meshHandle.IsValid()) - { - meshHandle->SetQualityDecayRate(qualityDecayRate); - } - } - - float MeshFeatureProcessor::GetQualityDecayRate(const MeshHandle& meshHandle) - { - if (meshHandle.IsValid()) - { - return meshHandle->GetQualityDecayRate(); - } - else - { - AZ_Assert(false, "Invalid mesh handle"); - return 0; + return {0,0,0.0f,0.0f}; } } @@ -1033,34 +991,14 @@ namespace AZ return m_sortKey; } - void MeshDataInstance::SetLodOverride(RPI::Cullable::LodOverride lodOverride) + void MeshDataInstance::SetMeshLodConfiguration(RPI::Cullable::LodConfiguration meshLodConfig) { - m_cullable.m_lodData.m_lodOverride = lodOverride; + m_cullable.m_lodData.m_lodConfiguration = meshLodConfig; } - RPI::Cullable::LodOverride MeshDataInstance::GetLodOverride() const + RPI::Cullable::LodConfiguration MeshDataInstance::GetMeshLodConfiguration() const { - return m_cullable.m_lodData.m_lodOverride; - } - - void MeshDataInstance::SetMinimumScreenCoverage(float minimumScreenCoverage) - { - m_cullable.m_lodData.m_minimumScreenCoverage = minimumScreenCoverage; - } - - float MeshDataInstance::GetMinimumScreenCoverage() const - { - return m_cullable.m_lodData.m_minimumScreenCoverage; - } - - void MeshDataInstance::SetQualityDecayRate(float qualityDecayRate) - { - m_cullable.m_lodData.m_qualityDecayRate = qualityDecayRate; - } - - float MeshDataInstance::GetQualityDecayRate() const - { - return m_cullable.m_lodData.m_qualityDecayRate; + return m_cullable.m_lodData.m_lodConfiguration; } void MeshDataInstance::UpdateDrawPackets(bool forceUpdate /*= false*/) @@ -1110,18 +1048,18 @@ namespace AZ else { //every other lod: use the previous lod's min - lod.m_screenCoverageMax = AZStd::GetMax(lodData.m_lods[lodIndex - 1].m_screenCoverageMin, lodData.m_minimumScreenCoverage); + lod.m_screenCoverageMax = AZStd::GetMax(lodData.m_lods[lodIndex - 1].m_screenCoverageMin, lodData.m_lodConfiguration.m_minimumScreenCoverage); } if (lodIndex < lodAssets.size() - 1) { //first and middle lods: compute a stepdown value for the min - lod.m_screenCoverageMin = AZStd::GetMax(lodData.m_qualityDecayRate * lod.m_screenCoverageMax, lodData.m_minimumScreenCoverage); + lod.m_screenCoverageMin = AZStd::GetMax(lodData.m_lodConfiguration.m_qualityDecayRate * lod.m_screenCoverageMax, lodData.m_lodConfiguration.m_minimumScreenCoverage); } else { //last lod: use MinimumScreenCoverage for the min - lod.m_screenCoverageMin = lodData.m_minimumScreenCoverage; + lod.m_screenCoverageMin = lodData.m_lodConfiguration.m_minimumScreenCoverage; } lod.m_drawPackets.clear(); diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h index 4a39a21e0b..e89e180540 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h @@ -70,8 +70,18 @@ namespace AZ }; CullData m_cullData; + using LodType = uint8_t; using LodOverride = uint8_t; static constexpr uint8_t NoLodOverride = AZStd::numeric_limits::max(); + static constexpr uint8_t DefaultLodType = AZStd::numeric_limits::max(); + + struct LodConfiguration + { + LodType m_lodType; + LodOverride m_lodOverride; + float m_minimumScreenCoverage; + float m_qualityDecayRate; + }; struct LodData { @@ -89,11 +99,11 @@ namespace AZ float m_lodSelectionRadius = 1.0f; // the minimum possibe area a sphere enclosing a mesh projected onto the screen should have before it is culled. - float m_minimumScreenCoverage = 1.0f / 1080.0f; //For default, mesh should cover at least a screen pixel at 1080p to be drawn + static constexpr float DefaultMinimumScreenCoverage = 1.0f / 1080.0f; //For default, mesh should cover at least a screen pixel at 1080p to be drawn // The screen area decay between 0 and 1, i.e. closer to 1 -> lose quality immediately, closer to 0 -> never lose quality - float m_qualityDecayRate = 0.5f; + static constexpr float DefaultQualityDecayRate = 0.5f; - LodOverride m_lodOverride = NoLodOverride; + LodConfiguration m_lodConfiguration = { DefaultLodType, NoLodOverride, DefaultMinimumScreenCoverage, DefaultQualityDecayRate }; }; LodData m_lodData; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp index e192e71fc4..f22d5c7224 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp @@ -672,7 +672,7 @@ namespace AZ } }; - if (lodData.m_lodOverride == Cullable::NoLodOverride) + if (lodData.m_lodConfiguration.m_lodOverride == Cullable::NoLodOverride) { for (const Cullable::LodData::Lod& lod : lodData.m_lods) { @@ -683,9 +683,9 @@ namespace AZ } } } - else if(lodData.m_lodOverride < lodData.m_lods.size()) + else if(lodData.m_lodConfiguration.m_lodOverride < lodData.m_lods.size()) { - addLodToDrawPacket(lodData.m_lods.at(lodData.m_lodOverride)); + addLodToDrawPacket(lodData.m_lods.at(lodData.m_lodConfiguration.m_lodOverride)); } return numVisibleDrawPackets; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h index baef507b7a..cc9c78d356 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Include/AtomLyIntegration/CommonFeatures/Mesh/MeshComponentBus.h @@ -36,6 +36,9 @@ namespace AZ virtual void SetSortKey(RHI::DrawItemSortKey sortKey) = 0; virtual RHI::DrawItemSortKey GetSortKey() const = 0; + virtual void SetLodType(RPI::Cullable::LodType lodType) = 0; + virtual RPI::Cullable::LodType GetLodType() const = 0; + virtual void SetLodOverride(RPI::Cullable::LodOverride lodOverride) = 0; virtual RPI::Cullable::LodOverride GetLodOverride() const = 0; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index 3308767de9..0719d9f2bb 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -71,24 +71,28 @@ namespace AZ "MeshComponentConfig", "") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_modelAsset, "Mesh Asset", "Mesh asset reference") - ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_sortKey, "Sort Key", "Transparent meshes are drawn by sort key then depth. Used this to force certain transparent meshes to draw before or after others.") - ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodOverride, "Lod Override", "Allows the rendered LOD to be overridden instead of being calculated automatically.") - ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodOverrideValues) - ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) - ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") - ->Attribute(AZ::Edit::Attributes::Min, 0.f) - ->Attribute(AZ::Edit::Attributes::Max, 1.f) - ->Attribute(AZ::Edit::Attributes::Suffix, " percent") - ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", - "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") - ->Attribute(AZ::Edit::Attributes::Min, 0.f) - ->Attribute(AZ::Edit::Attributes::Max, 1.f) - ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_excludeFromReflectionCubeMaps, "Exclude from reflection cubemaps", "Mesh will not be visible in baked reflection probe cubemaps") - ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) - ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_useForwardPassIblSpecular, "Use Forward Pass IBL Specular", - "Renders IBL specular reflections in the forward pass, using only the most influential probe (based on the position of the entity) and the global IBL cubemap. Can reduce rendering costs, but only recommended for static objects that are affected by at most one reflection probe.") - ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) + ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_modelAsset, "Mesh Asset", "Mesh asset reference") + ->DataElement(AZ::Edit::UIHandlers::Default, &MeshComponentConfig::m_sortKey, "Sort Key", "Transparent meshes are drawn by sort key then depth. Used this to force certain transparent meshes to draw before or after others.") + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) + ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_excludeFromReflectionCubeMaps, "Exclude from reflection cubemaps", "Mesh will not be visible in baked reflection probe cubemaps") + ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) + ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_useForwardPassIblSpecular, "Use Forward Pass IBL Specular", + "Renders IBL specular reflections in the forward pass, using only the most influential probe (based on the position of the entity) and the global IBL cubemap. Can reduce rendering costs, but only recommended for static objects that are affected by at most one reflection probe.") + ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) + ->ClassElement(AZ::Edit::ClassElements::Group, "Lod Configuration") + ->Attribute(AZ::Edit::Attributes::AutoExpand, false) + ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodType, "Lod Type", "Lod Method.") + ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodTypeValues) + ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodOverride, "Lod Override", "Allows the rendered LOD to be overridden instead of being calculated automatically.") + ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodOverrideValues) + ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") + ->Attribute(AZ::Edit::Attributes::Min, 0.f) + ->Attribute(AZ::Edit::Attributes::Max, 1.f) + ->Attribute(AZ::Edit::Attributes::Suffix, " percent") + ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", + "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") + ->Attribute(AZ::Edit::Attributes::Min, 0.f) + ->Attribute(AZ::Edit::Attributes::Max, 1.f) ; } } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 5fde185e4c..adcf570899 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -39,11 +39,12 @@ namespace AZ ->Version(1) ->Field("ModelAsset", &MeshComponentConfig::m_modelAsset) ->Field("SortKey", &MeshComponentConfig::m_sortKey) + ->Field("ExcludeFromReflectionCubeMaps", &MeshComponentConfig::m_excludeFromReflectionCubeMaps) + ->Field("UseForwardPassIBLSpecular", &MeshComponentConfig::m_useForwardPassIblSpecular) + ->Field("LodType", &MeshComponentConfig::m_lodType) ->Field("LodOverride", &MeshComponentConfig::m_lodOverride) ->Field("MinimumScreenCoverage", &MeshComponentConfig::m_minimumScreenCoverage) - ->Field("QualityDecayRate", &MeshComponentConfig::m_qualityDecayRate) - ->Field("ExcludeFromReflectionCubeMaps", &MeshComponentConfig::m_excludeFromReflectionCubeMaps) - ->Field("UseForwardPassIBLSpecular", &MeshComponentConfig::m_useForwardPassIblSpecular); + ->Field("QualityDecayRate", &MeshComponentConfig::m_qualityDecayRate); } } @@ -85,6 +86,13 @@ namespace AZ return values; } + AZStd::vector> MeshComponentConfig::GetLodTypeValues() + { + return { + {RPI::Cullable::DefaultLodType, "Default"} + }; + } + MeshComponentController::~MeshComponentController() { // Release memory, disconnect from buses in the right order and broadcast events so that other components are aware. @@ -109,6 +117,11 @@ namespace AZ ->Attribute(AZ::Script::Attributes::Category, "render") ->Attribute(AZ::Script::Attributes::Module, "render"); + behaviorContext->ConstantProperty("DefaultLodType", BehaviorConstant(RPI::Cullable::DefaultLodType)) + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Category, "render") + ->Attribute(AZ::Script::Attributes::Module, "render"); + behaviorContext->EBus("RenderMeshComponentRequestBus") ->Event("GetModelAssetId", &MeshComponentRequestBus::Events::GetModelAssetId) ->Event("SetModelAssetId", &MeshComponentRequestBus::Events::SetModelAssetId) @@ -116,6 +129,8 @@ namespace AZ ->Event("SetModelAssetPath", &MeshComponentRequestBus::Events::SetModelAssetPath) ->Event("SetSortKey", &MeshComponentRequestBus::Events::SetSortKey) ->Event("GetSortKey", &MeshComponentRequestBus::Events::GetSortKey) + ->Event("SetLodType", &MeshComponentRequestBus::Events::SetLodType) + ->Event("GetLodType", &MeshComponentRequestBus::Events::GetLodType) ->Event("SetLodOverride", &MeshComponentRequestBus::Events::SetLodOverride) ->Event("GetLodOverride", &MeshComponentRequestBus::Events::GetLodOverride) ->Event("SetMinimumScreenCoverage", &MeshComponentRequestBus::Events::SetMinimumScreenCoverage) @@ -125,6 +140,7 @@ namespace AZ ->VirtualProperty("ModelAssetId", "GetModelAssetId", "SetModelAssetId") ->VirtualProperty("ModelAssetPath", "GetModelAssetPath", "SetModelAssetPath") ->VirtualProperty("SortKey", "GetSortKey", "SetSortKey") + ->VirtualProperty("LodType", "GetLodType", "SetLodType") ->VirtualProperty("LodOverride", "GetLodOverride", "SetLodOverride") ->VirtualProperty("MinimumScreenCoverage", "GetMinimumScreenCoverage", "SetMinimumScreenCoverage") ->VirtualProperty("QualityDecayRate", "GetQualityDecayRate", "SetQualityDecayRate") @@ -332,9 +348,7 @@ namespace AZ m_meshFeatureProcessor->SetTransform(m_meshHandle, transform, m_cachedNonUniformScale); m_meshFeatureProcessor->SetSortKey(m_meshHandle, m_configuration.m_sortKey); - m_meshFeatureProcessor->SetLodOverride(m_meshHandle, m_configuration.m_lodOverride); - m_meshFeatureProcessor->SetMinimumScreenCoverage(m_meshHandle, m_configuration.m_minimumScreenCoverage); - m_meshFeatureProcessor->SetQualityDecayRate(m_meshHandle, m_configuration.m_qualityDecayRate); + m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, GetMeshLodConfiguration()); m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_meshHandle, m_configuration.m_excludeFromReflectionCubeMaps); m_meshFeatureProcessor->SetVisible(m_meshHandle, m_isVisible); @@ -425,37 +439,66 @@ namespace AZ return m_meshFeatureProcessor->GetSortKey(m_meshHandle); } + RPI::Cullable::LodConfiguration MeshComponentController::GetMeshLodConfiguration() const + { + return { + m_configuration.m_lodType, + m_configuration.m_lodOverride, + m_configuration.m_minimumScreenCoverage, + m_configuration.m_qualityDecayRate + }; + } + // ----------------------- + void MeshComponentController::SetLodType(RPI::Cullable::LodType lodType) + { + RPI::Cullable::LodConfiguration lodConfig = GetMeshLodConfiguration(); + lodConfig.m_lodType = lodType; + m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, lodConfig); + } + + RPI::Cullable::LodType MeshComponentController::GetLodType() const + { + RPI::Cullable::LodConfiguration lodConfig = m_meshFeatureProcessor->GetMeshLodConfiguration(m_meshHandle); + return lodConfig.m_lodType; + } + void MeshComponentController::SetLodOverride(RPI::Cullable::LodOverride lodOverride) { - m_configuration.m_lodOverride = lodOverride; // Save for serialization - m_meshFeatureProcessor->SetLodOverride(m_meshHandle, lodOverride); + RPI::Cullable::LodConfiguration lodConfig = GetMeshLodConfiguration(); + lodConfig.m_lodOverride = lodOverride; + m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, lodConfig); } RPI::Cullable::LodOverride MeshComponentController::GetLodOverride() const { - return m_meshFeatureProcessor->GetSortKey(m_meshHandle); + RPI::Cullable::LodConfiguration lodConfig = m_meshFeatureProcessor->GetMeshLodConfiguration(m_meshHandle); + return lodConfig.m_lodOverride; } void MeshComponentController::SetMinimumScreenCoverage(float minimumScreenCoverage) { - m_configuration.m_minimumScreenCoverage = minimumScreenCoverage; - m_meshFeatureProcessor->SetMinimumScreenCoverage(m_meshHandle, minimumScreenCoverage); + RPI::Cullable::LodConfiguration lodConfig = GetMeshLodConfiguration(); + lodConfig.m_minimumScreenCoverage = minimumScreenCoverage; + m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, lodConfig); } float MeshComponentController::GetMinimumScreenCoverage() const { - return m_meshFeatureProcessor->GetMinimumScreenCoverage(m_meshHandle); + RPI::Cullable::LodConfiguration lodConfig = m_meshFeatureProcessor->GetMeshLodConfiguration(m_meshHandle); + return lodConfig.m_minimumScreenCoverage; } void MeshComponentController::SetQualityDecayRate(float qualityDecayRate) { - m_configuration.m_qualityDecayRate = qualityDecayRate; - m_meshFeatureProcessor->SetQualityDecayRate(m_meshHandle, qualityDecayRate); + RPI::Cullable::LodConfiguration lodConfig = GetMeshLodConfiguration(); + lodConfig.m_qualityDecayRate = qualityDecayRate; + m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, lodConfig); } float MeshComponentController::GetQualityDecayRate() const { - return m_meshFeatureProcessor->GetQualityDecayRate(m_meshHandle); + RPI::Cullable::LodConfiguration lodConfig = m_meshFeatureProcessor->GetMeshLodConfiguration(m_meshHandle); + return lodConfig.m_qualityDecayRate; } void MeshComponentController::SetVisibility(bool visible) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 888d4bb154..1b479ed3eb 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -30,6 +30,9 @@ namespace AZ { namespace Render { + + + //! A configuration structure for the MeshComponentController class MeshComponentConfig final : public AZ::ComponentConfig @@ -42,14 +45,17 @@ namespace AZ // Editor helper functions bool IsAssetSet(); AZStd::vector> GetLodOverrideValues(); + AZStd::vector> GetLodTypeValues(); Data::Asset m_modelAsset = { AZ::Data::AssetLoadBehavior::QueueLoad }; RHI::DrawItemSortKey m_sortKey = 0; - RPI::Cullable::LodOverride m_lodOverride = RPI::Cullable::NoLodOverride; - float m_minimumScreenCoverage = 1.0f / 1080.0f; - float m_qualityDecayRate = 0.5f; bool m_excludeFromReflectionCubeMaps = false; bool m_useForwardPassIblSpecular = false; + + RPI::Cullable::LodType m_lodType = RPI::Cullable::DefaultLodType; + RPI::Cullable::LodOverride m_lodOverride = RPI::Cullable::NoLodOverride; + float m_minimumScreenCoverage = RPI::Cullable::LodData::DefaultMinimumScreenCoverage; + float m_qualityDecayRate = RPI::Cullable::LodData::DefaultQualityDecayRate; }; class MeshComponentController final @@ -96,14 +102,17 @@ namespace AZ void SetSortKey(RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey() const override; - void SetLodOverride(RPI::Cullable::LodOverride lodOverride) override; - RPI::Cullable::LodOverride GetLodOverride() const override; + void SetLodType(RPI::Cullable::LodType lodType) override; + RPI::Cullable::LodType GetLodType() const override; - void SetMinimumScreenCoverage(float minimumScreenCoverage) override; - float GetMinimumScreenCoverage() const override; + virtual void SetLodOverride(RPI::Cullable::LodOverride lodOverride); + virtual RPI::Cullable::LodOverride GetLodOverride() const; - void SetQualityDecayRate(float qualityDecayRate) override; - float GetQualityDecayRate() const override; + virtual void SetMinimumScreenCoverage(float minimumScreenCoverage); + virtual float GetMinimumScreenCoverage() const; + + virtual void SetQualityDecayRate(float qualityDecayRate); + virtual float GetQualityDecayRate() const; void SetVisibility(bool visible) override; bool GetVisibility() const override; @@ -137,6 +146,8 @@ namespace AZ void UnregisterModel(); void RefreshModelRegistration(); + RPI::Cullable::LodConfiguration MeshComponentController::GetMeshLodConfiguration() const; + void HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale); Render::MeshFeatureProcessorInterface* m_meshFeatureProcessor = nullptr; diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp index 63912aa8a6..e2debacb83 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp @@ -404,35 +404,53 @@ namespace AZ { return m_meshFeatureProcessor->GetSortKey(*m_meshHandle); } + + void AtomActorInstance::SetLodType(RPI::Cullable::LodType lodType) + { + RPI::Cullable::LodConfiguration config = m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle); + config.m_lodType = lodType; + m_meshFeatureProcessor->SetMeshLodConfiguration(*m_meshHandle, config); + } + + RPI::Cullable::LodType AtomActorInstance::GetLodType() const + { + return m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle).m_lodType; + } void AtomActorInstance::SetLodOverride(RPI::Cullable::LodOverride lodOverride) { - m_meshFeatureProcessor->SetLodOverride(*m_meshHandle, lodOverride); + RPI::Cullable::LodConfiguration config = m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle); + config.m_lodOverride = lodOverride; + m_meshFeatureProcessor->SetMeshLodConfiguration(*m_meshHandle, config); } RPI::Cullable::LodOverride AtomActorInstance::GetLodOverride() const { - return m_meshFeatureProcessor->GetLodOverride(*m_meshHandle); + return m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle).m_lodOverride; } void AtomActorInstance::SetMinimumScreenCoverage(float minimumScreenCoverage) { - m_meshFeatureProcessor->SetMinimumScreenCoverage(*m_meshHandle, minimumScreenCoverage); + RPI::Cullable::LodConfiguration config = m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle); + config.m_minimumScreenCoverage = minimumScreenCoverage; + m_meshFeatureProcessor->SetMeshLodConfiguration(*m_meshHandle, config); } float AtomActorInstance::GetMinimumScreenCoverage() const { - return m_meshFeatureProcessor->GetMinimumScreenCoverage(*m_meshHandle); + return m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle).m_minimumScreenCoverage; } void AtomActorInstance::SetQualityDecayRate(float qualityDecayRate) { - m_meshFeatureProcessor->SetQualityDecayRate(*m_meshHandle, qualityDecayRate); + RPI::Cullable::LodConfiguration config = m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle); + config.m_qualityDecayRate = qualityDecayRate; + m_meshFeatureProcessor->SetMeshLodConfiguration(*m_meshHandle, config); } float AtomActorInstance::GetQualityDecayRate() const { - return m_meshFeatureProcessor->GetQualityDecayRate(*m_meshHandle); + return m_meshFeatureProcessor->GetMeshLodConfiguration(*m_meshHandle).m_qualityDecayRate; } void AtomActorInstance::SetVisibility(bool visible) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h index bd9afc668e..bf832e9def 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.h @@ -138,6 +138,8 @@ namespace AZ AZ::Data::Instance GetModel() const override; void SetSortKey(RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey() const override; + void SetLodType(RPI::Cullable::LodType lodType) override; + RPI::Cullable::LodType GetLodType() const override; void SetLodOverride(RPI::Cullable::LodOverride lodOverride) override; RPI::Cullable::LodOverride GetLodOverride() const override; void SetMinimumScreenCoverage(float minimumScreenCoverage) override; From 0c05c9f20462a708de228e5ff06acd96d9b3a533 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Wed, 11 Aug 2021 15:49:50 -0700 Subject: [PATCH 07/17] [not working] Made lod selection more generic for further work Signed-off-by: Kyle B --- .../Code/Source/Mesh/MeshFeatureProcessor.cpp | 2 +- .../Code/Include/Atom/RPI.Public/Culling.h | 26 +++++------ .../RPI/Code/Source/RPI.Public/Culling.cpp | 27 ++++++----- .../QuadSphere_Default.material | 28 +++++++++++ .../Code/Source/Mesh/EditorMeshComponent.cpp | 9 +++- .../Source/Mesh/MeshComponentController.cpp | 46 +++++++++++++++++-- .../Source/Mesh/MeshComponentController.h | 11 +++-- 7 files changed, 113 insertions(+), 36 deletions(-) create mode 100644 Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 679e64e283..363723f7da 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -376,7 +376,7 @@ namespace AZ else { AZ_Assert(false, "Invalid mesh handle"); - return {0,0,0.0f,0.0f}; + return {RPI::Cullable::LodType::Default, 0, 0.0f, 0.0f }; } } diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h index e89e180540..82e9c733c8 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Culling.h @@ -70,17 +70,22 @@ namespace AZ }; CullData m_cullData; - using LodType = uint8_t; + enum LodType : uint8_t + { + Default = 0, + ScreenCoverage, + SpecificLod, + }; using LodOverride = uint8_t; - static constexpr uint8_t NoLodOverride = AZStd::numeric_limits::max(); - static constexpr uint8_t DefaultLodType = AZStd::numeric_limits::max(); struct LodConfiguration { - LodType m_lodType; - LodOverride m_lodOverride; - float m_minimumScreenCoverage; - float m_qualityDecayRate; + LodType m_lodType = LodType::Default; + LodOverride m_lodOverride = 0; + // the minimum possibe area a sphere enclosing a mesh projected onto the screen should have before it is culled. + float m_minimumScreenCoverage = 1.0f / 1080.0f; // For default, mesh should cover at least a screen pixel at 1080p to be drawn; + // The screen area decay between 0 and 1, i.e. closer to 1 -> lose quality immediately, closer to 0 -> never lose quality + float m_qualityDecayRate = 0.5f; }; struct LodData @@ -98,12 +103,7 @@ namespace AZ //! Suggest setting to: 0.5f*localAabb.GetExtents().GetMaxElement() float m_lodSelectionRadius = 1.0f; - // the minimum possibe area a sphere enclosing a mesh projected onto the screen should have before it is culled. - static constexpr float DefaultMinimumScreenCoverage = 1.0f / 1080.0f; //For default, mesh should cover at least a screen pixel at 1080p to be drawn - // The screen area decay between 0 and 1, i.e. closer to 1 -> lose quality immediately, closer to 0 -> never lose quality - static constexpr float DefaultQualityDecayRate = 0.5f; - - LodConfiguration m_lodConfiguration = { DefaultLodType, NoLodOverride, DefaultMinimumScreenCoverage, DefaultQualityDecayRate }; + LodConfiguration m_lodConfiguration; }; LodData m_lodData; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp index f22d5c7224..c0d9023fa9 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp @@ -672,20 +672,25 @@ namespace AZ } }; - if (lodData.m_lodConfiguration.m_lodOverride == Cullable::NoLodOverride) + switch (lodData.m_lodConfiguration.m_lodType) { - for (const Cullable::LodData::Lod& lod : lodData.m_lods) - { - //Note that this supports overlapping lod ranges (to suport cross-fading lods, for example) - if (approxScreenPercentage >= lod.m_screenCoverageMin && approxScreenPercentage <= lod.m_screenCoverageMax) + case Cullable::LodType::SpecificLod: + if (lodData.m_lodConfiguration.m_lodOverride < lodData.m_lods.size()) { - addLodToDrawPacket(lod); + addLodToDrawPacket(lodData.m_lods.at(lodData.m_lodConfiguration.m_lodOverride)); } - } - } - else if(lodData.m_lodConfiguration.m_lodOverride < lodData.m_lods.size()) - { - addLodToDrawPacket(lodData.m_lods.at(lodData.m_lodConfiguration.m_lodOverride)); + break; + case Cullable::LodType::ScreenCoverage: + default: + for (const Cullable::LodData::Lod& lod : lodData.m_lods) + { + // Note that this supports overlapping lod ranges (to suport cross-fading lods, for example) + if (approxScreenPercentage >= lod.m_screenCoverageMin && approxScreenPercentage <= lod.m_screenCoverageMax) + { + addLodToDrawPacket(lod); + } + } + break; } return numVisibleDrawPackets; diff --git a/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material b/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material new file mode 100644 index 0000000000..4905c302fe --- /dev/null +++ b/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material @@ -0,0 +1,28 @@ +{ + "description": "", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "", + "propertyLayoutVersion": 3, + "properties": { + "baseColor": { + "color": [ + 0.800000011920929, + 0.800000011920929, + 0.800000011920929, + 1.0 + ], + "textureMap": "MaterialEditor/ViewportModels/_dev_shaderball_00_basecolor.png" + }, + "emissive": { + "color": [ + 0.0, + 0.0, + 0.0, + 1.0 + ] + }, + "opacity": { + "factor": 1.0 + } + } +} \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index 0719d9f2bb..ff0741fc31 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -79,20 +79,25 @@ namespace AZ ->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_useForwardPassIblSpecular, "Use Forward Pass IBL Specular", "Renders IBL specular reflections in the forward pass, using only the most influential probe (based on the position of the entity) and the global IBL cubemap. Can reduce rendering costs, but only recommended for static objects that are affected by at most one reflection probe.") ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) - ->ClassElement(AZ::Edit::ClassElements::Group, "Lod Configuration") - ->Attribute(AZ::Edit::Attributes::AutoExpand, false) ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodType, "Lod Type", "Lod Method.") ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodTypeValues) + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) + ->ClassElement(AZ::Edit::ClassElements::Group, "Lod Configuration") + ->Attribute(AZ::Edit::Attributes::AutoExpand, false) + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::ShowLodConfig) ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodOverride, "Lod Override", "Allows the rendered LOD to be overridden instead of being calculated automatically.") ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodOverrideValues) + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::LodTypeIsSpecificLOD) ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_minimumScreenCoverage, "Minimum Screen Coverage", "Minimum proportion of screen area an entitiy takes up, after that the entitiy is culled.") ->Attribute(AZ::Edit::Attributes::Min, 0.f) ->Attribute(AZ::Edit::Attributes::Max, 1.f) ->Attribute(AZ::Edit::Attributes::Suffix, " percent") + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::LodTypeIsScreenCoverage) ->DataElement(AZ::Edit::UIHandlers::Slider, &MeshComponentConfig::m_qualityDecayRate, "Quality Decay Rate", "Rate at which mesh quality decays (0 -> always stay highest quality, 1 -> quality falls off to lowest quality immediately).") ->Attribute(AZ::Edit::Attributes::Min, 0.f) ->Attribute(AZ::Edit::Attributes::Max, 1.f) + ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::LodTypeIsScreenCoverage) ; } } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index adcf570899..3d049d0f97 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -31,11 +31,30 @@ namespace AZ { namespace Render { + + namespace MeshComponentControllerVersionUtility + { + bool VersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement) + { + if (classElement.GetVersion() < 2) + { + RPI::Cullable::LodOverride lodOverride = classElement.FindElement(AZ_CRC("LodOverride")); + static constexpr uint8_t old_NoLodOverride = AZStd::numeric_limits ::max(); + if (lodOverride == old_NoLodOverride) + { + classElement.AddElementWithData(context, "LodType", RPI::Cullable::LodType::SpecificLod); + } + } + return true; + } + } // namespace MeshComponentControllerVersionUtility + void MeshComponentConfig::Reflect(ReflectContext* context) { if (auto* serializeContext = azrtti_cast(context)) { serializeContext->Class() + //->Version(2, &MeshComponentControllerVersionUtility::VersionConverter) ->Version(1) ->Field("ModelAsset", &MeshComponentConfig::m_modelAsset) ->Field("SortKey", &MeshComponentConfig::m_sortKey) @@ -53,6 +72,21 @@ namespace AZ return m_modelAsset.GetId().IsValid(); } + bool MeshComponentConfig::LodTypeIsScreenCoverage() + { + return m_lodType == RPI::Cullable::LodType::ScreenCoverage; + } + + bool MeshComponentConfig::LodTypeIsSpecificLOD() + { + return m_lodType == RPI::Cullable::LodType::SpecificLod; + } + + bool MeshComponentConfig::ShowLodConfig() + { + return LodTypeIsScreenCoverage() && LodTypeIsSpecificLOD(); + } + AZStd::vector> MeshComponentConfig::GetLodOverrideValues() { AZStd::vector> values; @@ -75,9 +109,9 @@ namespace AZ } values.reserve(lodCount + 1); - values.push_back({ RPI::Cullable::NoLodOverride, "Not Set" }); + values.push_back({0, "Default (Highest)" }); - for (uint32_t i = 0; i < lodCount; ++i) + for (uint32_t i = 1; i < lodCount; ++i) { AZStd::string enumDescription = AZStd::string::format("Lod %i", i); values.push_back({ aznumeric_cast(i), enumDescription.c_str() }); @@ -89,7 +123,9 @@ namespace AZ AZStd::vector> MeshComponentConfig::GetLodTypeValues() { return { - {RPI::Cullable::DefaultLodType, "Default"} + {aznumeric_cast(0), "Default"}, + {aznumeric_cast(1), "Screen Coverage" }, + {aznumeric_cast(2), "Specific Lod" } }; } @@ -112,12 +148,12 @@ namespace AZ if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) { - behaviorContext->ConstantProperty("NoLodOverride", BehaviorConstant(RPI::Cullable::NoLodOverride)) + behaviorContext->ConstantProperty("DefaultLodOverride", BehaviorConstant(0)) ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Category, "render") ->Attribute(AZ::Script::Attributes::Module, "render"); - behaviorContext->ConstantProperty("DefaultLodType", BehaviorConstant(RPI::Cullable::DefaultLodType)) + behaviorContext->ConstantProperty("DefaultLodType", BehaviorConstant(RPI::Cullable::LodType::Default)) ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Category, "render") ->Attribute(AZ::Script::Attributes::Module, "render"); diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 1b479ed3eb..5f38088ca3 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -44,6 +44,9 @@ namespace AZ // Editor helper functions bool IsAssetSet(); + bool LodTypeIsScreenCoverage(); + bool LodTypeIsSpecificLOD(); + bool ShowLodConfig(); AZStd::vector> GetLodOverrideValues(); AZStd::vector> GetLodTypeValues(); @@ -52,10 +55,10 @@ namespace AZ bool m_excludeFromReflectionCubeMaps = false; bool m_useForwardPassIblSpecular = false; - RPI::Cullable::LodType m_lodType = RPI::Cullable::DefaultLodType; - RPI::Cullable::LodOverride m_lodOverride = RPI::Cullable::NoLodOverride; - float m_minimumScreenCoverage = RPI::Cullable::LodData::DefaultMinimumScreenCoverage; - float m_qualityDecayRate = RPI::Cullable::LodData::DefaultQualityDecayRate; + RPI::Cullable::LodType m_lodType = RPI::Cullable::LodType::Default; + RPI::Cullable::LodOverride m_lodOverride = aznumeric_cast(0); + float m_minimumScreenCoverage = 1.0f / 1080.0f; + float m_qualityDecayRate = 0.5f; }; class MeshComponentController final From cea334dbc40d076b0d4d3fc052f89a660466f662 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Wed, 11 Aug 2021 22:23:06 -0700 Subject: [PATCH 08/17] Fixed enum value problems Signed-off-by: Kyle B --- .../Code/Source/Mesh/EditorMeshComponent.cpp | 4 +++- .../Code/Source/Mesh/MeshComponentController.cpp | 13 ++----------- .../Code/Source/Mesh/MeshComponentController.h | 1 - 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index ff0741fc31..63b32f6892 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -80,7 +80,9 @@ namespace AZ "Renders IBL specular reflections in the forward pass, using only the most influential probe (based on the position of the entity) and the global IBL cubemap. Can reduce rendering costs, but only recommended for static objects that are affected by at most one reflection probe.") ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly) ->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodType, "Lod Type", "Lod Method.") - ->Attribute(AZ::Edit::Attributes::EnumValues, &MeshComponentConfig::GetLodTypeValues) + ->EnumAttribute(RPI::Cullable::LodType::Default, "Default") + ->EnumAttribute(RPI::Cullable::LodType::ScreenCoverage, "Screen Coverage") + ->EnumAttribute(RPI::Cullable::LodType::SpecificLod, "Specific Lod") ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) ->ClassElement(AZ::Edit::ClassElements::Group, "Lod Configuration") ->Attribute(AZ::Edit::Attributes::AutoExpand, false) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 3d049d0f97..9aa3685c34 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -54,8 +54,7 @@ namespace AZ if (auto* serializeContext = azrtti_cast(context)) { serializeContext->Class() - //->Version(2, &MeshComponentControllerVersionUtility::VersionConverter) - ->Version(1) + ->Version(2, &MeshComponentControllerVersionUtility::VersionConverter) ->Field("ModelAsset", &MeshComponentConfig::m_modelAsset) ->Field("SortKey", &MeshComponentConfig::m_sortKey) ->Field("ExcludeFromReflectionCubeMaps", &MeshComponentConfig::m_excludeFromReflectionCubeMaps) @@ -65,6 +64,7 @@ namespace AZ ->Field("MinimumScreenCoverage", &MeshComponentConfig::m_minimumScreenCoverage) ->Field("QualityDecayRate", &MeshComponentConfig::m_qualityDecayRate); } + } bool MeshComponentConfig::IsAssetSet() @@ -120,15 +120,6 @@ namespace AZ return values; } - AZStd::vector> MeshComponentConfig::GetLodTypeValues() - { - return { - {aznumeric_cast(0), "Default"}, - {aznumeric_cast(1), "Screen Coverage" }, - {aznumeric_cast(2), "Specific Lod" } - }; - } - MeshComponentController::~MeshComponentController() { // Release memory, disconnect from buses in the right order and broadcast events so that other components are aware. diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 5f38088ca3..aba560b6e8 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -48,7 +48,6 @@ namespace AZ bool LodTypeIsSpecificLOD(); bool ShowLodConfig(); AZStd::vector> GetLodOverrideValues(); - AZStd::vector> GetLodTypeValues(); Data::Asset m_modelAsset = { AZ::Data::AssetLoadBehavior::QueueLoad }; RHI::DrawItemSortKey m_sortKey = 0; From bdbab1090a6970f057de0ac65e074204eefdbc2c Mon Sep 17 00:00:00 2001 From: Kyle B Date: Thu, 12 Aug 2021 14:49:25 -0700 Subject: [PATCH 09/17] removed accidental file addition Signed-off-by: Kyle B --- .../QuadSphere_Default.material | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material diff --git a/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material b/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material deleted file mode 100644 index 4905c302fe..0000000000 --- a/Gems/Atom/Tools/MaterialEditor/Assets/MaterialEditor/ViewportModels/QuadSphere_Default.material +++ /dev/null @@ -1,28 +0,0 @@ -{ - "description": "", - "materialType": "Materials/Types/StandardPBR.materialtype", - "parentMaterial": "", - "propertyLayoutVersion": 3, - "properties": { - "baseColor": { - "color": [ - 0.800000011920929, - 0.800000011920929, - 0.800000011920929, - 1.0 - ], - "textureMap": "MaterialEditor/ViewportModels/_dev_shaderball_00_basecolor.png" - }, - "emissive": { - "color": [ - 0.0, - 0.0, - 0.0, - 1.0 - ] - }, - "opacity": { - "factor": 1.0 - } - } -} \ No newline at end of file From 6acbea722ef101227896366bd6e9518f9d691da7 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Thu, 12 Aug 2021 18:15:17 -0700 Subject: [PATCH 10/17] minor syntax changes and adding a refresh tree attributeto the editor component Signed-off-by: Kyle B --- .../Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h | 2 +- .../Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h | 2 +- .../Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp | 2 +- .../CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index daf4a493c2..a448f7121f 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -155,7 +155,7 @@ namespace AZ void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override; - void SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig); + void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig); RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const; void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index 8c7a200ff5..c341cd8854 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -95,7 +95,7 @@ namespace AZ //! Gets the sort key for a given mesh handle. virtual RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) = 0; //! Sets LOD mesh configurations to be used in the Mesh Feature Processor - virtual void SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig) = 0; + virtual void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig) = 0; //! Gets the LOD mesh configurations being used in the Mesh Feature Processor virtual RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const = 0; //! Sets the option to exclude this mesh from baked reflection probe cubemaps diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 363723f7da..e07c7a0309 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -359,7 +359,7 @@ namespace AZ } } - void MeshFeatureProcessor::SetMeshLodConfiguration(const MeshHandle& meshHandle, RPI::Cullable::LodConfiguration meshLodConfig) + void MeshFeatureProcessor::SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig) { if (meshHandle.IsValid()) { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index 63b32f6892..8f81bd620d 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -84,6 +84,7 @@ namespace AZ ->EnumAttribute(RPI::Cullable::LodType::ScreenCoverage, "Screen Coverage") ->EnumAttribute(RPI::Cullable::LodType::SpecificLod, "Specific Lod") ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::IsAssetSet) + ->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::EntireTree) ->ClassElement(AZ::Edit::ClassElements::Group, "Lod Configuration") ->Attribute(AZ::Edit::Attributes::AutoExpand, false) ->Attribute(AZ::Edit::Attributes::Visibility, &MeshComponentConfig::ShowLodConfig) From e2a9c58cae300317f0b3b80ea3cccaae26926512 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Mon, 16 Aug 2021 23:01:18 -0700 Subject: [PATCH 11/17] fixed unnessisary qualifier error Signed-off-by: Kyle B --- .../CommonFeatures/Code/Source/Mesh/MeshComponentController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index aba560b6e8..c7f9c8f993 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -148,7 +148,7 @@ namespace AZ void UnregisterModel(); void RefreshModelRegistration(); - RPI::Cullable::LodConfiguration MeshComponentController::GetMeshLodConfiguration() const; + RPI::Cullable::LodConfiguration GetMeshLodConfiguration() const; void HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale); From 01ad7c5e4efcb95a185588c5e9ff13633e7667fd Mon Sep 17 00:00:00 2001 From: Kyle B Date: Mon, 16 Aug 2021 23:09:25 -0700 Subject: [PATCH 12/17] fixed namespace issue with the mocks Signed-off-by: Kyle B --- .../Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 0c03e767e7..75ce42daed 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -33,8 +33,8 @@ namespace UnitTest MOCK_CONST_METHOD1(GetLocalAabb, AZ::Aabb(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_CONST_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); - MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, RPI::Cullable::LodConfiguration)); - MOCK_CONST_METHOD1(GetMeshLodConfiguration, RPI::Cullable::LodConfiguration(const MeshHandle&)); + MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, AZ::RPI::Cullable::LodConfiguration)); + MOCK_CONST_METHOD1(GetMeshLodConfiguration, AZ::RPI::Cullable::LodConfiguration(const MeshHandle&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance&)); MOCK_METHOD2(SetRayTracingEnabled, void (const MeshHandle&, bool)); From c515ead27e1a64f146529f6933214be23972c0d5 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Tue, 17 Aug 2021 22:44:41 -0700 Subject: [PATCH 13/17] attempt to fixed mock errors Signed-off-by: Kyle B --- .../Code/Mocks/MockMeshFeatureProcessor.h | 2 +- Gems/Vegetation/Code/Tests/VegetationMocks.h | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 75ce42daed..49d615a37f 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -33,7 +33,7 @@ namespace UnitTest MOCK_CONST_METHOD1(GetLocalAabb, AZ::Aabb(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_CONST_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); - MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, AZ::RPI::Cullable::LodConfiguration)); + MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, const AZ::RPI::Cullable::LodConfiguration)); MOCK_CONST_METHOD1(GetMeshLodConfiguration, AZ::RPI::Cullable::LodConfiguration(const MeshHandle&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance&)); diff --git a/Gems/Vegetation/Code/Tests/VegetationMocks.h b/Gems/Vegetation/Code/Tests/VegetationMocks.h index 37bacef21a..cd438335c6 100644 --- a/Gems/Vegetation/Code/Tests/VegetationMocks.h +++ b/Gems/Vegetation/Code/Tests/VegetationMocks.h @@ -554,6 +554,16 @@ namespace UnitTest return m_drawItemSortKeyOutput; } + AZ::RPI::Cullable::LodType m_lodTypeOutput; + void SetLodOverride(AZ::RPI::Cullable::LodType lodType) override + { + m_lodTypeOutput = lodType; + } + AZ::RPI::Cullable::LodType GetLodType() const override + { + return m_lodTypeOutput; + } + AZ::RPI::Cullable::LodOverride m_lodOverrideOutput; void SetLodOverride(AZ::RPI::Cullable::LodOverride lodOverride) override { @@ -563,6 +573,26 @@ namespace UnitTest { return m_lodOverrideOutput; } + + float m_minimumScreenCoverageOutput; + void SetMinimumScreenCoverage(float minimumScreenCoverage) override + { + m_minimumScreenCoverageOutput = minimumScreenCoverage; + } + float GetMinimumScreenCoverage() const override + { + return m_minimumScreenCoverageOutput; + } + + float m_qualityDecayRateOutput; + void SetQualityDecayRate(float qualityDecayRate) override + { + m_qualityDecayRateOutput = qualityDecayRate; + } + float GetQualityDecayRate() const override + { + return m_qualityDecayRateOutput; + } }; struct MockTransformBus From 13f4f3b37a70f82bbce1acbfdeb2ea3dccfcbb4a Mon Sep 17 00:00:00 2001 From: Kyle B Date: Wed, 18 Aug 2021 19:35:51 -0700 Subject: [PATCH 14/17] fixed typo in vegitation mock Signed-off-by: Kyle B --- Gems/Vegetation/Code/Tests/VegetationMocks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Vegetation/Code/Tests/VegetationMocks.h b/Gems/Vegetation/Code/Tests/VegetationMocks.h index cd438335c6..ebc51d1b3b 100644 --- a/Gems/Vegetation/Code/Tests/VegetationMocks.h +++ b/Gems/Vegetation/Code/Tests/VegetationMocks.h @@ -555,7 +555,7 @@ namespace UnitTest } AZ::RPI::Cullable::LodType m_lodTypeOutput; - void SetLodOverride(AZ::RPI::Cullable::LodType lodType) override + void SetLodType(AZ::RPI::Cullable::LodType lodType) override { m_lodTypeOutput = lodType; } From e410eecd93c5db984cfab09374bfab64df8d1cb2 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Thu, 19 Aug 2021 23:41:30 -0700 Subject: [PATCH 15/17] fixed mesh feature processor abstract interface Signed-off-by: Kyle B --- .../Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h | 6 +++--- .../Atom/Feature/Mesh/MeshFeatureProcessorInterface.h | 4 ++-- .../Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h | 2 +- .../Common/Code/Source/Mesh/MeshFeatureProcessor.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index a448f7121f..389c5902f9 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -153,10 +153,10 @@ namespace AZ AZ::Aabb GetLocalAabb(const MeshHandle& meshHandle) const override; void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override; - RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override; + RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) const override; - void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig); - RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const; + void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration& meshLodConfig) override; + RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const override; void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) override; void SetRayTracingEnabled(const MeshHandle& meshHandle, bool rayTracingEnabled) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index c341cd8854..cffbe5c3c5 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -93,9 +93,9 @@ namespace AZ //! Sets the sort key for a given mesh handle. virtual void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) = 0; //! Gets the sort key for a given mesh handle. - virtual RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) = 0; + virtual RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) const = 0; //! Sets LOD mesh configurations to be used in the Mesh Feature Processor - virtual void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig) = 0; + virtual void SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration& meshLodConfig) = 0; //! Gets the LOD mesh configurations being used in the Mesh Feature Processor virtual RPI::Cullable::LodConfiguration GetMeshLodConfiguration(const MeshHandle& meshHandle) const = 0; //! Sets the option to exclude this mesh from baked reflection probe cubemaps diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 49d615a37f..35e399997f 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -33,7 +33,7 @@ namespace UnitTest MOCK_CONST_METHOD1(GetLocalAabb, AZ::Aabb(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_CONST_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); - MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, const AZ::RPI::Cullable::LodConfiguration)); + MOCK_METHOD2(SetMeshLodConfiguration, void(const MeshHandle&, const AZ::RPI::Cullable::LodConfiguration&)); MOCK_CONST_METHOD1(GetMeshLodConfiguration, AZ::RPI::Cullable::LodConfiguration(const MeshHandle&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&)); MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance&)); diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index e07c7a0309..18b87d0cea 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -346,7 +346,7 @@ namespace AZ } } - RHI::DrawItemSortKey MeshFeatureProcessor::GetSortKey(const MeshHandle& meshHandle) + RHI::DrawItemSortKey MeshFeatureProcessor::GetSortKey(const MeshHandle& meshHandle) const { if (meshHandle.IsValid()) { @@ -359,7 +359,7 @@ namespace AZ } } - void MeshFeatureProcessor::SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration meshLodConfig) + void MeshFeatureProcessor::SetMeshLodConfiguration(const MeshHandle& meshHandle, const RPI::Cullable::LodConfiguration& meshLodConfig) { if (meshHandle.IsValid()) { From 8ab9a88683f98e69703857e716ca43a33c7f9431 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Sat, 21 Aug 2021 00:19:07 -0700 Subject: [PATCH 16/17] added cast to version change system lodoverride Signed-off-by: Kyle B --- .../CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 11ac73d034..b1bfb30285 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -38,7 +38,7 @@ namespace AZ { if (classElement.GetVersion() < 2) { - RPI::Cullable::LodOverride lodOverride = classElement.FindElement(AZ_CRC("LodOverride")); + RPI::Cullable::LodOverride lodOverride = aznumeric_cast(classElement.FindElement(AZ_CRC("LodOverride"))); static constexpr uint8_t old_NoLodOverride = AZStd::numeric_limits ::max(); if (lodOverride == old_NoLodOverride) { From dfc5baae34dbbdc417d743a3c9e785aab95fb76b Mon Sep 17 00:00:00 2001 From: Kyle B Date: Mon, 23 Aug 2021 12:46:00 -0700 Subject: [PATCH 17/17] fixed casting errors Signed-off-by: Kyle B --- .../CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index b1bfb30285..ade4beaa33 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -109,7 +109,7 @@ namespace AZ } values.reserve(lodCount + 1); - values.push_back({0, "Default (Highest)" }); + values.push_back({ aznumeric_cast(0), "Default (Highest)" }); for (uint32_t i = 1; i < lodCount; ++i) {