On this page |
Sending data upstream, that is from Unity into Houdini, is a very useful and powerful feature. This allows data in Unity to be used as input to a Houdini asset, cook it, then send the generated output back out to Unity.
This can be achieved in 2 ways:
The primary mechanism to send and use input data is via Object Merge nodes. Either an existing Object Merge node is used or a new one created, and connected to the asset.
The following input data are currently supported:
-
HDA (as node connection)
-
Unity Mesh
-
Curve
-
Spline (for Unity versions 2022.1 or newer)
-
Terrain (see Terrain Input)
-
Bounding Box
-
Tilemap
Node Inputs ¶
By design, SOPs have node connectors for passing geometries. This allows SOP type assets to also have node connectors for inputting geometries. Those inputs can be configured by changing the Minimum Inputs and Maximum Inputs values in the Operator Type Properties dialog of the assets.
All inputs created in this way will be listed in the Inputs Interface. These are treated the same as the Object Path Input Parameters inputs.
Object Path Input Parameter ¶
Object Path Inputs are created from Operator Path parameters that accepts a path to a Houdini node. In order to input geometry, the Op Filter needs to be set either to Any Object or Any SOP. When geometry is assigned to this parameter, Houdini Engine will create the appropriate Houdini nodes that will represent the input geometry. The asset can then use these nodes to access the geometry.
These can be used for both Object-type assets and SOP-type assets to input geometry, but it is more common to use Node Inputs connections directly for SOP-type assets.
Although the Operator Path Parameter can be created manually, the simplest way to create one is to create an Object Merge SOP and expose its Object (objpath) parameter to the asset level. The geometry can then be accessed from the output of the Object Merge SOP. It will then appear in Unity as the Inputs Interface on the asset UI:
HDA Input Type
Input Type ¶
Type of input data. There are two different kinds of input types:
The UNITY_MESH input type can be of type GameObject or Prefab, and HDA (Input Assets) refers to objects with a HEU_HoudiniAssetRoot component attached to it. The above images show the Inputs Interface for those types.
Keep World Transform ¶
This affects how the input object’s transform is marshalled from Unity into Houdini. When geometry is marshalled to Houdini through an input, an Object Merge node is used to connect the asset and the geometry. For Node Inputs, the Object Merge node is automatically created by Houdini Engine, and set up in the same way that an object merge is used for Object Path Inputs.
-
If Keep World Transform is checked, the Object Merge used to connect the input will have its Transform type parameter set to Into This Object, causing the input geometry to use its Unity world transform values in Houdini. Therefore if the input was at (0,10,0) in Unity, it will be at (0,10,0) in Houdini.
-
If unchecked, the Object Merge's Transform type parameter will be set to None, causing the geometry to use its Unity transform as an offset from its Object transform. Therefore if the input was at (0,10,0) then it will be 10 units higher in Houdini from its Object transform.
Note
You can further modify this behaviour by setting the Transform type parameter of the HDA’s own Object Merge node. Essentially, this setting uses the local (HDA’s transform) or the world transform for the input object. The table below describes the possible combinations:
HDA’s Object Merge Transform Type |
Keep World Transform |
Result of Input Transform |
---|---|---|
None |
Off |
Uses HDA transform (i.e. at HDA position) |
None |
On |
Uses HDA’s transform + offset of input |
Into This Object |
Off |
Identity transform (i.e. at world origin) |
Input This Object |
On |
Uses input’s transform (i.e. at input’s world position) |
In most situations, either the first row (at HDA position) or last row (at input position) is the desired outcome of the input geometry’s position.
Pack Geometry Before Merging ¶
Only available for Input Objects
If checked, all the different Unity meshes will be packed individually before being merged into the asset’s input. This allows to have each object available as a Packed Primitive in Houdini, making instancing and differentiating objects easier.
Input Objects ¶
Types of Input Objects: Unity Mesh, Terrain, Bounding Box, Tilemaps, Splines
All other Input Objects are treated as a special case of the UNITY_MESH option. In other words, if you set the input type to UNITY_MESH, we will marshall Terrain data with default options even if it is identified as a Terrain object.
If you want the actual mesh component, the input should be a GameObject or Prefab that contains Unity Mesh data (specifically, it should have a MeshFilter Component with valid mesh geometry). When marshalling the geometry, the name of the GameObject will be assigned as the primitive attribute named _unity_input_mesh_name_
. This attribute can be used in Houdini to separate the meshes. If the GameObject has assigned materials, the material names will also be set on a primitive attribute named _unity_material_
. This way the material assignment can survive the roundtrip back to Unity.
The other options allow you to select an input object with an Object filter for that specific type, and may include additional options for that particular type.
Transform Offset - Each input object can be assigned a transform offset that adds to the world transform of the input object, if Keep World Transform is enabled.
You can also add an object with a HEU_BoundingVolume component attached to it, and it will use all the meshes in its bounding box as input. This uses Unity’s collider.bounds.Intersects()
which simply compares using the collider’s bounding box.
Tilemap input objects can be sent to Houdini Engine as point data representing each tile. The points will have point attributes P (position), Cd (tile color), orient (tilemap rotation), scale (tilemap scale), unity_tile_pos (position in grid), unity_tile_size (tile size), and a detail attribute unity_tile_bounds
(size of grid). Tilemap input objects also have a number of options to enable/disable/modify these attributes. For example, the Create Groups for Tiles will automatically create a point group for each tile type, or output a string point attribute unity_tile_name
representing the tile name.
Splines ¶
As of Unity 2022.1, the Unity.Splines package allows you to create spline game objects to draw and edit curves in a flexible way than the Curve Editor. These splines are now supported as a new Input Type and used as input to HDAs that work with curves. Advantages of using this approach include access to a suite of contextual tools to manipulate points in the Scene view and build splines with multiple branching paths.
Unity Spline Resolution
The resolution setting is used when marshalling Unity Splines to Houdini Engine and represents steps in meters between control points. Set this value to 0
to only export the control points.
Input Assets ¶
Types of Input Assets: HDA, Curve
All other Input Assets are treated as a special case of the HDA option. In other words, if you set the input type to HDA, we will marshall HDA data with default options even if it is identified as a Curve object.
For HDA input type, this can be used to specify multiple HDAs in the Unity scene. Only the root GameObject of the HDA (the one with the Houdini Engine UI) is accepted here. When set, the plug-in will create a new Object Merge node in the Houdini Engine session, specify the path to the HDA in the Object (objpath) parameter, and connect the new Object Merge node to the current asset. This is more efficient than uploading the geometry created by one asset into another, since the connection is directly made in the Houdini Engine session.
Lock Inspector ¶
Locks the inspector, so that you can select objects from the Hierarchy. To use this, press the Select from Hierarchy button, select the objects from the hierachy, and then press the Use Current Selection button to unlock the inspector and use the selected GameObjects as input.
Custom Input Scripts ¶
Custom scripts can be easily added to the plug-in’s input mechanism allowing you to add support for uploading custom input data or overriding built-in scripts. For example, users can add their own input script for uploading meshes or terrains instead of using the built-in scripts.
HEU_InputUtility.cs is the utility class that manages input interface scripts, which are derived from HEU_InputInterface.cs
. A class derived from HEU_InputInterface
registers itself with HEU_InputUtility
. When an input object needs to be uploaded into Houdini, HEU_InputUtility
finds and uses the registered HEU_InputInterface that can upload that object, based on the priority set by the user.
HEU_InputInterfaceMesh.cs
and HEU_InputInterfaceTerrain.cs
both provide examples of HEU_InputInterface
derived classes handling uploading of mesh and terrain objects, respectively.
To add a custom input script hook, create a new class that derives from HEU_InputInterface
, fill in the required methods, then copy and edit the OnScriptsReloaded function from HEU_InputInterfaceMesh.cs
, and add the [InitializeOnLoadMethod]
and [UnityEditor.Callbacks.DidReloadScripts]
attributes. These attributes will invoke the OnScriptsReloaded
function, which automatically creates a new custom interface object, and registers it with HEU_InputUtility
when the Unity Editor scripts are reloaded.