Shaders keep compiling endlessly

I haven’t converted my project yet to 12, but considering this problem existed in all prior versions I assume it’s still there.

The problem I have is Compiling. Compiling, and more compiling. It starts when I open any level I made (especially when the level has a terrain or foliage in it) UE4 needs to compile about 5000 - 8000 shaders and takes roughly an hour before it’s done doing so. In the meantime, the scene is rendered useless because all objects are gray and the lighting looks off so I can only start working after this has been completed.

Then it becomes more annoying when I am finally able to paint on any landscape I made. Every time I paint a new layer on a new terrain tile, it again needs to compile about 400 - 1500 shaders. Taking about 10 minutes per layer and while it’s doing so, the tile I’m painting on is again rendered gray until the compiling is done. These tiles are about 10 x 10 meters if not smaller and I’m working on a terrain with the size of about 2 x 2 kilometers. That means if I wanted to paint just one layer on the entire terrain I need to wait more than 600 hours, or almost a month.
And then I have about 8 layers. I can watch my kids grow by the time the compiling is done, and I don’t even have kids.

So about 80% of my time spent in the UE4 editor is wasted on waiting for shaders to compile. It really ruins the workflow not to mention my motivation or creativity and I doubt other people are fine developing this way.

Does anyone know what I’m doing wrong here? I’m using the Landscape AutoMaterial asset for most painting and my scenes aren’t that complex. The issue extends to regular terrain painting as well and foliage assets.
I figure there must be some way to have all shaders compile just one time and not after every single change or load.

I already contacted the author of the LAM asset but the conclusion was that it was normal. How could one properly design a terrain with so many interruptions?

Any help is really appreciated.

Hello Mr Robville,

This is completely out of my area of expertise as I’m not knowledgeable in how shaders are compiled, but I’m moving your post to the Rendering section as you’re more likely to get a response to this there.

Oops I must have put it in the wrong field, my apologies! Thanks for putting this question in the right area.

To put things more visually, this is pretty much what I’m looking at 80% of the time.
I simply applied a new layer to a bunch of tiles, and off I go to have some dinner. If this was an isolated shader compilation I would have simply done a quick brush over the entire landscape with all layers to have all shaders compile in one go and start properly painting the landscape once that’s done after a month, which is tedious but doable, but every time I open the map it needs to compile the shaders again.

The problem is not isolated to a single (possibly corrupted) project. This screenshot is from a quick test map in which I imported a heightmap. Say if this were a fully detailed island with vegetation and everything, I’d have to wait hours for it to load up if this already takes so much time. This can’t be right.

Anyone any ideas?

You should not have a shader recompile on every load or edit. Landscape recompile will happen when you add or remove a layer from terrain component and only if there is no corresponding shader variation exists for given layer combination. Landscape shader compile times will grow significantly with every terrain layer you have in material. From my experience, anything above 12 is impractical in terms of editing terrain. I haven’t worked with LAM, but i’d expect its shaders initial compile to take roughly 10-15 minutes on medium hardware. As a side note, enabling tessellation on landscape materials seems to increase compile times roughly by a factor of 2, for me at least.

But yeah, as I said, you should not have any kind of recompile when loading map. Ensure that nothing is stopping UE4 to properly save Derived Data Cache. It could be the reason why you are getting recompiles on every load.

Thanks a lot for your reply. I believe LAM uses more than 12 layers. Some of which use Tessellation. I haven’t checked UE’s ability to properly write data yet. Thanks for the tip.
I’ll also try making a simple landscape material myself to see how it performs compared to LAM. Maybe it’s possible to paint the entire landscape using very basic shaders and once I consider the terrain ready enough I then add all the effects I want and wait for the whole compilation process afterwards.

as-tu trouvé le problème ?