diff --git a/Gems/AtomTressFX/Assets/Passes/HairParentShortCutPass.pass b/Gems/AtomTressFX/Assets/Passes/HairParentShortCutPass.pass index 83f9f0d432..d8389a3da8 100644 --- a/Gems/AtomTressFX/Assets/Passes/HairParentShortCutPass.pass +++ b/Gems/AtomTressFX/Assets/Passes/HairParentShortCutPass.pass @@ -264,7 +264,7 @@ "Attachment": "HairColorRenderTarget" } }, - { + { // The final render target - this is MSAA mode RT - would it be cheaper to // use non-MSAA and then copy? "LocalSlot": "RenderTargetInputOutput", @@ -280,6 +280,13 @@ "Attachment": "DepthLinearInput" } }, + { + "LocalSlot": "AccumulatedInverseAlpha", + "AttachmentRef": { + "Pass": "HairShortCutGeometryDepthAlphaPass", + "Attachment": "InverseAlphaRTOutput" + } + }, { "LocalSlot": "Depth", "AttachmentRef": { diff --git a/Gems/AtomTressFX/Assets/Passes/HairShortCutGeometryShading.pass b/Gems/AtomTressFX/Assets/Passes/HairShortCutGeometryShading.pass index 5940f8c549..53fa2b358b 100644 --- a/Gems/AtomTressFX/Assets/Passes/HairShortCutGeometryShading.pass +++ b/Gems/AtomTressFX/Assets/Passes/HairShortCutGeometryShading.pass @@ -32,6 +32,12 @@ "SlotType": "Input", "ScopeAttachmentUsage": "Shader" }, + { // Used as the thickness accumulation to block TT (back) lobe lighting + "Name": "AccumulatedInverseAlpha", + "SlotType": "Input", + "ScopeAttachmentUsage": "Shader", + "ShaderInputName": "m_accumInvAlpha" + }, { // For comparing the depth to early disqualify but not to write "Name": "Depth", "SlotType": "Input", diff --git a/Gems/AtomTressFX/Assets/Shaders/HairRenderingFillPPLL.azsl b/Gems/AtomTressFX/Assets/Shaders/HairRenderingFillPPLL.azsl index 02777435f5..8dcd1ed372 100644 --- a/Gems/AtomTressFX/Assets/Shaders/HairRenderingFillPPLL.azsl +++ b/Gems/AtomTressFX/Assets/Shaders/HairRenderingFillPPLL.azsl @@ -51,9 +51,6 @@ ShaderResourceGroup PassSrg : SRG_PerPass_WithFallback RWTexture2D m_fragmentListHead; RWStructuredBuffer m_linkedListNodes; RWBuffer m_linkedListCounter; - - // Linear depth is used for getting the screen to world transform - Texture2D m_linearDepth; } //------------------------------------------------------------------------------ diff --git a/Gems/AtomTressFX/Assets/Shaders/HairShortCutGeometryShading.azsl b/Gems/AtomTressFX/Assets/Shaders/HairShortCutGeometryShading.azsl index c2a2958dfe..2a3e00b1e7 100644 --- a/Gems/AtomTressFX/Assets/Shaders/HairShortCutGeometryShading.azsl +++ b/Gems/AtomTressFX/Assets/Shaders/HairShortCutGeometryShading.azsl @@ -52,6 +52,9 @@ ShaderResourceGroup PassSrg : SRG_PerPass_WithFallback //! Originally in TressFXRendering.hlsl this is space 0 HairObjectShadeParams m_hairParams[AMD_TRESSFX_MAX_HAIR_GROUP_RENDER]; + // Will be used as thickness indication to block TT (back) lobe + Texture2D m_accumInvAlpha; + // Linear depth is used for getting the screen to world transform Texture2D m_linearDepth; @@ -164,9 +167,11 @@ float4 HairShortCutGeometryColorPS(PS_INPUT_HAIR input) : SV_Target float2 pixelCoord = input.Position.xy; float depth = input.Position.z; - // [To Do] - the thickness will need to be corrected somehow since this technique doesn't - // keeps track of the accumulated alpha / thickness - float thickness = alpha; + + // The following is a quick correction to remove the TT lobe (back lobe) contribution in case + // the hair is thick. We do that by accumulating alpha from the hair for the blend operation + // and this can be used here as an indication of thickness. + float thickness = saturate(1.0 - PassSrg::m_accumInvAlpha[int2(pixelCoord)]); float3 shadedFragment = TressFXShading(pixelCoord, depth, input.Tangent.xyz, strandColor.rgb, thickness, RenderParamsIndex); // Color channel: Pre-multiply with alpha to create non-normalized weighted sum.