[not working] Made lod selection more generic for further work
Signed-off-by: Kyle B <kylebirnbaum@gmail.com>
This commit is contained in:
@@ -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)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <RPI::Cullable::LodOverride>::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<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<MeshComponentConfig>()
|
||||
//->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<AZStd::pair<RPI::Cullable::LodOverride, AZStd::string>> MeshComponentConfig::GetLodOverrideValues()
|
||||
{
|
||||
AZStd::vector<AZStd::pair<RPI::Cullable::LodOverride, AZStd::string>> 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<RPI::Cullable::LodOverride>(i), enumDescription.c_str() });
|
||||
@@ -89,7 +123,9 @@ namespace AZ
|
||||
AZStd::vector<AZStd::pair<RPI::Cullable::LodType, AZStd::string>> MeshComponentConfig::GetLodTypeValues()
|
||||
{
|
||||
return {
|
||||
{RPI::Cullable::DefaultLodType, "Default"}
|
||||
{aznumeric_cast<RPI::Cullable::LodType>(0), "Default"},
|
||||
{aznumeric_cast<RPI::Cullable::LodType>(1), "Screen Coverage" },
|
||||
{aznumeric_cast<RPI::Cullable::LodType>(2), "Specific Lod" }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -112,12 +148,12 @@ namespace AZ
|
||||
|
||||
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(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");
|
||||
|
||||
@@ -44,6 +44,9 @@ namespace AZ
|
||||
|
||||
// Editor helper functions
|
||||
bool IsAssetSet();
|
||||
bool LodTypeIsScreenCoverage();
|
||||
bool LodTypeIsSpecificLOD();
|
||||
bool ShowLodConfig();
|
||||
AZStd::vector<AZStd::pair<RPI::Cullable::LodOverride, AZStd::string>> GetLodOverrideValues();
|
||||
AZStd::vector<AZStd::pair<RPI::Cullable::LodType, AZStd::string>> 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<RPI::Cullable::LodOverride>(0);
|
||||
float m_minimumScreenCoverage = 1.0f / 1080.0f;
|
||||
float m_qualityDecayRate = 0.5f;
|
||||
};
|
||||
|
||||
class MeshComponentController final
|
||||
|
||||
Reference in New Issue
Block a user