Instancer custom data

   4377   11   1
User Avatar
Member
47 posts
Joined: 3月 2014
Offline
Hi. Since 4.25 there is a feature to add custom float data per instance. Each instance can have several custom float attributes - these attributes can be accessed in shaders and blueprints and are super useful.
I think it would be nice to have ability to export them from Houdini as per-point/packed primitive attributes. Have some sort of naming convention - like "unreal_cdata_N" and export those to Unreal.
User Avatar
スタッフ
534 posts
Joined: 9月 2016
Offline
Hi,

Support for per-instance custom data has been added to the v2 plugin in Houdini 18.5.521:

The number of custom floats per instance can be set via the "unreal_num_custom_floats" attribute.
The custom data itself can be set on the instances via the "unreal_per_instance_custom_dataX" attributes, where X is the zero-based index of the custom float data.
User Avatar
Member
47 posts
Joined: 3月 2014
Offline
Fantastic! Thank You!
User Avatar
Member
38 posts
Joined: 2月 2018
Offline
Hello, How do I read these custom data into a shader in Unreal?

Ok found it, there is a PerInstanceCustomData node in the material editor.

Btw Unreal will crash if the Houdini attribute indexing doesn't start at 0, as mentioned above.
Edited by Eche - 2021年9月10日 00:10:36
User Avatar
Member
18 posts
Joined: 11月 2015
Offline
Can somebody help me with this setup? I can't get this to work. I want to assign a random color to my instances. I'm using the attribute instancer with the unreal_instance attr. set on my points. Then I add an unreal_num_custom_floats integer attribute set to 3 and then three float attributes unreal_per_instance_custom_data0,1,2 set to different values.
Inside Unreal I'm using PerInstanceCustomData in my material assigned to the object I'm instancing. But apparently it doesn't contain any values, it's always black. Any help would be greatly appreciated!
User Avatar
Member
18 posts
Joined: 11月 2015
Offline
No one? Or is the question too confusing
User Avatar
Member
710 posts
Joined: 7月 2005
Online
Hey Kasierlicht, I know I had this working. I will try to doublecheck this weekend and post the setup.
User Avatar
Member
18 posts
Joined: 11月 2015
Offline
Awesome, thank you!
User Avatar
Member
710 posts
Joined: 7月 2005
Online
I have attached a little sample hda. It scatters some cubes onto points with the unreal_num_custom_floats and unreal_per_instance_custom_dataX attributes. In Unreal you apply a material to this asset that uses the PerInstanceCustomData nodes passed through a VertexInterpolator. This setup also works fine if you skip the Copy to Points bit in Houdini and use the unreal_instance attribute like you are doing.
Let me know if you have any questions.

Attachments:
UE4Editor_f6eCbOCEGl.jpg (782.5 KB)
instance_custom_data.hdalc (21.0 KB)

User Avatar
Member
18 posts
Joined: 11月 2015
Offline
Thanks again for the effort! I'm starting to feel stupid but I still can't get this to work. I apply my material to the "static mesh (instanced)" output of my instancer, correct? I had to rebuild your hda because engine won't allow me to import indie assets with a fx license. Can you try if the attached asset works for you?

Attachments:
instancer_problem.JPG (537.9 KB)
instancer_custom_data.hda (19.0 KB)

User Avatar
Member
18 posts
Joined: 11月 2015
Offline
Oh dear, forget about it. I was on 18.5.499 all the time. Sorry for being stupid, and thanks again for the help
User Avatar
Member
710 posts
Joined: 7月 2005
Online
No worries, I'm glad it's sorted out!
  • Quick Links