Material expression custom - relative Include File Path?

There’s a solution that works without Visual Studio and C++.
I test it in two projects in 5.6.

Here are the steps:

  1. Close your unreal project.

  2. In the root folder of your project, create a folder called “Shaders.”
    (Example: /YourProject/Shaders)

  3. Create shader file “MyLib.usf” in that folder .
    (Like this: /YourProject/Shaders/MyLib.usf)

  4. Open “MyLib.usf” file and put this code inside:
    struct MyFunc
    {
    float3 Go()
    {
    return float3(1, 0.2, 0);
    }
    };

  5. Save MyLib.usf file

  6. Open your unreal project.

  7. Create Custom node in one of your materials and attach it to the “Base Color” input of your material.

  8. Add new “Include File Path” Element in Custom Node properties and type in this text:
    /Project/MyLib.usf
    as value and press enter.
    (Attention! I know, it does look weird because you probably expect it to be “/Shaders/..” or something, do not worry, just continue)

  9. Click inside of the code field of your Custom Node and type in this hlsl code:
    MyFunc f;
    return f.Go();

After those steps shader will compile and you will see orange material.