Trying to use Material Instances and Material Instance Parameters

   9434   9   2
User Avatar
Member
34 posts
Joined: 11月 2007
Offline
Hey guys,

I am trying to get a setup working with dynamic material instancing as described in this: http://www.sidefx.com/docs/unreal/_materials.html#MaterialsInstances [www.sidefx.com]

I setup a simple example scene with a grid and box copied onto the points. I want each box to have a different material instance with a different diffuse color. All the points have a “unreal_material_instance” parameter pointing at the same existing unreal base material. Each point has a different color value which I put into both “Cd” (to visualize in houdini) and “unreal_material_parameter_diffuse”. The boxes are packed and copied with a copy to point and the unreal values are moved to prim values on the final output.

I can't seem to get this to work properly in unreal. The first time I did it, it successfully made one instance material in “HoudiniEngine/Temp” that seemed to get the diffuse color from point 0, but it applied to all the boxes. I changed the color on all the boxes to red just to see if it was listening to the color and resaved my hda. Upon reloading it, it seems to have stopped listening all together and just assigns a default material. I deleted the hda and the temp instance material and reimported the hda, but that didn't change the behavior.

Is it supposed to work in the scenario I am showing? I am a little fuzzy on what logic might be happening with the prim attributes coming from the copy as the boxes are packed (packed so unreal sees them as instances). I tried a variation on this with the object level instancing node, but that had the same outcome and I wasn't sure if my unreal attrs were even making it on the instances.

Am I doing something wrong? Should my example be working? It would be great if I could get this to work!

I looked at: https://www.sidefx.com/forum/topic/53354/ [www.sidefx.com]
But that scenario is a bit different than mine (multiple materials on one object).

Thanks ahead of time for any help.

ps. I played with that new unreal_split_instances option. It's great and I know that gets the desired result, but splitting the instances on the scale I am working with causes a large perf hit. I basically I want the functionality the “unreal_material” parameter gives you with the added bonus of creating the instance materials automatically based on parameter changes the way the documentation describes “unreal_material_instance” and “unreal_material_parameter_xxxx” functioning.

Houdini Indie 16.5.496 and Unreal Engine 4.19.2

Attachments:
Houdini.JPG (1.0 MB)
Unreal.JPG (612.8 KB)
Unreal_material.JPG (306.1 KB)
test.hdalc (31.9 KB)
Material_Instance_UnrealProject.zip (2.3 MB)

User Avatar
Member
453 posts
Joined: 2月 2013
Offline
If I am not mistaken, Unreal instances do not support individual (vertex-)colors. They also take only one material per material slot on an instanced mesh. In other words, there are no dynamic material instances on instances in Unreal.
What you can do is in the Unreal material get a “PerInstanceRandom” node. This should give you a different random float value for each instance. The upside is that it should work, the downside is that you cannot exactly control the outcome.

I think you can also build some shaderlogic in Unreal based on worldspace location of an object (and I think this can be made to work for instances, but I am not certain). This could certainly be made to work by using vertex or pixel world-space position.
User Avatar
Member
34 posts
Joined: 11月 2007
Offline
Hey DASD!

Thanks for the reply, but I am not actually trying to put different vertex colors on the instances. I am just displaying that in houdini to visualize what is going into the “unreal_material_parameter_diffuse“ prim attribute that I am feeding into unreal.

But you are right about the material, I think I mistakenly thought you could apply a different material per instance via ”unreal_material". Seems not to be the case with some testing. I think I tested it before switching my geo to instances. So I thought I would be able to apply a bunch of different instance materials using the “unreal_material_instance” and “unreal_material_parameter_xxxx” methodology. But since it seems you can't have a different mat per instance… so that won't work.

Thanks again I will come up with a different workflow for it.

-bk
User Avatar
Member
603 posts
Joined: 9月 2016
Offline
Another option for getting material variation for geometry instances is to use the unreal_instance_color and unreal_split_instances attributes. This will convert geo instances in houdini to actor-level ‘instances’ which have a controllable color you can use in your material.
User Avatar
Member
34 posts
Joined: 11月 2007
Offline
Thanks chrisgreb!, but as I said at the end of my original post “unreal_split_instances” causes a huge perf hit. Which is why I was trying to come up with a different way.
User Avatar
Member
34 posts
Joined: 11月 2007
Offline
chrisgreb -

The workflow I was hoping for would be to make a bunch of instances on the houdini side, point at an unreal material with “unreal_material_instance” and change some parameters with “unreal_material_parameter_xxxx” and houdini engine would create material instances based on the parameter tweaks (like it does outside of this instance case) and then grouped the instances together into InstancedStaticMeshComponents on the unreal side based on which material they get assigned.

I will split it on the houdini side into separate instance nodes and unreal materials to achieve it, but would just save setup time and be more flexible with changes on the houdini side to have it happen dynamically.
User Avatar
Member
603 posts
Joined: 9月 2016
Offline
That makes sense - it would probably make a good RFE. I wonder if one could make a generic HDA that could do that splitting and bookkeeping of attributes on the Houdini side.
User Avatar
Member
10 posts
Joined: 3月 2017
Offline
nothing solution? the problem same to me
User Avatar
Member
255 posts
Joined: 9月 2012
Offline
Will also like to know...
Vincent Thomas   (VFX and Art since 1998)
Senior Env and Lighting  artist & Houdini generalist & Creative Concepts
http://fr.linkedin.com/in/vincentthomas [fr.linkedin.com]
User Avatar
Member
17 posts
Joined: 5月 2021
Offline
In Unreal, the instances share the same vertex data. This is why you can't, for example, vertex paint instances in unreal.

If the goal is to provide some color variation to the instances, the best route is as DASD mentioned above. You can attach PerInstanceData for the color and use that in the material.

To transfer the data from unreal, use unreal_per_instance_custom_dataX.

Hope this helps

Thanks
Bob
  • Quick Links