There’s a solution that works without Visual Studio and C++.
I test it in two projects in 5.6.
Here are the steps:
-
Close your unreal project.
-
In the root folder of your project, create a folder called “Shaders.”
(Example: /YourProject/Shaders) -
Create shader file “MyLib.usf” in that folder .
(Like this: /YourProject/Shaders/MyLib.usf) -
Open “MyLib.usf” file and put this code inside:
struct MyFunc
{
float3 Go()
{
return float3(1, 0.2, 0);
}
}; -
Save MyLib.usf file
-
Open your unreal project.
-
Create Custom node in one of your materials and attach it to the “Base Color” input of your material.
-
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) -
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.