Parcourir la source

Merge pull request #562 from aws-lumberyard-dev/Atom/santorac/MaterialPipelineCustomZ

Added tests for alpha cutout and POM pixel depth offset.
santorac il y a 2 ans
Parent
commit
c2ac41fbb1
19 fichiers modifiés avec 190 ajouts et 3 suppressions
  1. 11 0
      Materials/MaterialPipelineTest/MaterialPipelineTest_Enhanced_Cutout.material
  2. 14 0
      Materials/MaterialPipelineTest/MaterialPipelineTest_Enhanced_PDO.material
  3. 11 0
      Materials/MaterialPipelineTest/MaterialPipelineTest_Standard_Cutout.material
  4. 12 0
      Materials/MaterialPipelineTest/MaterialPipelineTest_Standard_PDO.material
  5. 12 1
      Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass.azsli
  6. 8 1
      Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass.shader.template
  7. 52 0
      Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass_CustomZ.shader.template
  8. 25 0
      Materials/Pipelines/PrototypeDeferredPipeline/DeferredPipeline.materialpipeline
  9. 9 1
      Materials/Pipelines/PrototypeDeferredPipeline/DeferredPipelineScript.lua
  10. 3 0
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_cutout_mainpipeline.png
  11. 3 0
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_pdo_deferredpipeline.png
  12. 3 0
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_pdo_lowendpipeline.png
  13. 3 0
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_pdo_mainpipeline.png
  14. 3 0
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_cutout_lowendpipeline.png
  15. 3 0
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_cutout_mainpipeline.png
  16. 3 0
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_pdo_deferredpipeline.png
  17. 3 0
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_pdo_lowendpipeline.png
  18. 3 0
      Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_pdo_mainpipeline.png
  19. 9 0
      Scripts/MaterialScreenshotTests.bv.lua

+ 11 - 0
Materials/MaterialPipelineTest/MaterialPipelineTest_Enhanced_Cutout.material

@@ -0,0 +1,11 @@
+{
+    "materialType": "@projectroot@/Cache/Intermediate Assets/testdata/materials/types/materialpipelinetest_enhanced_generated.materialtype",
+    "materialTypeVersion": 3,
+    "parentMaterial": "MaterialPipelineTest_Enhanced.material",
+    "propertyValues": {
+        "general.doubleSided": true,
+        "opacity.alphaSource": "Split",
+        "opacity.mode": "Cutout",
+        "opacity.textureMap": "@gemroot:Atom@/TestData/TestData/Textures/checker8x8_512.png"
+    }
+}

+ 14 - 0
Materials/MaterialPipelineTest/MaterialPipelineTest_Enhanced_PDO.material

@@ -0,0 +1,14 @@
+{
+    "materialType": "@projectroot@/Cache/Intermediate Assets/testdata/materials/types/materialpipelinetest_enhanced_generated.materialtype",
+    "materialTypeVersion": 3,
+    "parentMaterial": "MaterialPipelineTest_Enhanced.material",
+    "propertyValues": {
+        "parallax.algorithm": "Relief",
+        "parallax.factor": 0.10000000149011612,
+        "parallax.offset": 0.03799999877810478,
+        "parallax.pdo": true,
+        "parallax.quality": "Medium",
+        "parallax.textureMap": "@gemroot:Atom@/TestData/TestData/Textures/cc0/Concrete019_1K_Displacement.jpg",
+        "subsurfaceScattering.enableSubsurfaceScattering": false
+    }
+}

+ 11 - 0
Materials/MaterialPipelineTest/MaterialPipelineTest_Standard_Cutout.material

@@ -0,0 +1,11 @@
+{
+    "materialType": "@projectroot@/Cache/Intermediate Assets/testdata/materials/types/materialpipelinetest_standard_generated.materialtype",
+    "materialTypeVersion": 3,
+    "parentMaterial": "MaterialPipelineTest_Standard.material",
+    "propertyValues": {
+        "general.doubleSided": true,
+        "opacity.alphaSource": "Split",
+        "opacity.mode": "Cutout",
+        "opacity.textureMap": "@gemroot:Atom@/TestData/TestData/Textures/checker8x8_512.png"
+    }
+}

+ 12 - 0
Materials/MaterialPipelineTest/MaterialPipelineTest_Standard_PDO.material

@@ -0,0 +1,12 @@
+{
+    "materialType": "@projectroot@/Cache/Intermediate Assets/testdata/materials/types/materialpipelinetest_standard_generated.materialtype",
+    "materialTypeVersion": 3,
+    "parentMaterial": "MaterialPipelineTest_Standard.material",
+    "propertyValues": {
+        "parallax.algorithm": "Relief",
+        "parallax.factor": 0.30000001192092896,
+        "parallax.offset": 0.14499999582767487,
+        "parallax.pdo": true,
+        "parallax.quality": "Medium"
+    }
+}

+ 12 - 1
Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass.azsli

@@ -22,7 +22,6 @@
 #include <Atom/Features/PBR/DefaultObjectSrg.azsli>
 #include <Atom/Features/ColorManagement/TransformColor.azsli>
 #include <Atom/Features/PBR/LightingOptions.azsli>
-//#include <Atom/Features/PBR/Surfaces/StandardSurface.azsli>
 
 VsOutput MaterialVS(VsInput IN)
 {
@@ -35,8 +34,15 @@ struct DeferredMaterialOutput
     float4 m_baseColor  : SV_Target0;
     float4 m_roughnessMetal : SV_Target1; 
     float4 m_normal : SV_Target2;
+    
+#if OUTPUT_DEPTH
+    float m_depth : SV_Depth;
+#endif
 };
 
+#if !OUTPUT_DEPTH
+    [earlydepthstencil]
+#endif
 DeferredMaterialOutput MaterialPS(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
 {
     // ------- Geometry -> Surface -------
@@ -53,6 +59,11 @@ DeferredMaterialOutput MaterialPS(VsOutput IN, bool isFrontFace : SV_IsFrontFace
     OUT.m_roughnessMetal = float4(surface.roughnessLinear, surface.metallic, 0, 0);
     OUT.m_normal.rgb = EncodeNormalSignedOctahedron(surface.normal);
     OUT.m_normal.a = EncodeUnorm2BitFlags(o_enableIBL, o_specularF0_enableMultiScatterCompensation);
+    
+#if OUTPUT_DEPTH
+    // Can be modified in Parallax calculations in EvaluatePixelGeometry
+    OUT.m_depth = IN.position.z;
+#endif
 
     return OUT;
 }

+ 8 - 1
Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass.shader.template

@@ -1,5 +1,5 @@
 {
-    "Source" : "INSERT_AZSL_PATH_HERE",
+    "Source" : "TEMPLATE_AZSL_PATH",
 
     "DepthStencilState" :
     {
@@ -14,6 +14,13 @@
             "ReadMask" : "0x00",
             "WriteMask" : "0xFF",
             "FrontFace" :
+            {
+                "Func" : "Always",
+                "DepthFailOp" : "Keep",
+                "FailOp" : "Keep",
+                "PassOp" : "Replace"
+            },
+            "BackFace" :
             {
                 "Func" : "Always",
                 "DepthFailOp" : "Keep",

+ 52 - 0
Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass_CustomZ.shader.template

@@ -0,0 +1,52 @@
+{
+    "Source" : "TEMPLATE_AZSL_PATH",
+    
+    "Definitions": ["OUTPUT_DEPTH=1"],
+
+    "DepthStencilState" :
+    {
+        "Depth" :
+        {
+            "Enable" : true,
+            "CompareFunc" : "GreaterEqual"
+        },
+        "Stencil" :
+        {
+            "Enable" : true,
+            "ReadMask" : "0x00",
+            "WriteMask" : "0xFF",
+            "FrontFace" :
+            {
+                "Func" : "Always",
+                "DepthFailOp" : "Keep",
+                "FailOp" : "Keep",
+                "PassOp" : "Replace"
+            },
+            "BackFace" :
+            {
+                "Func" : "Always",
+                "DepthFailOp" : "Keep",
+                "FailOp" : "Keep",
+                "PassOp" : "Replace"
+            }
+        }
+    },
+
+    "ProgramSettings":
+    {
+      "EntryPoints":
+      [
+        {
+          "name": "MaterialVS",
+          "type": "Vertex"
+        },
+        {
+          "name": "MaterialPS",
+          "type": "Fragment"
+        }
+      ]
+    },
+
+    "DrawList" : "deferredMaterial"
+}
+

+ 25 - 0
Materials/Pipelines/PrototypeDeferredPipeline/DeferredPipeline.materialpipeline

@@ -5,16 +5,31 @@
             "azsli": "./DeferredMaterialPass.azsli",
             "tag": "main"
         },
+        {
+            "shader": "./DeferredMaterialPass_CustomZ.shader.template",
+            "azsli": "./DeferredMaterialPass.azsli",
+            "tag": "main_customZ"
+        },
         {
             "shader": "Materials/Pipelines/Common/DepthPass.shader.template",
             "azsli": "Materials/Pipelines/Common/DepthPass.azsli",
             "tag": "depth"
         },
+        {
+            "shader": "Materials/Pipelines/Common/DepthPass_CustomZ.shader.template",
+            "azsli": "Materials/Pipelines/Common/DepthPass_CustomZ.azsli",
+            "tag": "depth_customZ"
+        },
         {
             "shader": "Materials/Pipelines/Common/ShadowmapPass.shader.template",
             "azsli": "Materials/Pipelines/Common/DepthPass.azsli",
             "tag": "shadow"
         },
+        {
+            "shader": "Materials/Pipelines/Common/ShadowmapPass_CustomZ.shader.template",
+            "azsli": "Materials/Pipelines/Common/DepthPass_CustomZ.azsli",
+            "tag": "shadow_customZ"
+        },
         // This deferred pipeline uses the same transparent pass as the main pipeline
         {
             "shader": "Materials/Pipelines/MainPipeline/Transparent_StandardLighting.shader.template",
@@ -58,6 +73,16 @@
                 "name": "doubleSided",
                 "type": "Bool",
                 "defaultValue": false
+            },
+            {
+                "name": "hasPerPixelDepth",
+                "type": "Bool",
+                "defaultValue": false
+            },
+            {
+                "name": "hasPerPixelClip",
+                "type": "Bool",
+                "defaultValue": false
             }
         ],
         "functors": 

+ 9 - 1
Materials/Pipelines/PrototypeDeferredPipeline/DeferredPipelineScript.lua

@@ -22,6 +22,14 @@ function MaterialTypeSetup(context)
     context:IncludeShader("DepthPass")
     context:IncludeShader("ShadowmapPass")
     context:IncludeShader("DeferredMaterialPass")
+    
+    -- Unlike Standard and Enhanced, BaseLighting doesn't have "_CustomZ" just because BasePBR.materialtype doesn't use alpha cutout or POM PDO, so we don't need it right now.
+    -- But that could be added if some other material type wants to use BaseLighting with one of these features, as they don't really relate to the lighting model.
+    if(lightingModel ~= "Base") then
+        context:IncludeShader("DeferredMaterialPass_CustomZ")
+        context:IncludeShader("DepthPass_CustomZ")
+        context:IncludeShader("ShadowmapPass_CustomZ")
+    end
 
     -- Even though the enhanced lighting model is not supported by the deferred pass, since this pipeline 
     -- uses the same transparent pass shaders as the main pipeline, we can actually support the Standard
@@ -36,7 +44,7 @@ function MaterialTypeSetup(context)
         context:IncludeShader("Transparent_EnhancedLighting")
         context:IncludeShader("TintedTransparent_EnhancedLighting")
     end
-
+    
     return true
 end
 

+ 3 - 0
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_cutout_mainpipeline.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:48122ca9531d6d1c0b7fc18b729a78ae2d3e7cbfc6b9dcd38b7987845c315762
+size 862520

+ 3 - 0
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_pdo_deferredpipeline.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:35c9899c19ce7ad7b1ed5f4eefb65c659bd34b3fd519e202a049d6112481c5d2
+size 936855

+ 3 - 0
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_pdo_lowendpipeline.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:72f0b742fb58ea1f2241a2c065937b639fc122fb792dd4d20cdfdb58e3da14e2
+size 927980

+ 3 - 0
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_enhanced_pdo_mainpipeline.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:aab56816cc12f9c64b3a95f75d91f09c697fd8dd14fd449a8dd13d5476e82246
+size 936598

+ 3 - 0
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_cutout_lowendpipeline.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ee8030b2cc4c723d1006ba04119cb4b47455b8890be067348c395069a4662f8e
+size 1265995

+ 3 - 0
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_cutout_mainpipeline.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:14308eb1a8251b29413a311d735629015892ddd503728966313abc4ceccbdaa7
+size 1251997

+ 3 - 0
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_pdo_deferredpipeline.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:fc405f6116dd501a91a660404059374b0b867f77b800d785105aac0d6faef7dd
+size 1120512

+ 3 - 0
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_pdo_lowendpipeline.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ebb5e11f1a4bdfc2ae791bfc4021f13acfa5516ff2e667a3fd470b0476cada1e
+size 1226081

+ 3 - 0
Scripts/ExpectedScreenshots/MaterialPipelineSystem/materialpipelinetest_standard_pdo_mainpipeline.png

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:749554a1f9ce34e706b1c0c9cb5c8b54c315acdb3cbfba082d5bc4e0d95a522e
+size 1187522

+ 9 - 0
Scripts/MaterialScreenshotTests.bv.lua

@@ -265,24 +265,33 @@ GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Basic', {screenshotF
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard', {screenshotFilename="MaterialPipelineTest_Standard_MainPipeline"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard_Transparent', {screenshotFilename="MaterialPipelineTest_Standard_Transparent_MainPipeline"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard_TintedTransparent', {screenshotFilename="MaterialPipelineTest_Standard_TintedTransparent_MainPipeline"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard_Cutout', {screenshotFilename="MaterialPipelineTest_Standard_Cutout_MainPipeline"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard_PDO', {screenshotFilename="MaterialPipelineTest_Standard_PDO_MainPipeline", lighting="Test"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced', {screenshotFilename="MaterialPipelineTest_Enhanced_MainPipeline", lighting="Test"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced_Transparent', {screenshotFilename="MaterialPipelineTest_Enhanced_Transparent_MainPipeline", lighting="Test"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced_TintedTransparent', {screenshotFilename="MaterialPipelineTest_Enhanced_TintedTransparent_MainPipeline", lighting="Test"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced_Cutout', {screenshotFilename="MaterialPipelineTest_Enhanced_Cutout_MainPipeline", lighting="Test"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced_PDO', {screenshotFilename="MaterialPipelineTest_Enhanced_PDO_MainPipeline", lighting="Test"})
 
 SetImguiValue('Use Low End Pipeline', true)
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Basic', {screenshotFilename="MaterialPipelineTest_Basic_LowEndPipeline"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard', {screenshotFilename="MaterialPipelineTest_Standard_LowEndPipeline"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard_Transparent', {screenshotFilename="MaterialPipelineTest_Standard_Transparent_LowEndPipeline"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard_TintedTransparent', {screenshotFilename="MaterialPipelineTest_Standard_TintedTransparent_LowEndPipeline"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard_Cutout', {screenshotFilename="MaterialPipelineTest_Standard_Cutout_LowEndPipeline"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard_PDO', {screenshotFilename="MaterialPipelineTest_Standard_PDO_LowEndPipeline", lighting="Test"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced', {screenshotFilename="MaterialPipelineTest_Enhanced_LowEndPipeline", lighting="Test"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced_Transparent', {screenshotFilename="MaterialPipelineTest_Enhanced_Transparent_LowEndPipeline", lighting="Test"})
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced_TintedTransparent', {screenshotFilename="MaterialPipelineTest_Enhanced_TintedTransparent_LowEndPipeline", lighting="Test"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced_PDO', {screenshotFilename="MaterialPipelineTest_Enhanced_PDO_LowEndPipeline", lighting="Test"})
 SetImguiValue('Use Low End Pipeline', false)
 
 SetImguiValue('Use Deferred Pipeline', true)
 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"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard_PDO', {screenshotFilename="MaterialPipelineTest_Standard_PDO_DeferredPipeline", lighting="Test"})
+GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Enhanced_PDO', {screenshotFilename="MaterialPipelineTest_Enhanced_PDO_DeferredPipeline", lighting="Test"})
 -- There are several "transparent" materials but since none of them are supported in the deferred pipeline, just check one of them to make sure it's appropriately ignored.
 GenerateMaterialScreenshot('Level G', 'MaterialPipelineTest_Standard_Transparent', {screenshotFilename="MaterialPipelineTest_Standard_Transparent_DeferredPipeline"})
 SetImguiValue('Use Deferred Pipeline', false)