diff --git a/Content/Blueprints/OptiXVRPawnStandaloneBP.uasset b/Content/Blueprints/OptiXVRPawnStandaloneBP.uasset index 12db22255292780000c3e46138b4197f6a08265c..9781c53022dca3fe133c5da3799c734155764b7c 100644 Binary files a/Content/Blueprints/OptiXVRPawnStandaloneBP.uasset and b/Content/Blueprints/OptiXVRPawnStandaloneBP.uasset differ diff --git a/Content/Blueprints/OpticalTable.uasset b/Content/Blueprints/OpticalTable.uasset index 14a2a9921cab20cf3fb78f00d3b30d1edbfeca5e..1a11e5199596ac8a15e0bb31e3690cccabf894a8 100644 Binary files a/Content/Blueprints/OpticalTable.uasset and b/Content/Blueprints/OpticalTable.uasset differ diff --git a/Content/Blueprints/RenderTargetTest.uasset b/Content/Blueprints/RenderTargetTest.uasset new file mode 100644 index 0000000000000000000000000000000000000000..1087df6d6d62552c802479ac8a4d7264d445a284 Binary files /dev/null and b/Content/Blueprints/RenderTargetTest.uasset differ diff --git a/Source/OptiX/Private/OptiXContextManager.cpp b/Source/OptiX/Private/OptiXContextManager.cpp index 149e097382b90a539bb2b078a8a2c156026dc4ab..fb5d393a01555f4baa996f298032fb1e04187c5d 100644 --- a/Source/OptiX/Private/OptiXContextManager.cpp +++ b/Source/OptiX/Private/OptiXContextManager.cpp @@ -90,7 +90,7 @@ void FOptiXContextManager::PreRenderView_RenderThread(FRHICommandListImmediate & void FOptiXContextManager::PreRenderViewFamily_RenderThread(FRHICommandListImmediate & RHICmdList, FSceneViewFamily & InViewFamily) { //UE_LOG(LogTemp, Warning, TEXT("PreRenderViewFamily_RenderThread")); - if (!bIsInitialized) + if (!bIsInitialized && bStartTracing) { InitCUDADX(); } @@ -214,7 +214,7 @@ void FOptiXContextManager::PostRenderView_RenderThread(FRHICommandListImmediate UpdateCubemapBuffer(RHICmdList); } - else + else if(InView.StereoPass == EStereoscopicPass::eSSP_RIGHT_EYE) { /*optix::uchar4* Data = static_cast<optix::uchar4*>(OptiXContext->GetBuffer("result_color")->MapNative()); RHICmdList.UpdateTexture2D(OutputTextureColorRightRef, 0, TextureRegion, Size.X * 4, (uint8*)Data); @@ -269,6 +269,17 @@ void FOptiXContextManager::PostRenderView_RenderThread(FRHICommandListImmediate //D3DDeviceContext->Flush(); //end = FPlatformTime::Seconds(); //UE_LOG(LogTemp, Warning, TEXT("Update took %f seconds"), end - start); + + else if (InView.StereoPass == EStereoscopicPass::eSSP_FULL) + { + UE_LOG(LogTemp, Display, TEXT("Full Pass")); + } + + if (bCleanup) + { + CleanupOptiXOnEnd(); + } + } @@ -605,6 +616,12 @@ void FOptiXContextManager::InitRendering() DynamicMaterial->SetTextureParameterValue("DepthRight", DepthTexture.Get()); DynamicMaterial->SetTextureParameterValue("TextureLeft", OutputTexture2.Get()); DynamicMaterial->SetTextureParameterValue("DepthLeft", DepthTexture2.Get()); + + + DynamicMaterial2D = UMaterialInstanceDynamic::Create(RegularMaterial.Get(), OptiXContext.Get(), "DynamicNonVRMaterial"); + DynamicMaterial2D->SetTextureParameterValue("Texture", OutputTexture.Get()); + DynamicMaterial2D->SetTextureParameterValue("Depth", DepthTexture.Get()); + } else { diff --git a/Source/OptiX/Private/OptiXGameModeBase.cpp b/Source/OptiX/Private/OptiXGameModeBase.cpp index 3e245395034ede23f992711cb657ed6070b499b0..75acb1e04c6771515b056ad2ed89f16ede725067 100644 --- a/Source/OptiX/Private/OptiXGameModeBase.cpp +++ b/Source/OptiX/Private/OptiXGameModeBase.cpp @@ -22,6 +22,11 @@ void AOptiXGameModeBase::InitGame(const FString & MapName, const FString & Optio FOptiXModule::Get().Init(); } +void AOptiXGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason) +{ + FOptiXModule::Get().GetOptiXContextManager()->EndPlay(); +} + const TArray<FSceneData>& AOptiXGameModeBase::GetOptiXSceneDataArray() { return FOptiXModule::Get().GetSceneDataArray(); diff --git a/Source/OptiX/Public/OptiXContextManager.h b/Source/OptiX/Public/OptiXContextManager.h index 619a7445adbb209a3009f2918aa59b94777f3b2f..0d47f40acd06cf4ab6f91bb56c1459032e82ea83 100644 --- a/Source/OptiX/Public/OptiXContextManager.h +++ b/Source/OptiX/Public/OptiXContextManager.h @@ -113,7 +113,8 @@ public: void EndPlay() { - CleanupOptiXOnEnd(); + //CleanupOptiXOnEnd(); + bCleanup.AtomicSet(true); } UOptiXContext* GetOptiXContext() @@ -126,6 +127,11 @@ public: return DynamicMaterial.Get(); } + UMaterialInstanceDynamic* GetOptiXMID2D() // Used to set up the post process + { + return DynamicMaterial2D.Get(); + } + void SceneChangedCallback(); // The OptiX context is not thread-safe, so any changes to variables/properties on the game thread @@ -570,6 +576,7 @@ private: LaserIntersectionTexture.Reset(); DynamicMaterial.Reset(); + DynamicMaterial2D.Reset(); RegularMaterial.Reset(); VRMaterial.Reset(); LaserMaterial.Reset(); @@ -688,6 +695,7 @@ private: TWeakObjectPtr<UTexture2D> DepthTexture2; TWeakObjectPtr<UMaterialInstanceDynamic> DynamicMaterial; + TWeakObjectPtr<UMaterialInstanceDynamic> DynamicMaterial2D; TWeakObjectPtr<UMaterial> RegularMaterial; TWeakObjectPtr<UMaterial> VRMaterial; bool bWithHMD; diff --git a/Source/OptiX/Public/OptiXGameModeBase.h b/Source/OptiX/Public/OptiXGameModeBase.h index c5f147c6af51637b1b251f1d4ac46db25c869b4b..4b9156925c8aac6d9122d80764ffa04c5a81594c 100644 --- a/Source/OptiX/Public/OptiXGameModeBase.h +++ b/Source/OptiX/Public/OptiXGameModeBase.h @@ -21,6 +21,8 @@ public: AOptiXGameModeBase(const FObjectInitializer& ObjectInitializer); virtual void InitGame(const FString & MapName, const FString & Options, FString & ErrorMessage) override; + virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; + UFUNCTION(BlueprintCallable, BlueprintPure) const TArray<FSceneData>& GetOptiXSceneDataArray();