Easy way to force Compile all Shaders?

So, for…

UE4
4.15.2
MacOS.

Is their an easy way to force an entire folder or the editor to compile all shaders? I want to do some Level Design work (With the Infinity Icelands pack) but, I’m spending way to much of my time waiting on the Editor slowly compiling shaders every time I want to look at a Mesh.

(1) How can I force UE4 to compile all shaders at once, so I can wait for X time for to it ALL to compile, so I can just worry about my Art.

Regards,

Eric

1 Like

Deleting your DerivedDataCache folder of your project should force the editor to compile -> https://forums.unrealengine/showthread.php?1612-How-to-Force-Shader-recompile-of-everything-like-the-first-time-you-run-the-engine

https://docs.unrealengine/latest/INT/Programming/Rendering/ShaderDevelopment/index.html


Shader caching and cooking

Once shaders are compiled, they are stored in the Derived Data Cache. They contain, in their key, a hash of all the inputs to the compile, including shader source files. That means that changes to shader source files are automatically picked up every time you re-launch the engine or do a ‘recompileshaders changed’.

When you are modifying FShader Serialize functions, there is no need to handle backward compatibility, just add a space to a shader file that is included by that shader.

When cooking assets, material shaders are inlined into the material’s package, and global shaders are stored seperately in a global shader file which allows them to be loaded early in the engine startup.

The only “DerivedDataCache” folder I can find is in my…
HDD > Users > Shared > Epic Games > UE_4.15 > Engine
Deleting that did force UE4 to compile “some” shaders, but not the ones I wanted in my Infinity Icelands pack, as the Static Meshes still need their shaders compiled.

Going to my project folder…
HDD > Users > MyUserName > Documents > Unreal Projects > LevelDesign_01
Shows no “DerivedDataCache”…

Looking on google for where the heck this folder is located is also very vague. Am I deleting the correct folder?

You can put all of the meshes in the level (or some level) and UE4 should compile shaders for all of them.

Looks like the answer is:

“You can fill your DDCs at any time by running the following command:
UE4\Engine\Binaries\Win64\UE4Editor.exe ProjectName -run=DerivedDataCache -fill
Epic Games does this on a nightly basis to ensure that the DDC is always primed”

That is not merely shaders though but all derived data, regardless a ‘primed’ DDC should ensure that editor load times are unhindered.

2 Likes

I know this is old but just in case you want to do what OP asked: just use content browser in UE4, go to the folder, select all meshes and press right click. Wait for it to finish and the shaders will be compiled. This is the same as dragging all of them to the scene, as cyaoeu said, but I guess easier so you don’t have to delete them later (and easier if you have dynamic lightning and such)

6 Likes

This is great. I also used the filters to select all "Material"s, and it compiled a few other shaders. Probably ones used by particles systems and other things not related to meshes.

1 Like

Ho yeah, right on my friend. All fixed now! I can’t believe I did not think about that haha. So use to open the demo map for project that I forget about this.

Thanks

Not sure what works or doesn’t anymore. The rebuild of DDC didn’t help me with rebuilding shaders for running in a “standalone game”, and that cache doesn’t seem to stay after you close the window. What worked for me was filtering at the “All” folder level for “material”, then selecting all materials, right clicking on them and selecting save. It builds shaders for each one as it saves them.

I also tried: r.ShaderCompiler.JobCacheDDC=1
I thought it worked once, but then I was right back to 12k shaders compiling, so not sure what happened. But the right click and save thing seems to be working so far.

1 Like

[Solution]

  1. Click on content folder in content browser.
  2. Turn on filters for: Materials, static mesh, niagara effect, textures.
  3. Select all with Ctrl+A
  4. Right Click → Now compiling start.
  5. Done.

I just add few big project with assets, and now compile everything at once. Thanks! :grinning: