Browse Source

Merge pull request #553 from aws-lumberyard-dev/Atom/santorac/MaterialPipelineReorg

Atom/santorac/material pipeline reorg
santorac 2 years ago
parent
commit
20ce7365dc
19 changed files with 96 additions and 153 deletions
  1. 8 6
      Materials/MaterialPipelineTest/MaterialPipelineTest_Basic.material
  2. 6 0
      Materials/MaterialPipelineTest/MaterialPipelineTest_Empty.material
  3. 13 0
      Materials/MaterialPipelineTest/MaterialPipelineTest_Enhanced.material
  4. 20 7
      Materials/MaterialPipelineTest/MaterialPipelineTest_Standard.material
  5. 18 66
      Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass.azsli
  6. 2 2
      Materials/Pipelines/PrototypeDeferredPipeline/DeferredPipeline.materialpipeline
  7. 2 2
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_basic_deferredpipeline.png
  8. 2 2
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_basic_lowendpipeline.png
  9. 2 2
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_basic_mainpipeline.png
  10. 2 2
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_deferredpipeline.png
  11. 2 2
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_lowendpipeline.png
  12. 2 2
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_mainpipeline.png
  13. 2 2
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_deferredpipeline.png
  14. 2 2
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_lowendpipeline.png
  15. 2 2
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_mainpipeline.png
  16. 9 9
      Scripts/MaterialScreenshotTests.bv.lua
  17. 0 43
      ShaderVariants/Shaders/Materials/BasePBR/BasePBR_ForwardPass.shadervariantlist
  18. 1 1
      Shaders/ComprehensiveTestMaterial/Stacks.azsl
  19. 1 1
      Shaders/DebugVertexNormals.azsl

+ 8 - 6
Materials/MaterialPipelineTest/MaterialPipelineTest_Basic.material

@@ -2,11 +2,13 @@
     "materialType": "@projectroot@/Cache/Intermediate Assets/testdata/materials/types/materialpipelinetest_basic_generated.materialtype",
     "materialTypeVersion": 3,
     "propertyValues": {
-        "settings.color": [
-            1.0,
-            0.20444037020206451,
-            0.20444037020206451,
-            1.0
-        ]
+        "baseColor.textureMap": "@gemroot:Atom_Feature_Common@/Assets/Textures/Default/default_basecolor.tif",
+        "metallic.textureMap": "@gemroot:Atom@/TestData/TestData/Textures/checker8x8_512.png",
+        "normal.textureMap": "@gemroot:Atom_Feature_Common@/Assets/Textures/Default/default_normal.tif",
+        "roughness.lowerBound": 0.10999999940395355,
+        "roughness.textureMap": "@gemroot:Atom@/TestData/TestData/Textures/checker8x8_gray_512.png",
+        "roughness.upperBound": 0.8899999856948853,
+        "specularF0.factor": 0.4399999976158142,
+        "uv.rotateDegrees": 45.0
     }
 }

+ 6 - 0
Materials/MaterialPipelineTest/MaterialPipelineTest_Empty.material

@@ -0,0 +1,6 @@
+{
+    "materialType": "@projectroot@/Cache/Intermediate Assets/testdata/materials/types/materialpipelinetest_empty_generated.materialtype",
+    "materialTypeVersion": 3,
+    "propertyValues": {
+    }
+}

+ 13 - 0
Materials/MaterialPipelineTest/MaterialPipelineTest_Enhanced.material

@@ -2,6 +2,19 @@
     "materialType": "@projectroot@/Cache/Intermediate Assets/testdata/materials/types/materialpipelinetest_enhanced_generated.materialtype",
     "materialTypeVersion": 3,
     "propertyValues": {
+        "anisotropy.anisotropyAngle": 0.6399999856948853,
+        "anisotropy.enableAnisotropy": true,
+        "anisotropy.factor": 0.949999988079071,
+        "baseColor.factor": 0.7599999904632568,
+        "baseColor.textureBlendMode": "Lerp",
+        "baseColor.textureMap": "@gemroot:Atom@/TestData/TestData/Textures/cc0/Concrete019_1K_Color.jpg",
+        "detailLayerGroup.baseColorDetailMap": "@gemroot:Atom@/TestData/TestData/Textures/cc0/Concrete019_1K_Color.jpg",
+        "detailLayerGroup.detailUV.offsetV": 0.9200000166893005,
+        "detailLayerGroup.detailUV.scale": 2.0,
+        "detailLayerGroup.enableBaseColor": true,
+        "detailLayerGroup.enableDetailLayer": true,
+        "detailLayerGroup.enableNormals": true,
+        "detailLayerGroup.normalDetailMap": "@gemroot:Atom@/TestData/TestData/Textures/cc0/Concrete019_1K_Normal.jpg",
         "subsurfaceScattering.enableSubsurfaceScattering": true
     }
 }

+ 20 - 7
Materials/MaterialPipelineTest/MaterialPipelineTest_Standard.material

@@ -2,14 +2,27 @@
     "materialType": "@projectroot@/Cache/Intermediate Assets/testdata/materials/types/materialpipelinetest_standard_generated.materialtype",
     "materialTypeVersion": 3,
     "propertyValues": {
-        "base.color": [
-            0.16862745583057404,
-            0.6078431606292725,
-            0.4431372582912445,
+        "baseColor.textureMap": "@engroot@/Gems/AtomContent/Sponza/Assets/Textures/bricks_1k_basecolor.png",
+        "clearCoat.enable": true,
+        "clearCoat.influenceMap": "@gemroot:Atom@/TestData/TestData/Textures/checker8x8_512.png",
+        "clearCoat.roughness": 0.10999999940395355,
+        "emissive.color": [
+            1.0,
+            0.01925688609480858,
+            0.01925688609480858,
             1.0
         ],
-        "base.roughness": 0.5,
-        "clearCoat.enable": true,
-        "clearCoat.roughness": 0.18000000715255737
+        "emissive.enable": true,
+        "emissive.intensity": 1.2599999904632568,
+        "emissive.textureMap": "@gemroot:Atom@/TestData/TestData/Textures/checker8x8_gray_512.png",
+        "normal.textureMap": "@engroot@/Gems/AtomContent/Sponza/Assets/Textures/bricks_1k_normal.jpg",
+        "occlusion.diffuseTextureMap": "@engroot@/Gems/AtomContent/Sponza/Assets/Textures/bricks_1k_ao.png",
+        "occlusion.specularTextureMap": "@engroot@/Gems/AtomContent/Sponza/Assets/Textures/bricks_1k_ao.png",
+        "parallax.factor": 0.10000000149011612,
+        "parallax.offset": 0.05000000074505806,
+        "parallax.textureMap": "@engroot@/Gems/AtomContent/Sponza/Assets/Textures/bricks_1k_height.png",
+        "roughness.textureMap": "@engroot@/Gems/AtomContent/Sponza/Assets/Textures/bricks_1k_roughness.png",
+        "roughness.upperBound": 0.5099999904632568,
+        "specularF0.factor": 0.3799999952316284
     }
 }

+ 18 - 66
Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass.azsli

@@ -6,54 +6,28 @@
  *
  */
  
+#define MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE 1
+
 //TODO(DeferredPOC): Support clear coat
 #define ENABLE_CLEAR_COAT 0
 
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include MATERIAL_TYPE_AZSLI_FILE_PATH
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
 #include <viewsrg.srgi>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 #include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/Features/ColorManagement/TransformColor.azsli>
-#include <Atom/Features/PBR/Surfaces/StandardSurface.azsli>
+#include <Atom/Features/PBR/LightingOptions.azsli>
+//#include <Atom/Features/PBR/Surfaces/StandardSurface.azsli>
 
-struct VSInput
+VsOutput MaterialVS(VsInput IN)
 {
-    float3 m_position : POSITION;
-    float3 m_normal : NORMAL;
-    //TODO(DeferredPOC): Support tangent space and normal mapping
-    //float4 m_tangent : TANGENT; 
-};
-
-struct VSOutput
-{
-    precise linear centroid float4 m_position : SV_Position;
-    float3 m_normal: NORMAL;
-    //TODO(DeferredPOC): Support tangent space and normal mapping
-    //float3 m_tangent : TANGENT; 
-    float3 m_worldPosition : UV0;
-};
-
-#define MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE 1
-#include <Atom/RPI/MaterialPipelineCallbacks.azsli>
-
-VSOutput MaterialVS(VSInput IN)
-{
-    VertexData adjustableVertexData;
-    adjustableVertexData.InitializeToZero();
-    adjustableVertexData.positionWS = LocalSpaceToWorldSpace(IN.m_position);
-    adjustableVertexData.normalLS = IN.m_normal;
-    //TODO(DeferredPOC): Support tangent space and normal mapping
-    //adjustableVertexData.tangentLS = IN.m_tangent;
-
-    MaterialFunction_AdjustVertexData(IN.m_position, adjustableVertexData);
-    
-    VSOutput output;
-    output.m_worldPosition = adjustableVertexData.positionWS;
-    output.m_position = mul(ViewSrg::m_viewProjectionMatrix, float4(output.m_worldPosition, 1.0));
-    output.m_normal = adjustableVertexData.normalLS;
-    //TODO(DeferredPOC): Support tangent space and normal mapping
-    //output.m_tangent = adjustableVertexData.tangentLS.xyz;
-
-    return output;
+    VsOutput OUT = EvaluateVertexGeometry(IN);
+    return OUT;
 }
 
 struct DeferredMaterialOutput
@@ -63,36 +37,13 @@ struct DeferredMaterialOutput
     float4 m_normal : SV_Target2;
 };
 
-option bool o_enableIBL = true;
-option bool o_specularF0_enableMultiScatterCompensation = true;
-
-#define MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE 1
-
-DeferredMaterialOutput MaterialPS(VSOutput IN)
+DeferredMaterialOutput MaterialPS(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
 {
-    // ------- Surface -------
-
-    // Note, some of the data being set up in this "Surface" section isn't necessary for the deferred material pass,
-    // we are just doing it for consistency with how the same code is structured in the other material pipelines.
-
-    Surface surface;
-    surface.position = IN.m_worldPosition.xyz;
-    surface.vertexNormal = normalize(IN.m_normal);
+    // ------- Geometry -> Surface -------
 
-    // These are the values we expect MaterialFunction_EvaluateSurface to potentially replace.
-    surface.normal = surface.vertexNormal;
-    surface.roughnessLinear = 0.0;
-    float3 baseColor = float3(0.5, 0.5, 0.5);
-    float metallic = 0.0;
-    float specularF0Factor = 0.5f;
-    surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
+    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
 
-    //TODO(DeferredPOC): Support clear coat
-    //surface.clearCoat.InitializeToZero();
-
-    MaterialFunction_AdjustSurface(surface);
-    
-    surface.CalculateRoughnessA();
+    Surface surface = EvaluateSurface(geoData);
 
     // ------- Output -------
 
@@ -106,3 +57,4 @@ DeferredMaterialOutput MaterialPS(VSOutput IN)
     return OUT;
 }
 
+

+ 2 - 2
Materials/Pipelines/PrototypeDeferredPipeline/DeferredPipeline.materialpipeline

@@ -2,7 +2,7 @@
     "shaderTemplates": [
         {
             "shader": "./DeferredMaterialPass.shader.template",
-            "azsli": "Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass.azsli"
+            "azsli": "./DeferredMaterialPass.azsli"
         },
         {
             "shader": "Materials/Pipelines/Common/DepthPass.shader.template",
@@ -10,7 +10,7 @@
         },
         {
             "shader": "Materials/Pipelines/Common/ShadowmapPass.shader.template",
-            "azsli": "Materials/Pipelines/Common/ShadowmapPass.azsli"
+            "azsli": "Materials/Pipelines/Common/DepthPass.azsli"
         }
     ]
 }

+ 2 - 2
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_basic_deferredpipeline.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:915bdc882d79d33d4ff1edf012d064e7541dd7e59063b1cf2d11e248811ceb82
-size 575563
+oid sha256:973a6ff5ef1a593a3885842535ab8ad967aaf480b1a5bf4965566470b962e00c
+size 925548

+ 2 - 2
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_basic_lowendpipeline.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:d82e952ccbc394551bd701b9000bd09b33a2977864484635275ef0f6917ff8db
-size 453002
+oid sha256:8eaea4ad5b162e1eeb125075bc8cf8a15d679f36055f517b3e05b2ac001cd9c2
+size 890087

+ 2 - 2
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_basic_mainpipeline.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:453b55aee21cb22dc7e3ed736aaf76a6c54019136ccbc13b1f9a0337d5e13945
-size 551823
+oid sha256:3b22f61fb685178ad4406b24326fbd2fa9cd9fe4a490929c44e3e120af92c0b1
+size 919921

+ 2 - 2
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_deferredpipeline.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:9e69662e42a095e135d79ff4fd48a351b1c08a487aaf0689050da409854f34b7
-size 515079
+oid sha256:26272e7af064fc13659969a26d77b077ab58093044d2cb41fe4dabf04c3e03c2
+size 914935

+ 2 - 2
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_lowendpipeline.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:cba2907b29879b79067836b0dc6b82bd0ef3de008bb469040df1d325853ca153
-size 400419
+oid sha256:ed0228ee230c7bc8656d0e013908c912c3eed68337f860eea4a6342877b6dd62
+size 904115

+ 2 - 2
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_mainpipeline.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:c8b200aaab1689d927a03133d24285b7370b8bff1121fd710608f1d824f32473
-size 534522
+oid sha256:9751c238d79aea21f8d4eaac1edd7f64404aacf95d1d761ab5191838b97052db
+size 743132

+ 2 - 2
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_deferredpipeline.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:f7e0bea16cd2d0fd3aa959bd07ae83eb152104167f9ee01a92698df07297ca9a
-size 629216
+oid sha256:7b94000e851cc6ddad06e7a7f3fd01ebb4b4fb0575f620e151ca34732e4b097b
+size 1318822

+ 2 - 2
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_lowendpipeline.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:dd5eb145af4cf59d75606510504daf11fb34a299551b743b0ec8fc53182ce03f
-size 564610
+oid sha256:e74f52f901c6302095b5806e9d1296263a3aa794adf351f9ad7ba5cb0d8f855a
+size 1321213

+ 2 - 2
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_mainpipeline.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:fe6a0353a902e470939ac9b3997d4a022e305a4f2bd052cd03e72c660fcba72d
-size 683466
+oid sha256:9f33ffffcb439006c13900291c53321d7065403a2ce4050c4fb9ef5dfe36abde
+size 1332549

+ 9 - 9
Scripts/MaterialScreenshotTests.bv.lua

@@ -260,18 +260,18 @@ Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder .. g_te
 
 SetImguiValue('Use Low End Pipeline', false)
 SetImguiValue('Use Deferred Pipeline', false)
-GenerateMaterialScreenshot('Level E', 'MaterialPipelineTest_Basic', {screenshotFilename="MaterialPipelineTest_Basic_MainPipeline"})
-GenerateMaterialScreenshot('Level E', 'MaterialPipelineTest_Standard', {screenshotFilename="MaterialPipelineTest_Standard_MainPipeline"})
-GenerateMaterialScreenshot('Level E', 'MaterialPipelineTest_Enhanced', {screenshotFilename="MaterialPipelineTest_Enhanced_MainPipeline", lighting="Test"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Basic', {screenshotFilename="MaterialPipelineTest_Basic_MainPipeline"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard', {screenshotFilename="MaterialPipelineTest_Standard_MainPipeline"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced', {screenshotFilename="MaterialPipelineTest_Enhanced_MainPipeline", lighting="Test"})
 
 SetImguiValue('Use Low End Pipeline', true)
-GenerateMaterialScreenshot('Level E', 'MaterialPipelineTest_Basic', {screenshotFilename="MaterialPipelineTest_Basic_LowEndPipeline"})
-GenerateMaterialScreenshot('Level E', 'MaterialPipelineTest_Standard', {screenshotFilename="MaterialPipelineTest_Standard_LowEndPipeline"})
-GenerateMaterialScreenshot('Level E', 'MaterialPipelineTest_Enhanced', {screenshotFilename="MaterialPipelineTest_Enhanced_LowEndPipeline", lighting="Test"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Basic', {screenshotFilename="MaterialPipelineTest_Basic_LowEndPipeline"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard', {screenshotFilename="MaterialPipelineTest_Standard_LowEndPipeline"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced', {screenshotFilename="MaterialPipelineTest_Enhanced_LowEndPipeline", lighting="Test"})
 SetImguiValue('Use Low End Pipeline', false)
 
 SetImguiValue('Use Deferred Pipeline', true)
-GenerateMaterialScreenshot('Level E', 'MaterialPipelineTest_Basic', {screenshotFilename="MaterialPipelineTest_Basic_DeferredPipeline"})
-GenerateMaterialScreenshot('Level E', 'MaterialPipelineTest_Standard', {screenshotFilename="MaterialPipelineTest_Standard_DeferredPipeline"})
-GenerateMaterialScreenshot('Level E', 'MaterialPipelineTest_Enhanced', {screenshotFilename="MaterialPipelineTest_Enhanced_DeferredPipeline", lighting="Test"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Basic', {screenshotFilename="MaterialPipelineTest_Basic_DeferredPipeline"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard', {screenshotFilename="MaterialPipelineTest_Standard_DeferredPipeline"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced', {screenshotFilename="MaterialPipelineTest_Enhanced_DeferredPipeline", lighting="Test"})
 SetImguiValue('Use Deferred Pipeline', false)

+ 0 - 43
ShaderVariants/Shaders/Materials/BasePBR/BasePBR_ForwardPass.shadervariantlist

@@ -1,43 +0,0 @@
-{
-    "Shader": "Shaders/Materials/BasePBR/BasePBR_ForwardPass.shader",
-    "Variants": [
-        {
-            "StableId": 1,
-            "Options": {
-                "o_applySpecularAA": "true",
-                "o_baseColorTextureBlendMode": "TextureBlendMode::Multiply",
-                "o_baseColor_useTexture": "false",
-                "o_enableAreaLights": "true",
-                "o_enableDirectionalLights": "true",
-                "o_enableIBL": "true",
-                "o_enablePunctualLights": "true",
-                "o_enableShadows": "true",
-                "o_materialUseForwardPassIBLSpecular": "false",
-                "o_metallic_useTexture": "false",
-                "o_normal_useTexture": "false",
-                "o_roughness_useTexture": "false",
-                "o_specularF0_enableMultiScatterCompensation": "true",
-                "o_specularF0_useTexture": "false"
-            }
-        },
-        {
-            "StableId": 2,
-            "Options": {
-                "o_applySpecularAA": "false",
-                "o_baseColorTextureBlendMode": "TextureBlendMode::Multiply",
-                "o_baseColor_useTexture": "false",
-                "o_enableAreaLights": "true",
-                "o_enableDirectionalLights": "true",
-                "o_enableIBL": "true",
-                "o_enablePunctualLights": "true",
-                "o_enableShadows": "true",
-                "o_materialUseForwardPassIBLSpecular": "false",
-                "o_metallic_useTexture": "false",
-                "o_normal_useTexture": "false",
-                "o_roughness_useTexture": "false",
-                "o_specularF0_enableMultiScatterCompensation": "true",
-                "o_specularF0_useTexture": "false"
-            }
-        }
-    ]
-}

+ 1 - 1
Shaders/ComprehensiveTestMaterial/Stacks.azsl

@@ -8,7 +8,7 @@
 
 #include <scenesrg.srgi>
 #include <viewsrg.srgi>
-#include <Atom/RPI/ShaderResourceGroups/DefaultObjectSrg.azsli>
+#include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
 
 // This shader draws a model with most of the surface clipped away, only drawing regularly spaced slices of it.

+ 1 - 1
Shaders/DebugVertexNormals.azsl

@@ -8,7 +8,7 @@
 
 #include <scenesrg.srgi>
 #include <viewsrg.srgi>
-#include <Atom/RPI/ShaderResourceGroups/DefaultObjectSrg.azsli>
+#include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 
 struct VertexInput
 {