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.main
parent
275bb1bfec
commit
53188a12da
@ -0,0 +1,49 @@
|
||||
--------------------------------------------------------------------------------------
|
||||
--
|
||||
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
-- its licensors.
|
||||
--
|
||||
-- For complete copyright and license terms please see the LICENSE at the root of this
|
||||
-- distribution (the "License"). All use of this software is governed by the License,
|
||||
-- or, if provided, by the license below or the license accompanying this file. Do not
|
||||
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
--
|
||||
--
|
||||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
-- This functor hides the properties for disabled material layers.
|
||||
|
||||
function GetMaterialPropertyDependencies()
|
||||
return {
|
||||
"blend.enableLayer2",
|
||||
"blend.enableLayer3"
|
||||
}
|
||||
end
|
||||
|
||||
function SetLayerVisibility(context, layerNamePrefix, isVisible)
|
||||
|
||||
local visibility = MaterialPropertyGroupVisibility_Enabled
|
||||
if(not isVisible) then
|
||||
visibility = MaterialPropertyGroupVisibility_Hidden
|
||||
end
|
||||
|
||||
context:SetMaterialPropertyGroupVisibility(layerNamePrefix .. "baseColor", visibility)
|
||||
context:SetMaterialPropertyGroupVisibility(layerNamePrefix .. "metallic", visibility)
|
||||
context:SetMaterialPropertyGroupVisibility(layerNamePrefix .. "roughness", visibility)
|
||||
context:SetMaterialPropertyGroupVisibility(layerNamePrefix .. "specularF0", visibility)
|
||||
context:SetMaterialPropertyGroupVisibility(layerNamePrefix .. "normal", visibility)
|
||||
context:SetMaterialPropertyGroupVisibility(layerNamePrefix .. "clearCoat", visibility)
|
||||
context:SetMaterialPropertyGroupVisibility(layerNamePrefix .. "occlusion", visibility)
|
||||
context:SetMaterialPropertyGroupVisibility(layerNamePrefix .. "emissive", visibility)
|
||||
context:SetMaterialPropertyGroupVisibility(layerNamePrefix .. "parallax", visibility)
|
||||
context:SetMaterialPropertyGroupVisibility(layerNamePrefix .. "uv", visibility)
|
||||
end
|
||||
|
||||
function ProcessEditor(context)
|
||||
local enableLayer2 = context:GetMaterialPropertyValue_bool("blend.enableLayer2")
|
||||
local enableLayer3 = context:GetMaterialPropertyValue_bool("blend.enableLayer3")
|
||||
|
||||
SetLayerVisibility(context, "layer2_", context:GetMaterialPropertyValue_bool("blend.enableLayer2"))
|
||||
SetLayerVisibility(context, "layer3_", context:GetMaterialPropertyValue_bool("blend.enableLayer3"))
|
||||
end
|
||||
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/RTTI/ReflectContext.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialPropertyValue.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
{
|
||||
// Normally we wouldn't want editor-related code mixed in with runtime code, but
|
||||
// since this data can be modified dynamically, keeping it in the runtime makes
|
||||
// the overall material functor design simpler and more user-friendly.
|
||||
|
||||
|
||||
//! Visibility for each material property.
|
||||
//! If the data field is empty, use default as editable.
|
||||
enum class MaterialPropertyVisibility : uint32_t
|
||||
{
|
||||
Enabled, //!< The property is visible and editable
|
||||
Disabled, //!< The property is visible but non-editable
|
||||
Hidden, //!< The property is invisible
|
||||
|
||||
Default = Enabled
|
||||
};
|
||||
|
||||
struct MaterialPropertyRange
|
||||
{
|
||||
MaterialPropertyRange() = default;
|
||||
MaterialPropertyRange(
|
||||
const MaterialPropertyValue& max,
|
||||
const MaterialPropertyValue& min,
|
||||
const MaterialPropertyValue& softMax,
|
||||
const MaterialPropertyValue& softMin
|
||||
)
|
||||
: m_max(max)
|
||||
, m_min(min)
|
||||
, m_softMax(softMax)
|
||||
, m_softMin(softMin)
|
||||
{}
|
||||
|
||||
MaterialPropertyValue m_max;
|
||||
MaterialPropertyValue m_min;
|
||||
MaterialPropertyValue m_softMax;
|
||||
MaterialPropertyValue m_softMin;
|
||||
};
|
||||
|
||||
//! Used by material functors to dynamically control property metadata in tools.
|
||||
//! For example, show/hide a property based on some other 'enable' flag property.
|
||||
struct MaterialPropertyDynamicMetadata
|
||||
{
|
||||
AZ_TYPE_INFO(MaterialPropertyDynamicMetadata, "{A89F215F-3235-499F-896C-9E63ACC1D657}");
|
||||
|
||||
AZ::RPI::MaterialPropertyVisibility m_visibility;
|
||||
AZStd::string m_description;
|
||||
AZ::RPI::MaterialPropertyRange m_propertyRange;
|
||||
};
|
||||
|
||||
//! Visibility for each material property group.
|
||||
enum class MaterialPropertyGroupVisibility : uint32_t
|
||||
{
|
||||
// Note it's helpful to keep these values aligned with MaterialPropertyVisibility in part because in lua it would be easy to accidentally use
|
||||
// MaterialPropertyVisibility instead of MaterialPropertyGroupVisibility resulting in sneaky bugs. Also, if the enums end up being the same in
|
||||
// the future, we could just merge them into one.
|
||||
|
||||
Enabled, //!< The property is visible and editable
|
||||
//Disabled, //!< The property is visible but non-editable (reserved for possible future use, to match MaterialPropertyVisibility)
|
||||
Hidden=2, //!< The property is invisible
|
||||
|
||||
Default = Enabled
|
||||
};
|
||||
|
||||
//! Used by material functors to dynamically control property group metadata in tools.
|
||||
//! For example, show/hide an entire property group based on some 'enable' flag property.
|
||||
struct MaterialPropertyGroupDynamicMetadata
|
||||
{
|
||||
AZ_TYPE_INFO(MaterialPropertyGroupDynamicMetadata, "{F94009F7-48A3-4CE0-AF64-D5A86890ACD4}");
|
||||
|
||||
AZ::RPI::MaterialPropertyGroupVisibility m_visibility;
|
||||
};
|
||||
|
||||
void ReflectMaterialDynamicMetadata(ReflectContext* context);
|
||||
|
||||
} // namespace RPI
|
||||
|
||||
AZ_TYPE_INFO_SPECIALIZE(RPI::MaterialPropertyVisibility, "{318B43A2-79E3-4502-8FD0-5815209EA123}");
|
||||
AZ_TYPE_INFO_SPECIALIZE(RPI::MaterialPropertyGroupVisibility, "{B803958B-DE64-4FBF-AC00-CF781611BE37}");
|
||||
} // namespace AZ
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Reflect/Material/MaterialDynamicMetadata.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace RPI
|
||||
{
|
||||
void ReflectMaterialDynamicMetadata(ReflectContext* context)
|
||||
{
|
||||
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Enum<MaterialPropertyVisibility>()
|
||||
->Value("Enabled", MaterialPropertyVisibility::Enabled)
|
||||
->Value("Disabled", MaterialPropertyVisibility::Disabled)
|
||||
->Value("Hidden", MaterialPropertyVisibility::Hidden)
|
||||
;
|
||||
|
||||
serializeContext->Enum<MaterialPropertyGroupVisibility>()
|
||||
->Value("Enabled", MaterialPropertyGroupVisibility::Enabled)
|
||||
->Value("Hidden", MaterialPropertyGroupVisibility::Hidden)
|
||||
;
|
||||
}
|
||||
|
||||
if (auto* behaviorContext = azrtti_cast<BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext
|
||||
->Enum<(int)MaterialPropertyVisibility::Enabled>("MaterialPropertyVisibility_Enabled")
|
||||
->Enum<(int)MaterialPropertyVisibility::Disabled>("MaterialPropertyVisibility_Disabled")
|
||||
->Enum<(int)MaterialPropertyVisibility::Hidden>("MaterialPropertyVisibility_Hidden");
|
||||
|
||||
behaviorContext
|
||||
->Enum<(int)MaterialPropertyGroupVisibility::Enabled>("MaterialPropertyGroupVisibility_Enabled")
|
||||
->Enum<(int)MaterialPropertyGroupVisibility::Hidden>("MaterialPropertyGroupVisibility_Hidden");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace RPI
|
||||
} // namespace AZ
|
||||
Loading…
Reference in New Issue