8fbd2aaaf5
Simplified the call back for MaterialTypeSourceData::EnumeratePropertyGroups while also providing more data. Made the Material Inspector join nested property group display names to be like "Layer 1 | Base Color", since the leaf property groups are shown as a flat list in the inspector. Fixed CreateMaterialAssetFromSourceData to include the imported json files in the list of sourceDependencies. This triggers the Material Editor to hot-reload when one of these json files changes. Updated a few places that were still assuming only one level of property group. Updated EditorMaterialComponentInspector to apply the per-property-group material functors, before it was still only applying the top-level onces. Moved some accessor function implementations to the cpp files, per feedback on another already-merged PR. Testing: Made changes to MinimalMultilayerPbr (in AtomSampleViewer) to use nested property groups, and saw the correct behavior in the Material Editor's property inspector. Used MaterialComponent's property inspector to edit a StandardPbr material instance. Confrimed that functors were correctly controlling property visibility by enabling and disabling things like emissive and clear coat. Used MaterialComponent's property inspector to edit a MinimalMultilayerPbr material instance. Saw all the expected groups and properties show up. Confirmed that per-group functors were correctly controlling property visibility. Used MaterialComponent's property inspector to export a material instance and confirmed the .material file included the expected properties. Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
137 lines
4.2 KiB
C++
137 lines
4.2 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#include <Atom/RPI.Reflect/Material/MaterialNameContext.h>
|
|
#include <AzCore/RTTI/ReflectContext.h>
|
|
#include <AzCore/Serialization/SerializeContext.h>
|
|
#include <AzCore/Name/Name.h>
|
|
|
|
namespace AZ
|
|
{
|
|
namespace RPI
|
|
{
|
|
void MaterialNameContext::Reflect(ReflectContext* context)
|
|
{
|
|
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
|
|
{
|
|
serializeContext->Class<MaterialNameContext>()
|
|
->Version(1)
|
|
->Field("propertyIdContext", &MaterialNameContext::m_propertyIdContext)
|
|
->Field("srgInputNameContext", &MaterialNameContext::m_srgInputNameContext)
|
|
->Field("shaderOptionNameContext", &MaterialNameContext::m_shaderOptionNameContext)
|
|
;
|
|
}
|
|
}
|
|
|
|
bool MaterialNameContext::IsDefault() const
|
|
{
|
|
return m_propertyIdContext.empty() && m_srgInputNameContext.empty() && m_shaderOptionNameContext.empty();
|
|
}
|
|
|
|
void MaterialNameContext::ExtendPropertyIdContext(AZStd::string_view nameContext, bool insertDelimiter)
|
|
{
|
|
m_propertyIdContext += nameContext;
|
|
if (insertDelimiter && !nameContext.empty() && !nameContext.ends_with("."))
|
|
{
|
|
m_propertyIdContext += ".";
|
|
}
|
|
}
|
|
|
|
void MaterialNameContext::ExtendSrgInputContext(AZStd::string_view nameContext)
|
|
{
|
|
m_srgInputNameContext += nameContext;
|
|
}
|
|
|
|
void MaterialNameContext::ExtendShaderOptionContext(AZStd::string_view nameContext)
|
|
{
|
|
m_shaderOptionNameContext += nameContext;
|
|
}
|
|
|
|
bool MaterialNameContext::ContextualizeProperty(Name& propertyName) const
|
|
{
|
|
if (m_propertyIdContext.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
propertyName = m_propertyIdContext + propertyName.GetCStr();
|
|
return true;
|
|
}
|
|
|
|
bool MaterialNameContext::ContextualizeSrgInput(Name& srgInputName) const
|
|
{
|
|
if (m_srgInputNameContext.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
srgInputName = m_srgInputNameContext + srgInputName.GetCStr();
|
|
return true;
|
|
}
|
|
|
|
bool MaterialNameContext::ContextualizeShaderOption(Name& shaderOptionName) const
|
|
{
|
|
if (m_shaderOptionNameContext.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
shaderOptionName = m_shaderOptionNameContext + shaderOptionName.GetCStr();
|
|
return true;
|
|
}
|
|
|
|
bool MaterialNameContext::ContextualizeProperty(AZStd::string& propertyName) const
|
|
{
|
|
if (m_propertyIdContext.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
propertyName = m_propertyIdContext + propertyName;
|
|
return true;
|
|
}
|
|
|
|
bool MaterialNameContext::ContextualizeSrgInput(AZStd::string& srgInputName) const
|
|
{
|
|
if (m_srgInputNameContext.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
srgInputName = m_srgInputNameContext + srgInputName;
|
|
return true;
|
|
}
|
|
|
|
bool MaterialNameContext::ContextualizeShaderOption(AZStd::string& shaderOptionName) const
|
|
{
|
|
if (m_shaderOptionNameContext.empty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
shaderOptionName = m_shaderOptionNameContext + shaderOptionName;
|
|
return true;
|
|
}
|
|
|
|
bool MaterialNameContext::HasContextForProperties() const
|
|
{
|
|
return !m_propertyIdContext.empty();
|
|
}
|
|
|
|
bool MaterialNameContext::HasContextForSrgInputs() const
|
|
{
|
|
return !m_srgInputNameContext.empty();
|
|
}
|
|
|
|
bool MaterialNameContext::HasContextForShaderOptions() const
|
|
{
|
|
return !m_shaderOptionNameContext.empty();
|
|
}
|
|
} // namespace RPI
|
|
} // namespace AZ
|