On this page |
Input ¶
You can import instancers to Houdini when you select the Actor with the Instanced Static Mesh ComponentThe instanced mesh is imported as a packed primitive, copied on each of the instanced points.
Each material used for the instances will have a corresponding attribute named unreal_materialINDEX
where INDEX
is the index of the corresponding material’s slot. The value will be the Unreal path to that material.
Foliage instances can be imported in a similar way, and will have the unreal_foliage attribute
set.
Alternatively, you can import a Static Mesh as a single attribute instance when checking the Import as reference checkbox.
Output ¶
The plug-in supports outputting instances from an asset using packed primiitives, object instancers, or attribute instancers.
Instanced geometries in Unreal are InstancedStaticMeshComponents
by default or HierarchicalInstancedStaticMeshComponents
if the geometry instanced has multiple LODs. If you want to force the creation of HierarchicalInstancedStaticMeshComponents
, even without LODs, you can add the unreal_hierarchical_instancer
attribute and set its value to 1.
Instanced geometry or uassets
appear as instancers in the Houdini Outputs section of the Detail Panel, as shown below:
Point attributes can be added to specify material overrides for the instanced meshes. Create an attribute named unreal_materialINDEX
where INDEX
represents the material slot index to override. The value should be the Unreal path to the material to be used.
The geometry on each instanced output can be replaced in Unreal and can have a position, rotation, and scale offset applied to it using the corresponding controls in the detail panel.
Packed Primitives ¶
The recommended way to create instances is using Packed primitives. The packed geometry is used as the instanced geometry and any copy of this packed primitive is converted to instances in Unreal.
Note
An instancer is created for packed primitives only if that packed primitive is copied more than once. Single instance instancers only create regular Static Mesh Components.
A simple way is to use a Copy To Points SOP with the Pack and Instance option on. You can also use Pack Geometry Before Merging or Inputs.
It’s important to look at the location of the attributes when you control properties of either the instancer of the instanced mesh in packed primitives. If you apply an attribute before packing it’s applied to the generated mesh. For example, you apply attributes before using the PACK SOP. If you apply attributes after packing, it’s only applied to the instancer.
Object Instancers ¶
You can also create Instancers using the instance Object node.
Attribute Instancers ¶
Besides instancing geometry generated by the HDA, instances can also be created from pre-existing Unreal assets.
This can be done using the unreal_instance
attribute and setting the attribute value to the asset’s reference.
You aren’t limited to static meshes, but the instanced asset must be convertible to a native Actor type. In that case, multiple instances of that Actor type is created and the generated instancer component will be a HoudiniInstancedActorComponent
. This can be used to spawn pre-existing assets in the level using the generated instancer’s point cloud.
You can also instantiate classes directly by using attribute instancers. This is useful to create instances of a class that can’t be saved as a uasset in the Content Browser, but can be instaniated as an Actor(for example, Lights, Volumes etc.. ).
To do so, set the unreal_instance
value to the name of the class you want to instantiate as Actor (unreal_instance
= PointLight).
Note
To detect properly, attribute instancers need to be in a separate part of the Geometry. Attribute instancer won’t be detected if the points that they are assigned to is part of the main geometry.
When an asset referenced by an attribute instancer could not be found, the plugin creates a default “asset not found” box mesh (hidden in-game by default) instead of ignoring the instancer. This can be enabled or disabled in the plugin settings in the Show default Mesh checkbox.
You can apply the Houdini rot/orient and scale attributes to specify the transform of the instance.
Splitting Instancers ¶
There are some cases where you may want to split instancer outputs to multiple components. This could be to assign different materials to each instancer or to get a finer grain control on the actors generated when baking.
This can be done using the unreal_split_attr
string attribute. This attribute’s value should be set to the name of another attribute, whose values will be used to control the splitting.
(a separate instancer component will be created for each individual value of that attribute).
For example, you can use the unreal_material
attribute as the unreal_split_attr
attribute (unreal_split_attr
= unreal_material
) creates an instancer component for each material on the second attribute.
If three different materials are used, the instancer splits to three different instancer components.
Alternatively, you can use the unreal_split_instances
attribute to create individual StaticMeshComponents
instead of the instanced one.
The unreal_instance_color
primitive attribute can then be used to specify an override vertex-color to apply to each component that is created this way. This can be used to add some variation to the instances via the material.
Overriding ¶
The geometry that is instanced is shown in a thumbnail picker. You can override it by pressing the drop down asset chooser to pick an asset from the list, or by dragging and dropping an asset from the content browser over the thumbnail.
If the geometry used by an instancer output is overridden with something other than a static mesh or vise-versa, the corresponding component will be changed accordingly. For example, you can choose a ParticleSystem asset, which results in AEmitter
objects spawned at instance points. Likewise choosing a Blueprint asset will spawn Actor instances of that Blueprint.
Variations ¶
You might want random variations of instanced elements. For example, if you have scattered rocks around a scene, you may want a few variations to add visual interest. Variations can be added by pressing the + icon next to the instance thumbnail, this results in an even probability distribution of instances between the two instanced inputs.
Multiple instance variations are displayed as Instancer output rows with a square bracket suffix.
Per Instance Custom Data ¶
Per instance Custom Data lets you add custom data to the instance buffer, that can then be read by the instancer’s material’s vertex shader.
In your HDA, you can specify per instance custom data on your instances, via attributes:
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 unreal_per_instance_custom_dataX
attributes, where X
is the zero-based index of the custom float data.
An example is to specify custom RGB float values on instances.
You need to add:
i@unreal_num_custom_floats = 3; (to indicate that each instance will have 3 custom floats) f@unreal_per_instance_custom_data0 = XXX; (red value) f@unreal_per_instance_custom_data1 = YYY; (green value) f@unreal_per_instance_custom_data2 = ZZZ; (blue value)
Foliage Types ¶
To output foliage instances with an HDA, you will need to add the unreal_foliage
attribute with its value set to 1 to the instances. Contrary to UE4, UE5 requires a Foliage Type Asset, stored in the Content folder, in order to create foliage instances inside an Unreal level.
If the instance type in the HDA is set to reference an Unreal Static Mesh then the plugin will automatically create the needed Foliage Type assets when cooking and baking.
If the instance type is set to an existing Unreal Foliage Type then foliage instances can be baked to that foliage type. During cooking a temporary Foliage Type is created which is a copy of the user-defined Foliage Type specified in the HDA. This allows users to select either existing or HDA generated foliage in the Foliage Editor after cooking. Only during baking are the instances baked into the level using the target Foliage Type.
Note
If the temporary Foliage Type that is created as a copy of the user-defined Foliage Type is modified (for example, by using generic UProperty attributes, or by using material overrides) then baking that HDA will create a new Foliage Type, instead of baking to the target Foliage Type, in order to preserve these modifications without modifying the target Foliage Type.
The `unreal_foliage_attachment_type attribute can be used to attach foliage instances to other objects in the Unreal level. It can take the following values:
-
0 - The instance is not attached (default)
-
1 - The instance can be attached to any collision component.
-
2 - The instance can only be attached to landscape collision components.
The exact component to attach to is determined by tracing a vertical ray up & down from above the instance’s position for a distance of unreal_foliage_attachment_distance
.
Level Instancing ¶
Level Instancing is supported in Unreal 5.1 and later; set unreal_instance
to reference the source level or packed level blueprint.
In Unreal Level Instancing is performed at the Actor level, rather than the component level, so both cooking and baking generate Actors rather than Components.
Note
Unreal expects both the source and target levels to have certain settings enabled, such as Extenal Actors. We therefore suggest running Map Check in Unreal when developing your HDA and instancing pipeline to ensure your data is compatible with the latest version of Unreal.