2019-12-27 09:26:59 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-07-18 12:00:53 -04:00
|
|
|
|
|
|
|
|
#include "PostProcess/DisplayClusterPostprocessOutputRemap.h"
|
|
|
|
|
|
2020-10-09 22:42:26 -04:00
|
|
|
#include "Misc/DisplayClusterHelpers.h"
|
2019-07-18 12:00:53 -04:00
|
|
|
#include "DisplayClusterPostprocessLog.h"
|
|
|
|
|
#include "DisplayClusterPostprocessStrings.h"
|
2021-04-29 19:32:06 -04:00
|
|
|
#include "DisplayClusterRootActor.h"
|
|
|
|
|
|
|
|
|
|
#include "Render/Containers/DisplayClusterRender_MeshComponentProxy.h"
|
|
|
|
|
#include "Render/Containers/DisplayClusterRender_MeshGeometry.h"
|
|
|
|
|
|
|
|
|
|
#include "Render/Viewport/IDisplayClusterViewportManager.h"
|
|
|
|
|
|
|
|
|
|
#include "IDisplayClusterShaders.h"
|
|
|
|
|
|
|
|
|
|
#include "DisplayClusterRootActor.h"
|
2019-07-18 12:00:53 -04:00
|
|
|
|
|
|
|
|
#include "Engine/RendererSettings.h"
|
|
|
|
|
#include "Misc/Paths.h"
|
|
|
|
|
|
|
|
|
|
FDisplayClusterPostprocessOutputRemap::FDisplayClusterPostprocessOutputRemap()
|
2021-04-29 19:32:06 -04:00
|
|
|
: MeshComponentProxy(*(new FDisplayClusterRender_MeshComponentProxy()))
|
|
|
|
|
, ShadersAPI(IDisplayClusterShaders::Get())
|
2019-07-18 12:00:53 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FDisplayClusterPostprocessOutputRemap::~FDisplayClusterPostprocessOutputRemap()
|
|
|
|
|
{
|
2021-04-29 19:32:06 -04:00
|
|
|
delete (&MeshComponentProxy);
|
2019-07-18 12:00:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// IDisplayClusterPostProcess
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
2021-04-29 19:32:06 -04:00
|
|
|
bool FDisplayClusterPostprocessOutputRemap::IsPostProcessFrameAfterWarpBlendRequired() const
|
2019-07-18 12:00:53 -04:00
|
|
|
{
|
2021-04-29 19:32:06 -04:00
|
|
|
return bIsInitialized;
|
2019-07-18 12:00:53 -04:00
|
|
|
}
|
|
|
|
|
|
2021-04-29 19:32:06 -04:00
|
|
|
void FDisplayClusterPostprocessOutputRemap::InitializePostProcess(class IDisplayClusterViewportManager& InViewportManager, const TMap<FString, FString>& Parameters)
|
2019-07-18 12:00:53 -04:00
|
|
|
{
|
2021-04-29 19:32:06 -04:00
|
|
|
// OBJ file (optional)
|
2019-07-18 12:00:53 -04:00
|
|
|
FString ExtMeshFile;
|
2020-10-09 22:42:26 -04:00
|
|
|
if (DisplayClusterHelpers::map::template ExtractValue(Parameters, DisplayClusterPostprocessStrings::output_remap::File, ExtMeshFile))
|
2019-07-18 12:00:53 -04:00
|
|
|
{
|
2020-10-09 22:42:26 -04:00
|
|
|
UE_LOG(LogDisplayClusterPostprocessOutputRemap, Log, TEXT("Found Argument '%s'='%s'"), DisplayClusterPostprocessStrings::output_remap::File, *ExtMeshFile);
|
2019-07-18 12:00:53 -04:00
|
|
|
|
2021-04-29 19:32:06 -04:00
|
|
|
FDisplayClusterRender_MeshGeometry MeshGeometry;
|
|
|
|
|
if (!MeshGeometry.LoadFromFile(ExtMeshFile))
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogDisplayClusterPostprocessOutputRemap, Error, TEXT("Failed to load ext mesh from file '%s'"), *ExtMeshFile);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-07-18 12:00:53 -04:00
|
|
|
|
2021-04-29 19:32:06 -04:00
|
|
|
MeshComponentProxy.UpdateDeffered(MeshGeometry);
|
|
|
|
|
bIsInitialized = true;
|
2019-07-18 12:00:53 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 19:32:06 -04:00
|
|
|
// Mesh from RootActor
|
|
|
|
|
FString RootActorMeshComponentName;
|
|
|
|
|
if (DisplayClusterHelpers::map::template ExtractValue(Parameters, DisplayClusterPostprocessStrings::output_remap::Mesh, RootActorMeshComponentName))
|
2019-07-18 12:00:53 -04:00
|
|
|
{
|
2021-04-29 19:32:06 -04:00
|
|
|
UE_LOG(LogDisplayClusterPostprocessOutputRemap, Log, TEXT("Found Argument '%s'='%s'"), DisplayClusterPostprocessStrings::output_remap::Mesh, *RootActorMeshComponentName);
|
|
|
|
|
|
|
|
|
|
ADisplayClusterRootActor* RootActor = InViewportManager.GetRootActor();
|
|
|
|
|
if (RootActor == nullptr)
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogDisplayClusterPostprocessOutputRemap, Error, TEXT("RootActor not found: Can't load static mesh component '%s'"), *RootActorMeshComponentName);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get mesh component
|
2021-06-23 17:51:32 -04:00
|
|
|
UStaticMeshComponent* MeshComponent = RootActor->GetComponentByName<UStaticMeshComponent>(RootActorMeshComponentName);
|
2021-04-29 19:32:06 -04:00
|
|
|
if (MeshComponent == nullptr)
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogDisplayClusterPostprocessOutputRemap, Error, TEXT("Static mesh component '%s' not found in RootActor"), *RootActorMeshComponentName);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MeshComponentProxy.AssignMeshRefs(MeshComponent);
|
|
|
|
|
MeshComponentProxy.UpdateDefferedRef();
|
|
|
|
|
bIsInitialized = true;
|
|
|
|
|
return;
|
2019-07-18 12:00:53 -04:00
|
|
|
}
|
2021-04-29 19:32:06 -04:00
|
|
|
|
|
|
|
|
UE_LOG(LogDisplayClusterPostprocessOutputRemap, Error, TEXT("OutputRemap parameters is undefined"));
|
2019-07-18 12:00:53 -04:00
|
|
|
}
|
|
|
|
|
|
2021-04-29 19:32:06 -04:00
|
|
|
void FDisplayClusterPostprocessOutputRemap::PerformPostProcessFrameAfterWarpBlend_RenderThread(FRHICommandListImmediate& RHICmdList, const TArray<FRHITexture2D*>* InFrameTargets, const TArray<FRHITexture2D*>* InAdditionalFrameTargets) const
|
2019-07-18 12:00:53 -04:00
|
|
|
{
|
2021-04-29 19:32:06 -04:00
|
|
|
if (InFrameTargets && InAdditionalFrameTargets)
|
2019-07-18 12:00:53 -04:00
|
|
|
{
|
2021-04-29 19:32:06 -04:00
|
|
|
// Support mesh refresh:
|
|
|
|
|
if(MeshComponentProxy.MeshComponentRef.IsMeshComponentChanged())
|
|
|
|
|
{
|
|
|
|
|
MeshComponentProxy.UpdateDefferedRef();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int Index = 0; Index < InFrameTargets->Num(); Index++)
|
2019-07-18 12:00:53 -04:00
|
|
|
{
|
2021-04-29 19:32:06 -04:00
|
|
|
FRHITexture2D* InOutTexture = (*InFrameTargets)[Index];
|
|
|
|
|
FRHITexture2D* TempTargetableTexture = (*InAdditionalFrameTargets)[Index];
|
2019-07-18 12:00:53 -04:00
|
|
|
|
2021-04-29 19:32:06 -04:00
|
|
|
if (ShadersAPI.RenderPostprocess_OutputRemap(RHICmdList, InOutTexture, TempTargetableTexture, MeshComponentProxy))
|
|
|
|
|
{
|
|
|
|
|
//Copy remapped result back
|
|
|
|
|
RHICmdList.CopyToResolveTarget(TempTargetableTexture, InOutTexture, FResolveParams());
|
|
|
|
|
}
|
2019-07-18 12:00:53 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|