From a71a5746ccd6734a68b8c592cab757879993301f Mon Sep 17 00:00:00 2001
From: sphrose <82213493+sphrose@users.noreply.github.com>
Date: Tue, 13 Apr 2021 17:15:10 +0100
Subject: [PATCH 001/163] [LY-113714] Jira: LY-113714
https://jira.agscollab.com/browse/LY-113714
---
.../Serialization/EditContextConstants.inl | 2 +
.../Components/img/UI20/line.svg | 7 ++++
.../AzQtComponents/Components/resources.qrc | 1 +
.../UI/PropertyEditor/PropertyRowWidget.cpp | 37 ++++++++++++++++++-
.../UI/PropertyEditor/PropertyRowWidget.hxx | 8 ++++
Code/Sandbox/Editor/Style/Editor.qss | 5 +++
Gems/Vegetation/Code/Source/Descriptor.cpp | 2 +
7 files changed, 61 insertions(+), 1 deletion(-)
create mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg
diff --git a/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl b/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl
index d4658d4e8c..de67013741 100644
--- a/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl
+++ b/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl
@@ -62,6 +62,8 @@ namespace AZ
const static AZ::Crc32 ButtonTooltip = AZ_CRC("ButtonTooltip", 0x1605a7d2);
const static AZ::Crc32 CheckboxTooltip = AZ_CRC("CheckboxTooltip", 0x1159eb78);
const static AZ::Crc32 CheckboxDefaultValue = AZ_CRC("CheckboxDefaultValue", 0x03f117e6);
+ //! Emboldens the text and adds a line above this item within the RPE.
+ const static AZ::Crc32 RPESectionSeparator = AZ_CRC("RPESectionSeparator", 0xc6249a95);
//! Affects the display order of a node relative to it's parent/children. Higher values display further down (after) lower values. Default is 0, negative values are allowed. Must be applied as an attribute to the EditorData element
const static AZ::Crc32 DisplayOrder = AZ_CRC("DisplayOrder", 0x23660ec2);
//! Specifies whether the UI should support multi-edit for aggregate instances of this property
diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg
new file mode 100644
index 0000000000..60f7c07c8d
--- /dev/null
+++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc b/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc
index 77dead96a1..decc1bd72f 100644
--- a/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc
+++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc
@@ -627,6 +627,7 @@
img/UI20/Settings.svg
img/UI20/Asset_Folder.svg
img/UI20/Asset_File.svg
+ img/UI20/line.svg
img/UI20/AssetEditor/default_document.svg
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
index 8c371baf8c..a16c1f7480 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
@@ -44,6 +44,24 @@ namespace AzToolsFramework
m_iconOpen = s_iconOpen;
m_iconClosed = s_iconClosed;
+ m_outerLayout = new QVBoxLayout(nullptr);
+ m_outerLayout->setSpacing(0);
+ m_outerLayout->setContentsMargins(0, 0, 0, 0);
+
+ // separatorLayout will contain a spacer and a separator line. The width of the spacer is adjusted later to ensure the line is the
+ // correct length.
+ QHBoxLayout* separatorLayout = new QHBoxLayout(nullptr);
+ m_outerLayout->addLayout(separatorLayout);
+
+ m_separatorIndent = new QSpacerItem(1, 1);
+ separatorLayout->addItem(m_separatorIndent);
+
+ m_separatorLine.load(QStringLiteral(":/Gallery/line.svg"));
+ m_separatorLine.setFixedHeight(3);
+
+ separatorLayout->addWidget(&m_separatorLine);
+ m_separatorLine.setVisible(false);
+
m_mainLayout = new QHBoxLayout();
m_mainLayout->setSpacing(0);
m_mainLayout->setContentsMargins(0, 1, 0, 1);
@@ -118,7 +136,8 @@ namespace AzToolsFramework
m_handler = nullptr;
m_containerSize = 0;
- setLayout(m_mainLayout);
+ m_outerLayout->addLayout(m_mainLayout);
+ setLayout(m_outerLayout);
}
bool PropertyRowWidget::HasChildWidgetAlready() const
@@ -301,6 +320,9 @@ namespace AzToolsFramework
}
}
+ m_isSectionSeparator = false;
+ m_separatorLine.setVisible(false);
+
RefreshAttributesFromNode(true);
// --------------------- HANDLER discovery:
@@ -946,6 +968,11 @@ namespace AzToolsFramework
{
HandleChangeNotifyAttribute(reader, m_sourceNode ? m_sourceNode->GetParent() : nullptr, m_editingCompleteNotifiers);
}
+ else if (attributeName == AZ::Edit::Attributes::RPESectionSeparator)
+ {
+ m_separatorLine.setVisible(true);
+ m_isSectionSeparator = true;
+ }
}
void PropertyRowWidget::SetReadOnlyQueryFunction(const ReadOnlyQueryFunction& readOnlyQueryFunction)
@@ -1070,6 +1097,7 @@ namespace AzToolsFramework
{
m_dropDownArrow->hide();
}
+ m_separatorIndent->changeSize((m_treeDepth * m_treeIndentation) + m_leafIndentation, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_indent->changeSize((m_treeDepth * m_treeIndentation) + m_leafIndentation, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_leftHandSideLayout->invalidate();
m_leftHandSideLayout->update();
@@ -1085,6 +1113,7 @@ namespace AzToolsFramework
connect(m_dropDownArrow, &QCheckBox::clicked, this, &PropertyRowWidget::OnClickedExpansionButton);
}
m_dropDownArrow->show();
+ m_separatorIndent->changeSize((m_treeDepth * m_treeIndentation), 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_indent->changeSize((m_treeDepth * m_treeIndentation), 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_leftHandSideLayout->invalidate();
m_leftHandSideLayout->update();
@@ -1095,6 +1124,7 @@ namespace AzToolsFramework
void PropertyRowWidget::SetIndentSize(int w)
{
+ m_separatorIndent->changeSize(w, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_indent->changeSize(w, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_leftHandSideLayout->invalidate();
m_leftHandSideLayout->update();
@@ -1318,6 +1348,11 @@ namespace AzToolsFramework
return canBeTopLevel(this);
}
+ bool PropertyRowWidget::IsSectionSeparator() const
+ {
+ return m_isSectionSeparator;
+ }
+
bool PropertyRowWidget::GetAppendDefaultLabelToName()
{
return false;
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
index e4b538ccdc..af1b68b66f 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
@@ -25,6 +25,7 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // class '...' needs t
#include
#include
#include
+#include
#include
AZ_POP_DISABLE_WARNING
@@ -44,6 +45,7 @@ namespace AzToolsFramework
Q_PROPERTY(bool hasChildRows READ HasChildRows);
Q_PROPERTY(bool isTopLevel READ IsTopLevel);
Q_PROPERTY(int getLevel READ GetLevel);
+ Q_PROPERTY(bool isSectionSeparator READ IsSectionSeparator);
Q_PROPERTY(bool appendDefaultLabelToName READ GetAppendDefaultLabelToName WRITE AppendDefaultLabelToName)
public:
AZ_CLASS_ALLOCATOR(PropertyRowWidget, AZ::SystemAllocator, 0)
@@ -82,6 +84,7 @@ namespace AzToolsFramework
PropertyRowWidget* GetParentRow() const { return m_parentRow; }
int GetLevel() const;
bool IsTopLevel() const;
+ bool IsSectionSeparator() const;
// Remove the default label and append the text to the name label.
bool GetAppendDefaultLabelToName();
@@ -161,6 +164,9 @@ namespace AzToolsFramework
QHBoxLayout* m_leftHandSideLayout;
QHBoxLayout* m_middleLayout;
QHBoxLayout* m_rightHandSideLayout;
+ QVBoxLayout* m_outerLayout;
+ QSvgWidget m_separatorLine;
+ QSpacerItem* m_separatorIndent;
QPointer m_dropDownArrow;
QPointer m_containerClearButton;
@@ -229,6 +235,8 @@ namespace AzToolsFramework
int m_treeIndentation = 14;
int m_leafIndentation = 16;
+ bool m_isSectionSeparator = false;
+
QIcon m_iconOpen;
QIcon m_iconClosed;
diff --git a/Code/Sandbox/Editor/Style/Editor.qss b/Code/Sandbox/Editor/Style/Editor.qss
index 0c3f64b85c..7887560105 100644
--- a/Code/Sandbox/Editor/Style/Editor.qss
+++ b/Code/Sandbox/Editor/Style/Editor.qss
@@ -38,6 +38,11 @@ AzToolsFramework--ComponentPaletteWidget > QTreeView
background-color: #222222;
}
+AzToolsFramework--PropertyRowWidget[isSectionSeparator="true"] QLabel#Name
+{
+ font-weight: bold;
+}
+
/* Style for visualizing property values overridden from their prefab values */
AzToolsFramework--PropertyRowWidget[IsOverridden=true] #Name QLabel,
AzToolsFramework--ComponentEditorHeader #Title[IsOverridden="true"]
diff --git a/Gems/Vegetation/Code/Source/Descriptor.cpp b/Gems/Vegetation/Code/Source/Descriptor.cpp
index 93a301f073..4fd1037f09 100644
--- a/Gems/Vegetation/Code/Source/Descriptor.cpp
+++ b/Gems/Vegetation/Code/Source/Descriptor.cpp
@@ -170,6 +170,8 @@ namespace Vegetation
{
edit->Class(
"Vegetation Descriptor", "Details used to create vegetation instances")
+ ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
+ ->Attribute(AZ::Edit::Attributes::RPESectionSeparator, true)
// For this ComboBox to actually work, there is a PropertyHandler registration in EditorVegetationSystemComponent.cpp
->DataElement(AZ::Edit::UIHandlers::ComboBox, &Descriptor::m_spawnerType, "Instance Spawner", "The type of instances to spawn")
->Attribute(AZ::Edit::Attributes::GenericValueList, &Descriptor::GetSpawnerTypeList)
From a94700786133526d14971bddfdd87e5d989d8678 Mon Sep 17 00:00:00 2001
From: sphrose <82213493+sphrose@users.noreply.github.com>
Date: Wed, 14 Apr 2021 15:15:42 +0100
Subject: [PATCH 002/163] Darken line
---
.../AzQtComponents/AzQtComponents/Components/img/UI20/line.svg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg
index 60f7c07c8d..fe01efddba 100644
--- a/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg
+++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg
@@ -2,6 +2,6 @@
\ No newline at end of file
From 2dbd9e4a050e141a45c85a12b4d245f0695f581a Mon Sep 17 00:00:00 2001
From: sphrose <82213493+sphrose@users.noreply.github.com>
Date: Mon, 19 Apr 2021 15:54:41 +0100
Subject: [PATCH 003/163] Changed to use direct line drawing rather than adding
svg.
---
.../Components/img/UI20/line.svg | 7 ----
.../UI/PropertyEditor/PropertyRowWidget.cpp | 40 +++++++------------
.../UI/PropertyEditor/PropertyRowWidget.hxx | 4 +-
3 files changed, 16 insertions(+), 35 deletions(-)
delete mode 100644 Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg
diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg b/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg
deleted file mode 100644
index fe01efddba..0000000000
--- a/Code/Framework/AzQtComponents/AzQtComponents/Components/img/UI20/line.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
\ No newline at end of file
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
index a16c1f7480..5b02e81e6d 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
@@ -27,6 +27,7 @@ AZ_PUSH_DISABLE_WARNING(4244 4251 4800, "-Wunknown-warning-option") // 4244: con
#include
#include
#include
+#include
AZ_POP_DISABLE_WARNING
static const int LabelColumnStretch = 2;
@@ -44,24 +45,6 @@ namespace AzToolsFramework
m_iconOpen = s_iconOpen;
m_iconClosed = s_iconClosed;
- m_outerLayout = new QVBoxLayout(nullptr);
- m_outerLayout->setSpacing(0);
- m_outerLayout->setContentsMargins(0, 0, 0, 0);
-
- // separatorLayout will contain a spacer and a separator line. The width of the spacer is adjusted later to ensure the line is the
- // correct length.
- QHBoxLayout* separatorLayout = new QHBoxLayout(nullptr);
- m_outerLayout->addLayout(separatorLayout);
-
- m_separatorIndent = new QSpacerItem(1, 1);
- separatorLayout->addItem(m_separatorIndent);
-
- m_separatorLine.load(QStringLiteral(":/Gallery/line.svg"));
- m_separatorLine.setFixedHeight(3);
-
- separatorLayout->addWidget(&m_separatorLine);
- m_separatorLine.setVisible(false);
-
m_mainLayout = new QHBoxLayout();
m_mainLayout->setSpacing(0);
m_mainLayout->setContentsMargins(0, 1, 0, 1);
@@ -136,8 +119,20 @@ namespace AzToolsFramework
m_handler = nullptr;
m_containerSize = 0;
- m_outerLayout->addLayout(m_mainLayout);
- setLayout(m_outerLayout);
+ setLayout(m_mainLayout);
+ }
+
+ void PropertyRowWidget::paintEvent(QPaintEvent* event)
+ {
+ QStylePainter p(this);
+
+ if (IsSectionSeparator())
+ {
+ const QPen linePen(QColor(0x3B3E3F));
+ p.setPen(linePen);
+ int indent = m_treeDepth * m_treeIndentation;
+ p.drawLine(event->rect().topLeft() + QPoint(indent, 0), event->rect().topRight());
+ }
}
bool PropertyRowWidget::HasChildWidgetAlready() const
@@ -321,7 +316,6 @@ namespace AzToolsFramework
}
m_isSectionSeparator = false;
- m_separatorLine.setVisible(false);
RefreshAttributesFromNode(true);
@@ -970,7 +964,6 @@ namespace AzToolsFramework
}
else if (attributeName == AZ::Edit::Attributes::RPESectionSeparator)
{
- m_separatorLine.setVisible(true);
m_isSectionSeparator = true;
}
}
@@ -1097,7 +1090,6 @@ namespace AzToolsFramework
{
m_dropDownArrow->hide();
}
- m_separatorIndent->changeSize((m_treeDepth * m_treeIndentation) + m_leafIndentation, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_indent->changeSize((m_treeDepth * m_treeIndentation) + m_leafIndentation, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_leftHandSideLayout->invalidate();
m_leftHandSideLayout->update();
@@ -1113,7 +1105,6 @@ namespace AzToolsFramework
connect(m_dropDownArrow, &QCheckBox::clicked, this, &PropertyRowWidget::OnClickedExpansionButton);
}
m_dropDownArrow->show();
- m_separatorIndent->changeSize((m_treeDepth * m_treeIndentation), 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_indent->changeSize((m_treeDepth * m_treeIndentation), 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_leftHandSideLayout->invalidate();
m_leftHandSideLayout->update();
@@ -1124,7 +1115,6 @@ namespace AzToolsFramework
void PropertyRowWidget::SetIndentSize(int w)
{
- m_separatorIndent->changeSize(w, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_indent->changeSize(w, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_leftHandSideLayout->invalidate();
m_leftHandSideLayout->update();
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
index af1b68b66f..d08779caa4 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
@@ -129,6 +129,7 @@ namespace AzToolsFramework
void SetSelectionEnabled(bool selectionEnabled);
void SetSelected(bool selected);
bool eventFilter(QObject *watched, QEvent *event) override;
+ void paintEvent(QPaintEvent*) override;
/// Apply tooltip to widget and some of its children.
void SetDescription(const QString& text);
@@ -164,9 +165,6 @@ namespace AzToolsFramework
QHBoxLayout* m_leftHandSideLayout;
QHBoxLayout* m_middleLayout;
QHBoxLayout* m_rightHandSideLayout;
- QVBoxLayout* m_outerLayout;
- QSvgWidget m_separatorLine;
- QSpacerItem* m_separatorIndent;
QPointer m_dropDownArrow;
QPointer m_containerClearButton;
From b1d8330870f31399d05aa0c1d1b28e5f55512580 Mon Sep 17 00:00:00 2001
From: sphrose <82213493+sphrose@users.noreply.github.com>
Date: Tue, 20 Apr 2021 17:20:19 +0100
Subject: [PATCH 004/163] Review fixes.
---
.../AzQtComponents/AzQtComponents/Components/resources.qrc | 1 -
.../AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx | 1 -
2 files changed, 2 deletions(-)
diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc b/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc
index e253c6492d..f9e601fb6d 100644
--- a/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc
+++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/resources.qrc
@@ -630,7 +630,6 @@
img/UI20/Settings.svg
img/UI20/Asset_Folder.svg
img/UI20/Asset_File.svg
- img/UI20/line.svg
img/UI20/AssetEditor/default_document.svg
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
index d08779caa4..2fb695fca5 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
@@ -25,7 +25,6 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // class '...' needs t
#include
#include
#include
-#include
#include
AZ_POP_DISABLE_WARNING
From 304696fa5cc59b3b517d5545844d2d25d35ee610 Mon Sep 17 00:00:00 2001
From: moudgils
Date: Tue, 27 Apr 2021 19:26:35 -0700
Subject: [PATCH 005/163] Shader compile fixes
---
.../DiffuseComposite_nomsaa.azsl | 8 ++++----
Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl
index 74571b5c6a..c243af0855 100644
--- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl
@@ -91,7 +91,7 @@ float3 SampleProbeIrradiance(uint2 probeIrradianceCoords, float depth, float3 no
{
for (int x = -extent; x <= extent; ++x)
{
- float3 downsampledNormal = PassSrg::m_downsampledNormal.Load(int3(probeIrradianceCoords, 0), int2(x, y)).rgb;
+ float3 downsampledNormal = PassSrg::m_downsampledNormal.Load(int3(probeIrradianceCoords + int2(x, y), 0)).rgb;
downsampledNormal = downsampledNormal * 2.0f - 1.0f;
float normalDot = dot(downsampledNormal, normal);
@@ -100,10 +100,10 @@ float3 SampleProbeIrradiance(uint2 probeIrradianceCoords, float depth, float3 no
if (normalDot > NormalMatchTolerance)
{
// the normals are almost identical, if the depth is within the tolerance we can optimize by just taking this sample
- float downsampledDepth = PassSrg::m_downsampledDepth.Load(int3(probeIrradianceCoords, 0), int2(x, y)).r;
+ float downsampledDepth = PassSrg::m_downsampledDepth.Load(int3(probeIrradianceCoords + int2(x, y), 0)).r;
if (abs(depth - downsampledDepth) <= DepthTolerance)
{
- float3 probeIrradiance = PassSrg::m_downsampledProbeIrradiance.Load(int3(probeIrradianceCoords,0), int2(x, y)).rgb;
+ float3 probeIrradiance = PassSrg::m_downsampledProbeIrradiance.Load(int3(probeIrradianceCoords + int2(x, y),0)).rgb;
probeIrradiance = saturate(probeIrradiance);
return probeIrradiance;
}
@@ -115,7 +115,7 @@ float3 SampleProbeIrradiance(uint2 probeIrradianceCoords, float depth, float3 no
}
}
- float3 probeIrradiance = PassSrg::m_downsampledProbeIrradiance.Load(int3(probeIrradianceCoords, 0), closestOffset).rgb;
+ float3 probeIrradiance = PassSrg::m_downsampledProbeIrradiance.Load(int3(probeIrradianceCoords + closestOffset, 0)).rgb;
probeIrradiance = saturate(probeIrradiance);
return probeIrradiance;
}
diff --git a/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp b/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp
index 00b5dada69..957c076592 100644
--- a/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp
+++ b/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp
@@ -308,7 +308,7 @@ namespace AZ
uint32_t exitCode = 0;
bool timedOut = false;
- const AZStd::sys_time_t maxWaitTimeSeconds = 120;
+ const AZStd::sys_time_t maxWaitTimeSeconds = 240;
const AZStd::sys_time_t startTimeSeconds = AZStd::GetTimeNowSecond();
const AZStd::sys_time_t startTime = AZStd::GetTimeNowTicks();
From 12d5288e32ea98420d2585498e2d5fb02c731963 Mon Sep 17 00:00:00 2001
From: puvvadar
Date: Wed, 28 Apr 2021 15:15:14 -0700
Subject: [PATCH 006/163] Add codegen for BehaviorContext binding of RPC Send
functions
---
.../Source/AutoGen/AutoComponent_Header.jinja | 1 +
.../Source/AutoGen/AutoComponent_Source.jinja | 34 +++++++++++++++++++
...tionPlayerInputComponent.AutoComponent.xml | 6 ++--
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja
index f5774b07c0..b2d2792e9b 100644
--- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja
+++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Header.jinja
@@ -416,6 +416,7 @@ namespace {{ Component.attrib['Namespace'] }}
static void Reflect(AZ::ReflectContext* context);
static void ReflectToEditContext(AZ::ReflectContext* context);
+ static void ReflectToBehaviorContext(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
diff --git a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja
index d6907876e1..f2d6ca71c6 100644
--- a/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja
+++ b/Gems/Multiplayer/Code/Source/AutoGen/AutoComponent_Source.jinja
@@ -315,6 +315,22 @@ void {{ ClassName }}::{{ UpperFirst(Property.attrib['Name']) }}({{ ', '.join(par
{% endmacro %}
{#
+#}
+{% macro ReflectRpcInvocations(Component, ClassName, InvokeFrom, HandleOn) %}
+{% call(Property) AutoComponentMacros.ParseRemoteProcedures(Component, InvokeFrom, HandleOn) %}
+{% if Property.attrib['CanScript']|booleanTrue == true %}
+{% set paramNames = [] %}
+{% set paramTypes = [] %}
+{% set paramDefines = [] %}
+{{ AutoComponentMacros.ParseRpcParams(Property, paramNames, paramTypes, paramDefines) }}
+ ->Method("{{ UpperFirst(Property.attrib['Name']) }}", [](const {{ ClassName }}* self, {{ ', '.join(paramDefines) }}) {
+ self->m_controller->{{ UpperFirst(Property.attrib['Name']) }}({{ ', '.join(paramNames) }});
+ })
+{% endif %}
+{% endcall %}
+{% endmacro %}
+{#
+
#}
{% macro DeclareRpcHandleCases(Component, ComponentDerived, InvokeFrom, HandleOn, ValidationFunction) %}
{% call(Property) AutoComponentMacros.ParseRemoteProcedures(Component, InvokeFrom, HandleOn) %}
@@ -1114,6 +1130,7 @@ namespace {{ Component.attrib['Namespace'] }}
{{ DefineArchetypePropertyReflection(Component, ComponentBaseName)|indent(16) }};
}
ReflectToEditContext(context);
+ ReflectToBehaviorContext(context);
}
void {{ ComponentBaseName }}::{{ ComponentBaseName }}::ReflectToEditContext(AZ::ReflectContext* context)
@@ -1138,6 +1155,23 @@ namespace {{ Component.attrib['Namespace'] }}
}
}
+ void {{ ComponentBaseName }}::{{ ComponentBaseName }}::ReflectToBehaviorContext(AZ::ReflectContext* context)
+ {
+ AZ::BehaviorContext* behaviorContext = azrtti_cast(context);
+ if (behaviorContext)
+ {
+ behaviorContext->Class<{{ ComponentName }}>("{{ ComponentName }}")
+ ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
+ ->Attribute(AZ::Script::Attributes::Category, "Multiplayer")
+ ->Attribute(AZ::Script::Attributes::Module, "Multiplayer")
+ {{ ReflectRpcInvocations(Component, ComponentName, 'Server', 'Authority')|indent(4) -}}
+ {{ ReflectRpcInvocations(Component, ComponentName, 'Autonomous', 'Authority')|indent(4) -}}
+ {{ ReflectRpcInvocations(Component, ComponentName, 'Authority', 'Autonomous')|indent(4) -}}
+ {{ ReflectRpcInvocations(Component, ComponentName, 'Authority', 'Client')|indent(4) -}}
+ ;
+ }
+ }
+
void {{ ComponentBaseName }}::{{ ComponentBaseName }}::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC_CE("{{ ComponentName }}Service"));
diff --git a/Gems/Multiplayer/Code/Source/AutoGen/LocalPredictionPlayerInputComponent.AutoComponent.xml b/Gems/Multiplayer/Code/Source/AutoGen/LocalPredictionPlayerInputComponent.AutoComponent.xml
index d38ebbb1b8..336909a102 100644
--- a/Gems/Multiplayer/Code/Source/AutoGen/LocalPredictionPlayerInputComponent.AutoComponent.xml
+++ b/Gems/Multiplayer/Code/Source/AutoGen/LocalPredictionPlayerInputComponent.AutoComponent.xml
@@ -18,18 +18,18 @@
-
+
-
+
-
+
From 2f4120cdfbbd736d18fdc5f3187a94f6640ed28b Mon Sep 17 00:00:00 2001
From: puvvadar
Date: Mon, 3 May 2021 13:07:11 -0700
Subject: [PATCH 007/163] Update Ctrl+G logic to account for prefab processing
status and timing
---
.../PrefabEditorEntityOwnershipInterface.h | 2 +
.../PrefabEditorEntityOwnershipService.cpp | 5 ++
.../PrefabEditorEntityOwnershipService.h | 2 +
Gems/Multiplayer/Code/CMakeLists.txt | 1 +
.../Code/Include/IMultiplayerTools.h | 39 ++++++++++++
.../MultiplayerEditorSystemComponent.cpp | 63 ++++++++++++-------
.../Editor/MultiplayerEditorSystemComponent.h | 12 +++-
.../Code/Source/MultiplayerToolsModule.cpp | 35 ++++-------
.../Code/Source/MultiplayerToolsModule.h | 27 ++++++++
.../Pipeline/NetworkPrefabProcessor.cpp | 3 +
.../Code/multiplayer_tools_files.cmake | 1 +
11 files changed, 142 insertions(+), 48 deletions(-)
create mode 100644 Gems/Multiplayer/Code/Include/IMultiplayerTools.h
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h
index 19c236f509..4476876b59 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipInterface.h
@@ -46,6 +46,8 @@ namespace AzToolsFramework
virtual Prefab::InstanceOptionalReference GetRootPrefabInstance() = 0;
+ virtual const AZStd::vector>& GetPlayInEditorAssetData() = 0;
+
virtual bool LoadFromStream(AZ::IO::GenericStream& stream, AZStd::string_view filename) = 0;
virtual bool SaveToStream(AZ::IO::GenericStream& stream, AZStd::string_view filename) = 0;
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp
index 81233069a9..e81d6bf08e 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp
@@ -321,6 +321,11 @@ namespace AzToolsFramework
return *m_rootInstance;
}
+ const AZStd::vector>& PrefabEditorEntityOwnershipService::GetPlayInEditorAssetData()
+ {
+ return m_playInEditorData.m_assets;
+ }
+
void PrefabEditorEntityOwnershipService::OnEntityRemoved(AZ::EntityId entityId)
{
AzFramework::SliceEntityRequestBus::MultiHandler::BusDisconnect(entityId);
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h
index 9c483e61c5..cf62220e67 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h
@@ -195,6 +195,8 @@ namespace AzToolsFramework
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder) override;
Prefab::InstanceOptionalReference GetRootPrefabInstance() override;
+
+ const AZStd::vector>& GetPlayInEditorAssetData() override;
//////////////////////////////////////////////////////////////////////////
void OnEntityRemoved(AZ::EntityId entityId);
diff --git a/Gems/Multiplayer/Code/CMakeLists.txt b/Gems/Multiplayer/Code/CMakeLists.txt
index 4eeee15c47..46f56ef315 100644
--- a/Gems/Multiplayer/Code/CMakeLists.txt
+++ b/Gems/Multiplayer/Code/CMakeLists.txt
@@ -119,6 +119,7 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS)
BUILD_DEPENDENCIES
PRIVATE
Gem::Multiplayer.Editor.Static
+ Gem::Multiplayer.Tools
)
endif()
diff --git a/Gems/Multiplayer/Code/Include/IMultiplayerTools.h b/Gems/Multiplayer/Code/Include/IMultiplayerTools.h
new file mode 100644
index 0000000000..c621808f7a
--- /dev/null
+++ b/Gems/Multiplayer/Code/Include/IMultiplayerTools.h
@@ -0,0 +1,39 @@
+/*
+* 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
+
+namespace Multiplayer
+{
+ //! IMultiplayer provides insight into the Multiplayer session and its Agents
+ class IMultiplayerTools
+ {
+ public:
+ // NetworkPrefabProcessor is the only class that should be setting process network prefab status
+ friend class NetworkPrefabProcessor;
+
+ AZ_RTTI(IMultiplayerTools, "{E8A80EAB-29CB-4E3B-A0B2-FFCB37060FB0}");
+
+ virtual ~IMultiplayerTools() = default;
+
+ //! Returns if network prefab processing has created currently active or pending spawnables
+ //! @return If network prefab processing has created currently active or pending spawnables
+ virtual bool DidProcessNetworkPrefabs() = 0;
+
+ private:
+ //! Sets if network prefab processing has created currently active or pending spawnables
+ //! @param didProcessNetPrefabs if network prefab processing has created currently active or pending spawnables
+ virtual void SetDidProcessNetworkPrefabs(bool didProcessNetPrefabs) = 0;
+ };
+}
diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp
index aec3e7870f..0850b858a2 100644
--- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp
+++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp
@@ -10,12 +10,14 @@
*
*/
+#include
#include
#include
#include
#include
#include
#include
+#include
namespace Multiplayer
{
@@ -57,12 +59,14 @@ namespace Multiplayer
void MultiplayerEditorSystemComponent::Activate()
{
+ AzFramework::GameEntityContextEventBus::Handler::BusConnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
}
void MultiplayerEditorSystemComponent::Deactivate()
{
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
+ AzFramework::GameEntityContextEventBus::Handler::BusDisconnect();
}
void MultiplayerEditorSystemComponent::NotifyRegisterViews()
@@ -77,11 +81,42 @@ namespace Multiplayer
{
switch (event)
{
- case eNotify_OnBeginGameMode:
- {
+ case eNotify_OnQuit:
+ AZ_Warning("Multiplayer Editor", m_editor != nullptr, "Multiplayer Editor received On Quit without an Editor pointer.");
+ if (m_editor)
+ {
+ m_editor->UnregisterNotifyListener(this);
+ m_editor = nullptr;
+ }
+ [[fallthrough]];
+ case eNotify_OnEndGameMode:
+ AZ::TickBus::Handler::BusDisconnect();
+ // Kill the configured server if it's active
+ if (m_serverProcess)
+ {
+ m_serverProcess->TerminateProcess(0);
+ m_serverProcess = nullptr;
+ }
+ break;
+ }
+ }
+
+ void MultiplayerEditorSystemComponent::OnGameEntitiesStarted()
+ {
+ // BeginGameMode and Prefab Processing have completed at this point
+ IMultiplayerTools* mpTools = AZ::Interface::Get();
+ if (editorsv_enabled && mpTools != nullptr && mpTools->DidProcessNetworkPrefabs())
+ {
AZ::TickBus::Handler::BusConnect();
- if (editorsv_enabled)
+ auto prefabEditorEntityOwnershipInterface = AZ::Interface::Get();
+ if (!prefabEditorEntityOwnershipInterface)
+ {
+ AZ_Error("MultiplayerEditor", prefabEditorEntityOwnershipInterface != nullptr, "PrefabEditorEntityOwnershipInterface unavailable");
+ }
+ const AZStd::vector>& assetData = prefabEditorEntityOwnershipInterface->GetPlayInEditorAssetData();
+
+ if (assetData.size() > 0)
{
// Assemble the server's path
AZ::CVarFixedString serverProcess = editorsv_process;
@@ -111,33 +146,13 @@ namespace Multiplayer
// Start the configured server if it's available
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
- processLaunchInfo.m_commandlineParameters =
- AZStd::string::format("\"%s\"", serverPath.c_str());
+ processLaunchInfo.m_commandlineParameters = AZStd::string::format("\"%s\"", serverPath.c_str());
processLaunchInfo.m_showWindow = true;
processLaunchInfo.m_processPriority = AzFramework::ProcessPriority::PROCESSPRIORITY_NORMAL;
m_serverProcess = AzFramework::ProcessWatcher::LaunchProcess(
processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE);
}
- break;
- }
- case eNotify_OnQuit:
- AZ_Warning("Multiplayer Editor", m_editor != nullptr, "Multiplayer Editor received On Quit without an Editor pointer.");
- if (m_editor)
- {
- m_editor->UnregisterNotifyListener(this);
- m_editor = nullptr;
- }
- [[fallthrough]];
- case eNotify_OnEndGameMode:
- AZ::TickBus::Handler::BusDisconnect();
- // Kill the configured server if it's active
- if (m_serverProcess)
- {
- m_serverProcess->TerminateProcess(0);
- m_serverProcess = nullptr;
- }
- break;
}
}
diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h
index 8c18a2e57a..31ecdf83a3 100644
--- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h
+++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h
@@ -19,6 +19,7 @@
#include
#include
+#include
#include
#include
@@ -34,6 +35,7 @@ namespace Multiplayer
class MultiplayerEditorSystemComponent final
: public AZ::Component
, private AZ::TickBus::Handler
+ , private AzFramework::GameEntityContextEventBus::Handler
, private AzToolsFramework::EditorEvents::Bus::Handler
, private IEditorNotifyListener
{
@@ -66,8 +68,16 @@ namespace Multiplayer
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
int GetTickOrder() override;
//! @}
- //!
+
+ //! EditorEvents::Handler overrides
+ //! @{
void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
+ //! @}
+
+ //! GameEntityContextEventBus::Handler overrides
+ //! @{
+ void OnGameEntitiesStarted() override;
+ //! @}
IEditor* m_editor = nullptr;
AzFramework::ProcessWatcher* m_serverProcess = nullptr;
diff --git a/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.cpp b/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.cpp
index 5a223d6214..a5df3c1dc5 100644
--- a/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.cpp
+++ b/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.cpp
@@ -18,32 +18,21 @@
namespace Multiplayer
{
- //! Multiplayer Tools system component provides serialize context reflection for tools-only systems.
- class MultiplayerToolsSystemComponent final
- : public AZ::Component
+
+ void MultiplayerToolsSystemComponent::Reflect(AZ::ReflectContext* context)
{
- public:
- AZ_COMPONENT(MultiplayerToolsSystemComponent, "{65AF5342-0ECE-423B-B646-AF55A122F72B}");
+ NetworkPrefabProcessor::Reflect(context);
+ }
- static void Reflect(AZ::ReflectContext* context)
- {
- NetworkPrefabProcessor::Reflect(context);
- }
+ bool MultiplayerToolsSystemComponent::DidProcessNetworkPrefabs()
+ {
+ return m_didProcessNetPrefabs;
+ }
- MultiplayerToolsSystemComponent() = default;
- ~MultiplayerToolsSystemComponent() override = default;
-
- /// AZ::Component overrides.
- void Activate() override
- {
-
- }
-
- void Deactivate() override
- {
-
- }
- };
+ void MultiplayerToolsSystemComponent::SetDidProcessNetworkPrefabs(bool didProcessNetPrefabs)
+ {
+ m_didProcessNetPrefabs = didProcessNetPrefabs;
+ }
MultiplayerToolsModule::MultiplayerToolsModule()
: AZ::Module()
diff --git a/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.h b/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.h
index 823bd63a1d..82d0415c5a 100644
--- a/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.h
+++ b/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.h
@@ -12,10 +12,37 @@
#pragma once
+#include
#include
+#include
namespace Multiplayer
{
+ class MultiplayerToolsSystemComponent final
+ : public AZ::Component
+ , public IMultiplayerTools
+ {
+ public:
+ AZ_COMPONENT(MultiplayerToolsSystemComponent, "{65AF5342-0ECE-423B-B646-AF55A122F72B}");
+
+ static void Reflect(AZ::ReflectContext* context);
+
+ MultiplayerToolsSystemComponent() = default;
+ ~MultiplayerToolsSystemComponent() override = default;
+
+ /// AZ::Component overrides.
+ void Activate() override {};
+
+ void Deactivate() override {};
+
+ bool DidProcessNetworkPrefabs() override;
+
+ private:
+ void SetDidProcessNetworkPrefabs(bool didProcessNetPrefabs) override;
+
+ bool m_didProcessNetPrefabs = false;
+ };
+
class MultiplayerToolsModule
: public AZ::Module
{
diff --git a/Gems/Multiplayer/Code/Source/Pipeline/NetworkPrefabProcessor.cpp b/Gems/Multiplayer/Code/Source/Pipeline/NetworkPrefabProcessor.cpp
index 2006272135..8528b3d564 100644
--- a/Gems/Multiplayer/Code/Source/Pipeline/NetworkPrefabProcessor.cpp
+++ b/Gems/Multiplayer/Code/Source/Pipeline/NetworkPrefabProcessor.cpp
@@ -18,6 +18,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -29,6 +30,8 @@ namespace Multiplayer
void NetworkPrefabProcessor::Process(PrefabProcessorContext& context)
{
+ IMultiplayerTools* mpTools = AZ::Interface::Get();
+ mpTools->SetDidProcessNetworkPrefabs(false);
context.ListPrefabs([&context](AZStd::string_view prefabName, PrefabDom& prefab) {
ProcessPrefab(context, prefabName, prefab);
});
diff --git a/Gems/Multiplayer/Code/multiplayer_tools_files.cmake b/Gems/Multiplayer/Code/multiplayer_tools_files.cmake
index 1be02fd999..12f12479ba 100644
--- a/Gems/Multiplayer/Code/multiplayer_tools_files.cmake
+++ b/Gems/Multiplayer/Code/multiplayer_tools_files.cmake
@@ -10,6 +10,7 @@
#
set(FILES
+ Include/IMultiplayerTools.h
Source/Multiplayer_precompiled.cpp
Source/Multiplayer_precompiled.h
Source/Pipeline/NetworkPrefabProcessor.cpp
From 7eb6cc10b6559511927028d9f6c5514b973a99bb Mon Sep 17 00:00:00 2001
From: sphrose <82213493+sphrose@users.noreply.github.com>
Date: Wed, 5 May 2021 08:57:39 +0100
Subject: [PATCH 008/163] Made change affect all modifiable containers.
---
.../Serialization/EditContextConstants.inl | 2 --
.../UI/PropertyEditor/PropertyRowWidget.cpp | 22 +++++++++++++------
.../UI/PropertyEditor/PropertyRowWidget.hxx | 5 +++--
Gems/Vegetation/Code/Source/Descriptor.cpp | 2 --
4 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl b/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl
index 481ae5a91c..90b9ba5afd 100644
--- a/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl
+++ b/Code/Framework/AzCore/AzCore/Serialization/EditContextConstants.inl
@@ -62,8 +62,6 @@ namespace AZ
const static AZ::Crc32 ButtonTooltip = AZ_CRC("ButtonTooltip", 0x1605a7d2);
const static AZ::Crc32 CheckboxTooltip = AZ_CRC("CheckboxTooltip", 0x1159eb78);
const static AZ::Crc32 CheckboxDefaultValue = AZ_CRC("CheckboxDefaultValue", 0x03f117e6);
- //! Emboldens the text and adds a line above this item within the RPE.
- const static AZ::Crc32 RPESectionSeparator = AZ_CRC("RPESectionSeparator", 0xc6249a95);
//! Affects the display order of a node relative to it's parent/children. Higher values display further down (after) lower values. Default is 0, negative values are allowed. Must be applied as an attribute to the EditorData element
const static AZ::Crc32 DisplayOrder = AZ_CRC("DisplayOrder", 0x23660ec2);
//! Specifies whether the UI should support multi-edit for aggregate instances of this property
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
index 5b02e81e6d..faeae0a06d 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
@@ -315,8 +315,6 @@ namespace AzToolsFramework
}
}
- m_isSectionSeparator = false;
-
RefreshAttributesFromNode(true);
// --------------------- HANDLER discovery:
@@ -962,10 +960,6 @@ namespace AzToolsFramework
{
HandleChangeNotifyAttribute(reader, m_sourceNode ? m_sourceNode->GetParent() : nullptr, m_editingCompleteNotifiers);
}
- else if (attributeName == AZ::Edit::Attributes::RPESectionSeparator)
- {
- m_isSectionSeparator = true;
- }
}
void PropertyRowWidget::SetReadOnlyQueryFunction(const ReadOnlyQueryFunction& readOnlyQueryFunction)
@@ -1340,7 +1334,7 @@ namespace AzToolsFramework
bool PropertyRowWidget::IsSectionSeparator() const
{
- return m_isSectionSeparator;
+ return CanBeReordered();
}
bool PropertyRowWidget::GetAppendDefaultLabelToName()
@@ -1686,6 +1680,20 @@ namespace AzToolsFramework
m_nameLabel->setFilter(m_currentFilterString);
}
+ bool PropertyRowWidget::CanChildrenBeReordered() const
+ {
+ return m_containerEditable;
+ }
+
+ bool PropertyRowWidget::CanBeReordered() const
+ {
+ if (!m_parentRow)
+ {
+ return false;
+ }
+
+ return m_parentRow->CanChildrenBeReordered();
+ }
}
#include "UI/PropertyEditor/moc_PropertyRowWidget.cpp"
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
index 2fb695fca5..b6c94dc98b 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
@@ -149,6 +149,9 @@ namespace AzToolsFramework
QLabel* GetNameLabel() { return m_nameLabel; }
void SetIndentSize(int w);
void SetAsCustom(bool custom) { m_custom = custom; }
+
+ bool CanChildrenBeReordered() const;
+ bool CanBeReordered() const;
protected:
int CalculateLabelWidth() const;
@@ -232,8 +235,6 @@ namespace AzToolsFramework
int m_treeIndentation = 14;
int m_leafIndentation = 16;
- bool m_isSectionSeparator = false;
-
QIcon m_iconOpen;
QIcon m_iconClosed;
diff --git a/Gems/Vegetation/Code/Source/Descriptor.cpp b/Gems/Vegetation/Code/Source/Descriptor.cpp
index 45ec25038d..ecda8415e7 100644
--- a/Gems/Vegetation/Code/Source/Descriptor.cpp
+++ b/Gems/Vegetation/Code/Source/Descriptor.cpp
@@ -170,8 +170,6 @@ namespace Vegetation
{
edit->Class(
"Vegetation Descriptor", "Details used to create vegetation instances")
- ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
- ->Attribute(AZ::Edit::Attributes::RPESectionSeparator, true)
// For this ComboBox to actually work, there is a PropertyHandler registration in EditorVegetationSystemComponent.cpp
->DataElement(AZ::Edit::UIHandlers::ComboBox, &Descriptor::m_spawnerType, "Instance Spawner", "The type of instances to spawn")
->Attribute(AZ::Edit::Attributes::GenericValueList, &Descriptor::GetSpawnerTypeList)
From aa51233536a55816324da9d41fff6afe4e3970c9 Mon Sep 17 00:00:00 2001
From: puvvadar
Date: Thu, 6 May 2021 16:18:13 -0700
Subject: [PATCH 009/163] Add Asset serialization for Ctrl+G and related net
interfaces
---
.../AzNetworking/TcpTransport/TcpSocket.cpp | 4 +-
.../AutoGen/Multiplayer.AutoPackets.xml | 6 ++
.../MultiplayerEditorSystemComponent.cpp | 93 +++++++++++++++++--
.../Editor/MultiplayerEditorSystemComponent.h | 2 +
.../Source/MultiplayerSystemComponent.cpp | 21 +++++
.../Code/Source/MultiplayerSystemComponent.h | 4 +-
.../Code/Source/MultiplayerToolsModule.cpp | 10 ++
.../Code/Source/MultiplayerToolsModule.h | 5 +-
8 files changed, 132 insertions(+), 13 deletions(-)
diff --git a/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpSocket.cpp b/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpSocket.cpp
index 78020cb09d..e8c30d0816 100644
--- a/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpSocket.cpp
+++ b/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpSocket.cpp
@@ -116,8 +116,8 @@ namespace AzNetworking
int32_t TcpSocket::Receive(uint8_t* outData, uint32_t size) const
{
- AZ_Assert(size > 0, "Invalid data size for send");
- AZ_Assert(outData != nullptr, "NULL data pointer passed to send");
+ AZ_Assert(size > 0, "Invalid data size for receive");
+ AZ_Assert(outData != nullptr, "NULL data pointer passed to receive");
if (!IsOpen())
{
return SocketOpResultErrorNotOpen;
diff --git a/Gems/Multiplayer/Code/Source/AutoGen/Multiplayer.AutoPackets.xml b/Gems/Multiplayer/Code/Source/AutoGen/Multiplayer.AutoPackets.xml
index 5de466899c..21faefa880 100644
--- a/Gems/Multiplayer/Code/Source/AutoGen/Multiplayer.AutoPackets.xml
+++ b/Gems/Multiplayer/Code/Source/AutoGen/Multiplayer.AutoPackets.xml
@@ -57,4 +57,10 @@
+
+
+
+
+
+
diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp
index 0850b858a2..15f00bdf80 100644
--- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp
+++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.cpp
@@ -10,23 +10,32 @@
*
*/
+#include
#include
+#include
+#include
#include
#include
+#include
#include
#include
#include
#include
+#include
#include
namespace Multiplayer
{
+ static const AZStd::string_view s_networkInterfaceName("MultiplayerEditorServerInterface");
+
using namespace AzNetworking;
AZ_CVAR(bool, editorsv_enabled, false, nullptr, AZ::ConsoleFunctorFlags::DontReplicate,
"Whether Editor launching a local server to connect to is supported");
AZ_CVAR(AZ::CVarFixedString, editorsv_process, "", nullptr, AZ::ConsoleFunctorFlags::DontReplicate,
"The server executable that should be run. Empty to use the current project's ServerLauncher");
+ AZ_CVAR(AZ::CVarFixedString, sv_serveraddr, "127.0.0.1", nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "The address of the server to connect to");
+ AZ_CVAR(uint16_t, sv_port, 30091, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "The port that the multiplayer editor gem will bind to for traffic");
void MultiplayerEditorSystemComponent::Reflect(AZ::ReflectContext* context)
{
@@ -61,6 +70,16 @@ namespace Multiplayer
{
AzFramework::GameEntityContextEventBus::Handler::BusConnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
+
+ // Setup a network interface handled by MultiplayerSystemComponent
+ if (m_editorNetworkInterface == nullptr)
+ {
+ AZ::Entity* systemEntity = this->GetEntity();
+ MultiplayerSystemComponent* mpSysComponent = systemEntity->FindComponent();
+
+ m_editorNetworkInterface = AZ::Interface::Get()->CreateNetworkInterface(
+ AZ::Name(s_networkInterfaceName), ProtocolType::Tcp, TrustZone::ExternalClientToServer, *mpSysComponent);
+ }
}
void MultiplayerEditorSystemComponent::Deactivate()
@@ -97,25 +116,52 @@ namespace Multiplayer
m_serverProcess->TerminateProcess(0);
m_serverProcess = nullptr;
}
+ if (m_editorNetworkInterface)
+ {
+ // Disconnect the interface, connection management will clean it up
+ m_editorNetworkInterface->Disconnect(m_editorConnId, AzNetworking::DisconnectReason::TerminatedByUser);
+ m_editorConnId = AzNetworking::InvalidConnectionId;
+ }
break;
}
}
void MultiplayerEditorSystemComponent::OnGameEntitiesStarted()
{
+ auto prefabEditorEntityOwnershipInterface = AZ::Interface::Get();
+ if (!prefabEditorEntityOwnershipInterface)
+ {
+ AZ_Error("MultiplayerEditor", prefabEditorEntityOwnershipInterface != nullptr, "PrefabEditorEntityOwnershipInterface unavailable");
+ }
+ const AZStd::vector>& assetData = prefabEditorEntityOwnershipInterface->GetPlayInEditorAssetData();
+
+ AZStd::vector buffer;
+ AZ::IO::ByteContainerStream byteStream(&buffer);
+
+ // Serialize Asset information and AssetData into a potentially large buffer
+ for (auto asset : assetData)
+ {
+ AZ::Data::AssetId assetId = asset.GetId();
+ AZ::Data::AssetType assetType = asset.GetType();
+ const AZStd::string& assetHint = asset.GetHint();
+ AZ::IO::SizeType assetHintSize = assetHint.size();
+ AZ::Data::AssetLoadBehavior assetLoadBehavior = asset.GetAutoLoadBehavior();
+
+ byteStream.Write(sizeof(AZ::Data::AssetId), reinterpret_cast(&assetId));
+ byteStream.Write(sizeof(AZ::Data::AssetType), reinterpret_cast(&assetType));
+ byteStream.Write(sizeof(assetHintSize), reinterpret_cast(&assetHintSize));
+ byteStream.Write(assetHint.size(), assetHint.c_str());
+ byteStream.Write(sizeof(AZ::Data::AssetLoadBehavior), reinterpret_cast(&assetLoadBehavior));
+
+ AZ::Utils::SaveObjectToStream(byteStream, AZ::DataStream::ST_BINARY, asset.GetData(), asset.GetData()->GetType());
+ }
+
// BeginGameMode and Prefab Processing have completed at this point
IMultiplayerTools* mpTools = AZ::Interface::Get();
if (editorsv_enabled && mpTools != nullptr && mpTools->DidProcessNetworkPrefabs())
{
AZ::TickBus::Handler::BusConnect();
- auto prefabEditorEntityOwnershipInterface = AZ::Interface::Get();
- if (!prefabEditorEntityOwnershipInterface)
- {
- AZ_Error("MultiplayerEditor", prefabEditorEntityOwnershipInterface != nullptr, "PrefabEditorEntityOwnershipInterface unavailable");
- }
- const AZStd::vector>& assetData = prefabEditorEntityOwnershipInterface->GetPlayInEditorAssetData();
-
if (assetData.size() > 0)
{
// Assemble the server's path
@@ -154,6 +200,39 @@ namespace Multiplayer
processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE);
}
}
+
+ // Now that the server has launched, attempt to connect the NetworkInterface
+ const AZ::CVarFixedString remoteAddress = sv_serveraddr;
+ m_editorConnId = m_editorNetworkInterface->Connect(
+ AzNetworking::IpAddress(remoteAddress.c_str(), sv_port, AzNetworking::ProtocolType::Tcp));
+
+ // Read the buffer into EditorServerInit packets until we've flushed the whole thing
+ byteStream.Seek(0, AZ::IO::GenericStream::SeekMode::ST_SEEK_BEGIN);
+
+ while (byteStream.GetCurPos() < byteStream.GetLength())
+ {
+ MultiplayerPackets::EditorServerInit packet;
+ AzNetworking::TcpPacketEncodingBuffer& outBuffer = packet.ModifyAssetData();
+
+ // Size the packet's buffer appropriately
+ size_t readSize = TcpPacketEncodingBuffer::GetCapacity();
+ size_t byteStreamSize = byteStream.GetLength() - byteStream.GetCurPos();
+ if (byteStreamSize < readSize)
+ {
+ readSize = byteStreamSize;
+ }
+
+ outBuffer.Resize(readSize);
+ byteStream.Read(readSize, outBuffer.GetBuffer());
+
+ // If we've run out of buffer, mark that we're done
+ if (byteStream.GetCurPos() == byteStream.GetLength())
+ {
+ packet.SetLastUpdate(true);
+ }
+ m_editorNetworkInterface->SendReliablePacket(m_editorConnId, packet);
+ }
+
}
void MultiplayerEditorSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
diff --git a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h
index 31ecdf83a3..d43d8747b9 100644
--- a/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h
+++ b/Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorSystemComponent.h
@@ -81,5 +81,7 @@ namespace Multiplayer
IEditor* m_editor = nullptr;
AzFramework::ProcessWatcher* m_serverProcess = nullptr;
+ AzNetworking::ConnectionId m_editorConnId;
+ AzNetworking::INetworkInterface* m_editorNetworkInterface = nullptr;
};
}
diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp
index 03c661ab03..3c1e142d96 100644
--- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp
+++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp
@@ -57,7 +57,9 @@ namespace Multiplayer
using namespace AzNetworking;
static const AZStd::string_view s_networkInterfaceName("MultiplayerNetworkInterface");
+ static const AZStd::string_view s_networkEditorInterfaceName("MultiplayerEditorNetworkInterface");
static constexpr uint16_t DefaultServerPort = 30090;
+ static constexpr uint16_t DefaultServerEditorPort = 30091;
AZ_CVAR(uint16_t, cl_clientport, 0, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "The port to bind to for game traffic when connecting to a remote host, a value of 0 will select any available port");
AZ_CVAR(AZ::CVarFixedString, cl_serveraddr, "127.0.0.1", nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "The address of the remote server or host to connect to");
@@ -397,6 +399,19 @@ namespace Multiplayer
return false;
}
+ bool MultiplayerSystemComponent::HandleRequest
+ (
+ [[maybe_unused]] AzNetworking::IConnection* connection,
+ [[maybe_unused]] const IPacketHeader& packetHeader,
+ [[maybe_unused]] MultiplayerPackets::EditorServerInit& packet
+ )
+ {
+#if !defined(_RELEASE)
+ // Support Editor Server Init for all non-release targets
+#endif
+ return true;
+ }
+
ConnectResult MultiplayerSystemComponent::ValidateConnect
(
[[maybe_unused]] const IpAddress& remoteAddress,
@@ -492,6 +507,12 @@ namespace Multiplayer
{
if (multiplayerType == MultiplayerAgentType::ClientServer || multiplayerType == MultiplayerAgentType::DedicatedServer)
{
+#if !defined(_RELEASE)
+ m_networkEditorInterface = AZ::Interface::Get()->CreateNetworkInterface(
+ AZ::Name(s_networkEditorInterfaceName), ProtocolType::Tcp, TrustZone::ExternalClientToServer, *this);
+ m_networkEditorInterface->Listen(DefaultServerEditorPort);
+#endif
+
m_initEvent.Signal(m_networkInterface);
const AZ::Aabb worldBounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(-16384.0f), AZ::Vector3(16384.0f));
diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h
index f25e530b61..e77fa129b0 100644
--- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h
+++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h
@@ -72,7 +72,8 @@ namespace Multiplayer
bool HandleRequest(AzNetworking::IConnection* connection, const AzNetworking::IPacketHeader& packetHeader, MultiplayerPackets::NotifyClientMigration& packet);
bool HandleRequest(AzNetworking::IConnection* connection, const AzNetworking::IPacketHeader& packetHeader, MultiplayerPackets::EntityMigration& packet);
bool HandleRequest(AzNetworking::IConnection* connection, const AzNetworking::IPacketHeader& packetHeader, MultiplayerPackets::ReadyForEntityUpdates& packet);
-
+ bool HandleRequest(AzNetworking::IConnection* connection, const AzNetworking::IPacketHeader& packetHeader, MultiplayerPackets::EditorServerInit& packet);
+
//! IConnectionListener interface
//! @{
AzNetworking::ConnectResult ValidateConnect(const AzNetworking::IpAddress& remoteAddress, const AzNetworking::IPacketHeader& packetHeader, AzNetworking::ISerializer& serializer) override;
@@ -109,6 +110,7 @@ namespace Multiplayer
AZ_CONSOLEFUNC(MultiplayerSystemComponent, DumpStats, AZ::ConsoleFunctorFlags::Null, "Dumps stats for the current multiplayer session");
AzNetworking::INetworkInterface* m_networkInterface = nullptr;
+ AzNetworking::INetworkInterface* m_networkEditorInterface = nullptr;
AZ::ConsoleCommandInvokedEvent::Handler m_consoleCommandHandler;
AZ::ThreadSafeDeque m_cvarCommands;
diff --git a/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.cpp b/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.cpp
index a5df3c1dc5..ae91999a0c 100644
--- a/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.cpp
+++ b/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.cpp
@@ -24,6 +24,16 @@ namespace Multiplayer
NetworkPrefabProcessor::Reflect(context);
}
+ void MultiplayerToolsSystemComponent::Activate()
+ {
+ AZ::Interface::Register(this);
+ }
+
+ void MultiplayerToolsSystemComponent::Deactivate()
+ {
+ AZ::Interface::Unregister(this);
+ }
+
bool MultiplayerToolsSystemComponent::DidProcessNetworkPrefabs()
{
return m_didProcessNetPrefabs;
diff --git a/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.h b/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.h
index 82d0415c5a..181a971150 100644
--- a/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.h
+++ b/Gems/Multiplayer/Code/Source/MultiplayerToolsModule.h
@@ -31,9 +31,8 @@ namespace Multiplayer
~MultiplayerToolsSystemComponent() override = default;
/// AZ::Component overrides.
- void Activate() override {};
-
- void Deactivate() override {};
+ void Activate() override;
+ void Deactivate() override;
bool DidProcessNetworkPrefabs() override;
From e2ca84ceb253d0930a006b45c66f745d4f597c8a Mon Sep 17 00:00:00 2001
From: moudgils
Date: Fri, 7 May 2021 17:41:24 -0700
Subject: [PATCH 010/163] More fixes to shaders with the latest dxc
---
.../Assets/Materials/Types/EnhancedPBR_ForwardPass.shader | 3 +--
.../DiffuseProbeGridDownsample_nomsaa.azsl | 4 ++--
Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp | 2 +-
.../Code/Source/Platform/Windows/Vulkan_Traits_Windows.h | 2 +-
4 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.shader b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.shader
index 7964e3c84a..764b67c82f 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.shader
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.shader
@@ -31,8 +31,7 @@
},
"CompilerHints" : {
- "DisableOptimizations" : true,
- "DxcGenerateDebugInfo" : true
+ "DisableOptimizations" : true
},
"ProgramSettings":
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridDownsample_nomsaa.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridDownsample_nomsaa.azsl
index f10fc67da5..d2e73927e0 100644
--- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridDownsample_nomsaa.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridDownsample_nomsaa.azsl
@@ -70,8 +70,8 @@ PSOutput MainPS(VSOutput IN)
{
for (uint x = 0; x < ImageScale; ++x)
{
- float depth = PassSrg::m_depth.Load(int3(screenCoords, 0), int2(x, y)).r;
- float4 encodedNormal = PassSrg::m_normal.Load(int3(screenCoords, 0), int2(x, y));
+ float depth = PassSrg::m_depth.Load(int3(screenCoords + int2(x, y), 0)).r;
+ float4 encodedNormal = PassSrg::m_normal.Load(int3(screenCoords + int2(x, y), 0));
// take the closest depth sample to ensure we're getting the normal closest to the viewer
// (larger depth value due to reverse depth)
diff --git a/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp b/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp
index 957c076592..00b5dada69 100644
--- a/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp
+++ b/Gems/Atom/RHI/Code/Source/RHI.Edit/Utils.cpp
@@ -308,7 +308,7 @@ namespace AZ
uint32_t exitCode = 0;
bool timedOut = false;
- const AZStd::sys_time_t maxWaitTimeSeconds = 240;
+ const AZStd::sys_time_t maxWaitTimeSeconds = 120;
const AZStd::sys_time_t startTimeSeconds = AZStd::GetTimeNowSecond();
const AZStd::sys_time_t startTime = AZStd::GetTimeNowTicks();
diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/Platform/Windows/Vulkan_Traits_Windows.h b/Gems/Atom/RHI/Vulkan/Code/Source/Platform/Windows/Vulkan_Traits_Windows.h
index c7c9902115..c1314aaf66 100644
--- a/Gems/Atom/RHI/Vulkan/Code/Source/Platform/Windows/Vulkan_Traits_Windows.h
+++ b/Gems/Atom/RHI/Vulkan/Code/Source/Platform/Windows/Vulkan_Traits_Windows.h
@@ -11,7 +11,7 @@
*/
#pragma once
-#define AZ_TRAIT_ATOM_SHADERBUILDER_DXC "Builders/DirectXShaderCompilerAz/dxc.exe"
+#define AZ_TRAIT_ATOM_SHADERBUILDER_DXC "Builders/DirectXShaderCompiler/dxc.exe"
#define AZ_TRAIT_ATOM_VULKAN_DISABLE_DUAL_SOURCE_BLENDING 0
#define AZ_TRAIT_ATOM_VULKAN_DLL "vulkan.dll"
#define AZ_TRAIT_ATOM_VULKAN_DLL_1 "vulkan-1.dll"
From 1f3d0beb387a68ac5ac87c63aafa5105d1f253b6 Mon Sep 17 00:00:00 2001
From: antonmic
Date: Fri, 7 May 2021 18:51:20 -0700
Subject: [PATCH 011/163] work in progress
---
.../Materials/Types/StandardPBR.materialtype | 15 +
.../Types/StandardPBR_ForwardPass.azsl | 15 +-
.../Types/StandardPBR_LowEndForward.azsl | 15 +
.../Types/StandardPBR_LowEndForward.shader | 53 +++
.../StandardPBR_LowEndForward_EDS.shader | 53 +++
.../Feature/Common/Assets/Passes/Forward.pass | 16 -
.../Assets/Passes/LightAdaptationParent.pass | 146 ++++++++
.../Common/Assets/Passes/LowEndForward.pass | 133 +++++++
.../Common/Assets/Passes/LowEndPipeline.pass | 344 ++++++++++++++++++
.../Common/Assets/Passes/OpaqueParent.pass | 11 +-
.../Assets/Passes/PassTemplates.azasset | 12 +
.../Assets/Passes/PostProcessParent.pass | 90 +----
.../Feature/Common/Assets/Passes/SkyBox.pass | 5 -
.../Atom/Features/PBR/ForwardPassOutput.azsli | 17 +
.../PBR/LowEndForwardPassOutput.azsli | 32 ++
.../Atom/Features/ShaderQualityOptions.azsli | 24 ++
.../Reflections/ReflectionComposite.azsl | 15 +-
.../Common/Assets/Shaders/SkyBox/SkyBox.azsl | 2 -
.../atom_feature_common_asset_files.cmake | 10 +
19 files changed, 887 insertions(+), 121 deletions(-)
create mode 100644 Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.azsl
create mode 100644 Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.shader
create mode 100644 Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward_EDS.shader
create mode 100644 Gems/Atom/Feature/Common/Assets/Passes/LightAdaptationParent.pass
create mode 100644 Gems/Atom/Feature/Common/Assets/Passes/LowEndForward.pass
create mode 100644 Gems/Atom/Feature/Common/Assets/Passes/LowEndPipeline.pass
create mode 100644 Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LowEndForwardPassOutput.azsli
create mode 100644 Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype
index e071a793a5..fa5c94c606 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype
@@ -77,6 +77,13 @@
],
"properties": {
"general": [
+ {
+ "id": "useLowEndShader",
+ "displayName": "Use Low End",
+ "description": "Whether to use the low end shader.",
+ "type": "Bool",
+ "defaultValue": false
+ },
{
"id": "applySpecularAA",
"displayName": "Apply Specular AA",
@@ -1175,6 +1182,14 @@
"file": "./StandardPBR_ForwardPass_EDS.shader",
"tag": "ForwardPass_EDS"
},
+ {
+ "file": "./StandardPBR_LowEndForward.shader",
+ "tag": "LowEndForward"
+ },
+ {
+ "file": "./StandardPBR_LowEndForward_EDS.shader",
+ "tag": "LowEndForward_EDS"
+ },
{
"file": "Shaders/Shadow/Shadowmap.shader",
"tag": "Shadowmap"
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl
index d3bc72d162..bb4e4cdaab 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl
@@ -10,6 +10,8 @@
*
*/
+#include "Atom/Features/ShaderQualityOptions.azsli"
+
#include "StandardPBR_Common.azsli"
// SRGs
@@ -306,13 +308,18 @@ ForwardPassOutputWithDepth StandardPbr_ForwardPassPS(VSOutput IN, bool isFrontFa
PbrLightingOutput lightingOutput = ForwardPassPS_Common(IN, isFrontFace, depth);
+#ifdef UNIFIED_FORWARD_OUTPUT
+ OUT.m_color.rgb = lightingOutput.m_diffuseColor.rgb + lightingOutput.m_specularColor.rgb;
+ OUT.m_color.a = 1.0f;
+ OUT.m_depth = depth;
+#else
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
OUT.m_specularColor = lightingOutput.m_specularColor;
OUT.m_specularF0 = lightingOutput.m_specularF0;
OUT.m_albedo = lightingOutput.m_albedo;
OUT.m_normal = lightingOutput.m_normal;
OUT.m_depth = depth;
-
+#endif
return OUT;
}
@@ -324,12 +331,16 @@ ForwardPassOutput StandardPbr_ForwardPassPS_EDS(VSOutput IN, bool isFrontFace :
PbrLightingOutput lightingOutput = ForwardPassPS_Common(IN, isFrontFace, depth);
+#ifdef UNIFIED_FORWARD_OUTPUT
+ OUT.m_color.rgb = lightingOutput.m_diffuseColor.rgb + lightingOutput.m_specularColor.rgb;
+ OUT.m_color.a = 1.0f;
+#else
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
OUT.m_specularColor = lightingOutput.m_specularColor;
OUT.m_specularF0 = lightingOutput.m_specularF0;
OUT.m_albedo = lightingOutput.m_albedo;
OUT.m_normal = lightingOutput.m_normal;
-
+#endif
return OUT;
}
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.azsl
new file mode 100644
index 0000000000..a690cbf84a
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.azsl
@@ -0,0 +1,15 @@
+/*
+* 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.
+*
+*/
+
+#define QUALITY_LOW_END 1
+
+#include "StandardPBR_ForwardPass.azsl"
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.shader b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.shader
new file mode 100644
index 0000000000..19538e5db3
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.shader
@@ -0,0 +1,53 @@
+{
+ "Source" : "./StandardPBR_LowEndForward.azsl",
+
+ "DepthStencilState" :
+ {
+ "Depth" :
+ {
+ "Enable" : true,
+ "CompareFunc" : "GreaterEqual"
+ },
+ "Stencil" :
+ {
+ "Enable" : true,
+ "ReadMask" : "0x00",
+ "WriteMask" : "0xFF",
+ "FrontFace" :
+ {
+ "Func" : "Always",
+ "DepthFailOp" : "Keep",
+ "FailOp" : "Keep",
+ "PassOp" : "Replace"
+ },
+ "BackFace" :
+ {
+ "Func" : "Always",
+ "DepthFailOp" : "Keep",
+ "FailOp" : "Keep",
+ "PassOp" : "Replace"
+ }
+ }
+ },
+
+ "CompilerHints" : {
+ "DisableOptimizations" : false
+ },
+
+ "ProgramSettings":
+ {
+ "EntryPoints":
+ [
+ {
+ "name": "StandardPbr_ForwardPassVS",
+ "type": "Vertex"
+ },
+ {
+ "name": "StandardPbr_ForwardPassPS",
+ "type": "Fragment"
+ }
+ ]
+ },
+
+ "DrawList" : "lowEndForward"
+}
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward_EDS.shader b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward_EDS.shader
new file mode 100644
index 0000000000..1b5f014d0e
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward_EDS.shader
@@ -0,0 +1,53 @@
+{
+ "Source" : "./StandardPBR_LowEndForward.azsl",
+
+ "DepthStencilState" :
+ {
+ "Depth" :
+ {
+ "Enable" : true,
+ "CompareFunc" : "GreaterEqual"
+ },
+ "Stencil" :
+ {
+ "Enable" : true,
+ "ReadMask" : "0x00",
+ "WriteMask" : "0xFF",
+ "FrontFace" :
+ {
+ "Func" : "Always",
+ "DepthFailOp" : "Keep",
+ "FailOp" : "Keep",
+ "PassOp" : "Replace"
+ },
+ "BackFace" :
+ {
+ "Func" : "Always",
+ "DepthFailOp" : "Keep",
+ "FailOp" : "Keep",
+ "PassOp" : "Replace"
+ }
+ }
+ },
+
+ "CompilerHints" : {
+ "DisableOptimizations" : false
+ },
+
+ "ProgramSettings":
+ {
+ "EntryPoints":
+ [
+ {
+ "name": "StandardPbr_ForwardPassVS",
+ "type": "Vertex"
+ },
+ {
+ "name": "StandardPbr_ForwardPassPS_EDS",
+ "type": "Fragment"
+ }
+ ]
+ },
+
+ "DrawList" : "lowEndForward"
+}
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/Forward.pass b/Gems/Atom/Feature/Common/Assets/Passes/Forward.pass
index 31a8ed1879..3dcc90ac5c 100644
--- a/Gems/Atom/Feature/Common/Assets/Passes/Forward.pass
+++ b/Gems/Atom/Feature/Common/Assets/Passes/Forward.pass
@@ -148,22 +148,6 @@
},
"LoadAction": "Clear"
}
- },
- {
- "Name": "ScatterDistanceOutput",
- "SlotType": "Output",
- "ScopeAttachmentUsage": "RenderTarget",
- "LoadStoreAction": {
- "ClearValue": {
- "Value": [
- 0.0,
- 0.0,
- 0.0,
- 0.0
- ]
- },
- "LoadAction": "Clear"
- }
}
],
"ImageAttachments": [
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/LightAdaptationParent.pass b/Gems/Atom/Feature/Common/Assets/Passes/LightAdaptationParent.pass
new file mode 100644
index 0000000000..3e804d23e2
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/Passes/LightAdaptationParent.pass
@@ -0,0 +1,146 @@
+{
+ "Type": "JsonSerialization",
+ "Version": 1,
+ "ClassName": "PassAsset",
+ "ClassData": {
+ "PassTemplate": {
+ "Name": "LightAdaptationParentTemplate",
+ "PassClass": "ParentPass",
+ "Slots": [
+ // Inputs...
+ {
+ "Name": "LightingInput",
+ "SlotType": "Input"
+ },
+ // SwapChain here is only used to reference the frame height and format
+ {
+ "Name": "SwapChainOutput",
+ "SlotType": "InputOutput"
+ },
+ // Outputs...
+ {
+ "Name": "Output",
+ "SlotType": "Output"
+ },
+ // Debug Outputs...
+ {
+ "Name": "LuminanceMipChainOutput",
+ "SlotType": "Output"
+ }
+ ],
+ "Connections": [
+ {
+ "LocalSlot": "Output",
+ "AttachmentRef": {
+ "Pass": "DisplayMapperPass",
+ "Attachment": "Output"
+ }
+ },
+ {
+ "LocalSlot": "LuminanceMipChainOutput",
+ "AttachmentRef": {
+ "Pass": "DownsampleLuminanceMipChain",
+ "Attachment": "MipChainInputOutput"
+ }
+ }
+ ],
+ "PassRequests": [
+ {
+ "Name": "DownsampleLuminanceMinAvgMax",
+ "TemplateName": "DownsampleLuminanceMinAvgMaxCS",
+ "Connections": [
+ {
+ "LocalSlot": "Input",
+ "AttachmentRef": {
+ "Pass": "Parent",
+ "Attachment": "LightingInput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "DownsampleLuminanceMipChain",
+ "TemplateName": "DownsampleMipChainTemplate",
+ "Connections": [
+ {
+ "LocalSlot": "MipChainInputOutput",
+ "AttachmentRef": {
+ "Pass": "DownsampleLuminanceMinAvgMax",
+ "Attachment": "Output"
+ }
+ }
+ ],
+ "PassData": {
+ "$type": "DownsampleMipChainPassData",
+ "ShaderAsset": {
+ "FilePath": "Shaders/PostProcessing/DownsampleMinAvgMaxCS.shader"
+ }
+ }
+ },
+ {
+ "Name": "EyeAdaptationPass",
+ "TemplateName": "EyeAdaptationTemplate",
+ "Enabled": false,
+ "Connections": [
+ {
+ "LocalSlot": "SceneLuminanceInput",
+ "AttachmentRef": {
+ "Pass": "DownsampleLuminanceMipChain",
+ "Attachment": "MipChainInputOutput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "LookModificationTransformPass",
+ "TemplateName": "LookModificationTransformTemplate",
+ "Enabled": true,
+ "Connections": [
+ {
+ "LocalSlot": "Input",
+ "AttachmentRef": {
+ "Pass": "Parent",
+ "Attachment": "LightingInput"
+ }
+ },
+ {
+ "LocalSlot": "EyeAdaptationDataInput",
+ "AttachmentRef": {
+ "Pass": "EyeAdaptationPass",
+ "Attachment": "EyeAdaptationDataInputOutput"
+ }
+ },
+ {
+ "LocalSlot": "SwapChainOutput",
+ "AttachmentRef": {
+ "Pass": "Parent",
+ "Attachment": "SwapChainOutput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "DisplayMapperPass",
+ "TemplateName": "DisplayMapperTemplate",
+ "Enabled": true,
+ "Connections": [
+ {
+ "LocalSlot": "Input",
+ "AttachmentRef": {
+ "Pass": "LookModificationTransformPass",
+ "Attachment": "Output"
+ }
+ },
+ {
+ "LocalSlot": "SwapChainOutput",
+ "AttachmentRef": {
+ "Pass": "Parent",
+ "Attachment": "SwapChainOutput"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+}
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/LowEndForward.pass b/Gems/Atom/Feature/Common/Assets/Passes/LowEndForward.pass
new file mode 100644
index 0000000000..4b865fcb6d
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/Passes/LowEndForward.pass
@@ -0,0 +1,133 @@
+{
+ "Type": "JsonSerialization",
+ "Version": 1,
+ "ClassName": "PassAsset",
+ "ClassData": {
+ "PassTemplate": {
+ "Name": "LowEndForwardPassTemplate",
+ "PassClass": "RasterPass",
+ "Slots": [
+ // Inputs...
+ {
+ "Name": "BRDFTextureInput",
+ "ShaderInputName": "m_brdfMap",
+ "SlotType": "Input",
+ "ScopeAttachmentUsage": "Shader"
+ },
+ {
+ "Name": "DirectionalLightShadowmap",
+ "ShaderInputName": "m_directionalLightShadowmap",
+ "SlotType": "Input",
+ "ScopeAttachmentUsage": "Shader",
+ "ImageViewDesc": {
+ "IsArray": 1
+ }
+ },
+ {
+ "Name": "ExponentialShadowmapDirectional",
+ "ShaderInputName": "m_directionalLightExponentialShadowmap",
+ "SlotType": "Input",
+ "ScopeAttachmentUsage": "Shader",
+ "ImageViewDesc": {
+ "IsArray": 1
+ }
+ },
+ {
+ "Name": "ProjectedShadowmap",
+ "ShaderInputName": "m_projectedShadowmaps",
+ "SlotType": "Input",
+ "ScopeAttachmentUsage": "Shader",
+ "ImageViewDesc": {
+ "IsArray": 1
+ }
+ },
+ {
+ "Name": "ExponentialShadowmapProjected",
+ "ShaderInputName": "m_projectedExponentialShadowmap",
+ "SlotType": "Input",
+ "ScopeAttachmentUsage": "Shader",
+ "ImageViewDesc": {
+ "IsArray": 1
+ }
+ },
+ {
+ "Name": "TileLightData",
+ "SlotType": "Input",
+ "ShaderInputName": "m_tileLightData",
+ "ScopeAttachmentUsage": "Shader"
+ },
+ {
+ "Name": "LightListRemapped",
+ "SlotType": "Input",
+ "ShaderInputName": "m_lightListRemapped",
+ "ScopeAttachmentUsage": "Shader"
+ },
+ // Input/Outputs...
+ {
+ "Name": "DepthStencilInputOutput",
+ "SlotType": "InputOutput",
+ "ScopeAttachmentUsage": "DepthStencil"
+ },
+ // Outputs...
+ {
+ "Name": "LightingOutput",
+ "SlotType": "Output",
+ "ScopeAttachmentUsage": "RenderTarget",
+ "LoadStoreAction": {
+ "ClearValue": {
+ "Value": [
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0
+ ]
+ },
+ "LoadAction": "Clear"
+ }
+ }
+ ],
+ "ImageAttachments": [
+ {
+ "Name": "LightingAttachment",
+ "SizeSource": {
+ "Source": {
+ "Pass": "Parent",
+ "Attachment": "SwapChainOutput"
+ }
+ },
+ "MultisampleSource": {
+ "Pass": "This",
+ "Attachment": "DepthStencilInputOutput"
+ },
+ "ImageDescriptor": {
+ "Format": "R16G16B16A16_FLOAT",
+ "SharedQueueMask": "Graphics"
+ }
+ },
+ {
+ "Name": "BRDFTexture",
+ "Lifetime": "Imported",
+ "AssetRef": {
+ "FilePath": "Textures/BRDFTexture.attimage"
+ }
+ }
+ ],
+ "Connections": [
+ {
+ "LocalSlot": "LightingOutput",
+ "AttachmentRef": {
+ "Pass": "This",
+ "Attachment": "LightingAttachment"
+ }
+ },
+ {
+ "LocalSlot": "BRDFTextureInput",
+ "AttachmentRef": {
+ "Pass": "This",
+ "Attachment": "BRDFTexture"
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/LowEndPipeline.pass b/Gems/Atom/Feature/Common/Assets/Passes/LowEndPipeline.pass
new file mode 100644
index 0000000000..b19569fb9d
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/Passes/LowEndPipeline.pass
@@ -0,0 +1,344 @@
+{
+ "Type": "JsonSerialization",
+ "Version": 1,
+ "ClassName": "PassAsset",
+ "ClassData": {
+ "PassTemplate": {
+ "Name": "LowEndPipelineTemplate",
+ "PassClass": "ParentPass",
+ "Slots": [
+ {
+ "Name": "SwapChainOutput",
+ "SlotType": "InputOutput",
+ "ScopeAttachmentUsage": "RenderTarget"
+ }
+ ],
+ "PassRequests": [
+ {
+ "Name": "MorphTargetPass",
+ "TemplateName": "MorphTargetPassTemplate"
+ },
+ {
+ "Name": "SkinningPass",
+ "TemplateName": "SkinningPassTemplate",
+ "Connections": [
+ {
+ "LocalSlot": "SkinnedMeshOutputStream",
+ "AttachmentRef": {
+ "Pass": "MorphTargetPass",
+ "Attachment": "MorphTargetDeltaOutput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "DepthPrePass",
+ "TemplateName": "DepthMSAAParentTemplate",
+ "Connections": [
+ {
+ "LocalSlot": "SkinnedMeshes",
+ "AttachmentRef": {
+ "Pass": "SkinningPass",
+ "Attachment": "SkinnedMeshOutputStream"
+ }
+ },
+ {
+ "LocalSlot": "SwapChainOutput",
+ "AttachmentRef": {
+ "Pass": "Parent",
+ "Attachment": "SwapChainOutput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "LightCullingPass",
+ "TemplateName": "LightCullingParentTemplate",
+ "Connections": [
+ {
+ "LocalSlot": "SkinnedMeshes",
+ "AttachmentRef": {
+ "Pass": "SkinningPass",
+ "Attachment": "SkinnedMeshOutputStream"
+ }
+ },
+ {
+ "LocalSlot": "DepthMSAA",
+ "AttachmentRef": {
+ "Pass": "DepthPrePass",
+ "Attachment": "DepthMSAA"
+ }
+ },
+ {
+ "LocalSlot": "SwapChainOutput",
+ "AttachmentRef": {
+ "Pass": "Parent",
+ "Attachment": "SwapChainOutput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "ShadowPass",
+ "TemplateName": "ShadowParentTemplate",
+ "Connections": [
+ {
+ "LocalSlot": "SkinnedMeshes",
+ "AttachmentRef": {
+ "Pass": "SkinningPass",
+ "Attachment": "SkinnedMeshOutputStream"
+ }
+ },
+ {
+ "LocalSlot": "SwapChainOutput",
+ "AttachmentRef": {
+ "Pass": "Parent",
+ "Attachment": "SwapChainOutput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "ForwardPass",
+ "TemplateName": "LowEndForwardPassTemplate",
+ "Connections": [
+ // Inputs...
+ {
+ "LocalSlot": "DirectionalLightShadowmap",
+ "AttachmentRef": {
+ "Pass": "ShadowPass",
+ "Attachment": "DirectionalShadowmap"
+ }
+ },
+ {
+ "LocalSlot": "ExponentialShadowmapDirectional",
+ "AttachmentRef": {
+ "Pass": "ShadowPass",
+ "Attachment": "DirectionalESM"
+ }
+ },
+ {
+ "LocalSlot": "ProjectedShadowmap",
+ "AttachmentRef": {
+ "Pass": "ShadowPass",
+ "Attachment": "ProjectedShadowmap"
+ }
+ },
+ {
+ "LocalSlot": "ExponentialShadowmapProjected",
+ "AttachmentRef": {
+ "Pass": "ShadowPass",
+ "Attachment": "ProjectedESM"
+ }
+ },
+ {
+ "LocalSlot": "TileLightData",
+ "AttachmentRef": {
+ "Pass": "LightCullingPass",
+ "Attachment": "TileLightData"
+ }
+ },
+ {
+ "LocalSlot": "LightListRemapped",
+ "AttachmentRef": {
+ "Pass": "LightCullingPass",
+ "Attachment": "LightListRemapped"
+ }
+ },
+ // Input/Outputs...
+ {
+ "LocalSlot": "DepthStencilInputOutput",
+ "AttachmentRef": {
+ "Pass": "DepthPrePass",
+ "Attachment": "DepthMSAA"
+ }
+ }
+ ],
+ "PassData": {
+ "$type": "RasterPassData",
+ "DrawListTag": "lowEndForward",
+ "PipelineViewTag": "MainCamera",
+ "PassSrgAsset": {
+ "FilePath": "shaderlib/atom/features/pbr/forwardpasssrg.azsli:PassSrg"
+ }
+ }
+ },
+ {
+ "Name": "SkyBoxPass",
+ "TemplateName": "SkyBoxTemplate",
+ "Enabled": true,
+ "Connections": [
+ {
+ "LocalSlot": "SpecularInputOutput",
+ "AttachmentRef": {
+ "Pass": "ForwardPass",
+ "Attachment": "LightingOutput"
+ }
+ },
+ {
+ "LocalSlot": "SkyBoxDepth",
+ "AttachmentRef": {
+ "Pass": "ForwardPass",
+ "Attachment": "DepthStencilInputOutput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "MSAAResolvePass",
+ "TemplateName": "MSAAResolveColorTemplate",
+ "Connections": [
+ {
+ "LocalSlot": "Input",
+ "AttachmentRef": {
+ "Pass": "SkyBoxPass",
+ "Attachment": "SpecularInputOutput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "TransparentPass",
+ "TemplateName": "TransparentParentTemplate",
+ "Connections": [
+ {
+ "LocalSlot": "DirectionalShadowmap",
+ "AttachmentRef": {
+ "Pass": "ShadowPass",
+ "Attachment": "DirectionalShadowmap"
+ }
+ },
+ {
+ "LocalSlot": "DirectionalESM",
+ "AttachmentRef": {
+ "Pass": "ShadowPass",
+ "Attachment": "DirectionalESM"
+ }
+ },
+ {
+ "LocalSlot": "ProjectedShadowmap",
+ "AttachmentRef": {
+ "Pass": "ShadowPass",
+ "Attachment": "ProjectedShadowmap"
+ }
+ },
+ {
+ "LocalSlot": "ProjectedESM",
+ "AttachmentRef": {
+ "Pass": "ShadowPass",
+ "Attachment": "ProjectedESM"
+ }
+ },
+ {
+ "LocalSlot": "TileLightData",
+ "AttachmentRef": {
+ "Pass": "LightCullingPass",
+ "Attachment": "TileLightData"
+ }
+ },
+ {
+ "LocalSlot": "LightListRemapped",
+ "AttachmentRef": {
+ "Pass": "LightCullingPass",
+ "Attachment": "LightListRemapped"
+ }
+ },
+ {
+ "LocalSlot": "DepthStencil",
+ "AttachmentRef": {
+ "Pass": "DepthPrePass",
+ "Attachment": "Depth"
+ }
+ },
+ {
+ "LocalSlot": "InputOutput",
+ "AttachmentRef": {
+ "Pass": "MSAAResolvePass",
+ "Attachment": "Output"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "LightAdaptation",
+ "TemplateName": "LightAdaptationParentTemplate",
+ "Connections": [
+ {
+ "LocalSlot": "LightingInput",
+ "AttachmentRef": {
+ "Pass": "TransparentPass",
+ "Attachment": "InputOutput"
+ }
+ },
+ {
+ "LocalSlot": "SwapChainOutput",
+ "AttachmentRef": {
+ "Pass": "Parent",
+ "Attachment": "SwapChainOutput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "AuxGeomPass",
+ "TemplateName": "AuxGeomPassTemplate",
+ "Enabled": true,
+ "Connections": [
+ {
+ "LocalSlot": "ColorInputOutput",
+ "AttachmentRef": {
+ "Pass": "LightAdaptation",
+ "Attachment": "Output"
+ }
+ },
+ {
+ "LocalSlot": "DepthInputOutput",
+ "AttachmentRef": {
+ "Pass": "DepthPrePass",
+ "Attachment": "Depth"
+ }
+ }
+ ],
+ "PassData": {
+ "$type": "RasterPassData",
+ "DrawListTag": "auxgeom",
+ "PipelineViewTag": "MainCamera"
+ }
+ },
+ {
+ "Name": "UIPass",
+ "TemplateName": "UIParentTemplate",
+ "Connections": [
+ {
+ "LocalSlot": "InputOutput",
+ "AttachmentRef": {
+ "Pass": "AuxGeomPass",
+ "Attachment": "ColorInputOutput"
+ }
+ }
+ ]
+ },
+ {
+ "Name": "CopyToSwapChain",
+ "TemplateName": "FullscreenCopyTemplate",
+ "Connections": [
+ {
+ "LocalSlot": "Input",
+ "AttachmentRef": {
+ "Pass": "UIPass",
+ "Attachment": "InputOutput"
+ }
+ },
+ {
+ "LocalSlot": "Output",
+ "AttachmentRef": {
+ "Pass": "Parent",
+ "Attachment": "SwapChainOutput"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ }
+}
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass b/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass
index dda120e164..40d6a51e77 100644
--- a/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass
+++ b/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass
@@ -315,13 +315,6 @@
"Attachment": "SpecularInputOutput"
}
},
- {
- "LocalSlot": "ReflectionInputOutput",
- "AttachmentRef": {
- "Pass": "ReflectionsPass",
- "Attachment": "ReflectionOutput"
- }
- },
{
"LocalSlot": "SkyBoxDepth",
"AttachmentRef": {
@@ -338,8 +331,8 @@
{
"LocalSlot": "ReflectionInput",
"AttachmentRef": {
- "Pass": "SkyBoxPass",
- "Attachment": "ReflectionInputOutput"
+ "Pass": "ReflectionsPass",
+ "Attachment": "ReflectionOutput"
}
},
{
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset b/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset
index b83ab65ff2..2421d7fbe7 100644
--- a/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset
+++ b/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset
@@ -483,6 +483,18 @@
{
"Name": "UIParentTemplate",
"Path": "Passes/UIParent.pass"
+ },
+ {
+ "Name": "LightAdaptationParentTemplate",
+ "Path": "Passes/LightAdaptationParent.pass"
+ },
+ {
+ "Name": "LowEndForwardPassTemplate",
+ "Path": "Passes/LowEndForward.pass"
+ },
+ {
+ "Name": "LowEndPipelineTemplate",
+ "Path": "Passes/LowEndPipeline.pass"
}
]
}
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/PostProcessParent.pass b/Gems/Atom/Feature/Common/Assets/Passes/PostProcessParent.pass
index 37b1ee5c5a..36f7f1e985 100644
--- a/Gems/Atom/Feature/Common/Assets/Passes/PostProcessParent.pass
+++ b/Gems/Atom/Feature/Common/Assets/Passes/PostProcessParent.pass
@@ -40,7 +40,7 @@
{
"LocalSlot": "Output",
"AttachmentRef": {
- "Pass": "DisplayMapperPass",
+ "Pass": "LightAdaptation",
"Attachment": "Output"
}
},
@@ -54,8 +54,8 @@
{
"LocalSlot": "LuminanceMipChainOutput",
"AttachmentRef": {
- "Pass": "DownsampleLuminanceMipChain",
- "Attachment": "MipChainInputOutput"
+ "Pass": "LightAdaptation",
+ "Attachment": "LuminanceMipChainOutput"
}
}
],
@@ -115,94 +115,16 @@
}
]
},
- // Everything before this point deals in raw lighting values
- // ---------------------------------------------------------
- // Everything after starts to map to values we see on screen
{
- "Name": "DownsampleLuminanceMinAvgMax",
- "TemplateName": "DownsampleLuminanceMinAvgMaxCS",
+ "Name": "LightAdaptation",
+ "TemplateName": "LightAdaptationParentTemplate",
"Connections": [
{
- "LocalSlot": "Input",
+ "LocalSlot": "LightingInput",
"AttachmentRef": {
"Pass": "BloomPass",
"Attachment": "InputOutput"
}
- }
- ]
- },
- {
- "Name": "DownsampleLuminanceMipChain",
- "TemplateName": "DownsampleMipChainTemplate",
- "Connections": [
- {
- "LocalSlot": "MipChainInputOutput",
- "AttachmentRef": {
- "Pass": "DownsampleLuminanceMinAvgMax",
- "Attachment": "Output"
- }
- }
- ],
- "PassData": {
- "$type": "DownsampleMipChainPassData",
- "ShaderAsset": {
- "FilePath": "Shaders/PostProcessing/DownsampleMinAvgMaxCS.shader"
- }
- }
- },
- {
- "Name": "EyeAdaptationPass",
- "TemplateName": "EyeAdaptationTemplate",
- "Enabled": false,
- "Connections": [
- {
- "LocalSlot": "SceneLuminanceInput",
- "AttachmentRef": {
- "Pass": "DownsampleLuminanceMipChain",
- "Attachment": "MipChainInputOutput"
- }
- }
- ]
- },
- {
- "Name": "LookModificationTransformPass",
- "TemplateName": "LookModificationTransformTemplate",
- "Enabled": true,
- "Connections": [
- {
- "LocalSlot": "Input",
- "AttachmentRef": {
- "Pass": "BloomPass",
- "Attachment": "InputOutput"
- }
- },
- {
- "LocalSlot": "EyeAdaptationDataInput",
- "AttachmentRef": {
- "Pass": "EyeAdaptationPass",
- "Attachment": "EyeAdaptationDataInputOutput"
- }
- },
- {
- "LocalSlot": "SwapChainOutput",
- "AttachmentRef": {
- "Pass": "Parent",
- "Attachment": "SwapChainOutput"
- }
- }
- ]
- },
- {
- "Name": "DisplayMapperPass",
- "TemplateName": "DisplayMapperTemplate",
- "Enabled": true,
- "Connections": [
- {
- "LocalSlot": "Input",
- "AttachmentRef": {
- "Pass": "LookModificationTransformPass",
- "Attachment": "Output"
- }
},
{
"LocalSlot": "SwapChainOutput",
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass b/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass
index 57f442e5de..fb16271ba7 100644
--- a/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass
+++ b/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass
@@ -12,11 +12,6 @@
"SlotType": "InputOutput",
"ScopeAttachmentUsage": "RenderTarget"
},
- {
- "Name": "ReflectionInputOutput",
- "SlotType": "InputOutput",
- "ScopeAttachmentUsage": "RenderTarget"
- },
{
"Name": "SkyBoxDepth",
"SlotType": "InputOutput",
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli
index acc215f1c9..5821deb3b1 100644
--- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli
+++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli
@@ -10,6 +10,21 @@
*
*/
+#ifdef UNIFIED_FORWARD_OUTPUT
+
+struct ForwardPassOutput
+{
+ float4 m_color : SV_Target0;
+};
+
+struct ForwardPassOutputWithDepth
+{
+ float4 m_color : SV_Target0;
+ float m_depth : SV_Depth;
+};
+
+#else
+
struct ForwardPassOutput
{
float4 m_diffuseColor : SV_Target0; //!< RGB = Diffuse Lighting, A = Blend Alpha (for blended surfaces) OR A = special encoding of surfaceScatteringFactor, m_subsurfaceScatteringQuality, o_enableSubsurfaceScattering
@@ -30,3 +45,5 @@ struct ForwardPassOutputWithDepth
float4 m_normal : SV_Target4;
float m_depth : SV_Depth;
};
+
+#endif
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LowEndForwardPassOutput.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LowEndForwardPassOutput.azsli
new file mode 100644
index 0000000000..acc215f1c9
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LowEndForwardPassOutput.azsli
@@ -0,0 +1,32 @@
+/*
+* 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.
+*
+*/
+
+struct ForwardPassOutput
+{
+ float4 m_diffuseColor : SV_Target0; //!< RGB = Diffuse Lighting, A = Blend Alpha (for blended surfaces) OR A = special encoding of surfaceScatteringFactor, m_subsurfaceScatteringQuality, o_enableSubsurfaceScattering
+ float4 m_specularColor : SV_Target1; //!< RGB = Specular Lighting, A = Unused
+ float4 m_albedo : SV_Target2; //!< RGB = Surface albedo pre-multiplied by other factors that will be multiplied later by diffuse GI, A = specularOcclusion
+ float4 m_specularF0 : SV_Target3; //!< RGB = Specular F0, A = roughness
+ float4 m_normal : SV_Target4; //!< RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled
+};
+
+struct ForwardPassOutputWithDepth
+{
+ // See above for descriptions of special encodings
+
+ float4 m_diffuseColor : SV_Target0;
+ float4 m_specularColor : SV_Target1;
+ float4 m_albedo : SV_Target2;
+ float4 m_specularF0 : SV_Target3;
+ float4 m_normal : SV_Target4;
+ float m_depth : SV_Depth;
+};
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli
new file mode 100644
index 0000000000..907e67ada5
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli
@@ -0,0 +1,24 @@
+/*
+* 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
+
+// These are a list of quality options to specify as macros (either in azsl or in shader files)
+//
+// QUALITY_LOW_END
+
+#ifdef QUALITY_LOW_END
+
+#define UNIFIED_FORWARD_OUTPUT 1
+
+#endif
+
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionComposite.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionComposite.azsl
index 92f8c3f638..865d657d85 100644
--- a/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionComposite.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionComposite.azsl
@@ -53,13 +53,22 @@ PSOutput MainPS(VSOutput IN)
uint width, height, samples;
PassSrg::m_reflection.GetDimensions(width, height, samples);
+ float nonZeroSamples = 0.0f;
for (uint sampleIndex = 0; sampleIndex < samples; ++sampleIndex)
{
- reflection += PassSrg::m_reflection.Load(IN.m_position.xy, sampleIndex).rgb;
+ float3 reflectionSample = PassSrg::m_reflection.Load(IN.m_position.xy, sampleIndex).rgb;
+ if(any(reflectionSample))
+ {
+ reflection += reflectionSample;
+ nonZeroSamples += 1.0f;
+ }
+ }
+
+ if(nonZeroSamples != 0.0f)
+ {
+ reflection /= nonZeroSamples;
}
- reflection /= samples;
-
PSOutput OUT;
OUT.m_color = float4(reflection, 1.0f);
return OUT;
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl
index 1ee30a4f98..a7de426374 100644
--- a/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl
@@ -102,7 +102,6 @@ float3 GetCubemapCoords(float3 original)
struct PSOutput
{
float4 m_specular : SV_Target0;
- float4 m_reflection : SV_Target1;
};
PSOutput MainPS(VSOutput input)
@@ -163,6 +162,5 @@ PSOutput MainPS(VSOutput input)
PSOutput OUT;
OUT.m_specular = float4(color, 1.0);
- OUT.m_reflection = float4(color, 1.0);
return OUT;
}
diff --git a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
index f14fb4f4a0..6902d456ff 100644
--- a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
+++ b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
@@ -52,6 +52,8 @@ set(FILES
Materials/Types/StandardPBR_ForwardPass_EDS.shader
Materials/Types/StandardPBR_HandleOpacityDoubleSided.lua
Materials/Types/StandardPBR_HandleOpacityMode.lua
+ Materials/Types/StandardPBR_LowEndForward.azsl
+ Materials/Types/StandardPBR_LowEndForward.shader
Materials/Types/StandardPBR_ParallaxState.lua
Materials/Types/StandardPBR_Roughness.lua
Materials/Types/StandardPBR_ShaderEnable.lua
@@ -116,6 +118,7 @@ set(FILES
Passes/DiffuseProbeGridBlendDistance.pass
Passes/DiffuseProbeGridBlendIrradiance.pass
Passes/DiffuseProbeGridBorderUpdate.pass
+ Passes/DiffuseProbeGridClassification.pass
Passes/DiffuseProbeGridDownsample.pass
Passes/DiffuseProbeGridRayTracing.pass
Passes/DiffuseProbeGridRelocation.pass
@@ -144,6 +147,7 @@ set(FILES
Passes/FullscreenCopy.pass
Passes/FullscreenOutputOnly.pass
Passes/ImGui.pass
+ Passes/LightAdaptationParent.pass
Passes/LightCulling.pass
Passes/LightCullingHeatmap.pass
Passes/LightCullingParent.pass
@@ -152,6 +156,8 @@ set(FILES
Passes/LightCullingTilePrepareMSAA.pass
Passes/LookModificationComposite.pass
Passes/LookModificationTransform.pass
+ Passes/LowEndForward.pass
+ Passes/LowEndPipeline.pass
Passes/LuminanceHeatmap.pass
Passes/LuminanceHistogramGenerator.pass
Passes/MainPipeline.pass
@@ -179,8 +185,10 @@ set(FILES
Passes/ReflectionScreenSpace.pass
Passes/ReflectionScreenSpaceBlur.pass
Passes/ReflectionScreenSpaceBlurHorizontal.pass
+ Passes/ReflectionScreenSpaceBlurMobile.pass
Passes/ReflectionScreenSpaceBlurVertical.pass
Passes/ReflectionScreenSpaceComposite.pass
+ Passes/ReflectionScreenSpaceMobile.pass
Passes/ReflectionScreenSpaceTrace.pass
Passes/Reflections_nomsaa.pass
Passes/ShadowParent.pass
@@ -205,6 +213,7 @@ set(FILES
ShaderLib/Atom/Features/IndirectRendering.azsli
ShaderLib/Atom/Features/MatrixUtility.azsli
ShaderLib/Atom/Features/ParallaxMapping.azsli
+ ShaderLib/Atom/Features/ShaderQualityOptions.azsli
ShaderLib/Atom/Features/SphericalHarmonicsUtility.azsli
ShaderLib/Atom/Features/SrgSemantics.azsli
ShaderLib/Atom/Features/ColorManagement/TransformColor.azsli
@@ -234,6 +243,7 @@ set(FILES
ShaderLib/Atom/Features/PBR/Hammersley.azsli
ShaderLib/Atom/Features/PBR/LightingOptions.azsli
ShaderLib/Atom/Features/PBR/LightingUtils.azsli
+ ShaderLib/Atom/Features/PBR/LowEndForwardPassOutput.azsli
ShaderLib/Atom/Features/PBR/TransparentPassSrg.azsli
ShaderLib/Atom/Features/PBR/Lighting/DualSpecularLighting.azsli
ShaderLib/Atom/Features/PBR/Lighting/EnhancedLighting.azsli
From 24aa0f852179f94bce8ae354b66c6804628bd1b7 Mon Sep 17 00:00:00 2001
From: antonmic
Date: Fri, 7 May 2021 20:56:40 -0700
Subject: [PATCH 012/163] skybox pass separation for single vs double output
---
.../Common/Assets/Passes/OpaqueParent.pass | 13 ++++--
.../Assets/Passes/PassTemplates.azasset | 4 ++
.../Feature/Common/Assets/Passes/SkyBox.pass | 5 +++
.../Assets/Passes/SkyBox_TwoOutputs.pass | 43 +++++++++++++++++++
.../Reflections/ReflectionComposite.azsl | 15 ++-----
.../Common/Assets/Shaders/SkyBox/SkyBox.azsl | 11 +++++
.../Shaders/SkyBox/SkyBox_TwoOutputs.azsl | 15 +++++++
.../Shaders/SkyBox/SkyBox_TwoOutputs.shader | 22 ++++++++++
8 files changed, 113 insertions(+), 15 deletions(-)
create mode 100644 Gems/Atom/Feature/Common/Assets/Passes/SkyBox_TwoOutputs.pass
create mode 100644 Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.azsl
create mode 100644 Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.shader
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass b/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass
index 40d6a51e77..a691fe2534 100644
--- a/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass
+++ b/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass
@@ -305,7 +305,7 @@
},
{
"Name": "SkyBoxPass",
- "TemplateName": "SkyBoxTemplate",
+ "TemplateName": "SkyBoxTwoOutputsTemplate",
"Enabled": true,
"Connections": [
{
@@ -315,6 +315,13 @@
"Attachment": "SpecularInputOutput"
}
},
+ {
+ "LocalSlot": "ReflectionInputOutput",
+ "AttachmentRef": {
+ "Pass": "ReflectionsPass",
+ "Attachment": "ReflectionOutput"
+ }
+ },
{
"LocalSlot": "SkyBoxDepth",
"AttachmentRef": {
@@ -331,8 +338,8 @@
{
"LocalSlot": "ReflectionInput",
"AttachmentRef": {
- "Pass": "ReflectionsPass",
- "Attachment": "ReflectionOutput"
+ "Pass": "SkyBoxPass",
+ "Attachment": "ReflectionInputOutput"
}
},
{
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset b/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset
index 2421d7fbe7..c56e8932b1 100644
--- a/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset
+++ b/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset
@@ -92,6 +92,10 @@
"Name": "SkyBoxTemplate",
"Path": "Passes/SkyBox.pass"
},
+ {
+ "Name": "SkyBoxTwoOutputsTemplate",
+ "Path": "Passes/SkyBox_TwoOutputs.pass"
+ },
{
"Name": "UIPassTemplate",
"Path": "Passes/UI.pass"
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass b/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass
index fb16271ba7..57f442e5de 100644
--- a/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass
+++ b/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass
@@ -12,6 +12,11 @@
"SlotType": "InputOutput",
"ScopeAttachmentUsage": "RenderTarget"
},
+ {
+ "Name": "ReflectionInputOutput",
+ "SlotType": "InputOutput",
+ "ScopeAttachmentUsage": "RenderTarget"
+ },
{
"Name": "SkyBoxDepth",
"SlotType": "InputOutput",
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/SkyBox_TwoOutputs.pass b/Gems/Atom/Feature/Common/Assets/Passes/SkyBox_TwoOutputs.pass
new file mode 100644
index 0000000000..0ed7b39288
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/Passes/SkyBox_TwoOutputs.pass
@@ -0,0 +1,43 @@
+{
+ "Type": "JsonSerialization",
+ "Version": 1,
+ "ClassName": "PassAsset",
+ "ClassData": {
+ "PassTemplate": {
+ "Name": "SkyBoxTwoOutputsTemplate",
+ "PassClass": "FullScreenTriangle",
+ "Slots": [
+ {
+ "Name": "SpecularInputOutput",
+ "SlotType": "InputOutput",
+ "ScopeAttachmentUsage": "RenderTarget"
+ },
+ {
+ "Name": "ReflectionInputOutput",
+ "SlotType": "InputOutput",
+ "ScopeAttachmentUsage": "RenderTarget"
+ },
+ {
+ "Name": "SkyBoxDepth",
+ "SlotType": "InputOutput",
+ "ScopeAttachmentUsage": "DepthStencil"
+ }
+ ],
+ "PassData": {
+ "$type": "FullscreenTrianglePassData",
+ "ShaderAsset": {
+ "FilePath": "shaders/skybox/skybox_twooutputs.shader"
+ },
+ "PipelineViewTag": "MainCamera",
+ "ShaderDataMappings": {
+ "FloatMappings": [
+ {
+ "Name": "m_sunIntensityMultiplier",
+ "Value": 1.0
+ }
+ ]
+ }
+ }
+ }
+ }
+}
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionComposite.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionComposite.azsl
index 865d657d85..92f8c3f638 100644
--- a/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionComposite.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionComposite.azsl
@@ -53,22 +53,13 @@ PSOutput MainPS(VSOutput IN)
uint width, height, samples;
PassSrg::m_reflection.GetDimensions(width, height, samples);
- float nonZeroSamples = 0.0f;
for (uint sampleIndex = 0; sampleIndex < samples; ++sampleIndex)
{
- float3 reflectionSample = PassSrg::m_reflection.Load(IN.m_position.xy, sampleIndex).rgb;
- if(any(reflectionSample))
- {
- reflection += reflectionSample;
- nonZeroSamples += 1.0f;
- }
- }
-
- if(nonZeroSamples != 0.0f)
- {
- reflection /= nonZeroSamples;
+ reflection += PassSrg::m_reflection.Load(IN.m_position.xy, sampleIndex).rgb;
}
+ reflection /= samples;
+
PSOutput OUT;
OUT.m_color = float4(reflection, 1.0f);
return OUT;
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl
index a7de426374..4b3e9536b7 100644
--- a/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl
@@ -10,6 +10,11 @@
*
*/
+// Static Options:
+//
+// SKYBOX_TWO_OUTPUTS - Allows the skybox to render to two rendertargets instead of one
+
+
#include
#include
#include
@@ -102,6 +107,9 @@ float3 GetCubemapCoords(float3 original)
struct PSOutput
{
float4 m_specular : SV_Target0;
+#ifdef SKYBOX_TWO_OUTPUTS
+ float4 m_reflection : SV_Target1;
+#endif
};
PSOutput MainPS(VSOutput input)
@@ -162,5 +170,8 @@ PSOutput MainPS(VSOutput input)
PSOutput OUT;
OUT.m_specular = float4(color, 1.0);
+#ifdef SKYBOX_TWO_OUTPUTS
+ OUT.m_reflection = float4(color, 1.0);
+#endif
return OUT;
}
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.azsl
new file mode 100644
index 0000000000..99d7b45e4c
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.azsl
@@ -0,0 +1,15 @@
+/*
+* 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.
+*
+*/
+
+#define SKYBOX_TWO_OUTPUTS
+
+#include "SkyBox.azsl"
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.shader b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.shader
new file mode 100644
index 0000000000..ec80d4a20e
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.shader
@@ -0,0 +1,22 @@
+{
+ "Source" : "SkyBox_TwoOutputs",
+
+ "DepthStencilState" : {
+ "Depth" : { "Enable" : true, "CompareFunc" : "GreaterEqual" }
+ },
+
+ "ProgramSettings":
+ {
+ "EntryPoints":
+ [
+ {
+ "name": "MainVS",
+ "type": "Vertex"
+ },
+ {
+ "name": "MainPS",
+ "type": "Fragment"
+ }
+ ]
+ }
+}
From cb245730a1f214c4891817b11bb617166f73c7b7 Mon Sep 17 00:00:00 2001
From: antonmic
Date: Sun, 9 May 2021 23:01:24 -0700
Subject: [PATCH 013/163] work in progress
---
.../Types/StandardPBR_LowEndForward.azsl | 2 ++
.../Feature/Common/Assets/Passes/Forward.pass | 20 -------------------
.../Feature/Common/Assets/Passes/SkyBox.pass | 5 -----
.../Shaders/SkyBox/SkyBox_TwoOutputs.azsl | 2 ++
.../atom_feature_common_asset_files.cmake | 4 ++++
5 files changed, 8 insertions(+), 25 deletions(-)
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.azsl
index a690cbf84a..c87faffcbe 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_LowEndForward.azsl
@@ -10,6 +10,8 @@
*
*/
+// NOTE: This file is a temporary workaround until .shader files can #define macros for their .azsl files
+
#define QUALITY_LOW_END 1
#include "StandardPBR_ForwardPass.azsl"
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/Forward.pass b/Gems/Atom/Feature/Common/Assets/Passes/Forward.pass
index 3dcc90ac5c..b66e3bb4e1 100644
--- a/Gems/Atom/Feature/Common/Assets/Passes/Forward.pass
+++ b/Gems/Atom/Feature/Common/Assets/Passes/Forward.pass
@@ -222,19 +222,6 @@
"AssetRef": {
"FilePath": "Textures/BRDFTexture.attimage"
}
- },
- {
- "Name": "ScatterDistanceImage",
- "SizeSource": {
- "Source": {
- "Pass": "Parent",
- "Attachment": "SwapChainOutput"
- }
- },
- "ImageDescriptor": {
- "Format": "R11G11B10_FLOAT",
- "SharedQueueMask": "Graphics"
- }
}
],
"Connections": [
@@ -279,13 +266,6 @@
"Pass": "This",
"Attachment": "BRDFTexture"
}
- },
- {
- "LocalSlot": "ScatterDistanceOutput",
- "AttachmentRef": {
- "Pass": "This",
- "Attachment": "ScatterDistanceImage"
- }
}
]
}
diff --git a/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass b/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass
index 57f442e5de..fb16271ba7 100644
--- a/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass
+++ b/Gems/Atom/Feature/Common/Assets/Passes/SkyBox.pass
@@ -12,11 +12,6 @@
"SlotType": "InputOutput",
"ScopeAttachmentUsage": "RenderTarget"
},
- {
- "Name": "ReflectionInputOutput",
- "SlotType": "InputOutput",
- "ScopeAttachmentUsage": "RenderTarget"
- },
{
"Name": "SkyBoxDepth",
"SlotType": "InputOutput",
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.azsl
index 99d7b45e4c..feacd2f44f 100644
--- a/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox_TwoOutputs.azsl
@@ -10,6 +10,8 @@
*
*/
+// NOTE: This file is a temporary workaround until .shader files can #define macros for their .azsl files
+
#define SKYBOX_TWO_OUTPUTS
#include "SkyBox.azsl"
diff --git a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
index 6902d456ff..7419c1e669 100644
--- a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
+++ b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
@@ -54,6 +54,7 @@ set(FILES
Materials/Types/StandardPBR_HandleOpacityMode.lua
Materials/Types/StandardPBR_LowEndForward.azsl
Materials/Types/StandardPBR_LowEndForward.shader
+ Materials/Types/StandardPBR_LowEndForward_EDS.shader
Materials/Types/StandardPBR_ParallaxState.lua
Materials/Types/StandardPBR_Roughness.lua
Materials/Types/StandardPBR_ShaderEnable.lua
@@ -194,6 +195,7 @@ set(FILES
Passes/ShadowParent.pass
Passes/Skinning.pass
Passes/SkyBox.pass
+ Passes/SkyBox_TwoOutputs.pass
Passes/SMAA1xApplyLinearHDRColor.pass
Passes/SMAA1xApplyPerceptualColor.pass
Passes/SMAABlendingWeightCalculation.pass
@@ -483,4 +485,6 @@ set(FILES
Shaders/SkinnedMesh/LinearSkinningPassSRG.azsli
Shaders/SkyBox/SkyBox.azsl
Shaders/SkyBox/SkyBox.shader
+ Shaders/SkyBox/SkyBox_TwoOutputs.azsl
+ Shaders/SkyBox/SkyBox_TwoOutputs.shader
)
From 89bb0edb3082b40de3c9b3737ad31e845b4cdf75 Mon Sep 17 00:00:00 2001
From: Chris Santora
Date: Mon, 10 May 2021 23:04:56 -0700
Subject: [PATCH 014/163] ATOM-15518 Change Multilayer PBR To Use Lerp Base
Blending
Changed to lerp-based blending, with an implicit base layer.
Renamed some variables to be more clear (blendWeight instead of blendMask, since the weights could come from vertex colors instead of a texture).
Updated DefaultBlendMask_layers.png to better suit the new layering model. It has a black background and overlapping R, G, and B areas.
Updated some of the test materials UV transforms to better fit the new DefaultBlendMask_layers image.
Added a new test object, which is a plane that has painted vertices.
Note that I updated test criteria in AtomSampleViewer to account for these changes as well.
---
.../Types/StandardMultilayerPBR.materialtype | 2 +-
.../Types/StandardMultilayerPBR_Common.azsli | 79 +++++++++++--------
...tandardMultilayerPBR_DepthPass_WithPS.azsl | 2 +-
.../StandardMultilayerPBR_ForwardPass.azsl | 39 +++++----
...tandardMultilayerPBR_Shadowmap_WithPS.azsl | 2 +-
.../Textures/DefaultBlendMask_layers.png | 4 +-
.../001_ManyFeatures.material | 12 ++-
.../002_ParallaxPdo.material | 3 +-
...aterial => 003_Debug_BlendSource.material} | 2 +-
.../TestData/Objects/PaintedPlane.fbx | 3 +
10 files changed, 87 insertions(+), 61 deletions(-)
rename Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/{003_Debug_BlendMaskValues.material => 003_Debug_BlendSource.material} (86%)
create mode 100644 Gems/Atom/TestData/TestData/Objects/PaintedPlane.fbx
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
index e2119dcf12..3e95846b6e 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
@@ -204,7 +204,7 @@
"displayName": "Debug Draw Mode",
"description": "Enables various debug view features.",
"type": "Enum",
- "enumValues": [ "None", "BlendMaskValues", "DepthMaps" ],
+ "enumValues": [ "None", "BlendSource", "DepthMaps" ],
"defaultValue": "None",
"connection": {
"type": "ShaderOption",
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli
index ba0eaf2ac1..f1f6d90e14 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli
@@ -42,7 +42,7 @@ COMMON_SRG_INPUTS_PARALLAX(prefix)
ShaderResourceGroup MaterialSrg : SRG_PerMaterial
{
- Texture2D m_blendMaskTexture;
+ Texture2D m_blendMaskTexture;
uint m_blendMaskUvIndex;
// Auto-generate material SRG fields for common inputs for each layer
@@ -113,7 +113,7 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial
// ------ Shader Options ----------------------------------------
-enum class DebugDrawMode { None, BlendMaskValues, DepthMaps };
+enum class DebugDrawMode { None, BlendSource, DepthMaps };
option DebugDrawMode o_debugDrawMode;
enum class BlendMaskSource { TextureMap, VertexColors, Fallback };
@@ -127,6 +127,10 @@ option bool o_blendMask_isBound;
// ------ Blend Utilities ----------------------------------------
+// This is mainly used to pass extra data to the GetDepth callback function during the parallax depth search.
+// But since we have it, we use it in some other functions as well rather than passing it around.
+static float3 s_blendMaskFromVertexStream;
+
//! Returns the BlendMaskSource that will actually be used when rendering (not necessarily the same BlendMaskSource specified by the user)
BlendMaskSource GetFinalBlendMaskSource()
{
@@ -151,40 +155,63 @@ BlendMaskSource GetFinalBlendMaskSource()
}
}
-//! Return the final blend mask values to be used for rendering, based on the available data and configuration.
-float3 GetBlendMaskValues(float2 uv, float3 vertexBlendMask)
+//! Return the raw blend source values directly from the blend mask or vertex colors, depending on the available data and configuration.
+//! layer1 is an implicit base layer
+//! layer2 is weighted by r
+//! layer3 is weighted by g
+//! b is reserved for perhaps a dedicated puddle layer
+float3 GetBlendSourceValues(float2 uv)
{
- float3 blendMaskValues;
+ float3 blendSourceValues = float3(0,0,0);
switch(GetFinalBlendMaskSource())
{
case BlendMaskSource::TextureMap:
- blendMaskValues = MaterialSrg::m_blendMaskTexture.Sample(MaterialSrg::m_sampler, uv).rgb;
+ blendSourceValues = MaterialSrg::m_blendMaskTexture.Sample(MaterialSrg::m_sampler, uv).rgb;
break;
case BlendMaskSource::VertexColors:
- blendMaskValues = vertexBlendMask;
- break;
- case BlendMaskSource::Fallback:
- blendMaskValues = float3(1,1,1);
+ blendSourceValues = s_blendMaskFromVertexStream;
break;
}
- blendMaskValues = blendMaskValues / (blendMaskValues.r + blendMaskValues.g + blendMaskValues.b);
-
- return blendMaskValues;
+ return blendSourceValues;
}
-float BlendLayers(float layer1, float layer2, float layer3, float3 blendMaskValues)
+//! Return the final blend mask values to be used for rendering, based on the available data and configuration.
+//! @return The blend weights for each layer.
+//! Even though layer1 not explicitly specified in the blend source data, it is explicitly included with the returned values.
+//! layer1 = r
+//! layer2 = g
+//! layer3 = b
+float3 GetBlendWeights(float2 uv)
{
- return dot(float3(layer1, layer2, layer3), blendMaskValues);
+ float3 blendSourceValues = GetBlendSourceValues(uv);
+
+ // Calculate blend weights such that multiplying and adding them with layer data is equivalent
+ // to lerping between each layer.
+ // final = lerp(final, layer1, blendWeights.r)
+ // final = lerp(final, layer2, blendWeights.g)
+ // final = lerp(final, layer3, blendWeights.b)
+
+ float3 blendWeights;
+ blendWeights.b = blendSourceValues.g;
+ blendWeights.g = (1.0 - blendSourceValues.g) * blendSourceValues.r;
+ blendWeights.r = (1.0 - blendSourceValues.g) * (1.0 - blendSourceValues.r);
+
+ return blendWeights;
}
-float2 BlendLayers(float2 layer1, float2 layer2, float2 layer3, float3 blendMaskValues)
+
+float BlendLayers(float layer1, float layer2, float layer3, float3 blendWeights)
{
- return layer1 * blendMaskValues.r + layer2 * blendMaskValues.g + layer3 * blendMaskValues.b;
+ return dot(float3(layer1, layer2, layer3), blendWeights);
}
-float3 BlendLayers(float3 layer1, float3 layer2, float3 layer3, float3 blendMaskValues)
+float2 BlendLayers(float2 layer1, float2 layer2, float2 layer3, float3 blendWeights)
{
- return layer1 * blendMaskValues.r + layer2 * blendMaskValues.g + layer3 * blendMaskValues.b;
+ return layer1 * blendWeights.r + layer2 * blendWeights.g + layer3 * blendWeights.b;
+}
+float3 BlendLayers(float3 layer1, float3 layer2, float3 layer3, float3 blendWeights)
+{
+ return layer1 * blendWeights.r + layer2 * blendWeights.g + layer3 * blendWeights.b;
}
// ------ Parallax Utilities ----------------------------------------
@@ -203,16 +230,6 @@ bool ShouldHandleParallaxInDepthShaders()
return ShouldHandleParallax() && o_parallax_enablePixelDepthOffset;
}
-// These static values are used to pass extra data to the GetDepth callback function during the parallax depth search.
-static float3 s_blendMaskFromVertexStream;
-
-//! Setup static variables that are needed by the GetDepth callback function
-//! @param vertexBlendMask the blend mask values from the vertex input stream.
-void GetDepth_Setup(float3 vertexBlendMask)
-{
- s_blendMaskFromVertexStream = vertexBlendMask;
-}
-
// Callback function for ParallaxMapping.azsli
DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
{
@@ -260,8 +277,8 @@ DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
// Note, when the blend source is BlendMaskSource::VertexColors, parallax will not be able to blend correctly between layers. It will end up using the same blend mask values
// for every UV position when searching for the intersection. This leads to smearing artifacts at the transition point, but these won't be so noticeable as long as
// you have a small depth factor relative to the size of the blend transition.
- float3 blendMaskValues = GetBlendMaskValues(uv, s_blendMaskFromVertexStream);
+ float3 blendWeights = GetBlendWeights(uv);
- float depth = BlendLayers(layerDepthValues.r, layerDepthValues.g, layerDepthValues.b, blendMaskValues);
+ float depth = BlendLayers(layerDepthValues.r, layerDepthValues.g, layerDepthValues.b, blendWeights);
return DepthResultAbsolute(depth);
}
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_DepthPass_WithPS.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_DepthPass_WithPS.azsl
index ae156d7313..178deca8a2 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_DepthPass_WithPS.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_DepthPass_WithPS.azsl
@@ -108,7 +108,7 @@ PSDepthOutput MainPS(VSDepthOutput IN, bool isFrontFace : SV_IsFrontFace)
float3 bitangents[UvSetCount] = { IN.m_bitangent.xyz, float3(0, 0, 0) };
PrepareGeneratedTangent(IN.m_normal, IN.m_worldPosition, isFrontFace, IN.m_uv, UvSetCount, tangents, bitangents, 1);
- GetDepth_Setup(IN.m_blendMask);
+ s_blendMaskFromVertexStream = IN.m_blendMask;
float depth;
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl
index a83ea629e4..a690c0569a 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl
@@ -134,6 +134,8 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
{
depth = IN.m_position.z;
+ s_blendMaskFromVertexStream = IN.m_blendMask;
+
// ------- Tangents & Bitangets -------
// We support two UV streams, but only a single stream of tangent/bitangent. So for UV[1+] we generated the tangent/bitangent in screen-space.
@@ -156,15 +158,14 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
// ------- Debug Modes -------
- if(o_debugDrawMode == DebugDrawMode::BlendMaskValues)
+ if(o_debugDrawMode == DebugDrawMode::BlendSource)
{
- float3 blendMaskValues = GetBlendMaskValues(IN.m_uv[MaterialSrg::m_blendMaskUvIndex], IN.m_blendMask);
- return DebugOutput(blendMaskValues);
+ float3 blendSource = GetBlendSourceValues(IN.m_uv[MaterialSrg::m_blendMaskUvIndex]);
+ return DebugOutput(blendSource);
}
if(o_debugDrawMode == DebugDrawMode::DepthMaps)
{
- GetDepth_Setup(IN.m_blendMask);
float depth = GetNormalizedDepth(-MaterialSrg::m_displacementMax, -MaterialSrg::m_displacementMin, IN.m_uv[MaterialSrg::m_parallaxUvIndex], float2(0,0), float2(0,0));
return DebugOutput(float3(depth,depth,depth));
}
@@ -176,8 +177,6 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
// Parallax mapping's non uniform uv transformations break screen space subsurface scattering, disable it when subsurface scatteirng is enabled
if(ShouldHandleParallax())
{
- GetDepth_Setup(IN.m_blendMask);
-
float3x3 uvMatrix = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3();
float3x3 uvMatrixInverse = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrixInverse : CreateIdentity3x3();
@@ -218,13 +217,13 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
// ------- Calculate Layer Blend Mask Values -------
// Now that any parallax has been calculated, we calculate the blend factors for any layers that are impacted by the parallax.
- float3 blendMaskValues = GetBlendMaskValues(IN.m_uv[MaterialSrg::m_blendMaskUvIndex], IN.m_blendMask);
+ float3 blendWeights = GetBlendWeights(IN.m_uv[MaterialSrg::m_blendMaskUvIndex]);
// ------- Normal -------
- float3 layer1_normalFactor = MaterialSrg::m_layer1_m_normalFactor * blendMaskValues.r;
- float3 layer2_normalFactor = MaterialSrg::m_layer2_m_normalFactor * blendMaskValues.g;
- float3 layer3_normalFactor = MaterialSrg::m_layer3_m_normalFactor * blendMaskValues.b;
+ float3 layer1_normalFactor = MaterialSrg::m_layer1_m_normalFactor * blendWeights.r;
+ float3 layer2_normalFactor = MaterialSrg::m_layer2_m_normalFactor * blendWeights.g;
+ float3 layer3_normalFactor = MaterialSrg::m_layer3_m_normalFactor * blendWeights.b;
float3x3 layer1_uvMatrix = MaterialSrg::m_layer1_m_normalMapUvIndex == 0 ? MaterialSrg::m_layer1_m_uvMatrix : CreateIdentity3x3();
float3x3 layer2_uvMatrix = MaterialSrg::m_layer2_m_normalMapUvIndex == 0 ? MaterialSrg::m_layer2_m_uvMatrix : CreateIdentity3x3();
float3x3 layer3_uvMatrix = MaterialSrg::m_layer3_m_normalMapUvIndex == 0 ? MaterialSrg::m_layer3_m_uvMatrix : CreateIdentity3x3();
@@ -249,7 +248,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
float3 layer1_baseColor = BlendBaseColor(layer1_sampledColor, MaterialSrg::m_layer1_m_baseColor.rgb, MaterialSrg::m_layer1_m_baseColorFactor, o_layer1_o_baseColorTextureBlendMode, o_layer1_o_baseColor_useTexture);
float3 layer2_baseColor = BlendBaseColor(layer2_sampledColor, MaterialSrg::m_layer2_m_baseColor.rgb, MaterialSrg::m_layer2_m_baseColorFactor, o_layer2_o_baseColorTextureBlendMode, o_layer2_o_baseColor_useTexture);
float3 layer3_baseColor = BlendBaseColor(layer3_sampledColor, MaterialSrg::m_layer3_m_baseColor.rgb, MaterialSrg::m_layer3_m_baseColorFactor, o_layer3_o_baseColorTextureBlendMode, o_layer3_o_baseColor_useTexture);
- float3 baseColor = BlendLayers(layer1_baseColor, layer2_baseColor, layer3_baseColor, blendMaskValues);
+ float3 baseColor = BlendLayers(layer1_baseColor, layer2_baseColor, layer3_baseColor, blendWeights);
if(o_parallax_highlightClipping && displacementIsClipped)
{
@@ -264,7 +263,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
float layer1_metallic = GetMetallicInput(MaterialSrg::m_layer1_m_metallicMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_metallicMapUvIndex], MaterialSrg::m_layer1_m_metallicFactor, o_layer1_o_metallic_useTexture);
float layer2_metallic = GetMetallicInput(MaterialSrg::m_layer2_m_metallicMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_metallicMapUvIndex], MaterialSrg::m_layer2_m_metallicFactor, o_layer2_o_metallic_useTexture);
float layer3_metallic = GetMetallicInput(MaterialSrg::m_layer3_m_metallicMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_metallicMapUvIndex], MaterialSrg::m_layer3_m_metallicFactor, o_layer3_o_metallic_useTexture);
- metallic = BlendLayers(layer1_metallic, layer2_metallic, layer3_metallic, blendMaskValues);
+ metallic = BlendLayers(layer1_metallic, layer2_metallic, layer3_metallic, blendWeights);
}
// ------- Specular -------
@@ -272,7 +271,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
float layer1_specularF0Factor = GetSpecularInput(MaterialSrg::m_layer1_m_specularF0Map, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularF0MapUvIndex], MaterialSrg::m_layer1_m_specularF0Factor, o_layer1_o_specularF0_useTexture);
float layer2_specularF0Factor = GetSpecularInput(MaterialSrg::m_layer2_m_specularF0Map, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_specularF0MapUvIndex], MaterialSrg::m_layer2_m_specularF0Factor, o_layer2_o_specularF0_useTexture);
float layer3_specularF0Factor = GetSpecularInput(MaterialSrg::m_layer3_m_specularF0Map, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularF0MapUvIndex], MaterialSrg::m_layer3_m_specularF0Factor, o_layer3_o_specularF0_useTexture);
- float specularF0Factor = BlendLayers(layer1_specularF0Factor, layer2_specularF0Factor, layer3_specularF0Factor, blendMaskValues);
+ float specularF0Factor = BlendLayers(layer1_specularF0Factor, layer2_specularF0Factor, layer3_specularF0Factor, blendWeights);
surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
@@ -281,7 +280,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
float layer1_roughness = GetRoughnessInput(MaterialSrg::m_layer1_m_roughnessMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_roughnessMapUvIndex], MaterialSrg::m_layer1_m_roughnessFactor, MaterialSrg::m_layer1_m_roughnessLowerBound, MaterialSrg::m_layer1_m_roughnessUpperBound, o_layer1_o_roughness_useTexture);
float layer2_roughness = GetRoughnessInput(MaterialSrg::m_layer2_m_roughnessMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_roughnessMapUvIndex], MaterialSrg::m_layer2_m_roughnessFactor, MaterialSrg::m_layer2_m_roughnessLowerBound, MaterialSrg::m_layer2_m_roughnessUpperBound, o_layer2_o_roughness_useTexture);
float layer3_roughness = GetRoughnessInput(MaterialSrg::m_layer3_m_roughnessMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_roughnessMapUvIndex], MaterialSrg::m_layer3_m_roughnessFactor, MaterialSrg::m_layer3_m_roughnessLowerBound, MaterialSrg::m_layer3_m_roughnessUpperBound, o_layer3_o_roughness_useTexture);
- surface.roughnessLinear = BlendLayers(layer1_roughness, layer2_roughness, layer3_roughness, blendMaskValues);
+ surface.roughnessLinear = BlendLayers(layer1_roughness, layer2_roughness, layer3_roughness, blendWeights);
surface.CalculateRoughnessA();
@@ -314,19 +313,19 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
float3 layer1_emissive = GetEmissiveInput(MaterialSrg::m_layer1_m_emissiveMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_emissiveMapUvIndex], MaterialSrg::m_layer1_m_emissiveIntensity, MaterialSrg::m_layer1_m_emissiveColor.rgb, o_layer1_o_emissiveEnabled, o_layer1_o_emissive_useTexture);
float3 layer2_emissive = GetEmissiveInput(MaterialSrg::m_layer2_m_emissiveMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_emissiveMapUvIndex], MaterialSrg::m_layer2_m_emissiveIntensity, MaterialSrg::m_layer2_m_emissiveColor.rgb, o_layer2_o_emissiveEnabled, o_layer2_o_emissive_useTexture);
float3 layer3_emissive = GetEmissiveInput(MaterialSrg::m_layer3_m_emissiveMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_emissiveMapUvIndex], MaterialSrg::m_layer3_m_emissiveIntensity, MaterialSrg::m_layer3_m_emissiveColor.rgb, o_layer3_o_emissiveEnabled, o_layer3_o_emissive_useTexture);
- lightingData.emissiveLighting = BlendLayers(layer1_emissive, layer2_emissive, layer3_emissive, blendMaskValues);
+ lightingData.emissiveLighting = BlendLayers(layer1_emissive, layer2_emissive, layer3_emissive, blendWeights);
// ------- Occlusion -------
float layer1_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer1_m_diffuseOcclusionFactor, o_layer1_o_diffuseOcclusion_useTexture);
float layer2_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer2_m_diffuseOcclusionFactor, o_layer2_o_diffuseOcclusion_useTexture);
float layer3_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer3_m_diffuseOcclusionFactor, o_layer3_o_diffuseOcclusion_useTexture);
- lightingData.diffuseAmbientOcclusion = BlendLayers(layer1_diffuseAmbientOcclusion, layer2_diffuseAmbientOcclusion, layer3_diffuseAmbientOcclusion, blendMaskValues);
+ lightingData.diffuseAmbientOcclusion = BlendLayers(layer1_diffuseAmbientOcclusion, layer2_diffuseAmbientOcclusion, layer3_diffuseAmbientOcclusion, blendWeights);
float layer1_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer1_m_specularOcclusionFactor, o_layer1_o_specularOcclusion_useTexture);
float layer2_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer2_m_specularOcclusionFactor, o_layer2_o_specularOcclusion_useTexture);
float layer3_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer3_m_specularOcclusionFactor, o_layer3_o_specularOcclusion_useTexture);
- lightingData.specularOcclusion = BlendLayers(layer1_specularOcclusion, layer2_specularOcclusion, layer3_specularOcclusion, blendMaskValues);
+ lightingData.specularOcclusion = BlendLayers(layer1_specularOcclusion, layer2_specularOcclusion, layer3_specularOcclusion, blendWeights);
// ------- Clearcoat -------
@@ -385,11 +384,11 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
// --- Blend Layers ---
- surface.clearCoat.factor = BlendLayers(layer1_clearCoatFactor, layer2_clearCoatFactor, layer3_clearCoatFactor, blendMaskValues);
- surface.clearCoat.roughness = BlendLayers(layer1_clearCoatRoughness, layer2_clearCoatRoughness, layer3_clearCoatRoughness, blendMaskValues);
+ surface.clearCoat.factor = BlendLayers(layer1_clearCoatFactor, layer2_clearCoatFactor, layer3_clearCoatFactor, blendWeights);
+ surface.clearCoat.roughness = BlendLayers(layer1_clearCoatRoughness, layer2_clearCoatRoughness, layer3_clearCoatRoughness, blendWeights);
// [GFX TODO][ATOM-14592] This is not the right way to blend the normals. We need to use ReorientTangentSpaceNormal(), and that requires GetClearCoatInputs() to return the normal in TS instead of WS.
- surface.clearCoat.normal = BlendLayers(layer1_clearCoatNormal, layer2_clearCoatNormal, layer3_clearCoatNormal, blendMaskValues);
+ surface.clearCoat.normal = BlendLayers(layer1_clearCoatNormal, layer2_clearCoatNormal, layer3_clearCoatNormal, blendWeights);
surface.clearCoat.normal = normalize(surface.clearCoat.normal);
// manipulate base layer f0 if clear coat is enabled
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.azsl
index 325937b228..2ab4c50841 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.azsl
@@ -107,7 +107,7 @@ PSDepthOutput MainPS(VertexOutput IN, bool isFrontFace : SV_IsFrontFace)
float3 bitangents[UvSetCount] = { IN.m_bitangent.xyz, float3(0, 0, 0) };
PrepareGeneratedTangent(IN.m_normal, IN.m_worldPosition, isFrontFace, IN.m_uv, UvSetCount, tangents, bitangents, 1);
- GetDepth_Setup(IN.m_blendMask);
+ s_blendMaskFromVertexStream = IN.m_blendMask;
float depth;
diff --git a/Gems/Atom/Feature/Common/Assets/Textures/DefaultBlendMask_layers.png b/Gems/Atom/Feature/Common/Assets/Textures/DefaultBlendMask_layers.png
index d1606516af..5e60261dd7 100644
--- a/Gems/Atom/Feature/Common/Assets/Textures/DefaultBlendMask_layers.png
+++ b/Gems/Atom/Feature/Common/Assets/Textures/DefaultBlendMask_layers.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:f74ffab6ee15906158d27cbd2e5556e8fcdfd7820c0d0fd4b403de8a7af81662
-size 5651
+oid sha256:6660fa05dbf1e90298472fb41d99fff80a80de64ee88d17af4d0df3bdafb1ff6
+size 52877
diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material
index b2a3eac890..b85705fcb8 100644
--- a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material
+++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material
@@ -134,8 +134,14 @@
"enable": true
},
"uv": {
- "offsetU": -0.2800000011920929,
- "rotateDegrees": 39.599998474121097
+ "center": [
+ 0.10000000149011612,
+ 0.20000000298023225
+ ],
+ "offsetU": 0.23000000417232514,
+ "offsetV": -0.23999999463558198,
+ "rotateDegrees": 39.599998474121097,
+ "scale": 1.100000023841858
}
}
-}
+}
\ No newline at end of file
diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material
index e7903a8c91..f6c881aee5 100644
--- a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material
+++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material
@@ -30,6 +30,7 @@
"layer2_parallax": {
"enable": true,
"factor": 0.05299999937415123,
+ "offset": -0.024000000208616258,
"textureMap": "TestData/Textures/cc0/Rock030_2K_Displacement.jpg"
},
"layer2_roughness": {
@@ -49,4 +50,4 @@
"pdo": true
}
}
-}
+}
\ No newline at end of file
diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/003_Debug_BlendMaskValues.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/003_Debug_BlendSource.material
similarity index 86%
rename from Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/003_Debug_BlendMaskValues.material
rename to Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/003_Debug_BlendSource.material
index 94a1ec6a30..cdd21212c9 100644
--- a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/003_Debug_BlendMaskValues.material
+++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/003_Debug_BlendSource.material
@@ -5,7 +5,7 @@
"propertyLayoutVersion": 3,
"properties": {
"general": {
- "debugDrawMode": "BlendMaskValues"
+ "debugDrawMode": "BlendSource"
}
}
}
diff --git a/Gems/Atom/TestData/TestData/Objects/PaintedPlane.fbx b/Gems/Atom/TestData/TestData/Objects/PaintedPlane.fbx
new file mode 100644
index 0000000000..be30ca4639
--- /dev/null
+++ b/Gems/Atom/TestData/TestData/Objects/PaintedPlane.fbx
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:053a7cd73b37c815900f87abd524830e6f23eee75d3b72fb866e86498d528159
+size 36156
From 7276253c4225dd09dc0208693815abffe7ac672c Mon Sep 17 00:00:00 2001
From: sphrose <82213493+sphrose@users.noreply.github.com>
Date: Tue, 11 May 2021 08:20:44 +0100
Subject: [PATCH 015/163] renamed function
---
.../AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp | 4 ++--
.../AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
index faeae0a06d..85784d61e0 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
@@ -126,7 +126,7 @@ namespace AzToolsFramework
{
QStylePainter p(this);
- if (IsSectionSeparator())
+ if (IsReorderableRow())
{
const QPen linePen(QColor(0x3B3E3F));
p.setPen(linePen);
@@ -1332,7 +1332,7 @@ namespace AzToolsFramework
return canBeTopLevel(this);
}
- bool PropertyRowWidget::IsSectionSeparator() const
+ bool PropertyRowWidget::IsReorderableRow() const
{
return CanBeReordered();
}
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
index b6c94dc98b..58bf3bb9f0 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
@@ -83,7 +83,7 @@ namespace AzToolsFramework
PropertyRowWidget* GetParentRow() const { return m_parentRow; }
int GetLevel() const;
bool IsTopLevel() const;
- bool IsSectionSeparator() const;
+ bool IsReorderableRow() const;
// Remove the default label and append the text to the name label.
bool GetAppendDefaultLabelToName();
From 8e4d0d73dcea7f50d05a9318011de9a07e0d88e6 Mon Sep 17 00:00:00 2001
From: antonmic
Date: Tue, 11 May 2021 01:29:53 -0700
Subject: [PATCH 016/163] Good working state, but material always emmits low
end draw item
---
.../Materials/Types/StandardPBR.materialtype | 24 ++--
.../Atom/Features/PBR/Lights/Ibl.azsli | 108 ++++++------------
.../Atom/Features/ShaderQualityOptions.azsli | 3 +-
.../Code/Include/Atom/RPI.Public/Pass/Pass.h | 1 +
.../RPI/Code/Source/RPI.Public/Pass/Pass.cpp | 4 +-
5 files changed, 59 insertions(+), 81 deletions(-)
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype
index 1612bf43b0..47d8a9d9d5 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype
@@ -1304,9 +1304,11 @@
"textureProperty": "baseColor.textureMap",
"useTextureProperty": "baseColor.useTexture",
"dependentProperties": ["baseColor.textureMapUv", "baseColor.textureBlendMode"],
- "shaderTags": [
+ "shaderTags": [
"ForwardPass",
- "ForwardPass_EDS"
+ "ForwardPass_EDS",
+ "LowEndForward",
+ "LowEndForward_EDS"
],
"shaderOption": "o_baseColor_useTexture"
}
@@ -1317,9 +1319,11 @@
"textureProperty": "metallic.textureMap",
"useTextureProperty": "metallic.useTexture",
"dependentProperties": ["metallic.textureMapUv"],
- "shaderTags": [
+ "shaderTags": [
"ForwardPass",
- "ForwardPass_EDS"
+ "ForwardPass_EDS",
+ "LowEndForward",
+ "LowEndForward_EDS"
],
"shaderOption": "o_metallic_useTexture"
}
@@ -1330,9 +1334,11 @@
"textureProperty": "specularF0.textureMap",
"useTextureProperty": "specularF0.useTexture",
"dependentProperties": ["specularF0.textureMapUv"],
- "shaderTags": [
+ "shaderTags": [
"ForwardPass",
- "ForwardPass_EDS"
+ "ForwardPass_EDS",
+ "LowEndForward",
+ "LowEndForward_EDS"
],
"shaderOption": "o_specularF0_useTexture"
}
@@ -1343,9 +1349,11 @@
"textureProperty": "normal.textureMap",
"useTextureProperty": "normal.useTexture",
"dependentProperties": ["normal.textureMapUv", "normal.factor", "normal.flipX", "normal.flipY"],
- "shaderTags": [
+ "shaderTags": [
"ForwardPass",
- "ForwardPass_EDS"
+ "ForwardPass_EDS",
+ "LowEndForward",
+ "LowEndForward_EDS"
],
"shaderOption": "o_normal_useTexture"
}
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli
index 7400005508..721c48835d 100644
--- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli
+++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli
@@ -18,32 +18,30 @@
#include
#include
-void ApplyIblDiffuse(
+float3 GetIblDiffuse(
float3 normal,
float3 albedo,
- float3 diffuseResponse,
- out float3 outDiffuse)
+ float3 diffuseResponse)
{
float3 irradianceDir = MultiplyVectorQuaternion(normal, SceneSrg::m_iblOrientation);
float3 diffuseSample = SceneSrg::m_diffuseEnvMap.Sample(SceneSrg::m_samplerEnv, GetCubemapCoords(irradianceDir)).rgb;
- outDiffuse = diffuseResponse * albedo * diffuseSample;
+ return diffuseResponse * albedo * diffuseSample;
}
-void ApplyIblSpecular(
+float3 GetIblSpecular(
float3 position,
float3 normal,
float3 specularF0,
float roughnessLinear,
float3 dirToCamera,
- float2 brdf,
- out float3 outSpecular)
+ float2 brdf)
{
float3 reflectDir = reflect(-dirToCamera, normal);
reflectDir = MultiplyVectorQuaternion(reflectDir, SceneSrg::m_iblOrientation);
// global
- outSpecular = SceneSrg::m_specularEnvMap.SampleLevel(SceneSrg::m_samplerEnv, GetCubemapCoords(reflectDir), GetRoughnessMip(roughnessLinear)).rgb;
+ float3 outSpecular = SceneSrg::m_specularEnvMap.SampleLevel(SceneSrg::m_samplerEnv, GetCubemapCoords(reflectDir), GetRoughnessMip(roughnessLinear)).rgb;
outSpecular *= (specularF0 * brdf.x + brdf.y);
// reflection probe
@@ -72,86 +70,54 @@ void ApplyIblSpecular(
outSpecular = lerp(outSpecular, probeSpecular, blendAmount);
}
+ return outSpecular;
}
void ApplyIBL(Surface surface, inout LightingData lightingData)
{
- if (o_opacity_mode == OpacityMode::Blended || o_opacity_mode == OpacityMode::TintedTransparent)
+#ifdef FORCE_IBL_IN_FORWARD_PASS
+ bool useDiffuseIbl = true;
+ bool useSpecularIbl = true;
+ bool useIbl = true;
+#else
+ bool useDiffuseIbl = (o_opacity_mode == OpacityMode::Blended || o_opacity_mode == OpacityMode::TintedTransparent);
+ bool useSpecularIbl = (useDiffuseIbl || o_meshUseForwardPassIBLSpecular || o_materialUseForwardPassIBLSpecular);
+ bool useIbl = o_enableIBL && (useDiffuseIbl || useSpecularIbl);
+#endif
+
+ if(useIbl)
{
- // transparencies currently require IBL in the forward pass
- if (o_enableIBL)
+ float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure);
+
+ if(useDiffuseIbl)
{
- float3 iblDiffuse = 0.0f;
- ApplyIblDiffuse(
- surface.normal,
- surface.albedo,
- lightingData.diffuseResponse,
- iblDiffuse);
-
- float3 iblSpecular = 0.0f;
- ApplyIblSpecular(
- surface.position,
- surface.normal,
- surface.specularF0,
- surface.roughnessLinear,
- lightingData.dirToCamera,
- lightingData.brdf,
- iblSpecular);
-
- // Adjust IBL lighting by exposure.
- float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure);
+ float3 iblDiffuse = GetIblDiffuse(surface.normal, surface.albedo, lightingData.diffuseResponse);
lightingData.diffuseLighting += (iblDiffuse * iblExposureFactor * lightingData.diffuseAmbientOcclusion);
- lightingData.specularLighting += (iblSpecular * iblExposureFactor);
}
- }
- else if (o_meshUseForwardPassIBLSpecular || o_materialUseForwardPassIBLSpecular)
- {
- if (o_enableIBL)
- {
- float3 iblSpecular = 0.0f;
- ApplyIblSpecular(
- surface.position,
- surface.normal,
- surface.specularF0,
- surface.roughnessLinear,
- lightingData.dirToCamera,
- lightingData.brdf,
- iblSpecular);
+ if(useSpecularIbl)
+ {
+ float3 iblSpecular = GetIblSpecular(surface.position, surface.normal, surface.specularF0, surface.roughnessLinear, lightingData.dirToCamera, lightingData.brdf);
iblSpecular *= lightingData.multiScatterCompensation;
- if (o_clearCoat_feature_enabled)
+ if (o_clearCoat_feature_enabled && surface.clearCoat.factor > 0.0f)
{
- if (surface.clearCoat.factor > 0.0f)
- {
- float clearCoatNdotV = saturate(dot(surface.clearCoat.normal, lightingData.dirToCamera));
- clearCoatNdotV = max(clearCoatNdotV, 0.01f); // [GFX TODO][ATOM-4466] This is a current band-aid for specular noise at grazing angles.
- float2 clearCoatBrdf = PassSrg::m_brdfMap.Sample(PassSrg::LinearSampler, GetBRDFTexCoords(surface.clearCoat.roughness, clearCoatNdotV)).rg;
+ float clearCoatNdotV = saturate(dot(surface.clearCoat.normal, lightingData.dirToCamera));
+ clearCoatNdotV = max(clearCoatNdotV, 0.01f); // [GFX TODO][ATOM-4466] This is a current band-aid for specular noise at grazing angles.
+ float2 clearCoatBrdf = PassSrg::m_brdfMap.Sample(PassSrg::LinearSampler, GetBRDFTexCoords(surface.clearCoat.roughness, clearCoatNdotV)).rg;
- // clear coat uses fixed IOR = 1.5 represents polyurethane which is the most common material for gloss clear coat
- // coat layer assumed to be dielectric thus don't need multiple scattering compensation
- float3 clearCoatSpecularF0 = float3(0.04f, 0.04f, 0.04f);
- float3 clearCoatIblSpecular = 0.0f;
+ // clear coat uses fixed IOR = 1.5 represents polyurethane which is the most common material for gloss clear coat
+ // coat layer assumed to be dielectric thus don't need multiple scattering compensation
+ float3 clearCoatSpecularF0 = float3(0.04f, 0.04f, 0.04f);
+ float3 clearCoatIblSpecular = GetIblSpecular(surface.position, surface.clearCoat.normal, clearCoatSpecularF0, surface.clearCoat.roughness, lightingData.dirToCamera, clearCoatBrdf);
- ApplyIblSpecular(
- surface.position,
- surface.clearCoat.normal,
- clearCoatSpecularF0,
- surface.clearCoat.roughness,
- lightingData.dirToCamera,
- clearCoatBrdf,
- clearCoatIblSpecular);
-
- clearCoatIblSpecular *= surface.clearCoat.factor;
+ clearCoatIblSpecular *= surface.clearCoat.factor;
- // attenuate base layer energy
- float3 clearCoatResponse = FresnelSchlickWithRoughness(clearCoatNdotV, clearCoatSpecularF0, surface.clearCoat.roughness) * surface.clearCoat.factor;
- iblSpecular = iblSpecular * (1.0 - clearCoatResponse) * (1.0 - clearCoatResponse) + clearCoatIblSpecular;
- }
+ // attenuate base layer energy
+ float3 clearCoatResponse = FresnelSchlickWithRoughness(clearCoatNdotV, clearCoatSpecularF0, surface.clearCoat.roughness) * surface.clearCoat.factor;
+ iblSpecular = iblSpecular * (1.0 - clearCoatResponse) * (1.0 - clearCoatResponse) + clearCoatIblSpecular;
}
-
- float iblExposureFactor = pow(2.0f, SceneSrg::m_iblExposure);
lightingData.specularLighting += (iblSpecular * iblExposureFactor);
}
}
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli
index 907e67ada5..d6fb259548 100644
--- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli
+++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli
@@ -18,7 +18,8 @@
#ifdef QUALITY_LOW_END
-#define UNIFIED_FORWARD_OUTPUT 1
+#define UNIFIED_FORWARD_OUTPUT 1
+#define FORCE_IBL_IN_FORWARD_PASS 1
#endif
diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h
index b0d6bd4117..1cba71ae7e 100644
--- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h
+++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h
@@ -381,6 +381,7 @@ namespace AZ
uint64_t m_createdByPassRequest : 1;
uint64_t m_initialized : 1;
uint64_t m_enabled : 1;
+ uint64_t m_parentEnabled : 1;
uint64_t m_alreadyCreated : 1;
uint64_t m_alreadyReset : 1;
uint64_t m_alreadyPrepared : 1;
diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp
index 9401d1a9e0..f93d661b0f 100644
--- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp
+++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp
@@ -93,11 +93,12 @@ namespace AZ
void Pass::SetEnabled(bool enabled)
{
m_flags.m_enabled = enabled;
+ OnHierarchyChange();
}
bool Pass::IsEnabled() const
{
- return m_flags.m_enabled;
+ return m_flags.m_enabled && (m_flags.m_parentEnabled || m_parent == nullptr);
}
// --- Error Logging ---
@@ -140,6 +141,7 @@ namespace AZ
}
// Set new tree depth and path
+ m_flags.m_parentEnabled = m_parent->IsEnabled();
m_treeDepth = m_parent->m_treeDepth + 1;
m_path = ConcatPassName(m_parent->m_path, m_name);
m_flags.m_partOfHierarchy = m_parent->m_flags.m_partOfHierarchy;
From b08643d9da90d0215ed5b22efcc3716fdaa90622 Mon Sep 17 00:00:00 2001
From: sphrose <82213493+sphrose@users.noreply.github.com>
Date: Tue, 11 May 2021 11:24:51 +0100
Subject: [PATCH 017/163] Use renamed functions in stylesheet.
---
.../AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx | 2 +-
Code/Sandbox/Editor/Style/Editor.qss | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
index 58bf3bb9f0..1c17cab69f 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
@@ -44,7 +44,7 @@ namespace AzToolsFramework
Q_PROPERTY(bool hasChildRows READ HasChildRows);
Q_PROPERTY(bool isTopLevel READ IsTopLevel);
Q_PROPERTY(int getLevel READ GetLevel);
- Q_PROPERTY(bool isSectionSeparator READ IsSectionSeparator);
+ Q_PROPERTY(bool canBeReordered READ CanBeReordered);
Q_PROPERTY(bool appendDefaultLabelToName READ GetAppendDefaultLabelToName WRITE AppendDefaultLabelToName)
public:
AZ_CLASS_ALLOCATOR(PropertyRowWidget, AZ::SystemAllocator, 0)
diff --git a/Code/Sandbox/Editor/Style/Editor.qss b/Code/Sandbox/Editor/Style/Editor.qss
index 7887560105..fa7d67dd43 100644
--- a/Code/Sandbox/Editor/Style/Editor.qss
+++ b/Code/Sandbox/Editor/Style/Editor.qss
@@ -38,7 +38,7 @@ AzToolsFramework--ComponentPaletteWidget > QTreeView
background-color: #222222;
}
-AzToolsFramework--PropertyRowWidget[isSectionSeparator="true"] QLabel#Name
+AzToolsFramework--PropertyRowWidget[canBeReordered="true"] QLabel#Name
{
font-weight: bold;
}
From 9775822778ec2cf8003ea86f455906f75bce1c14 Mon Sep 17 00:00:00 2001
From: scottr
Date: Tue, 11 May 2021 16:09:16 -0700
Subject: [PATCH 018/163] [cpack_installer] remove wxs file ext from lfs filter
---
.gitattributes | 1 -
1 file changed, 1 deletion(-)
diff --git a/.gitattributes b/.gitattributes
index 1755def66a..55b43e4ba7 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -115,5 +115,4 @@
*.wav filter=lfs diff=lfs merge=lfs -text
*.webm filter=lfs diff=lfs merge=lfs -text
*.wem filter=lfs diff=lfs merge=lfs -text
-*.wxs filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
From 9faf35b529d942dffe1b9fce7d9310be8de9edf8 Mon Sep 17 00:00:00 2001
From: Chris Santora
Date: Tue, 11 May 2021 17:09:41 -0700
Subject: [PATCH 019/163] Refactor in prepration for ATOM-14688 "Disable
Individual Layers"
Refactored StandardMultilayerPBR to collate all the code for each layer into a couple structs and utility functions. This makes the code easier to maintain, and in particular will make it easy for me to add Enable flags for the layers in a subsequent commit.
Also removed subsurface scattering and translucency from StandardMultilayerPBR, according to ATOM-4120 "Stabilize Standard PBR Regarding Subsurface and Translucency".
Squashed commit of the following:
commit a6052d6ad4f70183d0ce72e84c7dc5512dc24d5e
Author: Chris Santora
Date: Tue May 11 16:32:15 2021 -0700
Got the refactor finally working. I had change it to blend the baseColor, spec factor, and metalness before converting to albedo and spec, in order to get exactly the same results as before.
commit 42d6da7f405097dea07b6ed0426d6a662b61440d
Author: Chris Santora
Date: Tue May 11 15:58:38 2021 -0700
Fixed clear coat issue due to LightingData initialized too late.
commit 358194a5caf6f9eb99b0e5345ad5f7768b244a93
Author: Chris Santora
Date: Tue May 11 15:18:30 2021 -0700
Fixed a couple issues.
commit adb431f8113b945057959db288a7ee2dd825dd69
Author: Chris Santora
Date: Tue May 11 12:42:12 2021 -0700
WIP refactor of StandardMultilayerPBR to collate the code for each layer. Also removed subsurface scattering from multilayer.
---
.../Types/StandardMultilayerPBR.materialtype | 207 ---------
.../Types/StandardMultilayerPBR_Common.azsli | 18 -
.../StandardMultilayerPBR_ForwardPass.azsl | 398 ++++++++++--------
.../PBR/Surfaces/StandardSurface.azsli | 14 +
4 files changed, 244 insertions(+), 393 deletions(-)
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
index 3e95846b6e..90a599c6f9 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
@@ -23,11 +23,6 @@
"displayName": "UVs",
"description": "Properties for configuring UV transforms for the entire material, including the blend masks."
},
- {
- "id": "subsurfaceScattering",
- "displayName": "Subsurface Scattering",
- "description": "Properties for configuring subsurface scattering effects."
- },
{
// Note: this property group is used in the DiffuseGlobalIllumination pass, it is not read by the StandardPBR shader
"id": "irradiance",
@@ -467,183 +462,6 @@
"step": 0.1
}
],
- "subsurfaceScattering": [
- {
- "id": "enableSubsurfaceScattering",
- "displayName": "Subsurface Scattering",
- "description": "Enable subsurface scattering feature, this will disable metallic and parallax mapping property due to incompatibility",
- "type": "Bool",
- "defaultValue": false,
- "connection": {
- "type": "ShaderOption",
- "id": "o_enableSubsurfaceScattering"
- }
- },
- {
- "id": "subsurfaceScatterFactor",
- "displayName": " Factor",
- "description": "Strength factor for scaling percentage of subsurface scattering effect applied",
- "type": "float",
- "defaultValue": 1.0,
- "min": 0.0,
- "max": 1.0,
- "connection": {
- "type": "ShaderInput",
- "id": "m_subsurfaceScatteringFactor"
- }
- },
- {
- "id": "influenceMap",
- "displayName": " Influence Map",
- "description": "Use texture map to control the strength of subsurface scattering",
- "type": "Image",
- "connection": {
- "type": "ShaderInput",
- "id": "m_subsurfaceScatteringInfluenceMap"
- }
- },
- {
- "id": "useInfluenceMap",
- "displayName": " Use Influence Map",
- "description": "Whether to use the texture map as influence mask.",
- "type": "Bool",
- "defaultValue": true
- },
- {
- "id": "influenceMapUv",
- "displayName": " UV",
- "description": "Influence map UV set",
- "type": "Enum",
- "enumIsUv": true,
- "defaultValue": "Tiled",
- "connection": {
- "type": "ShaderInput",
- "id": "m_subsurfaceScatteringInfluenceMapUvIndex"
- }
- },
- {
- "id": "scatterColor",
- "displayName": " Scatter color",
- "description": "Color of volume light traveled through",
- "type": "Color",
- "defaultValue": [ 1.0, 0.27, 0.13 ]
- },
- {
- "id": "scatterDistance",
- "displayName": " Scatter distance",
- "description": "How far light traveled inside the volume",
- "type": "float",
- "defaultValue": 8,
- "min": 0.0,
- "softMax": 20.0
- },
- {
- "id": "quality",
- "displayName": " Quality",
- "description": "How much percent of sample will be used for each pixel, more samples improve quality and reduce artifacts, especially when the scatter distance is relatively large, but slow down computation time, 1.0 = full set 200 samples per pixel",
- "type": "float",
- "defaultValue": 0.4,
- "min": 0.2,
- "max": 1.0,
- "connection": {
- "type": "ShaderInput",
- "id": "m_subsurfaceScatteringQuality"
- }
- },
- {
- "id": "transmissionMode",
- "displayName": "Transmission",
- "description": "Algorithm used for calculating transmission",
- "type": "Enum",
- "enumValues": [ "None", "ThickObject", "ThinObject" ],
- "defaultValue": "None",
- "connection": {
- "type": "ShaderOption",
- "id": "o_transmission_mode"
- }
- },
- {
- "id": "thickness",
- "displayName": " Thickness",
- "description": "Normalized global thickness, the maxima between this value (multiplied by thickness map if enabled) and thickness from shadow map (if applicable) will be used as final thickness of pixel",
- "type": "float",
- "defaultValue": 0.5,
- "min": 0.0,
- "max": 1.0
- },
- {
- "id": "thicknessMap",
- "displayName": " Thickness Map",
- "description": "Use a greyscale texture for per pixel thickness",
- "type": "Image",
- "connection": {
- "type": "ShaderInput",
- "id": "m_transmissionThicknessMap"
- }
- },
- {
- "id": "useThicknessMap",
- "displayName": " Use Thickness Map",
- "description": "Whether to use the thickness map",
- "type": "Bool",
- "defaultValue": true
- },
- {
- "id": "thicknessMapUv",
- "displayName": " UV",
- "description": "Thickness map UV set",
- "type": "Enum",
- "enumIsUv": true,
- "defaultValue": "Tiled",
- "connection": {
- "type": "ShaderInput",
- "id": "m_transmissionThicknessMapUvIndex"
- }
- },
- {
- "id": "transmissionTint",
- "displayName": " Transmission Tint",
- "description": "Color of the volume light travelling through",
- "type": "Color",
- "defaultValue": [ 1.0, 0.8, 0.6 ]
- },
- {
- "id": "transmissionPower",
- "displayName": " Power",
- "description": "How much transmitted light scatter radially ",
- "type": "float",
- "defaultValue": 6.0,
- "min": 0.0,
- "softMax": 20.0
- },
- {
- "id": "transmissionDistortion",
- "displayName": " Distortion",
- "description": "How much light direction distorted towards surface normal",
- "type": "float",
- "defaultValue": 0.1,
- "min": 0.0,
- "max": 1.0
- },
- {
- "id": "transmissionAttenuation",
- "displayName": " Attenuation",
- "description": "How fast transmitted light fade with thickness",
- "type": "float",
- "defaultValue": 4.0,
- "min": 0.0,
- "softMax": 20.0
- },
- {
- "id": "transmissionScale",
- "displayName": " Scale",
- "description": "Strength of transmission",
- "type": "float",
- "defaultValue": 3.0,
- "min": 0.0,
- "softMax": 20.0
- }
- ],
"irradiance": [
// Note: this property group is used in the DiffuseGlobalIllumination pass, it is not read by the StandardPBR shader
{
@@ -2844,25 +2662,6 @@
"file": "StandardMultilayerPBR_ShaderEnable.lua"
}
},
- {
- // Preprocess & build parameter set for subsurface scattering and translucency
- "type": "HandleSubsurfaceScatteringParameters",
- "args": {
- "mode": "subsurfaceScattering.transmissionMode",
- "scale" : "subsurfaceScattering.transmissionScale",
- "power" : "subsurfaceScattering.transmissionPower",
- "distortion" : "subsurfaceScattering.transmissionDistortion",
- "attenuation" : "subsurfaceScattering.transmissionAttenuation",
- "tintColor" : "subsurfaceScattering.transmissionTint",
- "thickness" : "subsurfaceScattering.thickness",
- "enabled": "subsurfaceScattering.enableSubsurfaceScattering",
- "scatterDistanceColor" : "subsurfaceScattering.scatterColor",
- "scatterDistanceIntensity" : "subsurfaceScattering.scatterDistance",
- "scatterDistanceShaderInput" : "m_scatterDistance",
- "parametersShaderInput" : "m_transmissionParams",
- "tintThickenssShaderInput" : "m_transmissionTintThickness"
- }
- },
{
"type": "Lua",
"args": {
@@ -2875,12 +2674,6 @@
"file": "StandardMultilayerPBR_Parallax.lua"
}
},
- {
- "type": "Lua",
- "args": {
- "file": "StandardPBR_SubsurfaceState.lua"
- }
- },
//##############################################################################################
// Layer 1 Functors
//##############################################################################################
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli
index f1f6d90e14..8c7b49214b 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli
@@ -91,24 +91,6 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial
MipFilter = Linear;
};
- // Parameters for subsurface scattering
- float m_subsurfaceScatteringFactor;
- float m_subsurfaceScatteringQuality;
- float3 m_scatterDistance;
- Texture2D m_subsurfaceScatteringInfluenceMap;
- uint m_subsurfaceScatteringInfluenceMapUvIndex;
-
- // Parameters for transmission
-
- // Elements of m_transmissionParams:
- // Thick object mode: (attenuation coefficient, power, distortion, scale)
- // Thin object mode: (float3 scatter distance, scale)
- float4 m_transmissionParams;
-
- // (float3 TintColor, thickness)
- float4 m_transmissionTintThickness;
- Texture2D m_transmissionThicknessMap;
- uint m_transmissionThicknessMapUvIndex;
}
// ------ Shader Options ----------------------------------------
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl
index a690c0569a..9e5a2e623a 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl
@@ -55,7 +55,6 @@ DEFINE_LAYER_OPTIONS(o_layer1_)
DEFINE_LAYER_OPTIONS(o_layer2_)
DEFINE_LAYER_OPTIONS(o_layer3_)
-#include "MaterialInputs/SubsurfaceInput.azsli"
#include "MaterialInputs/TransmissionInput.azsli"
#include "StandardMultilayerPBR_Common.azsli"
@@ -127,6 +126,181 @@ VSOutput ForwardPassVS(VSInput IN)
return OUT;
}
+//! Collects all the raw Standard material inputs for a single layer. See ProcessStandardMaterialInputs().
+struct StandardMaterialInputs
+{
+ COMMON_SRG_INPUTS_BASE_COLOR()
+ COMMON_SRG_INPUTS_ROUGHNESS()
+ COMMON_SRG_INPUTS_METALLIC()
+ COMMON_SRG_INPUTS_SPECULAR_F0()
+ COMMON_SRG_INPUTS_NORMAL()
+ COMMON_SRG_INPUTS_CLEAR_COAT()
+ COMMON_SRG_INPUTS_OCCLUSION()
+ COMMON_SRG_INPUTS_EMISSIVE()
+ // Note parallax is omitted here because that requires special handling.
+
+ bool m_normal_useTexture;
+ bool m_baseColor_useTexture;
+ bool m_metallic_useTexture;
+ bool m_specularF0_useTexture;
+ bool m_roughness_useTexture;
+ bool m_emissiveEnabled;
+ bool m_emissive_useTexture;
+ bool m_diffuseOcclusion_useTexture;
+ bool m_specularOcclusion_useTexture;
+ bool m_clearCoatEnabled;
+ bool m_clearCoat_factor_useTexture;
+ bool m_clearCoat_roughness_useTexture;
+ bool m_clearCoat_normal_useTexture;
+
+ TextureBlendMode m_baseColorTextureBlendMode;
+
+ float2 m_vertexUv[UvSetCount];
+ float3x3 m_uvMatrix;
+ float m_normal;
+ float3 m_tangents[UvSetCount];
+ float3 m_bitangents[UvSetCount];
+
+ sampler m_sampler;
+
+ bool m_isFrontFace;
+};
+
+//! Holds the final processed material inputs, after all flags have been checked, textures have been sampled, factors have been applied, etc.
+//! This data is ready to be copied into a Surface and/or LightingData struct for the lighting system to consume.
+class ProcessedMaterialInputs
+{
+ float3 m_normalTS; //!< Normal in tangent-space
+ float3 m_baseColor;
+ float3 m_specularF0Factor;
+ float m_metallic;
+ float m_roughness;
+ float3 m_emissiveLighting;
+ float m_diffuseAmbientOcclusion;
+ float m_specularOcclusion;
+ ClearCoatSurfaceData m_clearCoat;
+
+ void InitializeToZero()
+ {
+ m_normalTS = float3(0,0,0);
+ m_baseColor = float3(0,0,0);
+ m_specularF0Factor = float3(0,0,0);
+ m_metallic = 0.0f;
+ m_roughness = 0.0f;
+ m_emissiveLighting = float3(0,0,0);
+ m_diffuseAmbientOcclusion = 0;
+ m_specularOcclusion = 0;
+ m_clearCoat.InitializeToZero();
+ }
+};
+
+//! Processes the set of Standard material inputs for a single layer.
+//! The FILL_STANDARD_MATERIAL_INPUTS() macro below can be used to fill the StandardMaterialInputs struct.
+ProcessedMaterialInputs ProcessStandardMaterialInputs(StandardMaterialInputs inputs)
+{
+ ProcessedMaterialInputs result;
+
+ float2 transformedUv[UvSetCount];
+ transformedUv[0] = mul(inputs.m_uvMatrix, float3(inputs.m_vertexUv[0], 1.0)).xy;
+ transformedUv[1] = inputs.m_vertexUv[1];
+
+ float3x3 normalUvMatrix = inputs.m_normalMapUvIndex == 0 ? inputs.m_uvMatrix : CreateIdentity3x3();
+ result.m_normalTS = GetNormalInputTS(inputs.m_normalMap, inputs.m_sampler, transformedUv[inputs.m_normalMapUvIndex], inputs.m_flipNormalX, inputs.m_flipNormalY, normalUvMatrix, inputs.m_normal_useTexture, inputs.m_normalFactor);
+
+ float3 sampledBaseColor = GetBaseColorInput(inputs.m_baseColorMap, inputs.m_sampler, transformedUv[inputs.m_baseColorMapUvIndex], inputs.m_baseColor.rgb, inputs.m_baseColor_useTexture);
+ result.m_baseColor = BlendBaseColor(sampledBaseColor, inputs.m_baseColor.rgb, inputs.m_baseColorFactor, inputs.m_baseColorTextureBlendMode, inputs.m_baseColor_useTexture);
+ result.m_specularF0Factor = GetSpecularInput(inputs.m_specularF0Map, inputs.m_sampler, transformedUv[inputs.m_specularF0MapUvIndex], inputs.m_specularF0Factor, inputs.m_specularF0_useTexture);
+ result.m_metallic = GetMetallicInput(inputs.m_metallicMap, inputs.m_sampler, transformedUv[inputs.m_metallicMapUvIndex], inputs.m_metallicFactor, inputs.m_metallic_useTexture);
+ result.m_roughness = GetRoughnessInput(inputs.m_roughnessMap, MaterialSrg::m_sampler, transformedUv[inputs.m_roughnessMapUvIndex], inputs.m_roughnessFactor, inputs.m_roughnessLowerBound, inputs.m_roughnessUpperBound, inputs.m_roughness_useTexture);
+
+ result.m_emissiveLighting = GetEmissiveInput(inputs.m_emissiveMap, inputs.m_sampler, transformedUv[inputs.m_emissiveMapUvIndex], inputs.m_emissiveIntensity, inputs.m_emissiveColor.rgb, inputs.m_emissiveEnabled, inputs.m_emissive_useTexture);
+ result.m_diffuseAmbientOcclusion = GetOcclusionInput(inputs.m_diffuseOcclusionMap, inputs.m_sampler, transformedUv[inputs.m_diffuseOcclusionMapUvIndex], inputs.m_diffuseOcclusionFactor, inputs.m_diffuseOcclusion_useTexture);
+ result.m_specularOcclusion = GetOcclusionInput(inputs.m_specularOcclusionMap, MaterialSrg::m_sampler, transformedUv[inputs.m_specularOcclusionMapUvIndex], inputs.m_specularOcclusionFactor, inputs.m_specularOcclusion_useTexture);
+
+ result.m_clearCoat.InitializeToZero();
+ if(inputs.m_clearCoatEnabled)
+ {
+ float3x3 clearCoatUvMatrix = inputs.m_clearCoatNormalMapUvIndex == 0 ? inputs.m_uvMatrix : CreateIdentity3x3();
+
+ GetClearCoatInputs(inputs.m_clearCoatInfluenceMap, transformedUv[inputs.m_clearCoatInfluenceMapUvIndex], inputs.m_clearCoatFactor, inputs.m_clearCoat_factor_useTexture,
+ inputs.m_clearCoatRoughnessMap, transformedUv[inputs.m_clearCoatRoughnessMapUvIndex], inputs.m_clearCoatRoughness, inputs.m_clearCoat_roughness_useTexture,
+ inputs.m_clearCoatNormalMap, transformedUv[inputs.m_clearCoatNormalMapUvIndex], inputs.m_normal, inputs.m_clearCoat_normal_useTexture, inputs.m_clearCoatNormalStrength,
+ clearCoatUvMatrix, inputs.m_tangents[inputs.m_clearCoatNormalMapUvIndex], inputs.m_bitangents[inputs.m_clearCoatNormalMapUvIndex],
+ inputs.m_sampler, inputs.m_isFrontFace,
+ result.m_clearCoat.factor, result.m_clearCoat.roughness, result.m_clearCoat.normal);
+ }
+
+ return result;
+}
+
+//! Fills a StandardMaterialInputs struct with data from the MaterialSrg, shader options, and local vertex data.
+#define FILL_STANDARD_MATERIAL_INPUTS(inputs, srgLayerPrefix, optionsLayerPrefix, blendWeight) \
+ inputs.m_sampler = MaterialSrg::m_sampler; \
+ inputs.m_vertexUv = IN.m_uv; \
+ inputs.m_uvMatrix = srgLayerPrefix##m_uvMatrix; \
+ inputs.m_normal = IN.m_normal; \
+ inputs.m_tangents = tangents; \
+ inputs.m_bitangents = bitangents; \
+ inputs.m_isFrontFace = isFrontFace; \
+ \
+ inputs.m_normalMapUvIndex = srgLayerPrefix##m_normalMapUvIndex; \
+ inputs.m_normalMap = srgLayerPrefix##m_normalMap; \
+ inputs.m_flipNormalX = srgLayerPrefix##m_flipNormalX; \
+ inputs.m_flipNormalY = srgLayerPrefix##m_flipNormalY; \
+ inputs.m_normal_useTexture = optionsLayerPrefix##o_normal_useTexture; \
+ inputs.m_normalFactor = srgLayerPrefix##m_normalFactor * blendWeight; \
+ inputs.m_baseColorMap = srgLayerPrefix##m_baseColorMap; \
+ inputs.m_baseColorMapUvIndex = srgLayerPrefix##m_baseColorMapUvIndex; \
+ inputs.m_baseColor = srgLayerPrefix##m_baseColor; \
+ inputs.m_baseColor_useTexture = optionsLayerPrefix##o_baseColor_useTexture; \
+ inputs.m_baseColorFactor = srgLayerPrefix##m_baseColorFactor; \
+ inputs.m_baseColorTextureBlendMode = optionsLayerPrefix##o_baseColorTextureBlendMode; \
+ inputs.m_metallicMap = srgLayerPrefix##m_metallicMap; \
+ inputs.m_metallicMapUvIndex = srgLayerPrefix##m_metallicMapUvIndex; \
+ inputs.m_metallicFactor = srgLayerPrefix##m_metallicFactor; \
+ inputs.m_metallic_useTexture = optionsLayerPrefix##o_metallic_useTexture; \
+ inputs.m_specularF0Map = srgLayerPrefix##m_specularF0Map; \
+ inputs.m_specularF0MapUvIndex = srgLayerPrefix##m_specularF0MapUvIndex; \
+ inputs.m_specularF0Factor = srgLayerPrefix##m_specularF0Factor; \
+ inputs.m_specularF0_useTexture = optionsLayerPrefix##o_specularF0_useTexture; \
+ inputs.m_roughnessMap = srgLayerPrefix##m_roughnessMap; \
+ inputs.m_roughnessMapUvIndex = srgLayerPrefix##m_roughnessMapUvIndex; \
+ inputs.m_roughnessFactor = srgLayerPrefix##m_roughnessFactor; \
+ inputs.m_roughnessLowerBound = srgLayerPrefix##m_roughnessLowerBound; \
+ inputs.m_roughnessUpperBound = srgLayerPrefix##m_roughnessUpperBound; \
+ inputs.m_roughness_useTexture = optionsLayerPrefix##o_roughness_useTexture; \
+ \
+ inputs.m_emissiveMap = srgLayerPrefix##m_emissiveMap; \
+ inputs.m_emissiveMapUvIndex = srgLayerPrefix##m_emissiveMapUvIndex; \
+ inputs.m_emissiveIntensity = srgLayerPrefix##m_emissiveIntensity; \
+ inputs.m_emissiveColor = srgLayerPrefix##m_emissiveColor; \
+ inputs.m_emissiveEnabled = optionsLayerPrefix##o_emissiveEnabled; \
+ inputs.m_emissive_useTexture = optionsLayerPrefix##o_emissive_useTexture; \
+ \
+ inputs.m_diffuseOcclusionMap = srgLayerPrefix##m_diffuseOcclusionMap; \
+ inputs.m_diffuseOcclusionMapUvIndex = srgLayerPrefix##m_diffuseOcclusionMapUvIndex; \
+ inputs.m_diffuseOcclusionFactor = srgLayerPrefix##m_diffuseOcclusionFactor; \
+ inputs.m_diffuseOcclusion_useTexture = optionsLayerPrefix##o_diffuseOcclusion_useTexture; \
+ \
+ inputs.m_specularOcclusionMap = srgLayerPrefix##m_specularOcclusionMap; \
+ inputs.m_specularOcclusionMapUvIndex = srgLayerPrefix##m_specularOcclusionMapUvIndex; \
+ inputs.m_specularOcclusionFactor = srgLayerPrefix##m_specularOcclusionFactor; \
+ inputs.m_specularOcclusion_useTexture = optionsLayerPrefix##o_specularOcclusion_useTexture; \
+ \
+ inputs.m_clearCoatEnabled = o_clearCoat_feature_enabled && optionsLayerPrefix##o_clearCoat_enabled; \
+ inputs.m_clearCoatInfluenceMap = srgLayerPrefix##m_clearCoatInfluenceMap; \
+ inputs.m_clearCoatInfluenceMapUvIndex = srgLayerPrefix##m_clearCoatInfluenceMapUvIndex; \
+ inputs.m_clearCoatFactor = srgLayerPrefix##m_clearCoatFactor; \
+ inputs.m_clearCoat_factor_useTexture = optionsLayerPrefix##o_clearCoat_factor_useTexture; \
+ inputs.m_clearCoatRoughnessMap = srgLayerPrefix##m_clearCoatRoughnessMap; \
+ inputs.m_clearCoatRoughnessMapUvIndex = srgLayerPrefix##m_clearCoatRoughnessMapUvIndex; \
+ inputs.m_clearCoatRoughness = srgLayerPrefix##m_clearCoatRoughness; \
+ inputs.m_clearCoat_roughness_useTexture = optionsLayerPrefix##o_clearCoat_roughness_useTexture; \
+ inputs.m_clearCoatNormalMap = srgLayerPrefix##m_clearCoatNormalMap; \
+ inputs.m_clearCoatNormalMapUvIndex = srgLayerPrefix##m_clearCoatNormalMapUvIndex; \
+ inputs.m_clearCoat_normal_useTexture = optionsLayerPrefix##o_clearCoat_normal_useTexture; \
+ inputs.m_clearCoatNormalStrength = srgLayerPrefix##m_clearCoatNormalStrength;
+
// ---------- Pixel Shader ----------
@@ -174,7 +348,6 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
bool displacementIsClipped = false;
- // Parallax mapping's non uniform uv transformations break screen space subsurface scattering, disable it when subsurface scatteirng is enabled
if(ShouldHandleParallax())
{
float3x3 uvMatrix = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3();
@@ -197,108 +370,70 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
}
}
- Surface surface;
- surface.position = IN.m_worldPosition;
-
- // ------- Setup the per-layer UV transforms -------
-
- float2 uvLayer1[UvSetCount];
- float2 uvLayer2[UvSetCount];
- float2 uvLayer3[UvSetCount];
-
- // Only UV0 will be applied transforms from each layer.
- uvLayer1[0] = mul(MaterialSrg::m_layer1_m_uvMatrix, float3(IN.m_uv[0], 1.0)).xy;
- uvLayer2[0] = mul(MaterialSrg::m_layer2_m_uvMatrix, float3(IN.m_uv[0], 1.0)).xy;
- uvLayer3[0] = mul(MaterialSrg::m_layer3_m_uvMatrix, float3(IN.m_uv[0], 1.0)).xy;
- uvLayer1[1] = IN.m_uv[1];
- uvLayer2[1] = IN.m_uv[1];
- uvLayer3[1] = IN.m_uv[1];
-
// ------- Calculate Layer Blend Mask Values -------
// Now that any parallax has been calculated, we calculate the blend factors for any layers that are impacted by the parallax.
float3 blendWeights = GetBlendWeights(IN.m_uv[MaterialSrg::m_blendMaskUvIndex]);
- // ------- Normal -------
+ // ------- Layer 1 (base layer) -----------
+
+ ProcessedMaterialInputs lightingInputLayer1;
+ {
+ StandardMaterialInputs inputs;
+ FILL_STANDARD_MATERIAL_INPUTS(inputs, MaterialSrg::m_layer1_, o_layer1_, blendWeights.r)
+ lightingInputLayer1 = ProcessStandardMaterialInputs(inputs);
+ }
- float3 layer1_normalFactor = MaterialSrg::m_layer1_m_normalFactor * blendWeights.r;
- float3 layer2_normalFactor = MaterialSrg::m_layer2_m_normalFactor * blendWeights.g;
- float3 layer3_normalFactor = MaterialSrg::m_layer3_m_normalFactor * blendWeights.b;
- float3x3 layer1_uvMatrix = MaterialSrg::m_layer1_m_normalMapUvIndex == 0 ? MaterialSrg::m_layer1_m_uvMatrix : CreateIdentity3x3();
- float3x3 layer2_uvMatrix = MaterialSrg::m_layer2_m_normalMapUvIndex == 0 ? MaterialSrg::m_layer2_m_uvMatrix : CreateIdentity3x3();
- float3x3 layer3_uvMatrix = MaterialSrg::m_layer3_m_normalMapUvIndex == 0 ? MaterialSrg::m_layer3_m_uvMatrix : CreateIdentity3x3();
- float3 layer1_normalTS = GetNormalInputTS(MaterialSrg::m_layer1_m_normalMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_normalMapUvIndex], MaterialSrg::m_layer1_m_flipNormalX, MaterialSrg::m_layer1_m_flipNormalY, layer1_uvMatrix, o_layer1_o_normal_useTexture, layer1_normalFactor);
- float3 layer2_normalTS = GetNormalInputTS(MaterialSrg::m_layer2_m_normalMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_normalMapUvIndex], MaterialSrg::m_layer2_m_flipNormalX, MaterialSrg::m_layer2_m_flipNormalY, layer2_uvMatrix, o_layer2_o_normal_useTexture, layer2_normalFactor);
- float3 layer3_normalTS = GetNormalInputTS(MaterialSrg::m_layer3_m_normalMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_normalMapUvIndex], MaterialSrg::m_layer3_m_flipNormalX, MaterialSrg::m_layer3_m_flipNormalY, layer3_uvMatrix, o_layer3_o_normal_useTexture, layer3_normalFactor);
+ // ----------- Layer 2 -----------
+
+ ProcessedMaterialInputs lightingInputLayer2;
+ {
+ StandardMaterialInputs inputs;
+ FILL_STANDARD_MATERIAL_INPUTS(inputs, MaterialSrg::m_layer2_, o_layer2_, blendWeights.g)
+ lightingInputLayer2 = ProcessStandardMaterialInputs(inputs);
+ }
- float3 normalTS = ReorientTangentSpaceNormal(layer1_normalTS, layer2_normalTS);
- normalTS = ReorientTangentSpaceNormal(normalTS, layer3_normalTS);
+ // ----------- Layer 3 -----------
+
+ ProcessedMaterialInputs lightingInputLayer3;
+ {
+ StandardMaterialInputs inputs;
+ FILL_STANDARD_MATERIAL_INPUTS(inputs, MaterialSrg::m_layer3_, o_layer3_, blendWeights.b)
+ lightingInputLayer3 = ProcessStandardMaterialInputs(inputs);
+ }
+
+ // ------- Combine all layers ---------
+
+ Surface surface;
+ surface.position = IN.m_worldPosition;
+ surface.transmission.InitializeToZero();
+
+ // ------- Combine Normals ---------
+
+ float3 normalTS = lightingInputLayer1.m_normalTS;
+ normalTS = ReorientTangentSpaceNormal(normalTS, lightingInputLayer2.m_normalTS);
+ normalTS = ReorientTangentSpaceNormal(normalTS, lightingInputLayer3.m_normalTS);
// [GFX TODO][ATOM-14591]: This will only work if the normal maps all use the same UV stream. We would need to add support for having them in different UV streams.
surface.normal = normalize(TangentSpaceToWorld(normalTS, IN.m_normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex]));
-
- // ------- Base Color -------
-
- float2 layer1_baseColorUv = uvLayer1[MaterialSrg::m_layer1_m_baseColorMapUvIndex];
- float2 layer2_baseColorUv = uvLayer2[MaterialSrg::m_layer2_m_baseColorMapUvIndex];
- float2 layer3_baseColorUv = uvLayer3[MaterialSrg::m_layer3_m_baseColorMapUvIndex];
+
+ // ------- Combine Albedo, roughness, specular, roughness ---------
- float3 layer1_sampledColor = GetBaseColorInput(MaterialSrg::m_layer1_m_baseColorMap, MaterialSrg::m_sampler, layer1_baseColorUv, MaterialSrg::m_layer1_m_baseColor.rgb, o_layer1_o_baseColor_useTexture);
- float3 layer2_sampledColor = GetBaseColorInput(MaterialSrg::m_layer2_m_baseColorMap, MaterialSrg::m_sampler, layer2_baseColorUv, MaterialSrg::m_layer2_m_baseColor.rgb, o_layer2_o_baseColor_useTexture);
- float3 layer3_sampledColor = GetBaseColorInput(MaterialSrg::m_layer3_m_baseColorMap, MaterialSrg::m_sampler, layer3_baseColorUv, MaterialSrg::m_layer3_m_baseColor.rgb, o_layer3_o_baseColor_useTexture);
- float3 layer1_baseColor = BlendBaseColor(layer1_sampledColor, MaterialSrg::m_layer1_m_baseColor.rgb, MaterialSrg::m_layer1_m_baseColorFactor, o_layer1_o_baseColorTextureBlendMode, o_layer1_o_baseColor_useTexture);
- float3 layer2_baseColor = BlendBaseColor(layer2_sampledColor, MaterialSrg::m_layer2_m_baseColor.rgb, MaterialSrg::m_layer2_m_baseColorFactor, o_layer2_o_baseColorTextureBlendMode, o_layer2_o_baseColor_useTexture);
- float3 layer3_baseColor = BlendBaseColor(layer3_sampledColor, MaterialSrg::m_layer3_m_baseColor.rgb, MaterialSrg::m_layer3_m_baseColorFactor, o_layer3_o_baseColorTextureBlendMode, o_layer3_o_baseColor_useTexture);
- float3 baseColor = BlendLayers(layer1_baseColor, layer2_baseColor, layer3_baseColor, blendWeights);
+ float3 baseColor = BlendLayers(lightingInputLayer1.m_baseColor, lightingInputLayer2.m_baseColor, lightingInputLayer3.m_baseColor, blendWeights);
+ float3 specularF0Factor = BlendLayers(lightingInputLayer1.m_specularF0Factor, lightingInputLayer2.m_specularF0Factor, lightingInputLayer3.m_specularF0Factor, blendWeights);
+ float3 metallic = BlendLayers(lightingInputLayer1.m_metallic, lightingInputLayer2.m_metallic, lightingInputLayer3.m_metallic, blendWeights);
if(o_parallax_highlightClipping && displacementIsClipped)
{
ApplyParallaxClippingHighlight(baseColor);
}
- // ------- Metallic -------
-
- float metallic = 0;
- if(!o_enableSubsurfaceScattering) // If subsurface scattering is enabled skip texture lookup for metallic, as this quantity won't be used anyway
- {
- float layer1_metallic = GetMetallicInput(MaterialSrg::m_layer1_m_metallicMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_metallicMapUvIndex], MaterialSrg::m_layer1_m_metallicFactor, o_layer1_o_metallic_useTexture);
- float layer2_metallic = GetMetallicInput(MaterialSrg::m_layer2_m_metallicMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_metallicMapUvIndex], MaterialSrg::m_layer2_m_metallicFactor, o_layer2_o_metallic_useTexture);
- float layer3_metallic = GetMetallicInput(MaterialSrg::m_layer3_m_metallicMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_metallicMapUvIndex], MaterialSrg::m_layer3_m_metallicFactor, o_layer3_o_metallic_useTexture);
- metallic = BlendLayers(layer1_metallic, layer2_metallic, layer3_metallic, blendWeights);
- }
-
- // ------- Specular -------
-
- float layer1_specularF0Factor = GetSpecularInput(MaterialSrg::m_layer1_m_specularF0Map, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularF0MapUvIndex], MaterialSrg::m_layer1_m_specularF0Factor, o_layer1_o_specularF0_useTexture);
- float layer2_specularF0Factor = GetSpecularInput(MaterialSrg::m_layer2_m_specularF0Map, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_specularF0MapUvIndex], MaterialSrg::m_layer2_m_specularF0Factor, o_layer2_o_specularF0_useTexture);
- float layer3_specularF0Factor = GetSpecularInput(MaterialSrg::m_layer3_m_specularF0Map, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularF0MapUvIndex], MaterialSrg::m_layer3_m_specularF0Factor, o_layer3_o_specularF0_useTexture);
- float specularF0Factor = BlendLayers(layer1_specularF0Factor, layer2_specularF0Factor, layer3_specularF0Factor, blendWeights);
-
surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
- // ------- Roughness -------
-
- float layer1_roughness = GetRoughnessInput(MaterialSrg::m_layer1_m_roughnessMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_roughnessMapUvIndex], MaterialSrg::m_layer1_m_roughnessFactor, MaterialSrg::m_layer1_m_roughnessLowerBound, MaterialSrg::m_layer1_m_roughnessUpperBound, o_layer1_o_roughness_useTexture);
- float layer2_roughness = GetRoughnessInput(MaterialSrg::m_layer2_m_roughnessMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_roughnessMapUvIndex], MaterialSrg::m_layer2_m_roughnessFactor, MaterialSrg::m_layer2_m_roughnessLowerBound, MaterialSrg::m_layer2_m_roughnessUpperBound, o_layer2_o_roughness_useTexture);
- float layer3_roughness = GetRoughnessInput(MaterialSrg::m_layer3_m_roughnessMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_roughnessMapUvIndex], MaterialSrg::m_layer3_m_roughnessFactor, MaterialSrg::m_layer3_m_roughnessLowerBound, MaterialSrg::m_layer3_m_roughnessUpperBound, o_layer3_o_roughness_useTexture);
- surface.roughnessLinear = BlendLayers(layer1_roughness, layer2_roughness, layer3_roughness, blendWeights);
-
+ surface.roughnessLinear = BlendLayers(lightingInputLayer1.m_roughness, lightingInputLayer2.m_roughness, lightingInputLayer3.m_roughness, blendWeights);
surface.CalculateRoughnessA();
-
- // ------- Subsurface -------
-
- float2 subsurfaceUv = IN.m_uv[MaterialSrg::m_subsurfaceScatteringInfluenceMapUvIndex];
- float surfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, MaterialSrg::m_subsurfaceScatteringFactor);
-
- // ------- Transmission -------
-
- float2 transmissionUv = IN.m_uv[MaterialSrg::m_transmissionThicknessMapUvIndex];
- float4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, MaterialSrg::m_transmissionTintThickness);
- surface.transmission.tint = transmissionTintThickness.rgb;
- surface.transmission.thickness = transmissionTintThickness.w;
- surface.transmission.transmissionParams = MaterialSrg::m_transmissionParams;
- // ------- Lighting Data -------
-
+ // ------- Init and Combine Lighting Data -------
+
LightingData lightingData;
// Light iterator
@@ -307,88 +442,22 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
// Directional light shadow coordinates
lightingData.shadowCoords = IN.m_shadowCoords;
-
- // ------- Emissive -------
- float3 layer1_emissive = GetEmissiveInput(MaterialSrg::m_layer1_m_emissiveMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_emissiveMapUvIndex], MaterialSrg::m_layer1_m_emissiveIntensity, MaterialSrg::m_layer1_m_emissiveColor.rgb, o_layer1_o_emissiveEnabled, o_layer1_o_emissive_useTexture);
- float3 layer2_emissive = GetEmissiveInput(MaterialSrg::m_layer2_m_emissiveMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_emissiveMapUvIndex], MaterialSrg::m_layer2_m_emissiveIntensity, MaterialSrg::m_layer2_m_emissiveColor.rgb, o_layer2_o_emissiveEnabled, o_layer2_o_emissive_useTexture);
- float3 layer3_emissive = GetEmissiveInput(MaterialSrg::m_layer3_m_emissiveMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_emissiveMapUvIndex], MaterialSrg::m_layer3_m_emissiveIntensity, MaterialSrg::m_layer3_m_emissiveColor.rgb, o_layer3_o_emissiveEnabled, o_layer3_o_emissive_useTexture);
- lightingData.emissiveLighting = BlendLayers(layer1_emissive, layer2_emissive, layer3_emissive, blendWeights);
+ lightingData.emissiveLighting = BlendLayers(lightingInputLayer1.m_emissiveLighting, lightingInputLayer2.m_emissiveLighting, lightingInputLayer3.m_emissiveLighting, blendWeights);
+ lightingData.specularOcclusion = BlendLayers(lightingInputLayer1.m_specularOcclusion, lightingInputLayer2.m_specularOcclusion, lightingInputLayer3.m_specularOcclusion, blendWeights);
+ lightingData.diffuseAmbientOcclusion = BlendLayers(lightingInputLayer1.m_diffuseAmbientOcclusion, lightingInputLayer2.m_diffuseAmbientOcclusion, lightingInputLayer3.m_diffuseAmbientOcclusion, blendWeights);
- // ------- Occlusion -------
-
- float layer1_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer1_m_diffuseOcclusionFactor, o_layer1_o_diffuseOcclusion_useTexture);
- float layer2_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer2_m_diffuseOcclusionFactor, o_layer2_o_diffuseOcclusion_useTexture);
- float layer3_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer3_m_diffuseOcclusionFactor, o_layer3_o_diffuseOcclusion_useTexture);
- lightingData.diffuseAmbientOcclusion = BlendLayers(layer1_diffuseAmbientOcclusion, layer2_diffuseAmbientOcclusion, layer3_diffuseAmbientOcclusion, blendWeights);
+ lightingData.CalculateMultiscatterCompensation(surface.specularF0, o_specularF0_enableMultiScatterCompensation);
- float layer1_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer1_m_specularOcclusionFactor, o_layer1_o_specularOcclusion_useTexture);
- float layer2_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer2_m_specularOcclusionFactor, o_layer2_o_specularOcclusion_useTexture);
- float layer3_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer3_m_specularOcclusionFactor, o_layer3_o_specularOcclusion_useTexture);
- lightingData.specularOcclusion = BlendLayers(layer1_specularOcclusion, layer2_specularOcclusion, layer3_specularOcclusion, blendWeights);
-
- // ------- Clearcoat -------
+ // ------- Combine Clearcoat -------
if(o_clearCoat_feature_enabled)
{
- // --- Layer 1 ---
-
- float layer1_clearCoatFactor = 0.0f;
- float layer1_clearCoatRoughness = 0.0f;
- float3 layer1_clearCoatNormal = float3(0.0, 0.0, 0.0);
- if(o_layer1_o_clearCoat_enabled)
- {
- float3x3 layer1_uvMatrix = MaterialSrg::m_layer1_m_clearCoatNormalMapUvIndex == 0 ? MaterialSrg::m_layer1_m_uvMatrix : CreateIdentity3x3();
-
- GetClearCoatInputs(MaterialSrg::m_layer1_m_clearCoatInfluenceMap, uvLayer1[MaterialSrg::m_layer1_m_clearCoatInfluenceMapUvIndex], MaterialSrg::m_layer1_m_clearCoatFactor, o_layer1_o_clearCoat_factor_useTexture,
- MaterialSrg::m_layer1_m_clearCoatRoughnessMap, uvLayer1[MaterialSrg::m_layer1_m_clearCoatRoughnessMapUvIndex], MaterialSrg::m_layer1_m_clearCoatRoughness, o_layer1_o_clearCoat_roughness_useTexture,
- MaterialSrg::m_layer1_m_clearCoatNormalMap, uvLayer1[MaterialSrg::m_layer1_m_clearCoatNormalMapUvIndex], IN.m_normal, o_layer1_o_clearCoat_normal_useTexture, MaterialSrg::m_layer1_m_clearCoatNormalStrength,
- layer1_uvMatrix, tangents[MaterialSrg::m_layer1_m_clearCoatNormalMapUvIndex], bitangents[MaterialSrg::m_layer1_m_clearCoatNormalMapUvIndex],
- MaterialSrg::m_sampler, isFrontFace,
- layer1_clearCoatFactor, layer1_clearCoatRoughness, layer1_clearCoatNormal);
- }
-
- // --- Layer 2 ---
-
- float layer2_clearCoatFactor = 0.0f;
- float layer2_clearCoatRoughness = 0.0f;
- float3 layer2_clearCoatNormal = float3(0.0, 0.0, 0.0);
- if(o_layer2_o_clearCoat_enabled)
- {
- float3x3 layer2_uvMatrix = MaterialSrg::m_layer2_m_clearCoatNormalMapUvIndex == 0 ? MaterialSrg::m_layer2_m_uvMatrix : CreateIdentity3x3();
-
- GetClearCoatInputs(MaterialSrg::m_layer2_m_clearCoatInfluenceMap, uvLayer2[MaterialSrg::m_layer2_m_clearCoatInfluenceMapUvIndex], MaterialSrg::m_layer2_m_clearCoatFactor, o_layer2_o_clearCoat_factor_useTexture,
- MaterialSrg::m_layer2_m_clearCoatRoughnessMap, uvLayer2[MaterialSrg::m_layer2_m_clearCoatRoughnessMapUvIndex], MaterialSrg::m_layer2_m_clearCoatRoughness, o_layer2_o_clearCoat_roughness_useTexture,
- MaterialSrg::m_layer2_m_clearCoatNormalMap, uvLayer2[MaterialSrg::m_layer2_m_clearCoatNormalMapUvIndex], IN.m_normal, o_layer2_o_clearCoat_normal_useTexture, MaterialSrg::m_layer2_m_clearCoatNormalStrength,
- layer2_uvMatrix, tangents[MaterialSrg::m_layer2_m_clearCoatNormalMapUvIndex], bitangents[MaterialSrg::m_layer2_m_clearCoatNormalMapUvIndex],
- MaterialSrg::m_sampler, isFrontFace,
- layer2_clearCoatFactor, layer2_clearCoatRoughness, layer2_clearCoatNormal);
- }
-
- // --- Layer 3 ---
-
- float layer3_clearCoatFactor = 0.0f;
- float layer3_clearCoatRoughness = 0.0f;
- float3 layer3_clearCoatNormal = float3(0.0, 0.0, 0.0);
- if(o_layer3_o_clearCoat_enabled)
- {
- float3x3 layer3_uvMatrix = MaterialSrg::m_layer3_m_clearCoatNormalMapUvIndex == 0 ? MaterialSrg::m_layer3_m_uvMatrix : CreateIdentity3x3();
-
- GetClearCoatInputs(MaterialSrg::m_layer3_m_clearCoatInfluenceMap, uvLayer3[MaterialSrg::m_layer3_m_clearCoatInfluenceMapUvIndex], MaterialSrg::m_layer3_m_clearCoatFactor, o_layer3_o_clearCoat_factor_useTexture,
- MaterialSrg::m_layer3_m_clearCoatRoughnessMap, uvLayer3[MaterialSrg::m_layer3_m_clearCoatRoughnessMapUvIndex], MaterialSrg::m_layer3_m_clearCoatRoughness, o_layer3_o_clearCoat_roughness_useTexture,
- MaterialSrg::m_layer3_m_clearCoatNormalMap, uvLayer3[MaterialSrg::m_layer3_m_clearCoatNormalMapUvIndex], IN.m_normal, o_layer3_o_clearCoat_normal_useTexture, MaterialSrg::m_layer3_m_clearCoatNormalStrength,
- layer3_uvMatrix, tangents[MaterialSrg::m_layer3_m_clearCoatNormalMapUvIndex], bitangents[MaterialSrg::m_layer3_m_clearCoatNormalMapUvIndex],
- MaterialSrg::m_sampler, isFrontFace,
- layer3_clearCoatFactor, layer3_clearCoatRoughness, layer3_clearCoatNormal);
- }
-
- // --- Blend Layers ---
-
- surface.clearCoat.factor = BlendLayers(layer1_clearCoatFactor, layer2_clearCoatFactor, layer3_clearCoatFactor, blendWeights);
- surface.clearCoat.roughness = BlendLayers(layer1_clearCoatRoughness, layer2_clearCoatRoughness, layer3_clearCoatRoughness, blendWeights);
+ surface.clearCoat.factor = BlendLayers(lightingInputLayer1.m_clearCoat.factor, lightingInputLayer2.m_clearCoat.factor, lightingInputLayer3.m_clearCoat.factor, blendWeights);
+ surface.clearCoat.roughness = BlendLayers(lightingInputLayer1.m_clearCoat.roughness, lightingInputLayer2.m_clearCoat.roughness, lightingInputLayer3.m_clearCoat.roughness, blendWeights);
// [GFX TODO][ATOM-14592] This is not the right way to blend the normals. We need to use ReorientTangentSpaceNormal(), and that requires GetClearCoatInputs() to return the normal in TS instead of WS.
- surface.clearCoat.normal = BlendLayers(layer1_clearCoatNormal, layer2_clearCoatNormal, layer3_clearCoatNormal, blendWeights);
+ surface.clearCoat.normal = BlendLayers(lightingInputLayer1.m_clearCoat.normal, lightingInputLayer2.m_clearCoat.normal, lightingInputLayer3.m_clearCoat.normal, blendWeights);
surface.clearCoat.normal = normalize(surface.clearCoat.normal);
// manipulate base layer f0 if clear coat is enabled
@@ -408,11 +477,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
// Clear coat layer has fixed IOR = 1.5 and transparent => F0 = (1.5 - 1)^2 / (1.5 + 1)^2 = 0.04
lightingData.diffuseResponse *= 1.0 - (FresnelSchlickWithRoughness(lightingData.NdotV, float3(0.04, 0.04, 0.04), surface.clearCoat.roughness) * surface.clearCoat.factor);
}
-
- // ------- Multiscatter -------
-
- lightingData.CalculateMultiscatterCompensation(surface.specularF0, o_specularF0_enableMultiScatterCompensation);
-
+
// ------- Lighting Calculation -------
// Apply Decals
@@ -425,17 +490,14 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
ApplyIBL(surface, lightingData);
// Finalize Lighting
- lightingData.FinalizeLighting(surface.transmission.tint);
+ lightingData.FinalizeLighting(0);
const float alpha = 1.0;
PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha);
- // Pack factor and quality, drawback: because of precision limit of float16 cannot represent exact 1, maximum representable value is 0.9961
- uint factorAndQuality = dot(round(float2(saturate(surfaceScatteringFactor), MaterialSrg::m_subsurfaceScatteringQuality) * 255), float2(256, 1));
- lightingOutput.m_diffuseColor.w = factorAndQuality * (o_enableSubsurfaceScattering ? 1.0 : -1.0);
-
+ lightingOutput.m_diffuseColor.w = -1; // Disable subsurface scattering
return lightingOutput;
}
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli
index bb63d27df0..85d9370d2b 100644
--- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli
+++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli
@@ -32,6 +32,8 @@ class Surface
float roughnessA; //!< Actual roughness value ( a.k.a. "alpha roughness") to be used in microfacet calculations
float roughnessA2; //!< Alpha roughness ^ 2 (i.e. roughnessA * roughnessA), used in GGX, cached here for perfromance
+ void InitializeToZero();
+
//! Applies specular anti-aliasing to roughnessA2
void ApplySpecularAA();
@@ -43,6 +45,18 @@ class Surface
};
+void Surface::InitializeToZero()
+{
+ clearCoat.InitializeToZero();
+ transmission.InitializeToZero();
+ position = float3(0,0,0);
+ normal = float3(0,0,0);
+ albedo = float3(0,0,0);
+ specularF0 = float3(0,0,0);
+ roughnessLinear = 0.0f;
+ roughnessA = 0.0f;
+ roughnessA2 = 0.0f;
+}
// Specular Anti-Aliasing technique from this paper:
// http://www.jp.square-enix.com/tech/library/pdf/ImprovedGeometricSpecularAA.pdf
From 275bb1bfeccabb816880960c6afe61ff80e9fb58 Mon Sep 17 00:00:00 2001
From: Chris Santora
Date: Tue, 11 May 2021 17:25:53 -0700
Subject: [PATCH 020/163] ATOM-14688 Disable Individual Layers
Added flags for enabling StandardMultilayerPBR layers 2 and 3. This makes it easy to create a two-layer material, or to flip layers off and on for debugging.
---
.../Types/StandardMultilayerPBR.materialtype | 22 +++++++
.../Types/StandardMultilayerPBR_Common.azsli | 64 +++++++++++++------
.../StandardMultilayerPBR_ForwardPass.azsl | 20 +++++-
.../001_ManyFeatures.material | 4 ++
.../001_ManyFeatures_Layer2Off.material | 11 ++++
.../001_ManyFeatures_Layer3Off.material | 11 ++++
.../002_ParallaxPdo.material | 4 ++
7 files changed, 114 insertions(+), 22 deletions(-)
create mode 100644 Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures_Layer2Off.material
create mode 100644 Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures_Layer3Off.material
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
index 90a599c6f9..b49c66346f 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
@@ -295,6 +295,28 @@
}
],
"blend": [
+ {
+ "id": "enableLayer2",
+ "displayName": "Enable Layer 2",
+ "description": "Whether to enable layer 2.",
+ "type": "Bool",
+ "defaultValue": false,
+ "connection": {
+ "type": "ShaderOption",
+ "id": "o_layer2_enabled"
+ }
+ },
+ {
+ "id": "enableLayer3",
+ "displayName": "Enable Layer 3",
+ "description": "Whether to enable layer 3.",
+ "type": "Bool",
+ "defaultValue": false,
+ "connection": {
+ "type": "ShaderOption",
+ "id": "o_layer3_enabled"
+ }
+ },
{
"id": "blendSource",
"displayName": "Blend Source",
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli
index 8c7b49214b..d2314efefe 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Common.azsli
@@ -95,6 +95,9 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial
// ------ Shader Options ----------------------------------------
+option bool o_layer2_enabled;
+option bool o_layer3_enabled;
+
enum class DebugDrawMode { None, BlendSource, DepthMaps };
option DebugDrawMode o_debugDrawMode;
@@ -146,14 +149,27 @@ float3 GetBlendSourceValues(float2 uv)
{
float3 blendSourceValues = float3(0,0,0);
- switch(GetFinalBlendMaskSource())
+ if(o_layer2_enabled || o_layer3_enabled)
{
- case BlendMaskSource::TextureMap:
- blendSourceValues = MaterialSrg::m_blendMaskTexture.Sample(MaterialSrg::m_sampler, uv).rgb;
- break;
- case BlendMaskSource::VertexColors:
- blendSourceValues = s_blendMaskFromVertexStream;
- break;
+ switch(GetFinalBlendMaskSource())
+ {
+ case BlendMaskSource::TextureMap:
+ blendSourceValues = MaterialSrg::m_blendMaskTexture.Sample(MaterialSrg::m_sampler, uv).rgb;
+ break;
+ case BlendMaskSource::VertexColors:
+ blendSourceValues = s_blendMaskFromVertexStream;
+ break;
+ }
+
+ if(!o_layer2_enabled)
+ {
+ blendSourceValues.r = 0.0;
+ }
+
+ if(!o_layer3_enabled)
+ {
+ blendSourceValues.g = 0.0;
+ }
}
return blendSourceValues;
@@ -167,18 +183,26 @@ float3 GetBlendSourceValues(float2 uv)
//! layer3 = b
float3 GetBlendWeights(float2 uv)
{
- float3 blendSourceValues = GetBlendSourceValues(uv);
-
- // Calculate blend weights such that multiplying and adding them with layer data is equivalent
- // to lerping between each layer.
- // final = lerp(final, layer1, blendWeights.r)
- // final = lerp(final, layer2, blendWeights.g)
- // final = lerp(final, layer3, blendWeights.b)
-
float3 blendWeights;
- blendWeights.b = blendSourceValues.g;
- blendWeights.g = (1.0 - blendSourceValues.g) * blendSourceValues.r;
- blendWeights.r = (1.0 - blendSourceValues.g) * (1.0 - blendSourceValues.r);
+
+ if(o_layer2_enabled || o_layer3_enabled)
+ {
+ float3 blendSourceValues = GetBlendSourceValues(uv);
+
+ // Calculate blend weights such that multiplying and adding them with layer data is equivalent
+ // to lerping between each layer.
+ // final = lerp(final, layer1, blendWeights.r)
+ // final = lerp(final, layer2, blendWeights.g)
+ // final = lerp(final, layer3, blendWeights.b)
+
+ blendWeights.b = blendSourceValues.g;
+ blendWeights.g = (1.0 - blendSourceValues.g) * blendSourceValues.r;
+ blendWeights.r = (1.0 - blendSourceValues.g) * (1.0 - blendSourceValues.r);
+ }
+ else
+ {
+ blendWeights = float3(1,0,0);
+ }
return blendWeights;
}
@@ -230,7 +254,7 @@ DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
layerDepthValues.r -= MaterialSrg::m_layer1_m_depthOffset;
}
- if(o_layer2_o_useDepthMap)
+ if(o_layer2_enabled && o_layer2_o_useDepthMap)
{
float2 layerUv = uv;
if(MaterialSrg::m_parallaxUvIndex == 0)
@@ -243,7 +267,7 @@ DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
layerDepthValues.g -= MaterialSrg::m_layer2_m_depthOffset;
}
- if(o_layer3_o_useDepthMap)
+ if(o_layer3_enabled && o_layer3_o_useDepthMap)
{
float2 layerUv = uv;
if(MaterialSrg::m_parallaxUvIndex == 0)
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl
index 9e5a2e623a..8d5d32940d 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl
@@ -387,20 +387,30 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
// ----------- Layer 2 -----------
ProcessedMaterialInputs lightingInputLayer2;
+ if(o_layer2_enabled)
{
StandardMaterialInputs inputs;
FILL_STANDARD_MATERIAL_INPUTS(inputs, MaterialSrg::m_layer2_, o_layer2_, blendWeights.g)
lightingInputLayer2 = ProcessStandardMaterialInputs(inputs);
}
+ else
+ {
+ lightingInputLayer2.InitializeToZero();
+ }
// ----------- Layer 3 -----------
ProcessedMaterialInputs lightingInputLayer3;
+ if(o_layer3_enabled)
{
StandardMaterialInputs inputs;
FILL_STANDARD_MATERIAL_INPUTS(inputs, MaterialSrg::m_layer3_, o_layer3_, blendWeights.b)
lightingInputLayer3 = ProcessStandardMaterialInputs(inputs);
}
+ else
+ {
+ lightingInputLayer3.InitializeToZero();
+ }
// ------- Combine all layers ---------
@@ -411,8 +421,14 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
// ------- Combine Normals ---------
float3 normalTS = lightingInputLayer1.m_normalTS;
- normalTS = ReorientTangentSpaceNormal(normalTS, lightingInputLayer2.m_normalTS);
- normalTS = ReorientTangentSpaceNormal(normalTS, lightingInputLayer3.m_normalTS);
+ if(o_layer2_enabled)
+ {
+ normalTS = ReorientTangentSpaceNormal(normalTS, lightingInputLayer2.m_normalTS);
+ }
+ if(o_layer3_enabled)
+ {
+ normalTS = ReorientTangentSpaceNormal(normalTS, lightingInputLayer3.m_normalTS);
+ }
// [GFX TODO][ATOM-14591]: This will only work if the normal maps all use the same UV stream. We would need to add support for having them in different UV streams.
surface.normal = normalize(TangentSpaceToWorld(normalTS, IN.m_normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex]));
diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material
index b85705fcb8..d9a4aabe2a 100644
--- a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material
+++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material
@@ -4,6 +4,10 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
+ "blend": {
+ "enableLayer2": true,
+ "enableLayer3": true
+ },
"layer1_baseColor": {
"color": [
0.3495536744594574,
diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures_Layer2Off.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures_Layer2Off.material
new file mode 100644
index 0000000000..d91cfb34eb
--- /dev/null
+++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures_Layer2Off.material
@@ -0,0 +1,11 @@
+{
+ "description": "",
+ "materialType": "Materials/Types/StandardMultilayerPBR.materialtype",
+ "parentMaterial": "TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material",
+ "propertyLayoutVersion": 3,
+ "properties": {
+ "blend": {
+ "enableLayer2": false
+ }
+ }
+}
\ No newline at end of file
diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures_Layer3Off.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures_Layer3Off.material
new file mode 100644
index 0000000000..3ee48df612
--- /dev/null
+++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures_Layer3Off.material
@@ -0,0 +1,11 @@
+{
+ "description": "",
+ "materialType": "Materials/Types/StandardMultilayerPBR.materialtype",
+ "parentMaterial": "TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material",
+ "propertyLayoutVersion": 3,
+ "properties": {
+ "blend": {
+ "enableLayer3": false
+ }
+ }
+}
\ No newline at end of file
diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material
index f6c881aee5..0bf4177db9 100644
--- a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material
+++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/002_ParallaxPdo.material
@@ -4,6 +4,10 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
+ "blend": {
+ "enableLayer2": true,
+ "enableLayer3": true
+ },
"layer1_baseColor": {
"textureMap": "TestData/Textures/cc0/bark1_col.jpg"
},
From c777e2e35301cd0054fe39e8fdccb5e632d48a21 Mon Sep 17 00:00:00 2001
From: scottr
Date: Tue, 11 May 2021 18:07:19 -0700
Subject: [PATCH 021/163] [cpack_installer] some cpack cleanup and prep for
online installer support (pre/post build steps)
---
cmake/Packaging.cmake | 38 ++++++++++++-------
.../Platform/Windows/PackagingPostBuild.cmake | 12 ++++++
.../Platform/Windows/Packaging_windows.cmake | 8 +++-
.../Windows/platform_windows_files.cmake | 1 +
4 files changed, 43 insertions(+), 16 deletions(-)
create mode 100644 cmake/Platform/Windows/PackagingPostBuild.cmake
diff --git a/cmake/Packaging.cmake b/cmake/Packaging.cmake
index 4f6565edc7..e398ea7509 100644
--- a/cmake/Packaging.cmake
+++ b/cmake/Packaging.cmake
@@ -13,6 +13,30 @@ if(NOT PAL_TRAIT_BUILD_CPACK_SUPPORTED)
return()
endif()
+# set the common cpack variables first so they are accessible via configure_file
+# when the platforms specific properties are applied below
+set(LY_INSTALLER_DOWNLOAD_URL "" CACHE PATH "URL embded into the installer to download additional artifacts")
+
+set(CPACK_PACKAGE_VENDOR "${PROJECT_NAME}")
+set(CPACK_PACKAGE_VERSION "${LY_VERSION_STRING}")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Installation Tool")
+
+string(TOLOWER ${PROJECT_NAME} _project_name_lower)
+set(CPACK_PACKAGE_FILE_NAME "${_project_name_lower}_${LY_VERSION_STRING}_installer")
+
+set(DEFAULT_LICENSE_NAME "Apache-2.0")
+set(DEFAULT_LICENSE_FILE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
+
+set(CPACK_RESOURCE_FILE_LICENSE ${DEFAULT_LICENSE_FILE})
+
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_VENDOR}/${CPACK_PACKAGE_VERSION}")
+
+# custom cpack cache variables for use in pre/post build scripts
+set(CPACK_SOURCE_DIR ${CMAKE_SOURCE_DIR}/cmake)
+set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR}/installer)
+set(CPACK_DOWNLOAD_URL ${LY_INSTALLER_DOWNLOAD_URL})
+
+# attempt to apply platform specific settings
ly_get_absolute_pal_filename(pal_dir ${CMAKE_SOURCE_DIR}/cmake/Platform/${PAL_HOST_PLATFORM_NAME})
include(${pal_dir}/Packaging_${PAL_HOST_PLATFORM_NAME_LOWERCASE}.cmake)
@@ -21,20 +45,6 @@ if(NOT CPACK_GENERATOR)
return()
endif()
-set(CPACK_PACKAGE_VENDOR "${PROJECT_NAME}")
-set(CPACK_PACKAGE_VERSION "${LY_VERSION_STRING}")
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Installation Tool")
-
-string(TOLOWER ${PROJECT_NAME} _project_name_lower)
-set(CPACK_PACKAGE_FILE_NAME "${_project_name_lower}_installer")
-
-set(DEFAULT_LICENSE_NAME "Apache-2.0")
-set(DEFAULT_LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
-
-set(CPACK_RESOURCE_FILE_LICENSE ${DEFAULT_LICENSE_FILE})
-
-set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_VENDOR}/${CPACK_PACKAGE_VERSION}")
-
# IMPORTANT: required to be included AFTER setting all property overrides
include(CPack REQUIRED)
diff --git a/cmake/Platform/Windows/PackagingPostBuild.cmake b/cmake/Platform/Windows/PackagingPostBuild.cmake
new file mode 100644
index 0000000000..fe57904003
--- /dev/null
+++ b/cmake/Platform/Windows/PackagingPostBuild.cmake
@@ -0,0 +1,12 @@
+#
+# 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.
+#
+
+message(STATUS "Hello from CPack post build!")
diff --git a/cmake/Platform/Windows/Packaging_windows.cmake b/cmake/Platform/Windows/Packaging_windows.cmake
index 8aa6f2386d..ba3ce011a4 100644
--- a/cmake/Platform/Windows/Packaging_windows.cmake
+++ b/cmake/Platform/Windows/Packaging_windows.cmake
@@ -32,7 +32,7 @@ set(CPACK_GENERATOR "WIX")
# however, they are unique for each run. instead, let's do the auto generation here and add it to
# the cache for run persistence. an additional cache file will be used to store the information on
# the original generation so we still have the ability to detect if they are still being used.
-set(_guid_cache_file "${CMAKE_BINARY_DIR}/installer/wix_guid_cache.cmake")
+set(_guid_cache_file "${CPACK_BINARY_DIR}/wix_guid_cache.cmake")
if(NOT EXISTS ${_guid_cache_file})
set(_wix_guid_namespace "6D43F57A-2917-4AD9-B758-1F13CDB08593")
@@ -89,4 +89,8 @@ endif()
set(CPACK_WIX_PRODUCT_GUID ${LY_WIX_PRODUCT_GUID})
set(CPACK_WIX_UPGRADE_GUID ${LY_WIX_UPGRADE_GUID})
-set(CPACK_WIX_TEMPLATE "${CMAKE_SOURCE_DIR}/cmake/Platform/Windows/PackagingTemplate.wxs.in")
+set(CPACK_WIX_TEMPLATE "${CPACK_SOURCE_DIR}/Platform/Windows/PackagingTemplate.wxs.in")
+
+set(CPACK_POST_BUILD_SCRIPTS
+ ${CPACK_SOURCE_DIR}/Platform/Windows/PackagingPostBuild.cmake
+)
diff --git a/cmake/Platform/Windows/platform_windows_files.cmake b/cmake/Platform/Windows/platform_windows_files.cmake
index 2fc869b43e..579621d5ea 100644
--- a/cmake/Platform/Windows/platform_windows_files.cmake
+++ b/cmake/Platform/Windows/platform_windows_files.cmake
@@ -24,5 +24,6 @@ set(FILES
PALDetection_windows.cmake
Install_windows.cmake
Packaging_windows.cmake
+ PackagingPostBuild.cmake
PackagingTemplate.wxs.in
)
From f5e91c6e4284f00e64db5cc4ba4e0678be111b1c Mon Sep 17 00:00:00 2001
From: antonmic
Date: Wed, 12 May 2021 10:39:18 -0700
Subject: [PATCH 022/163] Added low end shaders in StandardPBR_ShaderEnable.lua
---
.../Assets/Materials/Types/StandardPBR_ShaderEnable.lua | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ShaderEnable.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ShaderEnable.lua
index 7c3d989c35..2733713122 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ShaderEnable.lua
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ShaderEnable.lua
@@ -29,26 +29,33 @@ function Process(context)
local depthPass = context:GetShaderByTag("DepthPass")
local shadowMap = context:GetShaderByTag("Shadowmap")
local forwardPassEDS = context:GetShaderByTag("ForwardPass_EDS")
+ local lowEndForwardEDS = context:GetShaderByTag("LowEndForward_EDS")
+
local depthPassWithPS = context:GetShaderByTag("DepthPass_WithPS")
local shadowMapWitPS = context:GetShaderByTag("Shadowmap_WithPS")
local forwardPass = context:GetShaderByTag("ForwardPass")
+ local lowEndForward = context:GetShaderByTag("LowEndForward")
if parallaxEnabled and parallaxPdoEnabled then
depthPass:SetEnabled(false)
shadowMap:SetEnabled(false)
forwardPassEDS:SetEnabled(false)
+ lowEndForwardEDS:SetEnabled(false)
depthPassWithPS:SetEnabled(true)
shadowMapWitPS:SetEnabled(true)
forwardPass:SetEnabled(true)
+ lowEndForward:SetEnabled(true)
else
depthPass:SetEnabled(opacityMode == OpacityMode_Opaque)
shadowMap:SetEnabled(opacityMode == OpacityMode_Opaque)
forwardPassEDS:SetEnabled((opacityMode == OpacityMode_Opaque) or (opacityMode == OpacityMode_Blended) or (opacityMode == OpacityMode_TintedTransparent))
+ lowEndForwardEDS:SetEnabled((opacityMode == OpacityMode_Opaque) or (opacityMode == OpacityMode_Blended) or (opacityMode == OpacityMode_TintedTransparent))
depthPassWithPS:SetEnabled(opacityMode == OpacityMode_Cutout)
shadowMapWitPS:SetEnabled(opacityMode == OpacityMode_Cutout)
forwardPass:SetEnabled(opacityMode == OpacityMode_Cutout)
+ lowEndForward:SetEnabled(opacityMode == OpacityMode_Cutout)
end
context:GetShaderByTag("DepthPassTransparentMin"):SetEnabled((opacityMode == OpacityMode_Blended) or (opacityMode == OpacityMode_TintedTransparent))
From 92b7099d78953eef8552633201b98d8f07597529 Mon Sep 17 00:00:00 2001
From: antonmic
Date: Wed, 12 May 2021 11:10:13 -0700
Subject: [PATCH 023/163] Some clean up
---
.../Common/Assets/Materials/Types/StandardPBR.materialtype | 7 -------
.../Assets/Materials/Types/StandardPBR_ForwardPass.azsl | 4 ++--
.../Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli | 3 +++
.../ShaderLib/Atom/Features/ShaderQualityOptions.azsli | 4 +---
Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl | 6 ++----
5 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype
index 47d8a9d9d5..a9a3e9e09b 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype
@@ -77,13 +77,6 @@
],
"properties": {
"general": [
- {
- "id": "useLowEndShader",
- "displayName": "Use Low End",
- "description": "Whether to use the low end shader.",
- "type": "Bool",
- "defaultValue": false
- },
{
"id": "applySpecularAA",
"displayName": "Apply Specular AA",
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl
index 1e6fafda9b..7ae5934d4f 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl
@@ -321,7 +321,7 @@ ForwardPassOutputWithDepth StandardPbr_ForwardPassPS(VSOutput IN, bool isFrontFa
#ifdef UNIFIED_FORWARD_OUTPUT
OUT.m_color.rgb = lightingOutput.m_diffuseColor.rgb + lightingOutput.m_specularColor.rgb;
- OUT.m_color.a = 1.0f;
+ OUT.m_color.a = lightingOutput.m_diffuseColor.a;
OUT.m_depth = depth;
#else
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
@@ -344,7 +344,7 @@ ForwardPassOutput StandardPbr_ForwardPassPS_EDS(VSOutput IN, bool isFrontFace :
#ifdef UNIFIED_FORWARD_OUTPUT
OUT.m_color.rgb = lightingOutput.m_diffuseColor.rgb + lightingOutput.m_specularColor.rgb;
- OUT.m_color.a = 1.0f;
+ OUT.m_color.a = lightingOutput.m_diffuseColor.a;
#else
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
OUT.m_specularColor = lightingOutput.m_specularColor;
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli
index 721c48835d..3e3544fe9e 100644
--- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli
+++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli
@@ -12,6 +12,9 @@
#pragma once
+// --- Static Options Available ---
+// FORCE_IBL_IN_FORWARD_PASS - forces IBL lighting to be run in the forward pass, used in pipelines that don't have a reflection pass
+
#include
#include
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli
index d6fb259548..6e89269f8d 100644
--- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli
+++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli
@@ -12,9 +12,7 @@
#pragma once
-// These are a list of quality options to specify as macros (either in azsl or in shader files)
-//
-// QUALITY_LOW_END
+// This file translates quality option macros like QUALITY_LOW_END to their relevant settings
#ifdef QUALITY_LOW_END
diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl
index 4b3e9536b7..1bebb2ec47 100644
--- a/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl
+++ b/Gems/Atom/Feature/Common/Assets/Shaders/SkyBox/SkyBox.azsl
@@ -10,10 +10,8 @@
*
*/
-// Static Options:
-//
-// SKYBOX_TWO_OUTPUTS - Allows the skybox to render to two rendertargets instead of one
-
+// --- Static Options Available ---
+// SKYBOX_TWO_OUTPUTS - Skybox renders to two rendertargets instead of one (SkyBox_TwoOutputs.pass writes to specular and reflection targets)
#include
#include
From b52388f5ebfb5af09505a99fe1e416ae12907dd0 Mon Sep 17 00:00:00 2001
From: antonmic
Date: Wed, 12 May 2021 11:11:45 -0700
Subject: [PATCH 024/163] Remove unused file
---
.../PBR/LowEndForwardPassOutput.azsli | 32 -------------------
1 file changed, 32 deletions(-)
delete mode 100644 Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LowEndForwardPassOutput.azsli
diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LowEndForwardPassOutput.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LowEndForwardPassOutput.azsli
deleted file mode 100644
index acc215f1c9..0000000000
--- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LowEndForwardPassOutput.azsli
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* 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.
-*
-*/
-
-struct ForwardPassOutput
-{
- float4 m_diffuseColor : SV_Target0; //!< RGB = Diffuse Lighting, A = Blend Alpha (for blended surfaces) OR A = special encoding of surfaceScatteringFactor, m_subsurfaceScatteringQuality, o_enableSubsurfaceScattering
- float4 m_specularColor : SV_Target1; //!< RGB = Specular Lighting, A = Unused
- float4 m_albedo : SV_Target2; //!< RGB = Surface albedo pre-multiplied by other factors that will be multiplied later by diffuse GI, A = specularOcclusion
- float4 m_specularF0 : SV_Target3; //!< RGB = Specular F0, A = roughness
- float4 m_normal : SV_Target4; //!< RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled
-};
-
-struct ForwardPassOutputWithDepth
-{
- // See above for descriptions of special encodings
-
- float4 m_diffuseColor : SV_Target0;
- float4 m_specularColor : SV_Target1;
- float4 m_albedo : SV_Target2;
- float4 m_specularF0 : SV_Target3;
- float4 m_normal : SV_Target4;
- float m_depth : SV_Depth;
-};
From 53188a12da7d3ce90de64a0d184b6a5f9df613d8 Mon Sep 17 00:00:00 2001
From: Chris Santora
Date: Wed, 12 May 2021 17:06:57 -0700
Subject: [PATCH 025/163] 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.
---
.../DetailMapsCommonFunctor.lua | 8 +-
.../Materials/Types/Skin_WrinkleMaps.lua | 4 +-
.../Types/StandardMultilayerPBR.materialtype | 6 ++
.../StandardMultilayerPBR_LayerEnable.lua | 49 +++++++++
...StandardMultilayerPBR_ParallaxPerLayer.lua | 4 +-
.../Types/StandardPBR_ClearCoatState.lua | 4 +-
.../Types/StandardPBR_EmissiveState.lua | 4 +-
.../Types/StandardPBR_HandleOpacityMode.lua | 2 +-
.../Types/StandardPBR_ParallaxState.lua | 4 +-
.../Materials/Types/StandardPBR_Roughness.lua | 4 +-
.../Types/StandardPBR_SubsurfaceState.lua | 4 +-
.../RPI.Reflect/Material/LuaMaterialFunctor.h | 2 +
.../Material/MaterialDynamicMetadata.h | 100 ++++++++++++++++++
.../RPI.Reflect/Material/MaterialFunctor.h | 20 +++-
.../Material/MaterialPropertyDescriptor.h | 47 --------
.../RPI.Public/Material/MaterialSystem.cpp | 1 +
.../Material/LuaMaterialFunctor.cpp | 17 ++-
.../Material/MaterialDynamicMetadata.cpp | 50 +++++++++
.../RPI.Reflect/Material/MaterialFunctor.cpp | 96 ++++++++++++-----
.../Material/MaterialPropertyDescriptor.cpp | 14 ---
.../Material/LuaMaterialFunctorTests.cpp | 76 ++++++++++++-
.../MaterialPropertySerializerTests.cpp | 1 +
.../RPI/Code/atom_rpi_reflect_files.cmake | 2 +
.../DynamicProperty/DynamicProperty.h | 6 +-
.../Inspector/InspectorRequestBus.h | 6 ++
.../Inspector/InspectorWidget.h | 3 +
.../Code/Source/Inspector/InspectorWidget.cpp | 27 +++++
.../MaterialDocumentNotificationBus.h | 7 ++
.../Document/MaterialDocumentRequestBus.h | 5 +
.../Code/Source/Document/MaterialDocument.cpp | 58 ++++++++--
.../Code/Source/Document/MaterialDocument.h | 21 +++-
.../MaterialInspector/MaterialInspector.cpp | 16 ++-
.../MaterialInspector/MaterialInspector.h | 1 +
.../EditorMaterialComponentInspector.cpp | 25 +++--
34 files changed, 553 insertions(+), 141 deletions(-)
create mode 100644 Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_LayerEnable.lua
create mode 100644 Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialDynamicMetadata.h
create mode 100644 Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialDynamicMetadata.cpp
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/DetailMapsCommonFunctor.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/DetailMapsCommonFunctor.lua
index 15e4b4f416..e1a3dd6f29 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/DetailMapsCommonFunctor.lua
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/DetailMapsCommonFunctor.lua
@@ -35,16 +35,16 @@ end
function Process(context)
local isFeatureEnabled = context:GetMaterialPropertyValue_bool("detailLayerGroup.enableDetailLayer")
- local blendMaskTexture = context:GetMaterialPropertyValue_image("detailLayerGroup.blendDetailMask")
+ local blendMaskTexture = context:GetMaterialPropertyValue_Image("detailLayerGroup.blendDetailMask")
local blendMaskTextureEnabled = context:GetMaterialPropertyValue_bool("detailLayerGroup.enableDetailMaskTexture")
context:SetShaderOptionValue_bool("o_detail_blendMask_useTexture", isFeatureEnabled and blendMaskTextureEnabled and blendMaskTexture ~= nil)
local baseColorDetailEnabled = context:GetMaterialPropertyValue_bool("detailLayerGroup.enableBaseColor")
- local baseColorDetailTexture = context:GetMaterialPropertyValue_image("detailLayerGroup.baseColorDetailMap")
+ local baseColorDetailTexture = context:GetMaterialPropertyValue_Image("detailLayerGroup.baseColorDetailMap")
context:SetShaderOptionValue_bool("o_detail_baseColor_useTexture", isFeatureEnabled and baseColorDetailEnabled and baseColorDetailTexture ~= nil)
local normalDetailEnabled = context:GetMaterialPropertyValue_bool("detailLayerGroup.enableNormals")
- local normalDetailTexture = context:GetMaterialPropertyValue_image("detailLayerGroup.normalDetailMap")
+ local normalDetailTexture = context:GetMaterialPropertyValue_Image("detailLayerGroup.normalDetailMap")
context:SetShaderOptionValue_bool("o_detail_normal_useTexture", isFeatureEnabled and normalDetailEnabled and normalDetailTexture ~= nil)
end
@@ -78,7 +78,7 @@ function ProcessEditor(context)
context:SetMaterialPropertyVisibility("detailUV.rotateDegrees", mainVisibility)
context:SetMaterialPropertyVisibility("detailUV.scale", mainVisibility)
- local blendMaskTexture = context:GetMaterialPropertyValue_image("detailLayerGroup.blendDetailMask")
+ local blendMaskTexture = context:GetMaterialPropertyValue_Image("detailLayerGroup.blendDetailMask")
if(nil == blendMaskTexture) then
context:SetMaterialPropertyVisibility("detailLayerGroup.enableDetailMaskTexture", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("detailLayerGroup.blendDetailMaskUv", MaterialPropertyVisibility_Hidden)
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_WrinkleMaps.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_WrinkleMaps.lua
index d77918f521..9e1bc3763a 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_WrinkleMaps.lua
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_WrinkleMaps.lua
@@ -65,8 +65,8 @@ function Process(context)
for i=1,MAX_WRINKLE_LAYER_COUNT do
if(i <= count) then
- isBaseColorTextureMissing = isBaseColorEnabled and nil == context:GetMaterialPropertyValue_image("wrinkleLayers.baseColorMap" .. i)
- isNormalTextureMissing = isNormalEnabled and nil == context:GetMaterialPropertyValue_image("wrinkleLayers.normalMap" .. i)
+ isBaseColorTextureMissing = isBaseColorEnabled and nil == context:GetMaterialPropertyValue_Image("wrinkleLayers.baseColorMap" .. i)
+ isNormalTextureMissing = isNormalEnabled and nil == context:GetMaterialPropertyValue_Image("wrinkleLayers.normalMap" .. i)
context:SetShaderOptionValue_bool("o_wrinkleLayers_baseColor_useTexture" .. i, not isBaseColorTextureMissing)
context:SetShaderOptionValue_bool("o_wrinkleLayers_normal_useTexture" .. i, not isNormalTextureMissing)
else
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
index b49c66346f..a2854e8902 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
@@ -2684,6 +2684,12 @@
"file": "StandardMultilayerPBR_ShaderEnable.lua"
}
},
+ {
+ "type": "Lua",
+ "args": {
+ "file": "StandardMultilayerPBR_LayerEnable.lua"
+ }
+ },
{
"type": "Lua",
"args": {
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_LayerEnable.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_LayerEnable.lua
new file mode 100644
index 0000000000..f60aac6149
--- /dev/null
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_LayerEnable.lua
@@ -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
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ParallaxPerLayer.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ParallaxPerLayer.lua
index 119dfed436..bd56292229 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ParallaxPerLayer.lua
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ParallaxPerLayer.lua
@@ -24,7 +24,7 @@ end
function Process(context)
local enable = context:GetMaterialPropertyValue_bool("parallax.enable")
- local textureMap = context:GetMaterialPropertyValue_image("parallax.textureMap")
+ local textureMap = context:GetMaterialPropertyValue_Image("parallax.textureMap")
context:SetShaderOptionValue_bool("o_useDepthMap", enable and textureMap ~= nil)
end
@@ -37,7 +37,7 @@ function ProcessEditor(context)
context:SetMaterialPropertyVisibility("parallax.textureMap", MaterialPropertyVisibility_Hidden)
end
- local textureMap = context:GetMaterialPropertyValue_image("parallax.textureMap")
+ local textureMap = context:GetMaterialPropertyValue_Image("parallax.textureMap")
local visibility = MaterialPropertyVisibility_Enabled
if(not enable or textureMap == nil) then
visibility = MaterialPropertyVisibility_Hidden
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ClearCoatState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ClearCoatState.lua
index 8289291ef4..ffa00d7efd 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ClearCoatState.lua
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ClearCoatState.lua
@@ -34,7 +34,7 @@ function GetShaderOptionDependencies()
end
function UpdateUseTextureState(context, clearCoatEnabled, textureMapPropertyName, useTexturePropertyName, shaderOptionName)
- local textureMap = context:GetMaterialPropertyValue_image(textureMapPropertyName)
+ local textureMap = context:GetMaterialPropertyValue_Image(textureMapPropertyName)
local useTextureMap = context:GetMaterialPropertyValue_bool(useTexturePropertyName)
context:SetShaderOptionValue_bool(shaderOptionName, clearCoatEnabled and useTextureMap and textureMap ~= nil)
end
@@ -50,7 +50,7 @@ end
-- Note this logic matches that of the UseTextureFunctor class.
function UpdateTextureDependentPropertyVisibility(context, textureMapPropertyName, useTexturePropertyName, uvPropertyName)
- local textureMap = context:GetMaterialPropertyValue_image(textureMapPropertyName)
+ local textureMap = context:GetMaterialPropertyValue_Image(textureMapPropertyName)
local useTexture = context:GetMaterialPropertyValue_bool(useTexturePropertyName)
if(textureMap == nil) then
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_EmissiveState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_EmissiveState.lua
index a8ac2e8a4a..7ee5876adb 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_EmissiveState.lua
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_EmissiveState.lua
@@ -22,7 +22,7 @@ end
function Process(context)
local enable = context:GetMaterialPropertyValue_bool("emissive.enable")
- local textureMap = context:GetMaterialPropertyValue_image("emissive.textureMap")
+ local textureMap = context:GetMaterialPropertyValue_Image("emissive.textureMap")
local useTextureMap = context:GetMaterialPropertyValue_bool("emissive.useTexture")
context:SetShaderOptionValue_bool("o_emissiveEnabled", enable)
@@ -47,7 +47,7 @@ function ProcessEditor(context)
context:SetMaterialPropertyVisibility("emissive.textureMapUv", mainVisibility)
if(enable) then
- local textureMap = context:GetMaterialPropertyValue_image("emissive.textureMap")
+ local textureMap = context:GetMaterialPropertyValue_Image("emissive.textureMap")
local useTextureMap = context:GetMaterialPropertyValue_bool("emissive.useTexture")
if(textureMap == nil) then
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_HandleOpacityMode.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_HandleOpacityMode.lua
index 6cc595d712..541b1ac1ce 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_HandleOpacityMode.lua
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_HandleOpacityMode.lua
@@ -90,7 +90,7 @@ function ProcessEditor(context)
context:SetMaterialPropertyVisibility("opacity.textureMap", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("opacity.textureMapUv", MaterialPropertyVisibility_Hidden)
else
- local textureMap = context:GetMaterialPropertyValue_image("opacity.textureMap")
+ local textureMap = context:GetMaterialPropertyValue_Image("opacity.textureMap")
if(nil == textureMap) then
context:SetMaterialPropertyVisibility("opacity.textureMapUv", MaterialPropertyVisibility_Disabled)
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ParallaxState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ParallaxState.lua
index 0287e1105e..e6689da327 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ParallaxState.lua
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ParallaxState.lua
@@ -22,7 +22,7 @@ end
function Process(context)
local enable = context:GetMaterialPropertyValue_bool("parallax.enable")
- local textureMap = context:GetMaterialPropertyValue_image("parallax.textureMap")
+ local textureMap = context:GetMaterialPropertyValue_Image("parallax.textureMap")
context:SetShaderOptionValue_bool("o_parallax_feature_enabled", enable)
context:SetShaderOptionValue_bool("o_useDepthMap", enable and textureMap ~= nil)
end
@@ -36,7 +36,7 @@ function ProcessEditor(context)
context:SetMaterialPropertyVisibility("parallax.textureMap", MaterialPropertyVisibility_Hidden)
end
- local textureMap = context:GetMaterialPropertyValue_image("parallax.textureMap")
+ local textureMap = context:GetMaterialPropertyValue_Image("parallax.textureMap")
local visibility = MaterialPropertyVisibility_Enabled
if(not enable or textureMap == nil) then
visibility = MaterialPropertyVisibility_Hidden
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Roughness.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Roughness.lua
index 4887bc47e8..222e69cd3d 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Roughness.lua
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Roughness.lua
@@ -21,13 +21,13 @@ function GetShaderOptionDependencies()
end
function Process(context)
- local textureMap = context:GetMaterialPropertyValue_image("roughness.textureMap")
+ local textureMap = context:GetMaterialPropertyValue_Image("roughness.textureMap")
local useTexture = context:GetMaterialPropertyValue_bool("roughness.useTexture")
context:SetShaderOptionValue_bool("o_roughness_useTexture", useTexture and textureMap ~= nil)
end
function ProcessEditor(context)
- local textureMap = context:GetMaterialPropertyValue_image("roughness.textureMap")
+ local textureMap = context:GetMaterialPropertyValue_Image("roughness.textureMap")
local useTexture = context:GetMaterialPropertyValue_bool("roughness.useTexture")
if(nil == textureMap) then
diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SubsurfaceState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SubsurfaceState.lua
index fb07ac89a3..d8a69ba355 100644
--- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SubsurfaceState.lua
+++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SubsurfaceState.lua
@@ -35,7 +35,7 @@ TransmissionMode_ThickObject = 1
TransmissionMode_ThinObject = 2
function UpdateUseTextureState(context, subsurfaceScatteringEnabled, textureMapPropertyName, useTexturePropertyName, shaderOptionName)
- local textureMap = context:GetMaterialPropertyValue_image(textureMapPropertyName)
+ local textureMap = context:GetMaterialPropertyValue_Image(textureMapPropertyName)
local useTextureMap = context:GetMaterialPropertyValue_bool(useTexturePropertyName)
context:SetShaderOptionValue_bool(shaderOptionName, subsurfaceScatteringEnabled and useTextureMap and textureMap ~= nil)
end
@@ -53,7 +53,7 @@ function UpdateTextureDependentPropertyVisibility(context, featureEnabled, textu
context:SetMaterialPropertyVisibility(useTexturePropertyName, MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility(uvPropertyName, MaterialPropertyVisibility_Hidden)
else
- local textureMap = context:GetMaterialPropertyValue_image(textureMapPropertyName)
+ local textureMap = context:GetMaterialPropertyValue_Image(textureMapPropertyName)
local useTextureMap = context:GetMaterialPropertyValue_bool(useTexturePropertyName)
if(textureMap == nil) then
diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/LuaMaterialFunctor.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/LuaMaterialFunctor.h
index 44de79ff22..396ba14810 100644
--- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/LuaMaterialFunctor.h
+++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/LuaMaterialFunctor.h
@@ -329,6 +329,8 @@ namespace AZ
bool SetMaterialPropertySoftMaxValue(const char* name, Type value);
bool SetMaterialPropertyDescription(const char* name, const char* description);
+
+ bool SetMaterialPropertyGroupVisibility(const char* name, MaterialPropertyGroupVisibility visibility);
private:
diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialDynamicMetadata.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialDynamicMetadata.h
new file mode 100644
index 0000000000..b74e330665
--- /dev/null
+++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialDynamicMetadata.h
@@ -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
+#include
+#include
+
+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
+
diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialFunctor.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialFunctor.h
index d17c7634a2..6b9b34aa1b 100644
--- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialFunctor.h
+++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialFunctor.h
@@ -18,6 +18,7 @@
#include
#include
#include
+#include
namespace AZ
{
@@ -147,6 +148,8 @@ namespace AZ
public:
const MaterialPropertyDynamicMetadata* GetMaterialPropertyMetadata(const Name& propertyName) const;
const MaterialPropertyDynamicMetadata* GetMaterialPropertyMetadata(const MaterialPropertyIndex& index) const;
+
+ const MaterialPropertyGroupDynamicMetadata* GetMaterialPropertyGroupMetadata(const Name& propertyName) const;
//! Get the property value. The type must be one of those in MaterialPropertyValue.
//! Otherwise, a compile error will be reported.
@@ -178,6 +181,8 @@ namespace AZ
bool SetMaterialPropertySoftMaxValue(const Name& propertyName, const MaterialPropertyValue& max);
bool SetMaterialPropertySoftMaxValue(const MaterialPropertyIndex& index, const MaterialPropertyValue& max);
+
+ bool SetMaterialPropertyGroupVisibility(const Name& propertyGroupName, MaterialPropertyGroupVisibility visibility);
// [GFX TODO][ATOM-4168] Replace the workaround for unlink-able RPI.Public classes in MaterialFunctor
// const AZStd::vector&, AZStd::unordered_map&, RHI::ConstPtr
@@ -185,18 +190,23 @@ namespace AZ
EditorContext(
const AZStd::vector& propertyValues,
RHI::ConstPtr materialPropertiesLayout,
- AZStd::unordered_map& metadata,
- AZStd::unordered_set& outChangedProperties,
+ AZStd::unordered_map& propertyMetadata,
+ AZStd::unordered_map& propertyGroupMetadata,
+ AZStd::unordered_set& updatedPropertiesOut,
+ AZStd::unordered_set& updatedPropertyGroupsOut,
const MaterialPropertyFlags* materialPropertyDependencies
);
private:
- AZStd::list_iterator> QueryMaterialMetadata(const Name& propertyName) const;
+ AZStd::list_iterator> QueryMaterialPropertyMetadata(const Name& propertyName) const;
+ AZStd::list_iterator> QueryMaterialPropertyGroupMetadata(const Name& propertyGroupName) const;
const AZStd::vector& m_materialPropertyValues;
RHI::ConstPtr m_materialPropertiesLayout;
- AZStd::unordered_map& m_metadata;
- AZStd::unordered_set& m_outChangedProperties;
+ AZStd::unordered_map& m_propertyMetadata;
+ AZStd::unordered_map& m_propertyGroupMetadata;
+ AZStd::unordered_set& m_updatedPropertiesOut;
+ AZStd::unordered_set& m_updatedPropertyGroupsOut;
const MaterialPropertyFlags* m_materialPropertyDependencies = nullptr;
};
diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h
index d73ce2334b..fab72d5f96 100644
--- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h
+++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h
@@ -81,52 +81,6 @@ namespace AZ
AZStd::string GetMaterialPropertyDataTypeString(AZ::TypeId typeId);
- //! 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.
- //! 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.
- 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;
- };
-
//! A material property is any data input to a material, like a bool, float, Vector, Image, Buffer, etc.
//! This descriptor defines a single input property, including it's name ID, and how it maps
//! to the shader system.
@@ -171,7 +125,6 @@ namespace AZ
} // namespace RPI
AZ_TYPE_INFO_SPECIALIZE(RPI::MaterialPropertyOutputType, "{42A6E5E8-0FE6-4D7B-884A-1F478E4ADD97}");
- AZ_TYPE_INFO_SPECIALIZE(RPI::MaterialPropertyVisibility, "{318B43A2-79E3-4502-8FD0-5815209EA123}");
AZ_TYPE_INFO_SPECIALIZE(RPI::MaterialPropertyDataType, "{3D903D5C-C6AA-452E-A2F8-8948D30833FF}");
} // namespace AZ
diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Material/MaterialSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Material/MaterialSystem.cpp
index e7e04b271d..f1751a02e2 100644
--- a/Gems/Atom/RPI/Code/Source/RPI.Public/Material/MaterialSystem.cpp
+++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Material/MaterialSystem.cpp
@@ -32,6 +32,7 @@ namespace AZ
MaterialPropertiesLayout::Reflect(context);
MaterialFunctor::Reflect(context);
LuaMaterialFunctor::Reflect(context);
+ ReflectMaterialDynamicMetadata(context);
}
void MaterialSystem::GetAssetHandlers(AssetHandlerPtrList& assetHandlers)
diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/LuaMaterialFunctor.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/LuaMaterialFunctor.cpp
index 7ab3489666..7db5f12560 100644
--- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/LuaMaterialFunctor.cpp
+++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/LuaMaterialFunctor.cpp
@@ -63,6 +63,7 @@ namespace AZ
behaviorContext->Class();
MaterialPropertyDescriptor::Reflect(behaviorContext);
+ ReflectMaterialDynamicMetadata(behaviorContext);
LuaMaterialFunctorRenderStates::Reflect(behaviorContext);
LuaMaterialFunctorShaderItem::Reflect(behaviorContext);
@@ -255,7 +256,7 @@ namespace AZ
// Specialize for type Image* because that will be more intuitive within Lua.
// The script can then check the result for nil without calling "get()".
- // For example, "GetMaterialPropertyValue_image(name) == nil" rather than "GetMaterialPropertyValue_image(name):get() == nil"
+ // For example, "GetMaterialPropertyValue_Image(name) == nil" rather than "GetMaterialPropertyValue_Image(name):get() == nil"
template<>
Image* LuaMaterialFunctorCommonContext::GetMaterialPropertyValue(const char* name) const
{
@@ -278,7 +279,7 @@ namespace AZ
->Method("GetMaterialPropertyValue_Vector3", &LuaMaterialFunctorRuntimeContext::GetMaterialPropertyValue)
->Method("GetMaterialPropertyValue_Vector4", &LuaMaterialFunctorRuntimeContext::GetMaterialPropertyValue)
->Method("GetMaterialPropertyValue_Color", &LuaMaterialFunctorRuntimeContext::GetMaterialPropertyValue)
- ->Method("GetMaterialPropertyValue_image", &LuaMaterialFunctorRuntimeContext::GetMaterialPropertyValue)
+ ->Method("GetMaterialPropertyValue_Image", &LuaMaterialFunctorRuntimeContext::GetMaterialPropertyValue)
->Method("SetShaderConstant_bool", &LuaMaterialFunctorRuntimeContext::SetShaderConstant)
->Method("SetShaderConstant_int", &LuaMaterialFunctorRuntimeContext::SetShaderConstant)
->Method("SetShaderConstant_uint", &LuaMaterialFunctorRuntimeContext::SetShaderConstant)
@@ -436,7 +437,7 @@ namespace AZ
->Method("GetMaterialPropertyValue_Vector3", &LuaMaterialFunctorEditorContext::GetMaterialPropertyValue)
->Method("GetMaterialPropertyValue_Vector4", &LuaMaterialFunctorEditorContext::GetMaterialPropertyValue)
->Method("GetMaterialPropertyValue_Color", &LuaMaterialFunctorEditorContext::GetMaterialPropertyValue)
- ->Method("GetMaterialPropertyValue_image", &LuaMaterialFunctorEditorContext::GetMaterialPropertyValue)
+ ->Method("GetMaterialPropertyValue_Image", &LuaMaterialFunctorEditorContext::GetMaterialPropertyValue)
->Method("SetMaterialPropertyVisibility", &LuaMaterialFunctorEditorContext::SetMaterialPropertyVisibility)
->Method("SetMaterialPropertyDescription", &LuaMaterialFunctorEditorContext::SetMaterialPropertyDescription)
->Method("SetMaterialPropertyMinValue_int", &LuaMaterialFunctorEditorContext::SetMaterialPropertyMinValue)
@@ -451,6 +452,7 @@ namespace AZ
->Method("SetMaterialPropertySoftMaxValue_int", &LuaMaterialFunctorEditorContext::SetMaterialPropertySoftMaxValue)
->Method("SetMaterialPropertySoftMaxValue_uint", &LuaMaterialFunctorEditorContext::SetMaterialPropertySoftMaxValue)
->Method("SetMaterialPropertySoftMaxValue_float", &LuaMaterialFunctorEditorContext::SetMaterialPropertySoftMaxValue)
+ ->Method("SetMaterialPropertyGroupVisibility", &LuaMaterialFunctorEditorContext::SetMaterialPropertyGroupVisibility)
;
}
@@ -524,6 +526,15 @@ namespace AZ
return m_editorContextImpl->SetMaterialPropertySoftMaxValue(index, value);
}
+
+ bool LuaMaterialFunctorEditorContext::SetMaterialPropertyGroupVisibility(const char* name, MaterialPropertyGroupVisibility visibility)
+ {
+ if (m_editorContextImpl)
+ {
+ return m_editorContextImpl->SetMaterialPropertyGroupVisibility(Name{m_propertyNamePrefix + name}, visibility);
+ }
+ return false;
+ }
bool LuaMaterialFunctorEditorContext::SetMaterialPropertyVisibility(const char* name, MaterialPropertyVisibility visibility)
{
diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialDynamicMetadata.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialDynamicMetadata.cpp
new file mode 100644
index 0000000000..5c8f4ccc02
--- /dev/null
+++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialDynamicMetadata.cpp
@@ -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
+#include
+
+namespace AZ
+{
+ namespace RPI
+ {
+ void ReflectMaterialDynamicMetadata(ReflectContext* context)
+ {
+ if (auto* serializeContext = azrtti_cast(context))
+ {
+ serializeContext->Enum()
+ ->Value("Enabled", MaterialPropertyVisibility::Enabled)
+ ->Value("Disabled", MaterialPropertyVisibility::Disabled)
+ ->Value("Hidden", MaterialPropertyVisibility::Hidden)
+ ;
+
+ serializeContext->Enum()
+ ->Value("Enabled", MaterialPropertyGroupVisibility::Enabled)
+ ->Value("Hidden", MaterialPropertyGroupVisibility::Hidden)
+ ;
+ }
+
+ if (auto* behaviorContext = azrtti_cast(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
diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp
index 32772e9dd5..ab18a1fb66 100644
--- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp
+++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp
@@ -142,21 +142,25 @@ namespace AZ
MaterialFunctor::EditorContext::EditorContext(
const AZStd::vector& propertyValues,
RHI::ConstPtr materialPropertiesLayout,
- AZStd::unordered_map& metadata,
- AZStd::unordered_set& outChangedProperties,
+ AZStd::unordered_map& propertyMetadata,
+ AZStd::unordered_map& propertyGroupMetadata,
+ AZStd::unordered_set& updatedPropertiesOut,
+ AZStd::unordered_set& updatedPropertyGroupsOut,
const MaterialPropertyFlags* materialPropertyDependencies
)
: m_materialPropertyValues(propertyValues)
, m_materialPropertiesLayout(materialPropertiesLayout)
- , m_metadata(metadata)
- , m_outChangedProperties(outChangedProperties)
+ , m_propertyMetadata(propertyMetadata)
+ , m_propertyGroupMetadata(propertyGroupMetadata)
+ , m_updatedPropertiesOut(updatedPropertiesOut)
+ , m_updatedPropertyGroupsOut(updatedPropertyGroupsOut)
, m_materialPropertyDependencies(materialPropertyDependencies)
{}
const MaterialPropertyDynamicMetadata* MaterialFunctor::EditorContext::GetMaterialPropertyMetadata(const Name& propertyName) const
{
- auto it = QueryMaterialMetadata(propertyName);
- if (it == m_metadata.end())
+ auto it = QueryMaterialPropertyMetadata(propertyName);
+ if (it == m_propertyMetadata.end())
{
return nullptr;
}
@@ -168,11 +172,38 @@ namespace AZ
const Name& name = m_materialPropertiesLayout->GetPropertyDescriptor(index)->GetName();
return GetMaterialPropertyMetadata(name);
}
+
+ const MaterialPropertyGroupDynamicMetadata* MaterialFunctor::EditorContext::GetMaterialPropertyGroupMetadata(const Name& propertyName) const
+ {
+ auto it = QueryMaterialPropertyGroupMetadata(propertyName);
+ if (it == m_propertyGroupMetadata.end())
+ {
+ return nullptr;
+ }
+ return &(it->second);
+ }
+
+ bool MaterialFunctor::EditorContext::SetMaterialPropertyGroupVisibility(const Name& propertyGroupName, MaterialPropertyGroupVisibility visibility)
+ {
+ auto it = QueryMaterialPropertyGroupMetadata(propertyGroupName);
+ if (it == m_propertyGroupMetadata.end())
+ {
+ return false;
+ }
+ MaterialPropertyGroupVisibility originValue = it->second.m_visibility;
+ it->second.m_visibility = visibility;
+ if (originValue != visibility)
+ {
+ m_updatedPropertyGroupsOut.insert(propertyGroupName);
+ }
+
+ return true;
+ }
bool MaterialFunctor::EditorContext::SetMaterialPropertyVisibility(const Name& propertyName, MaterialPropertyVisibility visibility)
{
- auto it = QueryMaterialMetadata(propertyName);
- if (it == m_metadata.end())
+ auto it = QueryMaterialPropertyMetadata(propertyName);
+ if (it == m_propertyMetadata.end())
{
return false;
}
@@ -180,7 +211,7 @@ namespace AZ
it->second.m_visibility = visibility;
if (originValue != visibility)
{
- m_outChangedProperties.insert(propertyName);
+ m_updatedPropertiesOut.insert(propertyName);
}
return true;
@@ -194,8 +225,8 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertyDescription(const Name& propertyName, AZStd::string description)
{
- auto it = QueryMaterialMetadata(propertyName);
- if (it == m_metadata.end())
+ auto it = QueryMaterialPropertyMetadata(propertyName);
+ if (it == m_propertyMetadata.end())
{
return false;
}
@@ -204,7 +235,7 @@ namespace AZ
it->second.m_description = description;
if (origin != description)
{
- m_outChangedProperties.insert(propertyName);
+ m_updatedPropertiesOut.insert(propertyName);
}
return true;
@@ -218,8 +249,8 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertyMinValue(const Name& propertyName, const MaterialPropertyValue& min)
{
- auto it = QueryMaterialMetadata(propertyName);
- if (it == m_metadata.end())
+ auto it = QueryMaterialPropertyMetadata(propertyName);
+ if (it == m_propertyMetadata.end())
{
return false;
}
@@ -229,7 +260,7 @@ namespace AZ
if(origin != min)
{
- m_outChangedProperties.insert(propertyName);
+ m_updatedPropertiesOut.insert(propertyName);
}
return true;
@@ -243,8 +274,8 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertyMaxValue(const Name& propertyName, const MaterialPropertyValue& max)
{
- auto it = QueryMaterialMetadata(propertyName);
- if (it == m_metadata.end())
+ auto it = QueryMaterialPropertyMetadata(propertyName);
+ if (it == m_propertyMetadata.end())
{
return false;
}
@@ -254,7 +285,7 @@ namespace AZ
if (origin != max)
{
- m_outChangedProperties.insert(propertyName);
+ m_updatedPropertiesOut.insert(propertyName);
}
return true;
@@ -268,8 +299,8 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertySoftMinValue(const Name& propertyName, const MaterialPropertyValue& min)
{
- auto it = QueryMaterialMetadata(propertyName);
- if (it == m_metadata.end())
+ auto it = QueryMaterialPropertyMetadata(propertyName);
+ if (it == m_propertyMetadata.end())
{
return false;
}
@@ -279,7 +310,7 @@ namespace AZ
if (origin != min)
{
- m_outChangedProperties.insert(propertyName);
+ m_updatedPropertiesOut.insert(propertyName);
}
return true;
@@ -293,8 +324,8 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertySoftMaxValue(const Name& propertyName, const MaterialPropertyValue& max)
{
- auto it = QueryMaterialMetadata(propertyName);
- if (it == m_metadata.end())
+ auto it = QueryMaterialPropertyMetadata(propertyName);
+ if (it == m_propertyMetadata.end())
{
return false;
}
@@ -304,7 +335,7 @@ namespace AZ
if (origin != max)
{
- m_outChangedProperties.insert(propertyName);
+ m_updatedPropertiesOut.insert(propertyName);
}
return true;
@@ -316,16 +347,27 @@ namespace AZ
return SetMaterialPropertySoftMaxValue(name, max);
}
- AZStd::list_iterator> MaterialFunctor::EditorContext::QueryMaterialMetadata(const Name& propertyName) const
+ AZStd::list_iterator> MaterialFunctor::EditorContext::QueryMaterialPropertyMetadata(const Name& propertyName) const
{
- auto it = m_metadata.find(propertyName);
- if (it == m_metadata.end())
+ auto it = m_propertyMetadata.find(propertyName);
+ if (it == m_propertyMetadata.end())
{
AZ_Error("MaterialFunctor", false, "Couldn't find metadata for material property: %s.", propertyName.GetCStr());
}
return it;
}
+
+ AZStd::list_iterator> MaterialFunctor::EditorContext::QueryMaterialPropertyGroupMetadata(const Name& propertyGroupName) const
+ {
+ auto it = m_propertyGroupMetadata.find(propertyGroupName);
+ if (it == m_propertyGroupMetadata.end())
+ {
+ AZ_Error("MaterialFunctor", false, "Couldn't find metadata for material property group: %s.", propertyGroupName.GetCStr());
+ }
+
+ return it;
+ }
template
const Type& MaterialFunctor::RuntimeContext::GetMaterialPropertyValue(const MaterialPropertyIndex& index) const
diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialPropertyDescriptor.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialPropertyDescriptor.cpp
index 367d95357b..72d658db63 100644
--- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialPropertyDescriptor.cpp
+++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialPropertyDescriptor.cpp
@@ -124,12 +124,6 @@ namespace AZ
->Value(ToString(MaterialPropertyOutputType::ShaderOption), MaterialPropertyOutputType::ShaderOption)
;
- serializeContext->Enum()
- ->Value("Enabled", MaterialPropertyVisibility::Enabled)
- ->Value("Disabled", MaterialPropertyVisibility::Disabled)
- ->Value("Hidden", MaterialPropertyVisibility::Hidden)
- ;
-
serializeContext->Enum()
->Value(ToString(MaterialPropertyDataType::Invalid), MaterialPropertyDataType::Invalid)
->Value(ToString(MaterialPropertyDataType::Bool), MaterialPropertyDataType::Bool)
@@ -153,14 +147,6 @@ namespace AZ
;
}
- if (auto* behaviorContext = azrtti_cast(context))
- {
- behaviorContext
- ->Enum<(int)MaterialPropertyVisibility::Enabled>("MaterialPropertyVisibility_Enabled")
- ->Enum<(int)MaterialPropertyVisibility::Disabled>("MaterialPropertyVisibility_Disabled")
- ->Enum<(int)MaterialPropertyVisibility::Hidden>("MaterialPropertyVisibility_Hidden");
- }
-
MaterialPropertyIndex::Reflect(context);
}
diff --git a/Gems/Atom/RPI/Code/Tests/Material/LuaMaterialFunctorTests.cpp b/Gems/Atom/RPI/Code/Tests/Material/LuaMaterialFunctorTests.cpp
index 76fa6bfb0e..3dcbdfce07 100644
--- a/Gems/Atom/RPI/Code/Tests/Material/LuaMaterialFunctorTests.cpp
+++ b/Gems/Atom/RPI/Code/Tests/Material/LuaMaterialFunctorTests.cpp
@@ -748,12 +748,15 @@ namespace UnitTest
MaterialPropertyDataType::UInt, "general.mode",
MaterialPropertyDataType::Float, "general.value",
functorScript);
-
+
AZStd::unordered_set changedPropertyNames;
-
AZStd::unordered_map propertyDynamicMetadata;
propertyDynamicMetadata[Name{"general.mode"}] = {};
propertyDynamicMetadata[Name{"general.value"}] = {};
+
+ AZStd::unordered_set changedPropertyGroupNames;
+ AZStd::unordered_map propertyGroupDynamicMetadata;
+ propertyGroupDynamicMetadata[Name{"general"}] = {};
Ptr 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 changedPropertyNames;
-
AZStd::unordered_map propertyDynamicMetadata;
propertyDynamicMetadata[Name{"general.units"}] = {};
propertyDynamicMetadata[Name{"general.distance"}] = {};
+
+ AZStd::unordered_set changedPropertyGroupNames;
+ AZStd::unordered_map propertyGroupDynamicMetadata;
+ propertyGroupDynamicMetadata[Name{"general"}] = {};
Ptr 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());
EXPECT_EQ(100.0f, propertyDynamicMetadata[Name{"general.distance"}].m_propertyRange.m_softMax.GetValue());
}
+
+ 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 changedPropertyNames;
+ AZStd::unordered_map propertyDynamicMetadata;
+ propertyDynamicMetadata[Name{"general.mode"}] = {};
+ propertyDynamicMetadata[Name{"otherGroup.value"}] = {};
+
+ AZStd::unordered_set changedPropertyGroupNames;
+ AZStd::unordered_map propertyGroupDynamicMetadata;
+ propertyGroupDynamicMetadata[Name{"general"}] = {};
+ propertyGroupDynamicMetadata[Name{"otherGroup"}] = {};
+
+ Ptr 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)
{
diff --git a/Gems/Atom/RPI/Code/Tests/Material/MaterialPropertySerializerTests.cpp b/Gems/Atom/RPI/Code/Tests/Material/MaterialPropertySerializerTests.cpp
index 5a81ebb74d..d32c285780 100644
--- a/Gems/Atom/RPI/Code/Tests/Material/MaterialPropertySerializerTests.cpp
+++ b/Gems/Atom/RPI/Code/Tests/Material/MaterialPropertySerializerTests.cpp
@@ -29,6 +29,7 @@ namespace JsonSerializationTests
{
AZ::RPI::MaterialTypeSourceData::Reflect(context.get());
AZ::RPI::MaterialPropertyDescriptor::Reflect(context.get());
+ AZ::RPI::ReflectMaterialDynamicMetadata(context.get());
}
void Reflect(AZStd::unique_ptr& context)
diff --git a/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake b/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake
index d1db00aa34..307f3a046b 100644
--- a/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake
+++ b/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake
@@ -55,6 +55,7 @@ set(FILES
Include/Atom/RPI.Reflect/Material/MaterialAsset.h
Include/Atom/RPI.Reflect/Material/MaterialAssetCreatorCommon.h
Include/Atom/RPI.Reflect/Material/MaterialAssetCreator.h
+ Include/Atom/RPI.Reflect/Material/MaterialDynamicMetadata.h
Include/Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h
Include/Atom/RPI.Reflect/Material/MaterialPropertiesLayout.h
Include/Atom/RPI.Reflect/Material/MaterialPropertyValue.h
@@ -135,6 +136,7 @@ set(FILES
Source/RPI.Reflect/Material/MaterialAssetCreatorCommon.cpp
Source/RPI.Reflect/Material/MaterialAssetCreator.cpp
Source/RPI.Reflect/Material/LuaMaterialFunctor.cpp
+ Source/RPI.Reflect/Material/MaterialDynamicMetadata.cpp
Source/RPI.Reflect/Material/MaterialPropertyDescriptor.cpp
Source/RPI.Reflect/Material/MaterialPropertiesLayout.cpp
Source/RPI.Reflect/Material/MaterialTypeAsset.cpp
diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/DynamicProperty/DynamicProperty.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/DynamicProperty/DynamicProperty.h
index b17a25a675..17ca1c8d04 100644
--- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/DynamicProperty/DynamicProperty.h
+++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/DynamicProperty/DynamicProperty.h
@@ -38,8 +38,8 @@ namespace AtomToolsFramework
Count
};
- // Configures the initial state, data type, attributes, and values that describe
- // the dynamic property and how it is presented
+ //! Configures the initial state, data type, attributes, and values that describe
+ //! the dynamic property and how it is presented
struct DynamicPropertyConfig
{
AZ_TYPE_INFO(DynamicPropertyConfig, "{9CA40E92-7F03-42BE-B6AA-51F30EE5796C}");
@@ -98,7 +98,7 @@ namespace AtomToolsFramework
//! Returns true if the property has a valid value.
bool IsValid() const;
- //! Returns the ID of the property.
+ //! Returns the ID of the property.
const AZ::Name GetId() const;
//! Returns the current property visibility.
diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h
index 81b512faf2..0403c06f87 100644
--- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h
+++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h
@@ -44,6 +44,12 @@ namespace AtomToolsFramework
const AZStd::string& groupDescription,
QWidget* groupWidget) = 0;
+ //! Sets the visibility of a specific property group. This impacts both the header and the widget.
+ virtual void SetGroupVisible(const AZStd::string& groupNameId, bool visible) = 0;
+
+ //! Returns the visibility of a specific property group.
+ virtual bool IsGroupVisible(const AZStd::string& groupNameId) const = 0;
+
//! Calls Refresh for a specific InspectorGroupWidget, allowing for non-destructive UI changes
virtual void RefreshGroup(const AZStd::string& groupNameId) = 0;
diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h
index b0932b3b04..5559b51462 100644
--- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h
+++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h
@@ -57,6 +57,9 @@ namespace AtomToolsFramework
const AZStd::string& groupDescription,
QWidget* groupWidget) override;
+ void SetGroupVisible(const AZStd::string& groupNameId, bool visible) override;
+ bool IsGroupVisible(const AZStd::string& groupNameId) const override;
+
void RefreshGroup(const AZStd::string& groupNameId) override;
void RebuildGroup(const AZStd::string& groupNameId) override;
diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp
index ec5f9893bd..c1ccfb4616 100644
--- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp
+++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp
@@ -69,6 +69,7 @@ namespace AtomToolsFramework
InspectorGroupHeaderWidget* groupHeader = new InspectorGroupHeaderWidget(m_ui->m_propertyContent);
groupHeader->setText(groupDisplayName.c_str());
groupHeader->setToolTip(groupDescription.c_str());
+ groupHeader->setObjectName(groupNameId.c_str());
m_layout->addWidget(groupHeader);
m_headers.push_back(groupHeader);
@@ -81,6 +82,32 @@ namespace AtomToolsFramework
OnHeaderClicked(event, groupHeader, groupWidget);
});
}
+
+ void InspectorWidget::SetGroupVisible(const AZStd::string& groupNameId, bool visible)
+ {
+ for (size_t i = 0; i < m_groups.size(); ++i)
+ {
+ if (m_groups[i]->objectName() == groupNameId.c_str())
+ {
+ m_headers[i]->setVisible(visible);
+ m_groups[i]->setVisible(visible && m_headers[i]->IsExpanded());
+ break;
+ }
+ }
+ }
+
+ bool InspectorWidget::IsGroupVisible(const AZStd::string& groupNameId) const
+ {
+ for (auto& header : m_headers)
+ {
+ if (header->objectName() == groupNameId.c_str())
+ {
+ return header->isVisible();
+ }
+ }
+
+ return false;
+ }
void InspectorWidget::RefreshGroup(const AZStd::string& groupNameId)
{
diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Document/MaterialDocumentNotificationBus.h b/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Document/MaterialDocumentNotificationBus.h
index 3c3c77a628..80e8054ec5 100644
--- a/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Document/MaterialDocumentNotificationBus.h
+++ b/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Document/MaterialDocumentNotificationBus.h
@@ -18,6 +18,7 @@
#include
#include
+#include
namespace MaterialEditor
{
@@ -77,6 +78,12 @@ namespace MaterialEditor
//! @param documentId unique id of material document for which the notification is sent
//! @param property object containing the property value and configuration that was modified
virtual void OnDocumentPropertyConfigModified([[maybe_unused]] const AZ::Uuid& documentId, [[maybe_unused]] const AtomToolsFramework::DynamicProperty& property) {}
+
+ //! Signal that the property group visibility has been changed.
+ //! @param documentId unique id of material document for which the notification is sent
+ //! @param groupId id of the group that changed
+ //! @param visible whether the property group is visible
+ virtual void OnDocumentPropertyGroupVisibilityChanged([[maybe_unused]] const AZ::Uuid& documentId, [[maybe_unused]] const AZ::Name& groupId, [[maybe_unused]] bool visible) {}
};
using MaterialDocumentNotificationBus = AZ::EBus;
diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Document/MaterialDocumentRequestBus.h b/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Document/MaterialDocumentRequestBus.h
index dad21a6348..c71d500d8c 100644
--- a/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Document/MaterialDocumentRequestBus.h
+++ b/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Document/MaterialDocumentRequestBus.h
@@ -19,6 +19,7 @@
#include
#include
+#include
namespace AZ
{
@@ -67,6 +68,10 @@ namespace MaterialEditor
//! Returns a property object
//! If the document is not open or the id can't be found, an invalid property is returned.
virtual const AtomToolsFramework::DynamicProperty& GetProperty(const AZ::Name& propertyFullName) const = 0;
+
+ //! Returns whether a property group is visible
+ //! If the document is not open or the id can't be found, returns false.
+ virtual bool IsPropertyGroupVisible(const AZ::Name& propertyGroupFullName) const = 0;
//! Modify material property value
virtual void SetPropertyValue(const AZ::Name& propertyFullName, const AZStd::any& value) = 0;
diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp
index 288530a4e4..fec70763dd 100644
--- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp
+++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp
@@ -117,6 +117,24 @@ namespace MaterialEditor
const AtomToolsFramework::DynamicProperty& property = it->second;
return property;
}
+
+ bool MaterialDocument::IsPropertyGroupVisible(const AZ::Name& propertyGroupFullName) const
+ {
+ if (!IsOpen())
+ {
+ AZ_Error("MaterialDocument", false, "Material document is not open.");
+ return false;
+ }
+
+ const auto it = m_propertyGroupVisibility.find(propertyGroupFullName);
+ if (it == m_propertyGroupVisibility.end())
+ {
+ AZ_Error("MaterialDocument", false, "Material document property group could not be found: '%s'.", propertyGroupFullName.GetCStr());
+ return false;
+ }
+
+ return it->second;
+ }
void MaterialDocument::SetPropertyValue(const AZ::Name& propertyFullName, const AZStd::any& value)
{
@@ -153,8 +171,12 @@ namespace MaterialEditor
Recompile();
- AZStd::unordered_set changedPropertyNames = RunEditorMaterialFunctors(dirtyFlags);
- for (const Name& changedPropertyName : changedPropertyNames)
+ EditorMaterialFunctorResult result = RunEditorMaterialFunctors(dirtyFlags);
+ for (const Name& changedPropertyGroupName : result.m_updatedPropertyGroups)
+ {
+ MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentPropertyGroupVisibilityChanged, m_id, changedPropertyGroupName, IsPropertyGroupVisible(changedPropertyGroupName));
+ }
+ for (const Name& changedPropertyName : result.m_updatedProperties)
{
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentPropertyConfigModified, m_id, GetProperty(changedPropertyName));
}
@@ -782,6 +804,12 @@ namespace MaterialEditor
return true;
});
+ // Populate the property group visibility map
+ for (MaterialTypeSourceData::GroupDefinition& group : m_materialTypeSourceData.GetGroupDefinitionsInDisplayOrder())
+ {
+ m_propertyGroupVisibility[AZ::Name{group.m_nameId}] = true;
+ }
+
// Adding properties for material type and parent as part of making dynamic
// properties and the inspector more general purpose.
// This allows the read only properties to appear in the inspector like any
@@ -914,16 +942,26 @@ namespace MaterialEditor
}
}
- AZStd::unordered_set MaterialDocument::RunEditorMaterialFunctors(AZ::RPI::MaterialPropertyFlags dirtyFlags)
+ MaterialDocument::EditorMaterialFunctorResult MaterialDocument::RunEditorMaterialFunctors(AZ::RPI::MaterialPropertyFlags dirtyFlags)
{
- AZStd::unordered_set changedPropertyNames;
+ EditorMaterialFunctorResult result;
+
AZStd::unordered_map propertyDynamicMetadata;
+ AZStd::unordered_map propertyGroupDynamicMetadata;
for (auto& propertyPair : m_properties)
{
AtomToolsFramework::DynamicProperty& property = propertyPair.second;
AtomToolsFramework::ConvertToPropertyMetaData(propertyDynamicMetadata[property.GetId()], property.GetConfig());
}
+ for (auto& groupPair : m_propertyGroupVisibility)
+ {
+ AZ::RPI::MaterialPropertyGroupDynamicMetadata& metadata = propertyGroupDynamicMetadata[AZ::Name{groupPair.first}];
+ bool visible = groupPair.second;
+ metadata.m_visibility = visible ?
+ AZ::RPI::MaterialPropertyGroupVisibility::Enabled : AZ::RPI::MaterialPropertyGroupVisibility::Hidden;
+ }
+
for (AZ::RPI::Ptr& functor : m_editorFunctors)
{
const AZ::RPI::MaterialPropertyFlags& materialPropertyDependencies = functor->GetMaterialPropertyDependencies();
@@ -935,7 +973,9 @@ namespace MaterialEditor
m_materialInstance->GetPropertyValues(),
m_materialInstance->GetMaterialPropertiesLayout(),
propertyDynamicMetadata,
- changedPropertyNames,
+ propertyGroupDynamicMetadata,
+ result.m_updatedProperties,
+ result.m_updatedPropertyGroups,
&materialPropertyDependencies
);
functor->Process(context);
@@ -950,7 +990,13 @@ namespace MaterialEditor
property.SetConfig(propertyConfig);
}
- return changedPropertyNames;
+ for (auto& updatedPropertyGroup : result.m_updatedPropertyGroups)
+ {
+ bool visible = propertyGroupDynamicMetadata[updatedPropertyGroup].m_visibility == AZ::RPI::MaterialPropertyGroupVisibility::Enabled;
+ m_propertyGroupVisibility[updatedPropertyGroup] = visible;
+ }
+
+ return result;
}
} // namespace MaterialEditor
diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.h
index 3959e45ad7..42f48c95cd 100644
--- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.h
+++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.h
@@ -56,6 +56,7 @@ namespace MaterialEditor
const AZ::RPI::MaterialTypeSourceData* GetMaterialTypeSourceData() const override;
const AZStd::any& GetPropertyValue(const AZ::Name& propertyFullName) const override;
const AtomToolsFramework::DynamicProperty& GetProperty(const AZ::Name& propertyFullName) const override;
+ bool IsPropertyGroupVisible(const AZ::Name& propertyGroupFullName) const override;
void SetPropertyValue(const AZ::Name& propertyFullName, const AZStd::any& value) override;
bool Open(AZStd::string_view loadPath) override;
bool Rebuild() override;
@@ -79,11 +80,14 @@ namespace MaterialEditor
// Predicate for evaluating properties
using PropertyFilterFunction = AZStd::function;
- // Map of documenmt's property
+ // Map of document's properties
using PropertyMap = AZStd::unordered_map;
// Map of raw property values for undo/redo comparison and storage
using PropertyValueMap = AZStd::unordered_map;
+
+ // Map of document's property group visibility flags
+ using PropertyGroupVisibilityMap = AZStd::unordered_map;
// Function to be bound for undo and redo
using UndoRedoFunction = AZStd::function;
@@ -119,10 +123,16 @@ namespace MaterialEditor
void RestorePropertyValues(const PropertyValueMap& propertyValues);
+ struct EditorMaterialFunctorResult
+ {
+ AZStd::unordered_set m_updatedProperties;
+ AZStd::unordered_set m_updatedPropertyGroups;
+ };
+
// Run editor material functor to update editor metadata.
// @param dirtyFlags indicates which properties have changed, and thus which MaterialFunctors need to be run.
- // @return names for the set of properties that have been changed or need update.
- AZStd::unordered_set RunEditorMaterialFunctors(AZ::RPI::MaterialPropertyFlags dirtyFlags);
+ // @return names for the set of properties and groups that have been changed or need update.
+ EditorMaterialFunctorResult RunEditorMaterialFunctors(AZ::RPI::MaterialPropertyFlags dirtyFlags);
// Unique id of this material document
AZ::Uuid m_id = AZ::Uuid::CreateRandom();
@@ -153,6 +163,9 @@ namespace MaterialEditor
// Collection of all material's properties
PropertyMap m_properties;
+
+ // Collection of all material's property groups
+ PropertyGroupVisibilityMap m_propertyGroupVisibility;
// Material functors that run in editor. See MaterialFunctor.h for details.
AZStd::vector> m_editorFunctors;
@@ -175,7 +188,7 @@ namespace MaterialEditor
int m_undoHistoryIndex = 0;
AZStd::any m_invalidValue;
-
+
AtomToolsFramework::DynamicProperty m_invalidProperty;
};
} // namespace MaterialEditor
diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp
index b066c3c7dd..0fd3a8e2a8 100644
--- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp
+++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp
@@ -185,7 +185,7 @@ namespace MaterialEditor
}
}
- void MaterialInspector::OnDocumentPropertyConfigModified(const AZ::Uuid& documentId, const AtomToolsFramework::DynamicProperty& property)
+ void MaterialInspector::OnDocumentPropertyConfigModified(const AZ::Uuid&, const AtomToolsFramework::DynamicProperty& property)
{
for (auto& groupPair : m_groups)
{
@@ -197,18 +197,28 @@ namespace MaterialEditor
if (reflectedProperty.GetVisibility() != property.GetVisibility())
{
reflectedProperty.SetConfig(property.GetConfig());
- AtomToolsFramework::InspectorRequestBus::Event(documentId, &AtomToolsFramework::InspectorRequestBus::Events::RebuildGroup, groupPair.first);
+ RebuildGroup(groupPair.first);
}
else
{
reflectedProperty.SetConfig(property.GetConfig());
- AtomToolsFramework::InspectorRequestBus::Event(documentId, &AtomToolsFramework::InspectorRequestBus::Events::RefreshGroup, groupPair.first);
+ RefreshGroup(groupPair.first);
}
return;
}
}
}
}
+
+ void MaterialInspector::OnDocumentPropertyGroupVisibilityChanged(const AZ::Uuid&, const AZ::Name& groupId, bool visible)
+ {
+ auto groupIter = m_groups.find(groupId.GetStringView());
+
+ if(groupIter != m_groups.end())
+ {
+ SetGroupVisible(groupIter->first, visible);
+ }
+ }
void MaterialInspector::BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode)
{
diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.h
index efe979e5ea..65de41f240 100644
--- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.h
+++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.h
@@ -50,6 +50,7 @@ namespace MaterialEditor
void OnDocumentOpened(const AZ::Uuid& documentId) override;
void OnDocumentPropertyValueModified(const AZ::Uuid& documentId, const AtomToolsFramework::DynamicProperty& property) override;
void OnDocumentPropertyConfigModified(const AZ::Uuid& documentId, const AtomToolsFramework::DynamicProperty& property) override;
+ void OnDocumentPropertyGroupVisibilityChanged(const AZ::Uuid& documentId, const AZ::Name& groupId, bool visible) override;
// AzToolsFramework::IPropertyEditorNotify overrides...
void BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp
index 03533e142f..62f8a58fab 100644
--- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp
+++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp
@@ -288,15 +288,17 @@ namespace AZ
void MaterialPropertyInspector::RunEditorMaterialFunctors()
{
AZStd::unordered_set changedPropertyNames;
+ AZStd::unordered_set changedPropertyGroupNames;
// Convert editor property configuration data into material property meta data so that it can be used to execute functors
AZStd::unordered_map propertyDynamicMetadata;
- for (auto& group : m_groups)
+ AZStd::unordered_map propertyGroupDynamicMetadata;
+ for (auto& groupPair : m_groups)
{
- for (auto& property : group.second.m_properties)
- {
- AtomToolsFramework::ConvertToPropertyMetaData(propertyDynamicMetadata[property.GetId()], property.GetConfig());
- }
+ AZ::RPI::MaterialPropertyGroupDynamicMetadata& metadata = propertyGroupDynamicMetadata[AZ::Name{groupPair.first}];
+
+ metadata.m_visibility = IsGroupVisible(groupPair.first) ?
+ AZ::RPI::MaterialPropertyGroupVisibility::Enabled : AZ::RPI::MaterialPropertyGroupVisibility::Hidden;
}
for (AZ::RPI::Ptr& functor : m_editorFunctors)
@@ -310,7 +312,9 @@ namespace AZ
m_materialInstance->GetPropertyValues(),
m_materialInstance->GetMaterialPropertiesLayout(),
propertyDynamicMetadata,
+ propertyGroupDynamicMetadata,
changedPropertyNames,
+ changedPropertyGroupNames,
&materialPropertyDependencies
);
functor->Process(context);
@@ -319,9 +323,16 @@ namespace AZ
m_dirtyPropertyFlags.reset();
// Apply any changes to material property meta data back to the editor property configurations
- for (auto& group : m_groups)
+ for (auto& groupPair : m_groups)
{
- for (auto& property : group.second.m_properties)
+ AZ::Name groupName{groupPair.first};
+
+ if (changedPropertyGroupNames.find(groupName) != changedPropertyGroupNames.end())
+ {
+ SetGroupVisible(groupPair.first, propertyGroupDynamicMetadata[groupName].m_visibility == AZ::RPI::MaterialPropertyGroupVisibility::Enabled);
+ }
+
+ for (auto& property : groupPair.second.m_properties)
{
AtomToolsFramework::DynamicPropertyConfig propertyConfig = property.GetConfig();
From b225dcfa79a4ee9bfe48456899dba0632e632e24 Mon Sep 17 00:00:00 2001
From: moudgils
Date: Wed, 12 May 2021 19:37:44 -0700
Subject: [PATCH 026/163] Update cmake to use the new Dxc binaries for windows
---
cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake
index bdc93d9a0e..9b202f2eb2 100644
--- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake
+++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake
@@ -1,4 +1,4 @@
-#
+#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
@@ -28,8 +28,8 @@ ly_associate_package(PACKAGE_NAME expat-2.1.0-multiplatform
ly_associate_package(PACKAGE_NAME zstd-1.35-multiplatform TARGETS zstd PACKAGE_HASH 45d466c435f1095898578eedde85acf1fd27190e7ea99aeaa9acfd2f09e12665)
ly_associate_package(PACKAGE_NAME SQLite-3.32.2-rev3-multiplatform TARGETS SQLite PACKAGE_HASH dd4d3de6cbb4ce3d15fc504ba0ae0587e515dc89a25228037035fc0aef4831f4)
ly_associate_package(PACKAGE_NAME SPIRVCross-2020.04.20-rev1-multiplatform TARGETS SPIRVCross PACKAGE_HASH 7c8c0eaa0166c26745c62d2238525af7e27ac058a5db3defdbaec1878e8798dd)
-ly_associate_package(PACKAGE_NAME DirectXShaderCompilerDxc-2020.08.07-rev1-multiplatform TARGETS DirectXShaderCompilerDxc PACKAGE_HASH 04a6850ce03d4c16e19ed206f7093d885276dfb74047e6aa99f0a834c8b7cc73)
ly_associate_package(PACKAGE_NAME DirectXShaderCompilerDxcAz-5.0.0_az-rev1-multiplatform TARGETS DirectXShaderCompilerDxcAz PACKAGE_HASH 94f24989a7a371d840b513aa5ffaff02747b3d19b119bc1f899427e29978f753)
+ly_associate_package(PACKAGE_NAME DirectXShaderCompiler-2021.05.05-rev1-windows TARGETS DirectXShaderCompilerDxc PACKAGE_HASH b2e34c4a19b8a996c1e488aeb83233abe1985b6502ef644516ef692029b98f6d)
ly_associate_package(PACKAGE_NAME azslc-1.7.20-rev1-multiplatform TARGETS azslc PACKAGE_HASH 45d55f28bea2ef823ed3204f60df52e5e329f42923923d4555fdbdf3bea0af60)
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)
ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5)
From e429c8e06a1638eb8ac2e29ae4fa5d5d0c2ec1c7 Mon Sep 17 00:00:00 2001
From: Chris Santora
Date: Wed, 12 May 2021 23:28:05 -0700
Subject: [PATCH 027/163] Fixed issues after merging latest main, as well as
some edge cases I didn't notice before.
The structure of InspectorWidget::m_groups changed, so I had to update my new code accordingly.
Updated the InspectorWidget::m_groups code a bit to be more readable.
Discovered the initial property group visiblity state wasn't being set correctly when a material was first opened, so groups weren't initially hidden when they should have been. This had to be fixed in different ways for MaterialEditor's inspector and MaterialComponent's inspector.
ATOM-14688 Disable Individual Layers
---
.../Inspector/InspectorRequestBus.h | 7 ++-
.../Inspector/InspectorWidget.h | 10 +++-
.../Code/Source/Inspector/InspectorWidget.cpp | 50 +++++++++++--------
.../MaterialInspector/MaterialInspector.cpp | 5 ++
.../EditorMaterialComponentInspector.cpp | 7 ++-
5 files changed, 53 insertions(+), 26 deletions(-)
diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h
index 442ff90f5b..d9b626f631 100644
--- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h
+++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorRequestBus.h
@@ -47,8 +47,13 @@ namespace AtomToolsFramework
//! Sets the visibility of a specific property group. This impacts both the header and the widget.
virtual void SetGroupVisible(const AZStd::string& groupNameId, bool visible) = 0;
- //! Returns the visibility of a specific property group.
+ //! Returns whether a specific property is visible.
+ //! Note this follows the same rules as QWidget::isVisible(), meaning a group could be not visible due to the widget's parents being not visible.
virtual bool IsGroupVisible(const AZStd::string& groupNameId) const = 0;
+
+ //! Returns whether a specific property is explicitly hidden.
+ //! Note this follows the same rules as QWidget::isHidden(), meaning a group that is hidden will not become visible automatically when the parent becomes visible.
+ virtual bool IsGroupHidden(const AZStd::string& groupNameId) const = 0;
//! Calls Refresh for a specific InspectorGroupWidget, allowing for non-destructive UI changes
virtual void RefreshGroup(const AZStd::string& groupNameId) = 0;
diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h
index 4e94de952c..5e41121b37 100644
--- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h
+++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Inspector/InspectorWidget.h
@@ -59,6 +59,7 @@ namespace AtomToolsFramework
void SetGroupVisible(const AZStd::string& groupNameId, bool visible) override;
bool IsGroupVisible(const AZStd::string& groupNameId) const override;
+ bool IsGroupHidden(const AZStd::string& groupNameId) const override;
void RefreshGroup(const AZStd::string& groupNameId) override;
void RebuildGroup(const AZStd::string& groupNameId) override;
@@ -82,6 +83,13 @@ namespace AtomToolsFramework
private:
QVBoxLayout* m_layout = nullptr;
QScopedPointer m_ui;
- AZStd::unordered_map> m_groups;
+
+ struct GroupWidgetPair
+ {
+ InspectorGroupHeaderWidget* m_header;
+ QWidget* m_panel;
+ };
+
+ AZStd::unordered_map m_groups;
};
} // namespace AtomToolsFramework
diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp
index 94d4d95c24..83aed3c2ae 100644
--- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp
+++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp
@@ -75,7 +75,7 @@ namespace AtomToolsFramework
groupWidget->setParent(m_ui->m_propertyContent);
m_layout->addWidget(groupWidget);
- m_groups[groupNameId] = AZStd::make_pair(groupHeader, groupWidget);
+ m_groups[groupNameId] = {groupHeader, groupWidget};
connect(groupHeader, &InspectorGroupHeaderWidget::clicked, this, [this, groupNameId](QMouseEvent* event) {
OnHeaderClicked(groupNameId, event);
@@ -95,25 +95,31 @@ namespace AtomToolsFramework
void InspectorWidget::SetGroupVisible(const AZStd::string& groupNameId, bool visible)
{
- for (size_t i = 0; i < m_groups.size(); ++i)
+ auto groupItr = m_groups.find(groupNameId);
+ if (groupItr != m_groups.end())
{
- if (m_groups[i]->objectName() == groupNameId.c_str())
- {
- m_headers[i]->setVisible(visible);
- m_groups[i]->setVisible(visible && m_headers[i]->IsExpanded());
- break;
- }
+ groupItr->second.m_header->setVisible(visible);
+ groupItr->second.m_panel->setVisible(visible && groupItr->second.m_header->IsExpanded());
}
}
bool InspectorWidget::IsGroupVisible(const AZStd::string& groupNameId) const
{
- for (auto& header : m_headers)
+ auto groupItr = m_groups.find(groupNameId);
+ if (groupItr != m_groups.end())
{
- if (header->objectName() == groupNameId.c_str())
- {
- return header->isVisible();
- }
+ return groupItr->second.m_header->isVisible();
+ }
+
+ return false;
+ }
+
+ bool InspectorWidget::IsGroupHidden(const AZStd::string& groupNameId) const
+ {
+ auto groupItr = m_groups.find(groupNameId);
+ if (groupItr != m_groups.end())
+ {
+ return groupItr->second.m_header->isHidden();
}
return false;
@@ -156,8 +162,8 @@ namespace AtomToolsFramework
auto groupItr = m_groups.find(groupNameId);
if (groupItr != m_groups.end())
{
- groupItr->second.first->SetExpanded(true);
- groupItr->second.second->setVisible(true);
+ groupItr->second.m_header->SetExpanded(true);
+ groupItr->second.m_panel->setVisible(true);
}
}
@@ -166,23 +172,23 @@ namespace AtomToolsFramework
auto groupItr = m_groups.find(groupNameId);
if (groupItr != m_groups.end())
{
- groupItr->second.first->SetExpanded(false);
- groupItr->second.second->setVisible(false);
+ groupItr->second.m_header->SetExpanded(false);
+ groupItr->second.m_panel->setVisible(false);
}
}
bool InspectorWidget::IsGroupExpanded(const AZStd::string& groupNameId) const
{
auto groupItr = m_groups.find(groupNameId);
- return groupItr != m_groups.end() ? groupItr->second.first->IsExpanded() : false;
+ return groupItr != m_groups.end() ? groupItr->second.m_header->IsExpanded() : false;
}
void InspectorWidget::ExpandAll()
{
for (auto& groupPair : m_groups)
{
- groupPair.second.first->SetExpanded(true);
- groupPair.second.second->setVisible(true);
+ groupPair.second.m_header->SetExpanded(true);
+ groupPair.second.m_panel->setVisible(true);
}
}
@@ -190,8 +196,8 @@ namespace AtomToolsFramework
{
for (auto& groupPair : m_groups)
{
- groupPair.second.first->SetExpanded(false);
- groupPair.second.second->setVisible(false);
+ groupPair.second.m_header->SetExpanded(false);
+ groupPair.second.m_panel->setVisible(false);
}
}
diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp
index 0492c9c150..19dfc6154c 100644
--- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp
+++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp
@@ -198,6 +198,11 @@ namespace MaterialEditor
&group, &group, group.TYPEINFO_Uuid(), this, this, GetGroupSaveStateKey(groupNameId),
[this](const auto source, const auto target) { return CompareInstanceNodeProperties(source, target); });
AddGroup(groupNameId, groupDisplayName, groupDescription, propertyGroupWidget);
+
+ bool isGroupVisible = false;
+ MaterialDocumentRequestBus::EventResult(
+ isGroupVisible, m_documentId, &MaterialDocumentRequestBus::Events::IsPropertyGroupVisible, AZ::Name{groupNameId});
+ SetGroupVisible(groupNameId, isGroupVisible);
}
}
diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp
index 59e29d29f1..31d69569db 100644
--- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp
+++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp
@@ -305,8 +305,11 @@ namespace AZ
{
AZ::RPI::MaterialPropertyGroupDynamicMetadata& metadata = propertyGroupDynamicMetadata[AZ::Name{groupPair.first}];
- metadata.m_visibility = IsGroupVisible(groupPair.first) ?
- AZ::RPI::MaterialPropertyGroupVisibility::Enabled : AZ::RPI::MaterialPropertyGroupVisibility::Hidden;
+ // It's significant that we check IsGroupHidden rather than IsGroupVisisble, because it follows the same rules as QWidget::isHidden().
+ // We don't care whether the widget and all its parents are visible, we only care about whether the group was hidden within the context
+ // of the material property inspector.
+ metadata.m_visibility = IsGroupHidden(groupPair.first) ?
+ AZ::RPI::MaterialPropertyGroupVisibility::Hidden : AZ::RPI::MaterialPropertyGroupVisibility::Enabled;
}
for (AZ::RPI::Ptr& functor : m_editorFunctors)
From 36a79aca8a353316f560f3079ff2b66cb5120996 Mon Sep 17 00:00:00 2001
From: sphrose <82213493+sphrose@users.noreply.github.com>
Date: Thu, 13 May 2021 10:56:39 +0100
Subject: [PATCH 028/163] Remove redundant function.
---
.../UI/PropertyEditor/PropertyRowWidget.cpp | 7 +------
.../UI/PropertyEditor/PropertyRowWidget.hxx | 1 -
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
index 85784d61e0..890253b528 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.cpp
@@ -126,7 +126,7 @@ namespace AzToolsFramework
{
QStylePainter p(this);
- if (IsReorderableRow())
+ if (CanBeReordered())
{
const QPen linePen(QColor(0x3B3E3F));
p.setPen(linePen);
@@ -1332,11 +1332,6 @@ namespace AzToolsFramework
return canBeTopLevel(this);
}
- bool PropertyRowWidget::IsReorderableRow() const
- {
- return CanBeReordered();
- }
-
bool PropertyRowWidget::GetAppendDefaultLabelToName()
{
return false;
diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
index 1c17cab69f..79121403c9 100644
--- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
+++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyRowWidget.hxx
@@ -83,7 +83,6 @@ namespace AzToolsFramework
PropertyRowWidget* GetParentRow() const { return m_parentRow; }
int GetLevel() const;
bool IsTopLevel() const;
- bool IsReorderableRow() const;
// Remove the default label and append the text to the name label.
bool GetAppendDefaultLabelToName();
From f478340376267f1623f7138fe2b06024d050687c Mon Sep 17 00:00:00 2001
From: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
Date: Wed, 12 May 2021 16:04:25 -0500
Subject: [PATCH 029/163] Data driven asset importer. Need to fix reflection
---
AssetImporterSettings.json | 7 +++
.../FbxImportRequestHandler.cpp | 60 +++++++++++++++++--
.../FbxSceneBuilder/FbxImportRequestHandler.h | 16 ++++-
3 files changed, 78 insertions(+), 5 deletions(-)
create mode 100644 AssetImporterSettings.json
diff --git a/AssetImporterSettings.json b/AssetImporterSettings.json
new file mode 100644
index 0000000000..134484cf8d
--- /dev/null
+++ b/AssetImporterSettings.json
@@ -0,0 +1,7 @@
+{
+ "SupportedFileTypeExtensions" : [
+ ".fbx",
+ ".stl",
+ ".stp"
+ ]
+}
\ No newline at end of file
diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.cpp
index 155209f1b5..2210abfaf7 100644
--- a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.cpp
+++ b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.cpp
@@ -10,7 +10,14 @@
*
*/
+#include
+#include
+#include
+#include
#include
+#include
+#include
+#include
#include
#include
#include
@@ -23,10 +30,47 @@ namespace AZ
{
namespace FbxSceneImporter
{
- const char* FbxImportRequestHandler::s_extension = ".fbx";
+ AssetImporterSettings::AssetImporterSettings()
+ {
+ // Default supported extension in case the settings file isn't found
+ m_supportedFileTypeExtensions.emplace(".fbx");
+ }
+
+ void AssetImporterSettings::Reflect(AZ::ReflectContext* context)
+ {
+ if (auto serializeContext = azrtti_cast(context); serializeContext)
+ {
+ serializeContext->Class()
+ ->Version(1)
+ ->Field("SupportedFileTypeExtensions", &AssetImporterSettings::m_supportedFileTypeExtensions);
+ }
+ }
void FbxImportRequestHandler::Activate()
{
+ // Attempt to load the Slice Builder Settings file
+ AZ::IO::LocalFileIO localFileIO;
+
+ // This will point to @assets@/SettingsFilename, which loads from the cache
+ // We don't really want this but it works for now
+ // Trying to use AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath at this point
+ // would fail because components seem to activate before the AP has populated its file list
+ AZ::IO::Path sliceBuilderSettingsIoPath(SettingsFilename);
+ auto result = AzFramework::FileFunc::ReadJsonFile(sliceBuilderSettingsIoPath, &localFileIO);
+ if (result.IsSuccess())
+ {
+ AZ::JsonSerializationResult::ResultCode serializationResult =
+ AZ::JsonSerialization::Load(m_settings, result.GetValue());
+ if (serializationResult.GetProcessing() == AZ::JsonSerializationResult::Processing::Halted)
+ {
+ AZ_Warning("", false, "Error in Asset Importer Settings file.\nUsing default settings.");
+ }
+ }
+ else
+ {
+ AZ_Warning("", false, "Failed to load Asset Importer Settings file.\nUsing default settings.");
+ }
+
BusConnect();
}
@@ -37,21 +81,29 @@ namespace AZ
void FbxImportRequestHandler::Reflect(ReflectContext* context)
{
+ AssetImporterSettings::Reflect(context);
+
SerializeContext* serializeContext = azrtti_cast(context);
if (serializeContext)
{
- serializeContext->Class()->Version(1);
+ serializeContext->Class()->Version(1)->Attribute(
+ AZ::Edit::Attributes::SystemComponentTags,
+ AZStd::vector({AssetBuilderSDK::ComponentTags::AssetBuilder}));
+
}
}
void FbxImportRequestHandler::GetSupportedFileExtensions(AZStd::unordered_set& extensions)
{
- extensions.insert(s_extension);
+ extensions.insert(m_settings.m_supportedFileTypeExtensions.begin(), m_settings.m_supportedFileTypeExtensions.end());
}
Events::LoadingResult FbxImportRequestHandler::LoadAsset(Containers::Scene& scene, const AZStd::string& path, const Uuid& guid, [[maybe_unused]] RequestingApplication requester)
{
- if (!AzFramework::StringFunc::Path::IsExtension(path.c_str(), s_extension))
+ AZStd::string extension;
+ AzFramework::StringFunc::Path::GetExtension(path.c_str(), extension);
+
+ if (!m_settings.m_supportedFileTypeExtensions.contains(extension))
{
return Events::LoadingResult::Ignored;
}
diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.h b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.h
index 8b33051f1e..3ef2823e24 100644
--- a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.h
+++ b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.h
@@ -21,6 +21,17 @@ namespace AZ
{
namespace FbxSceneImporter
{
+ struct AssetImporterSettings
+ {
+ AZ_TYPE_INFO(AssetImporterSettings, "{8BB6C7AD-BF99-44DC-9DA1-E7AD3F03DC10}");
+
+ AssetImporterSettings();
+
+ static void Reflect(AZ::ReflectContext* context);
+
+ AZStd::unordered_set m_supportedFileTypeExtensions;
+ };
+
class FbxImportRequestHandler
: public SceneCore::BehaviorComponent
, public Events::AssetImportRequestBus::Handler
@@ -39,7 +50,10 @@ namespace AZ
RequestingApplication requester) override;
private:
- static const char* s_extension;
+
+ AssetImporterSettings m_settings;
+
+ static constexpr const char* SettingsFilename = "AssetImporterSettings.json";
};
} // namespace FbxSceneImporter
} // namespace SceneAPI
From 2b538c9921ce2be2ee4fc9c9877c1dd0272c8f58 Mon Sep 17 00:00:00 2001
From: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
Date: Thu, 13 May 2021 09:47:21 -0500
Subject: [PATCH 030/163] Switch to using settings registry
# Conflicts:
# Assets/Engine/Registry/assetimporter.setreg
---
AssetImporterSettings.json | 7 ----
.../SceneAPI/FbxSceneBuilder/DllMain.cpp | 6 +---
.../FbxImportRequestHandler.cpp | 35 +++++--------------
.../FbxSceneBuilder/FbxImportRequestHandler.h | 6 ++--
.../SceneBuilder/SceneBuilderComponent.cpp | 6 +++-
.../SceneBuilder/SceneBuilderComponent.h | 2 ++
Registry/assetimporter.setreg | 17 +++++++++
7 files changed, 37 insertions(+), 42 deletions(-)
delete mode 100644 AssetImporterSettings.json
create mode 100644 Registry/assetimporter.setreg
diff --git a/AssetImporterSettings.json b/AssetImporterSettings.json
deleted file mode 100644
index 134484cf8d..0000000000
--- a/AssetImporterSettings.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "SupportedFileTypeExtensions" : [
- ".fbx",
- ".stl",
- ".stp"
- ]
-}
\ No newline at end of file
diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/DllMain.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/DllMain.cpp
index 3dc14814de..d3d7b38663 100644
--- a/Code/Tools/SceneAPI/FbxSceneBuilder/DllMain.cpp
+++ b/Code/Tools/SceneAPI/FbxSceneBuilder/DllMain.cpp
@@ -46,11 +46,6 @@ namespace AZ
// Currently it's still needed to explicitly create an instance of this instead of letting
// it be a normal component. This is because ResourceCompilerScene needs to return
// the list of available extensions before it can start the application.
- if (!g_fbxImporter)
- {
- g_fbxImporter = aznew AZ::SceneAPI::FbxSceneImporter::FbxImportRequestHandler();
- g_fbxImporter->Activate();
- }
}
void Reflect(AZ::SerializeContext* /*context*/)
@@ -64,6 +59,7 @@ namespace AZ
{
// Global importer and behavior
g_componentDescriptors.push_back(FbxSceneBuilder::FbxImporter::CreateDescriptor());
+ g_componentDescriptors.push_back(FbxSceneImporter::FbxImportRequestHandler::CreateDescriptor());
// Node and attribute importers
g_componentDescriptors.push_back(AssImpBitangentStreamImporter::CreateDescriptor());
diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.cpp
index 2210abfaf7..d3962cce60 100644
--- a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.cpp
+++ b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.cpp
@@ -30,12 +30,6 @@ namespace AZ
{
namespace FbxSceneImporter
{
- AssetImporterSettings::AssetImporterSettings()
- {
- // Default supported extension in case the settings file isn't found
- m_supportedFileTypeExtensions.emplace(".fbx");
- }
-
void AssetImporterSettings::Reflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast(context); serializeContext)
@@ -48,27 +42,11 @@ namespace AZ
void FbxImportRequestHandler::Activate()
{
- // Attempt to load the Slice Builder Settings file
- AZ::IO::LocalFileIO localFileIO;
-
- // This will point to @assets@/SettingsFilename, which loads from the cache
- // We don't really want this but it works for now
- // Trying to use AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath at this point
- // would fail because components seem to activate before the AP has populated its file list
- AZ::IO::Path sliceBuilderSettingsIoPath(SettingsFilename);
- auto result = AzFramework::FileFunc::ReadJsonFile(sliceBuilderSettingsIoPath, &localFileIO);
- if (result.IsSuccess())
+ auto settingsRegistry = AZ::SettingsRegistry::Get();
+
+ if (settingsRegistry)
{
- AZ::JsonSerializationResult::ResultCode serializationResult =
- AZ::JsonSerialization::Load(m_settings, result.GetValue());
- if (serializationResult.GetProcessing() == AZ::JsonSerializationResult::Processing::Halted)
- {
- AZ_Warning("", false, "Error in Asset Importer Settings file.\nUsing default settings.");
- }
- }
- else
- {
- AZ_Warning("", false, "Failed to load Asset Importer Settings file.\nUsing default settings.");
+ settingsRegistry->GetObject(m_settings, "/O3DE/SceneAPI/AssetImporter");
}
BusConnect();
@@ -125,6 +103,11 @@ namespace AZ
return Events::LoadingResult::AssetFailure;
}
}
+
+ void FbxImportRequestHandler::GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided)
+ {
+ provided.emplace_back(AZ_CRC_CE("AssetImportRequestHandler"));
+ }
} // namespace Import
} // namespace SceneAPI
} // namespace AZ
diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.h b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.h
index 3ef2823e24..99d2061229 100644
--- a/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.h
+++ b/Code/Tools/SceneAPI/FbxSceneBuilder/FbxImportRequestHandler.h
@@ -24,9 +24,7 @@ namespace AZ
struct AssetImporterSettings
{
AZ_TYPE_INFO(AssetImporterSettings, "{8BB6C7AD-BF99-44DC-9DA1-E7AD3F03DC10}");
-
- AssetImporterSettings();
-
+
static void Reflect(AZ::ReflectContext* context);
AZStd::unordered_set m_supportedFileTypeExtensions;
@@ -49,6 +47,8 @@ namespace AZ
Events::LoadingResult LoadAsset(Containers::Scene& scene, const AZStd::string& path, const Uuid& guid,
RequestingApplication requester) override;
+ static void GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided);
+
private:
AssetImporterSettings m_settings;
diff --git a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.cpp b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.cpp
index e71a5207d0..25faca3667 100644
--- a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.cpp
+++ b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.cpp
@@ -72,6 +72,11 @@ namespace SceneBuilder
m_sceneBuilder.BusDisconnect();
}
+ void BuilderPluginComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
+ {
+ required.emplace_back(AZ_CRC_CE("AssetImportRequestHandler"));
+ }
+
void BuilderPluginComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast(context);
@@ -81,5 +86,4 @@ namespace SceneBuilder
->Attribute(AZ::Edit::Attributes::SystemComponentTags, AZStd::vector({ AssetBuilderSDK::ComponentTags::AssetBuilder }));
}
}
-
} // namespace SceneBuilder
diff --git a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.h b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.h
index c1fc6ebb36..aed5e1b026 100644
--- a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.h
+++ b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderComponent.h
@@ -32,6 +32,8 @@ namespace SceneBuilder
void Activate() override;
void Deactivate() override;
+ static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
+
private:
SceneBuilderWorker m_sceneBuilder;
};
diff --git a/Registry/assetimporter.setreg b/Registry/assetimporter.setreg
new file mode 100644
index 0000000000..e0b0f00f6c
--- /dev/null
+++ b/Registry/assetimporter.setreg
@@ -0,0 +1,17 @@
+{
+ "O3DE":
+ {
+ "SceneAPI":
+ {
+ "AssetImporter":
+ {
+ "SupportedFileTypeExtensions":
+ [
+ ".fbx",
+ ".stl",
+ ".stp"
+ ]
+ }
+ }
+ }
+}
\ No newline at end of file
From 70c8ef99ef4a9b3bc2d7c69a1262304522085177 Mon Sep 17 00:00:00 2001
From: Chris Santora
Date: Thu, 13 May 2021 09:39:01 -0700
Subject: [PATCH 031/163] Updates in response to code review, from gadams3.
Cleaned up code around MaterialFunctor's QueryMaterialPropertyMetadata and
QueryMaterialPropertyGroupMetadata. Removed unnecessary
"groupHeader->setObjectName(...)" Simplified code in
MaterialInspector::OnDocumentPropertyGroupVisibilityChanged.
---
.../RPI.Reflect/Material/MaterialFunctor.h | 4 +-
.../RPI.Reflect/Material/MaterialFunctor.cpp | 83 +++++++++----------
.../Code/Source/Inspector/InspectorWidget.cpp | 1 -
.../MaterialInspector/MaterialInspector.cpp | 7 +-
4 files changed, 42 insertions(+), 53 deletions(-)
diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialFunctor.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialFunctor.h
index 6b9b34aa1b..83472ade77 100644
--- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialFunctor.h
+++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Material/MaterialFunctor.h
@@ -198,8 +198,8 @@ namespace AZ
);
private:
- AZStd::list_iterator> QueryMaterialPropertyMetadata(const Name& propertyName) const;
- AZStd::list_iterator> QueryMaterialPropertyGroupMetadata(const Name& propertyGroupName) const;
+ MaterialPropertyDynamicMetadata* QueryMaterialPropertyMetadata(const Name& propertyName) const;
+ MaterialPropertyGroupDynamicMetadata* QueryMaterialPropertyGroupMetadata(const Name& propertyGroupName) const;
const AZStd::vector& m_materialPropertyValues;
RHI::ConstPtr m_materialPropertiesLayout;
diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp
index ab18a1fb66..17e55309fb 100644
--- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp
+++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp
@@ -159,12 +159,7 @@ namespace AZ
const MaterialPropertyDynamicMetadata* MaterialFunctor::EditorContext::GetMaterialPropertyMetadata(const Name& propertyName) const
{
- auto it = QueryMaterialPropertyMetadata(propertyName);
- if (it == m_propertyMetadata.end())
- {
- return nullptr;
- }
- return &(it->second);
+ return QueryMaterialPropertyMetadata(propertyName);
}
const MaterialPropertyDynamicMetadata* MaterialFunctor::EditorContext::GetMaterialPropertyMetadata(const MaterialPropertyIndex& index) const
@@ -175,23 +170,20 @@ namespace AZ
const MaterialPropertyGroupDynamicMetadata* MaterialFunctor::EditorContext::GetMaterialPropertyGroupMetadata(const Name& propertyName) const
{
- auto it = QueryMaterialPropertyGroupMetadata(propertyName);
- if (it == m_propertyGroupMetadata.end())
- {
- return nullptr;
- }
- return &(it->second);
+ return QueryMaterialPropertyGroupMetadata(propertyName);
}
bool MaterialFunctor::EditorContext::SetMaterialPropertyGroupVisibility(const Name& propertyGroupName, MaterialPropertyGroupVisibility visibility)
{
- auto it = QueryMaterialPropertyGroupMetadata(propertyGroupName);
- if (it == m_propertyGroupMetadata.end())
+ MaterialPropertyGroupDynamicMetadata* metadata = QueryMaterialPropertyGroupMetadata(propertyGroupName);
+ if (!metadata)
{
return false;
}
- MaterialPropertyGroupVisibility originValue = it->second.m_visibility;
- it->second.m_visibility = visibility;
+
+ MaterialPropertyGroupVisibility originValue = metadata->m_visibility;
+ metadata->m_visibility = visibility;
+
if (originValue != visibility)
{
m_updatedPropertyGroupsOut.insert(propertyGroupName);
@@ -202,13 +194,15 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertyVisibility(const Name& propertyName, MaterialPropertyVisibility visibility)
{
- auto it = QueryMaterialPropertyMetadata(propertyName);
- if (it == m_propertyMetadata.end())
+ MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyName);
+ if (!metadata)
{
return false;
}
- MaterialPropertyVisibility originValue = it->second.m_visibility;
- it->second.m_visibility = visibility;
+
+ MaterialPropertyVisibility originValue = metadata->m_visibility;
+ metadata->m_visibility = visibility;
+
if (originValue != visibility)
{
m_updatedPropertiesOut.insert(propertyName);
@@ -225,14 +219,15 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertyDescription(const Name& propertyName, AZStd::string description)
{
- auto it = QueryMaterialPropertyMetadata(propertyName);
- if (it == m_propertyMetadata.end())
+ MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyName);
+ if (!metadata)
{
return false;
}
- AZStd::string origin = it->second.m_description;
- it->second.m_description = description;
+ AZStd::string origin = metadata->m_description;
+ metadata->m_description = description;
+
if (origin != description)
{
m_updatedPropertiesOut.insert(propertyName);
@@ -249,14 +244,14 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertyMinValue(const Name& propertyName, const MaterialPropertyValue& min)
{
- auto it = QueryMaterialPropertyMetadata(propertyName);
- if (it == m_propertyMetadata.end())
+ MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyName);
+ if (!metadata)
{
return false;
}
- MaterialPropertyValue origin = it->second.m_propertyRange.m_min;
- it->second.m_propertyRange.m_min = min;
+ MaterialPropertyValue origin = metadata->m_propertyRange.m_min;
+ metadata->m_propertyRange.m_min = min;
if(origin != min)
{
@@ -274,14 +269,14 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertyMaxValue(const Name& propertyName, const MaterialPropertyValue& max)
{
- auto it = QueryMaterialPropertyMetadata(propertyName);
- if (it == m_propertyMetadata.end())
+ MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyName);
+ if (!metadata)
{
return false;
}
- MaterialPropertyValue origin = it->second.m_propertyRange.m_max;
- it->second.m_propertyRange.m_max = max;
+ MaterialPropertyValue origin = metadata->m_propertyRange.m_max;
+ metadata->m_propertyRange.m_max = max;
if (origin != max)
{
@@ -299,14 +294,14 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertySoftMinValue(const Name& propertyName, const MaterialPropertyValue& min)
{
- auto it = QueryMaterialPropertyMetadata(propertyName);
- if (it == m_propertyMetadata.end())
+ MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyName);
+ if (!metadata)
{
return false;
}
- MaterialPropertyValue origin = it->second.m_propertyRange.m_softMin;
- it->second.m_propertyRange.m_softMin = min;
+ MaterialPropertyValue origin = metadata->m_propertyRange.m_softMin;
+ metadata->m_propertyRange.m_softMin = min;
if (origin != min)
{
@@ -324,14 +319,14 @@ namespace AZ
bool MaterialFunctor::EditorContext::SetMaterialPropertySoftMaxValue(const Name& propertyName, const MaterialPropertyValue& max)
{
- auto it = QueryMaterialPropertyMetadata(propertyName);
- if (it == m_propertyMetadata.end())
+ MaterialPropertyDynamicMetadata* metadata = QueryMaterialPropertyMetadata(propertyName);
+ if (!metadata)
{
return false;
}
- MaterialPropertyValue origin = it->second.m_propertyRange.m_softMax;
- it->second.m_propertyRange.m_softMax = max;
+ MaterialPropertyValue origin = metadata->m_propertyRange.m_softMax;
+ metadata->m_propertyRange.m_softMax = max;
if (origin != max)
{
@@ -347,7 +342,7 @@ namespace AZ
return SetMaterialPropertySoftMaxValue(name, max);
}
- AZStd::list_iterator> MaterialFunctor::EditorContext::QueryMaterialPropertyMetadata(const Name& propertyName) const
+ MaterialPropertyDynamicMetadata* MaterialFunctor::EditorContext::QueryMaterialPropertyMetadata(const Name& propertyName) const
{
auto it = m_propertyMetadata.find(propertyName);
if (it == m_propertyMetadata.end())
@@ -355,10 +350,10 @@ namespace AZ
AZ_Error("MaterialFunctor", false, "Couldn't find metadata for material property: %s.", propertyName.GetCStr());
}
- return it;
+ return &it->second;
}
- AZStd::list_iterator> MaterialFunctor::EditorContext::QueryMaterialPropertyGroupMetadata(const Name& propertyGroupName) const
+ MaterialPropertyGroupDynamicMetadata* MaterialFunctor::EditorContext::QueryMaterialPropertyGroupMetadata(const Name& propertyGroupName) const
{
auto it = m_propertyGroupMetadata.find(propertyGroupName);
if (it == m_propertyGroupMetadata.end())
@@ -366,7 +361,7 @@ namespace AZ
AZ_Error("MaterialFunctor", false, "Couldn't find metadata for material property group: %s.", propertyGroupName.GetCStr());
}
- return it;
+ return &it->second;
}
template
diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp
index 83aed3c2ae..097a819e49 100644
--- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp
+++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorWidget.cpp
@@ -68,7 +68,6 @@ namespace AtomToolsFramework
InspectorGroupHeaderWidget* groupHeader = new InspectorGroupHeaderWidget(m_ui->m_propertyContent);
groupHeader->setText(groupDisplayName.c_str());
groupHeader->setToolTip(groupDescription.c_str());
- groupHeader->setObjectName(groupNameId.c_str());
m_layout->addWidget(groupHeader);
groupWidget->setObjectName(groupNameId.c_str());
diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp
index 19dfc6154c..706d365027 100644
--- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp
+++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialInspector/MaterialInspector.cpp
@@ -253,12 +253,7 @@ namespace MaterialEditor
void MaterialInspector::OnDocumentPropertyGroupVisibilityChanged(const AZ::Uuid&, const AZ::Name& groupId, bool visible)
{
- auto groupIter = m_groups.find(groupId.GetStringView());
-
- if(groupIter != m_groups.end())
- {
- SetGroupVisible(groupIter->first, visible);
- }
+ SetGroupVisible(groupId.GetStringView(), visible);
}
void MaterialInspector::BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode)
From 1684c338b23b8ae7f9aff43748533b79de2b7541 Mon Sep 17 00:00:00 2001
From: Chris Santora
Date: Thu, 13 May 2021 15:16:37 -0700
Subject: [PATCH 032/163] More minor cleanup in MaterialFunctor.cpp
---
.../RPI.Reflect/Material/MaterialFunctor.cpp | 42 +++++++------------
1 file changed, 14 insertions(+), 28 deletions(-)
diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp
index 17e55309fb..a41ab9eea6 100644
--- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp
+++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialFunctor.cpp
@@ -181,11 +181,9 @@ namespace AZ
return false;
}
- MaterialPropertyGroupVisibility originValue = metadata->m_visibility;
- metadata->m_visibility = visibility;
-
- if (originValue != visibility)
+ if (metadata->m_visibility != visibility)
{
+ metadata->m_visibility = visibility;
m_updatedPropertyGroupsOut.insert(propertyGroupName);
}
@@ -200,11 +198,9 @@ namespace AZ
return false;
}
- MaterialPropertyVisibility originValue = metadata->m_visibility;
- metadata->m_visibility = visibility;
-
- if (originValue != visibility)
+ if (metadata->m_visibility != visibility)
{
+ metadata->m_visibility = visibility;
m_updatedPropertiesOut.insert(propertyName);
}
@@ -225,11 +221,9 @@ namespace AZ
return false;
}
- AZStd::string origin = metadata->m_description;
- metadata->m_description = description;
-
- if (origin != description)
+ if (metadata->m_description != description)
{
+ metadata->m_description = description;
m_updatedPropertiesOut.insert(propertyName);
}
@@ -250,11 +244,9 @@ namespace AZ
return false;
}
- MaterialPropertyValue origin = metadata->m_propertyRange.m_min;
- metadata->m_propertyRange.m_min = min;
-
- if(origin != min)
+ if(metadata->m_propertyRange.m_min != min)
{
+ metadata->m_propertyRange.m_min = min;
m_updatedPropertiesOut.insert(propertyName);
}
@@ -275,11 +267,9 @@ namespace AZ
return false;
}
- MaterialPropertyValue origin = metadata->m_propertyRange.m_max;
- metadata->m_propertyRange.m_max = max;
-
- if (origin != max)
+ if (metadata->m_propertyRange.m_max != max)
{
+ metadata->m_propertyRange.m_max = max;
m_updatedPropertiesOut.insert(propertyName);
}
@@ -300,11 +290,9 @@ namespace AZ
return false;
}
- MaterialPropertyValue origin = metadata->m_propertyRange.m_softMin;
- metadata->m_propertyRange.m_softMin = min;
-
- if (origin != min)
+ if (metadata->m_propertyRange.m_softMin != min)
{
+ metadata->m_propertyRange.m_softMin = min;
m_updatedPropertiesOut.insert(propertyName);
}
@@ -325,11 +313,9 @@ namespace AZ
return false;
}
- MaterialPropertyValue origin = metadata->m_propertyRange.m_softMax;
- metadata->m_propertyRange.m_softMax = max;
-
- if (origin != max)
+ if (metadata->m_propertyRange.m_softMax != max)
{
+ metadata->m_propertyRange.m_softMax = max;
m_updatedPropertiesOut.insert(propertyName);
}
From 8a39f9f1b474640b4b525423b0ec3fa9c32c187e Mon Sep 17 00:00:00 2001
From: puvvadar
Date: Thu, 13 May 2021 15:31:37 -0700
Subject: [PATCH 033/163] Streamline MP Ctrl+G logic via
MultiplayerEditorConnection
---
.../AzNetworking/TcpTransport/TcpSocket.cpp | 2 +-
.../UdpTransport/UdpNetworkInterface.cpp | 2 +-
.../AzNetworking/UdpTransport/UdpSocket.cpp | 2 +-
Gems/Multiplayer/Code/CMakeLists.txt | 25 +--
.../AutoGen/Multiplayer.AutoPackets.xml | 7 +-
.../AutoGen/MultiplayerEditor.AutoPackets.xml | 14 ++
.../Editor/MultiplayerEditorConnection.cpp | 162 ++++++++++++++
.../Editor/MultiplayerEditorConnection.h | 55 +++++
.../Editor/MultiplayerEditorDispatcher.cpp | 21 --
.../Editor/MultiplayerEditorDispatcher.h | 36 ----
.../{ => Editor}/MultiplayerEditorGem.cpp | 2 +-
.../{ => Editor}/MultiplayerEditorGem.h | 0
.../MultiplayerEditorSystemComponent.cpp | 199 ++++++++----------
.../Editor/MultiplayerEditorSystemComponent.h | 13 +-
.../Source/MultiplayerSystemComponent.cpp | 42 ++--
.../Code/Source/MultiplayerSystemComponent.h | 8 +-
.../Pipeline/NetworkPrefabProcessor.cpp | 4 +
.../Code/multiplayer_editor_files.cmake | 2 -
.../multiplayer_editor_shared_files.cmake | 4 +-
Gems/Multiplayer/Code/multiplayer_files.cmake | 3 +
20 files changed, 359 insertions(+), 244 deletions(-)
create mode 100644 Gems/Multiplayer/Code/Source/AutoGen/MultiplayerEditor.AutoPackets.xml
create mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.cpp
create mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorConnection.h
delete mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.cpp
delete mode 100644 Gems/Multiplayer/Code/Source/Editor/MultiplayerEditorDispatcher.h
rename Gems/Multiplayer/Code/Source/{ => Editor}/MultiplayerEditorGem.cpp (97%)
rename Gems/Multiplayer/Code/Source/{ => Editor}/MultiplayerEditorGem.h (100%)
diff --git a/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpSocket.cpp b/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpSocket.cpp
index e8c30d0816..70000dc9a8 100644
--- a/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpSocket.cpp
+++ b/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpSocket.cpp
@@ -176,7 +176,7 @@ namespace AzNetworking
if (::bind(aznumeric_cast