Files
Adi Bar-Lev 64bbc700fa Hair - ShortCut rendering technique and pipeline with Marschner lighting model (#4871)
- This rendering technique reduces the memory required per pipeline by 750MB compared to the PPLL technique!!
- Using 3 screen buffers representing the closest 3 hair gragments depths.
- Going through second geometry pass that disqualify any fragment further than the third depth, the technique blends the three closes shaders hair fragments.
- Supports the Marschner lighting model (big change from the original TressFX 4.1 implementation)
- The current technique is almost twice the performance of the PPLL but not quite as advacned when come to final visual quality.

Remarks:
Unlike the PPLL, this technique is still lacking some of the advanced features added to the PPLL such as
1. Back lobe (TT) conseal by depth comparison
2. Thickness dependency in light transfer (mainly TT)
3. Allowing TT transfer for thin separated hair strands (might be supported by default with no distinction)

Signed-off-by: Adi-Amazon <Adi Bar-Lev 82479970+Adi-Amazon@users.noreply.github.com>
Signed-off-by: Adi-Amazon <Adi Bar-Lev barlev@amazon.com>
Signed-off-by: Adi-Amazon <Adi Bar-Lev 82479970+Adi-Amazon@users.noreply.github.com>
Signed-off-by: Adi-Amazon <Adi Bar-Lev barlev@amazon.com>

Co-authored-by: Adi-Amazon <Adi Bar-Lev 82479970+Adi-Amazon@users.noreply.github.com>
2021-10-21 14:29:53 -04:00

102 lines
4.0 KiB
C++

/*
* 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
*
*/
#include <AzCore/Serialization/SerializeContext.h>
#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
#include <Atom/RPI.Public/FeatureProcessorFactory.h>
#include <Components/HairSystemComponent.h>
#include <Components/HairComponentController.h>
#include <Rendering/HairFeatureProcessor.h>
namespace AZ
{
namespace Render
{
namespace Hair
{
HairSystemComponent::HairSystemComponent() = default;
HairSystemComponent::~HairSystemComponent() = default;
void HairSystemComponent::Reflect(ReflectContext* context)
{
if (SerializeContext* serialize = azrtti_cast<SerializeContext*>(context))
{
serialize->Class<HairSystemComponent, Component>()
->Version(0)
;
}
Hair::HairFeatureProcessor::Reflect(context);
}
void HairSystemComponent::GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC_CE("HairService"));
}
void HairSystemComponent::GetIncompatibleServices(ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC_CE("HairService"));
}
void HairSystemComponent::GetRequiredServices([[maybe_unused]] ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC("ActorSystemService", 0x5e493d6c));
required.push_back(AZ_CRC("EMotionFXAnimationService", 0x3f8a6369));
}
void HairSystemComponent::LoadPassTemplateMappings()
{
auto* passSystem = RPI::PassSystemInterface::Get();
AZ_Assert(passSystem, "Cannot get the pass system.");
const char* passTemplatesFile = "Passes/AtomTressFX_PassTemplates.azasset";
passSystem->LoadPassTemplateMappings(passTemplatesFile);
}
void HairSystemComponent::Init()
{
}
void HairSystemComponent::Activate()
{
// Feature processor
AZ::RPI::FeatureProcessorFactory::Get()->RegisterFeatureProcessor<Hair::HairFeatureProcessor>();
auto* passSystem = RPI::PassSystemInterface::Get();
AZ_Assert(passSystem, "Cannot get the pass system.");
// Setup handler for load pass templates mappings
m_loadTemplatesHandler = RPI::PassSystemInterface::OnReadyLoadTemplatesEvent::Handler([this]() { this->LoadPassTemplateMappings(); });
passSystem->ConnectEvent(m_loadTemplatesHandler);
// Load the AtomTressFX pass classes
passSystem->AddPassCreator(Name("HairSkinningComputePass"), &HairSkinningComputePass::Create);
// Load the PPLL render method passes
passSystem->AddPassCreator(Name("HairPPLLRasterPass"), &HairPPLLRasterPass::Create);
passSystem->AddPassCreator(Name("HairPPLLResolvePass"), &HairPPLLResolvePass::Create);
// Load the ShortCut render method passes
passSystem->AddPassCreator(Name("HairShortCutGeometryDepthAlphaPass"), &HairShortCutGeometryDepthAlphaPass::Create);
passSystem->AddPassCreator(Name("HairShortCutGeometryShadingPass"), &HairShortCutGeometryShadingPass::Create);
}
void HairSystemComponent::Deactivate()
{
AZ::RPI::FeatureProcessorFactory::Get()->UnregisterFeatureProcessor<Hair::HairFeatureProcessor>();
m_loadTemplatesHandler.Disconnect();
}
} // namespace Hair
} // End Render namespace
} // End AZ namespace