Do not run SSAO pass when disabled (#3826)

* Define fallback slots when shader is disabled

* Disable SSAO parent pass depending on the settings

* Move SSAO modulation pass into SsaoParent pass so it can be disabled with the rest of SSAO

* Enable SSAO by default

Co-authored-by: Tobias Alexander Franke <tobias.alexander.franke@huawei.com>
This commit is contained in:
Tobias Alexander Franke
2021-10-11 18:48:28 +02:00
committed by GitHub
parent 189aa5f3ac
commit 091b729183
4 changed files with 72 additions and 29 deletions
@@ -472,36 +472,15 @@
"Pass": "Parent",
"Attachment": "DepthLinear"
}
}
]
},
{
"Name": "ModulateWithSsao",
"TemplateName": "ModulateTextureTemplate",
"Enabled": true,
"Connections": [
{
"LocalSlot": "Input",
"AttachmentRef": {
"Pass": "Ssao",
"Attachment": "Output"
}
},
{
"LocalSlot": "InputOutput",
"LocalSlot": "Modulate",
"AttachmentRef": {
"Pass": "SubsurfaceScatteringPass",
"Attachment": "Output"
}
}
],
"PassData": {
"$type": "ComputePassData",
"ShaderAsset": {
"FilePath": "Shaders/PostProcessing/ModulateTexture.shader"
},
"Make Fullscreen Pass": true
}
]
},
{
"Name": "DiffuseSpecularMergePass",
@@ -510,8 +489,8 @@
{
"LocalSlot": "InputDiffuse",
"AttachmentRef": {
"Pass": "ModulateWithSsao",
"Attachment": "InputOutput"
"Pass": "Ssao",
"Attachment": "Output"
}
},
{
@@ -51,7 +51,13 @@
},
"Make Fullscreen Pass": true,
"PipelineViewTag": "MainCamera"
}
},
"FallbackConnections": [
{
"Input": "LinearDepth",
"Output": "Output"
}
]
}
}
}
@@ -12,6 +12,11 @@
"SlotType": "Input",
"ScopeAttachmentUsage": "Shader"
},
{
"Name": "Modulate",
"SlotType": "Input",
"ScopeAttachmentUsage": "Shader"
},
{
"Name": "Output",
"SlotType": "Output",
@@ -22,8 +27,8 @@
{
"LocalSlot": "Output",
"AttachmentRef": {
"Pass": "Upsample",
"Attachment": "Output"
"Pass": "ModulateWithSsao",
"Attachment": "InputOutput"
}
}
],
@@ -103,6 +108,34 @@
}
}
]
},
{
"Name": "ModulateWithSsao",
"TemplateName": "ModulateTextureTemplate",
"Enabled": true,
"Connections": [
{
"LocalSlot": "Input",
"AttachmentRef": {
"Pass": "Upsample",
"Attachment": "Output"
}
},
{
"LocalSlot": "InputOutput",
"AttachmentRef": {
"Pass": "Parent",
"Attachment": "Modulate"
}
}
],
"PassData": {
"$type": "ComputePassData",
"ShaderAsset": {
"FilePath": "Shaders/PostProcessing/ModulateTexture.shader"
},
"Make Fullscreen Pass": true
}
}
]
}
@@ -34,7 +34,32 @@ namespace AZ
bool SsaoParentPass::IsEnabled() const
{
return ParentPass::IsEnabled();
if (!ParentPass::IsEnabled())
{
return false;
}
const RPI::Scene* scene = GetScene();
if (!scene)
{
return false;
}
PostProcessFeatureProcessor* fp = scene->GetFeatureProcessor<PostProcessFeatureProcessor>();
const RPI::ViewPtr view = GetRenderPipeline()->GetDefaultView();
if (!fp)
{
return true;
}
PostProcessSettings* postProcessSettings = fp->GetLevelSettingsFromView(view);
if (!postProcessSettings)
{
return true;
}
const SsaoSettings* ssaoSettings = postProcessSettings->GetSsaoSettings();
if (!ssaoSettings)
{
return true;
}
return ssaoSettings->GetEnabled();
}
void SsaoParentPass::InitializeInternal()