Changing Simple custom shader taking 3 minutes to compile on project reload but fast with Ctr+Shft+

Using Engine 4.11, I’ve got a C++ plugin using custom shaders ( modified version of UE4ShaderPluginDemo from Github ) and if I modify one of its shaders in engine\shaders and reload the project, it gets stuck at 95% for almost 3 minutes, then loads and my shader changes work. These are simple shaders and shouldn’t take that long. If I make another change to the shader and hit Ctrl+Shift+Period(.) the shader compiles almost instantly and my changes take effect. If I then reload the project it doesn’t get stuck on 95% and loads quick.

Can anyone explain why it’s taking so long to load, I’ve seen this 95% hitch before, but in this simple case, it’s kind of killing iteration as when we make changes to our plugin and shader, we have to reload the project which is taking forever. Almost like the shader compiler is fighting with the project loader or something if done in different threads.

REPRO

-Enable the “ShaderDevelopmentMode” option in “Engine\Config\ConsoleVariables.ini” to enable the “Ctrl+Shift+.” .
-Restart Unreal editor.
-Download UE4ShaderPluginDemo (
-Load the project ( the shaders in “<project>\shaders” will be copied to “engine\shaders” everytime on load )
-Open both PixelShaderExample.usf files found in “engine\shaders” and “<project>\shaders” )
-Add the line “OutColor = float4( 1, 0, 0, 1 );” at the end of the shader to both “PixelShaderExample.usf files”.
-Reload the project, should get stuck on 95% for 2-3 minutes ( ouch )
-Hit Play, then fire the gun at one of the cubes, it should turn red
-Hit escape
-Now change that last line we added to “OutColor = float4( 0, 1, 0, 1 );” then select anywhere in the viewport and hit Ctrl+Shift+Period(.), it should recompile the shader in 1 second ( yay )
-Hit play again, fire at a box and it should turn green.
-Now that our shader compiled quick, reload the project and notice it loads nice and quick and doesn’t get stuck on 95% and our shader is still working.

Thanks,

I believe Epic is working on a way to only compile a small subset of shaders when a change is made depending on which shaders are modified, but currently it will re-compile all shaders every time, which takes forever I know.

If you open up your Task Manager in Windows while the engine is at 95% loading (or 45%), you should see at least 3 “Shader Compiler” threads plus the UE4 thread maxing out your CPU to compile pre-load. If you have more than 4 cores you will see 1 for each plus the UE4 editor running during this time.

It takes roughly 10min to fully load and compile all shaders when an edit is made on my machine (i5-4670k), so 3 min at 95% sounds about right. Hopefully this will be improved in the future.

Hope that helps somewhat, don’t have a fix for you, but it is not an with your engine version. :slight_smile:

Wow they don’t have any shader cache yet? Pretty sure I’ve tried changing one of the core shader files before ( one included by others ) and it took forever, not 3 minutes, so they must be doing a little caching or something. Should be trivial for them to have a file with at least the last compiled file’s time stamp or even some hash key for the file’s content for the last compile to compare with.

Hope they fix this sooner than later because I’m planning on using unlimited C++ plugins to represent complex rendering which are generated by my NodeFlex software, and as far as I know, the only way to hotload these types of shader plugins are to reload the project each time we iterate on the run-time plugin code and possibly the shader.

Thanks for the reply :wink:

Using Engine 4.11, I’ve got a C++ plugin using custom shaders ( modified version of UE4ShaderPluginDemo from Github ) and if I modify one of its shaders in engine\shaders and reload the project, it gets stuck at 95% for almost 3 minutes, then loads and my shader changes work. These are simple shaders and shouldn’t take that long. If I make another change to the shader and hit Ctrl+Shift+Period(.) the shader compiles almost instantly and my changes take effect. If I then reload the project it doesn’t get stuck on 95% and loads quick.

Can anyone explain why it’s taking so long to load, I’ve seen this 95% hitch before, but in this simple case, it’s kind of killing iteration as when we make changes to our plugin and shader, we have to reload the project which is taking forever. Almost like the shader compiler is fighting with the project loader or something if done in different threads.

REPRO

-Enable the “ShaderDevelopmentMode” option in “Engine\Config\ConsoleVariables.ini” to enable the “Ctrl+Shift+.” .
-Restart Unreal editor.
-Download UE4ShaderPluginDemo (
-Load the project ( the shaders in “<project>\shaders” will be copied to “engine\shaders” everytime on load )
-Open both PixelShaderExample.usf files found in “engine\shaders” and “<project>\shaders” )
-Add the line “OutColor = float4( 1, 0, 0, 1 );” at the end of the shader to both “PixelShaderExample.usf files”.
-Reload the project, should get stuck on 95% for 2-3 minutes ( ouch )
-Hit Play, then fire the gun at one of the cubes, it should turn red
-Hit escape
-Now change that last line we added to “OutColor = float4( 0, 1, 0, 1 );” then select anywhere in the viewport and hit Ctrl+Shift+Period(.), it should recompile the shader in 1 second ( yay )
-Hit play again, fire at a box and it should turn green.
-Now that our shader compiled quick, reload the project and notice it loads nice and quick and doesn’t get stuck on 95% and our shader is still working.

Thanks,

[/QUOTE]

Hi, I followed your instructions.

I uncomment the option in config

; Uncomment to get detailed logs on shader compiles and the opportunity to retry on errors
r.ShaderDevelopmentMode=1

then I followed your instructions. When i press ctrl+shift+. I get the message “recompiling shaders” but then nothing change. I still need to close and re-open the project in order to have the shaders working.

There are some news or solutions?