Unity to Unreal Material and Shader logic

Hi, first post here. I am moving from Unity to Unreal. I can create shaders by coding or by using graph editors etc.

The first problem I am facing, it is hard to understand a default pipeline of how to work with Materials in Unreal.

My use case: I need to create custom Uber shader, where I have many texture and variable inputs. Then I need to use this shader on the whole game level, as I need to control all materials via code- they have the same input fields, so it is easy, to lets say, to change colour of everything in the level.

In Unity that would be creating a shader via code or Graph Editor. Then I can create as many materials as I want and use that shader. I can also change any Material to use that shader. The later, is actually what I need at this point - I am importing many models and I want to assign that “shader” to all materials that were imported automatically with each model.

My problem is that I do not know how to do it. It seems in Unreal that every material is it’s own instance? It would take too long to open material editor, then create common logic (or copy paste) from the main material. Can I assign let’s say main material logic, which has all parameters I need to every individual material that was imported automatically via fbx? Also, when I “assign” that main logic to every material, can it be easier than opening every individual material? - Lets say I have ~1000 materials and I need to do it to every material.

In Unity that would be a single mouse click - changing a shader on selected materials.

P.s. I watched many tutorials at this point, and non covers this simple thing. Thank you.

You can make a master material that has every variable and texture you need, convert them to parameters and then create for every new material you need a new material instance of your master material where you change the texture and variables accordingly. another way of doing this is adding “RenderCore” as a private dependency module to your project’s build.cs and changing the “.h” like this
Screenshot_20221110_193046
and changing the .cpp like this


after that, you can use the custom node in the material graph to include HLSL code via “.usf” and “.ush” files that you placed in the in this example “Shaders” folder, you include the “.usf” and “.ush” files with #include "/<ProjectName>/<FileName>.<usf or ush> return 0;, you still need to add every texture and variable you want as an input to the custom node, important is that the input on the node has the same name as the variable in HLSL and the same goes for outputs, but please don’t ask me what the standard output of the custom node does.

2 Likes