I will showcase two ways to create multiple material slots for your HDAs from Houdini to use in Unreal Engine (using Houdini Engine)
First Way - Unreal Material Node / unreal_material Attribute
Create multiple primitive groups for each set of primitives the different materials need to be applied. These will help us divide the material slots according to different groups.
Tab and drop an unreal material node. The unreal material node is nothing but a pre-configured attribute create node. It creates a string attribute by the name "unreal_material," which is recognized by Unreal as a material assignment.
Create multiple unreal material nodes, as many material slots as you need to have for your HDA in unreal. In each node, add the name of the different primitive groups in the group column. In my example, I need to make three different material slots in Unreal. So I drop three unreal material nodes. I want different material for road, lines, and side_lines, so I replace the group name in each node with the primitive group names.
Now, the important part: In your HDA, create 3 string parameters and then link each of them to their corresponding unreal material node. The string parameters in your HDA will look something like this -
Export this HDA and bring it into an Unreal Engine scene.
Navigate and select a test material from your content browser in Unreal. Right-click and choose "Copy Reference". Then, paste this path to that material in your string parameter that we created in the previous step. Important to note - If the parameter is left empty and it is not pointing towards a valid material in the scene, the multiple material slots will not show up and will not be created. The right way will look something like this -
Thats it! The materials should be applied to the HDA geometry now. One quick way to check if the 3 material slots were created is to go into the Houdini Outputs tab in your HDA, click the dropdown, and if you see the different materials (3 in my case), you did everything right.
You can bake the geometry now, and you will see the different slot materials in the baked geometry.
Second Way - Material node Shop Material Path
Create multiple primitive groups for each set of primitives the different materials need to be applied. These will help us divide the material slots according to different groups.
Create a matnet. Inside the matnet, drop multiple principled shaders. Name them according to each primitive group. (in my case, I will drop 3 different principled shader nodes)
Outside, drop a material-assigned node. Assign each group the corresponding principled shader we created earlier.
Thats it! When you import this HDA in Unreal, after baking, 3 different material slots should show up.
Hey Rahul,
Is is possible to plug materialx shaders too like this?