MeshMaterialShader Issue When Using Texture in Material

I’m trying to create a custom shader that can essentially render a material. I’m currently following Shadeup’s tutorial on the subject - Material graph to render target via compute in UE5 | Compute | Shadeup

It works fine if the material uses a solid colour but as soon as you bring in a texture it throws “Missing uniform buffer at slot 0, stage SF_Compute. Please check the high level drawing code.”

I would have thought that I just need to add a SHADER_PARAMETER_RDG_TEXTURE(Texture2D, …)
to my shader parameters or something similar but there’s no suggestion on a name or anything.

How do I fix this?

Of course I figured it out like 30 minutes after asking for help.

So when you include a texture in the material, you need to add the following into the shader parameters

SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, View)

and then set it with something similar to this with PassParameters being the parameters for the shader

FViewUniformShaderParameters ViewUniformShaderParameters;

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

The shader no longer crashes the engine but I do have another issue to fix

1 Like