Shader expected a uniform buffer

Hi.

I’m modifying a popular story game (this is not creating cheats and everything is “with the permission of the developers”, so it’s okay). The game runs on Unreal Engine 4.26.

I needed to create my own material. But when I set it to static mesh, the engine crashes. I did my research and found out where the crash occurred.

It happens on this line:
https://github.com/EpicGames/UnrealEngine/blob/4.26/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11Commands.cpp#L1589

The pointer to the Buffer is nullptr.

In the latest version of Unreal Engine:
https://github.com/EpicGames/UnrealEngine/blob/cdaec5b33ea5d332e51eee4e4866495c90442122/Engine/Source/Runtime/Windows/D3D11RHI/Private/D3D11Commands.cpp#L1467

This “crash” has been “fixed”. So you can imagine that the game did not “crash”, but gave me this error:

Shader expected a uniform buffer at slot %u but got null instead (Shader='%s' UB='%s').  Rendering code needs to set a valid uniform buffer for this slot.

I don’t really understand why this is happening. The game runs on the same version of the engine on which I create the material. I also copied all the settings “DefaultEngine.ini”, “DefaultGame.ini” etc. from the game’s .pak into my empty project. I also copied the properties from the “base material” from the .pak of the game (I viewed it with the FModel) into my material.

My material looks like this:

I tried to do an interesting thing. I patched (with reverse-engineering) the code to look like this:

if (!Buffer) return 0;

The game has stopped crashing. And the material is normally displayed on the static mesh. But for me this is not a “normal solution”, the problem is clearly in some engine or material setting that I missed.

I also tried exporting the base material from the game’s .pak and opening it in the editor to then set it as the base material for my materials. But it didn’t work for me. The engine works very poorly with “cooked” assets and the editor keeps crashing.

Perhaps someone has already encountered this or can tell me which way I should continue researching the game to fix this problem.

Any help would be appreciated. Thanks!

Hi, I have a similar issue on 5.3, as soon as I am trying to draw additive material into the render target, for example as in this famous tutorial: https://youtu.be/67z5u8ZcEcw?t=1049

As soon as I change my brush material to be additive, I have the same crash.
I have forward shading activated, but I can’t tell if that could be a reason.

UPD: It seems crash is gone when I changed my brush material settings to Unlit (which is quite a logical fix, and I don’t know why it took me a whole day to understand :slight_smile: )

Hey so I had a similar issue related to this with my landscape. Where the uniform buffer slot 1 was being assigned to something else over landscape parameters. I resolved it by unchecking the custom depth flag under rendering

1 Like