Made StandardMultilayerPBR hide a layer's property groups when that layer is disabled.
ATOM-14688 Disable Individual Layers - Added new SetMaterialPropertyGroupVisibility functions to the material functors. - Updated the MaterialFunctor::EditorContext to include parameters for handling material property group metadata. - Updated the material inspector(s) to apply the property group visiblity changes from the material functor, to hide or show the property groups. - Moved some code from MaterialPropertyDescriptor.h/cpp to a new MaterialDynamicMetadata.h/cpp, since these aren't really related to the MaterialPropertyDescriptor code. It's more for material functors to use. - Also fixed the casing for the "GetMaterialPropertyValue_Image" lua function, since I was already in this code (ATOM-14793 "Fix Inconsistent Casing For LuaMaterialFunctorRuntimeContext") Tested in MaterialEditor and in in the main Editor's MaterialComponent property override inspector.
This commit is contained in:
@@ -748,12 +748,15 @@ namespace UnitTest
|
||||
MaterialPropertyDataType::UInt, "general.mode",
|
||||
MaterialPropertyDataType::Float, "general.value",
|
||||
functorScript);
|
||||
|
||||
|
||||
AZStd::unordered_set<AZ::Name> changedPropertyNames;
|
||||
|
||||
AZStd::unordered_map<Name, MaterialPropertyDynamicMetadata> propertyDynamicMetadata;
|
||||
propertyDynamicMetadata[Name{"general.mode"}] = {};
|
||||
propertyDynamicMetadata[Name{"general.value"}] = {};
|
||||
|
||||
AZStd::unordered_set<AZ::Name> changedPropertyGroupNames;
|
||||
AZStd::unordered_map<Name, MaterialPropertyGroupDynamicMetadata> propertyGroupDynamicMetadata;
|
||||
propertyGroupDynamicMetadata[Name{"general"}] = {};
|
||||
|
||||
Ptr<MaterialFunctor> functor = testData.GetMaterialTypeAsset()->GetMaterialFunctors()[0];
|
||||
|
||||
@@ -761,7 +764,9 @@ namespace UnitTest
|
||||
testData.GetMaterial()->GetPropertyValues(),
|
||||
testData.GetMaterial()->GetMaterialPropertiesLayout(),
|
||||
propertyDynamicMetadata,
|
||||
propertyGroupDynamicMetadata,
|
||||
changedPropertyNames,
|
||||
changedPropertyGroupNames,
|
||||
&functor->GetMaterialPropertyDependencies()
|
||||
);
|
||||
|
||||
@@ -814,10 +819,13 @@ namespace UnitTest
|
||||
functorScript);
|
||||
|
||||
AZStd::unordered_set<AZ::Name> changedPropertyNames;
|
||||
|
||||
AZStd::unordered_map<Name, MaterialPropertyDynamicMetadata> propertyDynamicMetadata;
|
||||
propertyDynamicMetadata[Name{"general.units"}] = {};
|
||||
propertyDynamicMetadata[Name{"general.distance"}] = {};
|
||||
|
||||
AZStd::unordered_set<AZ::Name> changedPropertyGroupNames;
|
||||
AZStd::unordered_map<Name, MaterialPropertyGroupDynamicMetadata> propertyGroupDynamicMetadata;
|
||||
propertyGroupDynamicMetadata[Name{"general"}] = {};
|
||||
|
||||
Ptr<MaterialFunctor> functor = testData.GetMaterialTypeAsset()->GetMaterialFunctors()[0];
|
||||
|
||||
@@ -825,7 +833,9 @@ namespace UnitTest
|
||||
testData.GetMaterial()->GetPropertyValues(),
|
||||
testData.GetMaterial()->GetMaterialPropertiesLayout(),
|
||||
propertyDynamicMetadata,
|
||||
propertyGroupDynamicMetadata,
|
||||
changedPropertyNames,
|
||||
changedPropertyGroupNames,
|
||||
&functor->GetMaterialPropertyDependencies()
|
||||
);
|
||||
|
||||
@@ -845,6 +855,66 @@ namespace UnitTest
|
||||
EXPECT_EQ(-100.0f, propertyDynamicMetadata[Name{"general.distance"}].m_propertyRange.m_softMin.GetValue<float>());
|
||||
EXPECT_EQ(100.0f, propertyDynamicMetadata[Name{"general.distance"}].m_propertyRange.m_softMax.GetValue<float>());
|
||||
}
|
||||
|
||||
TEST_F(LuaMaterialFunctorTests, LuaMaterialFunctor_EditorContext_SetMaterialPropertyGroupVisibility)
|
||||
{
|
||||
using namespace AZ::RPI;
|
||||
|
||||
const char* functorScript =
|
||||
R"(
|
||||
function GetMaterialPropertyDependencies()
|
||||
return { "general.mode" }
|
||||
end
|
||||
|
||||
function ProcessEditor(context)
|
||||
local mode = context:GetMaterialPropertyValue_uint("general.mode")
|
||||
|
||||
if (mode == 1) then
|
||||
context:SetMaterialPropertyGroupVisibility("otherGroup", MaterialPropertyGroupVisibility_Enabled)
|
||||
else
|
||||
context:SetMaterialPropertyGroupVisibility("otherGroup", MaterialPropertyGroupVisibility_Hidden)
|
||||
end
|
||||
end
|
||||
)";
|
||||
|
||||
TestMaterialData testData;
|
||||
testData.Setup(
|
||||
MaterialPropertyDataType::UInt, "general.mode",
|
||||
MaterialPropertyDataType::Float, "otherGroup.value",
|
||||
functorScript);
|
||||
|
||||
AZStd::unordered_set<AZ::Name> changedPropertyNames;
|
||||
AZStd::unordered_map<Name, MaterialPropertyDynamicMetadata> propertyDynamicMetadata;
|
||||
propertyDynamicMetadata[Name{"general.mode"}] = {};
|
||||
propertyDynamicMetadata[Name{"otherGroup.value"}] = {};
|
||||
|
||||
AZStd::unordered_set<AZ::Name> changedPropertyGroupNames;
|
||||
AZStd::unordered_map<Name, MaterialPropertyGroupDynamicMetadata> propertyGroupDynamicMetadata;
|
||||
propertyGroupDynamicMetadata[Name{"general"}] = {};
|
||||
propertyGroupDynamicMetadata[Name{"otherGroup"}] = {};
|
||||
|
||||
Ptr<MaterialFunctor> functor = testData.GetMaterialTypeAsset()->GetMaterialFunctors()[0];
|
||||
|
||||
AZ::RPI::MaterialFunctor::EditorContext context = AZ::RPI::MaterialFunctor::EditorContext(
|
||||
testData.GetMaterial()->GetPropertyValues(),
|
||||
testData.GetMaterial()->GetMaterialPropertiesLayout(),
|
||||
propertyDynamicMetadata,
|
||||
propertyGroupDynamicMetadata,
|
||||
changedPropertyNames,
|
||||
changedPropertyGroupNames,
|
||||
&functor->GetMaterialPropertyDependencies()
|
||||
);
|
||||
|
||||
testData.GetMaterial()->SetPropertyValue(testData.GetMaterialPropertyIndex(), MaterialPropertyValue{0u});
|
||||
functor->Process(context);
|
||||
EXPECT_EQ(MaterialPropertyGroupVisibility::Enabled, propertyGroupDynamicMetadata[Name{"general"}].m_visibility);
|
||||
EXPECT_EQ(MaterialPropertyGroupVisibility::Hidden, propertyGroupDynamicMetadata[Name{"otherGroup"}].m_visibility);
|
||||
|
||||
testData.GetMaterial()->SetPropertyValue(testData.GetMaterialPropertyIndex(), MaterialPropertyValue{1u});
|
||||
functor->Process(context);
|
||||
EXPECT_EQ(MaterialPropertyGroupVisibility::Enabled, propertyGroupDynamicMetadata[Name{"general"}].m_visibility);
|
||||
EXPECT_EQ(MaterialPropertyGroupVisibility::Enabled, propertyGroupDynamicMetadata[Name{"otherGroup"}].m_visibility);
|
||||
}
|
||||
|
||||
TEST_F(LuaMaterialFunctorTests, LuaMaterialFunctor_RuntimeContext_SetRenderStates)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user