From a436ea7f9bccd98083318da91b7f877aed117589 Mon Sep 17 00:00:00 2001 From: antonmic <56370189+antonmic@users.noreply.github.com> Date: Wed, 15 Dec 2021 22:30:37 -0800 Subject: [PATCH] BasePbr working Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com> --- .../Materials/Presets/PBR/metal_gold.material | 4 +- .../Presets/PBR/metal_gold_matte.material | 4 +- .../Presets/PBR/metal_gold_polished.material | 4 +- .../Materials/Types/BasePBR.materialtype | 18 --------- .../Materials/Types/BasePBR_ForwardPass.azsl | 13 +++--- .../Materials/Types/BasePBR_ShaderEnable.lua | 40 ------------------- .../Types/StandardPBR_ForwardPass.shader | 1 - 7 files changed, 13 insertions(+), 71 deletions(-) delete mode 100644 Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR_ShaderEnable.lua diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold.material b/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold.material index f0fd265726..04aaccada4 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold.material +++ b/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold.material @@ -1,8 +1,8 @@ { "description": "", - "materialType": "Materials\\Types\\Temp\\BasePBR.materialtype", + "materialType": "Materials\\Types\\BasePBR.materialtype", "parentMaterial": "", - "propertyLayoutVersion": 3, + "propertyLayoutVersion": 0, "properties": { "baseColor": { "color": [ diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold_matte.material b/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold_matte.material index 53ba190084..80ddede2ec 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold_matte.material +++ b/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold_matte.material @@ -1,8 +1,8 @@ { "description": "", - "materialType": "Materials\\Types\\Temp\\BasePBR.materialtype", + "materialType": "Materials\\Types\\BasePBR.materialtype", "parentMaterial": "", - "propertyLayoutVersion": 3, + "propertyLayoutVersion": 0, "properties": { "baseColor": { "color": [ diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold_polished.material b/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold_polished.material index d200bddbc5..b9f34f4717 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold_polished.material +++ b/Gems/Atom/Feature/Common/Assets/Materials/Presets/PBR/metal_gold_polished.material @@ -1,8 +1,8 @@ { "description": "", - "materialType": "Materials/Types/Temp/BasePBR.materialtype", + "materialType": "Materials/Types/BasePBR.materialtype", "parentMaterial": "", - "propertyLayoutVersion": 3, + "propertyLayoutVersion": 0, "properties": { "baseColor": { "color": [ diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR.materialtype index d4c79a05ef..5765537120 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR.materialtype @@ -596,24 +596,6 @@ "args": { "file": "StandardPBR_Metallic.lua" } - }, - { - "type": "Lua", - "args": { - "file": "StandardPBR_HandleOpacityDoubleSided.lua" - } - }, - { - "type": "Lua", - "args": { - "file": "StandardPBR_HandleOpacityMode.lua" - } - }, - { - "type": "Lua", - "args": { - "file": "BasePBR_ShaderEnable.lua" - } } ], "uvNameMap": { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR_ForwardPass.azsl index 8c8c9a589d..30a8666183 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR_ForwardPass.azsl @@ -69,7 +69,7 @@ struct VSOutput VSOutput BasePbr_ForwardPassVS(VSInput IN) { - VSOutput OUT = (VSOutput)0; + VSOutput OUT; float3 worldPosition = mul(ObjectSrg::GetWorldMatrix(), float4(IN.m_position, 1.0)).xyz; @@ -101,7 +101,8 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace) PrepareGeneratedTangent(IN.m_normal, IN.m_worldPosition, isFrontFace, IN.m_uv, UvSetCount, tangents, bitangents); } - Surface surface = (Surface)0; + Surface surface; + surface.clearCoat.InitializeToZero(); surface.position = IN.m_worldPosition.xyz; // ------- Normal ------- @@ -139,7 +140,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace) // ------- Lighting Data ------- - LightingData lightingData = (LightingData)0; + LightingData lightingData; // Light iterator lightingData.tileIterator.Init(IN.m_position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData); @@ -173,7 +174,8 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace) float alpha = 1.0f; PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha); - lightingOutput.m_diffuseColor.w = -1; // Disable subsurface scattering + // Disable subsurface scattering + lightingOutput.m_diffuseColor.w = -1; return lightingOutput; } @@ -183,8 +185,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace) ForwardPassOutput BasePbr_ForwardPassPS_EDS(VSOutput IN, bool isFrontFace : SV_IsFrontFace) { ForwardPassOutput OUT; - PbrLightingOutput lightingOutput = (PbrLightingOutput)0; - lightingOutput = ForwardPassPS_Common(IN, isFrontFace); + PbrLightingOutput lightingOutput = ForwardPassPS_Common(IN, isFrontFace); #ifdef UNIFIED_FORWARD_OUTPUT OUT.m_color.rgb = lightingOutput.m_diffuseColor.rgb + lightingOutput.m_specularColor.rgb; diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR_ShaderEnable.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR_ShaderEnable.lua deleted file mode 100644 index 4a5fba58e8..0000000000 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/BasePBR_ShaderEnable.lua +++ /dev/null @@ -1,40 +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 --- --- --- ----------------------------------------------------------------------------------------------------- - -function TryGetShaderByTag(context, shaderTag) - if context:HasShaderWithTag(shaderTag) then - return context:GetShaderByTag(shaderTag) - else - return nil - end -end - -function TrySetShaderEnabled(shader, enabled) - if shader then - shader:SetEnabled(enabled) - end -end - -function Process(context) - - local depthPass = context:GetShaderByTag("DepthPass") - local shadowMap = context:GetShaderByTag("Shadowmap") - local forwardPassEDS = context:GetShaderByTag("ForwardPass_EDS") - - -- Use TryGetShaderByTag because these shaders only exist in BasePBR but this script is also used for EnhancedPBR - local lowEndForwardEDS = TryGetShaderByTag(context, "LowEndForward_EDS") - - depthPass:SetEnabled(true); - shadowMap:SetEnabled(true); - forwardPassEDS:SetEnabled(true); - - TrySetShaderEnabled(lowEndForwardEDS, true) -end diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.shader b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.shader index d8df49f4b0..7c7a19efc9 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.shader +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.shader @@ -30,7 +30,6 @@ } }, - "CompilerHints" : { "DisableOptimizations" : false },