top of page

Houdini terrain implementation into Unreal / Real - time world changing? I Nona Bocheva - Week 4&5

Ideate, Define


Note:

This research was done considering one of the existing concepts for the project. The goal was to produce procedural terrain that can be tweaked by the audience real-time and explore possibilities with unique changing environments.


After creating the terrains, needed for the visualization the next steps would be to import it in Unreal and possibly interact with the terrains in real-time. Luckily, Unreal supports both Input and Output of Landscapes. Landscapes can be exported from Houdini by using Landscapes Inputs.


A person can choose how he wants for his landscapes to be exported. Basically, a lot of useful information can be found in Bianca Lopez's video on the topic. Making Heightfields Unreal - How to Import a Houdini Heightfield into Unreal Engine - YouTube.


Input

Landscapes can be imported to Houdini by using a Landscape Inputs and World Outliner Inputs. The landscape’s height and layer data is in Houdini as a heightfield (or as a point cloud or mesh if you selected the corresponding option in a world input). If the landscape is exported as a heightfield, all the landscape layers are masks on the heightfield node. The input’s landscape’s tags are imported as primitive attributes, prefixed with unreal tag_, followed by the tag’s name. Theses attributes recreate the imported tags when outputting the heightfield back to Unreal.


Output

Landscapes can be generated by your HDA if the output node contains Height Field primitives. Each Height Field primitive present in the output is converted to a Landscape by the plug-in. The height primitive controls the landscape geometry, and all the additional Height Field primitives (mask, mesa, and cliffs) on the landscape as Target Layer.


Creating or modifying landscapes

By default, the Houdini Engine plugin will treat each Output in an HDA is a unique Landscape which will be created. The plugin can also modify existing landscapes. This is controlled by an attribute on each primitive in the HDA Output: If you set the unreal_landscape_output_mode to 0, it generates a new landscape. Set it to 1 to modify an edit layer on an existing landscape. The name of the target landscape actor in both modes can be specified with unreal_output_name. When modifying existing landscapes the special name Input<N> can be used to specify that the output will be the <N>the input sent to the HDA; this is particularly useful when using Houdini to modify existing landscapes. The default name is Landscape.


Data conversion

As Unreal uses 16-bits integers for Landscapes and Houdini uses 32-bits floats to represent the height values, the data needs to be converted. This results in a small precision loss when creating Landscape from a Heightfield. By default, Landscapes generated by Houdini Engine uses 3/4 of the available 16 bits range for conversion. This allows you to sculpt the landscape past its min/max values afterwards in Unreal.

If you would rather use maximum precision for the data conversion, activate the Marshalling Landscapes Use Full Resolution setting in the Geometry Marshalling section. For example, a 4km high landscape will have a precision (on the Z axis) of 8.13 cm by default, or 6.10 cm if that option is activated.

You can also use the default unreal conversion values in the plugin settings, by enabling the Use default Unreal Scaling option in Geometry Marshalling. This likely results in a precision loss during the conversion and may clip the heightfield values if they are too high. This creates a landscape that has a “standard” scale factor on the Z axis.

When converting heightfield data to landscapes, you can specify the min and max values used for the conversion by adding the unreal_landscape_layer_min and unreal_landscape_layer_max float attributes. This works on the height data, but also on any masks that converts to a landscape layer. This is useful when outputting tiled landscapes to ensure that all tiles are converted in the same manner.

Target Layers are converted from Houdini’s 32-bits float to Unreal 8-bits unsigned int. Values are converted from Houdini’s (min, max) to (0, 255) in UE.

By default, Height Field masks converts to weight-blended landscape layers. If you want some of the Height Field masks to be exported to Unreal as non weight-blended layers, you must add a Primitive String attribute to your heightfield named unreal_landscape_layer_nonweightblended. Set this attribute values to the names of the masks separated by spaces (ie: mask water debris).

Alternatively, each heightfield mask can have a Primitive Int attribute named unreal_landscape_layer_noweightblend which can be used to explicitly set the No Weight Blend property to unchecked (0) or checked (1).


Landscape size

Unreal Engine requires specific sizes for its landscapes, as they are broken up in sections and components for LOD / optimisation purposes. The recommanded sizes are:

  • 8129 x 8129

  • 4033 x 4033

  • 2017 x 2017

  • 1009 x1009

  • 505 x 505

  • 253 x 253

  • 127 x 127

If your heightfield data doesn’t match one of these recommended size, Houdini Engine automatically resamples the data so that the generated landscapes fit the size requirements.


Heightfield to Landscape


1. In Houdini:


- Create Heightfield


- Create Houdini Digital Asset from Selection


- has to be executed in the Geometry node

- saved to $HIP and exported in Unreal with added Directional Light so details are visible


2. In Unreal 4:


- Import Houdini Digital Asset


- Create UE4 Landscape


NOITE: After making a change in Houdini ex: Importing more properties such as Amplitude and Element size -> save -> Rebuild all instances in UE4


-Add Lights, otherwise texture is not visible (Directional Light and Sky Light)


- Create UE4 Landscape Material

Starting by 3 main layers for the "Mountain top", "Steep slopes", "The base", marked with corresponding colors.


3. In Houdini


- 3 layers from masks (HeightField Mask by Feature -> Mask by Height -> Compute Range -> heightMap, selecting the top peaks)

- In the stream heightField mask by Feature there are two voxel channels: Height & Mask


TIP: Instead of replicating the same map over and over, node heightfield_copylyer can be used. In this node there are two parameters: Source & Destination;


- Match names in UE4 Landscape Material (Destination should be named exactly as in Unity Materials) - repeat process, just changing features and tweak them


! For the last mask: UE4 Landscape uses Blended Weight Painting of the different layers one's has; combine all layers and invert to make sure everything is covered, if not it will show as black area in Unreal. Invert can happen with a heightfield_remap node. In the final node (heightfield_copylayer) includes all the layers/masks: "Mountain top", "Steep slopes", "The base".


- to transfer the material without copying it too many times -> In Houdini - create Attribute and name it Unreal_material and copy a reference from UE4, making it a string type; class should be set to either Detail or Primotive.




4. Creating Holes


1. In Houdini -> add Visibility Layer by just cutting holes directly in Unreal OR create the holes in Houdini itself. Hole can be created by drawing it directly onto the terrain with drawmask_heightfield and copy the node to a Visibility layer.

!From SideFX documentation: "If your Heightfield has a mask called visibility, then the plug-in will use it for the landscape's visibility layer, used to create landscape holes."

2. In UE4 one should create a hole material"




5. Real time interaction


In UE4, real-time terrain editing can be enabled through the following steps:

  • Enter the landscape editing mode within UE4.

  • This mode provides access to a suite of terrain editing tools that allow for dynamic adjustments to the terrain's elevation and attributes.


For terrain sculpting - UE4 offers a range of sculpting tools for real-time terrain manipulation:

  • Employ sculpting tools to raise, lower, smooth, flatten, and otherwise modify the terrain's elevation in real-time.

  • Adjust brush size, strength, and falloff parameters to achieve the desired terrain changes.

For Texture Painting: Real-time texture painting is facilitated by UE4's terrain layer system:

  • Create terrain layers and assign textures (e.g., grass, sand, rock) to paint different terrain types onto the landscape.

  • Use weight maps to control texture blending and distribution.

For Adding Foliage and Objects: The terrain can be populated with foliage and objects in real-time:

  • Utilize UE4's foliage painting tools to distribute foliage (e.g., trees, grass, bushes) and objects (e.g., rocks, buildings, props) across the terrain.

  • The Paint Foliage tool simplifies the placement and arrangement of assets.

Note: For a more advanced and dynamic terrain changes Blueprints and Scripting might be of help.


Notes in this document were made based on Dough Richardson's YouTube tutorial: https://www.youtube.com/watch?v=iUGRAbTHynE

Comments


bottom of page