How to compile Engine shaders with script (outside the editor)

Currently messing around with Shaders\Private\GpuSkinCacheComputeShader.usf

Ideally I’d like to first do a quick compile of the shaders without having to load the editor to check for basic compilation errors and then proceed to open the editor to debug the algorithm itself. Is there a way to do this?

Currently when the shader compilation fails on silly syntax errors it crashes the editor. Maybe there is a way to not crash the editor when doing RecompileShaders Changed in the console?

What’s your optimal workflow when tinkering with Engine shaders?

You can manually compile your unreal shaders by doing the following, uncomment the following line:

UnrealSourceRootFolder\Engine\Config\ConsolesVariables.ini
r.DumpShaderDebugInfo=1

When launching the editor and compiling shaders (use: ‘RecompileShaders all’ in the editor’s console) this will dump text files of your shaders along with a .bat script to compile that shaders, just go to the ‘Save’ folder for instance:

D:\UE4\Samples\Games\TappyChicken\Saved\ShaderDebugInfo\PCD3D_SM5\M_Egg\FLocalVertexFactory\TBasePassPSFNoLightMapPolicy\

The text file are your shaders after applying the preprocessor, i.e. it’s a single text file with all the #defines and #includes replaced.

Bonus: if you’d like the editor to ask you to re-attempt to compile shaders when shader compilation fails (instead of crashing like with default options) uncomment the following line:

    r.ShaderDevelopmentMode=1
     UnrealSourceRootFolder\Engine\Config\ConsolesVariables.ini

Now a window with the compilation error of your shader and whether you want to attempt compilation again will appear.

There’s more doc about debbuging shaders here: