It is not really documented clearly.
If you are using a custom HLSL node in a material graph blue print…
Your HLSL code is copied into ANOTHER generated HLSL code module, this is done because some boiler plate code is needed so that you don’t have to deal with that mess yourself…
A temporary “Material.ush” file gets auto generated for every custom HLSL node you make. And your code is inserted into it.
For you to use functions you have to wrap the functions into a struct. Like this…
PLACE YOUR Custom Functions INTO THIS STRUCTURE
struct CustomFunctions // ANY NAME IS SUITABLE
{
// PLACE ANY OTHER "GLOBAL" VARIABLES HERE
// PLACE ANY OTHER FUNCTIONS HERE AS WELL
float AVariable1;
float2 AVariable2; // etc...
void Foo1()
{
......code ...
}
void Foo2()
{
......code ...
}
// etc etc etc
float4 main(***your params***)
{
return fragColor;
}
};
// THIS PART BELOW IS *NOT* WRAPPED INTO THE ABOVE STRUCT
CustomFunctions CF;
float4 fragColor = CF.main(* named inputs to your shader *);
return fragColor;
If your custom node had these 3 named input slots…
Then you could call your main function like this…
float4 fragColor = CF.main(UV, Timer, BufferA);