Explorar el Código

Merge pull request #18392 from kh-huawei/material_parameter_buffer

Move Material Parameters from the MaterialSrg to a Material Parameter Struct
jhmueller-huawei hace 3 meses
padre
commit
c08f103f6c
Se han modificado 100 ficheros con 1577 adiciones y 1150 borrados
  1. 17 0
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Android/Null/AzslcHeader.azsli
  2. 3 27
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Android/Vulkan/AzslcHeader.azsli
  3. 2 11
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Linux/Null/AzslcHeader.azsli
  4. 1 10
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Linux/Vulkan/AzslcHeader.azsli
  5. 3 13
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Mac/Metal/AzslcHeader.azsli
  6. 2 9
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Mac/Null/AzslcHeader.azsli
  7. 2 11
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Windows/DX12/AzslcHeader.azsli
  8. 2 9
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Windows/Null/AzslcHeader.azsli
  9. 1 11
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Windows/Vulkan/AzslcHeader.azsli
  10. 3 13
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/iOS/Metal/AzslcHeader.azsli
  11. 16 0
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/iOS/Null/AzslcHeader.azsli
  12. 1 1
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Common/DepthPass.azsli
  13. 3 3
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Common/DepthPass_CustomZ.azsli
  14. 1 1
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Common/MeshMotionVector.azsli
  15. 3 3
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Common/TransparentPassVertexAndPixel.azsli
  16. 3 3
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/LowEndPipeline/LowEndForwardPassVertexAndPixel.azsli
  17. 3 3
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MainPipeline/ForwardPassVertexAndPixel.azsli
  18. 3 3
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Mobile/MobileForwardPassVertexAndPixel.azsli
  19. 3 3
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/MultiViewForwardPassVertexAndPixel.azsli
  20. 12 3
      Gems/Atom/Feature/Common/Assets/Materials/ReflectionProbe/ReflectionProbeVisualization.azsli
  21. 10 3
      Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR.azsli
  22. 13 8
      Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.azsli
  23. 7 3
      Gems/Atom/Feature/Common/Assets/Materials/Types/Eye.azsli
  24. 29 5
      Gems/Atom/Feature/Common/Assets/Materials/Types/Eye.materialtype
  25. 11 1
      Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/DetailMapsPropertyGroup.json
  26. 10 1
      Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/EmissivePropertyGroup.json
  27. 15 1
      Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/SubsurfaceAndTransmissionPropertyGroup.json
  28. 11 1
      Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/UvPropertyGroup.json
  29. 7 2
      Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsli
  30. 51 40
      Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.azsli
  31. 11 1
      Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype
  32. 2 2
      Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Displacement.lua
  33. 7 1
      Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_LayerProperties.json
  34. 13 8
      Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.azsli
  35. 42 0
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Materials/MaterialSrg.azsli
  36. 84 0
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Materials/SceneMaterialSrg.azsli
  37. 93 0
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Materials/SingleMaterialSrg.azsli
  38. 3 1
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/DefaultObjectSrg.azsli
  39. 27 23
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ParallaxMapping.azsli
  40. 2 0
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Skin/SkinObjectSrg.azsli
  41. 18 0
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_MaterialInputs.azsli
  42. 0 57
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_MaterialSrg.azsli
  43. 3 1
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_PixelGeometryEval.azsli
  44. 28 21
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_SurfaceEval.azsli
  45. 6 2
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexEval.azsli
  46. 1 1
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/DepthPass_VertexEval.azsli
  47. 26 0
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_MaterialInputs.azsli
  48. 0 106
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_MaterialSrg.azsli
  49. 5 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_PixelGeometryEval.azsli
  50. 55 48
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_SurfaceEval.azsli
  51. 7 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_VertexEval.azsli
  52. 20 0
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_MaterialInputs.azsli
  53. 0 88
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_MaterialSrg.azsli
  54. 5 2
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_PixelGeometryEval.azsli
  55. 54 53
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_SurfaceEval.azsli
  56. 5 2
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_VertexEval.azsli
  57. 11 8
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/MultilayerParallaxDepth.azsli
  58. 14 11
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/ParallaxDepth.azsli
  59. 6 6
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardGetAlphaAndClip.azsli
  60. 3 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardTransformDetailUvs.azsli
  61. 8 6
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/ParallaxInput.azsli
  62. 46 111
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MultilayerPBR/StandardMultilayerPBR_Common.azsli
  63. 13 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Silhouette/SilhouetteGather_MaterialSrg.azsli
  64. 21 0
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_MaterialInputs.azsli
  65. 0 83
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_MaterialSrg.azsli
  66. 4 2
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_PixelGeometryEval.azsli
  67. 55 50
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_SurfaceEval.azsli
  68. 7 4
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_VertexEval.azsli
  69. 25 0
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_MaterialInputs.azsli
  70. 0 76
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_MaterialSrg.azsli
  71. 5 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_PixelGeometryEval.azsli
  72. 22 15
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_SurfaceEval.azsli
  73. 25 0
      Gems/Atom/Feature/Common/Assets/Shaders/SceneMaterialSrg.azsl
  74. 40 0
      Gems/Atom/Feature/Common/Assets/Shaders/SceneMaterialSrg.shader
  75. 8 5
      Gems/Atom/Feature/Common/Assets/Shaders/Silhouette/SilhouetteGather.azsl
  76. 80 50
      Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake
  77. 3 1
      Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Material/ConvertEmissiveUnitFunctor.h
  78. 18 5
      Gems/Atom/Feature/Common/Code/Source/Material/ConvertEmissiveUnitFunctor.cpp
  79. 8 11
      Gems/Atom/Feature/Common/Code/Source/Material/ConvertEmissiveUnitFunctorSourceData.cpp
  80. 38 3
      Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.cpp
  81. 4 3
      Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.h
  82. 7 23
      Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.cpp
  83. 29 6
      Gems/Atom/Feature/Common/Code/Source/Material/Transform2DFunctor.cpp
  84. 3 3
      Gems/Atom/Feature/Common/Code/Source/Material/Transform2DFunctor.h
  85. 8 24
      Gems/Atom/Feature/Common/Code/Source/Material/Transform2DFunctorSourceData.cpp
  86. 7 4
      Gems/Atom/Feature/Common/Code/Source/Material/UseTextureFunctorSourceData.cpp
  87. 25 5
      Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp
  88. 37 0
      Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/SamplerState.h
  89. 2 0
      Gems/Atom/RHI/Code/Include/Atom/RHI/ImageView.h
  90. 9 0
      Gems/Atom/RHI/Code/Source/RHI.Reflect/SamplerState.cpp
  91. 6 0
      Gems/Atom/RHI/Code/Source/RHI/DeviceShaderResourceGroupData.cpp
  92. 17 1
      Gems/Atom/RHI/Code/Source/RHI/ImageView.cpp
  93. 15 0
      Gems/Atom/RHI/Null/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp
  94. 47 0
      Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/Platform/Android/AzslcPlatformHeader.azsli
  95. 33 0
      Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/Platform/Linux/AzslcPlatformHeader.azsli
  96. 33 0
      Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/Platform/Mac/AzslcPlatformHeader.azsli
  97. 34 0
      Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/Platform/Windows/AzslcPlatformHeader.azsli
  98. 33 0
      Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/Platform/iOS/AzslcPlatformHeader.azsli
  99. 1 0
      Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli
  100. 2 0
      Gems/Atom/RPI/Code/CMakeLists.txt

+ 17 - 0
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Android/Null/AzslcHeader.azsli

@@ -0,0 +1,17 @@
+/*
+ * 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
+ *
+ */
+
+/*
+* The shader build pipeline has 2 preprocess stages. The first one happens 
+* after appending this header and pre-processing with mcpp ahead of azslc.
+*/
+
+static const float4 s_AzslDebugColor = float4(0.5, 0.5, 0.5, 1);
+
+#include <Atom/RPI/Platform/Android/AzslcPlatformHeader.azsli>
+

+ 3 - 27
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Android/Vulkan/AzslcHeader.azsli

@@ -11,39 +11,15 @@
 * after appending this header and pre-processing with mcpp ahead of azslc.
 * after appending this header and pre-processing with mcpp ahead of azslc.
 */
 */
 
 
+static const float4 s_AzslDebugColor = float4(165.0 / 255.0, 30.0 / 255.0, 36.0 / 255.0, 1);
+
 //Used for normal map sampling
 //Used for normal map sampling
 #define AZ_TRAIT_ASTC_COMPRESSION 1
 #define AZ_TRAIT_ASTC_COMPRESSION 1
 
 
-static const float4 s_AzslDebugColor = float4(165.0 / 255.0, 30.0 / 255.0, 36.0 / 255.0, 1);
-
 //In Vulkan not all texture formats can be sampled using linear filtering. This causes validation errors on Android, so we downgrade to 
 //In Vulkan not all texture formats can be sampled using linear filtering. This causes validation errors on Android, so we downgrade to 
 //point sample for certain formats that are not supported on Android and switch from linear to point filtering for depth related 
 //point sample for certain formats that are not supported on Android and switch from linear to point filtering for depth related 
 //textures (since linear filtering for non linear textures is not correct).
 //textures (since linear filtering for non linear textures is not correct).
 #define AZ_TRAIT_DOWNGRADE_LINEAR_SAMPLE 1
 #define AZ_TRAIT_DOWNGRADE_LINEAR_SAMPLE 1
 
 
-//Assuming unbounded array suport for Android
-#define UNBOUNDED_SIZE
-
-#define USE_HALF_FLOATS_FOR_ANDROID 1
-#if USE_HALF_FLOATS_FOR_ANDROID
-
-// use half float for android
-#define real half
-#define real2 half2
-#define real3 half3
-#define real4 half4
-#define real3x3 half3x3
-#define real3x4 half3x4
-#define real4x4 half4x4
-
-#else
-
-#define real float
-#define real2 float2
-#define real3 float3
-#define real4 float4
-#define real3x3 float3x3
-#define real3x4 float3x4
-#define real4x4 float4x4
+#include <Atom/RPI/Platform/Android/AzslcPlatformHeader.azsli>
 
 
-#endif

+ 2 - 11
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Linux/Null/AzslcHeader.azsli

@@ -11,15 +11,6 @@
 * after appending this header and pre-processing with mcpp ahead of azslc.
 * after appending this header and pre-processing with mcpp ahead of azslc.
 */
 */
 
 
-//Linux supports unbounded array
-#define UNBOUNDED_SIZE
+static const float4 s_AzslDebugColor = float4(0.5, 0.5, 0.5, 1);
 
 
-
- // Full floats for null rhi
- #define real float
- #define real2 float2
- #define real3 float3
- #define real4 float4
- #define real3x3 float3x3
- #define real3x4 float3x4
- 
+#include <Atom/RPI/Platform/Linux/AzslcPlatformHeader.azsli>

+ 1 - 10
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Linux/Vulkan/AzslcHeader.azsli

@@ -10,15 +10,6 @@
 * The shader build pipeline has 2 preprocess stages. The first one happens 
 * The shader build pipeline has 2 preprocess stages. The first one happens 
 * after appending this header and pre-processing with mcpp ahead of azslc.
 * after appending this header and pre-processing with mcpp ahead of azslc.
 */
 */
-
-#define UNBOUNDED_SIZE
 static const float4 s_AzslDebugColor = float4(165.0 / 255.0, 30.0 / 255.0, 36.0 / 255.0, 1);
 static const float4 s_AzslDebugColor = float4(165.0 / 255.0, 30.0 / 255.0, 36.0 / 255.0, 1);
 
 
-// Full floats for Linux
-#define real float
-#define real2 float2
-#define real3 float3
-#define real4 float4
-#define real3x3 float3x3
-#define real3x4 float3x4
-#define real4x4 float4x4
+#include <Atom/RPI/Platform/Linux/AzslcPlatformHeader.azsli>

+ 3 - 13
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Mac/Metal/AzslcHeader.azsli

@@ -11,20 +11,10 @@
 * after appending this header and pre-processing with mcpp ahead of azslc.
 * after appending this header and pre-processing with mcpp ahead of azslc.
 */
 */
 
 
+static const float4 s_AzslDebugColor = float4(85.0 / 255.0, 85.0 / 255.0, 85.0 / 255.0, 1);
+
 //Unbounded array direct binding not supported on metal
 //Unbounded array direct binding not supported on metal
 #define UB_DIRECTBINDING_NOTSUPPPORTED
 #define UB_DIRECTBINDING_NOTSUPPPORTED
 
 
-//size for unbounded arrays
-#define UNBOUNDED_SIZE 100000
-
-static const float4 s_AzslDebugColor = float4(85.0 / 255.0, 85.0 / 255.0, 85.0 / 255.0, 1);
-
+#include <Atom/RPI/Platform/Mac/AzslcPlatformHeader.azsli>
 
 
-// Full floats for Mac
-#define real float
-#define real2 float2
-#define real3 float3
-#define real4 float4
-#define real3x3 float3x3
-#define real3x4 float3x4
-#define real4x4 float4x4

+ 2 - 9
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Mac/Null/AzslcHeader.azsli

@@ -11,14 +11,7 @@
 * after appending this header and pre-processing with mcpp ahead of azslc.
 * after appending this header and pre-processing with mcpp ahead of azslc.
 */
 */
 
 
-#define UNBOUNDED_SIZE 100000
+static const float4 s_AzslDebugColor = float4(0.5, 0.5, 0.5, 1);
 
 
-
- // Full floats for null rhi
- #define real float
- #define real2 float2
- #define real3 float3
- #define real4 float4
- #define real3x3 float3x3
- #define real3x4 float3x4
+#include <Atom/RPI/Platform/Mac/AzslcPlatformHeader.azsli>
  
  

+ 2 - 11
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Windows/DX12/AzslcHeader.azsli

@@ -11,16 +11,7 @@
 * after appending this header and pre-processing with mcpp ahead of azslc.
 * after appending this header and pre-processing with mcpp ahead of azslc.
 */
 */
 
 
-//PC supports unbounded array
-#define UNBOUNDED_SIZE 
-
 static const float4 s_AzslDebugColor = float4(16.0 / 255.0, 124.0 / 255.0, 16.0 / 255.0, 1);
 static const float4 s_AzslDebugColor = float4(16.0 / 255.0, 124.0 / 255.0, 16.0 / 255.0, 1);
 
 
-// Full floats for windows DX12 PC
-#define real float
-#define real2 float2
-#define real3 float3
-#define real4 float4
-#define real3x3 float3x3
-#define real3x4 float3x4
-#define real4x4 float4x4
+#include <Atom/RPI/Platform/Windows/AzslcPlatformHeader.azsli>
+

+ 2 - 9
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Windows/Null/AzslcHeader.azsli

@@ -11,13 +11,6 @@
 * after appending this header and pre-processing with mcpp ahead of azslc.
 * after appending this header and pre-processing with mcpp ahead of azslc.
 */
 */
 
 
-#define UNBOUNDED_SIZE 
+static const float4 s_AzslDebugColor = float4(0.5, 0.5, 0.5, 1);
 
 
-// Full floats for null rhi
-#define real float
-#define real2 float2
-#define real3 float3
-#define real4 float4
-#define real3x3 float3x3
-#define real3x4 float3x4
-#define real4x4 float4x4
+#include <Atom/RPI/Platform/Windows/AzslcPlatformHeader.azsli>

+ 1 - 11
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Windows/Vulkan/AzslcHeader.azsli

@@ -13,18 +13,8 @@
 
 
 static const float4 s_AzslDebugColor = float4(165.0 / 255.0, 30.0 / 255.0, 36.0 / 255.0, 1);
 static const float4 s_AzslDebugColor = float4(165.0 / 255.0, 30.0 / 255.0, 36.0 / 255.0, 1);
 
 
-
 // Different constant buffer alignment on platforms
 // Different constant buffer alignment on platforms
 #define AZ_TRAIT_CONSTANT_BUFFER_ALIGNMENT      128
 #define AZ_TRAIT_CONSTANT_BUFFER_ALIGNMENT      128
 
 
-//PC supports unbounded array
-#define UNBOUNDED_SIZE
+#include <Atom/RPI/Platform/Windows/AzslcPlatformHeader.azsli>
 
 
-// Full floats for windows vulkan PC
-#define real float
-#define real2 float2
-#define real3 float3
-#define real4 float4
-#define real3x3 float3x3
-#define real3x4 float3x4
-#define real4x4 float4x4

+ 3 - 13
Gems/Atom/Asset/Shader/Code/AZSL/Platform/iOS/Metal/AzslcHeader.azsli

@@ -11,22 +11,12 @@
 * after appending this header and pre-processing with mcpp ahead of azslc.
 * after appending this header and pre-processing with mcpp ahead of azslc.
 */
 */
 
 
+static const float4 s_AzslDebugColor = float4(85.0 / 255.0, 85.0 / 255.0, 85.0 / 255.0, 1);
+
 //Used for normal map sampling
 //Used for normal map sampling
 #define AZ_TRAIT_ASTC_COMPRESSION 1
 #define AZ_TRAIT_ASTC_COMPRESSION 1
 
 
-//size for unbounded arrays
-#define UNBOUNDED_SIZE 100000
-
 //Unbounded array direct binding not supported on metal
 //Unbounded array direct binding not supported on metal
 #define UB_DIRECTBINDING_NOTSUPPPORTED
 #define UB_DIRECTBINDING_NOTSUPPPORTED
 
 
-static const float4 s_AzslDebugColor = float4(85.0 / 255.0, 85.0 / 255.0, 85.0 / 255.0, 1);
-
-// use half float for ios
-#define real half
-#define real2 half2
-#define real3 half3
-#define real4 half4
-#define real3x3 half3x3
-#define real3x4 half3x4
-#define real4x4 half4x4
+#include <Atom/RPI/Platform/iOS/AzslcPlatformHeader.azsli>

+ 16 - 0
Gems/Atom/Asset/Shader/Code/AZSL/Platform/iOS/Null/AzslcHeader.azsli

@@ -0,0 +1,16 @@
+/*
+ * 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
+ *
+ */
+
+/*
+* The shader build pipeline has 2 preprocess stages. The first one happens 
+* after appending this header and pre-processing with mcpp ahead of azslc.
+*/
+
+static const float4 s_AzslDebugColor = float4(0.5, 0.5, 0.5, 1);
+
+#include <Atom/RPI/Platform/iOS/AzslcPlatformHeader.azsli>

+ 1 - 1
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Common/DepthPass.azsli

@@ -17,7 +17,7 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
 {
 {
     VsSystemValues SV;
     VsSystemValues SV;
     SV.m_instanceId = instanceId;
     SV.m_instanceId = instanceId;
-    VsOutput OUT = EvaluateVertexGeometry(IN, SV);
+    VsOutput OUT = EvaluateVertexGeometry(IN, SV, GetMaterialParameters());
     return OUT;
     return OUT;
 }
 }
 
 

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Common/DepthPass_CustomZ.azsli

@@ -17,7 +17,7 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
 {
 {
     VsSystemValues SV;
     VsSystemValues SV;
     SV.m_instanceId = instanceId;
     SV.m_instanceId = instanceId;
-    VsOutput OUT = EvaluateVertexGeometry(IN, SV);
+    VsOutput OUT = EvaluateVertexGeometry(IN, SV, GetMaterialParameters());
     return OUT;
     return OUT;
 }
 }
 
 
@@ -28,10 +28,10 @@ struct PsOutput
 
 
 PsOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
 PsOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
 {
 {
-    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
+    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace, GetMaterialParameters());
 
 
     // Pixel clipping can be done here
     // Pixel clipping can be done here
-    EvaluateSurface(IN, geoData);
+    EvaluateSurface(IN, geoData, GetMaterialParameters());
 
 
     PsOutput OUT;
     PsOutput OUT;
     OUT.m_depth = IN.position.z;
     OUT.m_depth = IN.position.z;

+ 1 - 1
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Common/MeshMotionVector.azsli

@@ -28,7 +28,7 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
 {
 {
     VsSystemValues SV;
     VsSystemValues SV;
     SV.m_instanceId = instanceId;
     SV.m_instanceId = instanceId;
-    VsOutput OUT = EvaluateVertexGeometry(IN, SV);
+    VsOutput OUT = EvaluateVertexGeometry(IN, SV, GetMaterialParameters());
     return OUT;
     return OUT;
 }
 }
 
 

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/Common/TransparentPassVertexAndPixel.azsli

@@ -21,7 +21,7 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
 {
 {
     VsSystemValues SV;
     VsSystemValues SV;
     SV.m_instanceId = instanceId;
     SV.m_instanceId = instanceId;
-    VsOutput OUT = EvaluateVertexGeometry(IN, SV);
+    VsOutput OUT = EvaluateVertexGeometry(IN, SV, GetMaterialParameters());
     return OUT;
     return OUT;
 }
 }
 
 
@@ -31,9 +31,9 @@ ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
 {
 {
     // ------- Geometry -> Surface -> Lighting -------
     // ------- Geometry -> Surface -> Lighting -------
 
 
-    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
+    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace, GetMaterialParameters());
 
 
-    Surface surface = EvaluateSurface(IN, geoData);
+    Surface surface = EvaluateSurface(IN, geoData, GetMaterialParameters());
 
 
     LightingData lightingData = EvaluateLighting(surface, IN.position, ViewSrg::m_worldPosition.xyz);
     LightingData lightingData = EvaluateLighting(surface, IN.position, ViewSrg::m_worldPosition.xyz);
 
 

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/LowEndPipeline/LowEndForwardPassVertexAndPixel.azsli

@@ -16,7 +16,7 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
 {
 {
     VsSystemValues SV;
     VsSystemValues SV;
     SV.m_instanceId = instanceId;
     SV.m_instanceId = instanceId;
-    VsOutput OUT = EvaluateVertexGeometry(IN, SV);
+    VsOutput OUT = EvaluateVertexGeometry(IN, SV, GetMaterialParameters());
     return OUT;
     return OUT;
 }
 }
 
 
@@ -30,9 +30,9 @@ ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
 {
 {
     // ------- Geometry -> Surface -> Lighting -------
     // ------- Geometry -> Surface -> Lighting -------
 
 
-    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
+    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace, GetMaterialParameters());
 
 
-    Surface surface = EvaluateSurface(IN, geoData);
+    Surface surface = EvaluateSurface(IN, geoData, GetMaterialParameters());
 
 
     LightingData lightingData = EvaluateLighting(surface, IN.position, ViewSrg::m_worldPosition.xyz);
     LightingData lightingData = EvaluateLighting(surface, IN.position, ViewSrg::m_worldPosition.xyz);
 
 

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MainPipeline/ForwardPassVertexAndPixel.azsli

@@ -20,7 +20,7 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
 {
 {
     VsSystemValues SV;
     VsSystemValues SV;
     SV.m_instanceId = instanceId;
     SV.m_instanceId = instanceId;
-    VsOutput OUT = EvaluateVertexGeometry(IN, SV);
+    VsOutput OUT = EvaluateVertexGeometry(IN, SV, GetMaterialParameters());
     return OUT;
     return OUT;
 }
 }
 
 
@@ -46,9 +46,9 @@ ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
 {
 {
     // ------- Geometry -> Surface -> Lighting -------
     // ------- Geometry -> Surface -> Lighting -------
 
 
-    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
+    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace, GetMaterialParameters());
 
 
-    Surface surface = EvaluateSurface(IN, geoData);
+    Surface surface = EvaluateSurface(IN, geoData, GetMaterialParameters());
 
 
     LightingData lightingData = EvaluateLighting(surface, IN.position, ViewSrg::m_worldPosition.xyz);
     LightingData lightingData = EvaluateLighting(surface, IN.position, ViewSrg::m_worldPosition.xyz);
 
 

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

@@ -17,7 +17,7 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
 {
 {
     VsSystemValues SV;
     VsSystemValues SV;
     SV.m_instanceId = instanceId;
     SV.m_instanceId = instanceId;
-    VsOutput OUT = EvaluateVertexGeometry(IN, SV);
+    VsOutput OUT = EvaluateVertexGeometry(IN, SV, GetMaterialParameters());
     return OUT;
     return OUT;
 }
 }
 
 
@@ -30,9 +30,9 @@ ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
 {
 {
     // ------- Geometry -> Surface -> Lighting -------
     // ------- Geometry -> Surface -> Lighting -------
 
 
-    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
+    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace, GetMaterialParameters());
 
 
-    Surface surface = EvaluateSurface(IN, geoData);
+    Surface surface = EvaluateSurface(IN, geoData, GetMaterialParameters());
 
 
     LightingData lightingData = EvaluateLighting(surface, IN.position, ViewSrg::m_worldPosition.xyz);
     LightingData lightingData = EvaluateLighting(surface, IN.position, ViewSrg::m_worldPosition.xyz);
 
 

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/MultiViewForwardPassVertexAndPixel.azsli

@@ -17,7 +17,7 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
 {
 {
     VsSystemValues SV;
     VsSystemValues SV;
     SV.m_instanceId = instanceId;
     SV.m_instanceId = instanceId;
-    VsOutput OUT = EvaluateVertexGeometry(IN, SV);
+    VsOutput OUT = EvaluateVertexGeometry(IN, SV, GetMaterialParameters());
     return OUT;
     return OUT;
 }
 }
 
 
@@ -30,9 +30,9 @@ ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
 {
 {
     // ------- Geometry -> Surface -> Lighting -------
     // ------- Geometry -> Surface -> Lighting -------
 
 
-    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
+    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace, GetMaterialParameters());
 
 
-    Surface surface = EvaluateSurface(IN, geoData);
+    Surface surface = EvaluateSurface(IN, geoData, GetMaterialParameters());
 
 
     LightingData lightingData = EvaluateLighting(surface, IN.position, ViewSrg::m_worldPosition.xyz);
     LightingData lightingData = EvaluateLighting(surface, IN.position, ViewSrg::m_worldPosition.xyz);
 
 

+ 12 - 3
Gems/Atom/Feature/Common/Assets/Materials/ReflectionProbe/ReflectionProbeVisualization.azsli

@@ -11,6 +11,15 @@
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 #include <Atom/Features/VertexUtility.azsli>
 #include <Atom/Features/VertexUtility.azsli>
 
 
+
+
+struct MaterialParameters {};
+
+const MaterialParameters GetMaterialParameters()
+{
+    return (MaterialParameters)0;
+}
+
 #define ENABLE_DEBUG_MODIFY_OUTPUT 0
 #define ENABLE_DEBUG_MODIFY_OUTPUT 0
 
 
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
@@ -35,7 +44,7 @@
         float3 worldPosition : UV0;
         float3 worldPosition : UV0;
     };
     };
     
     
-    VsOutput EvaluateVertexGeometry(VsInput IN, VsSystemValues SV)
+    VsOutput EvaluateVertexGeometry(VsInput IN, VsSystemValues SV, const MaterialParameters params)
     {        
     {        
         VsOutput output;
         VsOutput output;
         output.worldPosition = LocalSpaceToWorldSpace(IN.position, SV.m_instanceId);
         output.worldPosition = LocalSpaceToWorldSpace(IN.position, SV.m_instanceId);
@@ -50,7 +59,7 @@
         float3 vertexNormal;
         float3 vertexNormal;
     };
     };
 
 
-    PixelGeometryData EvaluatePixelGeometry(VsOutput IN, bool isFrontFace)
+    PixelGeometryData EvaluatePixelGeometry(VsOutput IN, bool isFrontFace, const MaterialParameters params)
     {
     {
         PixelGeometryData geoData;
         PixelGeometryData geoData;
         geoData.positionWS = IN.worldPosition;
         geoData.positionWS = IN.worldPosition;
@@ -60,7 +69,7 @@
 
 
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_SurfaceData.azsli>
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_SurfaceData.azsli>
 
 
-    Surface EvaluateSurface(VsOutput IN, PixelGeometryData geoData)
+    Surface EvaluateSurface(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params)
     {
     {
         Surface surface;
         Surface surface;
         surface.position = geoData.positionWS;
         surface.position = geoData.positionWS;

+ 10 - 3
Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR.azsli

@@ -7,14 +7,21 @@
  */
  */
 
 
 #define ENABLE_VERTEX_COLOR 1
 #define ENABLE_VERTEX_COLOR 1
-    
-//TODO(MaterialPipeline): Inline the MaterialSrg files since they aren't reused.
+     
 //TODO(MaterialPipeline): Try removing different parts of the SRG and see how hard/easy it is to customize the surface function.
 //TODO(MaterialPipeline): Try removing different parts of the SRG and see how hard/easy it is to customize the surface function.
-#include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_MaterialSrg.azsli>
+
 
 
 #include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 
 
+// This file contains the definition for 'struct MaterialParameters', which is generated by the Materialpipeline
+// e.g. for BasePBR this is "basepbr_parameters.azsli"
+// which is usually in [project]/Cache/Intermediate Assets/materials/types/basepbr_parameters.azsli
+#include MATERIAL_PARAMETERS_AZSLI_FILE_PATH
+#include <Atom/Features/Materials/MaterialSrg.azsli>
+
+#include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_MaterialInputs.azsli>
+
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 
 
     COMMON_OPTIONS_BASE_COLOR()
     COMMON_OPTIONS_BASE_COLOR()

+ 13 - 8
Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.azsli

@@ -10,13 +10,17 @@
 
 
 #define ENABLE_VERTEX_COLOR 1
 #define ENABLE_VERTEX_COLOR 1
 
 
-//TODO(MaterialPipeline): Inline the MaterialSrg files since they aren't reused.
 //TODO(MaterialPipeline): Try removing different parts of the SRG and see how hard/easy it is to customize the surface function.
 //TODO(MaterialPipeline): Try removing different parts of the SRG and see how hard/easy it is to customize the surface function.
-#include <Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_MaterialSrg.azsli>
 
 
 #include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 
 
+// This file contains the definition for 'struct MaterialParameters', which is generated by the Materialpipeline
+#include MATERIAL_PARAMETERS_AZSLI_FILE_PATH
+#include <Atom/Features/Materials/MaterialSrg.azsli>
+
+#include <Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_MaterialInputs.azsli>
+
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 
 
     // Subsurface
     // Subsurface
@@ -49,9 +53,9 @@
     }
     }
     
     
     // Callback function for ParallaxMapping.azsli
     // Callback function for ParallaxMapping.azsli
-    DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
+    DepthResult GetDepth(Texture2D heightmap, sampler mapSampler, float2 uv, float2 uv_ddx, float2 uv_ddy)
     {
     {
-        return SampleDepthFromHeightmap(MaterialSrg::m_heightmap, MaterialSrg::m_sampler, uv, uv_ddx, uv_ddy);
+        return SampleDepthFromHeightmap(heightmap, mapSampler, uv, uv_ddx, uv_ddy);
     }
     }
 
 
     #include <Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_VertexData.azsli>
     #include <Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_VertexData.azsli>
@@ -83,10 +87,11 @@
     }
     }
     
     
     // Callback function for ParallaxMapping.azsli
     // Callback function for ParallaxMapping.azsli
-    DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
+    DepthResult GetDepth(Texture2D heightmap, sampler mapSampler, float2 uv, float2 uv_ddx, float2 uv_ddy)
     {
     {
-        return SampleDepthFromHeightmap(MaterialSrg::m_heightmap, MaterialSrg::m_sampler, uv, uv_ddx, uv_ddy);
+        return SampleDepthFromHeightmap(heightmap, mapSampler, uv, uv_ddx, uv_ddy);
     }
     }
+
     
     
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexData.azsli>
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexData.azsli>
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexEval.azsli>
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexEval.azsli>
@@ -98,9 +103,9 @@
     
     
     #include "Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardGetAlphaAndClip.azsli"
     #include "Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardGetAlphaAndClip.azsli"
 
 
-    void EvaluateSurface(VsOutput IN, PixelGeometryData geoData)
+    void EvaluateSurface(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params)
     {
     {
-        GetAlphaAndClip(geoData.uvs);
+        GetAlphaAndClip(params, geoData.uvs);
     }
     }
 
 
 #else
 #else

+ 7 - 3
Gems/Atom/Feature/Common/Assets/Materials/Types/Eye.azsli

@@ -5,15 +5,19 @@
  * SPDX-License-Identifier: Apache-2.0 OR MIT
  * SPDX-License-Identifier: Apache-2.0 OR MIT
  *
  *
  */
  */
-
-//TODO(MaterialPipeline): Inline the MaterialSrg files since they aren't reused.
-#include <Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_MaterialSrg.azsli>
+    
 
 
 #include <scenesrg_all.srgi>
 #include <scenesrg_all.srgi>
 #include <viewsrg_all.srgi>
 #include <viewsrg_all.srgi>
 #include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 
 
+// This file contains the definition for 'struct MaterialParameters', which is generated by the Materialpipeline
+#include MATERIAL_PARAMETERS_AZSLI_FILE_PATH
+#include <Atom/Features/Materials/MaterialSrg.azsli>
+
+#include <Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_MaterialInputs.azsli>
+
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 
 
     COMMON_OPTIONS_BASE_COLOR(o_iris_)
     COMMON_OPTIONS_BASE_COLOR(o_iris_)

+ 29 - 5
Gems/Atom/Feature/Common/Assets/Materials/Types/Eye.materialtype

@@ -3,12 +3,36 @@
     "version": 1,
     "version": 1,
     "propertyLayout": {
     "propertyLayout": {
         "propertyGroups": [
         "propertyGroups": [
+            {
+                "name": "TextureSampler",
+                "displayName": "Texture Sampler",
+                "description": "Configuration for the Texture sampler",
+                "properties": [
+                    {
+                        "name": "ClampSampler",
+                        "displayName": "Clamp Texture Sampler",
+                        "description": "The texture Sampler configuration used for all material textures.",
+                        "type": "SamplerState",
+                        "defaultValue": {
+                            "m_filterMin": "Linear",
+                            "m_filterMag": "Linear",
+                            "m_filterMip": "Linear",
+                            "m_addressU": "Clamp",
+                            "m_addressV": "Clamp"
+                        },
+                        "connection": {
+                            "type": "ShaderInput",
+                            "name": "m_clampSampler"
+                        }
+                    }
+                ]
+            },
             {
             {
                 "name": "iris",
                 "name": "iris",
                 "shaderInputsPrefix": "m_iris_",
                 "shaderInputsPrefix": "m_iris_",
                 "shaderOptionsPrefix": "o_iris_",
                 "shaderOptionsPrefix": "o_iris_",
-                "displayName":  "Iris",
-                "description":  "Material properties for the iris.",
+                "displayName": "Iris",
+                "description": "Material properties for the iris.",
                 "propertyGroups": [
                 "propertyGroups": [
                     {
                     {
                         "$import": "MaterialInputs/BaseColorPropertyGroup.json"
                         "$import": "MaterialInputs/BaseColorPropertyGroup.json"
@@ -25,8 +49,8 @@
                 "name": "sclera",
                 "name": "sclera",
                 "shaderInputsPrefix": "m_sclera_",
                 "shaderInputsPrefix": "m_sclera_",
                 "shaderOptionsPrefix": "o_sclera_",
                 "shaderOptionsPrefix": "o_sclera_",
-                "displayName":  "Sclera",
-                "description":  "Material properties for the sclera.",
+                "displayName": "Sclera",
+                "description": "Material properties for the sclera.",
                 "propertyGroups": [
                 "propertyGroups": [
                     {
                     {
                         "$import": "MaterialInputs/BaseColorPropertyGroup.json"
                         "$import": "MaterialInputs/BaseColorPropertyGroup.json"
@@ -132,4 +156,4 @@
         "UV0": "Tiled",
         "UV0": "Tiled",
         "UV1": "Unwrapped"
         "UV1": "Unwrapped"
     }
     }
-}
+}

+ 11 - 1
Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/DetailMapsPropertyGroup.json

@@ -168,7 +168,17 @@
                                 "translateYProperty": "offsetV",
                                 "translateYProperty": "offsetV",
                                 "rotateDegreesProperty": "rotateDegrees",
                                 "rotateDegreesProperty": "rotateDegrees",
                                 "float3x3ShaderInput": "m_detailUvMatrix",
                                 "float3x3ShaderInput": "m_detailUvMatrix",
-                                "float3x3InverseShaderInput": "m_detailUvMatrixInverse"
+                                "float3x3InverseShaderInput": "m_detailUvMatrixInverse",
+                                "shaderParameters": [
+                                    {
+                                        "name": "m_detailUvMatrix",
+                                        "type": "float3x3"
+                                    },
+                                    {
+                                        "name": "m_detailUvMatrixInverse",
+                                        "type": "float3x3"
+                                    }
+                                ]
                             }
                             }
                         }
                         }
                     ]
                     ]

+ 10 - 1
Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/EmissivePropertyGroup.json

@@ -94,7 +94,16 @@
                 "ev100Index": 0,
                 "ev100Index": 0,
                 "nitIndex" : 1,
                 "nitIndex" : 1,
                 "ev100MinMax": [-10, 20],
                 "ev100MinMax": [-10, 20],
-                "nitMinMax": [0.001, 100000.0]
+                "nitMinMax": [
+                    0.001,
+                    100000.0
+                ],
+                "shaderParameters": [
+                    {
+                        "name": "m_emissiveIntensity",
+                        "type": "float"
+                    }
+                ]
             }
             }
         },
         },
         {
         {

+ 15 - 1
Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/SubsurfaceAndTransmissionPropertyGroup.json

@@ -226,7 +226,21 @@
                 "scatterDistanceIntensity": "scatterDistance",
                 "scatterDistanceIntensity": "scatterDistance",
                 "scatterDistanceShaderInput": "m_scatterDistance",
                 "scatterDistanceShaderInput": "m_scatterDistance",
                 "parametersShaderInput": "m_transmissionParams",
                 "parametersShaderInput": "m_transmissionParams",
-                "tintThickenssShaderInput": "m_transmissionTintThickness"
+                "tintThickenssShaderInput": "m_transmissionTintThickness",
+                "shaderParameters": [
+                    {
+                        "name": "m_scatterDistance",
+                        "type": "float3"
+                    },
+                    {
+                        "name": "m_transmissionParams",
+                        "type": "float4"
+                    },
+                    {
+                        "name": "m_transmissionTintThickness",
+                        "type": "float4"
+                    }
+                ]
             }
             }
         },
         },
         {
         {

+ 11 - 1
Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/UvPropertyGroup.json

@@ -78,7 +78,17 @@
                 "translateYProperty": "offsetV",
                 "translateYProperty": "offsetV",
                 "rotateDegreesProperty": "rotateDegrees",
                 "rotateDegreesProperty": "rotateDegrees",
                 "float3x3ShaderInput": "m_uvMatrix",
                 "float3x3ShaderInput": "m_uvMatrix",
-                "float3x3InverseShaderInput": "m_uvMatrixInverse"
+                "float3x3InverseShaderInput": "m_uvMatrixInverse",
+                "shaderParameters": [
+                    {
+                        "name": "m_uvMatrix",
+                        "type": "float3x3"
+                    },
+                    {
+                        "name": "m_uvMatrixInverse",
+                        "type": "float3x3"
+                    }
+                ]
             }
             }
         }
         }
     ]
     ]

+ 7 - 2
Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsli

@@ -6,12 +6,17 @@
  *
  *
  */
  */
     
     
-//TODO(MaterialPipeline): Inline the MaterialSrg files since they aren't reused.
-#include <Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_MaterialSrg.azsli>
+#include <scenesrg_all.srgi>
 
 
 #include <Atom/Features/Skin/SkinObjectSrg.azsli>
 #include <Atom/Features/Skin/SkinObjectSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 
 
+// This file contains the definition for 'struct MaterialParameters', which is generated by the Materialpipeline
+#include MATERIAL_PARAMETERS_AZSLI_FILE_PATH
+#include <Atom/Features/Materials/MaterialSrg.azsli>
+
+#include <Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_MaterialInputs.azsli>
+
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 
 
     COMMON_OPTIONS_BASE_COLOR()
     COMMON_OPTIONS_BASE_COLOR()

+ 51 - 40
Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.azsli

@@ -74,6 +74,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexEval.azsli>
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexEval.azsli>
     
     
     VsOutput EvaluateVertexGeometry_StandardMultilayerPBR(
     VsOutput EvaluateVertexGeometry_StandardMultilayerPBR(
+        const MaterialParameters params,
         float3 position,
         float3 position,
         float3 normal,
         float3 normal,
         float4 tangent,
         float4 tangent,
@@ -83,7 +84,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         uint instanceId,
         uint instanceId,
         bool useVertexBlendMask)
         bool useVertexBlendMask)
     {
     {
-        VsOutput output = EvaluateVertexGeometry_BasePBR(position, normal, tangent, uv0, uv1, instanceId, false, float4(1.0f, 1.0f, 1.0f, 1.0f));
+        VsOutput output = EvaluateVertexGeometry_BasePBR(params, position, normal, tangent, uv0, uv1, instanceId, false, float4(1.0f, 1.0f, 1.0f, 1.0f));
 
 
         if(useVertexBlendMask)
         if(useVertexBlendMask)
         {
         {
@@ -101,6 +102,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
     // Avoids compilation errors for compute shaders, listed in a materialpipeline,
     // Avoids compilation errors for compute shaders, listed in a materialpipeline,
     // that call EvaluateVertexGeometry().
     // that call EvaluateVertexGeometry().
     VsOutput EvaluateVertexGeometry_StandardMultilayerPBR(
     VsOutput EvaluateVertexGeometry_StandardMultilayerPBR(
+        const MaterialParameters params,
         float3 position,
         float3 position,
         float3 normal,
         float3 normal,
         float4 tangent,
         float4 tangent,
@@ -108,12 +110,13 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         float2 uv1_unwrapped,
         float2 uv1_unwrapped,
         uint instanceId)
         uint instanceId)
     {
     {
-        return EvaluateVertexGeometry_StandardMultilayerPBR(position, normal, tangent, uv0_tiled, uv1_unwrapped, float3(0, 0, 0), instanceId, false);
+        return EvaluateVertexGeometry_StandardMultilayerPBR(params, position, normal, tangent, uv0_tiled, uv1_unwrapped, float3(0, 0, 0), instanceId, false);
     }
     }
 
 
-    VsOutput EvaluateVertexGeometry_StandardMultilayerPBR(VsInput IN, VsSystemValues SV)
+    VsOutput EvaluateVertexGeometry_StandardMultilayerPBR(VsInput IN, VsSystemValues SV, const MaterialParameters params)
     {
     {
         return EvaluateVertexGeometry_StandardMultilayerPBR(
         return EvaluateVertexGeometry_StandardMultilayerPBR(
+            params,
             IN.position,
             IN.position,
             IN.normal,
             IN.normal,
             IN.tangent,
             IN.tangent,
@@ -143,6 +146,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
     bool ShouldHandleParallax();
     bool ShouldHandleParallax();
 
 
     PixelGeometryData EvaluatePixelGeometry_StandardMultilayerPBR(
     PixelGeometryData EvaluatePixelGeometry_StandardMultilayerPBR(
+        const MaterialParameters params,
         inout float4 positionSV,
         inout float4 positionSV,
         float3 positionWS,
         float3 positionWS,
         real3 normalWS,
         real3 normalWS,
@@ -153,7 +157,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         real4x4 objectToWorld,
         real4x4 objectToWorld,
         real3 vertexBlendMask)
         real3 vertexBlendMask)
     {
     {
-        PixelGeometryData geoData = EvaluatePixelGeometry_BasePBR(positionWS, normalWS, tangentWS, bitangentWS, uvs, isFrontFace);
+        PixelGeometryData geoData = EvaluatePixelGeometry_BasePBR(params, positionWS, normalWS, tangentWS, bitangentWS, uvs, isFrontFace);
 
 
         geoData.isDisplacementClipped = false;
         geoData.isDisplacementClipped = false;
         geoData.m_vertexBlendMask = vertexBlendMask;
         geoData.m_vertexBlendMask = vertexBlendMask;
@@ -161,14 +165,14 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
 #if ENABLE_PARALLAX
 #if ENABLE_PARALLAX
         if(ShouldHandleParallax())
         if(ShouldHandleParallax())
         {
         {
-            MultilayerSetPixelDepth(vertexBlendMask, geoData.positionWS, geoData.vertexNormal, geoData.tangents, geoData.bitangents,
+            MultilayerSetPixelDepth(params, vertexBlendMask, geoData.positionWS, geoData.vertexNormal, geoData.tangents, geoData.bitangents,
                 geoData.uvs, isFrontFace, objectToWorld, positionSV.z, positionSV.w, geoData.isDisplacementClipped);
                 geoData.uvs, isFrontFace, objectToWorld, positionSV.z, positionSV.w, geoData.isDisplacementClipped);
         }
         }
 #endif
 #endif
         return geoData;
         return geoData;
     }
     }
     
     
-    PixelGeometryData EvaluatePixelGeometry_StandardMultilayerPBR(inout VsOutput IN, bool isFrontFace)
+    PixelGeometryData EvaluatePixelGeometry_StandardMultilayerPBR(inout VsOutput IN, bool isFrontFace, const MaterialParameters params)
     {
     {
         real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
         real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
         real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
         real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
@@ -177,6 +181,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
         ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
 
         return EvaluatePixelGeometry_StandardMultilayerPBR(
         return EvaluatePixelGeometry_StandardMultilayerPBR(
+            params,
             IN.position,
             IN.position,
             IN.worldPosition,
             IN.worldPosition,
             normalWS,
             normalWS,
@@ -333,11 +338,11 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         result.m_baseColor = BlendBaseColor(sampledBaseColor, real3(inputs.m_baseColor.rgb), real(inputs.m_baseColorFactor), inputs.m_baseColorTextureBlendMode, inputs.m_baseColor_useTexture);
         result.m_baseColor = BlendBaseColor(sampledBaseColor, real3(inputs.m_baseColor.rgb), real(inputs.m_baseColorFactor), inputs.m_baseColorTextureBlendMode, inputs.m_baseColor_useTexture);
         result.m_specularF0Factor = GetSpecularInput(inputs.m_specularF0Map, inputs.m_sampler, transformedUv[inputs.m_specularF0MapUvIndex], real(inputs.m_specularF0Factor), inputs.m_specularF0_useTexture, uvDxDy, customDerivatives);
         result.m_specularF0Factor = GetSpecularInput(inputs.m_specularF0Map, inputs.m_sampler, transformedUv[inputs.m_specularF0MapUvIndex], real(inputs.m_specularF0Factor), inputs.m_specularF0_useTexture, uvDxDy, customDerivatives);
         result.m_metallic = GetMetallicInput(inputs.m_metallicMap, inputs.m_sampler, transformedUv[inputs.m_metallicMapUvIndex], real(inputs.m_metallicFactor), inputs.m_metallic_useTexture, uvDxDy, customDerivatives);
         result.m_metallic = GetMetallicInput(inputs.m_metallicMap, inputs.m_sampler, transformedUv[inputs.m_metallicMapUvIndex], real(inputs.m_metallicFactor), inputs.m_metallic_useTexture, uvDxDy, customDerivatives);
-        result.m_roughness = GetRoughnessInput(inputs.m_roughnessMap, MaterialSrg::m_sampler, transformedUv[inputs.m_roughnessMapUvIndex], real(inputs.m_roughnessFactor), real(inputs.m_roughnessLowerBound), real(inputs.m_roughnessUpperBound), inputs.m_roughness_useTexture, uvDxDy, customDerivatives);
+        result.m_roughness = GetRoughnessInput(inputs.m_roughnessMap, GetMaterialTextureSampler(), transformedUv[inputs.m_roughnessMapUvIndex], real(inputs.m_roughnessFactor), real(inputs.m_roughnessLowerBound), real(inputs.m_roughnessUpperBound), inputs.m_roughness_useTexture, uvDxDy, customDerivatives);
 
 
         result.m_emissiveLighting = GetEmissiveInput(inputs.m_emissiveMap, inputs.m_sampler, transformedUv[inputs.m_emissiveMapUvIndex], real(inputs.m_emissiveIntensity), real3(inputs.m_emissiveColor.rgb), 0.0, 1.0, inputs.m_emissiveEnabled, inputs.m_emissive_useTexture, uvDxDy, customDerivatives);
         result.m_emissiveLighting = GetEmissiveInput(inputs.m_emissiveMap, inputs.m_sampler, transformedUv[inputs.m_emissiveMapUvIndex], real(inputs.m_emissiveIntensity), real3(inputs.m_emissiveColor.rgb), 0.0, 1.0, inputs.m_emissiveEnabled, inputs.m_emissive_useTexture, uvDxDy, customDerivatives);
         result.m_diffuseAmbientOcclusion = GetOcclusionInput(inputs.m_diffuseOcclusionMap, inputs.m_sampler, transformedUv[inputs.m_diffuseOcclusionMapUvIndex], real(inputs.m_diffuseOcclusionFactor), inputs.m_diffuseOcclusion_useTexture, uvDxDy, customDerivatives);
         result.m_diffuseAmbientOcclusion = GetOcclusionInput(inputs.m_diffuseOcclusionMap, inputs.m_sampler, transformedUv[inputs.m_diffuseOcclusionMapUvIndex], real(inputs.m_diffuseOcclusionFactor), inputs.m_diffuseOcclusion_useTexture, uvDxDy, customDerivatives);
-        result.m_specularOcclusion = GetOcclusionInput(inputs.m_specularOcclusionMap, MaterialSrg::m_sampler, transformedUv[inputs.m_specularOcclusionMapUvIndex], real(inputs.m_specularOcclusionFactor), inputs.m_specularOcclusion_useTexture, uvDxDy, customDerivatives);
+        result.m_specularOcclusion = GetOcclusionInput(inputs.m_specularOcclusionMap, GetMaterialTextureSampler(), transformedUv[inputs.m_specularOcclusionMapUvIndex], real(inputs.m_specularOcclusionFactor), inputs.m_specularOcclusion_useTexture, uvDxDy, customDerivatives);
     
     
     #if ENABLE_CLEAR_COAT
     #if ENABLE_CLEAR_COAT
         result.m_clearCoat.InitializeToZero();
         result.m_clearCoat.InitializeToZero();
@@ -359,7 +364,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
 
 
     //! Fills a StandardMaterialInputs struct with data from the MaterialSrg, shader options, and local vertex data.
     //! Fills a StandardMaterialInputs struct with data from the MaterialSrg, shader options, and local vertex data.
     #define FILL_STANDARD_MATERIAL_INPUTS(inputs, srgLayerPrefix, optionsLayerPrefix, blendWeight)                     \
     #define FILL_STANDARD_MATERIAL_INPUTS(inputs, srgLayerPrefix, optionsLayerPrefix, blendWeight)                     \
-        inputs.m_sampler = MaterialSrg::m_sampler;                                                                     \
+        inputs.m_sampler = GetMaterialTextureSampler();                                                                     \
         inputs.m_vertexUv = uvs;                                                                                       \
         inputs.m_vertexUv = uvs;                                                                                       \
         inputs.m_uvMatrix = srgLayerPrefix##m_uvMatrix;                                                                \
         inputs.m_uvMatrix = srgLayerPrefix##m_uvMatrix;                                                                \
         inputs.m_normal = normalWS;                                                                                \
         inputs.m_normal = normalWS;                                                                                \
@@ -368,46 +373,46 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         inputs.m_isFrontFace = isFrontFace;                                                                            \
         inputs.m_isFrontFace = isFrontFace;                                                                            \
                                                                                                                        \
                                                                                                                        \
         inputs.m_normalMapUvIndex = srgLayerPrefix##m_normalMapUvIndex;                                                \
         inputs.m_normalMapUvIndex = srgLayerPrefix##m_normalMapUvIndex;                                                \
-        inputs.m_normalMap = srgLayerPrefix##m_normalMap;                                                              \
+        inputs.m_normalMap = GetMaterialTexture(srgLayerPrefix##m_normalMap);                                                              \
         inputs.m_flipNormalX = srgLayerPrefix##m_flipNormalX;                                                          \
         inputs.m_flipNormalX = srgLayerPrefix##m_flipNormalX;                                                          \
         inputs.m_flipNormalY = srgLayerPrefix##m_flipNormalY;                                                          \
         inputs.m_flipNormalY = srgLayerPrefix##m_flipNormalY;                                                          \
         inputs.m_normal_useTexture = optionsLayerPrefix##o_normal_useTexture;                                          \
         inputs.m_normal_useTexture = optionsLayerPrefix##o_normal_useTexture;                                          \
         inputs.m_normalFactor = srgLayerPrefix##m_normalFactor * blendWeight;                                          \
         inputs.m_normalFactor = srgLayerPrefix##m_normalFactor * blendWeight;                                          \
-        inputs.m_baseColorMap = srgLayerPrefix##m_baseColorMap;                                                        \
+        inputs.m_baseColorMap = GetMaterialTexture(srgLayerPrefix##m_baseColorMap);                                                        \
         inputs.m_baseColorMapUvIndex = srgLayerPrefix##m_baseColorMapUvIndex;                                          \
         inputs.m_baseColorMapUvIndex = srgLayerPrefix##m_baseColorMapUvIndex;                                          \
-        inputs.m_baseColor = srgLayerPrefix##m_baseColor;                                                              \
+        inputs.m_baseColor = srgLayerPrefix##m_baseColor.rgb;                                                              \
         inputs.m_baseColor_useTexture = optionsLayerPrefix##o_baseColor_useTexture;                                    \
         inputs.m_baseColor_useTexture = optionsLayerPrefix##o_baseColor_useTexture;                                    \
         inputs.m_baseColorFactor = srgLayerPrefix##m_baseColorFactor;                                                  \
         inputs.m_baseColorFactor = srgLayerPrefix##m_baseColorFactor;                                                  \
         inputs.m_baseColorTextureBlendMode = optionsLayerPrefix##o_baseColorTextureBlendMode;                          \
         inputs.m_baseColorTextureBlendMode = optionsLayerPrefix##o_baseColorTextureBlendMode;                          \
-        inputs.m_metallicMap = srgLayerPrefix##m_metallicMap;                                                          \
+        inputs.m_metallicMap = GetMaterialTexture(srgLayerPrefix##m_metallicMap);                                                          \
         inputs.m_metallicMapUvIndex = srgLayerPrefix##m_metallicMapUvIndex;                                            \
         inputs.m_metallicMapUvIndex = srgLayerPrefix##m_metallicMapUvIndex;                                            \
         inputs.m_metallicFactor = srgLayerPrefix##m_metallicFactor;                                                    \
         inputs.m_metallicFactor = srgLayerPrefix##m_metallicFactor;                                                    \
         inputs.m_metallic_useTexture = optionsLayerPrefix##o_metallic_useTexture;                                      \
         inputs.m_metallic_useTexture = optionsLayerPrefix##o_metallic_useTexture;                                      \
-        inputs.m_specularF0Map = srgLayerPrefix##m_specularF0Map;                                                      \
+        inputs.m_specularF0Map = GetMaterialTexture(srgLayerPrefix##m_specularF0Map);                                                      \
         inputs.m_specularF0MapUvIndex = srgLayerPrefix##m_specularF0MapUvIndex;                                        \
         inputs.m_specularF0MapUvIndex = srgLayerPrefix##m_specularF0MapUvIndex;                                        \
         inputs.m_specularF0Factor = srgLayerPrefix##m_specularF0Factor;                                                \
         inputs.m_specularF0Factor = srgLayerPrefix##m_specularF0Factor;                                                \
         inputs.m_specularF0_useTexture = optionsLayerPrefix##o_specularF0_useTexture;                                  \
         inputs.m_specularF0_useTexture = optionsLayerPrefix##o_specularF0_useTexture;                                  \
-        inputs.m_roughnessMap = srgLayerPrefix##m_roughnessMap;                                                        \
+        inputs.m_roughnessMap = GetMaterialTexture(srgLayerPrefix##m_roughnessMap);                                                        \
         inputs.m_roughnessMapUvIndex = srgLayerPrefix##m_roughnessMapUvIndex;                                          \
         inputs.m_roughnessMapUvIndex = srgLayerPrefix##m_roughnessMapUvIndex;                                          \
         inputs.m_roughnessFactor = srgLayerPrefix##m_roughnessFactor;                                                  \
         inputs.m_roughnessFactor = srgLayerPrefix##m_roughnessFactor;                                                  \
         inputs.m_roughnessLowerBound = srgLayerPrefix##m_roughnessLowerBound;                                          \
         inputs.m_roughnessLowerBound = srgLayerPrefix##m_roughnessLowerBound;                                          \
         inputs.m_roughnessUpperBound = srgLayerPrefix##m_roughnessUpperBound;                                          \
         inputs.m_roughnessUpperBound = srgLayerPrefix##m_roughnessUpperBound;                                          \
         inputs.m_roughness_useTexture = optionsLayerPrefix##o_roughness_useTexture;                                    \
         inputs.m_roughness_useTexture = optionsLayerPrefix##o_roughness_useTexture;                                    \
                                                                                                                        \
                                                                                                                        \
-        inputs.m_emissiveMap = srgLayerPrefix##m_emissiveMap;                                                          \
+        inputs.m_emissiveMap = GetMaterialTexture(srgLayerPrefix##m_emissiveMap);                                                          \
         inputs.m_emissiveMapUvIndex = srgLayerPrefix##m_emissiveMapUvIndex;                                            \
         inputs.m_emissiveMapUvIndex = srgLayerPrefix##m_emissiveMapUvIndex;                                            \
         inputs.m_emissiveIntensity = srgLayerPrefix##m_emissiveIntensity;                                              \
         inputs.m_emissiveIntensity = srgLayerPrefix##m_emissiveIntensity;                                              \
-        inputs.m_emissiveColor = srgLayerPrefix##m_emissiveColor;                                                      \
+        inputs.m_emissiveColor = srgLayerPrefix##m_emissiveColor.rgb;                                                      \
         inputs.m_emissiveAffectedByAlpha = srgLayerPrefix##m_emissiveAffectedByAlpha;                                  \
         inputs.m_emissiveAffectedByAlpha = srgLayerPrefix##m_emissiveAffectedByAlpha;                                  \
         inputs.m_emissiveEnabled = optionsLayerPrefix##o_emissiveEnabled;                                              \
         inputs.m_emissiveEnabled = optionsLayerPrefix##o_emissiveEnabled;                                              \
         inputs.m_emissive_useTexture = optionsLayerPrefix##o_emissive_useTexture;                                      \
         inputs.m_emissive_useTexture = optionsLayerPrefix##o_emissive_useTexture;                                      \
                                                                                                                        \
                                                                                                                        \
-        inputs.m_diffuseOcclusionMap = srgLayerPrefix##m_diffuseOcclusionMap;                                          \
+        inputs.m_diffuseOcclusionMap = GetMaterialTexture(srgLayerPrefix##m_diffuseOcclusionMap);                                          \
         inputs.m_diffuseOcclusionMapUvIndex = srgLayerPrefix##m_diffuseOcclusionMapUvIndex;                            \
         inputs.m_diffuseOcclusionMapUvIndex = srgLayerPrefix##m_diffuseOcclusionMapUvIndex;                            \
         inputs.m_diffuseOcclusionFactor = srgLayerPrefix##m_diffuseOcclusionFactor;                                    \
         inputs.m_diffuseOcclusionFactor = srgLayerPrefix##m_diffuseOcclusionFactor;                                    \
         inputs.m_diffuseOcclusion_useTexture = optionsLayerPrefix##o_diffuseOcclusion_useTexture;                      \
         inputs.m_diffuseOcclusion_useTexture = optionsLayerPrefix##o_diffuseOcclusion_useTexture;                      \
                                                                                                                        \
                                                                                                                        \
-        inputs.m_specularOcclusionMap = srgLayerPrefix##m_specularOcclusionMap;                                        \
+        inputs.m_specularOcclusionMap = GetMaterialTexture(srgLayerPrefix##m_specularOcclusionMap);                                        \
         inputs.m_specularOcclusionMapUvIndex = srgLayerPrefix##m_specularOcclusionMapUvIndex;                          \
         inputs.m_specularOcclusionMapUvIndex = srgLayerPrefix##m_specularOcclusionMapUvIndex;                          \
         inputs.m_specularOcclusionFactor = srgLayerPrefix##m_specularOcclusionFactor;                                  \
         inputs.m_specularOcclusionFactor = srgLayerPrefix##m_specularOcclusionFactor;                                  \
         inputs.m_specularOcclusion_useTexture = optionsLayerPrefix##o_specularOcclusion_useTexture;                    
         inputs.m_specularOcclusion_useTexture = optionsLayerPrefix##o_specularOcclusion_useTexture;                    
@@ -416,15 +421,15 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
     #if ENABLE_CLEAR_COAT
     #if ENABLE_CLEAR_COAT
     #define FILL_STANDARD_MATERIAL_INPUTS_CLEAR_COAT(inputs, srgLayerPrefix, optionsLayerPrefix, blendWeight)        \
     #define FILL_STANDARD_MATERIAL_INPUTS_CLEAR_COAT(inputs, srgLayerPrefix, optionsLayerPrefix, blendWeight)        \
         inputs.m_clearCoatEnabled = o_clearCoat_feature_enabled && optionsLayerPrefix##o_clearCoat_enabled;          \
         inputs.m_clearCoatEnabled = o_clearCoat_feature_enabled && optionsLayerPrefix##o_clearCoat_enabled;          \
-        inputs.m_clearCoatInfluenceMap = srgLayerPrefix##m_clearCoatInfluenceMap;                                    \
+        inputs.m_clearCoatInfluenceMap = GetMaterialTexture(srgLayerPrefix##m_clearCoatInfluenceMap);                                    \
         inputs.m_clearCoatInfluenceMapUvIndex = srgLayerPrefix##m_clearCoatInfluenceMapUvIndex;                      \
         inputs.m_clearCoatInfluenceMapUvIndex = srgLayerPrefix##m_clearCoatInfluenceMapUvIndex;                      \
         inputs.m_clearCoatFactor = srgLayerPrefix##m_clearCoatFactor;                                                \
         inputs.m_clearCoatFactor = srgLayerPrefix##m_clearCoatFactor;                                                \
         inputs.m_clearCoat_factor_useTexture = optionsLayerPrefix##o_clearCoat_factor_useTexture;                    \
         inputs.m_clearCoat_factor_useTexture = optionsLayerPrefix##o_clearCoat_factor_useTexture;                    \
-        inputs.m_clearCoatRoughnessMap = srgLayerPrefix##m_clearCoatRoughnessMap;                                    \
+        inputs.m_clearCoatRoughnessMap = GetMaterialTexture(srgLayerPrefix##m_clearCoatRoughnessMap);                                    \
         inputs.m_clearCoatRoughnessMapUvIndex = srgLayerPrefix##m_clearCoatRoughnessMapUvIndex;                      \
         inputs.m_clearCoatRoughnessMapUvIndex = srgLayerPrefix##m_clearCoatRoughnessMapUvIndex;                      \
         inputs.m_clearCoatRoughness = srgLayerPrefix##m_clearCoatRoughness;                                          \
         inputs.m_clearCoatRoughness = srgLayerPrefix##m_clearCoatRoughness;                                          \
         inputs.m_clearCoat_roughness_useTexture = optionsLayerPrefix##o_clearCoat_roughness_useTexture;              \
         inputs.m_clearCoat_roughness_useTexture = optionsLayerPrefix##o_clearCoat_roughness_useTexture;              \
-        inputs.m_clearCoatNormalMap = srgLayerPrefix##m_clearCoatNormalMap;                                          \
+        inputs.m_clearCoatNormalMap = GetMaterialTexture(srgLayerPrefix##m_clearCoatNormalMap);                                          \
         inputs.m_clearCoatNormalMapUvIndex = srgLayerPrefix##m_clearCoatNormalMapUvIndex;                            \
         inputs.m_clearCoatNormalMapUvIndex = srgLayerPrefix##m_clearCoatNormalMapUvIndex;                            \
         inputs.m_clearCoat_normal_useTexture = optionsLayerPrefix##o_clearCoat_normal_useTexture;                    \
         inputs.m_clearCoat_normal_useTexture = optionsLayerPrefix##o_clearCoat_normal_useTexture;                    \
         inputs.m_clearCoatNormalStrength = srgLayerPrefix##m_clearCoatNormalStrength;
         inputs.m_clearCoatNormalStrength = srgLayerPrefix##m_clearCoatNormalStrength;
@@ -435,6 +440,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
     #include <Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_SurfaceData.azsli>
     #include <Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_SurfaceData.azsli>
 
 
     Surface EvaluateSurface_StandardMultilayerPBR(
     Surface EvaluateSurface_StandardMultilayerPBR(
+        const MaterialParameters params,
         float3 positionWS,
         float3 positionWS,
         float3 normalWS,
         float3 normalWS,
         float3 tangents[UvSetCount],
         float3 tangents[UvSetCount],
@@ -452,15 +458,16 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
 
 
         if(o_debugDrawMode == DebugDrawMode::BlendMask)
         if(o_debugDrawMode == DebugDrawMode::BlendMask)
         {
         {
-            real3 blendMaskValues = GetApplicableBlendMaskValues(blendSource, uvs[MaterialSrg::m_blendMaskUvIndex], vertexBlendMask, uvDxDy, customDerivatives);
+            real3 blendMaskValues = GetApplicableBlendMaskValues(params, blendSource, uvs[params.m_blendMaskUvIndex], vertexBlendMask, uvDxDy, customDerivatives);
             return MakeDebugSurface(positionWS, normalWS, real3(blendMaskValues));
             return MakeDebugSurface(positionWS, normalWS, real3(blendMaskValues));
         }
         }
     
     
         if(o_debugDrawMode == DebugDrawMode::Displacement)
         if(o_debugDrawMode == DebugDrawMode::Displacement)
         {
         {
-            real startDepth = real(-MaterialSrg::m_displacementMax);
-            real stopDepth = real(-MaterialSrg::m_displacementMin);
-            real depth = GetNormalizedDepth(startDepth, stopDepth, uvs[MaterialSrg::m_parallaxUvIndex], real2(0,0), real2(0,0));
+            real startDepth = real(-params.m_displacementMax);
+            real stopDepth = real(-params.m_displacementMin);
+            // the heightmap and sampler doesn't matter here, since they will simply be passed on to the GetDepth() - function in StandardMultiLayerPBR_Common.azsli, which ignores them.
+            real depth = GetNormalizedDepth(GetMaterialTexture(params.m_layer1_m_heightmap), GetMaterialTextureSampler(), startDepth, stopDepth, uvs[params.m_parallaxUvIndex], real2(0,0), real2(0,0));
             real height = 1 - saturate(depth);
             real height = 1 - saturate(depth);
             return MakeDebugSurface(positionWS, normalWS, real3(height,height,height));
             return MakeDebugSurface(positionWS, normalWS, real3(height,height,height));
         }
         }
@@ -470,11 +477,11 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
             real3 blendWeights;
             real3 blendWeights;
             if (customDerivatives)
             if (customDerivatives)
             {
             {
-                blendWeights = GetBlendWeights(blendSource, uvs[MaterialSrg::m_blendMaskUvIndex], vertexBlendMask, uvDxDy, customDerivatives);
+                blendWeights = GetBlendWeights(params, blendSource, uvs[params.m_blendMaskUvIndex], vertexBlendMask, uvDxDy, customDerivatives);
             }
             }
             else
             else
             {
             {
-                blendWeights = GetBlendWeights(blendSource, uvs[MaterialSrg::m_blendMaskUvIndex], vertexBlendMask, float4(0.0f, 0.0f, 0.0f, 0.0f), false);
+                blendWeights = GetBlendWeights(params, blendSource, uvs[params.m_blendMaskUvIndex], vertexBlendMask, float4(0.0f, 0.0f, 0.0f, 0.0f), false);
             }
             }
             return MakeDebugSurface(positionWS, normalWS, real3(blendWeights));
             return MakeDebugSurface(positionWS, normalWS, real3(blendWeights));
         }
         }
@@ -485,11 +492,11 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         real3 blendWeights;
         real3 blendWeights;
         if (customDerivatives)
         if (customDerivatives)
         {
         {
-            blendWeights = real3(GetBlendWeights(blendSource, uvs[MaterialSrg::m_blendMaskUvIndex], vertexBlendMask, uvDxDy, customDerivatives));
+            blendWeights = real3(GetBlendWeights(params, blendSource, uvs[params.m_blendMaskUvIndex], vertexBlendMask, uvDxDy, customDerivatives));
         }
         }
         else
         else
         {
         {
-            blendWeights = real3(GetBlendWeights(blendSource, uvs[MaterialSrg::m_blendMaskUvIndex], vertexBlendMask, float4(0.0f, 0.0f, 0.0f, 0.0f), false));
+            blendWeights = real3(GetBlendWeights(params, blendSource, uvs[params.m_blendMaskUvIndex], vertexBlendMask, float4(0.0f, 0.0f, 0.0f, 0.0f), false));
         }
         }
         
         
         
         
@@ -499,8 +506,8 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         if(blendWeights.r > 0)
         if(blendWeights.r > 0)
         {
         {
             StandardMaterialInputs inputs;
             StandardMaterialInputs inputs;
-            FILL_STANDARD_MATERIAL_INPUTS(inputs, MaterialSrg::m_layer1_, o_layer1_, blendWeights.r)
-            FILL_STANDARD_MATERIAL_INPUTS_CLEAR_COAT(inputs, MaterialSrg::m_layer1_, o_layer1_, blendWeights.r)
+            FILL_STANDARD_MATERIAL_INPUTS(inputs, params.m_layer1_, o_layer1_, blendWeights.r)
+            FILL_STANDARD_MATERIAL_INPUTS_CLEAR_COAT(inputs, params.m_layer1_, o_layer1_, blendWeights.r)
             lightingInputLayer1 = ProcessStandardMaterialInputs(inputs, uvDxDy, customDerivatives);
             lightingInputLayer1 = ProcessStandardMaterialInputs(inputs, uvDxDy, customDerivatives);
         }
         }
         else
         else
@@ -515,8 +522,8 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         if(o_layer2_enabled && blendWeights.g > 0)
         if(o_layer2_enabled && blendWeights.g > 0)
         {
         {
             StandardMaterialInputs inputs;
             StandardMaterialInputs inputs;
-            FILL_STANDARD_MATERIAL_INPUTS(inputs, MaterialSrg::m_layer2_, o_layer2_, blendWeights.g)
-            FILL_STANDARD_MATERIAL_INPUTS_CLEAR_COAT(inputs, MaterialSrg::m_layer2_, o_layer2_, blendWeights.g)
+            FILL_STANDARD_MATERIAL_INPUTS(inputs, params.m_layer2_, o_layer2_, blendWeights.g)
+            FILL_STANDARD_MATERIAL_INPUTS_CLEAR_COAT(inputs, params.m_layer2_, o_layer2_, blendWeights.g)
             lightingInputLayer2 = ProcessStandardMaterialInputs(inputs, uvDxDy, customDerivatives);
             lightingInputLayer2 = ProcessStandardMaterialInputs(inputs, uvDxDy, customDerivatives);
         }
         }
         else
         else
@@ -531,8 +538,8 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         if(o_layer3_enabled && blendWeights.b > 0)
         if(o_layer3_enabled && blendWeights.b > 0)
         {
         {
             StandardMaterialInputs inputs;
             StandardMaterialInputs inputs;
-            FILL_STANDARD_MATERIAL_INPUTS(inputs, MaterialSrg::m_layer3_, o_layer3_, blendWeights.b)
-            FILL_STANDARD_MATERIAL_INPUTS_CLEAR_COAT(inputs, MaterialSrg::m_layer3_, o_layer3_, blendWeights.b)
+            FILL_STANDARD_MATERIAL_INPUTS(inputs, params.m_layer3_, o_layer3_, blendWeights.b)
+            FILL_STANDARD_MATERIAL_INPUTS_CLEAR_COAT(inputs, params.m_layer3_, o_layer3_, blendWeights.b)
             lightingInputLayer3 = ProcessStandardMaterialInputs(inputs, uvDxDy, customDerivatives);
             lightingInputLayer3 = ProcessStandardMaterialInputs(inputs, uvDxDy, customDerivatives);
         }
         }
         else
         else
@@ -563,7 +570,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         }
         }
         // [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.
         // [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.vertexNormal = normalWS;
         surface.vertexNormal = normalWS;
-        surface.normal = normalize(TangentSpaceToWorld(normalTS, normalWS, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex]));
+        surface.normal = normalize(TangentSpaceToWorld(normalTS, normalWS, tangents[params.m_parallaxUvIndex], bitangents[params.m_parallaxUvIndex]));
         
         
         // ------- Combine Albedo, roughness, specular, roughness ---------
         // ------- Combine Albedo, roughness, specular, roughness ---------
 
 
@@ -609,6 +616,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
     // helper function to keep compatible with the previous version
     // helper function to keep compatible with the previous version
     // because dxc compiler doesn't allow default parameters on functions with overloads
     // because dxc compiler doesn't allow default parameters on functions with overloads
     Surface EvaluateSurface_StandardMultilayerPBR(
     Surface EvaluateSurface_StandardMultilayerPBR(
+        const MaterialParameters params,
         float3 positionWS,
         float3 positionWS,
         real3 normalWS,
         real3 normalWS,
         float3 tangents[UvSetCount],
         float3 tangents[UvSetCount],
@@ -619,6 +627,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         real3 vertexBlendMask)
         real3 vertexBlendMask)
     {
     {
         return EvaluateSurface_StandardMultilayerPBR(
         return EvaluateSurface_StandardMultilayerPBR(
+            params,
             positionWS,
             positionWS,
             normalWS,
             normalWS,
             tangents,
             tangents,
@@ -631,9 +640,10 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
             false);
             false);
     }
     }
 
 
-    Surface EvaluateSurface_StandardMultilayerPBR(VsOutput IN, PixelGeometryData geoData, float4 uvDxDy, bool customDerivatives)
+    Surface EvaluateSurface_StandardMultilayerPBR(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params, float4 uvDxDy, bool customDerivatives)
     {
     {
         return EvaluateSurface_StandardMultilayerPBR(
         return EvaluateSurface_StandardMultilayerPBR(
+            params,
             geoData.positionWS,
             geoData.positionWS,
             geoData.vertexNormal,
             geoData.vertexNormal,
             geoData.tangents,
             geoData.tangents,
@@ -646,9 +656,10 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
             customDerivatives);
             customDerivatives);
     }
     }
 
 
-    Surface EvaluateSurface_StandardMultilayerPBR(VsOutput IN, PixelGeometryData geoData)
+    Surface EvaluateSurface_StandardMultilayerPBR(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params)
     {
     {
         return EvaluateSurface_StandardMultilayerPBR(
         return EvaluateSurface_StandardMultilayerPBR(
+            params,
             geoData.positionWS,
             geoData.positionWS,
             geoData.vertexNormal,
             geoData.vertexNormal,
             geoData.tangents,
             geoData.tangents,
@@ -675,7 +686,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         return ShouldHandleParallax();
         return ShouldHandleParallax();
     }
     }
     
     
-    void EvaluateSurface(VsOutput IN, PixelGeometryData geoData)
+    void EvaluateSurface(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params)
     {
     {
         // do nothing, this is where alpha clip can be done if it's supported
         // do nothing, this is where alpha clip can be done if it's supported
     }
     }

+ 11 - 1
Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype

@@ -379,7 +379,17 @@
         {
         {
             "type": "Lua",
             "type": "Lua",
             "args": {
             "args": {
-                "file": "Materials/Types/StandardMultilayerPBR_Displacement.lua"
+                "file": "Materials/Types/StandardMultilayerPBR_Displacement.lua",
+                "shaderParameters": [
+                    {
+                        "name": "m_displacementMin",
+                        "type": "float"
+                    },
+                    {
+                        "name": "m_displacementMax",
+                        "type": "float"
+                    }
+                ]
             }
             }
         }
         }
     ],
     ],

+ 2 - 2
Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_Displacement.lua

@@ -148,8 +148,8 @@ end
 
 
 function Process(context)
 function Process(context)
     local heightMinMax = CalcOverallHeightRange(context)
     local heightMinMax = CalcOverallHeightRange(context)
-    context:SetShaderConstant_float("m_displacementMin", heightMinMax[0])
-    context:SetShaderConstant_float("m_displacementMax", heightMinMax[1])
+    context:SetShaderParameterValue_float("m_displacementMin", heightMinMax[0])
+    context:SetShaderParameterValue_float("m_displacementMax", heightMinMax[1])
     
     
     local parallaxFeatureEnabled = context:GetMaterialPropertyValue_bool("parallax.enable")
     local parallaxFeatureEnabled = context:GetMaterialPropertyValue_bool("parallax.enable")
     if parallaxFeatureEnabled then
     if parallaxFeatureEnabled then

+ 7 - 1
Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_LayerProperties.json

@@ -180,7 +180,13 @@
                                 "translateXProperty": "offsetU",
                                 "translateXProperty": "offsetU",
                                 "translateYProperty": "offsetV",
                                 "translateYProperty": "offsetV",
                                 "rotateDegreesProperty": "rotateDegrees",
                                 "rotateDegreesProperty": "rotateDegrees",
-                                "float3x3ShaderInput": "m_uvMatrix"
+                                "float3x3ShaderInput": "m_uvMatrix",
+                                "shaderParameters": [
+                                    {
+                                        "name": "m_uvMatrix",
+                                        "type": "float3x3"
+                                    }
+                                ]
                             }
                             }
                         }
                         }
                     ]
                     ]

+ 13 - 8
Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.azsli

@@ -10,13 +10,18 @@
 
 
 #define ENABLE_VERTEX_COLOR 1
 #define ENABLE_VERTEX_COLOR 1
 
 
-//TODO(MaterialPipeline): Inline the MaterialSrg files since they aren't reused.
+
 //TODO(MaterialPipeline): Try removing different parts of the SRG and see how hard/easy it is to customize the surface function.
 //TODO(MaterialPipeline): Try removing different parts of the SRG and see how hard/easy it is to customize the surface function.
-#include <Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_MaterialSrg.azsli>
 
 
 #include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 
 
+// This file contains the definition for 'struct MaterialParameters', which is generated by the Materialpipeline
+#include MATERIAL_PARAMETERS_AZSLI_FILE_PATH
+#include <Atom/Features/Materials/MaterialSrg.azsli>
+
+#include <Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_MaterialInputs.azsli>
+
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 #if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE
 
 
     COMMON_OPTIONS_BASE_COLOR()
     COMMON_OPTIONS_BASE_COLOR()
@@ -42,9 +47,9 @@
     }
     }
     
     
     // Callback function for ParallaxMapping.azsli
     // Callback function for ParallaxMapping.azsli
-    DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
+    DepthResult GetDepth(Texture2D heightmap, sampler mapSampler, float2 uv, float2 uv_ddx, float2 uv_ddy)
     {
     {
-        return SampleDepthFromHeightmap(MaterialSrg::m_heightmap, MaterialSrg::m_sampler, uv, uv_ddx, uv_ddy);
+        return SampleDepthFromHeightmap(heightmap, mapSampler, uv, uv_ddx, uv_ddy);
     }
     }
 
 
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexData.azsli>
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexData.azsli>
@@ -76,9 +81,9 @@
     }
     }
     
     
     // Callback function for ParallaxMapping.azsli
     // Callback function for ParallaxMapping.azsli
-    DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
+    DepthResult GetDepth(Texture2D heightmap, sampler mapSampler, float2 uv, float2 uv_ddx, float2 uv_ddy)
     {
     {
-        return SampleDepthFromHeightmap(MaterialSrg::m_heightmap, MaterialSrg::m_sampler, uv, uv_ddx, uv_ddy);
+        return SampleDepthFromHeightmap(heightmap, mapSampler, uv, uv_ddx, uv_ddy);
     }
     }
     
     
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexData.azsli>
     #include <Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexData.azsli>
@@ -89,9 +94,9 @@
     
     
     #include "Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardGetAlphaAndClip.azsli"
     #include "Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardGetAlphaAndClip.azsli"
 
 
-    void EvaluateSurface(VsOutput IN, PixelGeometryData geoData)
+    void EvaluateSurface(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params)
     {
     {
-        GetAlphaAndClip(geoData.uvs);
+        GetAlphaAndClip(params, geoData.uvs);
     }
     }
 
 
 #else
 #else

+ 42 - 0
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Materials/MaterialSrg.azsli

@@ -0,0 +1,42 @@
+/*
+ * 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 
+
+// This is a convenience header that includes either the Scene-Material-SRG, which allows access to all parameters of all materials using bindless buffers,
+// or the Single-Material-SRG, which contains the parameters of one material in the constant buffer
+// Either way, this effectively provides the functions 'GetMaterialTexture(const int readIndex)', 'GetMaterialParameters()' and 'GetMaterialTextureSampler()' 
+
+// relevant defines in AzslcPlatformHeader.azsli
+// USE_SINGLE_MATERIAL_SRG
+//      Optionally defined per material: Override to use the single material SRG
+// AZ_TRAITS_MATERIALS_USE_SAMPLER_ARRAY
+//      Allows multiple texture samplers per material-srg.
+// AZ_TRAIT_FORCE_SINGLE_MATERIAL_SRG
+//      Platform override to always use the single material SRG
+// AZ_TRAIT_SINGLE_MATERIAL_USE_TEXTURE_ARRAY
+//      Forces the single material SRG to register the textures in the SRG directly, and use a fixed size array.
+//      Needs to be set together with AZ_TRAIT_REGISTER_TEXTURES_PER_MATERIAL
+//      This is relevant if the platform has no support for bindless resources, and the workarround in the 
+//      BindlessSRG with large fixed-size arrays isn't supported either (e.g. IPhone 10 limits the array size to ~96)
+
+
+// Platform override to always use the single material SRG
+#if defined(AZ_TRAIT_FORCE_SINGLE_MATERIAL_SRG)
+    #ifndef USE_SINGLE_MATERIAL_SRG
+        #define USE_SINGLE_MATERIAL_SRG
+    #endif
+#endif
+
+// Use the Scene-material SRG by default
+#ifdef USE_SINGLE_MATERIAL_SRG
+    #include <Atom/Features/Materials/SingleMaterialSrg.azsli>
+#else
+    #include <Atom/Features/Materials/SceneMaterialSrg.azsli>
+#endif
+

+ 84 - 0
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Materials/SceneMaterialSrg.azsli

@@ -0,0 +1,84 @@
+/*
+ * 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/SrgSemantics.azsli>
+
+#define SCENE_MATERIALS_MAX_SAMPLERS 8
+
+ShaderResourceGroup SceneMaterialSrg : SRG_PerMaterial
+{
+    ByteAddressBuffer m_materialTypeBufferIndices;
+#ifdef AZ_TRAITS_MATERIALS_USE_SAMPLER_ARRAY
+    // sampler 0 is the default linear wrap sampler, the others are initialized by the MaterialSystem as needed
+    Sampler m_samplers[SCENE_MATERIALS_MAX_SAMPLERS];
+#else
+    Sampler m_defaultSampler
+    {
+        AddressU = Wrap;
+        AddressV = Wrap;
+        MinFilter = Linear;
+        MagFilter = Linear;
+        MipFilter = Linear;
+        MaxAnisotropy = 16;
+    };
+#endif
+}
+
+// If we are using the SceneMaterialSrg, we implicitly need BindlessSRG support 
+#include <Atom/Features/Bindless.azsli>
+
+Texture2D GetMaterialTexture(const int readIndex)
+{
+    int localReadIndex = readIndex; 
+    if (localReadIndex < 0)
+    {
+        // TODO: choose a suitable fallback texture here.
+        localReadIndex = 0;
+    }
+    return Bindless::GetTexture2D(readIndex);
+}
+
+const MaterialParameters GetMaterialParameters()
+{
+    // The ByteAddressBuffers referenced in the SceneMaterialSrg hold the MaterialParameters for all MaterialTypes
+    // but any given material-shader knows only it's MaterialParameter - struct.
+    // The first two integers in the MaterialParameter struct are the MaterialType-Id and the MaterialInstanceId:
+    // Load only those and compare the values to the DrawSrg to make sure we are converting the contents of the ByteAddresBuffer
+    // to the correct MaterialParameter struct
+    int materialTypeBufferIndex = int(SceneMaterialSrg::m_materialTypeBufferIndices.Load(ObjectSrg::m_materialTypeId * 4 /* sizeof(int)*/));
+    ByteAddressBuffer materialInstances = Bindless::GetByteAddressBuffer(materialTypeBufferIndex);
+    uint baseOffset = sizeof(MaterialParameters) * ObjectSrg::m_materialInstanceId;
+    uint2 loadedId = materialInstances.Load2(baseOffset);
+    if (loadedId.x != ObjectSrg::m_materialTypeId || loadedId.y != ObjectSrg::m_materialInstanceId)
+    {
+        return (MaterialParameters)0;
+    }
+
+    return materialInstances.Load<MaterialParameters>(sizeof(MaterialParameters) * ObjectSrg::m_materialInstanceId);
+}
+
+// All MaterialProperties with the type TextureSampler are collected from all active Materials and stored in the SceneMaterialSrg::m_samplers array.
+// The Shader - Parameter (in the Srg or the Parameter-Buffer) is then the sampler-index.
+// Note that the size of m_samplers is limited to SCENE_MATERIALS_MAX_SAMPLERS, but samplers are deduplicated based on their settings, so this should
+// be enough.
+// Sampler-Index 0 is always the default Wrap - sampler with linear filtering.
+sampler GetMaterialTextureSampler(const int samplerIndex = 0)
+{
+#ifdef AZ_TRAITS_MATERIALS_USE_SAMPLER_ARRAY
+    int localIndex = samplerIndex;
+    if (samplerIndex >= SCENE_MATERIALS_MAX_SAMPLERS)
+    {
+        localIndex = 0;
+    }
+    return SceneMaterialSrg::m_samplers[localIndex];
+#else
+    return SceneMaterialSrg::m_defaultSampler;
+#endif
+}

+ 93 - 0
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Materials/SingleMaterialSrg.azsli

@@ -0,0 +1,93 @@
+/*
+ * 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/SrgSemantics.azsli>
+
+
+// Note: These limits are arbitrary, but the arrays will exist in the SRG even if they are unused, so try to keep it low.
+#define SINGLE_MATERIAL_MAX_SAMPLERS 4
+#define SINGLE_MATERIAL_MAX_TEXTURES 6
+
+// MaterialSrg for a single Material Instance: The parameters are placed in constant memory.
+// This is either a Fallback if the Bindless SRG isnt supported, or an opt-in: 
+// if neither deferred nor raytracing support is required, accessing constant memory can be faster on some devices
+ShaderResourceGroup MaterialSrg : SRG_PerMaterial
+{
+    MaterialParameters m_params;
+
+#ifdef AZ_TRAIT_SINGLE_MATERIAL_USE_TEXTURE_ARRAY
+    // the MaterialParameters - struct can only contain texture indices, and no Texture2D directly.
+    // if we can't use the bindless SRG at all, we register the Textures in this fixed-size array, and the texture-indices refer to this array 
+    Texture2D m_textures[SINGLE_MATERIAL_MAX_TEXTURES];
+#endif
+
+#ifdef AZ_TRAITS_MATERIALS_USE_SAMPLER_ARRAY
+    // sampler 0 is the default linear clamp sampler, the others are initialized by the MaterialSystem as needed
+    Sampler m_samplers[SINGLE_MATERIAL_MAX_SAMPLERS];
+#else
+    Sampler m_defaultSampler
+    {
+        AddressU = Wrap;
+        AddressV = Wrap;
+        MinFilter = Linear;
+        MagFilter = Linear;
+        MipFilter = Linear;
+        MaxAnisotropy = 16;
+    };
+#endif
+}
+
+#ifndef AZ_TRAIT_SINGLE_MATERIAL_USE_TEXTURE_ARRAY
+#include <Atom/Features/Bindless.azsli>
+#endif
+
+Texture2D GetMaterialTexture(const int readIndex)
+{
+    int localReadIndex = readIndex; 
+    if (localReadIndex < 0)
+    {
+        // TODO: choose a suitable fallback texture here.
+        localReadIndex = 0;
+    }
+#ifdef AZ_TRAIT_SINGLE_MATERIAL_USE_TEXTURE_ARRAY
+    if (localReadIndex >= SINGLE_MATERIAL_MAX_TEXTURES)
+    {
+        localReadIndex = 0;
+    }
+    return MaterialSrg::m_textures[localReadIndex];
+#else
+    return BindlessSrg::GetTexture2D(localReadIndex);
+#endif
+}
+
+const MaterialParameters GetMaterialParameters()
+{
+    return MaterialSrg::m_params;
+}
+
+// All MaterialProperties of the material with the type TextureSampler are collected and stored in the MaterialSrg::m_samplers array.
+// The Shader - Parameter in the m_params - struct is then the samplerIndex.
+// Note that the size of m_samplers is limited to SINGLE_MATERIAL_MAX_SAMPLERS, but samplers are deduplicated based on their settings,
+// so this should be enough.
+// Sampler-Index 0 is always the default Wrap - sampler with linear filtering.
+sampler GetMaterialTextureSampler(const uint samplerIndex = 0)
+{
+#ifdef AZ_TRAITS_MATERIALS_USE_SAMPLER_ARRAY
+    int localIndex = samplerIndex;
+    if (samplerIndex >= SINGLE_MATERIAL_MAX_SAMPLERS)
+    {
+        localIndex = 0;
+    }
+    return MaterialSrg::m_samplers[localIndex];
+#else
+    return MaterialSrg::m_defaultSampler;
+#endif
+}
+

+ 3 - 1
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/DefaultObjectSrg.azsli

@@ -18,7 +18,9 @@
 ShaderResourceGroup ObjectSrg : SRG_PerObject
 ShaderResourceGroup ObjectSrg : SRG_PerObject
 {
 {
     uint m_objectId;
     uint m_objectId;
-
+    int m_materialTypeId;
+    int m_materialInstanceId;
+    
     //! Returns the matrix for transforming points from Object Space to World Space.
     //! Returns the matrix for transforming points from Object Space to World Space.
     float4x4 GetWorldMatrix()
     float4x4 GetWorldMatrix()
     {
     {

+ 27 - 23
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ParallaxMapping.azsli

@@ -59,7 +59,7 @@ DepthResult DepthResultAbsolute(float depth)
 //! @param uv_ddx will be set to ddx_fine(uv)
 //! @param uv_ddx will be set to ddx_fine(uv)
 //! @param uv_ddy will be set to ddy_fine(uv)
 //! @param uv_ddy will be set to ddy_fine(uv)
 //! @return see struct DepthResult
 //! @return see struct DepthResult
-DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy);
+DepthResult GetDepth(Texture2D heightmap, sampler mapSampler, float2 uv, float2 uv_ddx, float2 uv_ddy);
 
 
 //! Convenience function that can be used to implement GetDepth().
 //! Convenience function that can be used to implement GetDepth().
 //! @return see struct DepthResult. In this case it will always contain a Code::Normalized result. 
 //! @return see struct DepthResult. In this case it will always contain a Code::Normalized result. 
@@ -79,7 +79,7 @@ DepthResult SampleDepthFromHeightmap(Texture2D map, sampler mapSampler, float2 u
 //! @param uv_ddx must be set to ddx_fine(uv)
 //! @param uv_ddx must be set to ddx_fine(uv)
 //! @param uv_ddy must be set to ddy_fine(uv)
 //! @param uv_ddy must be set to ddy_fine(uv)
 //! @param a depth value in the range [0,1]
 //! @param a depth value in the range [0,1]
-float GetNormalizedDepth(float startDepth, float stopDepth, float inverseDepthRange, float2 uv, float2 uv_ddx, float2 uv_ddy)
+float GetNormalizedDepth(Texture2D heightmap, sampler mapSampler, float startDepth, float stopDepth, float inverseDepthRange, float2 uv, float2 uv_ddx, float2 uv_ddy)
 {
 {
     // startDepth can be less than 0, representing a displacement above the mesh surface.
     // startDepth can be less than 0, representing a displacement above the mesh surface.
     // But since we don't currently support any vertex displacement, negative depth values would cause various 
     // But since we don't currently support any vertex displacement, negative depth values would cause various 
@@ -88,7 +88,7 @@ float GetNormalizedDepth(float startDepth, float stopDepth, float inverseDepthRa
 
 
     float normalizedDepth = 0.0;
     float normalizedDepth = 0.0;
 
 
-    DepthResult depthResult = GetDepth(uv, uv_ddx, uv_ddy);
+    DepthResult depthResult = GetDepth(heightmap, mapSampler, uv, uv_ddx, uv_ddy);
 
 
     if(stopDepth - startDepth > 0.0001)
     if(stopDepth - startDepth > 0.0001)
     {
     {
@@ -107,10 +107,10 @@ float GetNormalizedDepth(float startDepth, float stopDepth, float inverseDepthRa
     return normalizedDepth;
     return normalizedDepth;
 }
 }
 
 
-float GetNormalizedDepth(float startDepth, float stopDepth, float2 uv, float2 uv_ddx, float2 uv_ddy)
+float GetNormalizedDepth(Texture2D heightmap, sampler mapSampler, float startDepth, float stopDepth, float2 uv, float2 uv_ddx, float2 uv_ddy)
 {
 {
     float inverseDepthRange = 1.0 / (stopDepth - startDepth);
     float inverseDepthRange = 1.0 / (stopDepth - startDepth);
-    return GetNormalizedDepth(startDepth, stopDepth, inverseDepthRange, uv, uv_ddx, uv_ddy);
+    return GetNormalizedDepth(heightmap, mapSampler, startDepth, stopDepth, inverseDepthRange, uv, uv_ddx, uv_ddy);
 }
 }
 
 
 void ApplyParallaxClippingHighlight(inout float3 baseColor)
 void ApplyParallaxClippingHighlight(inout float3 baseColor)
@@ -126,13 +126,13 @@ struct ParallaxOffset
 
 
 // dirToCameraTS should be in tangent space and normalized
 // dirToCameraTS should be in tangent space and normalized
 // From Reat-Time Rendering 3rd edition, p.192
 // From Reat-Time Rendering 3rd edition, p.192
-ParallaxOffset BasicParallaxMapping(float depthFactor, float2 uv, float3 dirToCameraTS)
+ParallaxOffset BasicParallaxMapping(Texture2D heightmap, sampler mapSampler, float depthFactor, float2 uv, float3 dirToCameraTS)
 {
 {
     // the amount to shift
     // the amount to shift
 #ifdef CS_SAMPLERS
 #ifdef CS_SAMPLERS
-    float2 delta = dirToCameraTS.xy * GetNormalizedDepth(0, depthFactor, uv, float2(0, 0), float2(0, 0)) * depthFactor;
+    float2 delta = dirToCameraTS.xy * GetNormalizedDepth(heightmap, mapSampler, 0, depthFactor, uv, float2(0, 0), float2(0, 0)) * depthFactor;
 #else
 #else
-    float2 delta = dirToCameraTS.xy * GetNormalizedDepth(0, depthFactor, uv, ddx_fine(uv), ddy_fine(uv)) * depthFactor;
+    float2 delta = dirToCameraTS.xy * GetNormalizedDepth(heightmap, mapSampler, 0, depthFactor, uv, ddx_fine(uv), ddy_fine(uv)) * depthFactor;
 #endif
 #endif
 
 
     ParallaxOffset result;
     ParallaxOffset result;
@@ -146,6 +146,8 @@ ParallaxOffset BasicParallaxMapping(float depthFactor, float2 uv, float3 dirToCa
 // Performs ray intersection against a surface with a heightmap.
 // Performs ray intersection against a surface with a heightmap.
 // Adapted from CryEngine shader shadelib.cfi and POM function in https://github.com/a-riccardi/shader-toy
 // Adapted from CryEngine shader shadelib.cfi and POM function in https://github.com/a-riccardi/shader-toy
 // check https://github.com/UPBGE/blender/issues/1009 for more details.
 // check https://github.com/UPBGE/blender/issues/1009 for more details.
+// @param heightmap - the heightmap texture.
+// @param mapSampler - the sampler for the heightmap texture.
 // @param depthFactor - scales the heightmap in tangent space units (which normally ends up being world units).
 // @param depthFactor - scales the heightmap in tangent space units (which normally ends up being world units).
 // @param depthOffset - offsets the heighmap up or down in tangent space units (which normally ends up being world units).
 // @param depthOffset - offsets the heighmap up or down in tangent space units (which normally ends up being world units).
 // @param uv - the UV coordinates on the surface, where the search will begin, used to sample the heightmap.
 // @param uv - the UV coordinates on the surface, where the search will begin, used to sample the heightmap.
@@ -153,7 +155,7 @@ ParallaxOffset BasicParallaxMapping(float depthFactor, float2 uv, float3 dirToCa
 // @param dirToLightTS - normalized direction to a light source, in tangent space, for self-shadowing (if enabled via o_parallax_shadow).
 // @param dirToLightTS - normalized direction to a light source, in tangent space, for self-shadowing (if enabled via o_parallax_shadow).
 // @param numSteps - the number of steps to take when marching along the ray searching for intersection.
 // @param numSteps - the number of steps to take when marching along the ray searching for intersection.
 // @param parallaxShadowAttenuation - returns a factor for attenuating a light source, for self-shadowing (if enabled via o_parallax_shadow).
 // @param parallaxShadowAttenuation - returns a factor for attenuating a light source, for self-shadowing (if enabled via o_parallax_shadow).
-ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, float2 uv, float3 dirToCameraTS, float3 dirToLightTS, int numSteps, inout float parallaxShadowAttenuation)
+ParallaxOffset AdvancedParallaxMapping(Texture2D heightmap, sampler mapSampler, float depthFactor, float depthOffset, float2 uv, float3 dirToCameraTS, float3 dirToLightTS, int numSteps, inout float parallaxShadowAttenuation)
 {
 {
     ParallaxOffset result;
     ParallaxOffset result;
     result.m_isClipped = false;
     result.m_isClipped = false;
@@ -183,7 +185,7 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
     float3 parallaxOffset = -dirToCameraTS.xyz * dirToCameraZInverse * depthOffset;
     float3 parallaxOffset = -dirToCameraTS.xyz * dirToCameraZInverse * depthOffset;
     
     
     // Get an initial heightmap sample to start the intersection search, starting at our initial parallaxOffset position.
     // Get an initial heightmap sample to start the intersection search, starting at our initial parallaxOffset position.
-    float currentSample = GetNormalizedDepth(depthSearchStart, depthSearchEnd, inverseDepthFactor, uv + parallaxOffset.xy, ddx_uv, ddy_uv);
+    float currentSample = GetNormalizedDepth(heightmap, mapSampler, depthSearchStart, depthSearchEnd, inverseDepthFactor, uv + parallaxOffset.xy, ddx_uv, ddy_uv);
     float prevSample;
     float prevSample;
     
     
     // Note that when depthOffset > 0, we could actually narrow the search so that instead of going through the entire [depthSearchStart,depthSearchEnd] range
     // Note that when depthOffset > 0, we could actually narrow the search so that instead of going through the entire [depthSearchStart,depthSearchEnd] range
@@ -197,7 +199,7 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
         parallaxOffset += delta;
         parallaxOffset += delta;
                 
                 
         prevSample = currentSample;
         prevSample = currentSample;
-        currentSample = GetNormalizedDepth(depthSearchStart, depthSearchEnd, inverseDepthFactor, uv + parallaxOffset.xy, ddx_uv, ddy_uv);
+        currentSample = GetNormalizedDepth(heightmap, mapSampler, depthSearchStart, depthSearchEnd, inverseDepthFactor, uv + parallaxOffset.xy, ddx_uv, ddy_uv);
     }
     }
 
 
     // Depending on the algorithm, we refine the result of the above search
     // Depending on the algorithm, we refine the result of the above search
@@ -237,7 +239,7 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
                     parallaxOffset += reliefDelta * depthSign;
                     parallaxOffset += reliefDelta * depthSign;
                     currentStep += reliefStep * depthSign;
                     currentStep += reliefStep * depthSign;
 
 
-                    currentSample = GetNormalizedDepth(depthSearchStart, depthSearchEnd, inverseDepthFactor, uv + parallaxOffset.xy, ddx_uv, ddy_uv);
+                    currentSample = GetNormalizedDepth(heightmap, mapSampler, depthSearchStart, depthSearchEnd, inverseDepthFactor, uv + parallaxOffset.xy, ddx_uv, ddy_uv);
                 }
                 }
             }
             }
             break;
             break;
@@ -265,7 +267,7 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
                     parallaxOffset += adjustedDelta;
                     parallaxOffset += adjustedDelta;
                     prevSample = currentSample;
                     prevSample = currentSample;
 
 
-                    currentSample = GetNormalizedDepth(depthSearchStart, depthSearchEnd, inverseDepthFactor, uv + parallaxOffset.xy, ddx_uv, ddy_uv);
+                    currentSample = GetNormalizedDepth(heightmap, mapSampler, depthSearchStart, depthSearchEnd, inverseDepthFactor, uv + parallaxOffset.xy, ddx_uv, ddy_uv);
                 }
                 }
             }
             }
             break;
             break;
@@ -286,7 +288,7 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
         // The most accurate way to report clipping is to sample the heightmap one last time at the final adjusted UV.
         // The most accurate way to report clipping is to sample the heightmap one last time at the final adjusted UV.
         // (trying to do it based on parallaxOffset.z values just leads to too many edge cases)
         // (trying to do it based on parallaxOffset.z values just leads to too many edge cases)
 
 
-        DepthResult depthResult = GetDepth(float2(uv + parallaxOffset.xy), ddx_uv, ddy_uv);
+        DepthResult depthResult = GetDepth(heightmap, mapSampler, float2(uv + parallaxOffset.xy), ddx_uv, ddy_uv);
         
         
         if(DepthResultCode_Normalized == depthResult.m_resultCode)
         if(DepthResultCode_Normalized == depthResult.m_resultCode)
         {
         {
@@ -321,7 +323,7 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
             }
             }
 
 
             shadowUV += shadowDelta;
             shadowUV += shadowDelta;
-            currentSample = GetNormalizedDepth(depthSearchStart, depthSearchEnd, inverseDepthFactor, shadowUV, ddx_uv, ddy_uv);
+            currentSample = GetNormalizedDepth(heightmap, mapSampler, depthSearchStart, depthSearchEnd, inverseDepthFactor, shadowUV, ddx_uv, ddy_uv);
             currentStep -= step;
             currentStep -= step;
         }
         }
 
 
@@ -340,11 +342,11 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
 }
 }
 
 
 // return offset in tangent space
 // return offset in tangent space
-ParallaxOffset CalculateParallaxOffset(float depthFactor, float depthOffset, float2 uv, float3 dirToCameraTS, float3 dirToLightTS, inout float parallaxShadowAttenuation)
+ParallaxOffset CalculateParallaxOffset(Texture2D heightmap, sampler mapSampler, float depthFactor, float depthOffset, float2 uv, float3 dirToCameraTS, float3 dirToLightTS, inout float parallaxShadowAttenuation)
 {
 {
     if(o_parallax_algorithm == ParallaxAlgorithm::Basic)
     if(o_parallax_algorithm == ParallaxAlgorithm::Basic)
     {
     {
-        return BasicParallaxMapping(depthFactor, uv, dirToCameraTS);
+        return BasicParallaxMapping(heightmap, mapSampler, depthFactor, uv, dirToCameraTS);
     }
     }
     else
     else
     {
     {
@@ -352,16 +354,16 @@ ParallaxOffset CalculateParallaxOffset(float depthFactor, float depthOffset, flo
         switch(o_parallax_quality)
         switch(o_parallax_quality)
         {
         {
             case ParallaxQuality::Low:
             case ParallaxQuality::Low:
-                parallaxOffset = AdvancedParallaxMapping(depthFactor, depthOffset, uv, dirToCameraTS, dirToLightTS, 16, parallaxShadowAttenuation);
+                parallaxOffset = AdvancedParallaxMapping(heightmap, mapSampler, depthFactor, depthOffset, uv, dirToCameraTS, dirToLightTS, 16, parallaxShadowAttenuation);
                 break;
                 break;
             case ParallaxQuality::Medium:
             case ParallaxQuality::Medium:
-                parallaxOffset = AdvancedParallaxMapping(depthFactor, depthOffset, uv, dirToCameraTS, dirToLightTS, 32, parallaxShadowAttenuation);
+                parallaxOffset = AdvancedParallaxMapping(heightmap, mapSampler, depthFactor, depthOffset, uv, dirToCameraTS, dirToLightTS, 32, parallaxShadowAttenuation);
                 break;
                 break;
             case ParallaxQuality::High:
             case ParallaxQuality::High:
-                parallaxOffset = AdvancedParallaxMapping(depthFactor, depthOffset, uv, dirToCameraTS, dirToLightTS, 64, parallaxShadowAttenuation);
+                parallaxOffset = AdvancedParallaxMapping(heightmap, mapSampler, depthFactor, depthOffset, uv, dirToCameraTS, dirToLightTS, 64, parallaxShadowAttenuation);
                 break;
                 break;
             case ParallaxQuality::Ultra:
             case ParallaxQuality::Ultra:
-                parallaxOffset = AdvancedParallaxMapping(depthFactor, depthOffset, uv, dirToCameraTS, dirToLightTS, 128, parallaxShadowAttenuation);
+                parallaxOffset = AdvancedParallaxMapping(heightmap, mapSampler, depthFactor, depthOffset, uv, dirToCameraTS, dirToLightTS, 128, parallaxShadowAttenuation);
                 break;
                 break;
         }
         }
         return parallaxOffset;
         return parallaxOffset;
@@ -374,7 +376,9 @@ ParallaxOffset CalculateParallaxOffset(float depthFactor, float depthOffset, flo
 // @param uv - the UV coordinates on the surface, where the search will begin, used to sample the heightmap.
 // @param uv - the UV coordinates on the surface, where the search will begin, used to sample the heightmap.
 // @param dirToCameraTS - normalized direction to the camera, in tangent space.
 // @param dirToCameraTS - normalized direction to the camera, in tangent space.
 // @param dirToLightTS - normalized direction to a light source, in tangent space, for self-shadowing (if enabled via o_parallax_shadow).
 // @param dirToLightTS - normalized direction to a light source, in tangent space, for self-shadowing (if enabled via o_parallax_shadow).
-ParallaxOffset GetParallaxOffset( float depthFactor, 
+ParallaxOffset GetParallaxOffset( Texture2D heightmap,
+                                  sampler mapSampler,
+                                  float depthFactor, 
                                   float depthOffset,
                                   float depthOffset,
                                   float2 uv,
                                   float2 uv,
                                   float3 dirToCameraWS,
                                   float3 dirToCameraWS,
@@ -397,7 +401,7 @@ ParallaxOffset GetParallaxOffset( float depthFactor,
     float4 dirToCameraTransformed = mul(uv3DTransform, float4(dirToCameraTS, 0.0));
     float4 dirToCameraTransformed = mul(uv3DTransform, float4(dirToCameraTS, 0.0));
 
 
     float dummy = 1;
     float dummy = 1;
-    return CalculateParallaxOffset(depthFactor, depthOffset, uv, normalize(dirToCameraTransformed.xyz), float3(0,0,0), dummy);
+    return CalculateParallaxOffset(heightmap, mapSampler, depthFactor, depthOffset, uv, normalize(dirToCameraTransformed.xyz), float3(0,0,0), dummy);
 }
 }
 
 
 struct PixelDepthOffset
 struct PixelDepthOffset

+ 2 - 0
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Skin/SkinObjectSrg.azsli

@@ -18,6 +18,8 @@
 ShaderResourceGroup ObjectSrg : SRG_PerObject
 ShaderResourceGroup ObjectSrg : SRG_PerObject
 {
 {
     uint m_objectId;
     uint m_objectId;
+    int m_materialTypeId;
+    int m_materialInstanceId;
 
 
     //! Returns the matrix for transforming points from Object Space to World Space.
     //! Returns the matrix for transforming points from Object Space to World Space.
     float4x4 GetWorldMatrix()
     float4x4 GetWorldMatrix()

+ 18 - 0
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_MaterialInputs.azsli

@@ -0,0 +1,18 @@
+/*
+ * 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 "../MaterialInputs/BaseColorInput.azsli"
+#include "../MaterialInputs/VertexColorInput.azsli"
+#include "../MaterialInputs/RoughnessInput.azsli"
+#include "../MaterialInputs/MetallicInput.azsli"
+#include "../MaterialInputs/SpecularInput.azsli"
+#include "../MaterialInputs/NormalInput.azsli"
+#include "../MaterialInputs/UvSetCount.azsli"
+#include "../MaterialInputs/SilhouetteBlockerInput.azsli"

+ 0 - 57
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_MaterialSrg.azsli

@@ -1,57 +0,0 @@
-/*
- * 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 "../MaterialInputs/BaseColorInput.azsli"
-#include "../MaterialInputs/VertexColorInput.azsli"
-#include "../MaterialInputs/RoughnessInput.azsli"
-#include "../MaterialInputs/MetallicInput.azsli"
-#include "../MaterialInputs/SpecularInput.azsli"
-#include "../MaterialInputs/NormalInput.azsli"
-#include "../MaterialInputs/UvSetCount.azsli"
-#include "../MaterialInputs/SilhouetteBlockerInput.azsli"
-
-#include <Atom/Features/SrgSemantics.azsli>
-
-ShaderResourceGroup MaterialSrg : SRG_PerMaterial
-{
-    // Auto-generate material SRG fields for common inputs
-    COMMON_SRG_INPUTS_BASE_COLOR()
-    COMMON_SRG_INPUTS_VERTEX_COLOR()
-    COMMON_SRG_INPUTS_ROUGHNESS()
-    COMMON_SRG_INPUTS_METALLIC()
-    COMMON_SRG_INPUTS_SPECULAR_F0()
-    COMMON_SRG_INPUTS_NORMAL()
-
-    float3x3 m_uvMatrix;
-    float4 m_pad1; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-    float3x3 m_uvMatrixInverse;
-    float4 m_pad2; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-
-    Sampler m_sampler
-    {
-        AddressU = Wrap;
-        AddressV = Wrap;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        MipFilter = Linear;
-        MaxAnisotropy = 16;
-    };
-
-    Texture2D m_brdfMap;
-
-    Sampler m_samplerBrdf
-    {
-        AddressU = Clamp;
-        AddressV = Clamp;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        MipFilter = Linear;
-    };
-}

+ 3 - 1
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_PixelGeometryEval.azsli

@@ -19,6 +19,7 @@
 #include <Atom/Features/InstancedTransforms.azsli>
 #include <Atom/Features/InstancedTransforms.azsli>
 
 
 PixelGeometryData EvaluatePixelGeometry_BasePBR(
 PixelGeometryData EvaluatePixelGeometry_BasePBR(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 normalWS,
     real3 normalWS,
     real3 tangentWS,
     real3 tangentWS,
@@ -46,7 +47,7 @@ PixelGeometryData EvaluatePixelGeometry_BasePBR(
     return geoData;
     return geoData;
 }
 }
 
 
-PixelGeometryData EvaluatePixelGeometry_BasePBR(VsOutput IN, bool isFrontFace)
+PixelGeometryData EvaluatePixelGeometry_BasePBR(VsOutput IN, bool isFrontFace, const MaterialParameters params)
 {
 {
     real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
     real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
     real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
     real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
@@ -55,6 +56,7 @@ PixelGeometryData EvaluatePixelGeometry_BasePBR(VsOutput IN, bool isFrontFace)
     ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
     ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
 
     return EvaluatePixelGeometry_BasePBR(
     return EvaluatePixelGeometry_BasePBR(
+        params,
         IN.worldPosition,
         IN.worldPosition,
         normalWS,
         normalWS,
         tangentWS,
         tangentWS,

+ 28 - 21
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_SurfaceEval.azsli

@@ -21,19 +21,20 @@
 
 
 #include <Atom/Features/MatrixUtility.azsli>
 #include <Atom/Features/MatrixUtility.azsli>
 
 
-real3 BlendVertexColor(real3 baseColor, real3 vertexColor)
+real3 BlendVertexColor(real3 baseColor, real3 vertexColor, real factor)
 {
 {
 #if ENABLE_VERTEX_COLOR
 #if ENABLE_VERTEX_COLOR
     // Check to ensure the material is using vertex colors (i.e o_useVertexColor) and that the mesh supports color vertex stream (i.e o_color0_isBound)
     // Check to ensure the material is using vertex colors (i.e o_useVertexColor) and that the mesh supports color vertex stream (i.e o_color0_isBound)
     if(o_useVertexColor && o_color0_isBound)
     if(o_useVertexColor && o_color0_isBound)
     {
     {
-        baseColor = BlendBaseColor(vertexColor, baseColor, real(MaterialSrg::m_vertexColorFactor), o_vertexColorBlendMode, true);
+        baseColor = BlendBaseColor(vertexColor, baseColor, factor, o_vertexColorBlendMode, true);
     }
     }
 #endif
 #endif
     return baseColor;
     return baseColor;
 }
 }
 
 
 Surface EvaluateSurface_BasePBR(
 Surface EvaluateSurface_BasePBR(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 vertexNormal,
     real3 vertexNormal,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -50,44 +51,44 @@ Surface EvaluateSurface_BasePBR(
     // ------- Normal -------
     // ------- Normal -------
 
 
     surface.vertexNormal = vertexNormal;
     surface.vertexNormal = vertexNormal;
-    float2 normalUv = uvs[MaterialSrg::m_normalMapUvIndex];
+    float2 normalUv = uvs[params.m_normalMapUvIndex];
 
 
-    real3x3 uvMatrix = MaterialSrg::m_normalMapUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : CreateIdentity3x3_real(); // By design, only UV0 is allowed to apply transforms.
+    real3x3 uvMatrix = params.m_normalMapUvIndex == 0 ? real3x3(params.m_uvMatrix) : CreateIdentity3x3_real(); // By design, only UV0 is allowed to apply transforms.
     if (customDerivatives)
     if (customDerivatives)
     {
     {
-        surface.normal = GetNormalInputWS(MaterialSrg::m_normalMap, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, isFrontFace, vertexNormal,
-                                           tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], uvMatrix, o_normal_useTexture, real(MaterialSrg::m_normalFactor), uvDxDy, customDerivatives);
+        surface.normal = GetNormalInputWS(GetMaterialTexture(params.m_normalMap), GetMaterialTextureSampler(), normalUv, params.m_flipNormalX, params.m_flipNormalY, isFrontFace, vertexNormal,
+                                           tangents[params.m_normalMapUvIndex], bitangents[params.m_normalMapUvIndex], uvMatrix, o_normal_useTexture, real(params.m_normalFactor), uvDxDy, customDerivatives);
     }
     }
     else
     else
     {
     {
-        surface.normal = GetNormalInputWS(MaterialSrg::m_normalMap, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, isFrontFace, vertexNormal,
-                                           tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], uvMatrix, o_normal_useTexture, real(MaterialSrg::m_normalFactor), float4(0.0f, 0.0f, 0.0f, 0.0f), false);
+        surface.normal = GetNormalInputWS(GetMaterialTexture(params.m_normalMap), GetMaterialTextureSampler(), normalUv, params.m_flipNormalX, params.m_flipNormalY, isFrontFace, vertexNormal,
+                                           tangents[params.m_normalMapUvIndex], bitangents[params.m_normalMapUvIndex], uvMatrix, o_normal_useTexture, real(params.m_normalFactor), float4(0.0f, 0.0f, 0.0f, 0.0f), false);
     }
     }
 
 
     // ------- Base Color -------
     // ------- Base Color -------
 
 
-    float2 baseColorUv = uvs[MaterialSrg::m_baseColorMapUvIndex];
-    real3 sampledColor = GetBaseColorInput(MaterialSrg::m_baseColorMap, MaterialSrg::m_sampler, baseColorUv, real3(MaterialSrg::m_baseColor.rgb), o_baseColor_useTexture, uvDxDy, customDerivatives);
-    real3 baseColor = BlendBaseColor(sampledColor, real3(MaterialSrg::m_baseColor.rgb), real(MaterialSrg::m_baseColorFactor), o_baseColorTextureBlendMode, o_baseColor_useTexture);
-    baseColor = BlendVertexColor(baseColor, real3(vertexColor.rgb));
+    float2 baseColorUv = uvs[params.m_baseColorMapUvIndex];
+    real3 sampledColor = GetBaseColorInput(GetMaterialTexture(params.m_baseColorMap), GetMaterialTextureSampler(), baseColorUv, real3(params.m_baseColor.rgb), o_baseColor_useTexture, uvDxDy, customDerivatives);
+    real3 baseColor = BlendBaseColor(sampledColor, real3(params.m_baseColor.rgb), real(params.m_baseColorFactor), o_baseColorTextureBlendMode, o_baseColor_useTexture);
+    baseColor = BlendVertexColor(baseColor, real3(vertexColor.rgb), real(params.m_vertexColorFactor));
     
     
     // ------- Metallic -------
     // ------- Metallic -------
 
 
-    float2 metallicUv = uvs[MaterialSrg::m_metallicMapUvIndex];
-    real metallic = GetMetallicInput(MaterialSrg::m_metallicMap, MaterialSrg::m_sampler, metallicUv, real(MaterialSrg::m_metallicFactor), o_metallic_useTexture, uvDxDy, customDerivatives);
+    float2 metallicUv = uvs[params.m_metallicMapUvIndex];
+    real metallic = GetMetallicInput(GetMaterialTexture(params.m_metallicMap), GetMaterialTextureSampler(), metallicUv, real(params.m_metallicFactor), o_metallic_useTexture, uvDxDy, customDerivatives);
 
 
     // ------- Specular -------
     // ------- Specular -------
 
 
-    float2 specularUv = uvs[MaterialSrg::m_specularF0MapUvIndex];
-    real specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, real(MaterialSrg::m_specularF0Factor), o_specularF0_useTexture, uvDxDy, customDerivatives);
+    float2 specularUv = uvs[params.m_specularF0MapUvIndex];
+    real specularF0Factor = GetSpecularInput(GetMaterialTexture(params.m_specularF0Map), GetMaterialTextureSampler(), specularUv, real(params.m_specularF0Factor), o_specularF0_useTexture, uvDxDy, customDerivatives);
 
 
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
 
 
     // ------- Roughness -------
     // ------- Roughness -------
 
 
-    float2 roughnessUv = uvs[MaterialSrg::m_roughnessMapUvIndex];
-    surface.roughnessLinear = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, real(MaterialSrg::m_roughnessFactor),
-                                        real(MaterialSrg::m_roughnessLowerBound), real(MaterialSrg::m_roughnessUpperBound), o_roughness_useTexture, uvDxDy, customDerivatives);
+    float2 roughnessUv = uvs[params.m_roughnessMapUvIndex];
+    surface.roughnessLinear = GetRoughnessInput(GetMaterialTexture(params.m_roughnessMap), GetMaterialTextureSampler(), roughnessUv, real(params.m_roughnessFactor),
+                                        real(params.m_roughnessLowerBound), real(params.m_roughnessUpperBound), o_roughness_useTexture, uvDxDy, customDerivatives);
     surface.CalculateRoughnessA();
     surface.CalculateRoughnessA();
 
 
     return surface;
     return surface;
@@ -105,6 +106,7 @@ float4 GetVertexColor(VsOutput IN)
 // helper function to keep compatible with the previous version
 // helper function to keep compatible with the previous version
 // because dxc compiler doesn't allow default parameters on functions with overloads
 // because dxc compiler doesn't allow default parameters on functions with overloads
 Surface EvaluateSurface_BasePBR(
 Surface EvaluateSurface_BasePBR(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 vertexNormal,
     real3 vertexNormal,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -115,6 +117,7 @@ Surface EvaluateSurface_BasePBR(
     bool customDerivatives)
     bool customDerivatives)
 {
 {
     return EvaluateSurface_BasePBR(
     return EvaluateSurface_BasePBR(
+        params,
         positionWS,
         positionWS,
         vertexNormal,
         vertexNormal,
         tangents,
         tangents,
@@ -127,6 +130,7 @@ Surface EvaluateSurface_BasePBR(
 }
 }
 
 
 Surface EvaluateSurface_BasePBR(
 Surface EvaluateSurface_BasePBR(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 vertexNormal,
     real3 vertexNormal,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -135,6 +139,7 @@ Surface EvaluateSurface_BasePBR(
     bool isFrontFace)
     bool isFrontFace)
 {
 {
     return EvaluateSurface_BasePBR(
     return EvaluateSurface_BasePBR(
+        params,
         positionWS,
         positionWS,
         vertexNormal,
         vertexNormal,
         tangents,
         tangents,
@@ -145,9 +150,10 @@ Surface EvaluateSurface_BasePBR(
         false);
         false);
 }
 }
 
 
-Surface EvaluateSurface_BasePBR(VsOutput IN, PixelGeometryData geoData, float4 uvDxDy, bool customDerivatives)
+Surface EvaluateSurface_BasePBR(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params, float4 uvDxDy, bool customDerivatives)
 {
 {
     return EvaluateSurface_BasePBR(
     return EvaluateSurface_BasePBR(
+        params,
         geoData.positionWS,
         geoData.positionWS,
         geoData.vertexNormal,
         geoData.vertexNormal,
         geoData.tangents,
         geoData.tangents,
@@ -159,9 +165,10 @@ Surface EvaluateSurface_BasePBR(VsOutput IN, PixelGeometryData geoData, float4 u
         GetVertexColor(IN));
         GetVertexColor(IN));
 }
 }
 
 
-Surface EvaluateSurface_BasePBR(VsOutput IN, PixelGeometryData geoData)
+Surface EvaluateSurface_BasePBR(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params)
 {
 {
     return EvaluateSurface_BasePBR(
     return EvaluateSurface_BasePBR(
+        params,
         geoData.positionWS,
         geoData.positionWS,
         geoData.vertexNormal,
         geoData.vertexNormal,
         geoData.tangents,
         geoData.tangents,

+ 6 - 2
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_VertexEval.azsli

@@ -24,6 +24,7 @@
 #include <Atom/Features/InstancedTransforms.azsli>
 #include <Atom/Features/InstancedTransforms.azsli>
 
 
 VsOutput EvaluateVertexGeometry_BasePBR(
 VsOutput EvaluateVertexGeometry_BasePBR(
+    const MaterialParameters params,
     float3 position,
     float3 position,
     float3 normal,
     float3 normal,
     float4 tangent,
     float4 tangent,
@@ -41,7 +42,7 @@ VsOutput EvaluateVertexGeometry_BasePBR(
     output.position = mul(ViewSrg::m_viewProjectionMatrix, worldPosition);
     output.position = mul(ViewSrg::m_viewProjectionMatrix, worldPosition);
 
 
     // By design, only UV0 is allowed to apply transforms.
     // By design, only UV0 is allowed to apply transforms.
-    output.uvs[0] = mul(MaterialSrg::m_uvMatrix, float3(uv0, 1.0)).xy;
+    output.uvs[0] = mul(params.m_uvMatrix, float3(uv0, 1.0)).xy;
     output.uvs[1] = uv1;
     output.uvs[1] = uv1;
 
 
     output.normal = normal;
     output.normal = normal;
@@ -76,13 +77,14 @@ void GetVertexColor(VsInput IN, out float4 color, out bool useVertexColor)
 #endif
 #endif
 }
 }
 
 
-VsOutput EvaluateVertexGeometry_BasePBR(VsInput IN, VsSystemValues SV)
+VsOutput EvaluateVertexGeometry_BasePBR(VsInput IN, VsSystemValues SV, const MaterialParameters params)
 {
 {
     float4 color0;
     float4 color0;
     bool useVertexColor0;
     bool useVertexColor0;
     GetVertexColor(IN, color0, useVertexColor0);
     GetVertexColor(IN, color0, useVertexColor0);
 
 
     return EvaluateVertexGeometry_BasePBR(
     return EvaluateVertexGeometry_BasePBR(
+        params,
         IN.position,
         IN.position,
         IN.normal,
         IN.normal,
         IN.tangent,
         IN.tangent,
@@ -94,6 +96,7 @@ VsOutput EvaluateVertexGeometry_BasePBR(VsInput IN, VsSystemValues SV)
 }
 }
 
 
 VsOutput EvaluateVertexGeometry_BasePBR(
 VsOutput EvaluateVertexGeometry_BasePBR(
+    const MaterialParameters params,
     float3 position,
     float3 position,
     float3 normal,
     float3 normal,
     float4 tangent,
     float4 tangent,
@@ -102,6 +105,7 @@ VsOutput EvaluateVertexGeometry_BasePBR(
     uint instanceId)
     uint instanceId)
 {
 {
     return EvaluateVertexGeometry_BasePBR(
     return EvaluateVertexGeometry_BasePBR(
+        params,
         position,
         position,
         normal,
         normal,
         tangent,
         tangent,

+ 1 - 1
Gems/Atom/Feature/Common/Assets/Shaders/Materials/DepthPass_VertexEval.azsli

@@ -15,7 +15,7 @@
 #include <Atom/RPI/TangentSpace.azsli>
 #include <Atom/RPI/TangentSpace.azsli>
 #include <Atom/Features/InstancedTransforms.azsli>
 #include <Atom/Features/InstancedTransforms.azsli>
 
 
-VsOutput EvaluateVertexGeometry_DepthPass(VsInput IN, VsSystemValues SV)
+VsOutput EvaluateVertexGeometry_DepthPass(VsInput IN, VsSystemValues SV, const MaterialParameters params)
 {
 {
     VsOutput output;
     VsOutput output;
 
 

+ 26 - 0
Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_MaterialInputs.azsli

@@ -0,0 +1,26 @@
+/*
+ * 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/PBR/AlphaUtils.azsli>
+#include <Atom/Features/PBR/LightingOptions.azsli>
+
+#include "../MaterialInputs/BaseColorInput.azsli"
+#include "../MaterialInputs/VertexColorInput.azsli"
+#include "../MaterialInputs/RoughnessInput.azsli"
+#include "../MaterialInputs/MetallicInput.azsli"
+#include "../MaterialInputs/SpecularInput.azsli"
+#include "../MaterialInputs/NormalInput.azsli"
+#include "../MaterialInputs/ClearCoatInput.azsli"
+#include "../MaterialInputs/OcclusionInput.azsli"
+#include "../MaterialInputs/EmissiveInput.azsli"
+#include "../MaterialInputs/ParallaxInput.azsli"
+#include "../MaterialInputs/UvSetCount.azsli"
+#include "../MaterialInputs/DetailMapsInput.azsli"
+

+ 0 - 106
Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_MaterialSrg.azsli

@@ -1,106 +0,0 @@
-/*
- * 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/PBR/AlphaUtils.azsli>
-#include <Atom/Features/PBR/LightingOptions.azsli>
-
-#include "../MaterialInputs/BaseColorInput.azsli"
-#include "../MaterialInputs/VertexColorInput.azsli"
-#include "../MaterialInputs/RoughnessInput.azsli"
-#include "../MaterialInputs/MetallicInput.azsli"
-#include "../MaterialInputs/SpecularInput.azsli"
-#include "../MaterialInputs/NormalInput.azsli"
-#include "../MaterialInputs/ClearCoatInput.azsli"
-#include "../MaterialInputs/OcclusionInput.azsli"
-#include "../MaterialInputs/EmissiveInput.azsli"
-#include "../MaterialInputs/ParallaxInput.azsli"
-#include "../MaterialInputs/UvSetCount.azsli"
-#include "../MaterialInputs/DetailMapsInput.azsli"
-
-#include <Atom/Features/SrgSemantics.azsli>
-
-ShaderResourceGroup MaterialSrg : SRG_PerMaterial
-{
-    // Auto-generate material SRG fields for common inputs
-    COMMON_SRG_INPUTS_BASE_COLOR()
-    COMMON_SRG_INPUTS_VERTEX_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()      
-    COMMON_SRG_INPUTS_PARALLAX()
-    COMMON_SRG_INPUTS_DETAIL_MAPS()
-    
-    uint m_parallaxUvIndex;
-    float m_parallax_pdo_shadowFactor;
-
-    float3x3 m_uvMatrix;                    // The combined transform for the uv coordinates having translation, 
-    float4 m_pad1; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-    float3x3 m_uvMatrixInverse;             //      rotation, scale and other modifiers represented by it.
-    float4 m_pad2; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-
-    float m_anisotropicAngle;   // Base layer anisotropic angle to control direction of major deviation axis.
-    float m_anisotropicFactor;  // Base layer anisotropic strength of deviation:  negative = Bi-Normal direction, positive = Tangent direction
-
-    float m_opacityFactor;
-    float m_opacityAffectsSpecularFactor;
-    Texture2D m_opacityMap;
-    uint m_opacityMapUvIndex;
-
-    Sampler m_sampler
-    {
-       AddressU = Wrap;
-       AddressV = Wrap;
-       MinFilter = Linear;
-       MagFilter = Linear;
-       MipFilter = Linear;
-       MaxAnisotropy = 16;
-    };
-
-    Texture2D m_brdfMap;
-
-    Sampler m_samplerBrdf
-    {
-        AddressU = Clamp;
-        AddressV = Clamp;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        MipFilter = Linear;
-    };
-
-    // Detail Layer for clear coat
-    float m_clearCoatDetailRoughnessBlend;
-    Texture2D m_clearCoatDetailRoughnessMap;
-    float m_clearCoatDetailNormalBlend;
-    Texture2D m_clearCoatDetailNormalMap;
-
-    // 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:  (shrinkFactor, transmissionNdLBias, distanceAttenuation, scale)
-    float4 m_transmissionParams;
-    
-    // (float3 TintColor, thickness)
-    float4 m_transmissionTintThickness;
-    Texture2D m_transmissionThicknessMap;
-    uint m_transmissionThicknessMapUvIndex;
-}
-

+ 5 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_PixelGeometryEval.azsli

@@ -21,6 +21,7 @@
 #include <Atom/Features/Debug.azsli>
 #include <Atom/Features/Debug.azsli>
 
 
 PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(
 PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(
+    const MaterialParameters params,
     inout float4 positionSV,
     inout float4 positionSV,
     float3 positionWS,
     float3 positionWS,
     real3 normalWS,
     real3 normalWS,
@@ -31,7 +32,7 @@ PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(
     bool isFrontFace,
     bool isFrontFace,
     real4x4 objectToWorld)
     real4x4 objectToWorld)
 {
 {
-    PixelGeometryData geoData = EvaluatePixelGeometry_BasePBR(positionWS, normalWS, tangentWS, bitangentWS, uvs, isFrontFace);
+    PixelGeometryData geoData = EvaluatePixelGeometry_BasePBR(params, positionWS, normalWS, tangentWS, bitangentWS, uvs, isFrontFace);
 
 
     // ------- Detail UVs -------
     // ------- Detail UVs -------
 
 
@@ -44,7 +45,7 @@ PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(
 #if ENABLE_PARALLAX
 #if ENABLE_PARALLAX
     if(ShouldHandleParallax())
     if(ShouldHandleParallax())
     {
     {
-        SetPixelDepth(geoData.positionWS, geoData.vertexNormal, geoData.tangents, geoData.bitangents,
+        SetPixelDepth(params, geoData.positionWS, geoData.vertexNormal, geoData.tangents, geoData.bitangents,
                       geoData.uvs, geoData.detailUvs, isFrontFace, objectToWorld, positionSV.z, positionSV.w, geoData.isDisplacementClipped);
                       geoData.uvs, geoData.detailUvs, isFrontFace, objectToWorld, positionSV.z, positionSV.w, geoData.isDisplacementClipped);
     }
     }
 #endif
 #endif
@@ -52,7 +53,7 @@ PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(
     return geoData;
     return geoData;
 }
 }
 
 
-PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(inout VsOutput IN, bool isFrontFace)
+PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(inout VsOutput IN, bool isFrontFace, const MaterialParameters params)
 {
 {
     real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
     real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
     real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
     real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
@@ -61,6 +62,7 @@ PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(inout VsOutput IN, bool isFr
     ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
     ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
 
     return EvaluatePixelGeometry_EnhancedPBR(
     return EvaluatePixelGeometry_EnhancedPBR(
+        params,
         IN.position,
         IN.position,
         IN.worldPosition,
         IN.worldPosition,
         normalWS,
         normalWS,

+ 55 - 48
Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_SurfaceEval.azsli

@@ -19,6 +19,7 @@
 #include "../MaterialFunctions/StandardGetAlphaAndClip.azsli"
 #include "../MaterialFunctions/StandardGetAlphaAndClip.azsli"
 
 
 Surface EvaluateSurface_EnhancedPBR(
 Surface EvaluateSurface_EnhancedPBR(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 normalWS,
     real3 normalWS,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -36,45 +37,45 @@ Surface EvaluateSurface_EnhancedPBR(
 
 
     // ------- Detail Layer Setup -------
     // ------- Detail Layer Setup -------
     
     
-    const float2 detailUv = detailUvs[MaterialSrg::m_detail_allMapsUvIndex];
+    const float2 detailUv = detailUvs[params.m_detail_allMapsUvIndex];
 
 
     // When the detail maps and the detail blend mask are on the same UV, they both use the transformed detail UVs because they are 'attached' to each other
     // When the detail maps and the detail blend mask are on the same UV, they both use the transformed detail UVs because they are 'attached' to each other
-    const float2 detailBlendMaskUv = (MaterialSrg::m_detail_blendMask_uvIndex == MaterialSrg::m_detail_allMapsUvIndex) ?
-        detailUvs[MaterialSrg::m_detail_blendMask_uvIndex] : 
-        uvs[MaterialSrg::m_detail_blendMask_uvIndex];        
+    const float2 detailBlendMaskUv = (params.m_detail_blendMask_uvIndex ==params.m_detail_allMapsUvIndex) ?
+        detailUvs[params.m_detail_blendMask_uvIndex] : 
+        uvs[params.m_detail_blendMask_uvIndex];        
 
 
     const real detailLayerBlendFactor = GetDetailLayerBlendFactor(
     const real detailLayerBlendFactor = GetDetailLayerBlendFactor(
-        MaterialSrg::m_detail_blendMask_texture,
-        MaterialSrg::m_sampler,
+        GetMaterialTexture(params.m_detail_blendMask_texture),
+        GetMaterialTextureSampler(),
         detailBlendMaskUv,
         detailBlendMaskUv,
         o_detail_blendMask_useTexture,
         o_detail_blendMask_useTexture,
-        real(MaterialSrg::m_detail_blendFactor),
+        real(params.m_detail_blendFactor),
         uvDxDy,
         uvDxDy,
         customDerivatives);
         customDerivatives);
 
 
     // ------- Normal -------
     // ------- Normal -------
     
     
     surface.vertexNormal = real3(normalWS);
     surface.vertexNormal = real3(normalWS);
-    float2 normalUv = uvs[MaterialSrg::m_normalMapUvIndex];
-    real3x3 uvMatrix = MaterialSrg::m_normalMapUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : CreateIdentity3x3_real(); // By design, only UV0 is allowed to apply transforms.
-    real detailLayerNormalFactor = real(MaterialSrg::m_detail_normal_factor) * detailLayerBlendFactor;
+    float2 normalUv = uvs[params.m_normalMapUvIndex];
+    real3x3 uvMatrix = params.m_normalMapUvIndex == 0 ? real3x3(params.m_uvMatrix) : CreateIdentity3x3_real(); // By design, only UV0 is allowed to apply transforms.
+    real detailLayerNormalFactor = real(params.m_detail_normal_factor) * detailLayerBlendFactor;
     float3 normal = GetDetailedNormalInputWS(
     float3 normal = GetDetailedNormalInputWS(
         isFrontFace, normalWS,
         isFrontFace, normalWS,
-        tangents[MaterialSrg::m_normalMapUvIndex],      bitangents[MaterialSrg::m_normalMapUvIndex],      MaterialSrg::m_normalMap,             MaterialSrg::m_sampler, normalUv, MaterialSrg::m_normalFactor,  MaterialSrg::m_flipNormalX,         MaterialSrg::m_flipNormalY,         uvMatrix,                                o_normal_useTexture,
-        tangents[MaterialSrg::m_detail_allMapsUvIndex], bitangents[MaterialSrg::m_detail_allMapsUvIndex], MaterialSrg::m_detail_normal_texture, MaterialSrg::m_sampler, detailUv, detailLayerNormalFactor,      MaterialSrg::m_detail_normal_flipX, MaterialSrg::m_detail_normal_flipY, real3x3(MaterialSrg::m_detailUvMatrix), o_detail_normal_useTexture,
+        tangents[params.m_normalMapUvIndex],      bitangents[params.m_normalMapUvIndex],      GetMaterialTexture(params.m_normalMap),             GetMaterialTextureSampler(), normalUv, params.m_normalFactor,  params.m_flipNormalX,         params.m_flipNormalY,         uvMatrix,                         o_normal_useTexture,
+        tangents[params.m_detail_allMapsUvIndex], bitangents[params.m_detail_allMapsUvIndex], GetMaterialTexture(params.m_detail_normal_texture), GetMaterialTextureSampler(), detailUv, detailLayerNormalFactor,      params.m_detail_normal_flipX, params.m_detail_normal_flipY, real3x3(params.m_detailUvMatrix), o_detail_normal_useTexture,
         uvDxDy, customDerivatives);
         uvDxDy, customDerivatives);
 
 
     surface.normal = real3(normal);
     surface.normal = real3(normal);
 
 
     // ------- Base Color -------
     // ------- Base Color -------
 
 
-    real detailLayerBaseColorFactor = real(MaterialSrg::m_detail_baseColor_factor) * detailLayerBlendFactor;
-    float2 baseColorUv = uvs[MaterialSrg::m_baseColorMapUvIndex];
+    real detailLayerBaseColorFactor = real(params.m_detail_baseColor_factor) * detailLayerBlendFactor;
+    float2 baseColorUv = uvs[params.m_baseColorMapUvIndex];
 
 
     real3 baseColor = GetDetailedBaseColorInput(
     real3 baseColor = GetDetailedBaseColorInput(
-        MaterialSrg::m_baseColorMap,             MaterialSrg::m_sampler, baseColorUv, o_baseColor_useTexture,        real3(MaterialSrg::m_baseColor),  real(MaterialSrg::m_baseColorFactor), o_baseColorTextureBlendMode,
-        MaterialSrg::m_detail_baseColor_texture, MaterialSrg::m_sampler, detailUv,    o_detail_baseColor_useTexture, detailLayerBaseColorFactor, uvDxDy, customDerivatives);
-    baseColor = BlendVertexColor(baseColor, real3(vertexColor.rgb));
+        GetMaterialTexture(params.m_baseColorMap),             GetMaterialTextureSampler(), baseColorUv, o_baseColor_useTexture,        real3(params.m_baseColor.rgb),  real(params.m_baseColorFactor), o_baseColorTextureBlendMode,
+        GetMaterialTexture(params.m_detail_baseColor_texture), GetMaterialTextureSampler(), detailUv,    o_detail_baseColor_useTexture, detailLayerBaseColorFactor, uvDxDy, customDerivatives);
+    baseColor = BlendVertexColor(baseColor, real3(vertexColor.rgb), real(params.m_vertexColorFactor));
     
     
     // ------- Parallax Clipping -------
     // ------- Parallax Clipping -------
 
 
@@ -86,47 +87,47 @@ Surface EvaluateSurface_EnhancedPBR(
     // ------- Alpha & Clip -------
     // ------- Alpha & Clip -------
 
 
     // TODO: this often invokes a separate sample of the base color texture which is wasteful
     // TODO: this often invokes a separate sample of the base color texture which is wasteful
-    surface.alpha = GetAlphaAndClip(uvs, uvDxDy, customDerivatives);
+    surface.alpha = GetAlphaAndClip(params, uvs, uvDxDy, customDerivatives);
 
 
     // ------- Metallic -------
     // ------- Metallic -------
 
 
     real metallic = 0;
     real metallic = 0;
     if(!o_enableSubsurfaceScattering)   // If subsurface scattering is enabled skip texture lookup for metallic, as this quantity won't be used anyway
     if(!o_enableSubsurfaceScattering)   // If subsurface scattering is enabled skip texture lookup for metallic, as this quantity won't be used anyway
     {
     {
-        float2 metallicUv = uvs[MaterialSrg::m_metallicMapUvIndex];
-        metallic = GetMetallicInput(MaterialSrg::m_metallicMap, MaterialSrg::m_sampler, metallicUv, real(MaterialSrg::m_metallicFactor), o_metallic_useTexture, uvDxDy, customDerivatives);
+        float2 metallicUv = uvs[params.m_metallicMapUvIndex];
+        metallic = GetMetallicInput(GetMaterialTexture(params.m_metallicMap), GetMaterialTextureSampler(), metallicUv, real(params.m_metallicFactor), o_metallic_useTexture, uvDxDy, customDerivatives);
     }
     }
 
 
     // ------- Specular -------
     // ------- Specular -------
 
 
-    float2 specularUv = uvs[MaterialSrg::m_specularF0MapUvIndex];
-    real specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, real(MaterialSrg::m_specularF0Factor), o_specularF0_useTexture, uvDxDy, customDerivatives);
+    float2 specularUv = uvs[params.m_specularF0MapUvIndex];
+    real specularF0Factor = GetSpecularInput(GetMaterialTexture(params.m_specularF0Map), GetMaterialTextureSampler(), specularUv, real(params.m_specularF0Factor), o_specularF0_useTexture, uvDxDy, customDerivatives);
 
 
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
 
 
     // ------- Roughness -------
     // ------- Roughness -------
 
 
-    float2 roughnessUv = uvs[MaterialSrg::m_roughnessMapUvIndex];
-    surface.roughnessLinear = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, real(MaterialSrg::m_roughnessFactor),
-                                        real(MaterialSrg::m_roughnessLowerBound), real(MaterialSrg::m_roughnessUpperBound), o_roughness_useTexture, uvDxDy, customDerivatives);
+    float2 roughnessUv = uvs[params.m_roughnessMapUvIndex];
+    surface.roughnessLinear = GetRoughnessInput(GetMaterialTexture(params.m_roughnessMap), GetMaterialTextureSampler(), roughnessUv, real(params.m_roughnessFactor),
+                                        real(params.m_roughnessLowerBound), real(params.m_roughnessUpperBound), o_roughness_useTexture, uvDxDy, customDerivatives);
     surface.CalculateRoughnessA();
     surface.CalculateRoughnessA();
 
 
     // ------- Subsurface -------
     // ------- Subsurface -------
 
 
-    float2 subsurfaceUv = uvs[MaterialSrg::m_subsurfaceScatteringInfluenceMapUvIndex];
-    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, real(MaterialSrg::m_subsurfaceScatteringFactor), uvDxDy, customDerivatives);
-    surface.subsurfaceScatteringQuality = real(MaterialSrg::m_subsurfaceScatteringQuality);
-    surface.scatterDistance = real3(MaterialSrg::m_scatterDistance);
+    float2 subsurfaceUv = uvs[params.m_subsurfaceScatteringInfluenceMapUvIndex];
+    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(GetMaterialTexture(params.m_subsurfaceScatteringInfluenceMap), GetMaterialTextureSampler(), subsurfaceUv, real(params.m_subsurfaceScatteringFactor), uvDxDy, customDerivatives);
+    surface.subsurfaceScatteringQuality = real(params.m_subsurfaceScatteringQuality);
+    surface.scatterDistance = real3(params.m_scatterDistance);
 
 
     // ------- Transmission -------
     // ------- Transmission -------
     
     
 #if ENABLE_TRANSMISSION
 #if ENABLE_TRANSMISSION
-    float2 transmissionUv = uvs[MaterialSrg::m_transmissionThicknessMapUvIndex];
-    real4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, real4(MaterialSrg::m_transmissionTintThickness), uvDxDy, customDerivatives);
+    float2 transmissionUv = uvs[params.m_transmissionThicknessMapUvIndex];
+    real4 transmissionTintThickness = GeTransmissionInput(GetMaterialTexture(params.m_transmissionThicknessMap), GetMaterialTextureSampler(), transmissionUv, real4(params.m_transmissionTintThickness), uvDxDy, customDerivatives);
     surface.transmission.tint = transmissionTintThickness.rgb;
     surface.transmission.tint = transmissionTintThickness.rgb;
     surface.transmission.thickness = transmissionTintThickness.w;
     surface.transmission.thickness = transmissionTintThickness.w;
-    surface.transmission.transmissionParams = real4(MaterialSrg::m_transmissionParams);
-    surface.transmission.scatterDistance = real3(MaterialSrg::m_scatterDistance);
+    surface.transmission.transmissionParams = real4(params.m_transmissionParams);
+    surface.transmission.scatterDistance = real3(params.m_scatterDistance);
 #endif
 #endif
 
 
     // ------- Anisotropy -------
     // ------- Anisotropy -------
@@ -134,20 +135,20 @@ Surface EvaluateSurface_EnhancedPBR(
     if (o_enableAnisotropy)
     if (o_enableAnisotropy)
     {
     {
         // Convert the angle from [0..1] = [0 .. 180 degrees] to radians [0 .. PI]
         // Convert the angle from [0..1] = [0 .. 180 degrees] to radians [0 .. PI]
-        const real anisotropyAngle = real(MaterialSrg::m_anisotropicAngle) * PI;
-        const real anisotropyFactor = real(MaterialSrg::m_anisotropicFactor);
+        const real anisotropyAngle = real(params.m_anisotropicAngle) * PI;
+        const real anisotropyFactor = real(params.m_anisotropicFactor);
         surface.anisotropy.Init(surface.GetSpecularNormal(), tangents[0], bitangents[0], anisotropyAngle, anisotropyFactor, surface.roughnessA);
         surface.anisotropy.Init(surface.GetSpecularNormal(), tangents[0], bitangents[0], anisotropyAngle, anisotropyFactor, surface.roughnessA);
     }
     }
 
 
     // ------- Emissive -------
     // ------- Emissive -------
 
 
-    float2 emissiveUv = uvs[MaterialSrg::m_emissiveMapUvIndex];
-    surface.emissiveLighting = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, real(MaterialSrg::m_emissiveIntensity), real3(MaterialSrg::m_emissiveColor.rgb), real(MaterialSrg::m_emissiveAffectedByAlpha), surface.alpha,  o_emissiveEnabled, o_emissive_useTexture, uvDxDy, customDerivatives);
+    float2 emissiveUv = uvs[params.m_emissiveMapUvIndex];
+    surface.emissiveLighting = GetEmissiveInput(GetMaterialTexture(params.m_emissiveMap), GetMaterialTextureSampler(), emissiveUv, real(params.m_emissiveIntensity), real3(params.m_emissiveColor.rgb), real(params.m_emissiveAffectedByAlpha), surface.alpha,  o_emissiveEnabled, o_emissive_useTexture, uvDxDy, customDerivatives);
 
 
     // ------- Occlusion -------
     // ------- Occlusion -------
     
     
-    surface.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_diffuseOcclusionMapUvIndex], real(MaterialSrg::m_diffuseOcclusionFactor), o_diffuseOcclusion_useTexture, uvDxDy, customDerivatives);
-    surface.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_specularOcclusionMapUvIndex], real(MaterialSrg::m_specularOcclusionFactor), o_specularOcclusion_useTexture, uvDxDy, customDerivatives);
+    surface.diffuseAmbientOcclusion = GetOcclusionInput(GetMaterialTexture(params.m_diffuseOcclusionMap), GetMaterialTextureSampler(), uvs[params.m_diffuseOcclusionMapUvIndex], real(params.m_diffuseOcclusionFactor), o_diffuseOcclusion_useTexture, uvDxDy, customDerivatives);
+    surface.specularOcclusion = GetOcclusionInput(GetMaterialTexture(params.m_specularOcclusionMap), GetMaterialTextureSampler(), uvs[params.m_specularOcclusionMapUvIndex], real(params.m_specularOcclusionFactor), o_specularOcclusion_useTexture, uvDxDy, customDerivatives);
 
 
     // ------- Clearcoat -------
     // ------- Clearcoat -------
     
     
@@ -157,12 +158,12 @@ Surface EvaluateSurface_EnhancedPBR(
     {
     {
         if(o_clearCoat_enabled)
         if(o_clearCoat_enabled)
         {
         {
-            real3x3 uvMatrix = MaterialSrg::m_clearCoatNormalMapUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : CreateIdentity3x3_real();
-            GetClearCoatInputs(MaterialSrg::m_clearCoatInfluenceMap, uvs[MaterialSrg::m_clearCoatInfluenceMapUvIndex], real(MaterialSrg::m_clearCoatFactor), o_clearCoat_factor_useTexture,
-                               MaterialSrg::m_clearCoatRoughnessMap, uvs[MaterialSrg::m_clearCoatRoughnessMapUvIndex], real(MaterialSrg::m_clearCoatRoughness), o_clearCoat_roughness_useTexture,
-                               MaterialSrg::m_clearCoatNormalMap,    uvs[MaterialSrg::m_clearCoatNormalMapUvIndex], normalWS, o_clearCoat_normal_useTexture, real(MaterialSrg::m_clearCoatNormalStrength),
-                               uvMatrix, tangents[MaterialSrg::m_clearCoatNormalMapUvIndex], bitangents[MaterialSrg::m_clearCoatNormalMapUvIndex],
-                               MaterialSrg::m_sampler, isFrontFace,
+            real3x3 uvMatrix = params.m_clearCoatNormalMapUvIndex == 0 ? real3x3(params.m_uvMatrix) : CreateIdentity3x3_real();
+            GetClearCoatInputs(GetMaterialTexture(params.m_clearCoatInfluenceMap), uvs[params.m_clearCoatInfluenceMapUvIndex], real(params.m_clearCoatFactor), o_clearCoat_factor_useTexture,
+                               GetMaterialTexture(params.m_clearCoatRoughnessMap), uvs[params.m_clearCoatRoughnessMapUvIndex], real(params.m_clearCoatRoughness), o_clearCoat_roughness_useTexture,
+                               GetMaterialTexture(params.m_clearCoatNormalMap),    uvs[params.m_clearCoatNormalMapUvIndex], normalWS, o_clearCoat_normal_useTexture, real(params.m_clearCoatNormalStrength),
+                               uvMatrix, tangents[params.m_clearCoatNormalMapUvIndex], bitangents[params.m_clearCoatNormalMapUvIndex],
+                               GetMaterialTextureSampler(), isFrontFace,
                                surface.clearCoat.factor, surface.clearCoat.roughness, surface.clearCoat.normal, uvDxDy, customDerivatives);
                                surface.clearCoat.factor, surface.clearCoat.roughness, surface.clearCoat.normal, uvDxDy, customDerivatives);
         }
         }
         
         
@@ -172,7 +173,7 @@ Surface EvaluateSurface_EnhancedPBR(
     
     
     // ------- Opacity -------
     // ------- Opacity -------
 
 
-    surface.opacityAffectsSpecularFactor = real(MaterialSrg::m_opacityAffectsSpecularFactor);
+    surface.opacityAffectsSpecularFactor = real(params.m_opacityAffectsSpecularFactor);
 
 
     return surface;
     return surface;
 }
 }
@@ -180,6 +181,7 @@ Surface EvaluateSurface_EnhancedPBR(
 // Helper functions to keep compatible with the previous version
 // Helper functions to keep compatible with the previous version
 // because dxc compiler doesn't allow default parameters on functions with overloads
 // because dxc compiler doesn't allow default parameters on functions with overloads
 Surface EvaluateSurface_EnhancedPBR(
 Surface EvaluateSurface_EnhancedPBR(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 normalWS,
     real3 normalWS,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -192,6 +194,7 @@ Surface EvaluateSurface_EnhancedPBR(
     bool customDerivatives)
     bool customDerivatives)
 {
 {
     return EvaluateSurface_EnhancedPBR(
     return EvaluateSurface_EnhancedPBR(
+            params,
             positionWS,
             positionWS,
             normalWS,
             normalWS,
             tangents,
             tangents,
@@ -206,6 +209,7 @@ Surface EvaluateSurface_EnhancedPBR(
 }
 }
 
 
 Surface EvaluateSurface_EnhancedPBR(
 Surface EvaluateSurface_EnhancedPBR(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 normalWS,
     real3 normalWS,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -216,6 +220,7 @@ Surface EvaluateSurface_EnhancedPBR(
     bool isDisplacementClipped)
     bool isDisplacementClipped)
 {
 {
     return EvaluateSurface_EnhancedPBR(
     return EvaluateSurface_EnhancedPBR(
+        params,
         positionWS,
         positionWS,
         normalWS,
         normalWS,
         tangents,
         tangents,
@@ -228,9 +233,10 @@ Surface EvaluateSurface_EnhancedPBR(
         false);
         false);
 }
 }
 
 
-Surface EvaluateSurface_EnhancedPBR(VsOutput IN, PixelGeometryData geoData, float4 uvDxDy, bool customDerivatives)
+Surface EvaluateSurface_EnhancedPBR(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params, float4 uvDxDy, bool customDerivatives)
 {
 {
     return EvaluateSurface_EnhancedPBR(
     return EvaluateSurface_EnhancedPBR(
+        params,
         geoData.positionWS,
         geoData.positionWS,
         geoData.vertexNormal,
         geoData.vertexNormal,
         geoData.tangents,
         geoData.tangents,
@@ -244,9 +250,10 @@ Surface EvaluateSurface_EnhancedPBR(VsOutput IN, PixelGeometryData geoData, floa
         GetVertexColor(IN));
         GetVertexColor(IN));
 }
 }
 
 
-Surface EvaluateSurface_EnhancedPBR(VsOutput IN, PixelGeometryData geoData)
+Surface EvaluateSurface_EnhancedPBR(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params)
 {
 {
     return EvaluateSurface_EnhancedPBR(
     return EvaluateSurface_EnhancedPBR(
+        params,
         geoData.positionWS,
         geoData.positionWS,
         geoData.vertexNormal,
         geoData.vertexNormal,
         geoData.tangents,
         geoData.tangents,

+ 7 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_VertexEval.azsli

@@ -19,6 +19,7 @@
 #include "../MaterialFunctions/StandardTransformDetailUvs.azsli"
 #include "../MaterialFunctions/StandardTransformDetailUvs.azsli"
 
 
 VsOutput EvaluateVertexGeometry_EnhancedPBR(
 VsOutput EvaluateVertexGeometry_EnhancedPBR(
+    const MaterialParameters params,
     float3 position,
     float3 position,
     float3 normal,
     float3 normal,
     float4 tangent,
     float4 tangent,
@@ -29,24 +30,25 @@ VsOutput EvaluateVertexGeometry_EnhancedPBR(
     float4 color0)
     float4 color0)
 {
 {
     // BasePBRP
     // BasePBRP
-    VsOutput output = EvaluateVertexGeometry_BasePBR(position, normal, tangent, uv0, uv1, instanceId, useVertexColor, color0);
+    VsOutput output = EvaluateVertexGeometry_BasePBR(params, position, normal, tangent, uv0, uv1, instanceId, useVertexColor, color0);
 
 
     // Detail UVs
     // Detail UVs
     float2 detailUvs[UvSetCount] = { uv0, uv1 };
     float2 detailUvs[UvSetCount] = { uv0, uv1 };
-    TransformDetailUvs(detailUvs, output.detailUvs);
+    TransformDetailUvs(params, detailUvs, output.detailUvs);
 
 
     return output;
     return output;
 }
 }
 
 
 // Helper functions to keep compatible with the previous version
 // Helper functions to keep compatible with the previous version
 // because dxc compiler doesn't allow default parameters on functions with overloads
 // because dxc compiler doesn't allow default parameters on functions with overloads
-VsOutput EvaluateVertexGeometry_EnhancedPBR(VsInput IN, VsSystemValues SV)
+VsOutput EvaluateVertexGeometry_EnhancedPBR(VsInput IN, VsSystemValues SV, const MaterialParameters params)
 {
 {
     float4 color0;
     float4 color0;
     bool useVertexColor0;
     bool useVertexColor0;
     GetVertexColor(IN, color0, useVertexColor0);
     GetVertexColor(IN, color0, useVertexColor0);
 
 
     return EvaluateVertexGeometry_EnhancedPBR(
     return EvaluateVertexGeometry_EnhancedPBR(
+        params,
         IN.position,
         IN.position,
         IN.normal,
         IN.normal,
         IN.tangent,
         IN.tangent,
@@ -58,6 +60,7 @@ VsOutput EvaluateVertexGeometry_EnhancedPBR(VsInput IN, VsSystemValues SV)
 }
 }
 
 
 VsOutput EvaluateVertexGeometry_EnhancedPBR(
 VsOutput EvaluateVertexGeometry_EnhancedPBR(
+    const MaterialParameters params,
     float3 position,
     float3 position,
     float3 normal,
     float3 normal,
     float4 tangent,
     float4 tangent,
@@ -66,6 +69,7 @@ VsOutput EvaluateVertexGeometry_EnhancedPBR(
     uint instanceId)
     uint instanceId)
 {
 {
     return EvaluateVertexGeometry_EnhancedPBR(
     return EvaluateVertexGeometry_EnhancedPBR(
+        params,
         position,
         position,
         normal,
         normal,
         tangent,
         tangent,

+ 20 - 0
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_MaterialInputs.azsli

@@ -0,0 +1,20 @@
+/*
+ * 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 "../MaterialInputs/BaseColorInput.azsli"
+#include "../MaterialInputs/DualSpecular.azsli"
+#include "../MaterialInputs/NormalInput.azsli"
+#include "../MaterialInputs/RoughnessInput.azsli"
+#include "../MaterialInputs/SpecularInput.azsli"
+#include "../MaterialInputs/UvSetCount.azsli"
+#include "../MaterialInputs/SubsurfaceInput.azsli"
+#include "../MaterialInputs/TransmissionInput.azsli"
+#include "../MaterialInputs/OcclusionInput.azsli"
+

+ 0 - 88
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_MaterialSrg.azsli

@@ -1,88 +0,0 @@
-/*
- * 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 "../MaterialInputs/BaseColorInput.azsli"
-#include "../MaterialInputs/DualSpecular.azsli"
-#include "../MaterialInputs/NormalInput.azsli"
-#include "../MaterialInputs/RoughnessInput.azsli"
-#include "../MaterialInputs/SpecularInput.azsli"
-#include "../MaterialInputs/UvSetCount.azsli"
-#include "../MaterialInputs/SubsurfaceInput.azsli"
-#include "../MaterialInputs/TransmissionInput.azsli"
-#include "../MaterialInputs/OcclusionInput.azsli"
-
-#include <Atom/Features/SrgSemantics.azsli>
-
-ShaderResourceGroup MaterialSrg : SRG_PerMaterial
-{
-    // Auto-generate material SRG fields for common inputs
-    COMMON_SRG_INPUTS_BASE_COLOR(m_iris_)
-    COMMON_SRG_INPUTS_NORMAL(m_iris_)
-    COMMON_SRG_INPUTS_ROUGHNESS(m_iris_)
-    COMMON_SRG_INPUTS_BASE_COLOR(m_sclera_)
-    COMMON_SRG_INPUTS_NORMAL(m_sclera_)
-    COMMON_SRG_INPUTS_ROUGHNESS(m_sclera_)
-    COMMON_SRG_INPUTS_SPECULAR_F0()
-    COMMON_SRG_INPUTS_DUAL_SPECULAR()
-    COMMON_SRG_INPUTS_OCCLUSION()
-
-    Sampler m_sampler
-    {
-        AddressU = Clamp;
-        AddressV = Clamp;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        MipFilter = Linear;
-    };
-
-    Texture2D m_brdfMap;
-
-    Sampler m_samplerBrdf
-    {
-        AddressU = Clamp;
-        AddressV = Clamp;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        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:  (shrinkFactor, transmissionNdLBias, distanceAttenuation, scale)
-    float4 m_transmissionParams;
-
-    // (float3 TintColor, thickness)
-    float4 m_transmissionTintThickness;
-    Texture2D m_transmissionThicknessMap;
-    uint m_transmissionThicknessMapUvIndex;
-
-    // Normalized Eye parameters. The following three parameters
-    // are unitless and assume normalized Eye geometry, where the
-    // radius of the pseudo-sphere is 0.5.
-    float m_irisDepth; //Distance from the center of the Eye to the center of the Iris-XZ plane.
-    float m_eyeIrisRadius; // Radius of the Iris, measured from the center of the Pupil (imagine a Circle in the XZ plane).
-    float m_limbusSize;
-    float m_irisUvScale;
-
-    // Index of refraction of the Inner Eye. This is the sequence
-    // of mediums the light has to travel: Air -> Cornea -> Aqueus Humor -> Pupil/Iris Plane.
-    // The Inner Eye, refers to the combined "Cornea -> Aqueus Humor" layers because in real life
-    // their IORs are very similar.
-    float m_innerEyeIOR;
-}

+ 5 - 2
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_PixelGeometryEval.azsli

@@ -22,6 +22,7 @@
 // since the file references an option o_normal_useTexture, which is not defined for the Eye shader. Need to find an elegant
 // since the file references an option o_normal_useTexture, which is not defined for the Eye shader. Need to find an elegant
 // way to handle this.
 // way to handle this.
 PixelGeometryData EvaluatePixelGeometry_Eye(
 PixelGeometryData EvaluatePixelGeometry_Eye(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 normalWS,
     real3 normalWS,
     real3 tangentWS,
     real3 tangentWS,
@@ -57,6 +58,7 @@ PixelGeometryData EvaluatePixelGeometry_Eye(
 }
 }
 
 
 PixelGeometryData EvaluatePixelGeometry_Eye(
 PixelGeometryData EvaluatePixelGeometry_Eye(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 normalWS,
     real3 normalWS,
     real3 tangentWS,
     real3 tangentWS,
@@ -67,7 +69,7 @@ PixelGeometryData EvaluatePixelGeometry_Eye(
 {
 {
     // Base PBR Geo Data
     // Base PBR Geo Data
     bool evaluateTangentFrame = o_iris_o_normal_useTexture || o_sclera_o_normal_useTexture;
     bool evaluateTangentFrame = o_iris_o_normal_useTexture || o_sclera_o_normal_useTexture;
-    PixelGeometryData geoData = EvaluatePixelGeometry_Eye(positionWS, normalWS, tangentWS, bitangentWS, uv, isFrontFace, evaluateTangentFrame);
+    PixelGeometryData geoData = EvaluatePixelGeometry_Eye(params, positionWS, normalWS, tangentWS, bitangentWS, uv, isFrontFace, evaluateTangentFrame);
 
 
     // Skin specifics
     // Skin specifics
     geoData.localPosition = localPosition;
     geoData.localPosition = localPosition;
@@ -75,7 +77,7 @@ PixelGeometryData EvaluatePixelGeometry_Eye(
     return geoData;
     return geoData;
 }
 }
 
 
-PixelGeometryData EvaluatePixelGeometry_Eye(VsOutput IN, bool isFrontFace)
+PixelGeometryData EvaluatePixelGeometry_Eye(VsOutput IN, bool isFrontFace, const MaterialParameters params)
 {
 {
     real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
     real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
     real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
     real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
@@ -87,6 +89,7 @@ PixelGeometryData EvaluatePixelGeometry_Eye(VsOutput IN, bool isFrontFace)
     bitangentWS = real3(normalize(mul(objectToWorld, float4(IN.bitangent, 0.0)).xyz));
     bitangentWS = real3(normalize(mul(objectToWorld, float4(IN.bitangent, 0.0)).xyz));
 
 
     PixelGeometryData geoData = EvaluatePixelGeometry_Eye(
     PixelGeometryData geoData = EvaluatePixelGeometry_Eye(
+        params,
         IN.worldPosition,
         IN.worldPosition,
         normalWS,
         normalWS,
         tangentWS,
         tangentWS,

+ 54 - 53
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_SurfaceEval.azsli

@@ -40,13 +40,19 @@
 // Assumptions:
 // Assumptions:
 // 1- Regarding model coordinates, it is assumed that the center of the pupil is aligned
 // 1- Regarding model coordinates, it is assumed that the center of the pupil is aligned
 //    with the center of the sphere along the Y (Forward) axis.
 //    with the center of the sphere along the Y (Forward) axis.
-real GetIrisRadiusMask(real vertexDistanceToCenterOfPupil)
+real GetIrisRadiusMask(real vertexDistanceToCenterOfPupil, const MaterialParameters params)
 {
 {
     // Use a sigmoid to determine the sclera/iris contribution for each point.
     // Use a sigmoid to determine the sclera/iris contribution for each point.
-    return PseudoSigmoid(vertexDistanceToCenterOfPupil, real(MaterialSrg::m_eyeIrisRadius), real(MaterialSrg::m_limbusSize));
+    return PseudoSigmoid(vertexDistanceToCenterOfPupil, real(params.m_eyeIrisRadius), real(params.m_limbusSize));
+}
+
+sampler GetEyeSampler(const MaterialParameters params)
+{
+    return GetMaterialTextureSampler(params.m_clampSampler);
 }
 }
 
 
 Surface EvaluateSurface_Eye(
 Surface EvaluateSurface_Eye(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 vertexNormal,
     real3 vertexNormal,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -81,33 +87,21 @@ Surface EvaluateSurface_Eye(
     const float distFromCenter = length(localPosition.xz);
     const float distFromCenter = length(localPosition.xz);
 #endif
 #endif
 
 
-    real mask = GetIrisRadiusMask(distFromCenter);
+    real mask = GetIrisRadiusMask(distFromCenter, params);
 
 
     // ------- Normal -------
     // ------- Normal -------
 
 
     surface.vertexNormal = normalize(vertexNormal);
     surface.vertexNormal = normalize(vertexNormal);
 
 
     // Get surface normal for each layer (iris/sclera) and blend using the mask defined above
     // Get surface normal for each layer (iris/sclera) and blend using the mask defined above
-    float2 irisNormalUv = uvs[MaterialSrg::m_iris_m_normalMapUvIndex];
-    float2 scleraNormalUv = uvs[MaterialSrg::m_sclera_m_normalMapUvIndex];
-    float3 irisNormal, scleraNormal;
+    float2 irisNormalUv = uvs[params.m_iris_m_normalMapUvIndex];
+    float2 scleraNormalUv = uvs[params.m_sclera_m_normalMapUvIndex];
     
     
-    if (customDerivatives)
-    {
-        irisNormal = GetNormalInputWS(MaterialSrg::m_iris_m_normalMap, MaterialSrg::m_sampler, irisNormalUv, MaterialSrg::m_iris_m_flipNormalX, MaterialSrg::m_iris_m_flipNormalY, isFrontFace, surface.vertexNormal,
-                                        tangents[MaterialSrg::m_iris_m_normalMapUvIndex], bitangents[MaterialSrg::m_iris_m_normalMapUvIndex], uvMatrix, o_iris_o_normal_useTexture, real(MaterialSrg::m_iris_m_normalFactor), uvDxDy, customDerivatives);
-
-        scleraNormal = GetNormalInputWS(MaterialSrg::m_sclera_m_normalMap, MaterialSrg::m_sampler, scleraNormalUv, MaterialSrg::m_sclera_m_flipNormalX, MaterialSrg::m_sclera_m_flipNormalY, isFrontFace, surface.vertexNormal,
-                                        tangents[MaterialSrg::m_sclera_m_normalMapUvIndex], bitangents[MaterialSrg::m_sclera_m_normalMapUvIndex], uvMatrix, o_sclera_o_normal_useTexture, real(MaterialSrg::m_sclera_m_normalFactor), uvDxDy, customDerivatives);
-    }
-    else
-    {
-        irisNormal = GetNormalInputWS(MaterialSrg::m_iris_m_normalMap, MaterialSrg::m_sampler, irisNormalUv, MaterialSrg::m_iris_m_flipNormalX, MaterialSrg::m_iris_m_flipNormalY, isFrontFace, surface.vertexNormal,
-                                        tangents[MaterialSrg::m_iris_m_normalMapUvIndex], bitangents[MaterialSrg::m_iris_m_normalMapUvIndex], uvMatrix, o_iris_o_normal_useTexture, real(MaterialSrg::m_iris_m_normalFactor), float4(0.0f, 0.0f, 0.0f, 0.0f), false);
-
-        scleraNormal = GetNormalInputWS(MaterialSrg::m_sclera_m_normalMap, MaterialSrg::m_sampler, scleraNormalUv, MaterialSrg::m_sclera_m_flipNormalX, MaterialSrg::m_sclera_m_flipNormalY, isFrontFace, surface.vertexNormal,
-                                        tangents[MaterialSrg::m_sclera_m_normalMapUvIndex], bitangents[MaterialSrg::m_sclera_m_normalMapUvIndex], uvMatrix, o_sclera_o_normal_useTexture, real(MaterialSrg::m_sclera_m_normalFactor), float4(0.0f, 0.0f, 0.0f, 0.0f), false);
-    }
+    float3 irisNormal = GetNormalInputWS(GetMaterialTexture(params.m_iris_m_normalMap), GetEyeSampler(params), irisNormalUv, params.m_iris_m_flipNormalX, params.m_iris_m_flipNormalY, isFrontFace, surface.vertexNormal,
+                                        tangents[params.m_iris_m_normalMapUvIndex], bitangents[params.m_iris_m_normalMapUvIndex], uvMatrix, o_iris_o_normal_useTexture, real(params.m_iris_m_normalFactor), uvDxDy, customDerivatives);
+
+    float3 scleraNormal = GetNormalInputWS(GetMaterialTexture(params.m_sclera_m_normalMap), GetEyeSampler(params), scleraNormalUv, params.m_sclera_m_flipNormalX, params.m_sclera_m_flipNormalY, isFrontFace, surface.vertexNormal,
+                                        tangents[params.m_sclera_m_normalMapUvIndex], bitangents[params.m_sclera_m_normalMapUvIndex], uvMatrix, o_sclera_o_normal_useTexture, real(params.m_sclera_m_normalFactor), uvDxDy, customDerivatives);
 
 
     surface.normal = normalize(lerp(irisNormal, scleraNormal, mask));
     surface.normal = normalize(lerp(irisNormal, scleraNormal, mask));
 
 
@@ -117,7 +111,7 @@ Surface EvaluateSurface_Eye(
 
 
     // Get refracted vector
     // Get refracted vector
     const real airIOR = 1.0;
     const real airIOR = 1.0;
-    real refractionFactor = airIOR/real(MaterialSrg::m_innerEyeIOR);
+    real refractionFactor = airIOR/real(params.m_innerEyeIOR);
     real3 refractedDir = refract(viewDir, surface.GetVertexNormal(), refractionFactor);
     real3 refractedDir = refract(viewDir, surface.GetVertexNormal(), refractionFactor);
 
 
     // Get UV offset due to refraction (based on http://www.iryoku.com/stare-into-the-future)
     // Get UV offset due to refraction (based on http://www.iryoku.com/stare-into-the-future)
@@ -131,14 +125,14 @@ Surface EvaluateSurface_Eye(
 
 
 #if USE_NORMALIZED_SPACE_ALGORITHM
 #if USE_NORMALIZED_SPACE_ALGORITHM
     real3 positionDirWS = normalize(mul(worldMatrix, real4(localPosition, 0.0)).xyz);
     real3 positionDirWS = normalize(mul(worldMatrix, real4(localPosition, 0.0)).xyz);
-    const real height = max(dot(gazeDirWS, positionDirWS) * NORMALIZED_EYE_RADIUS - real(MaterialSrg::m_irisDepth), 0.0);
+    const real height = max(dot(gazeDirWS, positionDirWS) * NORMALIZED_EYE_RADIUS - real(params.m_irisDepth), 0.0);
 #else
 #else
     // Position direction corresponds to the vector from the object's center to the point in WS (in order to support refraction in all orientations)
     // Position direction corresponds to the vector from the object's center to the point in WS (in order to support refraction in all orientations)
     real3 positionDirWS = mul(worldMatrix, real4(localPosition, 0.0)).xyz;
     real3 positionDirWS = mul(worldMatrix, real4(localPosition, 0.0)).xyz;
     // Compute distance from current point to the iris plane
     // Compute distance from current point to the iris plane
     // m_irisDepth corresponds to the distance from the object origin to the local plane (XZ) where the iris lays.
     // m_irisDepth corresponds to the distance from the object origin to the local plane (XZ) where the iris lays.
     // By multiplying this parameter by the scale we avoid having to re-tune it everytime we change the object's scale.
     // By multiplying this parameter by the scale we avoid having to re-tune it everytime we change the object's scale.
-    const real height = max(dot(gazeDirWS, positionDirWS) - real(MaterialSrg::m_irisDepth)*scaleY, 0.0);
+    const real height = max(dot(gazeDirWS, positionDirWS) - real(params.m_irisDepth)*scaleY, 0.0);
 #endif
 #endif
 
 
 
 
@@ -168,30 +162,30 @@ Surface EvaluateSurface_Eye(
     real2 refractionUVOffset = -mul(refractedRay, real3x3(worldMatrixIT)).xz;
     real2 refractionUVOffset = -mul(refractedRay, real3x3(worldMatrixIT)).xz;
 #endif
 #endif
 
 
-    real2 irisRefractionUv = real2(uvs[MaterialSrg::m_iris_m_baseColorMapUvIndex]) + refractionUVOffset;
+    real2 irisRefractionUv = real2(uvs[params.m_iris_m_baseColorMapUvIndex]) + refractionUVOffset;
     real2 irisUvCenterOffset = irisRefractionUv - real2(0.5, 0.5);
     real2 irisUvCenterOffset = irisRefractionUv - real2(0.5, 0.5);
-    irisUvCenterOffset *= MaterialSrg::m_irisUvScale;
+    irisUvCenterOffset *= params.m_irisUvScale;
     irisRefractionUv = real2(0.5, 0.5) + irisUvCenterOffset;
     irisRefractionUv = real2(0.5, 0.5) + irisUvCenterOffset;
 
 
     //--------------------- Base Color ----------------------
     //--------------------- Base Color ----------------------
 
 
     // Sample iris color map and blend with the base iris color
     // Sample iris color map and blend with the base iris color
     real2 irisBaseColorUv = irisRefractionUv;
     real2 irisBaseColorUv = irisRefractionUv;
-    real3 irisSampledColor = GetBaseColorInput(MaterialSrg::m_iris_m_baseColorMap, MaterialSrg::m_sampler, irisBaseColorUv, real3(MaterialSrg::m_iris_m_baseColor), o_iris_o_baseColor_useTexture, uvDxDy, customDerivatives);
-    real3 irisColor = BlendBaseColor(irisSampledColor, real3(MaterialSrg::m_iris_m_baseColor), real(MaterialSrg::m_iris_m_baseColorFactor), o_iris_o_baseColorTextureBlendMode, o_iris_o_baseColor_useTexture);
+    real3 irisSampledColor = GetBaseColorInput(GetMaterialTexture(params.m_iris_m_baseColorMap), GetEyeSampler(params), irisBaseColorUv, real3(params.m_iris_m_baseColor.rgb), o_iris_o_baseColor_useTexture, uvDxDy, customDerivatives);
+    real3 irisColor = BlendBaseColor(irisSampledColor, real3(params.m_iris_m_baseColor.rgb), real(params.m_iris_m_baseColorFactor), o_iris_o_baseColorTextureBlendMode, o_iris_o_baseColor_useTexture);
 
 
     // Sample sclera color map and blend with the base sclera color
     // Sample sclera color map and blend with the base sclera color
-    real2 scleraBaseColorUv = uvs[MaterialSrg::m_sclera_m_baseColorMapUvIndex];
-    real3 scleraSampledColor = GetBaseColorInput(MaterialSrg::m_sclera_m_baseColorMap, MaterialSrg::m_sampler, scleraBaseColorUv, real3(MaterialSrg::m_sclera_m_baseColor), o_sclera_o_baseColor_useTexture, uvDxDy, customDerivatives);
-    real3 scleraColor = BlendBaseColor(scleraSampledColor, real3(MaterialSrg::m_sclera_m_baseColor), real(MaterialSrg::m_sclera_m_baseColorFactor), o_sclera_o_baseColorTextureBlendMode, o_sclera_o_baseColor_useTexture);
+    real2 scleraBaseColorUv = uvs[params.m_sclera_m_baseColorMapUvIndex];
+    real3 scleraSampledColor = GetBaseColorInput(GetMaterialTexture(params.m_sclera_m_baseColorMap), GetEyeSampler(params), scleraBaseColorUv, real3(params.m_sclera_m_baseColor.rgb), o_sclera_o_baseColor_useTexture, uvDxDy, customDerivatives);
+    real3 scleraColor = BlendBaseColor(scleraSampledColor, real3(params.m_sclera_m_baseColor.rgb), real(params.m_sclera_m_baseColorFactor), o_sclera_o_baseColorTextureBlendMode, o_sclera_o_baseColor_useTexture);
 
 
     // Blend iris and sclera output colors
     // Blend iris and sclera output colors
     real3 baseColor = lerp(irisColor, scleraColor, mask);
     real3 baseColor = lerp(irisColor, scleraColor, mask);
 
 
     // ------- Specular -------
     // ------- Specular -------
 
 
-    real2 specularUv = uvs[MaterialSrg::m_specularF0MapUvIndex];
-    real specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, real(MaterialSrg::m_specularF0Factor), o_specularF0_useTexture, uvDxDy, customDerivatives);
+    real2 specularUv = uvs[params.m_specularF0MapUvIndex];
+    real specularF0Factor = GetSpecularInput(GetMaterialTexture(params.m_specularF0Map), GetEyeSampler(params), specularUv, real(params.m_specularF0Factor), o_specularF0_useTexture, uvDxDy, customDerivatives);
 
 
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor);
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor);
 
 
@@ -199,45 +193,48 @@ Surface EvaluateSurface_Eye(
 
 
     // Get surface roughness for each layer (iris/sclera) and blend using the mask defined above
     // Get surface roughness for each layer (iris/sclera) and blend using the mask defined above
     real2 irisRoughnessUv = irisRefractionUv;
     real2 irisRoughnessUv = irisRefractionUv;
-    real irisRoughnessLinear = GetRoughnessInput(MaterialSrg::m_iris_m_roughnessMap, MaterialSrg::m_sampler, irisRoughnessUv, real(MaterialSrg::m_iris_m_roughnessFactor),
-                                        real(MaterialSrg::m_iris_m_roughnessLowerBound), real(MaterialSrg::m_iris_m_roughnessUpperBound), o_iris_o_roughness_useTexture, uvDxDy, customDerivatives);
+    real irisRoughnessLinear = GetRoughnessInput(GetMaterialTexture(params.m_iris_m_roughnessMap), GetEyeSampler(params), irisRoughnessUv, real(params.m_iris_m_roughnessFactor),
+                                        real(params.m_iris_m_roughnessLowerBound), real(params.m_iris_m_roughnessUpperBound), o_iris_o_roughness_useTexture, uvDxDy, customDerivatives);
 
 
-    real2 scleraRoughnessUv = uvs[MaterialSrg::m_sclera_m_roughnessMapUvIndex];
-    real scleraRoughnessLinear = GetRoughnessInput(MaterialSrg::m_sclera_m_roughnessMap, MaterialSrg::m_sampler, scleraRoughnessUv, real(MaterialSrg::m_sclera_m_roughnessFactor),
-                                        real(MaterialSrg::m_sclera_m_roughnessLowerBound), real(MaterialSrg::m_sclera_m_roughnessUpperBound), o_sclera_o_roughness_useTexture, uvDxDy, customDerivatives);
+    real2 scleraRoughnessUv = uvs[params.m_sclera_m_roughnessMapUvIndex];
+    real scleraRoughnessLinear = GetRoughnessInput(GetMaterialTexture(params.m_sclera_m_roughnessMap), GetEyeSampler(params), scleraRoughnessUv, real(params.m_sclera_m_roughnessFactor),
+                                        real(params.m_sclera_m_roughnessLowerBound), real(params.m_sclera_m_roughnessUpperBound), o_sclera_o_roughness_useTexture, uvDxDy, customDerivatives);
 
 
     surface.roughnessLinear = lerp(irisRoughnessLinear, scleraRoughnessLinear, mask);
     surface.roughnessLinear = lerp(irisRoughnessLinear, scleraRoughnessLinear, mask);
     surface.CalculateRoughnessA();
     surface.CalculateRoughnessA();
 
 
     // ------- Dual Specular -------
     // ------- Dual Specular -------
 
 
-    GetDualSpecularInput(surface.GetSpecularNormal(), surface.roughnessLinear, surface.specularF0.x, MaterialSrg::m_dualSpecFactor,
-                          MaterialSrg::m_dualSpecF0Multiplier, MaterialSrg::m_dualSpecRoughnessExponent, MaterialSrg::m_dualSpecRoughnessMultiplier,
+    GetDualSpecularInput(surface.GetSpecularNormal(), surface.roughnessLinear, surface.specularF0.x, params.m_dualSpecFactor,
+                          params.m_dualSpecF0Multiplier, params.m_dualSpecRoughnessExponent, params.m_dualSpecRoughnessMultiplier,
                           surface.dualSpecRoughness, surface.dualSpecRoughnessA2, surface.dualSpecF0, surface.dualSpecFactor);
                           surface.dualSpecRoughness, surface.dualSpecRoughnessA2, surface.dualSpecF0, surface.dualSpecFactor);
 
 
     // ------- Subsurface -------
     // ------- Subsurface -------
 
 
 #if OUTPUT_SUBSURFACE
 #if OUTPUT_SUBSURFACE
-    real2 subsurfaceUv = uvs[MaterialSrg::m_subsurfaceScatteringInfluenceMapUvIndex];
-    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, real(MaterialSrg::m_subsurfaceScatteringFactor), uvDxDy, customDerivatives);
-    surface.subsurfaceScatteringQuality = real(MaterialSrg::m_subsurfaceScatteringQuality);
-    surface.scatterDistance = real3(MaterialSrg::m_scatterDistance);
+    real2 subsurfaceUv = uvs[params.m_subsurfaceScatteringInfluenceMapUvIndex];
+    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(GetMaterialTexture(params.m_subsurfaceScatteringInfluenceMap), GetEyeSampler(params), subsurfaceUv, real(params.m_subsurfaceScatteringFactor), uvDxDy, customDerivatives);
+    surface.subsurfaceScatteringQuality = real(params.m_subsurfaceScatteringQuality);
+    surface.scatterDistance = real3(params.m_scatterDistance);
 #endif
 #endif
 
 
     // ------- Occlusion -------
     // ------- Occlusion -------
     
     
-    surface.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_diffuseOcclusionMapUvIndex], real(MaterialSrg::m_diffuseOcclusionFactor), o_diffuseOcclusion_useTexture, uvDxDy, customDerivatives);
-    surface.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_specularOcclusionMapUvIndex], real(MaterialSrg::m_specularOcclusionFactor), o_specularOcclusion_useTexture, uvDxDy, customDerivatives);
+    // These parameters aren't in the eye.materialtype, so they don't exist in the MaterialParameters - struct
+    // surface.diffuseAmbientOcclusion = GetOcclusionInput(GetMaterialTexture(params.m_diffuseOcclusionMap), GetEyeSampler(params), uvs[params.m_diffuseOcclusionMapUvIndex], real(params.m_diffuseOcclusionFactor), o_diffuseOcclusion_useTexture, uvDxDy, customDerivatives);
+    // surface.specularOcclusion = GetOcclusionInput(GetMaterialTexture(params.m_specularOcclusionMap), GetEyeSampler(params), uvs[params.m_specularOcclusionMapUvIndex], real(params.m_specularOcclusionFactor), o_specularOcclusion_useTexture, uvDxDy, customDerivatives);
+    surface.diffuseAmbientOcclusion = 1.0f;
+    surface.specularOcclusion = 1.0f;
 
 
     // ------- Transmission -------
     // ------- Transmission -------
 
 
 #if ENABLE_TRANSMISSION
 #if ENABLE_TRANSMISSION
-    real2 transmissionUv = uvs[MaterialSrg::m_transmissionThicknessMapUvIndex];
-    real4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, real4(MaterialSrg::m_transmissionTintThickness), uvDxDy, customDerivatives);
+    real2 transmissionUv = uvs[params.m_transmissionThicknessMapUvIndex];
+    real4 transmissionTintThickness = GeTransmissionInput(GetMaterialTexture(params.m_transmissionThicknessMap), GetEyeSampler(params), transmissionUv, real4(params.m_transmissionTintThickness), uvDxDy, customDerivatives);
     surface.transmission.tint = transmissionTintThickness.rgb;
     surface.transmission.tint = transmissionTintThickness.rgb;
     surface.transmission.thickness = transmissionTintThickness.w;
     surface.transmission.thickness = transmissionTintThickness.w;
-    surface.transmission.transmissionParams = real4(MaterialSrg::m_transmissionParams);
-    surface.transmission.scatterDistance = real3(MaterialSrg::m_scatterDistance);
+    surface.transmission.transmissionParams = real4(params.m_transmissionParams);
+    surface.transmission.scatterDistance = real3(params.m_scatterDistance);
 #endif
 #endif
 
 
     return surface;
     return surface;
@@ -246,6 +243,7 @@ Surface EvaluateSurface_Eye(
 // helper function to keep compatible with the previous version
 // helper function to keep compatible with the previous version
 // because dxc compiler doesn't allow default parameters on functions with overloads
 // because dxc compiler doesn't allow default parameters on functions with overloads
 Surface EvaluateSurface_Eye(
 Surface EvaluateSurface_Eye(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 vertexNormal,
     real3 vertexNormal,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -257,6 +255,7 @@ Surface EvaluateSurface_Eye(
     real3x3 worldMatrixIT)
     real3x3 worldMatrixIT)
 {
 {
     return EvaluateSurface_Eye(
     return EvaluateSurface_Eye(
+        params,
         positionWS,
         positionWS,
         vertexNormal,
         vertexNormal,
         tangents,
         tangents,
@@ -270,9 +269,10 @@ Surface EvaluateSurface_Eye(
         false);
         false);
 }
 }
 
 
-Surface EvaluateSurface_Eye(VsOutput IN, PixelGeometryData geoData, float4 uvDxDy, bool customDerivatives)
+Surface EvaluateSurface_Eye(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params, float4 uvDxDy, bool customDerivatives)
 {
 {
     return EvaluateSurface_Eye(
     return EvaluateSurface_Eye(
+        params,
         geoData.positionWS,
         geoData.positionWS,
         geoData.vertexNormal,
         geoData.vertexNormal,
         geoData.tangents,
         geoData.tangents,
@@ -286,9 +286,10 @@ Surface EvaluateSurface_Eye(VsOutput IN, PixelGeometryData geoData, float4 uvDxD
         customDerivatives);
         customDerivatives);
 }
 }
 
 
-Surface EvaluateSurface_Eye(VsOutput IN, PixelGeometryData geoData)
+Surface EvaluateSurface_Eye(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params)
 {
 {
     return EvaluateSurface_Eye(
     return EvaluateSurface_Eye(
+        params,
         geoData.positionWS,
         geoData.positionWS,
         geoData.vertexNormal,
         geoData.vertexNormal,
         geoData.tangents,
         geoData.tangents,

+ 5 - 2
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_VertexEval.azsli

@@ -19,6 +19,7 @@
 #include <Atom/Features/InstancedTransforms.azsli>
 #include <Atom/Features/InstancedTransforms.azsli>
 
 
 VsOutput EvaluateVertexGeometry_Eye(
 VsOutput EvaluateVertexGeometry_Eye(
+    const MaterialParameters params,
     float3 position,
     float3 position,
     float3 normal,
     float3 normal,
     float4 tangent,
     float4 tangent,
@@ -55,6 +56,7 @@ VsOutput EvaluateVertexGeometry_Eye(
 // Avoids compilation errors for compute shaders, listed in a materialpipeline,
 // Avoids compilation errors for compute shaders, listed in a materialpipeline,
 // that call EvaluateVertexGeometry().
 // that call EvaluateVertexGeometry().
 VsOutput EvaluateVertexGeometry_Eye(
 VsOutput EvaluateVertexGeometry_Eye(
+    const MaterialParameters params,
     float3 position,
     float3 position,
     float3 normal,
     float3 normal,
     float4 tangent,
     float4 tangent,
@@ -63,12 +65,13 @@ VsOutput EvaluateVertexGeometry_Eye(
     uint instanceId)
     uint instanceId)
 {
 {
     const float3 bitangent = float3(0, 0, 0);
     const float3 bitangent = float3(0, 0, 0);
-    return EvaluateVertexGeometry_Eye(position, normal, tangent, bitangent, uv0, uv1, instanceId);
+    return EvaluateVertexGeometry_Eye(params, position, normal, tangent, bitangent, uv0, uv1, instanceId);
 }
 }
 
 
-VsOutput EvaluateVertexGeometry_Eye(VsInput IN, VsSystemValues SV)
+VsOutput EvaluateVertexGeometry_Eye(VsInput IN, VsSystemValues SV, const MaterialParameters params)
 {
 {
     return EvaluateVertexGeometry_Eye(
     return EvaluateVertexGeometry_Eye(
+        params,
         IN.position,
         IN.position,
         IN.normal,
         IN.normal,
         IN.tangent,
         IN.tangent,

+ 11 - 8
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/MultilayerParallaxDepth.azsli

@@ -12,6 +12,7 @@
 #include "ParallaxShadowUtil.azsli"
 #include "ParallaxShadowUtil.azsli"
 
 
  void MultilayerSetPixelDepth(
  void MultilayerSetPixelDepth(
+     const MaterialParameters params,
      real3 vertexBlendMask,
      real3 vertexBlendMask,
      inout float3 worldPosition,
      inout float3 worldPosition,
      real3 normal,
      real3 normal,
@@ -24,24 +25,26 @@
      inout float depthCS,
      inout float depthCS,
      out bool isClipped)
      out bool isClipped)
 {
 {
-    real3x3 uvMatrix = MaterialSrg::m_parallaxUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : CreateIdentity3x3_real();
-    real3x3 uvMatrixInverse = MaterialSrg::m_parallaxUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrixInverse) : CreateIdentity3x3_real();
+    real3x3 uvMatrix = params.m_parallaxUvIndex == 0 ? real3x3(params.m_uvMatrix) : CreateIdentity3x3_real();
+    real3x3 uvMatrixInverse = params.m_parallaxUvIndex == 0 ? real3x3(params.m_uvMatrixInverse) : CreateIdentity3x3_real();
 
 
-    real parallaxOverallOffset = real(MaterialSrg::m_displacementMax);
-    real parallaxOverallFactor = real(MaterialSrg::m_displacementMax) - real(MaterialSrg::m_displacementMin);
+    real parallaxOverallOffset = real(params.m_displacementMax);
+    real parallaxOverallFactor = real(params.m_displacementMax) - real(params.m_displacementMin);
     
     
-    AdjustParallaxShadowCaster(parallaxOverallFactor, parallaxOverallOffset, real(MaterialSrg::m_parallax_pdo_shadowFactor));
+    AdjustParallaxShadowCaster(parallaxOverallFactor, parallaxOverallOffset, real(params.m_parallax_pdo_shadowFactor));
     
     
     s_blendMaskFromVertexStream = vertexBlendMask;
     s_blendMaskFromVertexStream = vertexBlendMask;
     
     
+    // heightmap and heightmap sampler don't matter here: They get passed to the GetDepth() - function of the StandardMultiLayerPBR - material, where they are ignored.
     GetParallaxInput(
     GetParallaxInput(
-        normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex],
+        GetMaterialTexture(params.m_layer1_m_heightmap), GetMaterialTextureSampler(), normal, tangents[params.m_parallaxUvIndex], bitangents[params.m_parallaxUvIndex],
         parallaxOverallFactor, parallaxOverallOffset, 
         parallaxOverallFactor, parallaxOverallOffset, 
         objectToWorld, uvMatrix, uvMatrixInverse,
         objectToWorld, uvMatrix, uvMatrixInverse,
-        uvs[MaterialSrg::m_parallaxUvIndex], worldPosition, depthNDC, depthCS, isClipped);
+        uvs[params.m_parallaxUvIndex], worldPosition, depthNDC, depthCS, isClipped);
 }
 }
 
 
  void MultilayerSetPixelDepth(
  void MultilayerSetPixelDepth(
+     const MaterialParameters params,
      real3 vertexBlendMask,
      real3 vertexBlendMask,
      inout float3 positionWS,
      inout float3 positionWS,
      real3 normal,
      real3 normal,
@@ -56,5 +59,5 @@
     float depthCS = 1.0;
     float depthCS = 1.0;
     bool isClipped = false;
     bool isClipped = false;
 
 
-    MultilayerSetPixelDepth(vertexBlendMask, positionWS, normal, tangents, bitangents, uvs, isFrontFace, objectToWorld, depthNDC, depthCS, isClipped);
+    MultilayerSetPixelDepth(params, vertexBlendMask, positionWS, normal, tangents, bitangents, uvs, isFrontFace, objectToWorld, depthNDC, depthCS, isClipped);
 }
 }

+ 14 - 11
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/ParallaxDepth.azsli

@@ -14,6 +14,7 @@
 #include "ParallaxShadowUtil.azsli"
 #include "ParallaxShadowUtil.azsli"
 
 
  void SetPixelDepth(
  void SetPixelDepth(
+     const MaterialParameters params,
      inout float3 positionWS,
      inout float3 positionWS,
      real3 normal,
      real3 normal,
      float3 tangents[UvSetCount],
      float3 tangents[UvSetCount],
@@ -25,22 +26,23 @@
      inout float depthCS,
      inout float depthCS,
      out bool isClipped)
      out bool isClipped)
 {
 {
-    real3x3 uvMatrix = MaterialSrg::m_parallaxUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : CreateIdentity3x3_real();
-    real3x3 uvMatrixInverse = MaterialSrg::m_parallaxUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrixInverse) : CreateIdentity3x3_real();
+    real3x3 uvMatrix = params.m_parallaxUvIndex == 0 ? real3x3(params.m_uvMatrix) : CreateIdentity3x3_real();
+    real3x3 uvMatrixInverse = params.m_parallaxUvIndex == 0 ? real3x3(params.m_uvMatrixInverse) : CreateIdentity3x3_real();
     
     
-    float heightmapScale = float(MaterialSrg::m_heightmapScale);
-    float heightmapOffset = float(MaterialSrg::m_heightmapOffset);
+    float heightmapScale = float(params.m_heightmapScale);
+    float heightmapOffset = float(params.m_heightmapOffset);
     
     
-    AdjustParallaxShadowCaster(heightmapScale, heightmapOffset, float(MaterialSrg::m_parallax_pdo_shadowFactor));
+    AdjustParallaxShadowCaster(heightmapScale, heightmapOffset, float(params.m_parallax_pdo_shadowFactor));
 
 
     GetParallaxInput(
     GetParallaxInput(
-        normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex],
+        GetMaterialTexture(params.m_heightmap), GetMaterialTextureSampler(), normal, tangents[params.m_parallaxUvIndex], bitangents[params.m_parallaxUvIndex],
         heightmapScale, heightmapOffset,
         heightmapScale, heightmapOffset,
         objectToWorld, uvMatrix, uvMatrixInverse,
         objectToWorld, uvMatrix, uvMatrixInverse,
-        uvs[MaterialSrg::m_parallaxUvIndex], positionWS, depthNDC, depthCS, isClipped);
+        uvs[params.m_parallaxUvIndex], positionWS, depthNDC, depthCS, isClipped);
 }
 }
 
 
  void SetPixelDepth(
  void SetPixelDepth(
+     const MaterialParameters params,
      inout float3 positionWS,
      inout float3 positionWS,
      real3 normal,
      real3 normal,
      float3 tangents[UvSetCount],
      float3 tangents[UvSetCount],
@@ -54,10 +56,11 @@
     float depthCS = 1.0;
     float depthCS = 1.0;
     bool isClipped = false;
     bool isClipped = false;
     
     
-    SetPixelDepth(positionWS, normal, tangents, bitangents, uvs, isFrontFace, objectToWorld, depthNDC, depthCS, isClipped);
+    SetPixelDepth(params, positionWS, normal, tangents, bitangents, uvs, isFrontFace, objectToWorld, depthNDC, depthCS, isClipped);
 }
 }
 
 
  void SetPixelDepth(
  void SetPixelDepth(
+     const MaterialParameters params,
      inout float3 positionWS,
      inout float3 positionWS,
      float3 normal,
      float3 normal,
      float3 tangents[UvSetCount],
      float3 tangents[UvSetCount],
@@ -73,10 +76,10 @@
     // GetParallaxInput applies an tangent offset to the UV. We want to apply the same offset to the detailUv (note: this needs to be tested with content)
     // GetParallaxInput applies an tangent offset to the UV. We want to apply the same offset to the detailUv (note: this needs to be tested with content)
     // The math is:   offset = newUv - oldUv;   detailUv += offset;
     // The math is:   offset = newUv - oldUv;   detailUv += offset;
     // This is the same as:   detailUv -= oldUv;   detailUv += newUv;
     // This is the same as:   detailUv -= oldUv;   detailUv += newUv;
-    detailUv[MaterialSrg::m_parallaxUvIndex] -= uvs[MaterialSrg::m_parallaxUvIndex];
+    detailUv[params.m_parallaxUvIndex] -= uvs[params.m_parallaxUvIndex];
     
     
-    SetPixelDepth(positionWS, normal, tangents, bitangents, uvs, isFrontFace, objectToWorld, depthNDC, depthCS, isClipped);
+    SetPixelDepth(params, positionWS, normal, tangents, bitangents, uvs, isFrontFace, objectToWorld, depthNDC, depthCS, isClipped);
 
 
     // Apply second part of the offset to the detail UV (see comment above)
     // Apply second part of the offset to the detail UV (see comment above)
-    detailUv[MaterialSrg::m_parallaxUvIndex] += uvs[MaterialSrg::m_parallaxUvIndex];
+    detailUv[params.m_parallaxUvIndex] += uvs[params.m_parallaxUvIndex];
 }
 }

+ 6 - 6
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardGetAlphaAndClip.azsli

@@ -10,12 +10,12 @@
 
 
 #include "../MaterialInputs/AlphaInput.azsli"
 #include "../MaterialInputs/AlphaInput.azsli"
 
 
-real GetAlphaAndClip(float2 uvs[UvSetCount], float4 uvDxDy = float4(0.0f, 0.0f, 0.0f, 0.0f), bool customDerivatives = false)
+real GetAlphaAndClip(const MaterialParameters params, float2 uvs[UvSetCount], float4 uvDxDy = float4(0.0f, 0.0f, 0.0f, 0.0f), bool customDerivatives = false)
 {
 {
     // Alpha
     // Alpha
-    float2 baseColorUV = uvs[MaterialSrg::m_baseColorMapUvIndex];
-    float2 opacityUV = uvs[MaterialSrg::m_opacityMapUvIndex];
-    real alpha = SampleAlpha(MaterialSrg::m_baseColorMap, MaterialSrg::m_opacityMap, baseColorUV, opacityUV, MaterialSrg::m_sampler, o_opacity_source, uvDxDy, customDerivatives);
-    CheckClipping(alpha, real(MaterialSrg::m_opacityFactor));
-    return real(MaterialSrg::m_opacityFactor) * alpha;
+    float2 baseColorUV = uvs[params.m_baseColorMapUvIndex];
+    float2 opacityUV = uvs[params.m_opacityMapUvIndex];
+    real alpha = SampleAlpha(GetMaterialTexture(params.m_baseColorMap), GetMaterialTexture(params.m_opacityMap), baseColorUV, opacityUV, GetMaterialTextureSampler(), o_opacity_source, uvDxDy, customDerivatives);
+    CheckClipping(alpha, real(params.m_opacityFactor));
+    return real(params.m_opacityFactor) * alpha;
 }
 }

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardTransformDetailUvs.azsli

@@ -6,13 +6,13 @@
  *
  *
  */
  */
 
 
-void TransformDetailUvs(in float2 IN[UvSetCount], out float2 OUT[UvSetCount])
+void TransformDetailUvs(const MaterialParameters params, in float2 IN[UvSetCount], out float2 OUT[UvSetCount])
 {
 {
     // Our standard practice is to only transform the first UV as that's the one we expect to be used for
     // Our standard practice is to only transform the first UV as that's the one we expect to be used for
     // tiling. But for detail maps you could actually use either UV stream for tiling. There is no concern about applying
     // tiling. But for detail maps you could actually use either UV stream for tiling. There is no concern about applying
     // the same transform to both UV sets because the detail map feature forces the same UV set to be used for all detail maps.
     // the same transform to both UV sets because the detail map feature forces the same UV set to be used for all detail maps.
     // Note we might be able to combine these into a single UV similar to what Skin.materialtype does,
     // Note we might be able to combine these into a single UV similar to what Skin.materialtype does,
     // but we would need to address how it works with the parallax code below that indexes into the m_detailUV array.
     // but we would need to address how it works with the parallax code below that indexes into the m_detailUV array.
-    OUT[0] = mul(MaterialSrg::m_detailUvMatrix, float3(IN[0], 1.0)).xy;
-    OUT[1] = mul(MaterialSrg::m_detailUvMatrix, float3(IN[1], 1.0)).xy;
+    OUT[0] = mul(params.m_detailUvMatrix, float3(IN[0], 1.0)).xy;
+    OUT[1] = mul(params.m_detailUvMatrix, float3(IN[1], 1.0)).xy;
 }
 }

+ 8 - 6
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/ParallaxInput.azsli

@@ -25,7 +25,7 @@ float       prefix##m_heightmapOffset;
 #define COMMON_OPTIONS_PARALLAX(prefix) \
 #define COMMON_OPTIONS_PARALLAX(prefix) \
 option bool prefix##o_useHeightmap; 
 option bool prefix##o_useHeightmap; 
 
 
-void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float heightmapScale, float heightmapOffset,
+void GetParallaxInput(Texture2D heightmap, sampler mapSampler, float3 normal, float3 tangent, float3 bitangent, float heightmapScale, float heightmapOffset,
                       float4x4 objectWorldMatrix, real3x3 uvMatrix, real3x3 uvMatrixInverse,
                       float4x4 objectWorldMatrix, real3x3 uvMatrix, real3x3 uvMatrixInverse,
                       inout float2 uv, inout float3 worldPosition, inout float depthNDC, inout float depthCS, out bool isClipped)
                       inout float2 uv, inout float3 worldPosition, inout float depthNDC, inout float depthCS, out bool isClipped)
 {
 {
@@ -45,7 +45,9 @@ void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float hei
             dirToCamera = float3(ViewSrg::m_worldPosition.xyz - worldPosition);
             dirToCamera = float3(ViewSrg::m_worldPosition.xyz - worldPosition);
         }
         }
     
     
-        ParallaxOffset tangentOffset = GetParallaxOffset( heightmapScale,
+        ParallaxOffset tangentOffset = GetParallaxOffset( heightmap,
+                                                          mapSampler,
+                                                          heightmapScale,
                                                           -heightmapOffset,
                                                           -heightmapOffset,
                                                           uv,
                                                           uv,
                                                           dirToCamera, 
                                                           dirToCamera, 
@@ -77,19 +79,19 @@ void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float hei
     }
     }
 }
 }
 
 
-void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float heightmapScale, float heightmapOffset,
+void GetParallaxInput(Texture2D heightmap, sampler mapSampler, float3 normal, float3 tangent, float3 bitangent, float heightmapScale, float heightmapOffset,
                       float4x4 objectWorldMatrix, float3x3 uvMatrix, float3x3 uvMatrixInverse,
                       float4x4 objectWorldMatrix, float3x3 uvMatrix, float3x3 uvMatrixInverse,
                       inout float2 uv, inout float3 worldPosition, inout float depthNDC, inout float depthCS)
                       inout float2 uv, inout float3 worldPosition, inout float depthNDC, inout float depthCS)
 {
 {
     bool isClipped = false;
     bool isClipped = false;
-    GetParallaxInput(normal, tangent, bitangent, heightmapScale, heightmapOffset, objectWorldMatrix, uvMatrix, uvMatrixInverse, uv, worldPosition, depthNDC, depthCS, isClipped);
+    GetParallaxInput(heightmap, mapSampler, normal, tangent, bitangent, heightmapScale, heightmapOffset, objectWorldMatrix, uvMatrix, uvMatrixInverse, uv, worldPosition, depthNDC, depthCS, isClipped);
 }
 }
 
 
-void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float heightmapScale, float heightmapOffset,
+void GetParallaxInput(Texture2D heightmap, sampler mapSampler, float3 normal, float3 tangent, float3 bitangent, float heightmapScale, float heightmapOffset,
     float4x4 objectWorldMatrix, float3x3 uvMatrix, float3x3 uvMatrixInverse,
     float4x4 objectWorldMatrix, float3x3 uvMatrix, float3x3 uvMatrixInverse,
     inout float2 uv, inout float3 worldPosition, inout float depthNDC)
     inout float2 uv, inout float3 worldPosition, inout float depthNDC)
 {
 {
     float depthCS;
     float depthCS;
-    GetParallaxInput(normal, tangent, bitangent, heightmapScale, heightmapOffset, objectWorldMatrix, uvMatrix, uvMatrixInverse, uv, worldPosition, depthNDC, depthCS);
+    GetParallaxInput(heightmap, mapSampler, normal, tangent, bitangent, heightmapScale, heightmapOffset, objectWorldMatrix, uvMatrix, uvMatrixInverse, uv, worldPosition, depthNDC, depthCS);
 }
 }
 
 

+ 46 - 111
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MultilayerPBR/StandardMultilayerPBR_Common.azsli

@@ -12,6 +12,10 @@
 #include <Atom/Features/PBR/LightingOptions.azsli>
 #include <Atom/Features/PBR/LightingOptions.azsli>
 #include <Atom/RPI/Math.azsli>
 #include <Atom/RPI/Math.azsli>
 
 
+// This file contains the definition for 'struct MaterialParameters', which is generated by the Materialpipeline
+#include MATERIAL_PARAMETERS_AZSLI_FILE_PATH
+#include <Atom/Features/Materials/MaterialSrg.azsli>
+
 #include "../MaterialInputs/BaseColorInput.azsli"
 #include "../MaterialInputs/BaseColorInput.azsli"
 #include "../MaterialInputs/RoughnessInput.azsli"
 #include "../MaterialInputs/RoughnessInput.azsli"
 #include "../MaterialInputs/MetallicInput.azsli"
 #include "../MaterialInputs/MetallicInput.azsli"
@@ -23,79 +27,6 @@
 #include "../MaterialInputs/ParallaxInput.azsli"
 #include "../MaterialInputs/ParallaxInput.azsli"
 #include "../MaterialInputs/UvSetCount.azsli"
 #include "../MaterialInputs/UvSetCount.azsli"
 
 
-// ------ ShaderResourceGroup ----------------------------------------
-
-#define DEFINE_LAYER_SRG_INPUTS(prefix) \
-COMMON_SRG_INPUTS_BASE_COLOR(prefix)    \
-COMMON_SRG_INPUTS_ROUGHNESS(prefix)     \
-COMMON_SRG_INPUTS_METALLIC(prefix)      \
-COMMON_SRG_INPUTS_SPECULAR_F0(prefix)   \
-COMMON_SRG_INPUTS_NORMAL(prefix)        \
-COMMON_SRG_INPUTS_CLEAR_COAT(prefix)    \
-COMMON_SRG_INPUTS_OCCLUSION(prefix)     \
-COMMON_SRG_INPUTS_EMISSIVE(prefix)      \
-COMMON_SRG_INPUTS_PARALLAX(prefix)
-
-ShaderResourceGroup MaterialSrg : SRG_PerMaterial
-{
-    Texture2D m_blendMaskTexture;
-    uint m_blendMaskUvIndex;
-    
-    // When parallax mapping is used, these limit the heightmap intersection search range to the narrowest band possible, to give the best quality result.
-    // These are also support other calculations related to displacement-based blending, even when parallax is not used.
-    float m_displacementMin; // The lowest displacement value possible from all layers combined (negative values are below the surface)
-    float m_displacementMax; // The highest displacement value possible from all layers combined (negative values are below the surface)
-    
-    // When displacement-based blending is used, this is the height range where the surface properties of different layers will be blended together.
-    // We use an absolute value rather than a relative factor because disconnecting this property from the influence of other properties makes per-layer 
-    // displacement adjustments feel more natural if they don't impact the blend distance.
-    float m_displacementBlendDistance;
-
-    // Auto-generate material SRG fields for common inputs for each layer
-    DEFINE_LAYER_SRG_INPUTS(m_layer1_)
-    DEFINE_LAYER_SRG_INPUTS(m_layer2_)
-    DEFINE_LAYER_SRG_INPUTS(m_layer3_)
-    
-    float3x3 m_layer1_m_uvMatrix;
-    float4 m_pad1; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-
-    float3x3 m_layer2_m_uvMatrix;
-    float4 m_pad2; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-
-    float3x3 m_layer3_m_uvMatrix;
-    float4 m_pad3; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-    
-    uint m_parallaxUvIndex;
-    float m_parallax_pdo_shadowFactor;
-
-    float3x3 m_uvMatrix;
-    float4 m_pad4; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-    float3x3 m_uvMatrixInverse;
-    float4 m_pad5; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-    
-    Sampler m_sampler
-    {
-        AddressU = Wrap;
-        AddressV = Wrap;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        MipFilter = Linear;
-        MaxAnisotropy = 16;
-    };
-
-    Texture2D m_brdfMap;
-
-    Sampler m_samplerBrdf
-    {
-        AddressU = Clamp;
-        AddressV = Clamp;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        MipFilter = Linear;
-    };
-
-}
-
 // ------ Shader Options ----------------------------------------
 // ------ Shader Options ----------------------------------------
 
 
 option bool o_layer2_enabled;
 option bool o_layer2_enabled;
@@ -179,7 +110,7 @@ LayerBlendSource GetFinalLayerBlendSource()
 //! @param uvDxDy for sampling the textures if derivatives are customized
 //! @param uvDxDy for sampling the textures if derivatives are customized
 //! @param customDerivatives whether or not using customized derivatives
 //! @param customDerivatives whether or not using customized derivatives
 //! @return the blend mask values, or 0 if there is no blend mask
 //! @return the blend mask values, or 0 if there is no blend mask
-real3 GetApplicableBlendMaskValues(LayerBlendSource blendSource, float2 blendMaskUv, float3 blendMaskVertexColors, float4 uvDxDy = float4(0.0, 0.0, 0.0, 0.0), bool customDerivatives = false)
+real3 GetApplicableBlendMaskValues(const MaterialParameters params, LayerBlendSource blendSource, float2 blendMaskUv, float3 blendMaskVertexColors, float4 uvDxDy = float4(0.0, 0.0, 0.0, 0.0), bool customDerivatives = false)
 {
 {
     real3 blendSourceValues = real3(0,0,0);
     real3 blendSourceValues = real3(0,0,0);
 
 
@@ -195,14 +126,14 @@ real3 GetApplicableBlendMaskValues(LayerBlendSource blendSource, float2 blendMas
             case LayerBlendSource::Displacement_With_BlendMaskTexture:
             case LayerBlendSource::Displacement_With_BlendMaskTexture:
                 if (customDerivatives)
                 if (customDerivatives)
                 {
                 {
-                    blendSourceValues = real3(MaterialSrg::m_blendMaskTexture.SampleGrad(MaterialSrg::m_sampler, blendMaskUv, uvDxDy.xy, uvDxDy.zw).rgb);
+                    blendSourceValues = real3(GetMaterialTexture(params.m_blendMaskTexture).SampleGrad(GetMaterialTextureSampler(), blendMaskUv, uvDxDy.xy, uvDxDy.zw).rgb);
                 }
                 }
                 else
                 else
                 {
                 {
                 #ifdef CS_SAMPLERS
                 #ifdef CS_SAMPLERS
-                    blendSourceValues = real3(MaterialSrg::m_blendMaskTexture.SampleLevel(MaterialSrg::m_sampler, blendMaskUv, 0).rgb);
+                    blendSourceValues = real3(GetMaterialTexture(params.m_blendMaskTexture).SampleLevel(GetMaterialTextureSampler(), blendMaskUv, 0).rgb);
                 #else
                 #else
-                    blendSourceValues = real3(MaterialSrg::m_blendMaskTexture.Sample(MaterialSrg::m_sampler, blendMaskUv).rgb);
+                    blendSourceValues = real3(GetMaterialTexture(params.m_blendMaskTexture).Sample(GetMaterialTextureSampler(), blendMaskUv).rgb);
                 #endif
                 #endif
                 }
                 }
                 break;
                 break;
@@ -229,13 +160,13 @@ real3 GetApplicableBlendMaskValues(LayerBlendSource blendSource, float2 blendMas
 }
 }
 
 
 //! When dealing with masks for displacement-based blending, we sometimes need to push the value below the min displacement to make it disappear.
 //! When dealing with masks for displacement-based blending, we sometimes need to push the value below the min displacement to make it disappear.
-real GetSubMinDisplacement()
+real GetSubMinDisplacement(const MaterialParameters params)
 {
 {
-    return real(MaterialSrg::m_displacementMin) - 0.001;
-    //return MaterialSrg::m_displacementMin - max(MaterialSrg::m_displacementBlendDistance, 0.001);
+    return real(params.m_displacementMin) - 0.001;
+    //return params.m_displacementMin - max(params.m_displacementBlendDistance, 0.001);
 }
 }
 
 
-real3 ApplyBlendMaskToDepthValues(real3 blendMaskValues, real3 layerDepthValues, real zeroMaskDisplacement);
+real3 ApplyBlendMaskToDepthValues(const MaterialParameters params, real3 blendMaskValues, real3 layerDepthValues, real zeroMaskDisplacement);
 
 
 //! Return the final blend weights to be used for rendering, based on the available data and configuration.
 //! Return the final blend weights to be used for rendering, based on the available data and configuration.
 //! @param blendSource - indicates where to get the blend mask from
 //! @param blendSource - indicates where to get the blend mask from
@@ -327,16 +258,16 @@ real3 GetBlendWeights(LayerBlendSource blendSource, real3 blendMaskValues, real3
     return blendWeights;
     return blendWeights;
 }
 }
 
 
-float3 GetLayerDepthValues(float2 uv, float2 uv_ddx, float2 uv_ddy);
+float3 GetLayerDepthValues(const MaterialParameters params, float2 uv, float2 uv_ddx, float2 uv_ddy);
 
 
 //! Return the final blend weights to be used for rendering, based on the available data and configuration.
 //! Return the final blend weights to be used for rendering, based on the available data and configuration.
 //! Note this will sample the displacement maps in the case of LayerBlendSource::Displacement. If you have already
 //! Note this will sample the displacement maps in the case of LayerBlendSource::Displacement. If you have already
 //! the layer depth values, use the GetBlendWeights() overload that takes layerDepthValues instead.
 //! the layer depth values, use the GetBlendWeights() overload that takes layerDepthValues instead.
-real3 GetBlendWeights(LayerBlendSource blendSource, float2 uv, float3 blendMaskVertexColors, float4 uvDxDy, bool customDerivatives)
+real3 GetBlendWeights(const MaterialParameters params, LayerBlendSource blendSource, float2 uv, float3 blendMaskVertexColors, float4 uvDxDy, bool customDerivatives)
 {
 {
     real3 layerDepthValues = real3(0,0,0);
     real3 layerDepthValues = real3(0,0,0);
     
     
-    real3 blendMaskValues = GetApplicableBlendMaskValues(blendSource, uv, blendMaskVertexColors, uvDxDy, customDerivatives);
+    real3 blendMaskValues = GetApplicableBlendMaskValues(params, blendSource, uv, blendMaskVertexColors, uvDxDy, customDerivatives);
 
 
     if(blendSource == LayerBlendSource::Displacement ||
     if(blendSource == LayerBlendSource::Displacement ||
        blendSource == LayerBlendSource::Displacement_With_BlendMaskTexture ||
        blendSource == LayerBlendSource::Displacement_With_BlendMaskTexture ||
@@ -346,17 +277,17 @@ real3 GetBlendWeights(LayerBlendSource blendSource, float2 uv, float3 blendMaskV
            LayerBlendSource::Displacement_With_BlendMaskTexture == blendSource || 
            LayerBlendSource::Displacement_With_BlendMaskTexture == blendSource || 
            LayerBlendSource::Displacement_With_BlendMaskVertexColors == blendSource;
            LayerBlendSource::Displacement_With_BlendMaskVertexColors == blendSource;
            
            
-        layerDepthValues = real3(GetLayerDepthValues(uv, ddx_fine(uv), ddy_fine(uv)));
+        layerDepthValues = real3(GetLayerDepthValues(params, uv, ddx_fine(uv), ddy_fine(uv)));
 
 
         if(useBlendMask)
         if(useBlendMask)
         {
         {
             // Unlike the GetDepth() callback used for parallax, we don't just shift the values toward GetSubMinDisplacement(),
             // Unlike the GetDepth() callback used for parallax, we don't just shift the values toward GetSubMinDisplacement(),
             // we shift extra to ensure that completely masked-out layers are not blended onto upper layers.
             // we shift extra to ensure that completely masked-out layers are not blended onto upper layers.
-            layerDepthValues = ApplyBlendMaskToDepthValues(blendMaskValues, layerDepthValues, GetSubMinDisplacement() - real(MaterialSrg::m_displacementBlendDistance));
+            layerDepthValues = ApplyBlendMaskToDepthValues(params, blendMaskValues, layerDepthValues, GetSubMinDisplacement(params) - real(params.m_displacementBlendDistance));
         }
         }
     }
     }
     
     
-    return GetBlendWeights(blendSource, blendMaskValues, layerDepthValues, real(MaterialSrg::m_displacementBlendDistance));
+    return GetBlendWeights(blendSource, blendMaskValues, layerDepthValues, real(params.m_displacementBlendDistance));
 }
 }
 
 
 real BlendLayers(real layer1, real layer2, real layer3, real3 blendWeights)
 real BlendLayers(real layer1, real layer2, real layer3, real3 blendWeights)
@@ -375,7 +306,7 @@ real3 BlendLayers(real3 layer1, real3 layer2, real3 layer3, real3 blendWeights)
 // ------ Parallax Utilities ----------------------------------------
 // ------ Parallax Utilities ----------------------------------------
 
 
 //! Returns the depth values for each layer.
 //! Returns the depth values for each layer.
-float3 GetLayerDepthValues(float2 uv, float2 uv_ddx, float2 uv_ddy)
+float3 GetLayerDepthValues(const MaterialParameters params, float2 uv, float2 uv_ddx, float2 uv_ddy)
 {
 {
     float3 layerDepthValues = float3(0,0,0);
     float3 layerDepthValues = float3(0,0,0);
     
     
@@ -384,16 +315,16 @@ float3 GetLayerDepthValues(float2 uv, float2 uv_ddx, float2 uv_ddy)
         if(o_layer1_o_useHeightmap)
         if(o_layer1_o_useHeightmap)
         {
         {
             float2 layerUv = uv;
             float2 layerUv = uv;
-            if(MaterialSrg::m_parallaxUvIndex == 0)
+            if(params.m_parallaxUvIndex == 0)
             {
             {
-                layerUv = mul(MaterialSrg::m_layer1_m_uvMatrix, float3(uv, 1.0)).xy;
+                layerUv = mul(params.m_layer1_m_uvMatrix, float3(uv, 1.0)).xy;
             }
             }
 
 
-            layerDepthValues.r = SampleDepthFromHeightmap(MaterialSrg::m_layer1_m_heightmap, MaterialSrg::m_sampler, layerUv, uv_ddx, uv_ddy).m_depth;
-            layerDepthValues.r *= MaterialSrg::m_layer1_m_heightmapScale;
+            layerDepthValues.r = SampleDepthFromHeightmap(GetMaterialTexture(params.m_layer1_m_heightmap), GetMaterialTextureSampler(), layerUv, uv_ddx, uv_ddy).m_depth;
+            layerDepthValues.r *= params.m_layer1_m_heightmapScale;
         }
         }
 
 
-        layerDepthValues.r -= MaterialSrg::m_layer1_m_heightmapOffset;
+        layerDepthValues.r -= params.m_layer1_m_heightmapOffset;
     }
     }
     
     
     if(o_layer2_enabled)
     if(o_layer2_enabled)
@@ -401,16 +332,16 @@ float3 GetLayerDepthValues(float2 uv, float2 uv_ddx, float2 uv_ddy)
         if(o_layer2_o_useHeightmap)
         if(o_layer2_o_useHeightmap)
         {
         {
             float2 layerUv = uv;
             float2 layerUv = uv;
-            if(MaterialSrg::m_parallaxUvIndex == 0)
+            if(params.m_parallaxUvIndex == 0)
             {
             {
-                layerUv = mul(MaterialSrg::m_layer2_m_uvMatrix, float3(uv, 1.0)).xy;
+                layerUv = mul(params.m_layer2_m_uvMatrix, float3(uv, 1.0)).xy;
             }
             }
 
 
-            layerDepthValues.g = SampleDepthFromHeightmap(MaterialSrg::m_layer2_m_heightmap, MaterialSrg::m_sampler, layerUv, uv_ddx, uv_ddy).m_depth;
-            layerDepthValues.g *= MaterialSrg::m_layer2_m_heightmapScale;
+            layerDepthValues.g = SampleDepthFromHeightmap(GetMaterialTexture(params.m_layer2_m_heightmap), GetMaterialTextureSampler(), layerUv, uv_ddx, uv_ddy).m_depth;
+            layerDepthValues.g *= params.m_layer2_m_heightmapScale;
         }
         }
 
 
-        layerDepthValues.g -= MaterialSrg::m_layer2_m_heightmapOffset;
+        layerDepthValues.g -= params.m_layer2_m_heightmapOffset;
 
 
     }
     }
     
     
@@ -419,16 +350,16 @@ float3 GetLayerDepthValues(float2 uv, float2 uv_ddx, float2 uv_ddy)
         if(o_layer3_o_useHeightmap)
         if(o_layer3_o_useHeightmap)
         {
         {
             float2 layerUv = uv;
             float2 layerUv = uv;
-            if(MaterialSrg::m_parallaxUvIndex == 0)
+            if(params.m_parallaxUvIndex == 0)
             {
             {
-                layerUv = mul(MaterialSrg::m_layer3_m_uvMatrix, float3(uv, 1.0)).xy;
+                layerUv = mul(params.m_layer3_m_uvMatrix, float3(uv, 1.0)).xy;
             }
             }
 
 
-            layerDepthValues.b = SampleDepthFromHeightmap(MaterialSrg::m_layer3_m_heightmap, MaterialSrg::m_sampler, layerUv, uv_ddx, uv_ddy).m_depth;
-            layerDepthValues.b *= MaterialSrg::m_layer3_m_heightmapScale;
+            layerDepthValues.b = SampleDepthFromHeightmap(GetMaterialTexture(params.m_layer3_m_heightmap), GetMaterialTextureSampler(), layerUv, uv_ddx, uv_ddy).m_depth;
+            layerDepthValues.b *= params.m_layer3_m_heightmapScale;
         }
         }
 
 
-        layerDepthValues.b -= MaterialSrg::m_layer3_m_heightmapOffset;
+        layerDepthValues.b -= params.m_layer3_m_heightmapOffset;
 
 
     }
     }
     
     
@@ -442,7 +373,7 @@ float3 GetLayerDepthValues(float2 uv, float2 uv_ddx, float2 uv_ddy)
 //! @param layerDepthValues layer depth values as returned by GetLayerDepthValues()
 //! @param layerDepthValues layer depth values as returned by GetLayerDepthValues()
 //! @param zeroMaskDisplacement the target displacement value that corresponds to a mask value of 0
 //! @param zeroMaskDisplacement the target displacement value that corresponds to a mask value of 0
 //! @return new layer depth values that have been adjusted according to the layerMaskValues
 //! @return new layer depth values that have been adjusted according to the layerMaskValues
-real3 ApplyBlendMaskToDepthValues(real3 blendMaskValues, real3 layerDepthValues, real zeroMaskDisplacement)
+real3 ApplyBlendMaskToDepthValues(const MaterialParameters params, real3 blendMaskValues, real3 layerDepthValues, real zeroMaskDisplacement)
 {
 {
     if(o_layer2_enabled || o_layer3_enabled)
     if(o_layer2_enabled || o_layer3_enabled)
     {        
     {        
@@ -450,13 +381,13 @@ real3 ApplyBlendMaskToDepthValues(real3 blendMaskValues, real3 layerDepthValues,
 
 
         if(o_layer2_enabled)
         if(o_layer2_enabled)
         {
         {
-            real dropoffRange = real(MaterialSrg::m_layer2_m_heightmapOffset) - zeroMaskDisplacement;
+            real dropoffRange = real(params.m_layer2_m_heightmapOffset) - zeroMaskDisplacement;
             layerDepthValues.g += dropoffRange * (1-blendMaskValues.r);
             layerDepthValues.g += dropoffRange * (1-blendMaskValues.r);
         }
         }
         
         
         if(o_layer3_enabled)
         if(o_layer3_enabled)
         {
         {
-            real dropoffRange = real(MaterialSrg::m_layer3_m_heightmapOffset) - zeroMaskDisplacement;
+            real dropoffRange = real(params.m_layer3_m_heightmapOffset) - zeroMaskDisplacement;
             layerDepthValues.b += dropoffRange * (1-blendMaskValues.g);
             layerDepthValues.b += dropoffRange * (1-blendMaskValues.g);
         }
         }
     }
     }
@@ -465,16 +396,20 @@ real3 ApplyBlendMaskToDepthValues(real3 blendMaskValues, real3 layerDepthValues,
 }
 }
 
 
 //! Callback function for ParallaxMapping.azsli
 //! Callback function for ParallaxMapping.azsli
-DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
+DepthResult GetDepth(Texture2D heightmap, sampler mapSampler, float2 uv, float2 uv_ddx, float2 uv_ddy)
 {
 {
     LayerBlendSource blendSource = GetFinalLayerBlendSource();
     LayerBlendSource blendSource = GetFinalLayerBlendSource();
 
 
-    real3 layerDepthValues = real3(GetLayerDepthValues(uv, uv_ddx, uv_ddy));
+    // heightmap and mapSampler ignored here, since each layer can have it's own heightmap:
+    // we simply fetch the MaterialParameters from the SRG again and sample and blend the height from our configured layers
+    const MaterialParameters params = GetMaterialParameters();
+
+    real3 layerDepthValues = real3(GetLayerDepthValues(params, uv, uv_ddx, uv_ddy));
     
     
     // Note, when the blend source uses the blend mask from the vertex colors, parallax will not be able to blend correctly between layers. It will end up using the same blend mask values
     // Note, when the blend source uses the blend mask from the vertex colors, 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 as noticeable if
     // for every UV position when searching for the intersection. This leads to smearing artifacts at the transition point, but these won't be as noticeable if
     // you have a small depth factor relative to the size of the blend transition.
     // you have a small depth factor relative to the size of the blend transition.
-    real3 blendMaskValues = GetApplicableBlendMaskValues(blendSource, uv, s_blendMaskFromVertexStream);
+    real3 blendMaskValues = GetApplicableBlendMaskValues(params, blendSource, uv, s_blendMaskFromVertexStream);
         
         
     bool useBlendMask = 
     bool useBlendMask = 
        LayerBlendSource::Displacement_With_BlendMaskTexture == blendSource || 
        LayerBlendSource::Displacement_With_BlendMaskTexture == blendSource || 
@@ -485,10 +420,10 @@ DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
         // Regarding GetSubMinDisplacement(), when a mask of 0 pushes the surface all the way to the bottom, we want that 
         // Regarding GetSubMinDisplacement(), when a mask of 0 pushes the surface all the way to the bottom, we want that 
         // to go a little below the min so it will disappear if there is something else right at the min.
         // to go a little below the min so it will disappear if there is something else right at the min.
         
         
-        layerDepthValues = ApplyBlendMaskToDepthValues(blendMaskValues, layerDepthValues, GetSubMinDisplacement());
+        layerDepthValues = ApplyBlendMaskToDepthValues(params, blendMaskValues, layerDepthValues, GetSubMinDisplacement(params));
     }
     }
     
     
-    // When blending the depth together, we don't use MaterialSrg::m_displacementBlendDistance. The intention is that m_displacementBlendDistance
+    // When blending the depth together, we don't use params.m_displacementBlendDistance. The intention is that m_displacementBlendDistance
     // is for transitioning the appearance of the surface itself, but we still want a distinct change in the heightmap. If someday we want to 
     // is for transitioning the appearance of the surface itself, but we still want a distinct change in the heightmap. If someday we want to 
     // support smoothly blending the depth as well, there is a bit more work to do to get it to play nice with the blend mask code in GetLayerDepthValues().
     // support smoothly blending the depth as well, there is a bit more work to do to get it to play nice with the blend mask code in GetLayerDepthValues().
     real layerDepthBlendDistance = 0.0;
     real layerDepthBlendDistance = 0.0;

+ 13 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Silhouette/SilhouetteGather_MaterialSrg.azsli

@@ -11,12 +11,22 @@
 #include <Atom/Features/SrgSemantics.azsli>
 #include <Atom/Features/SrgSemantics.azsli>
 #include "../MaterialInputs/SilhouetteInput.azsli"
 #include "../MaterialInputs/SilhouetteInput.azsli"
 
 
-ShaderResourceGroup MaterialSrg : SRG_PerMaterial
-{
-    float3 m_color;
+struct MaterialParameters {
+    float4 m_color;
     float m_alpha;
     float m_alpha;
     float m_depthBias;
     float m_depthBias;
     float m_outlineSize;
     float m_outlineSize;
     float m_padding0;
     float m_padding0;
     float3x3 m_uvMatrix;
     float3x3 m_uvMatrix;
+};
+
+ShaderResourceGroup MaterialSrg : SRG_PerMaterial
+{
+    MaterialParameters m_params;
 }
 }
+
+const MaterialParameters GetMaterialParameters()
+{
+    return MaterialSrg::m_params;
+}
+

+ 21 - 0
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_MaterialInputs.azsli

@@ -0,0 +1,21 @@
+/*
+ * 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 "../MaterialInputs/BaseColorInput.azsli"
+#include "../MaterialInputs/RoughnessInput.azsli"
+#include "../MaterialInputs/MetallicInput.azsli"
+#include "../MaterialInputs/SpecularInput.azsli"
+#include "../MaterialInputs/NormalInput.azsli"
+#include "../MaterialInputs/OcclusionInput.azsli"
+#include "../MaterialInputs/EmissiveInput.azsli"
+#include "../MaterialInputs/UvSetCount.azsli"
+#include "../MaterialInputs/DetailMapsInput.azsli"
+#include "../MaterialInputs/DualSpecular.azsli"
+

+ 0 - 83
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_MaterialSrg.azsli

@@ -1,83 +0,0 @@
-/*
- * 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 "../MaterialInputs/BaseColorInput.azsli"
-#include "../MaterialInputs/RoughnessInput.azsli"
-#include "../MaterialInputs/MetallicInput.azsli"
-#include "../MaterialInputs/SpecularInput.azsli"
-#include "../MaterialInputs/NormalInput.azsli"
-#include "../MaterialInputs/OcclusionInput.azsli"
-#include "../MaterialInputs/EmissiveInput.azsli"
-#include "../MaterialInputs/UvSetCount.azsli"
-#include "../MaterialInputs/DetailMapsInput.azsli"
-#include "../MaterialInputs/DualSpecular.azsli"
-
-#include <Atom/Features/SrgSemantics.azsli>
-
-ShaderResourceGroup MaterialSrg : SRG_PerMaterial
-{
-    // Auto-generate material SRG fields for common inputs
-    COMMON_SRG_INPUTS_BASE_COLOR()
-    COMMON_SRG_INPUTS_ROUGHNESS()
-    COMMON_SRG_INPUTS_SPECULAR_F0()
-    COMMON_SRG_INPUTS_NORMAL()
-    COMMON_SRG_INPUTS_OCCLUSION()
-    COMMON_SRG_INPUTS_DETAIL_MAPS()
-    COMMON_SRG_INPUTS_DUAL_SPECULAR()
-    
-    Sampler m_sampler
-    {
-        AddressU = Wrap;
-        AddressV = Wrap;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        MipFilter = Linear;
-        MaxAnisotropy = 16;
-    };
-
-    Texture2D m_brdfMap;
-
-    Sampler m_samplerBrdf
-    {
-        AddressU = Clamp;
-        AddressV = Clamp;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        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:  (shrinkFactor, transmissionNdLBias, distanceAttenuation, scale)
-    float4 m_transmissionParams;
-    
-    // (float3 TintColor, thickness)
-    float4 m_transmissionTintThickness;
-    Texture2D m_transmissionThicknessMap;
-    uint m_transmissionThicknessMapUvIndex;
-    
-    Texture2D m_wrinkle_baseColor_texture1;
-    Texture2D m_wrinkle_baseColor_texture2;
-    Texture2D m_wrinkle_baseColor_texture3;
-    Texture2D m_wrinkle_baseColor_texture4;
-    Texture2D m_wrinkle_normal_texture1;
-    Texture2D m_wrinkle_normal_texture2;
-    Texture2D m_wrinkle_normal_texture3;
-    Texture2D m_wrinkle_normal_texture4;
-}

+ 4 - 2
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_PixelGeometryEval.azsli

@@ -19,6 +19,7 @@
 #include <Atom/Features/InstancedTransforms.azsli>
 #include <Atom/Features/InstancedTransforms.azsli>
 
 
 PixelGeometryData EvaluatePixelGeometry_Skin(
 PixelGeometryData EvaluatePixelGeometry_Skin(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 normalWS,
     real3 normalWS,
     real3 tangentWS,
     real3 tangentWS,
@@ -29,7 +30,7 @@ PixelGeometryData EvaluatePixelGeometry_Skin(
     bool isFrontFace)
     bool isFrontFace)
 {
 {
     // Base PBR Geo Data
     // Base PBR Geo Data
-    PixelGeometryData geoData = EvaluatePixelGeometry_BasePBR(positionWS, normalWS, tangentWS, bitangentWS, uvs, isFrontFace);
+    PixelGeometryData geoData = EvaluatePixelGeometry_BasePBR(params, positionWS, normalWS, tangentWS, bitangentWS, uvs, isFrontFace);
 
 
     // Skin specifics
     // Skin specifics
     geoData.detailUv = detailUv;
     geoData.detailUv = detailUv;
@@ -38,7 +39,7 @@ PixelGeometryData EvaluatePixelGeometry_Skin(
     return geoData;
     return geoData;
 }
 }
 
 
-PixelGeometryData EvaluatePixelGeometry_Skin(VsOutput IN, bool isFrontFace)
+PixelGeometryData EvaluatePixelGeometry_Skin(VsOutput IN, bool isFrontFace, const MaterialParameters params)
 {
 {
     real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
     real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
     real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
     real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
@@ -47,6 +48,7 @@ PixelGeometryData EvaluatePixelGeometry_Skin(VsOutput IN, bool isFrontFace)
     ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
     ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
 
     return EvaluatePixelGeometry_Skin(
     return EvaluatePixelGeometry_Skin(
+        params,
         IN.worldPosition,
         IN.worldPosition,
         normalWS,
         normalWS,
         tangentWS,
         tangentWS,

+ 55 - 50
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_SurfaceEval.azsli

@@ -85,6 +85,7 @@ real2 ApplyNormalWrinkleMap(bool shouldApply, real2 baseNormalSample, Texture2D
 }
 }
 
 
 Surface EvaluateSurface_Skin(
 Surface EvaluateSurface_Skin(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 vertexNormal,
     real3 vertexNormal,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -102,15 +103,15 @@ Surface EvaluateSurface_Skin(
     // ------- Detail Layer Setup -------
     // ------- Detail Layer Setup -------
     
     
     // When the detail maps and the detail blend mask are on the same UV, they both use the transformed detail UVs because they are 'attached' to each other
     // When the detail maps and the detail blend mask are on the same UV, they both use the transformed detail UVs because they are 'attached' to each other
-    const float2 detailBlendMaskUv = (MaterialSrg::m_detail_blendMask_uvIndex == MaterialSrg::m_detail_allMapsUvIndex) ?
-                                     detailUv : uvs[MaterialSrg::m_detail_blendMask_uvIndex];
+    const float2 detailBlendMaskUv = (params.m_detail_blendMask_uvIndex == params.m_detail_allMapsUvIndex) ?
+                                     detailUv : uvs[params.m_detail_blendMask_uvIndex];
         
         
-    const real detailLayerBlendFactor = GetDetailLayerBlendFactor( MaterialSrg::m_detail_blendMask_texture, MaterialSrg::m_sampler,
-                                                                    detailBlendMaskUv, o_detail_blendMask_useTexture, real(MaterialSrg::m_detail_blendFactor), uvDxDy, customDerivatives);
+    const real detailLayerBlendFactor = GetDetailLayerBlendFactor( GetMaterialTexture(params.m_detail_blendMask_texture), GetMaterialTextureSampler(),
+                                                                    detailBlendMaskUv, o_detail_blendMask_useTexture, real(params.m_detail_blendFactor), uvDxDy, customDerivatives);
   
   
     // ------- Wrinkle Map Setup -------
     // ------- Wrinkle Map Setup -------
 
 
-    float2 normalUv = uvs[MaterialSrg::m_normalMapUvIndex];
+    float2 normalUv = uvs[params.m_normalMapUvIndex];
 
 
     if(o_wrinkleLayers_enabled)
     if(o_wrinkleLayers_enabled)
     {
     {
@@ -121,14 +122,14 @@ Surface EvaluateSurface_Skin(
         {
         {
             if (customDerivatives)
             if (customDerivatives)
             {
             {
-                wrinkleMaskBlendFactors += real4(ObjectSrg::m_wrinkle_masks[wrinkleMaskIndex].SampleGrad(MaterialSrg::m_sampler, normalUv, uvDxDy.xy, uvDxDy.zw) * ObjectSrg::GetWrinkleMaskWeight(wrinkleMaskIndex));
+                wrinkleMaskBlendFactors += real4(ObjectSrg::m_wrinkle_masks[wrinkleMaskIndex].SampleGrad(GetMaterialTextureSampler(), normalUv, uvDxDy.xy, uvDxDy.zw) * ObjectSrg::GetWrinkleMaskWeight(wrinkleMaskIndex));
             }
             }
             else
             else
             {
             {
                 #ifdef CS_SAMPLERS
                 #ifdef CS_SAMPLERS
-                wrinkleMaskBlendFactors += real4(ObjectSrg::m_wrinkle_masks[wrinkleMaskIndex].SampleLevel(MaterialSrg::m_sampler, normalUv, 0) * ObjectSrg::GetWrinkleMaskWeight(wrinkleMaskIndex));
+                wrinkleMaskBlendFactors += real4(ObjectSrg::m_wrinkle_masks[wrinkleMaskIndex].SampleLevel(GetMaterialTextureSampler(), normalUv, 0) * ObjectSrg::GetWrinkleMaskWeight(wrinkleMaskIndex));
                 #else
                 #else
-                wrinkleMaskBlendFactors += real4(ObjectSrg::m_wrinkle_masks[wrinkleMaskIndex].Sample(MaterialSrg::m_sampler, normalUv) * ObjectSrg::GetWrinkleMaskWeight(wrinkleMaskIndex));
+                wrinkleMaskBlendFactors += real4(ObjectSrg::m_wrinkle_masks[wrinkleMaskIndex].Sample(GetMaterialTextureSampler(), normalUv) * ObjectSrg::GetWrinkleMaskWeight(wrinkleMaskIndex));
                 #endif
                 #endif
             }
             }
         }
         }
@@ -143,7 +144,7 @@ Surface EvaluateSurface_Skin(
     // ------- Normal -------
     // ------- Normal -------
 
 
     surface.vertexNormal = vertexNormal;
     surface.vertexNormal = vertexNormal;
-    real detailLayerNormalFactor = real(MaterialSrg::m_detail_normal_factor) * detailLayerBlendFactor;
+    real detailLayerNormalFactor = real(params.m_detail_normal_factor) * detailLayerBlendFactor;
 
 
     // Since the wrinkle normal maps should all be in the same tangent space as the main normal map, we should be able to blend the raw normal map
     // Since the wrinkle normal maps should all be in the same tangent space as the main normal map, we should be able to blend the raw normal map
     // texture values before doing all the tangent space transforms, so we only have to do the transforms once, for better performance.
     // texture values before doing all the tangent space transforms, so we only have to do the transforms once, for better performance.
@@ -154,70 +155,70 @@ Surface EvaluateSurface_Skin(
     {
     {
         if (customDerivatives)
         if (customDerivatives)
         {
         {
-            normalMapSample = SampleNormalXY(MaterialSrg::m_normalMap, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, uvDxDy, customDerivatives);
+            normalMapSample = SampleNormalXY(GetMaterialTexture(params.m_normalMap), GetMaterialTextureSampler(), normalUv, params.m_flipNormalX, params.m_flipNormalY, uvDxDy, customDerivatives);
         }
         }
         else
         else
         {
         {
-            normalMapSample = SampleNormalXY(MaterialSrg::m_normalMap, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, float4(0.0f, 0.0f, 0.0f, 0.0f), false);
+            normalMapSample = SampleNormalXY(GetMaterialTexture(params.m_normalMap), GetMaterialTextureSampler(), normalUv, params.m_flipNormalX, params.m_flipNormalY, float4(0.0f, 0.0f, 0.0f, 0.0f), false);
         }
         }
     }
     }
 
 
     if(o_wrinkleLayers_enabled && o_wrinkleLayers_normal_enabled)
     if(o_wrinkleLayers_enabled && o_wrinkleLayers_normal_enabled)
     {
     {
-        normalMapSample = ApplyNormalWrinkleMap(o_wrinkleLayers_normal_useTexture1, normalMapSample, MaterialSrg::m_wrinkle_normal_texture1, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, wrinkleBlendFactors.r, uvDxDy, customDerivatives);
-        normalMapSample = ApplyNormalWrinkleMap(o_wrinkleLayers_normal_useTexture2, normalMapSample, MaterialSrg::m_wrinkle_normal_texture2, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, wrinkleBlendFactors.g, uvDxDy, customDerivatives);
-        normalMapSample = ApplyNormalWrinkleMap(o_wrinkleLayers_normal_useTexture3, normalMapSample, MaterialSrg::m_wrinkle_normal_texture3, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, wrinkleBlendFactors.b, uvDxDy, customDerivatives);
-        normalMapSample = ApplyNormalWrinkleMap(o_wrinkleLayers_normal_useTexture4, normalMapSample, MaterialSrg::m_wrinkle_normal_texture4, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, wrinkleBlendFactors.a, uvDxDy, customDerivatives);
+        normalMapSample = ApplyNormalWrinkleMap(o_wrinkleLayers_normal_useTexture1, normalMapSample, GetMaterialTexture(params.m_wrinkle_normal_texture1), GetMaterialTextureSampler(), normalUv, params.m_flipNormalX, params.m_flipNormalY, wrinkleBlendFactors.r, uvDxDy, customDerivatives);
+        normalMapSample = ApplyNormalWrinkleMap(o_wrinkleLayers_normal_useTexture2, normalMapSample, GetMaterialTexture(params.m_wrinkle_normal_texture2), GetMaterialTextureSampler(), normalUv, params.m_flipNormalX, params.m_flipNormalY, wrinkleBlendFactors.g, uvDxDy, customDerivatives);
+        normalMapSample = ApplyNormalWrinkleMap(o_wrinkleLayers_normal_useTexture3, normalMapSample, GetMaterialTexture(params.m_wrinkle_normal_texture3), GetMaterialTextureSampler(), normalUv, params.m_flipNormalX, params.m_flipNormalY, wrinkleBlendFactors.b, uvDxDy, customDerivatives);
+        normalMapSample = ApplyNormalWrinkleMap(o_wrinkleLayers_normal_useTexture4, normalMapSample, GetMaterialTexture(params.m_wrinkle_normal_texture4), GetMaterialTextureSampler(), normalUv, params.m_flipNormalX, params.m_flipNormalY, wrinkleBlendFactors.a, uvDxDy, customDerivatives);
     }
     }
 
 
     real3x3 uvMatrix = CreateIdentity3x3_real();
     real3x3 uvMatrix = CreateIdentity3x3_real();
 
 
     if(o_detail_normal_useTexture)
     if(o_detail_normal_useTexture)
     {
     {
-        real3 normalTS = GetTangentSpaceNormal(normalMapSample, uvMatrix, real(MaterialSrg::m_normalFactor));
+        real3 normalTS = GetTangentSpaceNormal(normalMapSample, uvMatrix, real(params.m_normalFactor));
     
     
         bool applyOverlay = true;
         bool applyOverlay = true;
-        surface.normal = ApplyNormalMapOverlayWS(applyOverlay, vertexNormal, normalTS, tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], 
-                                                 MaterialSrg::m_detail_normal_texture, MaterialSrg::m_sampler, detailUv, MaterialSrg::m_detail_normal_flipX, MaterialSrg::m_detail_normal_flipY, 
-                                                 detailLayerNormalFactor, tangents[MaterialSrg::m_detail_allMapsUvIndex], bitangents[MaterialSrg::m_detail_allMapsUvIndex], real3x3(MaterialSrg::m_detailUvMatrix), uvDxDy, customDerivatives);
+        surface.normal = ApplyNormalMapOverlayWS(applyOverlay, vertexNormal, normalTS, tangents[params.m_normalMapUvIndex], bitangents[params.m_normalMapUvIndex], 
+                                                 GetMaterialTexture(params.m_detail_normal_texture), GetMaterialTextureSampler(), detailUv, params.m_detail_normal_flipX, params.m_detail_normal_flipY, 
+                                                 detailLayerNormalFactor, tangents[params.m_detail_allMapsUvIndex], bitangents[params.m_detail_allMapsUvIndex], real3x3(params.m_detailUvMatrix), uvDxDy, customDerivatives);
     }
     }
     else
     else
     {
     {
-        surface.normal = GetWorldSpaceNormal(normalMapSample, vertexNormal, tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], uvMatrix, real(MaterialSrg::m_normalFactor));
+        surface.normal = GetWorldSpaceNormal(normalMapSample, vertexNormal, tangents[params.m_normalMapUvIndex], bitangents[params.m_normalMapUvIndex], uvMatrix, real(params.m_normalFactor));
     }
     }
 
 
 
 
     //--------------------- Base Color ----------------------
     //--------------------- Base Color ----------------------
         
         
-    float2 baseColorUv = uvs[MaterialSrg::m_baseColorMapUvIndex];
-    real detailLayerBaseColorFactor = real(MaterialSrg::m_detail_baseColor_factor) * detailLayerBlendFactor;
+    float2 baseColorUv = uvs[params.m_baseColorMapUvIndex];
+    real detailLayerBaseColorFactor = real(params.m_detail_baseColor_factor) * detailLayerBlendFactor;
     
     
-    real3 baseColor = GetBaseColorInput(MaterialSrg::m_baseColorMap, MaterialSrg::m_sampler, baseColorUv, real3(MaterialSrg::m_baseColor), o_baseColor_useTexture, uvDxDy, customDerivatives);
+    real3 baseColor = GetBaseColorInput(GetMaterialTexture(params.m_baseColorMap), GetMaterialTextureSampler(), baseColorUv, real3(params.m_baseColor.rgb), o_baseColor_useTexture, uvDxDy, customDerivatives);
     
     
     bool useSampledBaseColor = o_baseColor_useTexture;
     bool useSampledBaseColor = o_baseColor_useTexture;
     if(o_wrinkleLayers_enabled && o_wrinkleLayers_baseColor_enabled)
     if(o_wrinkleLayers_enabled && o_wrinkleLayers_baseColor_enabled)
     {
     {
-        // If any of the wrinkle maps are applied, we will use the Base Color blend settings to apply the MaterialSrg::m_baseColor tint to the wrinkle maps,
+        // If any of the wrinkle maps are applied, we will use the Base Color blend settings to apply the params.m_baseColor tint to the wrinkle maps,
         // even if the main base color map is not used.
         // even if the main base color map is not used.
         useSampledBaseColor = useSampledBaseColor || o_wrinkleLayers_baseColor_useTexture1 || o_wrinkleLayers_baseColor_useTexture2 || o_wrinkleLayers_baseColor_useTexture3 || o_wrinkleLayers_baseColor_useTexture4;
         useSampledBaseColor = useSampledBaseColor || o_wrinkleLayers_baseColor_useTexture1 || o_wrinkleLayers_baseColor_useTexture2 || o_wrinkleLayers_baseColor_useTexture3 || o_wrinkleLayers_baseColor_useTexture4;
 
 
-        // There is a particular case where the MaterialSrg::m_baseColor could otherwise be blended twice, making it look too dark,
+        // There is a particular case where the params.m_baseColor could otherwise be blended twice, making it look too dark,
         // we reset the initial baseColor back to white to make sure it will only be applied once.
         // we reset the initial baseColor back to white to make sure it will only be applied once.
         if(useSampledBaseColor && !o_baseColor_useTexture)
         if(useSampledBaseColor && !o_baseColor_useTexture)
         {
         {
             baseColor = real3(1,1,1);
             baseColor = real3(1,1,1);
         }
         }
 
 
-        baseColor = ApplyBaseColorWrinkleMap(o_wrinkleLayers_baseColor_useTexture1, baseColor, MaterialSrg::m_wrinkle_baseColor_texture1, MaterialSrg::m_sampler, baseColorUv, wrinkleBlendFactors.r, uvDxDy, customDerivatives);
-        baseColor = ApplyBaseColorWrinkleMap(o_wrinkleLayers_baseColor_useTexture2, baseColor, MaterialSrg::m_wrinkle_baseColor_texture2, MaterialSrg::m_sampler, baseColorUv, wrinkleBlendFactors.g, uvDxDy, customDerivatives);
-        baseColor = ApplyBaseColorWrinkleMap(o_wrinkleLayers_baseColor_useTexture3, baseColor, MaterialSrg::m_wrinkle_baseColor_texture3, MaterialSrg::m_sampler, baseColorUv, wrinkleBlendFactors.b, uvDxDy, customDerivatives);
-        baseColor = ApplyBaseColorWrinkleMap(o_wrinkleLayers_baseColor_useTexture4, baseColor, MaterialSrg::m_wrinkle_baseColor_texture4, MaterialSrg::m_sampler, baseColorUv, wrinkleBlendFactors.a, uvDxDy, customDerivatives);
+        baseColor = ApplyBaseColorWrinkleMap(o_wrinkleLayers_baseColor_useTexture1, baseColor, GetMaterialTexture(params.m_wrinkle_baseColor_texture1), GetMaterialTextureSampler(), baseColorUv, wrinkleBlendFactors.r, uvDxDy, customDerivatives);
+        baseColor = ApplyBaseColorWrinkleMap(o_wrinkleLayers_baseColor_useTexture2, baseColor, GetMaterialTexture(params.m_wrinkle_baseColor_texture2), GetMaterialTextureSampler(), baseColorUv, wrinkleBlendFactors.g, uvDxDy, customDerivatives);
+        baseColor = ApplyBaseColorWrinkleMap(o_wrinkleLayers_baseColor_useTexture3, baseColor, GetMaterialTexture(params.m_wrinkle_baseColor_texture3), GetMaterialTextureSampler(), baseColorUv, wrinkleBlendFactors.b, uvDxDy, customDerivatives);
+        baseColor = ApplyBaseColorWrinkleMap(o_wrinkleLayers_baseColor_useTexture4, baseColor, GetMaterialTexture(params.m_wrinkle_baseColor_texture4), GetMaterialTextureSampler(), baseColorUv, wrinkleBlendFactors.a, uvDxDy, customDerivatives);
     
     
     }
     }
     
     
-    baseColor = BlendBaseColor(baseColor, real3(MaterialSrg::m_baseColor), real(MaterialSrg::m_baseColorFactor), o_baseColorTextureBlendMode, useSampledBaseColor);
+    baseColor = BlendBaseColor(baseColor, real3(params.m_baseColor.rgb), real(params.m_baseColorFactor), o_baseColorTextureBlendMode, useSampledBaseColor);
     
     
-    baseColor = ApplyTextureOverlay(o_detail_baseColor_useTexture, baseColor, MaterialSrg::m_detail_baseColor_texture, MaterialSrg::m_sampler, detailUv, detailLayerBaseColorFactor, uvDxDy, customDerivatives);
+    baseColor = ApplyTextureOverlay(o_detail_baseColor_useTexture, baseColor, GetMaterialTexture(params.m_detail_baseColor_texture), GetMaterialTextureSampler(), detailUv, detailLayerBaseColorFactor, uvDxDy, customDerivatives);
 
 
     if(o_wrinkleLayers_enabled && o_wrinkleLayers_showBlendMaskValues)
     if(o_wrinkleLayers_enabled && o_wrinkleLayers_showBlendMaskValues)
     {
     {
@@ -230,48 +231,48 @@ Surface EvaluateSurface_Skin(
 
 
     // ------- Specular -------
     // ------- Specular -------
 
 
-    float2 specularUv = uvs[MaterialSrg::m_specularF0MapUvIndex];
-    real specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, real(MaterialSrg::m_specularF0Factor), o_specularF0_useTexture, uvDxDy, customDerivatives);
+    float2 specularUv = uvs[params.m_specularF0MapUvIndex];
+    real specularF0Factor = GetSpecularInput(GetMaterialTexture(params.m_specularF0Map), GetMaterialTextureSampler(), specularUv, real(params.m_specularF0Factor), o_specularF0_useTexture, uvDxDy, customDerivatives);
 
 
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor);
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor);
 
 
     // ------- Roughness -------
     // ------- Roughness -------
 
 
-    float2 roughnessUv = uvs[MaterialSrg::m_roughnessMapUvIndex];
-    surface.roughnessLinear = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, real(MaterialSrg::m_roughnessFactor),
-                                        real(MaterialSrg::m_roughnessLowerBound), real(MaterialSrg::m_roughnessUpperBound), o_roughness_useTexture, uvDxDy, customDerivatives);
+    float2 roughnessUv = uvs[params.m_roughnessMapUvIndex];
+    surface.roughnessLinear = GetRoughnessInput(GetMaterialTexture(params.m_roughnessMap), GetMaterialTextureSampler(), roughnessUv, real(params.m_roughnessFactor),
+                                        real(params.m_roughnessLowerBound), real(params.m_roughnessUpperBound), o_roughness_useTexture, uvDxDy, customDerivatives);
 
 
     surface.CalculateRoughnessA();
     surface.CalculateRoughnessA();
 
 
     // ------- Dual Specular -------
     // ------- Dual Specular -------
 
 
-    GetDualSpecularInput(surface.GetSpecularNormal(), surface.roughnessLinear, surface.specularF0.x, MaterialSrg::m_dualSpecFactor,
-                          MaterialSrg::m_dualSpecF0Multiplier, MaterialSrg::m_dualSpecRoughnessExponent, MaterialSrg::m_dualSpecRoughnessMultiplier,
+    GetDualSpecularInput(surface.GetSpecularNormal(), surface.roughnessLinear, surface.specularF0.x, params.m_dualSpecFactor,
+                          params.m_dualSpecF0Multiplier, params.m_dualSpecRoughnessExponent, params.m_dualSpecRoughnessMultiplier,
                           surface.dualSpecRoughness, surface.dualSpecRoughnessA2, surface.dualSpecF0, surface.dualSpecFactor);
                           surface.dualSpecRoughness, surface.dualSpecRoughnessA2, surface.dualSpecF0, surface.dualSpecFactor);
 
 
     // ------- Subsurface -------
     // ------- Subsurface -------
 
 
 #if OUTPUT_SUBSURFACE
 #if OUTPUT_SUBSURFACE
-    float2 subsurfaceUv = uvs[MaterialSrg::m_subsurfaceScatteringInfluenceMapUvIndex];
-    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, real(MaterialSrg::m_subsurfaceScatteringFactor), uvDxDy, customDerivatives);
-    surface.subsurfaceScatteringQuality = real(MaterialSrg::m_subsurfaceScatteringQuality);
-    surface.scatterDistance = real3(MaterialSrg::m_scatterDistance);
+    float2 subsurfaceUv = uvs[params.m_subsurfaceScatteringInfluenceMapUvIndex];
+    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(GetMaterialTexture(params.m_subsurfaceScatteringInfluenceMap), GetMaterialTextureSampler(), subsurfaceUv, real(params.m_subsurfaceScatteringFactor), uvDxDy, customDerivatives);
+    surface.subsurfaceScatteringQuality = real(params.m_subsurfaceScatteringQuality);
+    surface.scatterDistance = real3(params.m_scatterDistance);
 #endif
 #endif
 
 
     // ------- Occlusion -------
     // ------- Occlusion -------
     
     
-    surface.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_diffuseOcclusionMapUvIndex], real(MaterialSrg::m_diffuseOcclusionFactor), o_diffuseOcclusion_useTexture, uvDxDy, customDerivatives);
-    surface.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_specularOcclusionMapUvIndex], real(MaterialSrg::m_specularOcclusionFactor), o_specularOcclusion_useTexture, uvDxDy, customDerivatives);
+    surface.diffuseAmbientOcclusion = GetOcclusionInput(GetMaterialTexture(params.m_diffuseOcclusionMap), GetMaterialTextureSampler(), uvs[params.m_diffuseOcclusionMapUvIndex], real(params.m_diffuseOcclusionFactor), o_diffuseOcclusion_useTexture, uvDxDy, customDerivatives);
+    surface.specularOcclusion = GetOcclusionInput(GetMaterialTexture(params.m_specularOcclusionMap), GetMaterialTextureSampler(), uvs[params.m_specularOcclusionMapUvIndex], real(params.m_specularOcclusionFactor), o_specularOcclusion_useTexture, uvDxDy, customDerivatives);
 
 
     // ------- Transmission -------
     // ------- Transmission -------
 
 
 #if ENABLE_TRANSMISSION
 #if ENABLE_TRANSMISSION
-    float2 transmissionUv = uvs[MaterialSrg::m_transmissionThicknessMapUvIndex];
-    real4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, real4(MaterialSrg::m_transmissionTintThickness), uvDxDy, customDerivatives);
+    float2 transmissionUv = uvs[params.m_transmissionThicknessMapUvIndex];
+    real4 transmissionTintThickness = GeTransmissionInput(GetMaterialTexture(params.m_transmissionThicknessMap), GetMaterialTextureSampler(), transmissionUv, real4(params.m_transmissionTintThickness), uvDxDy, customDerivatives);
     surface.transmission.tint = transmissionTintThickness.rgb;
     surface.transmission.tint = transmissionTintThickness.rgb;
     surface.transmission.thickness = transmissionTintThickness.w;
     surface.transmission.thickness = transmissionTintThickness.w;
-    surface.transmission.transmissionParams = real4(MaterialSrg::m_transmissionParams);
-    surface.transmission.scatterDistance = real3(MaterialSrg::m_scatterDistance);
+    surface.transmission.transmissionParams = real4(params.m_transmissionParams);
+    surface.transmission.scatterDistance = real3(params.m_scatterDistance);
 #endif
 #endif
 
 
     return surface;
     return surface;
@@ -280,6 +281,7 @@ Surface EvaluateSurface_Skin(
 // helper function to keep compatible with the previous version
 // helper function to keep compatible with the previous version
 // because dxc compiler doesn't allow default parameters on functions with overloads
 // because dxc compiler doesn't allow default parameters on functions with overloads
 Surface EvaluateSurface_Skin(
 Surface EvaluateSurface_Skin(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 vertexNormal,
     real3 vertexNormal,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -290,6 +292,7 @@ Surface EvaluateSurface_Skin(
     bool isFrontFace)
     bool isFrontFace)
 {
 {
     return EvaluateSurface_Skin(
     return EvaluateSurface_Skin(
+        params,
         positionWS,
         positionWS,
         vertexNormal,
         vertexNormal,
         tangents,
         tangents,
@@ -302,9 +305,10 @@ Surface EvaluateSurface_Skin(
         false);
         false);
 }
 }
 
 
-Surface EvaluateSurface_Skin(VsOutput IN, PixelGeometryData geoData, float4 uvDxDy, bool customDerivatives)
+Surface EvaluateSurface_Skin(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params, float4 uvDxDy, bool customDerivatives)
 {
 {
     return EvaluateSurface_Skin(
     return EvaluateSurface_Skin(
+        params,
         geoData.positionWS,
         geoData.positionWS,
         geoData.vertexNormal,
         geoData.vertexNormal,
         geoData.tangents,
         geoData.tangents,
@@ -317,9 +321,10 @@ Surface EvaluateSurface_Skin(VsOutput IN, PixelGeometryData geoData, float4 uvDx
         customDerivatives);
         customDerivatives);
 }
 }
 
 
-Surface EvaluateSurface_Skin(VsOutput IN, PixelGeometryData geoData)
+Surface EvaluateSurface_Skin(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params)
 {
 {
     return EvaluateSurface_Skin(
     return EvaluateSurface_Skin(
+        params,
         geoData.positionWS,
         geoData.positionWS,
         geoData.vertexNormal,
         geoData.vertexNormal,
         geoData.tangents,
         geoData.tangents,

+ 7 - 4
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_VertexEval.azsli

@@ -24,6 +24,7 @@
 option bool o_blendMask_isBound;
 option bool o_blendMask_isBound;
 
 
 VsOutput EvaluateVertexGeometry_Skin(
 VsOutput EvaluateVertexGeometry_Skin(
+    const MaterialParameters params,
     float3 position,
     float3 position,
     float3 normal,
     float3 normal,
     float4 tangent,
     float4 tangent,
@@ -53,8 +54,8 @@ VsOutput EvaluateVertexGeometry_Skin(
     
     
     // The detail layer has a dedicated UV transform which we apply here. The detail layer does have the option of using
     // The detail layer has a dedicated UV transform which we apply here. The detail layer does have the option of using
     // either UV0 or UV1, in either case we apply the transform.
     // either UV0 or UV1, in either case we apply the transform.
-    output.detailUv = MaterialSrg::m_detail_allMapsUvIndex == 0 ? uv0_tiled : uv1_unwrapped;
-    output.detailUv = mul(MaterialSrg::m_detailUvMatrix, float3(output.detailUv, 1.0)).xy;
+    output.detailUv = params.m_detail_allMapsUvIndex == 0 ? uv0_tiled : uv1_unwrapped;
+    output.detailUv = mul(params.m_detailUvMatrix, float3(output.detailUv, 1.0)).xy;
     
     
     if(o_blendMask_isBound)
     if(o_blendMask_isBound)
     {
     {
@@ -79,6 +80,7 @@ VsOutput EvaluateVertexGeometry_Skin(
 // Avoids compilation errors for compute shaders, listed in a materialpipeline,
 // Avoids compilation errors for compute shaders, listed in a materialpipeline,
 // that call EvaluateVertexGeometry().
 // that call EvaluateVertexGeometry().
 VsOutput EvaluateVertexGeometry_Skin(
 VsOutput EvaluateVertexGeometry_Skin(
+    const MaterialParameters params,
     float3 position,
     float3 position,
     float3 normal,
     float3 normal,
     float4 tangent,
     float4 tangent,
@@ -86,12 +88,13 @@ VsOutput EvaluateVertexGeometry_Skin(
     float2 uv1_unwrapped,
     float2 uv1_unwrapped,
     uint instanceId)
     uint instanceId)
 {
 {
-    return EvaluateVertexGeometry_Skin(position, normal, tangent, uv0_tiled, uv1_unwrapped, float4(0, 0, 0, 0), instanceId);
+    return EvaluateVertexGeometry_Skin(params, position, normal, tangent, uv0_tiled, uv1_unwrapped, float4(0, 0, 0, 0), instanceId);
 }
 }
 
 
-VsOutput EvaluateVertexGeometry_Skin(VsInput IN, VsSystemValues SV)
+VsOutput EvaluateVertexGeometry_Skin(VsInput IN, VsSystemValues SV, const MaterialParameters params)
 {
 {
     return EvaluateVertexGeometry_Skin(
     return EvaluateVertexGeometry_Skin(
+        params,
         IN.position,
         IN.position,
         IN.normal,
         IN.normal,
         IN.tangent,
         IN.tangent,

+ 25 - 0
Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_MaterialInputs.azsli

@@ -0,0 +1,25 @@
+/*
+ * 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/PBR/LightingOptions.azsli>
+#include <Atom/Features/PBR/AlphaUtils.azsli>
+
+#include "../MaterialInputs/BaseColorInput.azsli"
+#include "../MaterialInputs/VertexColorInput.azsli"
+#include "../MaterialInputs/RoughnessInput.azsli"
+#include "../MaterialInputs/MetallicInput.azsli"
+#include "../MaterialInputs/SpecularInput.azsli"
+#include "../MaterialInputs/NormalInput.azsli"
+#include "../MaterialInputs/ClearCoatInput.azsli"
+#include "../MaterialInputs/OcclusionInput.azsli"
+#include "../MaterialInputs/EmissiveInput.azsli"
+#include "../MaterialInputs/ParallaxInput.azsli"
+#include "../MaterialInputs/UvSetCount.azsli"
+#include "../MaterialInputs/SilhouetteBlockerInput.azsli"

+ 0 - 76
Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_MaterialSrg.azsli

@@ -1,76 +0,0 @@
-/*
- * 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/PBR/LightingOptions.azsli>
-#include <Atom/Features/PBR/AlphaUtils.azsli>
-
-#include "../MaterialInputs/BaseColorInput.azsli"
-#include "../MaterialInputs/VertexColorInput.azsli"
-#include "../MaterialInputs/RoughnessInput.azsli"
-#include "../MaterialInputs/MetallicInput.azsli"
-#include "../MaterialInputs/SpecularInput.azsli"
-#include "../MaterialInputs/NormalInput.azsli"
-#include "../MaterialInputs/ClearCoatInput.azsli"
-#include "../MaterialInputs/OcclusionInput.azsli"
-#include "../MaterialInputs/EmissiveInput.azsli"
-#include "../MaterialInputs/ParallaxInput.azsli"
-#include "../MaterialInputs/UvSetCount.azsli"
-#include "../MaterialInputs/SilhouetteBlockerInput.azsli"
-
-#include <Atom/Features/SrgSemantics.azsli>
-
-ShaderResourceGroup MaterialSrg : SRG_PerMaterial
-{
-    // Auto-generate material SRG fields for common inputs
-    COMMON_SRG_INPUTS_BASE_COLOR()
-    COMMON_SRG_INPUTS_VERTEX_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()      
-    COMMON_SRG_INPUTS_PARALLAX()
-    
-    uint m_parallaxUvIndex;
-    float m_parallax_pdo_shadowFactor;
-
-    float3x3 m_uvMatrix;
-    float4 m_pad1; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-    float3x3 m_uvMatrixInverse;
-    float4 m_pad2; // [GFX TODO][ATOM-14595] This is a workaround for a data stomping bug. Remove once it's fixed.
-
-    float m_opacityFactor;
-    float m_opacityAffectsSpecularFactor;
-    Texture2D m_opacityMap;
-    uint m_opacityMapUvIndex;
-
-    Sampler m_sampler
-    {
-        AddressU = Wrap;
-        AddressV = Wrap;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        MipFilter = Linear;
-        MaxAnisotropy = 16;
-    };
-
-    Texture2D m_brdfMap;
-
-    Sampler m_samplerBrdf
-    {
-        AddressU = Clamp;
-        AddressV = Clamp;
-        MinFilter = Linear;
-        MagFilter = Linear;
-        MipFilter = Linear;
-    };
-}

+ 5 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_PixelGeometryEval.azsli

@@ -24,6 +24,7 @@
 #include <Atom/Features/Debug.azsli>
 #include <Atom/Features/Debug.azsli>
 
 
 PixelGeometryData EvaluatePixelGeometry_StandardPBR(
 PixelGeometryData EvaluatePixelGeometry_StandardPBR(
+    const MaterialParameters params,
     inout float4 positionSV,
     inout float4 positionSV,
     float3 positionWS,
     float3 positionWS,
     real3 normalWS,
     real3 normalWS,
@@ -33,7 +34,7 @@ PixelGeometryData EvaluatePixelGeometry_StandardPBR(
     bool isFrontFace,
     bool isFrontFace,
     real4x4 objectToWorld)
     real4x4 objectToWorld)
 {
 {
-    PixelGeometryData geoData = EvaluatePixelGeometry_BasePBR(positionWS, normalWS, tangentWS, bitangentWS, uvs, isFrontFace);
+    PixelGeometryData geoData = EvaluatePixelGeometry_BasePBR(params, positionWS, normalWS, tangentWS, bitangentWS, uvs, isFrontFace);
 
 
     // ------- Parallax -------
     // ------- Parallax -------
 
 
@@ -42,7 +43,7 @@ PixelGeometryData EvaluatePixelGeometry_StandardPBR(
 #if ENABLE_PARALLAX
 #if ENABLE_PARALLAX
     if(ShouldHandleParallax())
     if(ShouldHandleParallax())
     {
     {
-        SetPixelDepth(geoData.positionWS, geoData.vertexNormal, geoData.tangents, geoData.bitangents,
+        SetPixelDepth(params, geoData.positionWS, geoData.vertexNormal, geoData.tangents, geoData.bitangents,
                       geoData.uvs, isFrontFace, objectToWorld, positionSV.z, positionSV.w, geoData.isDisplacementClipped);
                       geoData.uvs, isFrontFace, objectToWorld, positionSV.z, positionSV.w, geoData.isDisplacementClipped);
     }
     }
 #endif
 #endif
@@ -50,7 +51,7 @@ PixelGeometryData EvaluatePixelGeometry_StandardPBR(
     return geoData;
     return geoData;
 }
 }
 
 
-PixelGeometryData EvaluatePixelGeometry_StandardPBR(inout VsOutput IN, bool isFrontFace)
+PixelGeometryData EvaluatePixelGeometry_StandardPBR(inout VsOutput IN, bool isFrontFace, const MaterialParameters params)
 {
 {
     real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
     real4x4 objectToWorld = real4x4(GetObjectToWorldMatrix(IN.m_instanceId));
     real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
     real3x3 objectToWorldIT = real3x3(GetObjectToWorldMatrixInverseTranspose(IN.m_instanceId));
@@ -59,6 +60,7 @@ PixelGeometryData EvaluatePixelGeometry_StandardPBR(inout VsOutput IN, bool isFr
     ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
     ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
 
     return EvaluatePixelGeometry_StandardPBR(
     return EvaluatePixelGeometry_StandardPBR(
+        params,
         IN.position,
         IN.position,
         IN.worldPosition,
         IN.worldPosition,
         normalWS,
         normalWS,

+ 22 - 15
Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_SurfaceEval.azsli

@@ -20,6 +20,7 @@
 #include <Atom/Features/PBR/LightingOptions.azsli>
 #include <Atom/Features/PBR/LightingOptions.azsli>
 
 
 Surface EvaluateSurface_StandardPBR(
 Surface EvaluateSurface_StandardPBR(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 vertexNormal,
     real3 vertexNormal,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -31,7 +32,7 @@ Surface EvaluateSurface_StandardPBR(
     bool customDerivatives,
     bool customDerivatives,
     float4 vertexColor)
     float4 vertexColor)
 {
 {
-    Surface surface = EvaluateSurface_BasePBR(positionWS, vertexNormal, tangents, bitangents, uvs, isFrontFace, uvDxDy, customDerivatives, vertexColor);
+    Surface surface = EvaluateSurface_BasePBR(params, positionWS, vertexNormal, tangents, bitangents, uvs, isFrontFace, uvDxDy, customDerivatives, vertexColor);
 
 
     // ------- Parallax Clipping -------
     // ------- Parallax Clipping -------
 
 
@@ -43,17 +44,17 @@ Surface EvaluateSurface_StandardPBR(
     // ------- Alpha & Clip -------
     // ------- Alpha & Clip -------
 
 
     // TODO: this often invokes a separate sample of the base color texture which is wasteful
     // TODO: this often invokes a separate sample of the base color texture which is wasteful
-    surface.alpha = GetAlphaAndClip(uvs, uvDxDy, customDerivatives);
+    surface.alpha = GetAlphaAndClip(params, uvs, uvDxDy, customDerivatives);
 
 
     // ------- Emissive -------
     // ------- Emissive -------
 
 
-    float2 emissiveUv = uvs[MaterialSrg::m_emissiveMapUvIndex];
-    surface.emissiveLighting = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, real(MaterialSrg::m_emissiveIntensity), real3(MaterialSrg::m_emissiveColor.rgb), real(MaterialSrg::m_emissiveAffectedByAlpha), real(surface.alpha), o_emissiveEnabled, o_emissive_useTexture, uvDxDy, customDerivatives);
+    float2 emissiveUv = uvs[params.m_emissiveMapUvIndex];
+    surface.emissiveLighting = GetEmissiveInput(GetMaterialTexture(params.m_emissiveMap), GetMaterialTextureSampler(), emissiveUv, real(params.m_emissiveIntensity), real3(params.m_emissiveColor.rgb), real(params.m_emissiveAffectedByAlpha), real(surface.alpha), o_emissiveEnabled, o_emissive_useTexture, uvDxDy, customDerivatives);
 
 
     // ------- Occlusion -------
     // ------- Occlusion -------
     
     
-    surface.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_diffuseOcclusionMapUvIndex], real(MaterialSrg::m_diffuseOcclusionFactor), o_diffuseOcclusion_useTexture, uvDxDy, customDerivatives);
-    surface.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_specularOcclusionMapUvIndex], real(MaterialSrg::m_specularOcclusionFactor), o_specularOcclusion_useTexture, uvDxDy, customDerivatives);
+    surface.diffuseAmbientOcclusion = GetOcclusionInput(GetMaterialTexture(params.m_diffuseOcclusionMap), GetMaterialTextureSampler(), uvs[params.m_diffuseOcclusionMapUvIndex], real(params.m_diffuseOcclusionFactor), o_diffuseOcclusion_useTexture, uvDxDy, customDerivatives);
+    surface.specularOcclusion = GetOcclusionInput(GetMaterialTexture(params.m_specularOcclusionMap), GetMaterialTextureSampler(), uvs[params.m_specularOcclusionMapUvIndex], real(params.m_specularOcclusionFactor), o_specularOcclusion_useTexture, uvDxDy, customDerivatives);
 
 
     // ------- Clearcoat -------
     // ------- Clearcoat -------
 
 
@@ -63,12 +64,12 @@ Surface EvaluateSurface_StandardPBR(
     {
     {
         if(o_clearCoat_enabled)
         if(o_clearCoat_enabled)
         {
         {
-            real3x3 uvMatrix = MaterialSrg::m_clearCoatNormalMapUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : CreateIdentity3x3_real();
-            GetClearCoatInputs(MaterialSrg::m_clearCoatInfluenceMap, uvs[MaterialSrg::m_clearCoatInfluenceMapUvIndex], real(MaterialSrg::m_clearCoatFactor), o_clearCoat_factor_useTexture,
-                               MaterialSrg::m_clearCoatRoughnessMap, uvs[MaterialSrg::m_clearCoatRoughnessMapUvIndex], real(MaterialSrg::m_clearCoatRoughness), o_clearCoat_roughness_useTexture,
-                               MaterialSrg::m_clearCoatNormalMap,    uvs[MaterialSrg::m_clearCoatNormalMapUvIndex], vertexNormal, o_clearCoat_normal_useTexture, real(MaterialSrg::m_clearCoatNormalStrength),
-                               uvMatrix, tangents[MaterialSrg::m_clearCoatNormalMapUvIndex], bitangents[MaterialSrg::m_clearCoatNormalMapUvIndex],
-                               MaterialSrg::m_sampler, isFrontFace,
+            real3x3 uvMatrix = params.m_clearCoatNormalMapUvIndex == 0 ? real3x3(params.m_uvMatrix) : CreateIdentity3x3_real();
+            GetClearCoatInputs(GetMaterialTexture(params.m_clearCoatInfluenceMap), uvs[params.m_clearCoatInfluenceMapUvIndex], real(params.m_clearCoatFactor), o_clearCoat_factor_useTexture,
+                               GetMaterialTexture(params.m_clearCoatRoughnessMap), uvs[params.m_clearCoatRoughnessMapUvIndex], real(params.m_clearCoatRoughness), o_clearCoat_roughness_useTexture,
+                               GetMaterialTexture(params.m_clearCoatNormalMap),    uvs[params.m_clearCoatNormalMapUvIndex], vertexNormal, o_clearCoat_normal_useTexture, real(params.m_clearCoatNormalStrength),
+                               uvMatrix, tangents[params.m_clearCoatNormalMapUvIndex], bitangents[params.m_clearCoatNormalMapUvIndex],
+                               GetMaterialTextureSampler(), isFrontFace,
                                surface.clearCoat.factor, surface.clearCoat.roughness, surface.clearCoat.normal, uvDxDy, customDerivatives);
                                surface.clearCoat.factor, surface.clearCoat.roughness, surface.clearCoat.normal, uvDxDy, customDerivatives);
         }
         }
 
 
@@ -77,7 +78,7 @@ Surface EvaluateSurface_StandardPBR(
 #endif
 #endif
     
     
     // ------- Opacity -------
     // ------- Opacity -------
-    surface.opacityAffectsSpecularFactor = real(MaterialSrg::m_opacityAffectsSpecularFactor);
+    surface.opacityAffectsSpecularFactor = real(params.m_opacityAffectsSpecularFactor);
 
 
     return surface;
     return surface;
 }
 }
@@ -85,6 +86,7 @@ Surface EvaluateSurface_StandardPBR(
 // helper function to keep compatible with the previous version
 // helper function to keep compatible with the previous version
 // because dxc compiler doesn't allow default parameters on functions with overloads
 // because dxc compiler doesn't allow default parameters on functions with overloads
 Surface EvaluateSurface_StandardPBR(
 Surface EvaluateSurface_StandardPBR(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 vertexNormal,
     real3 vertexNormal,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -96,6 +98,7 @@ Surface EvaluateSurface_StandardPBR(
     bool customDerivatives)
     bool customDerivatives)
 {
 {
     return EvaluateSurface_StandardPBR(
     return EvaluateSurface_StandardPBR(
+        params,
         positionWS,
         positionWS,
         vertexNormal,
         vertexNormal,
         tangents,
         tangents,
@@ -109,6 +112,7 @@ Surface EvaluateSurface_StandardPBR(
 }
 }
 
 
 Surface EvaluateSurface_StandardPBR(
 Surface EvaluateSurface_StandardPBR(
+    const MaterialParameters params,
     float3 positionWS,
     float3 positionWS,
     real3 vertexNormal,
     real3 vertexNormal,
     float3 tangents[UvSetCount],
     float3 tangents[UvSetCount],
@@ -118,6 +122,7 @@ Surface EvaluateSurface_StandardPBR(
     bool isDisplacementClipped)
     bool isDisplacementClipped)
 {
 {
     return EvaluateSurface_StandardPBR(
     return EvaluateSurface_StandardPBR(
+        params,
         positionWS,
         positionWS,
         vertexNormal,
         vertexNormal,
         tangents,
         tangents,
@@ -129,9 +134,10 @@ Surface EvaluateSurface_StandardPBR(
         false);
         false);
 }
 }
 
 
-Surface EvaluateSurface_StandardPBR(VsOutput IN, PixelGeometryData geoData, float4 uvDxDy, bool customDerivatives)
+Surface EvaluateSurface_StandardPBR(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params, float4 uvDxDy, bool customDerivatives)
 {
 {
     return EvaluateSurface_StandardPBR(
     return EvaluateSurface_StandardPBR(
+        params,
         geoData.positionWS,
         geoData.positionWS,
         geoData.vertexNormal,
         geoData.vertexNormal,
         geoData.tangents,
         geoData.tangents,
@@ -144,9 +150,10 @@ Surface EvaluateSurface_StandardPBR(VsOutput IN, PixelGeometryData geoData, floa
         GetVertexColor(IN));
         GetVertexColor(IN));
 }
 }
 
 
-Surface EvaluateSurface_StandardPBR(VsOutput IN, PixelGeometryData geoData)
+Surface EvaluateSurface_StandardPBR(VsOutput IN, PixelGeometryData geoData, const MaterialParameters params)
 {
 {
     return EvaluateSurface_StandardPBR(
     return EvaluateSurface_StandardPBR(
+        params,
         geoData.positionWS,
         geoData.positionWS,
         geoData.vertexNormal,
         geoData.vertexNormal,
         geoData.tangents,
         geoData.tangents,

+ 25 - 0
Gems/Atom/Feature/Common/Assets/Shaders/SceneMaterialSrg.azsl

@@ -0,0 +1,25 @@
+/*
+ * 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
+ *
+ */
+
+// This shader is not used for rendering.
+// The only purpose of this shader is to have a shader asset that can be used
+// at runtime to find the common SceneMaterialSrg layout
+
+// dummy MaterialParameters struct to make sure the SceneMaterialSrg.azsli compiles.
+// The layout doesn't matter, since the SceneMaterialSrg only holds a buffer with indices of the ByteAddressBuffers
+// containing the MaterialParameters
+struct MaterialParameters {
+    uint     m_materialType;
+    uint     m_materialInstance;
+};
+
+// needed for GetMaterialParameters()
+#include <Atom/Features/PBR/DefaultObjectSrg.azsli>
+
+#include <Atom/Features/Materials/SceneMaterialSrg.azsli>
+#include <Atom/RPI/DummyEntryFunctions.azsli>

+ 40 - 0
Gems/Atom/Feature/Common/Assets/Shaders/SceneMaterialSrg.shader

@@ -0,0 +1,40 @@
+{ 
+    "Source" : "SceneMaterialSrg.azsl",
+
+    "DepthStencilState" : 
+    {
+        "Depth" : 
+        { 
+            "Enable" : false 
+        },
+        "Stencil" :
+        {
+            "Enable" : false
+        }
+    },
+
+    "ProgramSettings":
+    {
+      "EntryPoints":
+      [
+        {
+          "name": "MainVS",
+          "type": "Vertex"
+        },
+        {
+          "name": "MainPS",
+          "type": "Fragment"
+        }
+      ]
+    },
+    
+    "Supervariants":
+    [
+        {
+            "Name": "",
+            "RemoveBuildArguments": {
+                "azslc": ["--strip-unused-srgs"]
+            }
+        }
+    ]
+}

+ 8 - 5
Gems/Atom/Feature/Common/Assets/Shaders/Silhouette/SilhouetteGather.azsl

@@ -21,21 +21,23 @@ VsOutput MainVS(VsInput IN, uint instanceId : SV_InstanceID)
     VsSystemValues SV;
     VsSystemValues SV;
     SV.m_instanceId = instanceId;
     SV.m_instanceId = instanceId;
 
 
-    VsOutput OUT = EvaluateVertexGeometry(IN, SV);
+    const MaterialParameters params = GetMaterialParameters();
+
+    VsOutput OUT = EvaluateVertexGeometry(IN, SV, params);
 
 
     // this depth bias helps prevent silhouettes appearing where there are small intersections
     // this depth bias helps prevent silhouettes appearing where there are small intersections
     // like the player feet with the ground
     // like the player feet with the ground
     real distanceScale = 1.0 - OUT.position.z / OUT.position.w;
     real distanceScale = 1.0 - OUT.position.z / OUT.position.w;
-    OUT.position.z += MaterialSrg::m_depthBias * distanceScale;
+    OUT.position.z += params.m_depthBias * distanceScale;
 
 
-    if(MaterialSrg::m_outlineSize > EPSILON)
+    if(params.m_outlineSize > EPSILON)
     {
     {
         real3 worldNormal = normalize(mul(GetObjectToWorldMatrixInverseTranspose(instanceId), IN.normal));
         real3 worldNormal = normalize(mul(GetObjectToWorldMatrixInverseTranspose(instanceId), IN.normal));
         real4 screenSpaceNormal = mul(ViewSrg::m_viewProjectionMatrix, real4(worldNormal, 0.0));
         real4 screenSpaceNormal = mul(ViewSrg::m_viewProjectionMatrix, real4(worldNormal, 0.0));
 
 
         // use a size scale so input m_outlineSize can be in range 0..100
         // use a size scale so input m_outlineSize can be in range 0..100
         const real sizeScale = 1.0 / 400.0;
         const real sizeScale = 1.0 / 400.0;
-        OUT.position.xy += screenSpaceNormal.xy * (MaterialSrg::m_outlineSize * OUT.position.w * sizeScale) * distanceScale;
+        OUT.position.xy += screenSpaceNormal.xy * (params.m_outlineSize * OUT.position.w * sizeScale) * distanceScale;
     }
     }
 
 
     return OUT;
     return OUT;
@@ -50,8 +52,9 @@ PSOutput MainPS(VsOutput IN)
 {
 {
     PSOutput OUT;
     PSOutput OUT;
 
 
+    const MaterialParameters params = GetMaterialParameters();
     // write at least something in the alpha to distinguish between silhouette and background
     // write at least something in the alpha to distinguish between silhouette and background
-    OUT.m_color = float4(TransformColor(MaterialSrg::m_color, ColorSpaceId::ACEScg,ColorSpaceId::SRGB), max(0.01, MaterialSrg::m_alpha));
+    OUT.m_color = float4(TransformColor(params.m_color.rgb, ColorSpaceId::ACEScg,ColorSpaceId::SRGB), max(0.01, params.m_alpha));
 
 
     return OUT;
     return OUT;
 }
 }

+ 80 - 50
Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake

@@ -28,6 +28,12 @@ set(FILES
     Materials/Pipelines/MainPipeline/MainPipelineScript.lua
     Materials/Pipelines/MainPipeline/MainPipelineScript.lua
     Materials/Pipelines/MainPipeline/Transparent_EnhancedLighting.azsli
     Materials/Pipelines/MainPipeline/Transparent_EnhancedLighting.azsli
     Materials/Pipelines/MainPipeline/Transparent_StandardLighting.azsli
     Materials/Pipelines/MainPipeline/Transparent_StandardLighting.azsli
+    Materials/Pipelines/Mobile/ForwardPass_BaseLighting.azsli
+    Materials/Pipelines/Mobile/ForwardPass_StandardLighting.azsli
+    Materials/Pipelines/Mobile/ForwardPass_StandardLighting_CustomZ.azsli
+    Materials/Pipelines/Mobile/MobileForwardPassVertexAndPixel.azsli
+    Materials/Pipelines/Mobile/MobilePipelineScript.lua
+    Materials/Pipelines/Mobile/Transparent_StandardLighting.azsli
     Materials/Pipelines/MultiView/ForwardPass_BaseLighting.azsli
     Materials/Pipelines/MultiView/ForwardPass_BaseLighting.azsli
     Materials/Pipelines/MultiView/ForwardPass_StandardLighting.azsli
     Materials/Pipelines/MultiView/ForwardPass_StandardLighting.azsli
     Materials/Pipelines/MultiView/ForwardPass_StandardLighting_CustomZ.azsli
     Materials/Pipelines/MultiView/ForwardPass_StandardLighting_CustomZ.azsli
@@ -45,13 +51,16 @@ set(FILES
     Materials/Special/ShadowCatcher.shader
     Materials/Special/ShadowCatcher.shader
     Materials/Types/BasePBR.azsli
     Materials/Types/BasePBR.azsli
     Materials/Types/BasePBR.materialtype
     Materials/Types/BasePBR.materialtype
+    Materials/Types/BasePBR_VertexColorEnableFeature.lua
     Materials/Types/EnhancedPBR.azsli
     Materials/Types/EnhancedPBR.azsli
     Materials/Types/EnhancedPBR.materialtype
     Materials/Types/EnhancedPBR.materialtype
     Materials/Types/EnhancedPBR_Anisotropy.lua
     Materials/Types/EnhancedPBR_Anisotropy.lua
     Materials/Types/EnhancedPBR_SubsurfaceState.lua
     Materials/Types/EnhancedPBR_SubsurfaceState.lua
     Materials/Types/Eye.azsli
     Materials/Types/Eye.azsli
     Materials/Types/Eye.materialtype
     Materials/Types/Eye.materialtype
+    Materials/Types/MaterialInputs/DetailMapsCommonFunctor.lua
     Materials/Types/Silhouette.materialtype
     Materials/Types/Silhouette.materialtype
+    Materials/Types/Silhouette_DepthState.lua
     Materials/Types/Skin.azsli
     Materials/Types/Skin.azsli
     Materials/Types/Skin.materialtype
     Materials/Types/Skin.materialtype
     Materials/Types/Skin_SpecularF0.lua
     Materials/Types/Skin_SpecularF0.lua
@@ -71,7 +80,6 @@ set(FILES
     Materials/Types/StandardPBR_Metallic.lua
     Materials/Types/StandardPBR_Metallic.lua
     Materials/Types/StandardPBR_ParallaxState.lua
     Materials/Types/StandardPBR_ParallaxState.lua
     Materials/Types/StandardPBR_Roughness.lua
     Materials/Types/StandardPBR_Roughness.lua
-    Materials/Types/MaterialInputs/DetailMapsCommonFunctor.lua
     Passes/AuxGeom.pass
     Passes/AuxGeom.pass
     Passes/BlendColorGradingLuts.pass
     Passes/BlendColorGradingLuts.pass
     Passes/Bloom.pass
     Passes/Bloom.pass
@@ -86,9 +94,6 @@ set(FILES
     Passes/CheckerboardResolveColor.pass
     Passes/CheckerboardResolveColor.pass
     Passes/CheckerboardResolveDepth.pass
     Passes/CheckerboardResolveDepth.pass
     Passes/ChromaticAberration.pass
     Passes/ChromaticAberration.pass
-    Passes/PaniniProjection.pass
-    Passes/FilmGrain.pass
-    Passes/Vignette.pass
     Passes/ContrastAdaptiveSharpening.pass
     Passes/ContrastAdaptiveSharpening.pass
     Passes/ConvertToAcescg.pass
     Passes/ConvertToAcescg.pass
     Passes/DebugOverlayParent.pass
     Passes/DebugOverlayParent.pass
@@ -125,6 +130,7 @@ set(FILES
     Passes/FastDepthAwareBlur.pass
     Passes/FastDepthAwareBlur.pass
     Passes/FastDepthAwareBlurHor.pass
     Passes/FastDepthAwareBlurHor.pass
     Passes/FastDepthAwareBlurVer.pass
     Passes/FastDepthAwareBlurVer.pass
+    Passes/FilmGrain.pass
     Passes/Forward.pass
     Passes/Forward.pass
     Passes/ForwardCheckerboard.pass
     Passes/ForwardCheckerboard.pass
     Passes/ForwardSubsurface.pass
     Passes/ForwardSubsurface.pass
@@ -150,6 +156,19 @@ set(FILES
     Passes/MainPipeline.pass
     Passes/MainPipeline.pass
     Passes/MainPipelineRenderToTexture.pass
     Passes/MainPipelineRenderToTexture.pass
     Passes/MeshMotionVector.pass
     Passes/MeshMotionVector.pass
+    Passes/Mobile/DeferredFog.pass
+    Passes/Mobile/DisplayMapper.pass
+    Passes/Mobile/Forward.pass
+    Passes/Mobile/Pipeline.pass
+    Passes/Mobile/PostProcessParent.pass
+    Passes/Mobile/ShadowParent.pass
+    Passes/Mobile/SkyBox.pass
+    Passes/Mobile/Subpass1Parent.pass
+    Passes/Mobile/Subpass2Parent.pass
+    Passes/Mobile/Subpass3Parent.pass
+    Passes/Mobile/SubpassesParent.pass
+    Passes/Mobile/Transparent.pass
+    Passes/Mobile/TransparentParent.pass
     Passes/ModulateTexture.pass
     Passes/ModulateTexture.pass
     Passes/MorphTarget.pass
     Passes/MorphTarget.pass
     Passes/MotionVectorParent.pass
     Passes/MotionVectorParent.pass
@@ -161,12 +180,6 @@ set(FILES
     Passes/MultiViewSkyBox.pass
     Passes/MultiViewSkyBox.pass
     Passes/MultiViewTransparent.pass
     Passes/MultiViewTransparent.pass
     Passes/MultiViewTransparentParent.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/NewDepthOfField.pass
     Passes/NewDepthOfFieldComposite.pass
     Passes/NewDepthOfFieldComposite.pass
     Passes/NewDepthOfFieldDownsample.pass
     Passes/NewDepthOfFieldDownsample.pass
@@ -175,6 +188,7 @@ set(FILES
     Passes/NewDepthOfFieldTile3x3.pass
     Passes/NewDepthOfFieldTile3x3.pass
     Passes/NewDepthOfFieldTileReduce.pass
     Passes/NewDepthOfFieldTileReduce.pass
     Passes/OpaqueParent.pass
     Passes/OpaqueParent.pass
+    Passes/PaniniProjection.pass
     Passes/PostProcessParent.pass
     Passes/PostProcessParent.pass
     Passes/ProjectedShadowmaps.pass
     Passes/ProjectedShadowmaps.pass
     Passes/RayTracingAccelerationStructure.pass
     Passes/RayTracingAccelerationStructure.pass
@@ -200,6 +214,8 @@ set(FILES
     Passes/ReflectionScreenSpaceRayTracing.pass
     Passes/ReflectionScreenSpaceRayTracing.pass
     Passes/ReflectionScreenSpaceTrace.pass
     Passes/ReflectionScreenSpaceTrace.pass
     Passes/ShadowParent.pass
     Passes/ShadowParent.pass
+    Passes/Silhouette.pass
+    Passes/SilhouetteGather.pass
     Passes/Skinning.pass
     Passes/Skinning.pass
     Passes/SkyAtmosphere.pass
     Passes/SkyAtmosphere.pass
     Passes/SkyAtmosphereParent.pass
     Passes/SkyAtmosphereParent.pass
@@ -228,6 +244,7 @@ set(FILES
     Passes/TransparentParent.pass
     Passes/TransparentParent.pass
     Passes/UI.pass
     Passes/UI.pass
     Passes/UIParent.pass
     Passes/UIParent.pass
+    Passes/Vignette.pass
     Passes/WhiteBalance.pass
     Passes/WhiteBalance.pass
     Scripts/material_find_overrides_demo.lua
     Scripts/material_find_overrides_demo.lua
     Scripts/material_property_overrides_demo.lua
     Scripts/material_property_overrides_demo.lua
@@ -236,16 +253,6 @@ set(FILES
     ShaderLib/3rdParty/Features/PostProcessing/PSstyleColorBlends_Separable.azsli
     ShaderLib/3rdParty/Features/PostProcessing/PSstyleColorBlends_Separable.azsli
     ShaderLib/Atom/Features/Bindless.azsli
     ShaderLib/Atom/Features/Bindless.azsli
     ShaderLib/Atom/Features/BlendUtility.azsli
     ShaderLib/Atom/Features/BlendUtility.azsli
-    ShaderLib/Atom/Features/Debug.azsli
-    ShaderLib/Atom/Features/IndirectRendering.azsli
-    ShaderLib/Atom/Features/InstancedTransforms.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/VertexUtility.azsli
-    ShaderLib/Atom/Features/ColorManagement/TransformColor.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCcToAcesCg.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCcToAcesCg.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCgToAcesCc.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCgToAcesCc.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCg_To_LinearSrgb.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCg_To_LinearSrgb.azsli
@@ -255,27 +262,34 @@ set(FILES
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearSrgb_To_AcesCg.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearSrgb_To_AcesCg.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearSrgb_To_Srgb.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearSrgb_To_Srgb.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/Srgb_To_LinearSrgb.azsli
     ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/Srgb_To_LinearSrgb.azsli
+    ShaderLib/Atom/Features/ColorManagement/TransformColor.azsli
     ShaderLib/Atom/Features/CoreLights/PhotometricValue.azsli
     ShaderLib/Atom/Features/CoreLights/PhotometricValue.azsli
+    ShaderLib/Atom/Features/Debug.azsli
     ShaderLib/Atom/Features/Decals/DecalTextureUtil.azsli
     ShaderLib/Atom/Features/Decals/DecalTextureUtil.azsli
+    ShaderLib/Atom/Features/IndirectRendering.azsli
+    ShaderLib/Atom/Features/InstancedTransforms.azsli
     ShaderLib/Atom/Features/LightCulling/LightCullingShared.azsli
     ShaderLib/Atom/Features/LightCulling/LightCullingShared.azsli
     ShaderLib/Atom/Features/LightCulling/LightCullingTileIterator.azsli
     ShaderLib/Atom/Features/LightCulling/LightCullingTileIterator.azsli
     ShaderLib/Atom/Features/LightCulling/NVLC.azsli
     ShaderLib/Atom/Features/LightCulling/NVLC.azsli
+    ShaderLib/Atom/Features/Materials/MaterialSrg.azsli
+    ShaderLib/Atom/Features/Materials/SceneMaterialSrg.azsli
+    ShaderLib/Atom/Features/Materials/SingleMaterialSrg.azsli
     ShaderLib/Atom/Features/Math/Filter.azsli
     ShaderLib/Atom/Features/Math/Filter.azsli
     ShaderLib/Atom/Features/Math/FilterPassSrg.azsli
     ShaderLib/Atom/Features/Math/FilterPassSrg.azsli
     ShaderLib/Atom/Features/Math/IntersectionTests.azsli
     ShaderLib/Atom/Features/Math/IntersectionTests.azsli
+    ShaderLib/Atom/Features/MatrixUtility.azsli
     ShaderLib/Atom/Features/MorphTargets/MorphTargetCompression.azsli
     ShaderLib/Atom/Features/MorphTargets/MorphTargetCompression.azsli
+    ShaderLib/Atom/Features/ParallaxMapping.azsli
     ShaderLib/Atom/Features/PBR/AlphaUtils.azsli
     ShaderLib/Atom/Features/PBR/AlphaUtils.azsli
     ShaderLib/Atom/Features/PBR/BackLighting.azsli
     ShaderLib/Atom/Features/PBR/BackLighting.azsli
     ShaderLib/Atom/Features/PBR/Decals.azsli
     ShaderLib/Atom/Features/PBR/Decals.azsli
     ShaderLib/Atom/Features/PBR/DefaultObjectSrg.azsli
     ShaderLib/Atom/Features/PBR/DefaultObjectSrg.azsli
     ShaderLib/Atom/Features/PBR/Hammersley.azsli
     ShaderLib/Atom/Features/PBR/Hammersley.azsli
-    ShaderLib/Atom/Features/PBR/LightingOptions.azsli
-    ShaderLib/Atom/Features/PBR/LightingUtils.azsli
-    ShaderLib/Atom/Features/PBR/MaterialUtils.azsli
-    ShaderLib/Atom/Features/PBR/SpecularAA.azsli
     ShaderLib/Atom/Features/PBR/Lighting/DualSpecularLighting.azsli
     ShaderLib/Atom/Features/PBR/Lighting/DualSpecularLighting.azsli
     ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli
     ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli
     ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli
     ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli
+    ShaderLib/Atom/Features/PBR/LightingOptions.azsli
+    ShaderLib/Atom/Features/PBR/LightingUtils.azsli
     ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli
     ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli
     ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli
     ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli
     ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli
     ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli
@@ -290,9 +304,11 @@ set(FILES
     ShaderLib/Atom/Features/PBR/Lights/ReflectionProbeData.azsli
     ShaderLib/Atom/Features/PBR/Lights/ReflectionProbeData.azsli
     ShaderLib/Atom/Features/PBR/Lights/SimplePointLight.azsli
     ShaderLib/Atom/Features/PBR/Lights/SimplePointLight.azsli
     ShaderLib/Atom/Features/PBR/Lights/SimpleSpotLight.azsli
     ShaderLib/Atom/Features/PBR/Lights/SimpleSpotLight.azsli
+    ShaderLib/Atom/Features/PBR/MaterialUtils.azsli
     ShaderLib/Atom/Features/PBR/Microfacet/Brdf.azsli
     ShaderLib/Atom/Features/PBR/Microfacet/Brdf.azsli
     ShaderLib/Atom/Features/PBR/Microfacet/Fresnel.azsli
     ShaderLib/Atom/Features/PBR/Microfacet/Fresnel.azsli
     ShaderLib/Atom/Features/PBR/Microfacet/Ggx.azsli
     ShaderLib/Atom/Features/PBR/Microfacet/Ggx.azsli
+    ShaderLib/Atom/Features/PBR/SpecularAA.azsli
     ShaderLib/Atom/Features/PBR/Surfaces/AnisotropicSurfaceData.azsli
     ShaderLib/Atom/Features/PBR/Surfaces/AnisotropicSurfaceData.azsli
     ShaderLib/Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli
     ShaderLib/Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli
     ShaderLib/Atom/Features/PBR/Surfaces/DualSpecularSurface.azsli
     ShaderLib/Atom/Features/PBR/Surfaces/DualSpecularSurface.azsli
@@ -312,16 +328,17 @@ set(FILES
     ShaderLib/Atom/Features/PostProcessing/PostProcessUtil.azsli
     ShaderLib/Atom/Features/PostProcessing/PostProcessUtil.azsli
     ShaderLib/Atom/Features/PostProcessing/Shapers.azsli
     ShaderLib/Atom/Features/PostProcessing/Shapers.azsli
     ShaderLib/Atom/Features/PostProcessing/Tonemap.azsli
     ShaderLib/Atom/Features/PostProcessing/Tonemap.azsli
-    ShaderLib/Atom/Features/RayTracing/RayTracingIntersectionAttributes.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingGlobalSrg.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingGlobalSrg.azsli
+    ShaderLib/Atom/Features/RayTracing/RayTracingIntersectionAttributes.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingMaterialSrg.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingMaterialSrg.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingMaterialUtils.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingMaterialUtils.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingSceneSrg.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingSceneSrg.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingSceneUtils.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingSceneUtils.azsli
-    ShaderLib/Atom/Features/RayTracing/RayTracingSrgs.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingSrgs.azsl
     ShaderLib/Atom/Features/RayTracing/RayTracingSrgs.azsl
+    ShaderLib/Atom/Features/RayTracing/RayTracingSrgs.azsli
     ShaderLib/Atom/Features/RayTracing/RayTracingSrgs.shader
     ShaderLib/Atom/Features/RayTracing/RayTracingSrgs.shader
     ShaderLib/Atom/Features/ScreenSpace/ScreenSpaceUtil.azsli
     ShaderLib/Atom/Features/ScreenSpace/ScreenSpaceUtil.azsli
+    ShaderLib/Atom/Features/ShaderQualityOptions.azsli
     ShaderLib/Atom/Features/Shadow/BicubicPcfFilters.azsli
     ShaderLib/Atom/Features/Shadow/BicubicPcfFilters.azsli
     ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli
     ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli
     ShaderLib/Atom/Features/Shadow/DirectionalLightShadowCalculator.azsli
     ShaderLib/Atom/Features/Shadow/DirectionalLightShadowCalculator.azsli
@@ -332,18 +349,19 @@ set(FILES
     ShaderLib/Atom/Features/Shadow/Shadow.azsli
     ShaderLib/Atom/Features/Shadow/Shadow.azsli
     ShaderLib/Atom/Features/Shadow/ShadowmapAtlasLib.azsli
     ShaderLib/Atom/Features/Shadow/ShadowmapAtlasLib.azsli
     ShaderLib/Atom/Features/Skin/SkinObjectSrg.azsli
     ShaderLib/Atom/Features/Skin/SkinObjectSrg.azsli
-    ShaderResourceGroups/SceneSrg.azsli
-    ShaderResourceGroups/SceneSrgAll.azsli
-    ShaderResourceGroups/ViewSrg.azsli
-    ShaderResourceGroups/ViewSrgAll.azsli
+    ShaderLib/Atom/Features/SphericalHarmonicsUtility.azsli
+    ShaderLib/Atom/Features/SrgSemantics.azsli
+    ShaderLib/Atom/Features/VertexUtility.azsli
     ShaderResourceGroups/CoreLights/SceneSrg.azsli
     ShaderResourceGroups/CoreLights/SceneSrg.azsli
     ShaderResourceGroups/CoreLights/ViewSrg.azsli
     ShaderResourceGroups/CoreLights/ViewSrg.azsli
     ShaderResourceGroups/Decals/ViewSrg.azsli
     ShaderResourceGroups/Decals/ViewSrg.azsli
     ShaderResourceGroups/PostProcessing/SceneSrg.azsli
     ShaderResourceGroups/PostProcessing/SceneSrg.azsli
     ShaderResourceGroups/PostProcessing/ViewSrg.azsli
     ShaderResourceGroups/PostProcessing/ViewSrg.azsli
+    ShaderResourceGroups/SceneSrg.azsli
+    ShaderResourceGroups/SceneSrgAll.azsli
     ShaderResourceGroups/SkyBox/SceneSrg.azsli
     ShaderResourceGroups/SkyBox/SceneSrg.azsli
-    Shaders/ForwardPassSrg.azsl
-    Shaders/ForwardPassSrg.shader
+    ShaderResourceGroups/ViewSrg.azsli
+    ShaderResourceGroups/ViewSrgAll.azsli
     Shaders/AuxGeom/AuxGeomObject.azsl
     Shaders/AuxGeom/AuxGeomObject.azsl
     Shaders/AuxGeom/AuxGeomObject.shader
     Shaders/AuxGeom/AuxGeomObject.shader
     Shaders/AuxGeom/AuxGeomObjectLit.azsl
     Shaders/AuxGeom/AuxGeomObjectLit.azsl
@@ -371,6 +389,8 @@ set(FILES
     Shaders/Depth/DepthPass.shader
     Shaders/Depth/DepthPass.shader
     Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.azsl
     Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.azsl
     Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.shader
     Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.shader
+    Shaders/ForwardPassSrg.azsl
+    Shaders/ForwardPassSrg.shader
     Shaders/ImGui/ImGui.azsl
     Shaders/ImGui/ImGui.azsl
     Shaders/ImGui/ImGui.shader
     Shaders/ImGui/ImGui.shader
     Shaders/LightCulling/LightCulling.azsl
     Shaders/LightCulling/LightCulling.azsl
@@ -381,27 +401,27 @@ set(FILES
     Shaders/LightCulling/LightCullingRemap.shader
     Shaders/LightCulling/LightCullingRemap.shader
     Shaders/LightCulling/LightCullingTilePrepare.azsl
     Shaders/LightCulling/LightCullingTilePrepare.azsl
     Shaders/LightCulling/LightCullingTilePrepare.shader
     Shaders/LightCulling/LightCullingTilePrepare.shader
-    Shaders/Materials/DepthPass_VertexData.azsli
-    Shaders/Materials/DepthPass_VertexEval.azsli
     Shaders/Materials/BasePBR/BasePBR_LightingBrdf.azsli
     Shaders/Materials/BasePBR/BasePBR_LightingBrdf.azsli
     Shaders/Materials/BasePBR/BasePBR_LightingData.azsli
     Shaders/Materials/BasePBR/BasePBR_LightingData.azsli
     Shaders/Materials/BasePBR/BasePBR_LightingEval.azsli
     Shaders/Materials/BasePBR/BasePBR_LightingEval.azsli
-    Shaders/Materials/BasePBR/BasePBR_MaterialSrg.azsli
+    Shaders/Materials/BasePBR/BasePBR_MaterialInputs.azsli
     Shaders/Materials/BasePBR/BasePBR_PixelGeometryData.azsli
     Shaders/Materials/BasePBR/BasePBR_PixelGeometryData.azsli
     Shaders/Materials/BasePBR/BasePBR_PixelGeometryEval.azsli
     Shaders/Materials/BasePBR/BasePBR_PixelGeometryEval.azsli
     Shaders/Materials/BasePBR/BasePBR_SurfaceData.azsli
     Shaders/Materials/BasePBR/BasePBR_SurfaceData.azsli
     Shaders/Materials/BasePBR/BasePBR_SurfaceEval.azsli
     Shaders/Materials/BasePBR/BasePBR_SurfaceEval.azsli
     Shaders/Materials/BasePBR/BasePBR_VertexData.azsli
     Shaders/Materials/BasePBR/BasePBR_VertexData.azsli
     Shaders/Materials/BasePBR/BasePBR_VertexEval.azsli
     Shaders/Materials/BasePBR/BasePBR_VertexEval.azsli
+    Shaders/Materials/DepthPass_VertexData.azsli
+    Shaders/Materials/DepthPass_VertexEval.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_LightingBrdf.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_LightingBrdf.azsli
-    Shaders/Materials/EnhancedPBR/EnhancedPBR_MaterialSrg.azsli
+    Shaders/Materials/EnhancedPBR/EnhancedPBR_MaterialInputs.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_PixelGeometryData.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_PixelGeometryData.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_PixelGeometryEval.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_PixelGeometryEval.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_SurfaceData.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_SurfaceData.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_SurfaceEval.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_SurfaceEval.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_VertexData.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_VertexData.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_VertexEval.azsli
     Shaders/Materials/EnhancedPBR/EnhancedPBR_VertexEval.azsli
-    Shaders/Materials/Eye/Eye_MaterialSrg.azsli
+    Shaders/Materials/Eye/Eye_MaterialInputs.azsli
     Shaders/Materials/Eye/Eye_PixelGeometryData.azsli
     Shaders/Materials/Eye/Eye_PixelGeometryData.azsli
     Shaders/Materials/Eye/Eye_PixelGeometryEval.azsli
     Shaders/Materials/Eye/Eye_PixelGeometryEval.azsli
     Shaders/Materials/Eye/Eye_SurfaceEval.azsli
     Shaders/Materials/Eye/Eye_SurfaceEval.azsli
@@ -417,21 +437,27 @@ set(FILES
     Shaders/Materials/MaterialInputs/BaseColorInput.azsli
     Shaders/Materials/MaterialInputs/BaseColorInput.azsli
     Shaders/Materials/MaterialInputs/ClearCoatInput.azsli
     Shaders/Materials/MaterialInputs/ClearCoatInput.azsli
     Shaders/Materials/MaterialInputs/DetailMapsInput.azsli
     Shaders/Materials/MaterialInputs/DetailMapsInput.azsli
+    Shaders/Materials/MaterialInputs/DualSpecular.azsli
     Shaders/Materials/MaterialInputs/EmissiveInput.azsli
     Shaders/Materials/MaterialInputs/EmissiveInput.azsli
     Shaders/Materials/MaterialInputs/MetallicInput.azsli
     Shaders/Materials/MaterialInputs/MetallicInput.azsli
     Shaders/Materials/MaterialInputs/NormalInput.azsli
     Shaders/Materials/MaterialInputs/NormalInput.azsli
     Shaders/Materials/MaterialInputs/OcclusionInput.azsli
     Shaders/Materials/MaterialInputs/OcclusionInput.azsli
     Shaders/Materials/MaterialInputs/ParallaxInput.azsli
     Shaders/Materials/MaterialInputs/ParallaxInput.azsli
     Shaders/Materials/MaterialInputs/RoughnessInput.azsli
     Shaders/Materials/MaterialInputs/RoughnessInput.azsli
+    Shaders/Materials/MaterialInputs/SilhouetteBlockerInput.azsli
+    Shaders/Materials/MaterialInputs/SilhouetteInput.azsli
     Shaders/Materials/MaterialInputs/SpecularInput.azsli
     Shaders/Materials/MaterialInputs/SpecularInput.azsli
     Shaders/Materials/MaterialInputs/SubsurfaceInput.azsli
     Shaders/Materials/MaterialInputs/SubsurfaceInput.azsli
     Shaders/Materials/MaterialInputs/TransmissionInput.azsli
     Shaders/Materials/MaterialInputs/TransmissionInput.azsli
     Shaders/Materials/MaterialInputs/UvSetCount.azsli
     Shaders/Materials/MaterialInputs/UvSetCount.azsli
+    Shaders/Materials/MaterialInputs/VertexColorInput.azsli
     Shaders/Materials/MultilayerPBR/StandardMultilayerPBR_Common.azsli
     Shaders/Materials/MultilayerPBR/StandardMultilayerPBR_Common.azsli
     Shaders/Materials/MultilayerPBR/StandardMultilayerPBR_DepthPass_WithPS.azsl
     Shaders/Materials/MultilayerPBR/StandardMultilayerPBR_DepthPass_WithPS.azsl
     Shaders/Materials/MultilayerPBR/StandardMultilayerPBR_Shadowmap_WithPS.azsl
     Shaders/Materials/MultilayerPBR/StandardMultilayerPBR_Shadowmap_WithPS.azsl
+    Shaders/Materials/Silhouette/SilhouetteGather_MaterialSrg.azsli
     Shaders/Materials/Skin/Skin_LightingBrdf.azsli
     Shaders/Materials/Skin/Skin_LightingBrdf.azsli
-    Shaders/Materials/Skin/Skin_MaterialSrg.azsli
+    Shaders/Materials/Skin/Skin_LightingEval.azsli
+    Shaders/Materials/Skin/Skin_MaterialInputs.azsli
     Shaders/Materials/Skin/Skin_PixelGeometryData.azsli
     Shaders/Materials/Skin/Skin_PixelGeometryData.azsli
     Shaders/Materials/Skin/Skin_PixelGeometryEval.azsli
     Shaders/Materials/Skin/Skin_PixelGeometryEval.azsli
     Shaders/Materials/Skin/Skin_SurfaceData.azsli
     Shaders/Materials/Skin/Skin_SurfaceData.azsli
@@ -440,7 +466,7 @@ set(FILES
     Shaders/Materials/Skin/Skin_VertexEval.azsli
     Shaders/Materials/Skin/Skin_VertexEval.azsli
     Shaders/Materials/StandardPBR/StandardPBR_LightingBrdf.azsli
     Shaders/Materials/StandardPBR/StandardPBR_LightingBrdf.azsli
     Shaders/Materials/StandardPBR/StandardPBR_LightingEval.azsli
     Shaders/Materials/StandardPBR/StandardPBR_LightingEval.azsli
-    Shaders/Materials/StandardPBR/StandardPBR_MaterialSrg.azsli
+    Shaders/Materials/StandardPBR/StandardPBR_MaterialInputs.azsli
     Shaders/Materials/StandardPBR/StandardPBR_PixelGeometryData.azsli
     Shaders/Materials/StandardPBR/StandardPBR_PixelGeometryData.azsli
     Shaders/Materials/StandardPBR/StandardPBR_PixelGeometryEval.azsli
     Shaders/Materials/StandardPBR/StandardPBR_PixelGeometryEval.azsli
     Shaders/Materials/StandardPBR/StandardPBR_SurfaceData.azsli
     Shaders/Materials/StandardPBR/StandardPBR_SurfaceData.azsli
@@ -450,10 +476,6 @@ set(FILES
     Shaders/MorphTargets/MorphTargetSRG.azsli
     Shaders/MorphTargets/MorphTargetSRG.azsli
     Shaders/MotionVector/CameraMotionVector.azsl
     Shaders/MotionVector/CameraMotionVector.azsl
     Shaders/MotionVector/CameraMotionVector.shader
     Shaders/MotionVector/CameraMotionVector.shader
-    Shaders/Silhouette/Silhouette.azsl
-    Shaders/Silhouette/Silhouette.shader
-    Shaders/Silhouette/SilhouetteGather.azsl
-    Shaders/Silhouette/SilhouetteGather.shader
     Shaders/PostProcessing/AcesOutputTransformLut.azsl
     Shaders/PostProcessing/AcesOutputTransformLut.azsl
     Shaders/PostProcessing/AcesOutputTransformLut.shader
     Shaders/PostProcessing/AcesOutputTransformLut.shader
     Shaders/PostProcessing/ApplyShaperLookupTable.azsl
     Shaders/PostProcessing/ApplyShaperLookupTable.azsl
@@ -470,12 +492,6 @@ set(FILES
     Shaders/PostProcessing/BloomDownsampleCS.shader
     Shaders/PostProcessing/BloomDownsampleCS.shader
     Shaders/PostProcessing/ChromaticAberration.azsl
     Shaders/PostProcessing/ChromaticAberration.azsl
     Shaders/PostProcessing/ChromaticAberration.shader
     Shaders/PostProcessing/ChromaticAberration.shader
-    Shaders/PostProcessing/PaniniProjection.azsl
-    Shaders/PostProcessing/PaniniProjection.shader
-    Shaders/PostProcessing/FilmGrain.azsl
-    Shaders/PostProcessing/FilmGrain.shader
-    Shaders/PostProcessing/Vignette.azsl
-    Shaders/PostProcessing/Vignette.shader
     Shaders/PostProcessing/ContrastAdaptiveSharpening.azsl
     Shaders/PostProcessing/ContrastAdaptiveSharpening.azsl
     Shaders/PostProcessing/ContrastAdaptiveSharpening.shader
     Shaders/PostProcessing/ContrastAdaptiveSharpening.shader
     Shaders/PostProcessing/ConvertToAcescg.azsl
     Shaders/PostProcessing/ConvertToAcescg.azsl
@@ -519,6 +535,8 @@ set(FILES
     Shaders/PostProcessing/FastDepthAwareBlurHor.shader
     Shaders/PostProcessing/FastDepthAwareBlurHor.shader
     Shaders/PostProcessing/FastDepthAwareBlurVer.azsl
     Shaders/PostProcessing/FastDepthAwareBlurVer.azsl
     Shaders/PostProcessing/FastDepthAwareBlurVer.shader
     Shaders/PostProcessing/FastDepthAwareBlurVer.shader
+    Shaders/PostProcessing/FilmGrain.azsl
+    Shaders/PostProcessing/FilmGrain.shader
     Shaders/PostProcessing/FullscreenCopy.azsl
     Shaders/PostProcessing/FullscreenCopy.azsl
     Shaders/PostProcessing/FullscreenCopy.shader
     Shaders/PostProcessing/FullscreenCopy.shader
     Shaders/PostProcessing/HDRColorGrading.azsl
     Shaders/PostProcessing/HDRColorGrading.azsl
@@ -551,6 +569,9 @@ set(FILES
     Shaders/PostProcessing/NewDepthOfFieldTileReduce.shader
     Shaders/PostProcessing/NewDepthOfFieldTileReduce.shader
     Shaders/PostProcessing/OutputTransform.azsl
     Shaders/PostProcessing/OutputTransform.azsl
     Shaders/PostProcessing/OutputTransform.shader
     Shaders/PostProcessing/OutputTransform.shader
+    Shaders/PostProcessing/OutputTransformMobile.shader
+    Shaders/PostProcessing/PaniniProjection.azsl
+    Shaders/PostProcessing/PaniniProjection.shader
     Shaders/PostProcessing/ScreenSpaceSubsurfaceScatteringCS.azsl
     Shaders/PostProcessing/ScreenSpaceSubsurfaceScatteringCS.azsl
     Shaders/PostProcessing/ScreenSpaceSubsurfaceScatteringCS.shader
     Shaders/PostProcessing/ScreenSpaceSubsurfaceScatteringCS.shader
     Shaders/PostProcessing/SMAA.azsli
     Shaders/PostProcessing/SMAA.azsli
@@ -569,6 +590,8 @@ set(FILES
     Shaders/PostProcessing/Taa.shader
     Shaders/PostProcessing/Taa.shader
     Shaders/PostProcessing/UniformColor.azsl
     Shaders/PostProcessing/UniformColor.azsl
     Shaders/PostProcessing/UniformColor.shader
     Shaders/PostProcessing/UniformColor.shader
+    Shaders/PostProcessing/Vignette.azsl
+    Shaders/PostProcessing/Vignette.shader
     Shaders/PostProcessing/WhiteBalance.azsl
     Shaders/PostProcessing/WhiteBalance.azsl
     Shaders/PostProcessing/WhiteBalance.shader
     Shaders/PostProcessing/WhiteBalance.shader
     Shaders/Reflections/ReflectionCommon.azsli
     Shaders/Reflections/ReflectionCommon.azsli
@@ -599,8 +622,8 @@ set(FILES
     Shaders/Reflections/ReflectionScreenSpaceFilter.shader
     Shaders/Reflections/ReflectionScreenSpaceFilter.shader
     Shaders/Reflections/ReflectionScreenSpaceRayTracing.azsl
     Shaders/Reflections/ReflectionScreenSpaceRayTracing.azsl
     Shaders/Reflections/ReflectionScreenSpaceRayTracing.shader
     Shaders/Reflections/ReflectionScreenSpaceRayTracing.shader
-    Shaders/Reflections/ReflectionScreenSpaceRayTracingClosestHit.azsli
     Shaders/Reflections/ReflectionScreenSpaceRayTracingClosestHit.azsl
     Shaders/Reflections/ReflectionScreenSpaceRayTracingClosestHit.azsl
+    Shaders/Reflections/ReflectionScreenSpaceRayTracingClosestHit.azsli
     Shaders/Reflections/ReflectionScreenSpaceRayTracingClosestHit.shader
     Shaders/Reflections/ReflectionScreenSpaceRayTracingClosestHit.shader
     Shaders/Reflections/ReflectionScreenSpaceRayTracingClosestHitProcedural.azsl
     Shaders/Reflections/ReflectionScreenSpaceRayTracingClosestHitProcedural.azsl
     Shaders/Reflections/ReflectionScreenSpaceRayTracingClosestHitProcedural.shader
     Shaders/Reflections/ReflectionScreenSpaceRayTracingClosestHitProcedural.shader
@@ -610,8 +633,11 @@ set(FILES
     Shaders/Reflections/ReflectionScreenSpaceTrace.azsl
     Shaders/Reflections/ReflectionScreenSpaceTrace.azsl
     Shaders/Reflections/ReflectionScreenSpaceTrace.azsli
     Shaders/Reflections/ReflectionScreenSpaceTrace.azsli
     Shaders/Reflections/ReflectionScreenSpaceTrace.shader
     Shaders/Reflections/ReflectionScreenSpaceTrace.shader
+    Shaders/SceneMaterialSrg.azsl
+    Shaders/SceneMaterialSrg.shader
     Shaders/ScreenSpace/DeferredFog.azsl
     Shaders/ScreenSpace/DeferredFog.azsl
     Shaders/ScreenSpace/DeferredFog.shader
     Shaders/ScreenSpace/DeferredFog.shader
+    Shaders/ScreenSpace/MobileDeferredFog.shader
     Shaders/Shadow/ClearShadow.shader
     Shaders/Shadow/ClearShadow.shader
     Shaders/Shadow/ClearShadowmap.azsl
     Shaders/Shadow/ClearShadowmap.azsl
     Shaders/Shadow/DepthExponentiation.azsl
     Shaders/Shadow/DepthExponentiation.azsl
@@ -622,6 +648,10 @@ set(FILES
     Shaders/Shadow/KawaseShadowBlur.shader
     Shaders/Shadow/KawaseShadowBlur.shader
     Shaders/Shadow/Shadowmap.azsl
     Shaders/Shadow/Shadowmap.azsl
     Shaders/Shadow/Shadowmap.shader
     Shaders/Shadow/Shadowmap.shader
+    Shaders/Silhouette/Silhouette.azsl
+    Shaders/Silhouette/Silhouette.shader
+    Shaders/Silhouette/SilhouetteGather.azsl
+    Shaders/Silhouette/SilhouetteGather.shader
     Shaders/SkinnedMesh/LinearSkinningCS.azsl
     Shaders/SkinnedMesh/LinearSkinningCS.azsl
     Shaders/SkinnedMesh/LinearSkinningCS.shader
     Shaders/SkinnedMesh/LinearSkinningCS.shader
     Shaders/SkinnedMesh/LinearSkinningPassSRG.azsli
     Shaders/SkinnedMesh/LinearSkinningPassSRG.azsli

+ 3 - 1
Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Material/ConvertEmissiveUnitFunctor.h

@@ -33,11 +33,13 @@ namespace AZ
             void Process(RPI::MaterialFunctorAPI::EditorContext& context) override;
             void Process(RPI::MaterialFunctorAPI::EditorContext& context) override;
             float GetProcessedValue(float originalEmissiveIntensity, uint32_t lightUnitIndex) const;
             float GetProcessedValue(float originalEmissiveIntensity, uint32_t lightUnitIndex) const;
 
 
+            bool UpdateShaderParameterConnections(const RPI::MaterialShaderParameterLayout* layout) override;
+
         private:
         private:
 
 
             AZ::RPI::MaterialPropertyIndex m_intensityPropertyIndex;
             AZ::RPI::MaterialPropertyIndex m_intensityPropertyIndex;
             AZ::RPI::MaterialPropertyIndex m_lightUnitPropertyIndex;
             AZ::RPI::MaterialPropertyIndex m_lightUnitPropertyIndex;
-            AZ::RHI::ShaderInputConstantIndex m_shaderInputIndex;
+            AZ::RPI::MaterialShaderParameterNameIndex m_shaderParameter;
 
 
             uint32_t m_ev100Index;
             uint32_t m_ev100Index;
             uint32_t m_nitIndex;
             uint32_t m_nitIndex;

+ 18 - 5
Gems/Atom/Feature/Common/Code/Source/Material/ConvertEmissiveUnitFunctor.cpp

@@ -19,17 +19,16 @@ namespace AZ
             if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
             if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
             {
             {
                 serializeContext->Class<ConvertEmissiveUnitFunctor, AZ::RPI::MaterialFunctor>()
                 serializeContext->Class<ConvertEmissiveUnitFunctor, AZ::RPI::MaterialFunctor>()
-                    ->Version(6)
+                    ->Version(7) // changed shaderInputIndex to shaderParameter
                     ->Field("intensityPropertyIndex", &ConvertEmissiveUnitFunctor::m_intensityPropertyIndex)
                     ->Field("intensityPropertyIndex", &ConvertEmissiveUnitFunctor::m_intensityPropertyIndex)
                     ->Field("lightUnitPropertyIndex", &ConvertEmissiveUnitFunctor::m_lightUnitPropertyIndex)
                     ->Field("lightUnitPropertyIndex", &ConvertEmissiveUnitFunctor::m_lightUnitPropertyIndex)
-                    ->Field("shaderInputIndex", &ConvertEmissiveUnitFunctor::m_shaderInputIndex)
+                    ->Field("shaderParameter", &ConvertEmissiveUnitFunctor::m_shaderParameter)
                     ->Field("ev100Index", &ConvertEmissiveUnitFunctor::m_ev100Index)
                     ->Field("ev100Index", &ConvertEmissiveUnitFunctor::m_ev100Index)
                     ->Field("nitIndex", &ConvertEmissiveUnitFunctor::m_nitIndex)
                     ->Field("nitIndex", &ConvertEmissiveUnitFunctor::m_nitIndex)
                     ->Field("ev100Min", &ConvertEmissiveUnitFunctor::m_ev100Min)
                     ->Field("ev100Min", &ConvertEmissiveUnitFunctor::m_ev100Min)
                     ->Field("ev100Max", &ConvertEmissiveUnitFunctor::m_ev100Max)
                     ->Field("ev100Max", &ConvertEmissiveUnitFunctor::m_ev100Max)
                     ->Field("nitMin", &ConvertEmissiveUnitFunctor::m_nitMin)
                     ->Field("nitMin", &ConvertEmissiveUnitFunctor::m_nitMin)
-                    ->Field("nitMax", &ConvertEmissiveUnitFunctor::m_nitMax)
-                    ;
+                    ->Field("nitMax", &ConvertEmissiveUnitFunctor::m_nitMax);
             }
             }
         }
         }
 
 
@@ -39,7 +38,7 @@ namespace AZ
             float sourceValue = context.GetMaterialPropertyValue<float>(m_intensityPropertyIndex);
             float sourceValue = context.GetMaterialPropertyValue<float>(m_intensityPropertyIndex);
             uint32_t lightUnit = context.GetMaterialPropertyValue<uint32_t>(m_lightUnitPropertyIndex);
             uint32_t lightUnit = context.GetMaterialPropertyValue<uint32_t>(m_lightUnitPropertyIndex);
             float targetValue = GetProcessedValue(sourceValue, lightUnit);
             float targetValue = GetProcessedValue(sourceValue, lightUnit);
-            context.GetShaderResourceGroup()->SetConstant(m_shaderInputIndex, targetValue);
+            context.GetMaterialShaderParameter()->SetParameter(m_shaderParameter, targetValue);
         }
         }
 
 
         void ConvertEmissiveUnitFunctor::Process(RPI::MaterialFunctorAPI::EditorContext& context)
         void ConvertEmissiveUnitFunctor::Process(RPI::MaterialFunctorAPI::EditorContext& context)
@@ -82,5 +81,19 @@ namespace AZ
 
 
             return PhotometricValue::ConvertIntensityBetweenUnits(sourceType, PhotometricUnit::Nit, originalEmissiveIntensity);
             return PhotometricValue::ConvertIntensityBetweenUnits(sourceType, PhotometricUnit::Nit, originalEmissiveIntensity);
         }
         }
+
+        bool ConvertEmissiveUnitFunctor::UpdateShaderParameterConnections(const RPI::MaterialShaderParameterLayout* layout)
+        {
+            if (m_shaderParameter.ValidateOrFindIndex(layout) == false)
+            {
+                AZ_Error(
+                    "ConvertEmissiveUnitFunctorSourceData",
+                    false,
+                    "Could not find shader parameter '%s'",
+                    m_shaderParameter.GetName().GetCStr());
+                return false;
+            }
+            return true;
+        }
     }
     }
 }
 }

+ 8 - 11
Gems/Atom/Feature/Common/Code/Source/Material/ConvertEmissiveUnitFunctorSourceData.cpp

@@ -18,16 +18,15 @@ namespace AZ
         {
         {
             if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
             if (auto* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
             {
             {
-                serializeContext->Class<ConvertEmissiveUnitFunctorSourceData>()
-                    ->Version(5)
+                serializeContext->Class<ConvertEmissiveUnitFunctorSourceData, RPI::MaterialFunctorSourceData>()
+                    ->Version(6) // added base-class
                     ->Field("intensityProperty", &ConvertEmissiveUnitFunctorSourceData::m_intensityPropertyName)
                     ->Field("intensityProperty", &ConvertEmissiveUnitFunctorSourceData::m_intensityPropertyName)
                     ->Field("lightUnitProperty", &ConvertEmissiveUnitFunctorSourceData::m_lightUnitPropertyName)
                     ->Field("lightUnitProperty", &ConvertEmissiveUnitFunctorSourceData::m_lightUnitPropertyName)
                     ->Field("shaderInput", &ConvertEmissiveUnitFunctorSourceData::m_shaderInputName)
                     ->Field("shaderInput", &ConvertEmissiveUnitFunctorSourceData::m_shaderInputName)
                     ->Field("ev100Index", &ConvertEmissiveUnitFunctorSourceData::m_ev100Index)
                     ->Field("ev100Index", &ConvertEmissiveUnitFunctorSourceData::m_ev100Index)
                     ->Field("nitIndex", &ConvertEmissiveUnitFunctorSourceData::m_nitIndex)
                     ->Field("nitIndex", &ConvertEmissiveUnitFunctorSourceData::m_nitIndex)
                     ->Field("ev100MinMax", &ConvertEmissiveUnitFunctorSourceData::m_ev100MinMax)
                     ->Field("ev100MinMax", &ConvertEmissiveUnitFunctorSourceData::m_ev100MinMax)
-                    ->Field("nitMinMax", &ConvertEmissiveUnitFunctorSourceData::m_nitMinMax)
-                    ;
+                    ->Field("nitMinMax", &ConvertEmissiveUnitFunctorSourceData::m_nitMinMax);
             }
             }
         }
         }
 
 
@@ -49,17 +48,13 @@ namespace AZ
             }
             }
             AddMaterialPropertyDependency(functor, functor->m_lightUnitPropertyIndex);
             AddMaterialPropertyDependency(functor, functor->m_lightUnitPropertyIndex);
 
 
-            functor->m_shaderInputIndex = context.FindShaderInputConstantIndex(AZ::Name{ m_shaderInputName });
-
-            if (functor->m_shaderInputIndex.IsNull())
-            {
-                AZ_Error("ConvertEmissiveUnitFunctorSourceData", false, "Could not find shader input '%s'", m_shaderInputName.data());
-                return Failure();
-            }
+            functor->m_shaderParameter = RPI::MaterialShaderParameterNameIndex{ m_shaderInputName, context.GetNameContext() };
 
 
             functor->m_ev100Index = m_ev100Index;
             functor->m_ev100Index = m_ev100Index;
             functor->m_nitIndex = m_nitIndex;
             functor->m_nitIndex = m_nitIndex;
 
 
+            SetFunctorShaderParameter(functor, GetMaterialShaderParameters(context.GetNameContext()));
+
             return Success(RPI::Ptr<RPI::MaterialFunctor>(functor));
             return Success(RPI::Ptr<RPI::MaterialFunctor>(functor));
         }
         }
 
 
@@ -88,6 +83,8 @@ namespace AZ
             functor->m_nitMin = m_nitMinMax.GetX();
             functor->m_nitMin = m_nitMinMax.GetX();
             functor->m_nitMax = m_nitMinMax.GetY();
             functor->m_nitMax = m_nitMinMax.GetY();
 
 
+            SetFunctorShaderParameter(functor, GetMaterialShaderParameters(context.GetNameContext()));
+
             return Success(RPI::Ptr<RPI::MaterialFunctor>(functor));
             return Success(RPI::Ptr<RPI::MaterialFunctor>(functor));
         }
         }
     }
     }

+ 38 - 3
Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.cpp

@@ -83,9 +83,44 @@ namespace AZ
             transmissionTintThickness.Set(tintColor.GetAsVector3());
             transmissionTintThickness.Set(tintColor.GetAsVector3());
             transmissionTintThickness.SetW(thickness);
             transmissionTintThickness.SetW(thickness);
 
 
-            context.GetShaderResourceGroup()->SetConstant(m_scatterDistance, scatterDistance);
-            context.GetShaderResourceGroup()->SetConstant(m_transmissionParams, transmissionParams);
-            context.GetShaderResourceGroup()->SetConstant(m_transmissionTintThickness, transmissionTintThickness);
+            context.GetMaterialShaderParameter()->SetParameter(m_scatterDistance, scatterDistance);
+            context.GetMaterialShaderParameter()->SetParameter(m_transmissionParams, transmissionParams);
+            context.GetMaterialShaderParameter()->SetParameter(m_transmissionTintThickness, transmissionTintThickness);
+        }
+
+        bool SubsurfaceTransmissionParameterFunctor::UpdateShaderParameterConnections(const RPI::MaterialShaderParameterLayout* layout)
+        {
+            bool valid = true;
+            if (m_scatterDistance.ValidateOrFindIndex(layout) == false)
+            {
+                AZ_Error(
+                    "SubsurfaceTransmissionParameterFunctorSourceData",
+                    false,
+                    "Could not find shader parameter '%s'",
+                    m_scatterDistance.GetName().GetCStr());
+                valid &= false;
+            }
+
+            if (m_transmissionParams.ValidateOrFindIndex(layout) == false)
+            {
+                AZ_Error(
+                    "SubsurfaceTransmissionParameterFunctorSourceData",
+                    false,
+                    "Could not find shader parameter '%s'",
+                    m_transmissionParams.GetName().GetCStr());
+                valid &= false;
+            }
+
+            if (m_transmissionTintThickness.ValidateOrFindIndex(layout) == false)
+            {
+                AZ_Error(
+                    "SubsurfaceTransmissionParameterFunctorSourceData",
+                    false,
+                    "Could not find shader parameter '%s'",
+                    m_transmissionTintThickness.GetName().GetCStr());
+                valid &= false;
+            }
+            return valid;
         }
         }
 
 
     } // namespace Render
     } // namespace Render

+ 4 - 3
Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.h

@@ -29,6 +29,7 @@ namespace AZ
 
 
             using RPI::MaterialFunctor::Process;
             using RPI::MaterialFunctor::Process;
             void Process(RPI::MaterialFunctorAPI::RuntimeContext& context) override;
             void Process(RPI::MaterialFunctorAPI::RuntimeContext& context) override;
+            bool UpdateShaderParameterConnections(const RPI::MaterialShaderParameterLayout* layout) override;
 
 
         private:
         private:
 
 
@@ -48,9 +49,9 @@ namespace AZ
             RPI::MaterialPropertyIndex m_scatterDistanceIntensity;
             RPI::MaterialPropertyIndex m_scatterDistanceIntensity;
 
 
             // Shader setting output...
             // Shader setting output...
-            RHI::ShaderInputConstantIndex m_scatterDistance;
-            RHI::ShaderInputConstantIndex m_transmissionParams;
-            RHI::ShaderInputConstantIndex m_transmissionTintThickness;
+            RPI::MaterialShaderParameterNameIndex m_scatterDistance;
+            RPI::MaterialShaderParameterNameIndex m_transmissionParams;
+            RPI::MaterialShaderParameterNameIndex m_transmissionTintThickness;
         };
         };
     } // namespace Render
     } // namespace Render
 } // namespace AZ
 } // namespace AZ

+ 7 - 23
Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.cpp

@@ -19,7 +19,7 @@ namespace AZ
             if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
             if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
             {
             {
                 serializeContext->Class<SubsurfaceTransmissionParameterFunctorSourceData, RPI::MaterialFunctorSourceData>()
                 serializeContext->Class<SubsurfaceTransmissionParameterFunctorSourceData, RPI::MaterialFunctorSourceData>()
-                    ->Version(1)
+                    ->Version(2) // added shrinkFactor, transmissionNdLBias and distanceAttenuation
                     ->Field("mode", &SubsurfaceTransmissionParameterFunctorSourceData::m_mode)
                     ->Field("mode", &SubsurfaceTransmissionParameterFunctorSourceData::m_mode)
                     ->Field("scale", &SubsurfaceTransmissionParameterFunctorSourceData::m_scale)
                     ->Field("scale", &SubsurfaceTransmissionParameterFunctorSourceData::m_scale)
                     ->Field("power", &SubsurfaceTransmissionParameterFunctorSourceData::m_power)
                     ->Field("power", &SubsurfaceTransmissionParameterFunctorSourceData::m_power)
@@ -36,7 +36,7 @@ namespace AZ
                     ->Field("scatterDistanceShaderInput", &SubsurfaceTransmissionParameterFunctorSourceData::m_scatterDistance)
                     ->Field("scatterDistanceShaderInput", &SubsurfaceTransmissionParameterFunctorSourceData::m_scatterDistance)
                     ->Field("parametersShaderInput", &SubsurfaceTransmissionParameterFunctorSourceData::m_transmissionParams)
                     ->Field("parametersShaderInput", &SubsurfaceTransmissionParameterFunctorSourceData::m_transmissionParams)
                     ->Field("tintThickenssShaderInput", &SubsurfaceTransmissionParameterFunctorSourceData::m_transmissionTintThickness);
                     ->Field("tintThickenssShaderInput", &SubsurfaceTransmissionParameterFunctorSourceData::m_transmissionTintThickness);
-                    ;
+                ;
             }
             }
         }
         }
 
 
@@ -82,27 +82,11 @@ namespace AZ
             AddMaterialPropertyDependency(functor, functor->m_scatterDistanceColor);
             AddMaterialPropertyDependency(functor, functor->m_scatterDistanceColor);
             AddMaterialPropertyDependency(functor, functor->m_scatterDistanceIntensity);
             AddMaterialPropertyDependency(functor, functor->m_scatterDistanceIntensity);
 
 
-            functor->m_scatterDistance = context.FindShaderInputConstantIndex(Name{ m_scatterDistance });
-            functor->m_transmissionParams = context.FindShaderInputConstantIndex(Name{ m_transmissionParams });
-            functor->m_transmissionTintThickness = context.FindShaderInputConstantIndex(Name{ m_transmissionTintThickness });
-
-            if (functor->m_scatterDistance.IsNull())
-            {
-                AZ_Error("ShaderCollectionFunctorSourceData", false, "Could not find shader input '%s'", m_scatterDistance.c_str());
-                return Failure();
-            }
-
-            if (functor->m_transmissionParams.IsNull())
-            {
-                AZ_Error("ShaderCollectionFunctorSourceData", false, "Could not find shader input '%s'", m_transmissionParams.c_str());
-                return Failure();
-            }
-
-            if (functor->m_transmissionTintThickness.IsNull())
-            {
-                AZ_Error("ShaderCollectionFunctorSourceData", false, "Could not find shader input '%s'", m_transmissionTintThickness.c_str());
-                return Failure();
-            }
+            functor->m_scatterDistance = RPI::MaterialShaderParameterNameIndex{ m_scatterDistance, context.GetNameContext() };
+            functor->m_transmissionParams = RPI::MaterialShaderParameterNameIndex{ m_transmissionParams, context.GetNameContext() };
+            functor->m_transmissionTintThickness =
+                RPI::MaterialShaderParameterNameIndex{ m_transmissionTintThickness, context.GetNameContext() };
+            SetFunctorShaderParameter(functor, GetMaterialShaderParameters(context.GetNameContext()));
 
 
             return Success(RPI::Ptr<MaterialFunctor>(functor));
             return Success(RPI::Ptr<MaterialFunctor>(functor));
         }
         }

+ 29 - 6
Gems/Atom/Feature/Common/Code/Source/Material/Transform2DFunctor.cpp

@@ -55,15 +55,38 @@ namespace AZ
 
 
             Matrix3x3 transform = CreateUvTransformMatrix(desc, m_transformOrder);
             Matrix3x3 transform = CreateUvTransformMatrix(desc, m_transformOrder);
 
 
-            context.GetShaderResourceGroup()->SetConstant(m_transformMatrix, transform);
-
-            // There are some cases where the matrix is required but the inverse is not, so the SRG only has the regular matrix.
-            // In that case, the.materialtype file will not provide the name of an inverse matrix because it doesn't have one.
-            if (m_transformMatrixInverse.IsValid())
+            context.GetMaterialShaderParameter()->SetParameter(m_transformMatrix, transform);
+            if (m_transformMatrixInverse.GetIndex().IsValid())
             {
             {
-                context.GetShaderResourceGroup()->SetConstant(m_transformMatrixInverse, transform.GetInverseFull());
+                context.GetMaterialShaderParameter()->SetParameter(m_transformMatrixInverse, transform.GetInverseFull());
             }
             }
         }
         }
 
 
+        bool Transform2DFunctor::UpdateShaderParameterConnections(const RPI::MaterialShaderParameterLayout* layout)
+        {
+            bool valid = true;
+            if (m_transformMatrix.ValidateOrFindIndex(layout) == false)
+            {
+                AZ_Error(
+                    "Transform2DFunctorSourceData", false, "Could not find shader parameter '%s'", m_transformMatrix.GetName().GetCStr());
+                valid &= false;
+            }
+
+            // There are some cases where the matrix is required but the inverse is not, and the shader parameters only have the regular
+            // matrix.
+            if (!m_transformMatrixInverse.GetName().IsEmpty())
+            {
+                if (m_transformMatrixInverse.ValidateOrFindIndex(layout) == false)
+                {
+                    AZ_Error(
+                        "Transform2DFunctorSourceData",
+                        false,
+                        "Could not find shader parameter '%s'",
+                        m_transformMatrixInverse.GetName().GetCStr());
+                    valid &= false;
+                }
+            }
+            return valid;
+        }
     } // namespace Render
     } // namespace Render
 } // namespace AZ
 } // namespace AZ

+ 3 - 3
Gems/Atom/Feature/Common/Code/Source/Material/Transform2DFunctor.h

@@ -30,9 +30,9 @@ namespace AZ
 
 
             using RPI::MaterialFunctor::Process;
             using RPI::MaterialFunctor::Process;
             void Process(RPI::MaterialFunctorAPI::RuntimeContext& context) override;
             void Process(RPI::MaterialFunctorAPI::RuntimeContext& context) override;
+            bool UpdateShaderParameterConnections(const RPI::MaterialShaderParameterLayout* layout) override;
 
 
         private:
         private:
-
             AZStd::vector<TransformType> m_transformOrder; //!< Controls the order in which Scale, Translate, Rotate are performed
             AZStd::vector<TransformType> m_transformOrder; //!< Controls the order in which Scale, Translate, Rotate are performed
 
 
             // Material property inputs...
             // Material property inputs...
@@ -45,8 +45,8 @@ namespace AZ
             RPI::MaterialPropertyIndex m_rotateDegrees; //!< index of material property for rotating
             RPI::MaterialPropertyIndex m_rotateDegrees; //!< index of material property for rotating
 
 
             // Shader setting output...
             // Shader setting output...
-            RHI::ShaderInputConstantIndex m_transformMatrix;        //!< the index of a float3x3 shader input
-            RHI::ShaderInputConstantIndex m_transformMatrixInverse; //!< the index of the inverse float3x3 shader input
+            RPI::MaterialShaderParameterNameIndex m_transformMatrix; //!< the index of a float3x3 shader input
+            RPI::MaterialShaderParameterNameIndex m_transformMatrixInverse; //!< the index of the inverse float3x3 shader input
         };
         };
 
 
     } // namespace Render
     } // namespace Render

+ 8 - 24
Gems/Atom/Feature/Common/Code/Source/Material/Transform2DFunctorSourceData.cpp

@@ -19,8 +19,8 @@ namespace AZ
         {
         {
             if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
             if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
             {
             {
-                serializeContext->Class<Transform2DFunctorSourceData>()
-                    ->Version(3)
+                serializeContext->Class<Transform2DFunctorSourceData, RPI::MaterialFunctorSourceData>()
+                    ->Version(4) // added base class
                     ->Field("transformOrder", &Transform2DFunctorSourceData::m_transformOrder)
                     ->Field("transformOrder", &Transform2DFunctorSourceData::m_transformOrder)
                     ->Field("centerProperty", &Transform2DFunctorSourceData::m_center)
                     ->Field("centerProperty", &Transform2DFunctorSourceData::m_center)
                     ->Field("scaleProperty", &Transform2DFunctorSourceData::m_scale)
                     ->Field("scaleProperty", &Transform2DFunctorSourceData::m_scale)
@@ -30,8 +30,7 @@ namespace AZ
                     ->Field("translateYProperty", &Transform2DFunctorSourceData::m_translateY)
                     ->Field("translateYProperty", &Transform2DFunctorSourceData::m_translateY)
                     ->Field("rotateDegreesProperty", &Transform2DFunctorSourceData::m_rotateDegrees)
                     ->Field("rotateDegreesProperty", &Transform2DFunctorSourceData::m_rotateDegrees)
                     ->Field("float3x3ShaderInput", &Transform2DFunctorSourceData::m_transformMatrix)
                     ->Field("float3x3ShaderInput", &Transform2DFunctorSourceData::m_transformMatrix)
-                    ->Field("float3x3InverseShaderInput", &Transform2DFunctorSourceData::m_transformMatrixInverse)
-                    ;
+                    ->Field("float3x3InverseShaderInput", &Transform2DFunctorSourceData::m_transformMatrixInverse);
             }
             }
         }
         }
 
 
@@ -63,28 +62,11 @@ namespace AZ
             AddMaterialPropertyDependency(functor, functor->m_translateY);
             AddMaterialPropertyDependency(functor, functor->m_translateY);
             AddMaterialPropertyDependency(functor, functor->m_rotateDegrees);
             AddMaterialPropertyDependency(functor, functor->m_rotateDegrees);
 
 
-            functor->m_transformMatrix = context.FindShaderInputConstantIndex(Name{m_transformMatrix});
-            
-            if (functor->m_transformMatrix.IsNull())
+            functor->m_transformMatrix = MaterialShaderParameterNameIndex{ m_transformMatrix, context.GetNameContext() };
+            if (m_transformMatrixInverse.empty() == false)
             {
             {
-                AZ_Error("MaterialFunctorSourceData", false, "Could not find shader input '%s'", context.GetNameContext()->GetContextualizedProperty(m_transformMatrix).c_str());
-                return Failure();
+                functor->m_transformMatrixInverse = MaterialShaderParameterNameIndex{ m_transformMatrixInverse, context.GetNameContext() };
             }
             }
-
-            // There are some cases where the matrix is required but the inverse is not, so the SRG only has the regular matrix.
-            // In that case, the.materialtype file will not provide the name of an inverse matrix because it doesn't have one.
-            if (!m_transformMatrixInverse.empty())
-            {
-                functor->m_transformMatrixInverse = context.FindShaderInputConstantIndex(Name{m_transformMatrixInverse});
-
-                if (functor->m_transformMatrixInverse.IsNull())
-                {
-                    // There are cases where the same functor definition is used for multiple shaders where some have an inverse matrix and some do not.
-                    // So this is just a warning, not an error, to allow re-use of that functor definition.
-                    AZ_Warning("MaterialFunctorSourceData", false, "Could not find shader input '%s'", context.GetNameContext()->GetContextualizedProperty(m_transformMatrixInverse).c_str());
-                }
-            }
-
             functor->m_transformOrder = m_transformOrder;
             functor->m_transformOrder = m_transformOrder;
 
 
             AZStd::set<TransformType> transformSet{m_transformOrder.begin(), m_transformOrder.end()};
             AZStd::set<TransformType> transformSet{m_transformOrder.begin(), m_transformOrder.end()};
@@ -98,6 +80,8 @@ namespace AZ
                 AZ_Warning("Transform2DFunctor", false, "transformOrder contains invalid entries");
                 AZ_Warning("Transform2DFunctor", false, "transformOrder contains invalid entries");
             }
             }
 
 
+            SetFunctorShaderParameter(functor, GetMaterialShaderParameters(context.GetNameContext()));
+
             return Success(RPI::Ptr<MaterialFunctor>(functor));
             return Success(RPI::Ptr<MaterialFunctor>(functor));
         }
         }
     }
     }

+ 7 - 4
Gems/Atom/Feature/Common/Code/Source/Material/UseTextureFunctorSourceData.cpp

@@ -19,13 +19,12 @@ namespace AZ
         {
         {
             if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
             if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
             {
             {
-                serializeContext->Class<UseTextureFunctorSourceData>()
-                    ->Version(6)
+                serializeContext->Class<UseTextureFunctorSourceData, RPI::MaterialFunctorSourceData>()
+                    ->Version(7) // added base class
                     ->Field("textureProperty", &UseTextureFunctorSourceData::m_texturePropertyName)
                     ->Field("textureProperty", &UseTextureFunctorSourceData::m_texturePropertyName)
                     ->Field("useTextureProperty", &UseTextureFunctorSourceData::m_useTexturePropertyName)
                     ->Field("useTextureProperty", &UseTextureFunctorSourceData::m_useTexturePropertyName)
                     ->Field("dependentProperties", &UseTextureFunctorSourceData::m_dependentProperties)
                     ->Field("dependentProperties", &UseTextureFunctorSourceData::m_dependentProperties)
-                    ->Field("shaderOption", &UseTextureFunctorSourceData::m_useTextureOptionName)
-                    ;
+                    ->Field("shaderOption", &UseTextureFunctorSourceData::m_useTextureOptionName);
             }
             }
         }
         }
 
 
@@ -69,6 +68,8 @@ namespace AZ
             functor->m_useTextureOptionName = m_useTextureOptionName;
             functor->m_useTextureOptionName = m_useTextureOptionName;
             context.GetNameContext()->ContextualizeShaderOption(functor->m_useTextureOptionName);
             context.GetNameContext()->ContextualizeShaderOption(functor->m_useTextureOptionName);
 
 
+            SetFunctorShaderParameter(functor, GetMaterialShaderParameters(context.GetNameContext()));
+
             return Success(Ptr<MaterialFunctor>(functor));
             return Success(Ptr<MaterialFunctor>(functor));
         }
         }
 
 
@@ -102,6 +103,8 @@ namespace AZ
             }
             }
             AddMaterialPropertyDependency(functor, functor->m_useTexturePropertyIndex);
             AddMaterialPropertyDependency(functor, functor->m_useTexturePropertyIndex);
 
 
+            SetFunctorShaderParameter(functor, GetMaterialShaderParameters(context.GetNameContext()));
+
             return Success(Ptr<MaterialFunctor>(functor));
             return Success(Ptr<MaterialFunctor>(functor));
         }
         }
 
 

+ 25 - 5
Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp

@@ -2110,12 +2110,19 @@ namespace AZ
 
 
                 Data::Instance<RPI::ShaderResourceGroup> meshObjectSrg;
                 Data::Instance<RPI::ShaderResourceGroup> meshObjectSrg;
 
 
-                // See if the object SRG for this mesh is already in our list of object SRGs
-                for (auto& objectSrgIter : m_objectSrgList)
-                {
-                    if (objectSrgIter->GetLayout()->GetHash() == objectSrgLayout->GetHash())
+                // Note: If the material uses the SceneMaterialSrg, the ObjectSRG holds the
+                // materialType and Instance-ID, and needs to be unique for each submesh.
+                // TODO: We can avoid a separate ObjectSRG for each submesh if we move the data from the SceneMaterialSrg to the SceneSrg,
+                // and create a MaterialSrg again that only holds the materialType and Instance-ID
+                if (!material->UsesSceneMaterialSrg())
+                {
+                    // See if the object SRG for this mesh is already in our list of object SRGs
+                    for (auto& objectSrgIter : m_objectSrgList)
                     {
                     {
-                        meshObjectSrg = objectSrgIter;
+                        if (objectSrgIter->GetLayout()->GetHash() == objectSrgLayout->GetHash())
+                        {
+                            meshObjectSrg = objectSrgIter;
+                        }
                     }
                     }
                 }
                 }
 
 
@@ -2129,6 +2136,19 @@ namespace AZ
                         AZ_Warning("MeshFeatureProcessor", false, "Failed to create a new shader resource group, skipping.");
                         AZ_Warning("MeshFeatureProcessor", false, "Failed to create a new shader resource group, skipping.");
                         continue;
                         continue;
                     }
                     }
+                    // Set the material-Id and materialInstance-Id
+                    if (material->UsesSceneMaterialSrg())
+                    {
+                        {
+                            RHI::ShaderInputNameIndex nameIndex(AZ_NAME_LITERAL("m_materialTypeId"));
+                            meshObjectSrg->SetConstant(nameIndex, material->GetMaterialTypeId());
+                        }
+                        {
+                            RHI::ShaderInputNameIndex nameIndex(AZ_NAME_LITERAL("m_materialInstanceId"));
+                            meshObjectSrg->SetConstant(nameIndex, material->GetMaterialInstanceId());
+                        }
+                    }
+
                     m_objectSrgCreatedEvent.Signal(meshObjectSrg);
                     m_objectSrgCreatedEvent.Signal(meshObjectSrg);
                     m_objectSrgList.push_back(meshObjectSrg);
                     m_objectSrgList.push_back(meshObjectSrg);
                 }
                 }

+ 37 - 0
Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/SamplerState.h

@@ -95,6 +95,30 @@ namespace AZ::RHI
         float m_mipLodMax = static_cast<float>(Limits::Image::MipCountMax);
         float m_mipLodMax = static_cast<float>(Limits::Image::MipCountMax);
         float m_mipLodBias = 0.0f;
         float m_mipLodBias = 0.0f;
         BorderColor m_borderColor = BorderColor::TransparentBlack;
         BorderColor m_borderColor = BorderColor::TransparentBlack;
+
+        bool operator==(const SamplerState& other) const;
+        bool operator!=(const SamplerState& other) const;
+
+    private:
+        // used for the comparison operators
+        auto tie() const
+        {
+            return AZStd::tie(
+                m_anisotropyMax,
+                m_anisotropyEnable,
+                m_filterMin,
+                m_filterMag,
+                m_filterMip,
+                m_reductionType,
+                m_comparisonFunc,
+                m_addressU,
+                m_addressV,
+                m_addressW,
+                m_mipLodMin,
+                m_mipLodMax,
+                m_mipLodBias,
+                m_borderColor);
+        }
     };
     };
 
 
     AZ_TYPE_INFO_SPECIALIZE(FilterMode, "{CFAE2156-0293-4D71-87D5-68F5C9F98884}");
     AZ_TYPE_INFO_SPECIALIZE(FilterMode, "{CFAE2156-0293-4D71-87D5-68F5C9F98884}");
@@ -104,3 +128,16 @@ namespace AZ::RHI
     AZ_TYPE_INFO_SPECIALIZE(BorderColor, "{8A6739E8-538D-47FC-9068-45BCA5B7E5C4}");
     AZ_TYPE_INFO_SPECIALIZE(BorderColor, "{8A6739E8-538D-47FC-9068-45BCA5B7E5C4}");
 }
 }
 
 
+namespace AZStd
+{
+    // hash specialization
+    template<>
+    struct hash<AZ::RHI::SamplerState>
+    {
+        size_t operator()(const AZ::RHI::SamplerState& sampler) const
+        {
+            return static_cast<size_t>(sampler.GetHash());
+        }
+    };
+
+} // namespace AZStd

+ 2 - 0
Gems/Atom/RHI/Code/Include/Atom/RHI/ImageView.h

@@ -46,6 +46,8 @@ namespace AZ::RHI
             return m_descriptor;
             return m_descriptor;
         }
         }
 
 
+        AZStd::unordered_map<int, uint32_t> GetBindlessReadIndex() const;
+
         const DeviceResourceView* GetDeviceResourceView(int deviceIndex) const override
         const DeviceResourceView* GetDeviceResourceView(int deviceIndex) const override
         {
         {
             return GetDeviceImageView(deviceIndex).get();
             return GetDeviceImageView(deviceIndex).get();

+ 9 - 0
Gems/Atom/RHI/Code/Source/RHI.Reflect/SamplerState.cpp

@@ -44,6 +44,15 @@ namespace AZ::RHI
         }
         }
     }
     }
 
 
+    bool SamplerState::operator==(const SamplerState& other) const
+    {
+        return tie() == other.tie();
+    }
+    bool SamplerState::operator!=(const SamplerState& other) const
+    {
+        return tie() != other.tie();
+    }
+
     void SamplerState::Reflect(AZ::ReflectContext* context)
     void SamplerState::Reflect(AZ::ReflectContext* context)
     {
     {
         if (auto serializeContext = azrtti_cast<SerializeContext*>(context))
         if (auto serializeContext = azrtti_cast<SerializeContext*>(context))

+ 6 - 0
Gems/Atom/RHI/Code/Source/RHI/DeviceShaderResourceGroupData.cpp

@@ -33,6 +33,12 @@ namespace AZ::RHI
     {
     {
         m_imageViews.resize(layout->GetGroupSizeForImages());
         m_imageViews.resize(layout->GetGroupSizeForImages());
         m_bufferViews.resize(layout->GetGroupSizeForBuffers());
         m_bufferViews.resize(layout->GetGroupSizeForBuffers());
+        auto groupSizeForSamplers = layout->GetGroupSizeForSamplers();
+        if (groupSizeForSamplers == AZStd::numeric_limits<uint32_t>::max())
+        {
+            AZ_Assert(false, "SRG %s: Unbound arrays for samplers are not supported", m_shaderResourceGroupLayout->GetUniqueId().c_str());
+            groupSizeForSamplers = 0;
+        }
         m_samplers.resize(layout->GetGroupSizeForSamplers());
         m_samplers.resize(layout->GetGroupSizeForSamplers());
     }
     }
 
 

+ 17 - 1
Gems/Atom/RHI/Code/Source/RHI/ImageView.cpp

@@ -9,11 +9,27 @@
  #include <Atom/RHI/ImageView.h>
  #include <Atom/RHI/ImageView.h>
  #include <Atom/RHI/Image.h>
  #include <Atom/RHI/Image.h>
 
 
- namespace AZ::RHI
+namespace AZ::RHI
 {
 {
         //! Given a device index, return the corresponding DeviceBufferView for the selected device
         //! Given a device index, return the corresponding DeviceBufferView for the selected device
         const RHI::Ptr<RHI::DeviceImageView> ImageView::GetDeviceImageView(int deviceIndex) const
         const RHI::Ptr<RHI::DeviceImageView> ImageView::GetDeviceImageView(int deviceIndex) const
         {
         {
             return ResourceView::GetDeviceResourceView<DeviceImageView>(deviceIndex, m_descriptor);
             return ResourceView::GetDeviceResourceView<DeviceImageView>(deviceIndex, m_descriptor);
         }
         }
+
+        
+        AZStd::unordered_map<int, uint32_t> ImageView::GetBindlessReadIndex() const
+        {
+            AZStd::unordered_map<int, uint32_t> result;
+
+            MultiDeviceObject::IterateDevices(
+                GetResource()->GetDeviceMask(),
+                [this, &result](int deviceIndex)
+                {
+                    result[deviceIndex] = GetDeviceImageView(deviceIndex)->GetBindlessReadIndex();
+                    return true;
+                });
+
+            return result;
+        }
 }
 }

+ 15 - 0
Gems/Atom/RHI/Null/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp

@@ -21,6 +21,9 @@ namespace AZ
 
 
         static const char* WindowsAzslShaderHeader = "Builders/ShaderHeaders/Platform/Windows/Null/AzslcHeader.azsli";
         static const char* WindowsAzslShaderHeader = "Builders/ShaderHeaders/Platform/Windows/Null/AzslcHeader.azsli";
         static const char* MacAzslShaderHeader = "Builders/ShaderHeaders/Platform/Mac/Null/AzslcHeader.azsli";
         static const char* MacAzslShaderHeader = "Builders/ShaderHeaders/Platform/Mac/Null/AzslcHeader.azsli";
+        static const char* iOSsAzslShaderHeader = "Builders/ShaderHeaders/Platform/iOS/Null/AzslcHeader.azsli";
+        static const char* LinuxAzslShaderHeader = "Builders/ShaderHeaders/Platform/Linux/Null/AzslcHeader.azsli";
+        static const char* AndroidAzslShaderHeader = "Builders/ShaderHeaders/Platform/Android/Null/AzslcHeader.azsli";
 
 
         ShaderPlatformInterface::ShaderPlatformInterface(uint32_t apiUniqueIndex)
         ShaderPlatformInterface::ShaderPlatformInterface(uint32_t apiUniqueIndex)
             : RHI::ShaderPlatformInterface(apiUniqueIndex)
             : RHI::ShaderPlatformInterface(apiUniqueIndex)
@@ -90,6 +93,18 @@ namespace AZ
             {
             {
                 return MacAzslShaderHeader;
                 return MacAzslShaderHeader;
             }
             }
+            else if (platform.m_identifier == "ios")
+            {
+                return iOSsAzslShaderHeader;
+            }
+            else if (platform.m_identifier == "linux")
+            {
+                return LinuxAzslShaderHeader;
+            }
+            else if (platform.m_identifier == "android")
+            {
+                return AndroidAzslShaderHeader;
+            }
             else
             else
             {
             {
                 return WindowsAzslShaderHeader;
                 return WindowsAzslShaderHeader;

+ 47 - 0
Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/Platform/Android/AzslcPlatformHeader.azsli

@@ -0,0 +1,47 @@
+/*
+ * 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
+ *
+ */
+
+/*
+* The shader build pipeline has 2 preprocess stages. The first one happens 
+* after appending the Platform and RHI specific AzslcHeader.azsli, which includes this header.
+* This file contains defines specific to a platform (e.g. Android) but shared among all RHI implementations on that platform (e.g. Vulkan + Null).
+*/
+
+//Assuming unbounded array suport for Android
+#define UNBOUNDED_SIZE
+
+// Allow multiple textures samplers in MaterialSrgs
+#define AZ_TRAITS_MATERIALS_USE_SAMPLER_ARRAY
+// use the SingleMaterialSrg for each material
+#define AZ_TRAIT_FORCE_SINGLE_MATERIAL_SRG
+// disable using the bindless SRG for material textures in the SingleMaterialSrg
+#define AZ_TRAIT_SINGLE_MATERIAL_USE_TEXTURE_ARRAY
+
+#define USE_HALF_FLOATS_FOR_ANDROID 1
+#if USE_HALF_FLOATS_FOR_ANDROID
+
+// use half float for android
+#define real half
+#define real2 half2
+#define real3 half3
+#define real4 half4
+#define real3x3 half3x3
+#define real3x4 half3x4
+#define real4x4 half4x4
+
+#else
+
+#define real float
+#define real2 float2
+#define real3 float3
+#define real4 float4
+#define real3x3 float3x3
+#define real3x4 float3x4
+#define real4x4 float4x4
+
+#endif

+ 33 - 0
Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/Platform/Linux/AzslcPlatformHeader.azsli

@@ -0,0 +1,33 @@
+/*
+ * 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
+ *
+ */
+
+/*
+* The shader build pipeline has 2 preprocess stages. The first one happens 
+* after appending the Platform and RHI specific AzslcHeader.azsli, which includes this header.
+* This file contains defines specific to a platform (e.g. Linux) but shared among all RHI implementations on that platform (e.g. Vulkan + Null).
+* Note that the AssetProcessor uses the Null-RHI platform to process Materials, so anything that modifies SRGs has to go in this file.
+*/
+
+// Allow multiple textures samplers in MaterialSrgs
+#define AZ_TRAITS_MATERIALS_USE_SAMPLER_ARRAY
+// use the SceneMaterialSrg where possible 
+// #define AZ_TRAIT_FORCE_SINGLE_MATERIAL_SRG
+// disable using the bindless SRG for material textures in the SingleMaterialSrg
+// #define AZ_TRAIT_SINGLE_MATERIAL_USE_TEXTURE_ARRAY
+
+//Linux supports unbounded array
+#define UNBOUNDED_SIZE
+
+// Full floats for null rhi
+#define real float
+#define real2 float2
+#define real3 float3
+#define real4 float4
+#define real3x3 float3x3
+#define real3x4 float3x4
+#define real4x4 half4x4

+ 33 - 0
Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/Platform/Mac/AzslcPlatformHeader.azsli

@@ -0,0 +1,33 @@
+/*
+ * 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
+ *
+ */
+
+/*
+* The shader build pipeline has 2 preprocess stages. The first one happens 
+* after appending the Platform and RHI specific AzslcHeader.azsli, which includes this header.
+* This file contains defines specific to a platform (e.g. Mac) but shared among all RHI implementations on that platform (e.g. Metal + Null).
+* Note that the AssetProcessor uses the Null-RHI platform to process Materials, so anything that modifies SRGs has to go in this file.
+*/
+
+//size for unbounded arrays
+#define UNBOUNDED_SIZE 100000
+
+// Allow multiple textures samplers in MaterialSrgs
+#define AZ_TRAITS_MATERIALS_USE_SAMPLER_ARRAY
+// use the SingleMaterialSrg for each material
+#define AZ_TRAIT_FORCE_SINGLE_MATERIAL_SRG
+// disable using the bindless SRG for material textures in the SingleMaterialSrg
+#define AZ_TRAIT_SINGLE_MATERIAL_USE_TEXTURE_ARRAY
+
+// Full floats for Mac
+#define real float
+#define real2 float2
+#define real3 float3
+#define real4 float4
+#define real3x3 float3x3
+#define real3x4 float3x4
+#define real4x4 float4x4

+ 34 - 0
Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/Platform/Windows/AzslcPlatformHeader.azsli

@@ -0,0 +1,34 @@
+/*
+ * 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
+ *
+ */
+
+/*
+* The shader build pipeline has 2 preprocess stages. The first one happens 
+* after appending the Platform and RHI specific AzslcHeader.azsli, which includes this header.
+* This file contains defines specific to a platform (e.g. Windows) but shared among all RHI implementations on that platform (e.g. Vulkan, DX12, Null).
+* Note that the AssetProcessor uses the Null-RHI platform to process Materials, so anything that modifies SRGs has to go in this file.
+*/
+
+//PC supports unbounded array
+#define UNBOUNDED_SIZE 
+
+// Allow multiple textures samplers in MaterialSrgs
+#define AZ_TRAITS_MATERIALS_USE_SAMPLER_ARRAY
+// use the SceneMaterialSrg where possible 
+// #define AZ_TRAIT_FORCE_SINGLE_MATERIAL_SRG
+// enable the bindless SRG for material textures in the SingleMaterialSrg
+// #define AZ_TRAIT_SINGLE_MATERIAL_USE_TEXTURE_ARRAY
+
+
+// Full floats for windows DX12 PC
+#define real float
+#define real2 float2
+#define real3 float3
+#define real4 float4
+#define real3x3 float3x3
+#define real3x4 float3x4
+#define real4x4 float4x4

+ 33 - 0
Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/Platform/iOS/AzslcPlatformHeader.azsli

@@ -0,0 +1,33 @@
+/*
+ * 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
+ *
+ */
+
+/*
+* The shader build pipeline has 2 preprocess stages. The first one happens 
+* after appending the Platform and RHI specific AzslcHeader.azsli, which includes this header.
+* This file contains defines specific to a platform (e.g. iOS) but shared among all RHI implementations on that platform (e.g. Metal + Null).
+* Note that the AssetProcessor uses the Null-RHI platform to process Materials, so anything that modifies SRGs has to go in this file.
+*/
+
+//size for unbounded arrays
+#define UNBOUNDED_SIZE 100000
+
+// Allow multiple textures samplers in MaterialSrgs
+#define AZ_TRAITS_MATERIALS_USE_SAMPLER_ARRAY
+// use the SingleMaterialSrg for each material
+#define AZ_TRAIT_FORCE_SINGLE_MATERIAL_SRG
+// disable using the bindless SRG for material textures in the SingleMaterialSrg
+#define AZ_TRAIT_SINGLE_MATERIAL_USE_TEXTURE_ARRAY
+
+// use half float for ios
+#define real half
+#define real2 half2
+#define real3 half3
+#define real4 half4
+#define real3x3 half3x3
+#define real3x4 half3x4
+#define real4x4 half4x4

+ 1 - 0
Gems/Atom/RPI/Assets/ShaderLib/Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli

@@ -29,6 +29,7 @@ ShaderResourceGroup DrawSrg : SRG_PerDraw
     // This SRG is unique per draw packet
     // This SRG is unique per draw packet
     uint m_uvStreamTangentBitmask;
     uint m_uvStreamTangentBitmask;
 
 
+
 #if USE_DRAWSRG_MESHLOD_MESHINDEX
 #if USE_DRAWSRG_MESHLOD_MESHINDEX
     // See MeshDrawPacket.h
     // See MeshDrawPacket.h
     uint m_modelLodMeshIndex;
     uint m_modelLodMeshIndex;

+ 2 - 0
Gems/Atom/RPI/Code/CMakeLists.txt

@@ -59,6 +59,7 @@ ly_add_target(
     INCLUDE_DIRECTORIES
     INCLUDE_DIRECTORIES
         PRIVATE
         PRIVATE
             Source
             Source
+            ${pal_source_dir}
         PUBLIC
         PUBLIC
             Include
             Include
     BUILD_DEPENDENCIES
     BUILD_DEPENDENCIES
@@ -204,6 +205,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS)
                 Gem::${gem_name}.Public
                 Gem::${gem_name}.Public
                 Gem::${gem_name}.TestUtils
                 Gem::${gem_name}.TestUtils
     )
     )
+
     ly_add_googletest(
     ly_add_googletest(
         NAME Gem::${gem_name}.Tests
         NAME Gem::${gem_name}.Tests
         LABELS REQUIRES_tiaf
         LABELS REQUIRES_tiaf

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio