Landscape material question

I am in process of making terrain material and I’ve ran into several issues.
Firstly, landscape shader takes ages to compile,several hours for terrain with 16 components.
Secondly, unless I unplug tesselation and displacement pins, I get an error about compiled shader being longer than 32768 lines.

This is how my landscape layer material function looks like:

Then I blend 18 of them in main material:

Part of the blend function, it is repeated for all 18 layers:

Normally I would not expect its compilation time taking that long. Is there anything I am doing dead wrong for this kind of material?
I would be really grateful for any kind of help.

Landscape material compilation take a long time that’s “normal”. Instead of using a layer switch you can use a Layer Sample I believe. Plus you can use HeightLerp to produce good looking blend based on Heightmaps.