Created group for Lod component data
Signed-off-by: Kyle B <kylebirnbaum@gmail.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
+4
-12
@@ -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
|
||||
|
||||
@@ -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<AZ::RPI::Material>&));
|
||||
MOCK_METHOD2(SetRayTracingEnabled, void (const MeshHandle&, bool));
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<LodOverride>::max();
|
||||
static constexpr uint8_t DefaultLodType = AZStd::numeric_limits<LodType>::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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+3
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
+58
-15
@@ -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<AZStd::pair<RPI::Cullable::LodType, AZStd::string>> 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<MeshComponentRequestBus>("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)
|
||||
|
||||
@@ -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<AZStd::pair<RPI::Cullable::LodOverride, AZStd::string>> GetLodOverrideValues();
|
||||
AZStd::vector<AZStd::pair<RPI::Cullable::LodType, AZStd::string>> GetLodTypeValues();
|
||||
|
||||
Data::Asset<RPI::ModelAsset> 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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -138,6 +138,8 @@ namespace AZ
|
||||
AZ::Data::Instance<RPI::Model> 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;
|
||||
|
||||
Reference in New Issue
Block a user