HDA Unreal Material Instancing Texture Override

   4089   5   1
User Avatar
Member
8 posts
Joined: Sept. 2018
Offline
I have an HDA with geometry and a principled shader that has a basecolor texture. I would like to take that HDA and generate an instance of a master material in UE that will override the texture sample parameter based on the basecolor_texture parameter on my principled shader.
I can get HDA to override the texture sample parameter when in my HDA I am telling Unreal to use an existing texture that is inside Unreal's content browser. I can override master material's base color when using a vector parameter and specifying vector values in houdini using “unreal_material_parameter_” prefix. However, I cannot do what I really want: to override a texture sample parameter in the master material using the basecolor_texture parameter in the principled shader.
For the unreal_material_parameter_mytexture I have tried setting a string prim attribute to:
`chs(“../matnet1/principledshader1/basecolor_texture”)` or basecolor_texture
as the documentation suggests https://www.sidefx.com/docs/unreal/_materials.html#MaterialsInstancesParameter [www.sidefx.com] but neither options work.
Any tips on what may be wrong with this set up?
I am using: Houdini 17.0.352 / 17.0.416 + Engine, Unreal Engine 4.20.3

EDIT: It turned out that “basecolor” attribute value was added only in version 17.0.430. Thanks dpernuit for clarification!
Edited by anon_user_53621866 - Feb. 4, 2019 12:48:30

Attachments:
1_hou_mycolor.PNG (82.0 KB)
2_ue_mycolor_mat.PNG (143.0 KB)
3_ue_mycolor_viewport.PNG (1.3 MB)
4_hou_mytexture_network.PNG (89.3 KB)
5_hou_mytexture_attributes.PNG (83.6 KB)
6_hou_material_network.PNG (26.3 KB)
7_ue_mytexture_mat.PNG (140.9 KB)
8_ue_mytexture_viewport.PNG (1.5 MB)

User Avatar
Staff
534 posts
Joined: Sept. 2016
Offline
Hi,

There is a couple things that are important when trying to override material parameters:

- for textures, if you aim to use textures from Houdini, you need to assign the material to your object.
This ensure that when your mesh is generated, the unreal plugin sees the houdini material on it, creates its unreal counterpart and the corresponding textures.

- the unreal_material_instance attribute then overrides it, creating a new material instance from an existing unreal material instance.

- the material instance parameters can then be replaced via the unreal_material_parameter_ attributes.
for texture, there is two ways you can point this attribute to the corresponding channel in the houdini material:

If your HDA generates only one material, then you can simply set the attribute to the name of the channel you want to use (basecolor, normal, roughness etc…) the plugin will then find the corresponding texture that was generated when the houdini material was converted to an unreal one.

If your HDA generates multiple materials, then you can set the attribute to the path to the channel that you want to use.
For example, in your case, to use the base color texture, the attribute needs to be pointed to the principled shader's parameter that is assigned the texture, not the texture's source file.
try removing the “chs”, and just use “../matnet1/principled_shader1/basecolor_texture”.

EDIT: I'm actually wrong here, the attribute should be set to the relative path from the HDA's node to the material (matnet1/principledshader1) + the channel to use (basecolor), so “matnet1/principled_shader1/basecolor”

or since that HDA only creates one material, just specifying the channel should be enough, “basecolor”
Edited by dpernuit - Jan. 30, 2019 11:58:16
User Avatar
Member
8 posts
Joined: Sept. 2018
Offline
Thank you for your response! For some reason I still cannot get the textures outputting no matter what I put in the “unreal_material_parameter_” string. Could you please take a look at the scene?

Attachments:
ue_material_hda.zip (3.4 MB)

User Avatar
Staff
534 posts
Joined: Sept. 2016
Offline
Hi again,

I had a quick look at your HDA, will try to double check everything with the project tomorrow…
I know this part can be a little confusing, as these attributes are actually not referencing the principled shader's parameters or source texture files, but are helping the plugin to know which channel / unreal texture to use. From the docs:

First, if your asset generates only one material, you can simply set the attribute to the material channel you want to use (basecolor (or diffuse), normal, specular, roughness, emissive, metallic, opacitymask.. ) If your assets generates multiple materials, then you need to add the relative path to the SHOP node (or principled shader node) that generates the material before the desired channel. ( for example “testgeometry_squab1/shopnet1/SquabSkin/diffuse” ). Please note that this path is relative to your asset node.

What this means, is, your first need to decide what channel of the material you want to use: basecolor, normal etc….

If your asset generates only one material when imported into unreal, you can simply set the attribute to that channel's name.
That's your case, so if you want to use your material's basecolor texture, simply set the attribute to: basecolor

basecolor_texture is the name of the parameter in Houdini, but Unreal/Houdini Engine wont know about that.
However, it knows that it had generated a material for your asset, and that material had a basecolor channel, and it created a texture for that channel.

If your asset generates multiple materials, then you need to also tell the plugin which material you're refering to.
And as specified in the docs, the path is relative to your asset node, not the attribute create node.

in your case, the material's path relative to the asset is:
matnet1/principledshader1

you then append the material channel you want to use, in your case, basecolor:
matnet1/principledshader1/basecolor

The plugin knows that it had generated a material from “matnet1/principledshader1”, and you're telling it to use the texture that was created with that material.
User Avatar
Member
8 posts
Joined: Sept. 2018
Offline
Thank you, unfortunately I'm still stuck with the issue. I'm sure you're getting my problem right but I would like to clarify clarify exactly what part of material generation I am having problems with, just in case this helps you.

When there are no existing native Unreal materials in the Unreal level/content browser and I am trying to generate an Unreal material based on the principledshader I have in my HDA, the Unreal material generation goes just fine. However in this case I already have a master material in Unreal with some parameters exposed such as “mytexture” texture sampler. What I would like to do is to generate a material instance of that master Unreal material that would have the “mytexture” texture sampler parameter of the Unreal material overriden based on the texture in matnet1/principledshader1/basecolor_texture inside my HDA. If I then import a second HDA that has a a different principled shader with a different principled texture, I still want it to generate a material instance from the existing Unreal master material, so in my scene I would have say one M_Master and two M_Master_instance_XXXXXXXXX generated by HDAs.

When Houdini Engine generates the material that recreates principledshader it correctly also generates the texture in Game/HoudiniEngine/Temp. However it does not assign that generated texture to the instance of the unreal's master material automatically, which is what I would like to get. Just as a sanity check, in the same HDA I tried creating a primitive Attribute Create called unreal_material_parameter_mymetal with the float value and in my instance of the master unreal material the parameter “mymetal” controlling Metallic gets overriden correctly. Let me know if you need any clarifications regarding my issue or if you are able to reproduce the issue.
User Avatar
Member
8 posts
Joined: Sept. 2018
Offline
Figured out a solution to this. Rather than using “basecolor” or “matnet1/principledshader1/basecolor” the s@unreal_material_parameter_uesamplernamehere primitive attribute should be “diffuse” or “matnet1/principledshader1/diffuse”. I'm still going to be working on testing the HDA material instancing workflow in the near future so I may update this thread if I find additional problems.

EDIT: It turned out that “basecolor” attribute value was added only in version 17.0.430. Thanks dpernuit for clarification!
Edited by anon_user_53621866 - Feb. 4, 2019 12:48:14
  • Quick Links