How to make a large material

Hi. I have a material which renders the sky by a sun position (see the first screenshot below). But the material too big and it has some mess inside (see the second screenshot below). It’s happened because the material needs ‘for’-cycles. Are there any approaches to avoid this mess?

This example is very expensive, but it shows how you can use for loops in custom nodes, and how you can call custom nodes from other custom nodes. To find the number of the custom node you want to reference, open the HLSL code copy and paste it into a text program or IDE, and search for CustomExpression until you find the one with the code you want to call.

and also good idea is to write own shaders system. this is old example but it helped me GitHub - Temaran/UE4ShaderPluginDemo at 4.7