Trying to use Material Instances and Material Instance Parameters
8640 9 2-
- briankulig
- Member
- 32 posts
- Joined: Nov. 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
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
-
- DASD
- Member
- 453 posts
- Joined: Feb. 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.
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.
-
- briankulig
- Member
- 32 posts
- Joined: Nov. 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
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
-
- chrisgreb
- Member
- 603 posts
- Joined: Sept. 2016
- Offline
-
- briankulig
- Member
- 32 posts
- Joined: Nov. 2007
- Offline
-
- briankulig
- Member
- 32 posts
- Joined: Nov. 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.
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.
-
- chrisgreb
- Member
- 603 posts
- Joined: Sept. 2016
- Offline
-
- popple
- Member
- 10 posts
- Joined: March 2017
- Offline
-
- vinyvince
- Member
- 249 posts
- Joined: Sept. 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]
Senior Env and Lighting artist & Houdini generalist & Creative Concepts
http://fr.linkedin.com/in/vincentthomas [fr.linkedin.com]
-
- Bob_Cober
- Staff
- 17 posts
- Joined: May 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
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