Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UE5.3 compatibility - getting errors in compute shader base #11

Open
SalvatoSC opened this issue Sep 16, 2023 · 3 comments
Open

UE5.3 compatibility - getting errors in compute shader base #11

SalvatoSC opened this issue Sep 16, 2023 · 3 comments

Comments

@SalvatoSC
Copy link

Hi,
I just started learning compute shaders in unreal and wanted to follow your Recipe "Making a custom Advanced Output material expression accessible from Compute Shaders in Unreal Engine 5"

When I generate AdvancedOutputComputeShader.cpp I end up with errors on lines 168 and 185
DrawRenderState.SetViewUniformBuffer(ViewUniformBuffer);
RHICmdList.SetComputeShader(ComputeShaderRHI);
Both of those funtions have been depracated after 5.1 and I don't know where to begin with updating those for 5.3. Can you please help?

@AskingQuestions
Copy link
Owner

Thanks for the report

I just pushed an update today that should bring Shadeup fully up-to-date with UE 5.3

The following should fix both your errors above:

In AdvancedOutputComputeShader.cpp add the following include:

#include "MeshPassUtils.h"

and replace the lines found around 140-180 with the following

			PassParameters->OutputColor = GraphBuilder.CreateUAV(FRDGBufferUAVDesc(OutputBuffer, PF_A32B32G32R32F));
			FViewUniformShaderParameters ViewUniformShaderParameters;

			ViewUniformShaderParameters.GameTime = Params.GameTime;
			ViewUniformShaderParameters.RealTime = Params.GameTime;
			ViewUniformShaderParameters.Random = Params.Random;
			
			auto ViewUniformBuffer = TUniformBufferRef<FViewUniformShaderParameters>::CreateUniformBufferImmediate(ViewUniformShaderParameters, UniformBuffer_SingleFrame);
			PassParameters->View = ViewUniformBuffer;
			

			auto GroupCount = FComputeShaderUtils::GetGroupCount(FIntVector(Params.X, Params.Y, Params.Z), FComputeShaderUtils::kGolden2DGroupSize);
			GraphBuilder.AddPass(
				RDG_EVENT_NAME("ExecuteMyMaterial3"),
				PassParameters,
				ERDGPassFlags::AsyncCompute,
				[&PassParameters, ComputeShader, MaterialRenderProxy, MaterialResource, LocalScene, GroupCount](FRHIComputeCommandList& RHICmdList)
			{
				
				FMeshPassProcessorRenderState DrawRenderState;
				
				MaterialRenderProxy->UpdateUniformExpressionCacheIfNeeded(LocalScene->GetFeatureLevel());

				FMeshMaterialShaderElementData ShaderElementData;

				FMeshProcessorShaders PassShaders;
				PassShaders.ComputeShader = ComputeShader;

				FMeshDrawShaderBindings ShaderBindings;
				ShaderBindings.Initialize(PassShaders);

				int32 DataOffset = 0;
				FMeshDrawSingleShaderBindings SingleShaderBindings = ShaderBindings.GetSingleShaderBindings(SF_Compute, DataOffset);
				ComputeShader->GetShaderBindings(LocalScene->GetRenderScene(), LocalScene->GetFeatureLevel(), nullptr, *MaterialRenderProxy, *MaterialResource, DrawRenderState, ShaderElementData, SingleShaderBindings);

				ShaderBindings.Finalize(&PassShaders);

				UE::MeshPassUtils::Dispatch(RHICmdList, ComputeShader, ShaderBindings, *PassParameters, GroupCount);
			});

If you're still getting errors with I'd try regenerating.

@SalvatoSC
Copy link
Author

Hi, first of all thanks for replying this quickly!
I cleaned the project plugin of my previous downloads from Shadeup and installed the new shadeup CLI version (shows 1.2, UE5.3 compatible)
I once again tried to go through the "Making a custom Advanced Output material expression accessible from Compute Shaders in Unreal Engine 5" and downloaded the templates through console.
There was a missing include for MD_Surface so I added

#include "MaterialDomain.h"

at the top and then got the project to compile.
After that I am getting the error that something went wrong, so basically this part evaluates as false:

bool bIsShaderValid = ComputeShader.IsValid();

So that's how my little adventure ended on this tutorial.

Just to be sure, I also downloaded pure "Bare-bones material graph evaluation via Compute Shader in UE5" (also cleaned the plugins etc, basically clean install from console as well).
That one was also missing MaterialDomain.h and throws the same error.

@hoummel
Copy link

hoummel commented Oct 6, 2023

Hi, first of all thanks for replying this quickly! I cleaned the project plugin of my previous downloads from Shadeup and installed the new shadeup CLI version (shows 1.2, UE5.3 compatible) I once again tried to go through the "Making a custom Advanced Output material expression accessible from Compute Shaders in Unreal Engine 5" and downloaded the templates through console. There was a missing include for MD_Surface so I added

#include "MaterialDomain.h"

at the top and then got the project to compile. After that I am getting the error that something went wrong, so basically this part evaluates as false:

bool bIsShaderValid = ComputeShader.IsValid();

So that's how my little adventure ended on this tutorial.

Just to be sure, I also downloaded pure "Bare-bones material graph evaluation via Compute Shader in UE5" (also cleaned the plugins etc, basically clean install from console as well). That one was also missing MaterialDomain.h and throws the same error.

replace the code in ExampleComputeShader.cpp

const bool bIsCompatible = Parameters.MaterialParameters.MaterialDomain == MD_Surface
			&& Parameters.MaterialParameters.BlendMode == BLEND_Opaque
			&& Parameters.MaterialParameters.ShadingModels == MSM_DefaultLit
			&& !Parameters.MaterialParameters.bIsUsedWithVirtualHeightfieldMesh;

there was a "!" missing which prevents the shader to be compiled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants