Search - User list
Full Version: Trying to use Material Instances and Material Instance Parameters
Root » Houdini Engine for Unreal » Trying to use Material Instances and Material Instance Parameters
Hey guys,

I am trying to get a setup working with dynamic material instancing as described in this: []

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: []
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
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.

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.

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.
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.
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.
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.
nothing solution? the problem same to me
Will also like to know...
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

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB