Hi,
so I want to create a custom material node. But because the logic of this custom node is a bit more complex and lengthy, working with the small editor is really uncomfortable. Now my question. There are these files called Unreal Shader Header/File. I already included them via the “Include File Paths” section. But how exactly do I use them now? Can this file be the logic of the whole node? What include statements are necessary inside the files? Any links to documentation or tutorials would be really beneficial!
Note: I use Unreal Engine 5.1
Section where I included the shader files
Fortunately, I just finished this a few weeks ago, so I can share some of my experience. The entire custom node looks like sth like this↓
ReturnType CustomExpression(Parameters)
{
//codes you input in custom node -> code
//start
//
//end
}
The entire codes you enter are included in a function body. It means that you can only affect the middle part between ‘start’ and ‘end’. You can’t define the function either. Here’s a strange way to define functions. Add extra { } , just like
ReturnType CustomExpression(Parameters)
{
//codes you input in custom node -> code
//start
//
} //add}
void Func()
{ //add{
//end
}
I don’t recommend it because this needs at least 2 custom nodes. One of them should declare your func first. What’s more, you already have the ‘Include File Paths’.
Just like its name ‘ush’, ‘header’ files are always used to function definition, macro. So, you can put func in a ush file. Finally, you only need to enter a short piece of code into custom node → code and use the function you defined in .ush.
Now I can answer the question
Can this file be the logic of the whole node?
Not exactly, in my opinion, custom node looks like the main function of a program (you can’t define function in it), but if you finish all of your logic in a function, you can enter codes in custom node → code like this
return func();