Bladeren bron

Create a new Mobile render pipeline.
The mobile render pipeline has some customized passes which are added to Passes/Mobile folder.
It also has its own material pipeline which is defined in Materials/Pipeline/Mobile folder.
The mobile render pipeline has added cascade shadow for directional light and projected shadow for spot area light. The ESM filter is removed for both type of the shadows.
The FullScreenShadow pass is removed for cascade shadow for improve performance.

Signed-off-by: VickyAtAZ <[email protected]>

VickyAtAZ 1 jaar geleden
bovenliggende
commit
3d2f5c6e2a
23 gewijzigde bestanden met toevoegingen van 1213 en 16 verwijderingen
  1. 2 1
      AutomatedTesting/Registry/material_pipelines.setreg
  2. 49 0
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/ForwardPass_BaseLighting.azsli
  3. 50 0
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/ForwardPass_BaseLighting.shader.template
  4. 54 0
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/ForwardPass_StandardLighting.azsli
  5. 50 0
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/ForwardPass_StandardLighting.shader.template
  6. 65 0
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/MobileForwardPassVertexAndPixel.azsli
  7. 83 0
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/MobilePipeline.materialpipeline
  8. 51 0
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/MobilePipelineScript.lua
  9. 59 0
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/TintedTransparent_StandardLighting.shader.template
  10. 50 0
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/Transparent_StandardLighting.azsli
  11. 59 0
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/Transparent_StandardLighting.shader.template
  12. 129 0
      Gems/Atom/Feature/Common/Assets/Passes/Mobile/Forward.pass
  13. 17 0
      Gems/Atom/Feature/Common/Assets/Passes/Mobile/MobileRenderPipeline.azasset
  14. 213 0
      Gems/Atom/Feature/Common/Assets/Passes/Mobile/Pipeline.pass
  15. 86 0
      Gems/Atom/Feature/Common/Assets/Passes/Mobile/ShadowParent.pass
  16. 30 0
      Gems/Atom/Feature/Common/Assets/Passes/Mobile/SkyBox.pass
  17. 49 0
      Gems/Atom/Feature/Common/Assets/Passes/Mobile/Transparent.pass
  18. 55 0
      Gems/Atom/Feature/Common/Assets/Passes/Mobile/TransparentParent.pass
  19. 24 0
      Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset
  20. 10 2
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli
  21. 6 0
      Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
  22. 17 5
      Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp
  23. 5 8
      Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp

+ 2 - 1
AutomatedTesting/Registry/material_pipelines.setreg

@@ -5,7 +5,8 @@
                 "MaterialPipelineFiles": [
                     "@gemroot:Atom_Feature_Common@/Assets/Materials/Pipelines/MainPipeline/MainPipeline.materialpipeline",
                     "@gemroot:Atom_Feature_Common@/Assets/Materials/Pipelines/LowEndPipeline/LowEndPipeline.materialpipeline",
-                    "@gemroot:Atom_Feature_Common@/Assets/Materials/Pipelines/MultiView/MultiViewPipeline.materialpipeline"
+                    "@gemroot:Atom_Feature_Common@/Assets/Materials/Pipelines/MultiView/MultiViewPipeline.materialpipeline",
+                    "@gemroot:Atom_Feature_Common@/Assets/Materials/Pipelines/Mobile/MobilePipeline.materialpipeline"
                 ]
             }
         }

+ 49 - 0
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/ForwardPass_BaseLighting.azsli

@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+ 
+#define MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE 1
+
+// TODO(MaterialPipeline): In the end, after all refactoring and rearranging of our shader code is done, some of these flags might become unnecessary and should be re-evaluated.
+// Some of these setting used to be in ShaderQualityOptions.azsli as a basic/limited solution for multiple pipelines.
+// TODO(MaterialPipeline), instead of UNIFIED_FORWARD_OUTPUT, fork ForwardPassOutput.azsli
+#define UNIFIED_FORWARD_OUTPUT          1
+#define FORCE_IBL_IN_FORWARD_PASS       1
+#define FORCE_EARLY_DEPTH_STENCIL 1
+#define OUTPUT_DEPTH 0
+#define FORCE_OPAQUE 1
+#define OUTPUT_SUBSURFACE 0
+#define ENABLE_TRANSMISSION 0
+#define ENABLE_SHADER_DEBUGGING 0
+#define ENABLE_CLEAR_COAT 0
+#define ENABLE_SHADOWS 1
+#define ENABLE_FULLSCREEN_SHADOW 0
+#define ENABLE_LIGHT_CULLING 0
+#define ENABLE_DISK_LIGHTS 1
+#define ENABLE_AREA_LIGHTS 0
+#define ENABLE_AREA_LIGHT_VALIDATION    0
+#define ENABLE_PHYSICAL_SKY 0
+#define ENABLE_MERGE_FILMIC_TONEMAP 1
+#define ENABLE_DECALS              0
+#define ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION 0
+#define ENABLE_REFLECTIONPROBE_BLENDING 0
+#define ENABLE_SPECULARAA 0
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include MATERIAL_TYPE_AZSLI_FILE_PATH
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
+
+#include "../../../Shaders/Materials/BasePBR/BasePBR_LightingData.azsli"
+#include "../../../Shaders/Materials/BasePBR/BasePBR_LightingBrdf.azsli"
+#include "../../../Shaders/Materials/BasePBR/BasePBR_LightingEval.azsli"
+
+#include "MobileForwardPassVertexAndPixel.azsli"

+ 50 - 0
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/ForwardPass_BaseLighting.shader.template

@@ -0,0 +1,50 @@
+{
+    "Source" : "TEMPLATE_AZSL_PATH",
+
+    "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"
+            }
+        }
+    },
+
+    "ProgramSettings":
+    {
+      "EntryPoints":
+      [
+        {
+          "name": "VertexShader",
+          "type": "Vertex"
+        },
+        {
+          "name": "PixelShader",
+          "type": "Fragment"
+        }
+      ]
+    },
+
+    "DrawList" : "mobileForward"
+}
+

+ 54 - 0
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/ForwardPass_StandardLighting.azsli

@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+ 
+#define MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE 1
+
+// TODO(MaterialPipeline): In the end, after all refactoring and rearranging of our shader code is done, some of these flags might become unnecessary and should be re-evaluated.
+// Some of these setting used to be in ShaderQualityOptions.azsli as a basic/limited solution for multiple pipelines.
+// TODO(MaterialPipeline), instead of UNIFIED_FORWARD_OUTPUT, fork ForwardPassOutput.azsli
+#define UNIFIED_FORWARD_OUTPUT 1
+#define FORCE_IBL_IN_FORWARD_PASS 1
+#define FORCE_EARLY_DEPTH_STENCIL 1
+#define OUTPUT_DEPTH 0
+#define FORCE_OPAQUE 1
+#define OUTPUT_SUBSURFACE 0
+
+#define ENABLE_TRANSMISSION 0
+#define ENABLE_SHADER_DEBUGGING 0
+#define ENABLE_CLEAR_COAT 0
+#define ENABLE_SHADOWS 1
+#define ENABLE_FULLSCREEN_SHADOW 0
+#define ENABLE_LIGHT_CULLING 0
+#define ENABLE_DISK_LIGHTS 1
+#define ENABLE_AREA_LIGHTS 0
+#define ENABLE_AREA_LIGHT_VALIDATION    0
+#define ENABLE_PHYSICAL_SKY 0
+#define ENABLE_MERGE_FILMIC_TONEMAP 1
+#define ENABLE_DECALS 0
+#define ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION 0
+#define ENABLE_REFLECTIONPROBE_BLENDING 0
+#define ENABLE_SPECULARAA 0
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include MATERIAL_TYPE_AZSLI_FILE_PATH
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
+
+// TODO(MaterialPipeline): I don't like how this file #includes something from BasePBR. I'd rather it include a file
+// called StandardPBR_LightingData.azsli which just #includes the BasePBR file. Otherwise this looks suspicious like
+// a mistake of some kind.
+#include "../../../Shaders/Materials/BasePBR/BasePBR_LightingData.azsli"
+#include "../../../Shaders/Materials/StandardPBR/StandardPBR_LightingBrdf.azsli"
+#include "../../../Shaders/Materials/StandardPBR/StandardPBR_LightingEval.azsli"
+
+#include "MobileForwardPassVertexAndPixel.azsli"
+
+

+ 50 - 0
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/ForwardPass_StandardLighting.shader.template

@@ -0,0 +1,50 @@
+{
+    "Source" : "TEMPLATE_AZSL_PATH",
+
+    "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"
+            }
+        }
+    },
+
+    "ProgramSettings":
+    {
+      "EntryPoints":
+      [
+        {
+          "name": "VertexShader",
+          "type": "Vertex"
+        },
+        {
+          "name": "PixelShader",
+          "type": "Fragment"
+        }
+      ]
+    },
+
+    "DrawList" : "mobileForward"
+}
+

+ 65 - 0
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/MobileForwardPassVertexAndPixel.azsli

@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+
+#pragma once
+
+#include <Atom/Features/Pipeline/Forward/ForwardPassOutput.azsli>
+#include <Atom/Features/PostProcessing/Tonemap.azsli>
+#include <Atom/Features/ColorManagement/TransformColor.azsli>
+
+// --- Vertex Shader ---
+VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
+{
+    VsSystemValues SV;
+    SV.m_instanceId = instanceId;
+    VsOutput OUT = EvaluateVertexGeometry(IN, SV);
+    return OUT;
+}
+
+// --- Pixel Shader ---
+
+#if FORCE_EARLY_DEPTH_STENCIL
+    [earlydepthstencil]
+#endif
+ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
+{
+    // ------- Geometry -> Surface -> Lighting -------
+
+    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
+
+    Surface surface = EvaluateSurface(IN, geoData);
+
+    LightingData lightingData = EvaluateLighting(surface, IN.position);
+
+    // ------- Output -------
+
+    ForwardPassOutput OUT;
+
+    real3 color = lightingData.diffuseLighting.rgb + lightingData.specularLighting.rgb + lightingData.emissiveLighting.rgb;
+
+#if ENABLE_MERGE_FILMIC_TONEMAP
+    // Apply manual exposure compensation
+    color = ApplyManualExposure(color, real(ViewSrg::GetExposureValueCompensation()));
+    
+    //Convert to linearsrg space as we are in acescg space and we will not be applying aces tonemap
+    color = AcesCg_To_LinearSrgb(color);
+
+    // We could add other forms of tonemapping in future via shader options.
+    color = ApplyFilmicTonemap(color);
+#endif
+
+    OUT.m_color.rgb = color;
+    OUT.m_color.a = 1.0;
+
+#if OUTPUT_DEPTH
+    OUT.m_depth = IN.position.z;
+#endif
+
+    return OUT;
+}
+

+ 83 - 0
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/MobilePipeline.materialpipeline

@@ -0,0 +1,83 @@
+{
+    "shaderTemplates": [
+        // Unlike Standard and Enhanced, BaseLighting doesn't have "_CustomZ" just because BasePBR.materialtype doesn't use alpha cutout or POM PDO, so we don't need it right now.
+        // But that could be added if some other material type wants to use BaseLighting with one of these features, as they don't really relate to the lighting model.
+        {
+            "shader": "./ForwardPass_BaseLighting.shader.template",
+            "azsli": "./ForwardPass_BaseLighting.azsli",
+            "tag": "forward"
+        },
+        {
+            "shader": "./ForwardPass_StandardLighting.shader.template",
+            "azsli": "./ForwardPass_StandardLighting.azsli",
+            "tag": "forward"
+        },
+        {
+            "shader": "./Transparent_StandardLighting.shader.template",
+            "azsli": "./Transparent_StandardLighting.azsli",
+            "tag": "transparent"
+        },
+        {
+            "shader": "../Common/ShadowmapPass.shader.template",
+            "azsli": "../Common/DepthPass.azsli",
+            "tag": "shadow"
+        },
+        // TODO(MaterialPipeline): The TintedTransparent shaders uses the same azsli file as the normal Transparent shaders, they just need
+        // a different blend state. This results in a redundant shader compilation. We should find some way to reuse the same compiled bytecode
+        // rather than compiling each transparent shader twice. Note we are trying to avoid using the lua material functor's render state override
+        // features, so they can be deprecated. See https://github.com/o3de/sig-graphics-audio/issues/74
+        {
+            "shader": "./TintedTransparent_StandardLighting.shader.template",
+            "azsli": "./Transparent_StandardLighting.azsli",
+            "tag": "tintedTransparent"
+        }
+    ],
+    "runtime": {
+        "properties": [
+            {
+                "name": "isTransparent",
+                "type": "Bool",
+                "defaultValue": false
+            },
+            {
+                "name": "isTintedTransparent",
+                "type": "Bool",
+                "defaultValue": false
+            },
+            {
+                "name": "castShadows",
+                "type": "Bool",
+                "defaultValue": true
+            },
+            {
+                "name": "doubleSided",
+                "type": "Bool",
+                "defaultValue": false
+            },
+            {
+                "name": "hasPerPixelClip",
+                "type": "Bool",
+                "defaultValue": false
+            }
+            // Note we don't include "hasPerPixelDepth" because the VR pipeline will be highly optimized, and unlikely to ever support PDO or similar features.
+        ],
+        "functors": 
+        [
+            {
+                "type": "Lua",
+                "args": {
+                    //TODO(MaterialPipeline): Make the builder touch up this path so it can be relative to the .materialpipeline file
+                    "file": "Materials/Pipelines/Common/ShaderEnable.lua"
+                }
+            },
+            {
+                "type": "Lua",
+                "args": {
+                    //TODO(MaterialPipeline): Make the builder touch up this path so it can be relative to the .materialpipeline file
+                    "file": "Materials/Pipelines/Common/DoubleSided.lua"
+                }
+            }
+        ]
+    },
+    "pipelineScript": "./MobilePipelineScript.lua"
+}

+ 51 - 0
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/MobilePipelineScript.lua

@@ -0,0 +1,51 @@
+--------------------------------------------------------------------------------------
+--
+-- Copyright (c) Contributors to the Open 3D Engine Project.
+-- For complete copyright and license terms please see the LICENSE at the root of this distribution.
+--
+-- SPDX-License-Identifier: Apache-2.0 OR MIT
+--
+--
+--
+----------------------------------------------------------------------------------------------------
+
+function MaterialTypeSetup(context)
+    lightingModel = context:GetLightingModelName()
+    Print('Material type uses lighting model "' .. lightingModel .. '".')
+
+    context:ExcludeAllShaders()
+    
+    context:IncludeShader("ShadowmapPass")
+
+    if(lightingModel == "Base") then
+        context:IncludeShader("ForwardPass_BaseLighting")
+        return true
+    end
+
+    if(lightingModel == "Standard" or lightingModel == "Enhanced") then
+        if(lightingModel == "Enhanced") then
+            Warning("The multi view pipeline does not support the Enhanced lighting model. Will use Standard lighting as a fallback.")
+        end
+        
+        context:IncludeShader("ForwardPass_StandardLighting")
+        context:IncludeShader("Transparent_StandardLighting")
+        context:IncludeShader("TintedTransparent_StandardLighting")
+        return true
+    end
+    
+    if(lightingModel == "Skin") then
+        Error("The low end pipeline does not support the Skin lighting model. This combination should not be used at runtime.")
+        -- This returns 'true' to pass the build, the surface won't be rendered at runtime.
+        -- TODO(MaterialPipeline): Instead of rendering nothing, either render an error shader (like a magenta surface) or fall back to StandardLighting.
+        --                         For an error shader, .materialtype needs to have new field for an ObjectSrg azsli file separate from "materialShaderCode", so that
+        --                         the error shader can use the same ObjectSrg as the other shaders (depth/shadow) without including the unsupported materialShaderCode.
+        --                         Using StandardLighting as a fallback is even more difficult because it requires some kind of adapter to move data from the Surface that
+        --                         the material type wants to use, to the Surface that the lighting model supports. (It's a natural fit for downgrading from Enhanced to
+        --                         Standard but there is compatibility issues between Skin and Standard).
+        return true
+    end
+
+    Error('Unsupported lighting model "' .. lightingModel .. '".')
+    return false
+end
+

+ 59 - 0
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/TintedTransparent_StandardLighting.shader.template

@@ -0,0 +1,59 @@
+{
+    "Source" : "TEMPLATE_AZSL_PATH",
+
+    "DepthStencilState" :
+    {
+        "Depth" :
+        {
+            "Enable" : true,
+            "CompareFunc" : "GreaterEqual",
+            "writeMask": "Zero"
+        },
+        "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"
+            }
+        }
+    },
+    
+    "GlobalTargetBlendState" : 
+    {
+        "Enable" : true,
+        "BlendSource" : "One",
+        "BlendDest" : "ColorSource1",
+        "BlendOp" : "Add"
+    },
+
+    "ProgramSettings":
+    {
+      "EntryPoints":
+      [
+        {
+          "name": "VertexShader",
+          "type": "Vertex"
+        },
+        {
+          "name": "PixelShader",
+          "type": "Fragment"
+        }
+      ]
+    },
+
+    "DrawList" : "mobileTransparent"
+}
+

+ 50 - 0
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/Transparent_StandardLighting.azsli

@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+ 
+#define MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE 1
+
+// TODO(MaterialPipeline): In the end, after all refactoring and rearranging of our shader code is done, some of these flags might become unnecessary and should be re-evaluated.
+// Some of these setting used to be in ShaderQualityOptions.azsli as a basic/limited solution for multiple pipelines.
+// TODO(MaterialPipeline), instead of UNIFIED_FORWARD_OUTPUT, fork ForwardPassOutput.azsli
+#define UNIFIED_FORWARD_OUTPUT          1
+#define FORCE_IBL_IN_FORWARD_PASS       1
+#define ENABLE_AREA_LIGHT_VALIDATION    0
+#define FORCE_EARLY_DEPTH_STENCIL 1
+#define FORCE_OPAQUE 0
+#define OUTPUT_SUBSURFACE 0
+#define ENABLE_TRANSMISSION 0
+#define ENABLE_SHADER_DEBUGGING 0
+#define ENABLE_CLEAR_COAT 0
+#define ENABLE_SHADOWS 1
+#define ENABLE_FULLSCREEN_SHADOW 0
+#define ENABLE_LIGHT_CULLING 0
+#define ENABLE_AREA_LIGHTS 0
+#define ENABLE_PHYSICAL_SKY 0
+#define ENABLE_MERGE_FILMIC_TONEMAP 1
+#define ENABLE_DECALS              0
+#define ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION 0
+#define ENABLE_REFLECTIONPROBE_BLENDING 0
+#define ENABLE_SPECULARAA 0
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include MATERIAL_TYPE_AZSLI_FILE_PATH
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
+
+// TODO(MaterialPipeline): I don't like how this file #includes something from BasePBR. I'd rather it include a file
+// called StandardPBR_LightingData.azsli which just #includes the BasePBR file. Otherwise this looks suspicious like
+// a mistake of some kind.
+#include "../../../Shaders/Materials/BasePBR/BasePBR_LightingData.azsli"
+#include "../../../Shaders/Materials/StandardPBR/StandardPBR_LightingBrdf.azsli"
+#include "../../../Shaders/Materials/StandardPBR/StandardPBR_LightingEval.azsli"
+
+#include "../Common/TransparentPassVertexAndPixel.azsli"
+

+ 59 - 0
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/Transparent_StandardLighting.shader.template

@@ -0,0 +1,59 @@
+{
+    "Source" : "TEMPLATE_AZSL_PATH",
+
+    "DepthStencilState" :
+    {
+        "Depth" :
+        {
+            "Enable" : true,
+            "CompareFunc" : "GreaterEqual",
+            "writeMask": "Zero"
+        },
+        "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"
+            }
+        }
+    },
+    
+    "GlobalTargetBlendState" : 
+    {
+        "Enable" : true,
+        "BlendSource" : "One",
+        "BlendDest" : "AlphaSourceInverse",
+        "BlendOp" : "Add"
+    },
+
+    "ProgramSettings":
+    {
+      "EntryPoints":
+      [
+        {
+          "name": "VertexShader",
+          "type": "Vertex"
+        },
+        {
+          "name": "PixelShader",
+          "type": "Fragment"
+        }
+      ]
+    },
+
+    "DrawList" : "mobileTransparent"
+}
+

+ 129 - 0
Gems/Atom/Feature/Common/Assets/Passes/Mobile/Forward.pass

@@ -0,0 +1,129 @@
+{
+    "Type": "JsonSerialization",
+    "Version": 1,
+    "ClassName": "PassAsset",
+    "ClassData": {
+        "PassTemplate": {
+            "Name": "MobileForwardPassTemplate",
+            "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": "ProjectedShadowmap",
+                    "ShaderInputName": "m_projectedShadowmaps",
+                    "SlotType": "Input",
+                    "ScopeAttachmentUsage": "Shader",
+                    "ImageViewDesc": {
+                        "IsArray": 1
+                    }
+                },
+                // Outputs...
+                {
+                    "Name": "DepthStencilOutput",
+                    "SlotType": "Output",
+                    "ScopeAttachmentUsage": "DepthStencil",
+                    "LoadStoreAction": {
+                        "ClearValue": {
+                            "Type": "DepthStencil"
+                        },
+                        "LoadAction": "Clear",
+                        "LoadActionStencil": "Clear"
+                    }
+                },
+                {
+                    "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": "PipelineOutput"
+                      }
+                    },
+                  "MultisampleSource": {
+                    "Pass": "Parent",
+                    "Attachment": "PipelineOutput"
+                  },
+                    "ImageDescriptor": {
+                      "Format": "R16G16B16A16_FLOAT",
+                      "SharedQueueMask": "Graphics"
+                    }
+                },
+                {
+                    "Name": "DepthAttachment",
+                    "SizeSource": {
+                      "Source": {
+                        "Pass": "Parent",
+                        "Attachment": "PipelineOutput"
+                      }
+                    },
+                    "ImageDescriptor": {
+                      "Format": "D32_FLOAT_S8X24_UINT",
+                      "SharedQueueMask": "Graphics"
+                    }
+                },
+                {
+                    "Name": "BRDFTexture",
+                    "Lifetime": "Imported",
+                    "AssetRef": {
+                        "FilePath": "Textures/BRDFTexture.attimage"
+                    }
+                }
+            ],
+            "Connections": [
+                {
+                  "LocalSlot": "DepthStencilOutput",
+                  "AttachmentRef": {
+                    "Pass": "This",
+                    "Attachment": "DepthAttachment"
+                  }
+                },
+                {
+                    "LocalSlot": "LightingOutput",
+                    "AttachmentRef": {
+                        "Pass": "This",
+                        "Attachment": "LightingAttachment"
+                    }
+                },
+                {
+                    "LocalSlot": "BRDFTextureInput",
+                    "AttachmentRef": {
+                        "Pass": "This",
+                        "Attachment": "BRDFTexture"
+                    }
+                }
+            ]
+        }
+    }
+}

+ 17 - 0
Gems/Atom/Feature/Common/Assets/Passes/Mobile/MobileRenderPipeline.azasset

@@ -0,0 +1,17 @@
+{
+    "Type": "JsonSerialization",
+    "Version": 1,
+    "ClassName": "RenderPipelineDescriptor",
+    "ClassData": {
+        "Name": "MobilePipeline",
+        "MainViewTag": "MainCamera",
+        "MaterialPipelineTag": "MobilePipeline",
+        "RootPassTemplate": "MobilePipelineTemplate",
+        "AllowModification": true,
+        "RenderSettings": {
+            "MultisampleState": {
+                "samples": 1
+            }
+        }
+    }
+}

+ 213 - 0
Gems/Atom/Feature/Common/Assets/Passes/Mobile/Pipeline.pass

@@ -0,0 +1,213 @@
+{
+    "Type": "JsonSerialization",
+    "Version": 1,
+    "ClassName": "PassAsset",
+    "ClassData": {
+        "PassTemplate": {
+            "Name": "MobilePipelineTemplate",
+            "PassClass": "ParentPass",
+            "Slots": [
+                {
+                    "Name": "PipelineOutput",
+                    "SlotType": "InputOutput"
+                }
+            ],
+            "PassData": {
+                "$type": "PassData",
+                "PipelineGlobalConnections": [
+                    {
+                        "GlobalName": "PipelineOutput",
+                        "Slot": "PipelineOutput"
+                    }
+                ]
+            },
+            "PassRequests": [
+                {
+                    "Name": "MorphTargetPass",
+                    "TemplateName": "MorphTargetPassTemplate"
+                },
+                {
+                    "Name": "SkinningPass",
+                    "TemplateName": "SkinningPassTemplate",
+                    "Connections": [
+                        {
+                            "LocalSlot": "SkinnedMeshOutputStream",
+                            "AttachmentRef": {
+                            "Pass": "MorphTargetPass",
+                            "Attachment": "MorphTargetDeltaOutput"
+                            }
+                        }
+                    ]
+                },
+                {
+                    "Name": "Shadows",
+                    "TemplateName": "MobileShadowParentTemplate",
+                    "Connections": [
+                        {
+                            "LocalSlot": "SkinnedMeshes",
+                            "AttachmentRef": {
+                                "Pass": "SkinningPass",
+                                "Attachment": "SkinnedMeshOutputStream"
+                            }
+                        },
+                        {
+                            "LocalSlot": "PipelineOutput",
+                            "AttachmentRef": {
+                                "Pass": "Parent",
+                                "Attachment": "PipelineOutput"
+                            }
+                        }
+                    ]
+                },
+                {
+                    "Name": "ForwardPass",
+                    "TemplateName": "MobileForwardPassTemplate",
+                    "Connections": [
+                        {
+                            "LocalSlot": "DirectionalLightShadowmap",
+                            "AttachmentRef": {
+                                "Pass": "Shadows",
+                                "Attachment": "DirectionalShadowmap"
+                            }
+                        },
+                        {
+                            "LocalSlot": "ProjectedShadowmap",
+                            "AttachmentRef": {
+                                "Pass": "Shadows",
+                                "Attachment": "ProjectedShadowmap"
+                            }
+                        }
+                    ],
+                    "PassData": {
+                        "$type": "RasterPassData",
+                        "DrawListTag": "mobileForward",
+                        "BindViewSrg": true,
+                        "PassSrgShaderAsset": {
+                            "FilePath": "Shaders/ForwardPassSrg.shader"
+                        }
+                    }
+                },
+                {
+                    "Name": "SkyBoxPass",
+                    "TemplateName": "MobileSkyBoxTemplate",
+                    "Enabled": true,
+                    "Connections": [
+                        {
+                            "LocalSlot": "SpecularInputOutput",
+                            "AttachmentRef": {
+                                "Pass": "ForwardPass",
+                                "Attachment": "LightingOutput"
+                            }
+                        },
+                        {
+                            "LocalSlot": "SkyBoxDepth",
+                            "AttachmentRef": {
+                                "Pass": "ForwardPass",
+                                "Attachment": "DepthStencilOutput"
+                            }
+                        }
+                    ]
+                },
+                {
+                    "Name": "MSAAResolvePass",
+                    "TemplateName": "MSAAResolveColorTemplate",
+                    "Connections": [
+                        {
+                            "LocalSlot": "Input",
+                            "AttachmentRef": {
+                                "Pass": "SkyBoxPass",
+                                "Attachment": "SpecularInputOutput"
+                            }
+                        }
+                    ]
+                },
+                {
+                    "Name": "TransparentPass",
+                    "TemplateName": "MobileTransparentParentTemplate",
+                    "Connections": [
+                        {
+                            "LocalSlot": "DepthStencil",
+                            "AttachmentRef": {
+                                "Pass": "ForwardPass",
+                                "Attachment": "DepthStencilOutput"
+                            }
+                        },
+                        {
+                            "LocalSlot": "InputOutput",
+                            "AttachmentRef": {
+                                "Pass": "MSAAResolvePass",
+                                "Attachment": "Output"
+                            }
+                        }
+                    ]
+                }, 
+                {
+                    "Name": "AuxGeomPass",
+                    "TemplateName": "AuxGeomPassTemplate",
+                    "Enabled": true,
+                    "Connections": [
+                        {
+                            "LocalSlot": "ColorInputOutput",
+                            "AttachmentRef": {
+                                "Pass": "TransparentPass",
+                                "Attachment": "InputOutput"
+                            }
+                        },
+                        {
+                            "LocalSlot": "DepthInputOutput",
+                            "AttachmentRef": {
+                                "Pass": "ForwardPass",
+                                "Attachment": "DepthStencilOutput"
+                            }
+                        }
+                    ],
+                    "PassData": {
+                        "$type": "RasterPassData",
+                        "DrawListTag": "auxgeom",
+                        "BindViewSrg": true
+                    }
+                },
+                {
+                    "Name": "UIPass",
+                    "TemplateName": "UIParentTemplate",
+                    "Connections": [  
+                        {
+                            "LocalSlot": "DepthInputOutput",
+                            "AttachmentRef": {
+                                "Pass": "ForwardPass",
+                                "Attachment": "DepthStencilOutput"
+                            }
+                        },
+                        {
+                            "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": "PipelineOutput"
+                            }
+                        }
+                    ]
+                }
+            ]
+        }
+    }
+}

+ 86 - 0
Gems/Atom/Feature/Common/Assets/Passes/Mobile/ShadowParent.pass

@@ -0,0 +1,86 @@
+{
+    "Type": "JsonSerialization",
+    "Version": 1,
+    "ClassName": "PassAsset",
+    "ClassData": {
+        "PassTemplate": {
+            "Name": "MobileShadowParentTemplate",
+            "PassClass": "ParentPass",
+            "Slots": [
+                // Inputs...
+                {
+                    "Name": "SkinnedMeshes",
+                    "SlotType": "Input"
+                },
+                // Outputs...
+                {
+                    "Name": "DirectionalShadowmap",
+                    "SlotType": "Output"
+                },
+                {
+                    "Name": "ProjectedShadowmap",
+                    "SlotType": "Output"
+                },
+                // SwapChain here is only used to reference the frame height and format
+                {
+                    "Name": "PipelineOutput",
+                    "SlotType": "InputOutput"
+                }
+            ],
+            "Connections": [
+                {
+                    "LocalSlot": "DirectionalShadowmap",
+                    "AttachmentRef": {
+                        "Pass": "Cascades",
+                        "Attachment": "Shadowmap"
+                    }
+                },
+                {
+                    "LocalSlot": "ProjectedShadowmap",
+                    "AttachmentRef": {
+                        "Pass": "Projected",
+                        "Attachment": "Shadowmap"
+                    }
+                }
+            ],
+            "PassRequests": [
+                {
+                    "Name": "Cascades",
+                    "TemplateName": "CascadedShadowmapsTemplate",
+                    "PassData": {
+                        "$type": "RasterPassData",
+                        "DrawListTag": "shadow",
+                        "PipelineViewTag": "DirectionalLightView"
+                    },
+                    "Connections": [
+                        {
+                            "LocalSlot": "SkinnedMeshes",
+                            "AttachmentRef": {
+                                "Pass": "Parent",
+                                "Attachment": "SkinnedMeshes"
+                            }
+                        }
+                    ]
+                },
+                {
+                    "Name": "Projected",
+                    "TemplateName": "ProjectedShadowmapsTemplate",
+                    "PassData": {
+                        "$type": "RasterPassData",
+                        "DrawListTag": "shadow",
+                        "PipelineViewTag": "ProjectedShadowView"
+                    },
+                    "Connections": [
+                        {
+                            "LocalSlot": "SkinnedMeshes",
+                            "AttachmentRef": {
+                                "Pass": "Parent",
+                                "Attachment": "SkinnedMeshes"
+                            }
+                        }
+                    ]
+                }
+            ]
+        }
+    }
+}

+ 30 - 0
Gems/Atom/Feature/Common/Assets/Passes/Mobile/SkyBox.pass

@@ -0,0 +1,30 @@
+{
+    "Type": "JsonSerialization",
+    "Version": 1,
+    "ClassName": "PassAsset",
+    "ClassData": {
+        "PassTemplate": {
+            "Name": "MobileSkyBoxTemplate",
+            "PassClass": "FullScreenTriangle",
+            "Slots": [
+                {
+                    "Name": "SpecularInputOutput",
+                    "SlotType": "InputOutput",
+                    "ScopeAttachmentUsage": "RenderTarget"
+                },
+                {
+                    "Name": "SkyBoxDepth",
+                    "SlotType": "InputOutput",
+                    "ScopeAttachmentUsage": "DepthStencil"
+                }
+            ],
+            "PassData": {
+                "$type": "FullscreenTrianglePassData",
+                "ShaderAsset": {
+                    "FilePath": "Shaders/SkyBox/MultiViewSkyBox.shader"
+                },
+                "BindViewSrg": true
+            }
+        }
+    }
+}

+ 49 - 0
Gems/Atom/Feature/Common/Assets/Passes/Mobile/Transparent.pass

@@ -0,0 +1,49 @@
+{
+    "Type": "JsonSerialization",
+    "Version": 1,
+    "ClassName": "PassAsset",
+    "ClassData": {
+        "PassTemplate": {
+            "Name": "MultiViewTransparentPassTemplate",
+            "PassClass": "RasterPass",
+            "Slots": [
+                // Inputs...
+                {
+                    "Name": "BRDFTextureInput",
+                    "ShaderInputName": "m_brdfMap",
+                    "SlotType": "Input",
+                    "ScopeAttachmentUsage": "Shader"
+                },
+                {
+                    "Name": "InputOutput",
+                    "SlotType": "InputOutput",
+                    "ScopeAttachmentUsage": "RenderTarget"
+                },
+                // Input/Outputs
+                {
+                    "Name": "DepthStencil",
+                    "SlotType": "InputOutput",
+                    "ScopeAttachmentUsage": "DepthStencil"
+                }
+            ],
+            "ImageAttachments": [
+                {
+                    "Name": "BRDFTexture",
+                    "Lifetime": "Imported",
+                    "AssetRef": {
+                        "FilePath": "Textures/BRDFTexture.attimage"
+                    }
+                }
+            ],
+            "Connections": [
+                {
+                    "LocalSlot": "BRDFTextureInput",
+                    "AttachmentRef": {
+                        "Pass": "This",
+                        "Attachment": "BRDFTexture"
+                    }
+                }
+            ]
+        }
+    }
+}

+ 55 - 0
Gems/Atom/Feature/Common/Assets/Passes/Mobile/TransparentParent.pass

@@ -0,0 +1,55 @@
+{
+    "Type": "JsonSerialization",
+    "Version": 1,
+    "ClassName": "PassAsset",
+    "ClassData": {
+        "PassTemplate": {
+            "Name": "MobileTransparentParentTemplate",
+            "PassClass": "ParentPass",
+            "Slots": [
+                // Input/Outputs...
+                {
+                    "Name": "DepthStencil",
+                    "SlotType": "InputOutput"
+                },
+                {
+                    "Name": "InputOutput",
+                    "SlotType": "InputOutput"
+                }
+            ],
+            "PassRequests": [
+                {
+                    "Name": "MobileTransparentPass",
+                    "TemplateName": "MobileTransparentPassTemplate",
+                    "Enabled": true,
+                    "Connections": [
+                        // Input/Outputs...
+                        {
+                            "LocalSlot": "DepthStencil",
+                            "AttachmentRef": {
+                                "Pass": "Parent",
+                                "Attachment": "DepthStencil"
+                            }
+                        },
+                        {
+                            "LocalSlot": "InputOutput",
+                            "AttachmentRef": {
+                                "Pass": "Parent",
+                                "Attachment": "InputOutput"
+                            }
+                        }
+                    ],
+                    "PassData": {
+                        "$type": "RasterPassData",
+                        "DrawListTag": "mobileTransparent",
+                        "DrawListSortType": "KeyThenReverseDepth",
+                        "BindViewSrg": true,
+                        "PassSrgShaderAsset": {
+                            "FilePath": "Shaders/ForwardPassSrg.shader"
+                        }
+                    }
+                }
+            ]
+        }
+    }
+}

+ 24 - 0
Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset

@@ -548,6 +548,30 @@
                 "Name": "MultiViewTransparentParentTemplate",
                 "Path": "Passes/MultiViewTransparentParent.pass"
             },
+            {
+                "Name": "MobileForwardPassTemplate",
+                "Path": "Passes/Mobile/Forward.pass"
+            },
+            {
+                "Name": "MobilePipelineTemplate",
+                "Path": "Passes/Mobile/Pipeline.pass"
+            },
+            {
+                "Name": "MobileSkyBoxTemplate",
+                "Path": "Passes/Mobile/SkyBox.pass"
+            },
+            {
+                "Name": "MobileTransparentPassTemplate",
+                "Path": "Passes/Mobile/Transparent.pass"
+            },
+            {
+                "Name": "MobileTransparentParentTemplate",
+                "Path": "Passes/Mobile/TransparentParent.pass"
+            },
+            {
+                "Name": "MobileShadowParentTemplate",
+                "Path": "Passes/Mobile/ShadowParent.pass"
+            },
             {
                 "Name": "KawaseShadowBlurTemplate",
                 "Path": "Passes/KawaseShadowBlur.pass"

+ 10 - 2
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli

@@ -14,6 +14,10 @@
 
 #if ENABLE_SHADOWS
 
+#ifndef ENABLE_FULLSCREEN_SHADOW
+#define ENABLE_FULLSCREEN_SHADOW              1
+#endif
+
 #include <scenesrg.srgi>
 #include <viewsrg.srgi>
 #include <Atom/RPI/Math.azsli>
@@ -51,11 +55,15 @@ class DirectionalLightShadow
 
 bool DirectionalLightShadow::UseFullscreenShadows()
 {
-#if FORCE_OPAQUE
+#if ENABLE_FULLSCREEN_SHADOW
+    #if FORCE_OPAQUE
     return true;
-#else
+    #else
     bool useFullscreenShadows = o_opacity_mode == OpacityMode::Opaque || o_opacity_mode == OpacityMode::Cutout;
     return useFullscreenShadows;
+    #endif    
+#else
+    return false;
 #endif
 }
 

+ 6 - 0
Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake

@@ -160,6 +160,12 @@ set(FILES
     Passes/MultiViewSkyBox.pass
     Passes/MultiViewTransparent.pass
     Passes/MultiViewTransparentParent.pass
+    Passes/Mobile/Forward.pass
+    Passes/Mobile/Pipeline.pass
+    Passes/Mobile/ShadowParent.pass
+    Passes/Mobile/SkyBox.pass
+    Passes/Mobile/Transparent.pass
+    Passes/Mobile/TransparentParent.pass
     Passes/NewDepthOfField.pass
     Passes/NewDepthOfFieldComposite.pass
     Passes/NewDepthOfFieldDownsample.pass

+ 17 - 5
Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp

@@ -326,8 +326,12 @@ namespace AZ
                     }
 
                     m_shadowBufferHandlers.at(view.get()).UpdateSrg(viewSrg);
-                    m_esmParameterBufferHandlers.at(view.get()).UpdateBuffer(m_esmParameterData.at(view.get()).GetDataVector());
-                    m_esmParameterBufferHandlers.at(view.get()).UpdateSrg(viewSrg);
+                    auto itr = m_esmParameterBufferHandlers.find(view.get());
+                    if (itr != m_esmParameterBufferHandlers.end())
+                    {
+                        itr->second.UpdateBuffer(m_esmParameterData.at(view.get()).GetDataVector());
+                        itr->second.UpdateSrg(viewSrg);
+                    }
                     viewSrg->SetConstant(m_shadowIndexDirectionalLightIndex, rawShadowIndex);
                 }
             }
@@ -1262,7 +1266,11 @@ namespace AZ
 
             // Update ESM parameter buffer which is attached to
             // both of Forward Pass and ESM Shadowmaps Pass.
-            m_esmParameterBufferHandlers.at(cameraView).UpdateBuffer(m_esmParameterData.at(cameraView).GetDataVector());
+            auto itr = m_esmParameterBufferHandlers.find(cameraView);
+            if (itr != m_esmParameterBufferHandlers.end())
+            {
+                itr->second.UpdateBuffer(m_esmParameterData.at(cameraView).GetDataVector());
+            }
 
             // Create index table buffer.
             const RPI::RenderPipelineId cameraPipelineId = m_renderPipelineIdsForPersistentView.at(cameraView).front();
@@ -1495,8 +1503,12 @@ namespace AZ
 
             // Set parameter to convert to emphasize from minYSegment to maxYSegment
             // to mitigate Peter-Panning.
-            m_esmParameterData.at(cameraView).GetData(cascadeIndex).m_lightDistanceOfCameraViewFrustum =
-                (minYSegment - minY) / (maxYSegment - minY);
+            auto itr = m_esmParameterData.find(cameraView);
+            if (itr != m_esmParameterData.end())
+            {
+                itr->second.GetData(cascadeIndex).m_lightDistanceOfCameraViewFrustum =
+                    (minYSegment - minY) / (maxYSegment - minY);
+            }
 
             // Set coefficient of slope bias to remove shadow acne.
             // Slope bias is shadowmapTexelDiameter * tan(theta) / depthRange

+ 5 - 8
Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp

@@ -540,7 +540,6 @@ namespace AZ::Render
     {
         if (m_primaryEsmShadowmapsPass == nullptr)
         {
-            AZ_Error("ProjectedShadowFeatureProcessor", false, "Cannot find a required pass.");
             return;
         }
 
@@ -561,11 +560,6 @@ namespace AZ::Render
     void ProjectedShadowFeatureProcessor::SetFilterParameterToPass()
     {
         static uint32_t nameIndex = 0;
-        if (m_primaryProjectedShadowmapsPass == nullptr || m_primaryEsmShadowmapsPass == nullptr)
-        {
-            AZ_Error("ProjectedShadowFeatureProcessor", false, "Cannot find a required pass.");
-            return;
-        }
 
         // Create index table buffer.
         // [GFX TODO ATOM-14851] Should not be creating a new buffer here, just map the data or orphan with new data.
@@ -574,8 +568,11 @@ namespace AZ::Render
 
         m_filterParamBufferHandler.UpdateBuffer(m_shadowData.GetRawData<FilterParamIndex>(), static_cast<uint32_t>(m_shadowData.GetSize()));
 
-        m_primaryEsmShadowmapsPass->SetShadowmapIndexTableBuffer(indexTableBuffer);
-        m_primaryEsmShadowmapsPass->SetFilterParameterBuffer(m_filterParamBufferHandler.GetBuffer());
+        if (m_primaryEsmShadowmapsPass)
+        {
+            m_primaryEsmShadowmapsPass->SetShadowmapIndexTableBuffer(indexTableBuffer);
+            m_primaryEsmShadowmapsPass->SetFilterParameterBuffer(m_filterParamBufferHandler.GetBuffer());
+        }
     }
 
     void ProjectedShadowFeatureProcessor::Simulate(const FeatureProcessor::SimulatePacket& /*packet*/)