فهرست منبع

Updated the deferred material pipeline to work with reorganized material pipeline design.
Updated the example materials with more data that's now available in the test material types.

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

santorac 2 سال پیش
والد
کامیت
573ad817df

+ 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
     }
 }

+ 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
     }
 }

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

@@ -13,47 +13,13 @@
 #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 +29,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);
-
-    // 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);
+    // ------- Geometry -> Surface -------
 
-    //TODO(DeferredPOC): Support clear coat
-    //surface.clearCoat.InitializeToZero();
+    PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
 
-    MaterialFunction_AdjustSurface(surface);
-    
-    surface.CalculateRoughnessA();
+    Surface surface = EvaluateSurface(geoData);
 
     // ------- Output -------
 

+ 6 - 3
Materials/Pipelines/PrototypeDeferredPipeline/DeferredPipeline.materialpipeline

@@ -2,15 +2,18 @@
     "shaderTemplates": [
         {
             "shader": "./DeferredMaterialPass.shader.template",
-            "azsli": "Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass.azsli"
+            "preMaterialAzsli": "./MaterialPass_PreMaterial.azsli",
+            "postMaterialAzsli": "Materials/Pipelines/PrototypeDeferredPipeline/DeferredMaterialPass.azsli"
         },
         {
             "shader": "Materials/Pipelines/Common/DepthPass.shader.template",
-            "azsli": "Materials/Pipelines/Common/DepthPass.azsli"
+            "preMaterialAzsli": "Materials/Pipelines/Common/DepthAndShadow_PreMaterial.azsli",
+            "postMaterialAzsli": "Materials/Pipelines/Common/DepthPass.azsli"
         },
         {
             "shader": "Materials/Pipelines/Common/ShadowmapPass.shader.template",
-            "azsli": "Materials/Pipelines/Common/ShadowmapPass.azsli"
+            "preMaterialAzsli": "Materials/Pipelines/Common/DepthAndShadow_PreMaterial.azsli",
+            "postMaterialAzsli": "Materials/Pipelines/Common/ShadowmapPass.azsli"
         }
     ]
 }

+ 11 - 0
Materials/Pipelines/PrototypeDeferredPipeline/MaterialPass_PreMaterial.azsli

@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) Contributors to the Open 3D Engine Project.
+ * For complete copyright and license terms please see the LICENSE at the root of this distribution.
+ *
+ * SPDX-License-Identifier: Apache-2.0 OR MIT
+ *
+ */
+ 
+#define MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE 1
+
+#include <Atom/RPI/MaterialPipelineCallbacks.azsli>