diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index b917e90..85b7811 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -13,3 +13,6 @@ AppliedDefaultGraphicsPerformance=Maximum EditorStartupMap=/Game/Maps/TestMap.TestMap GameDefaultMap=/Game/Maps/TestMap.TestMap +[/Script/Engine.RendererSettings] +r.AntiAliasingMethod=0 + diff --git a/CustomComputeShader.uproject b/CustomComputeShader.uproject index 1a54fea..749f25e 100644 --- a/CustomComputeShader.uproject +++ b/CustomComputeShader.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "4.24", + "EngineAssociation": "5.2", "Category": "", "Description": "", "Modules": [ diff --git a/README.md b/README.md index 2c0c459..a78649a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # CustomComputeShader -A minimal Unreal Engine 4 porject for adding and using a compute shader. I published an article that covers the main steps of the process and I use this project as an example. +A minimal Unreal Engine 5 project for adding and using a compute shader. I published an article that covers the main steps of the process and I use this project as an example. ## Modules: * **CustomComputeShader** : The primary game module @@ -8,7 +8,3 @@ A minimal Unreal Engine 4 porject for adding and using a compute shader. I publi ## Shaders: * **WhiteNoiseCS** : A simple compute shader that renders white noise to a texture - -## UE4 Version -This project was created and tested using **UE4.24**. Id you're using **UE4.25**, you'll need to include **/Engine/Public/Platform.ush** in your shader file in order for it to compile. - diff --git a/Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.cpp b/Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.cpp index 0b90923..06efef9 100644 --- a/Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.cpp +++ b/Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.cpp @@ -27,7 +27,7 @@ class FWhiteNoiseCS : public FGlobalShader /// BEGIN_SHADER_PARAMETER_STRUCT(FParameters, ) SHADER_PARAMETER_UAV(RWTexture2D, OutputTexture) - SHADER_PARAMETER(FVector2D, Dimensions) + SHADER_PARAMETER(FVector2f, Dimensions) SHADER_PARAMETER(UINT, TimeStamp) END_SHADER_PARAMETER_STRUCT() @@ -110,8 +110,10 @@ void FWhiteNoiseCSManager::UpdateParameters(FWhiteNoiseCSParameters& params) /// Gets a reference to the shader type from the global shaders map /// Dispatches the shader using the parameter structure instance /// -void FWhiteNoiseCSManager::Execute_RenderThread(FRHICommandListImmediate& RHICmdList, class FSceneRenderTargets& SceneContext) +void FWhiteNoiseCSManager::Execute_RenderThread(FRDGBuilder& GraphBuilder, const FSceneTextures& SceneTextures) { + FRHICommandListImmediate& RHICmdList = GraphBuilder.RHICmdList; + //If there's no cached parameters to use, skip //If no Render Target is supplied in the cachedParams, skip if (!(bCachedParamsAreValid && cachedParams.RenderTarget)) @@ -136,13 +138,12 @@ void FWhiteNoiseCSManager::Execute_RenderThread(FRHICommandListImmediate& RHICmd //UnbindRenderTargets(RHICmdList); //Specify the resource transition, we're executing this in post scene rendering so we set it to Graphics to Compute - RHICmdList.TransitionResource(EResourceTransitionAccess::ERWBarrier, EResourceTransitionPipeline::EGfxToCompute, ComputeShaderOutput->GetRenderTargetItem().UAV); - + RHICmdList.TransitionResource(ERHIAccess::UAVCompute, ComputeShaderOutput->GetRenderTargetItem().GetRHI()); //Fill the shader parameters structure with tha cached data supplied by the client FWhiteNoiseCS::FParameters PassParameters; PassParameters.OutputTexture = ComputeShaderOutput->GetRenderTargetItem().UAV; - PassParameters.Dimensions = FVector2D(cachedParams.GetRenderTargetSize().X, cachedParams.GetRenderTargetSize().Y); + PassParameters.Dimensions = FVector2f(cachedParams.GetRenderTargetSize().X, cachedParams.GetRenderTargetSize().Y); PassParameters.TimeStamp = cachedParams.TimeStamp; //Get a reference to our shader type from global shader map diff --git a/Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.h b/Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.h index 8e70fc6..2d47e22 100644 --- a/Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.h +++ b/Source/CustomShadersDeclarations/Private/ComputeShaderDeclaration.h @@ -70,5 +70,5 @@ class CUSTOMSHADERSDECLARATIONS_API FWhiteNoiseCSManager //Reference to a pooled render target where the shader will write its output TRefCountPtr ComputeShaderOutput; public: - void Execute_RenderThread(FRHICommandListImmediate& RHICmdList, class FSceneRenderTargets& SceneContext); + void Execute_RenderThread(FRDGBuilder& GraphBuilder, const FSceneTextures& SceneTextures); };