Download

[Solved] Packaging own global shader failing [4.22.3]

Hi Community,

I am trying to set up a custom global compute shader, basically following along the instructions here: https://docs.unrealengine.com/en-US/…iew/index.html but with a compute shader and code not being in a plugin.
Within the editor and standalone, everything seems to work out fine - I managed to wrap my shader and can use it in a blueprint call.
However, as soon as I package the project, the executable crashes with


Assertion failed: [File:D:\UnrealEngine\Engine\Source\Runtime\Engine\Private\ShaderCompiler\ShaderCompiler.cpp] [Line: 3819] Missing global shader FWriteSliceToTextureShader's permutation 0, Please make sure cooking was successful.

The cooking, however, seems to be fine, with a pretty unambiguous “********** COOK COMMAND COMPLETED **********
UATHelper: Cooking (Windows): BUILD SUCCESSFUL”.
There are some warnings, but they seem unrelated (the BPs in question are not used in the packaged maps):



UATHelper: Cooking (Windows):   LogInit: Display: Warning/Error Summary (Unique only)
UATHelper: Cooking (Windows):   LogInit: Display: -----------------------------------
UATHelper: Cooking (Windows):   LogInit: Display: LogShaders: Warning: Compiled 1 global shaders
UATHelper: Cooking (Windows):   LogInit: Display: LogShaders: Warning: Blocking ProcessAsyncResults for 0.2s, processed 1 shader maps, 0 being compiled
UATHelper: Cooking (Windows):   LogInit: Display: CookResults: Warning: Unable to find package for cooking /Game/01_Planning/Blueprints/MouseKBGameMode
UATHelper: Cooking (Windows):   LogInit: Display: LogCook: Warning: Unable to find package for cooking /Game/01_Planning/Blueprints/MouseKBGameMode
UATHelper: Cooking (Windows):   LogInit: Display: CookResults: Warning: Unable to find package for cooking /Game/VirtualRealityBP/Maps/MotionControllerMap_2
UATHelper: Cooking (Windows):   LogInit: Display: LogCook: Warning: Unable to find package for cooking /Game/VirtualRealityBP/Maps/MotionControllerMap_2
UATHelper: Cooking (Windows):   LogInit: Display: LogEnum: Warning: In asset '/Game/VRIntegrator/Blueprints/BP_VRBasePawn.Default__BP_VRBasePawn_C', there is an enum property of type 'E_VRInteractionMode' with an invalid value of 'E_VRInteractionMode::NewEnumerator2'
UATHelper: Cooking (Windows):   LogInit: Display: LogScript: Warning: Script Msg: Divide by zero: Divide_VectorVector
UATHelper: Cooking (Windows):   LogInit: Display:
UATHelper: Cooking (Windows):   LogInit: Display: Success - 0 error(s), 31 warning(s)


Hereare some potentially relevant code snippets…:



****************************
// GPUImageProcessing.cpp [The module main source file]

void FGPUImageProcessingModule::StartupModule() {
  FString ModuleShaderDir =
      FPaths::Combine(FPaths::GameSourceDir(), TEXT("GPUImageProcessing"), TEXT("Shaders"));
  AddShaderSourceDirectoryMapping(TEXT("/Plugin/GPUImageProcessing"), ModuleShaderDir);
}

void FGPUImageProcessingModule::ShutdownModule() {
}

IMPLEMENT_GAME_MODULE(FGPUImageProcessingModule, GPUImageProcessing);

// ****************************
// VolumeProcessing.cpp
#include "VolumeProcessing.h"

namespace GPUImageProcessing {

IMPLEMENT_SHADER_TYPE(, FWriteSliceToTextureShader,
                      TEXT("/Plugin/GPUImageProcessing/Private/WriteSliceToTextureShader.usf"),
                      TEXT("MainComputeShader"), SF_Compute)
// ...]


My shader file is in [FONT=courier new]<ProjectRoot>/Source/GPUImageProcessing/Shaders/Private/WriteSliceToTextureShader.usf

Does anyone have any idea what’s going wrong?

Cheers!

As it turns out, due to some project rearrangement there was another copy of the FWriteSliceToTextureShader and its WriteSliceToTextureShader.usf file in the project in another module.
This seems to confuse the shader compiler or the UBT, not sure… bottom line, renaming one of them made it work - hope this helps someone else…