Houdini

We have created our heightfiled and layers and want to export them.

Heightfield

  • Heightfield
    • Note! Since UE is pretty picky with the terrain resolution we might set the Grid Samples to one of the sizes (Division mode is set to By Axis)
      • 8129
      • 4033
      • 2017
      • 1009
    • For a full list see UE Docs

Export

  • Export Heightfiled from Houdini to Unreal
    • Create a COP2 Network and jump in
    • Create a SOP Import node and set the SOP path to the output of the HF
      • Click
        • Set resolution from SOP
        • Set planes from SOP
        • Enable remap range
    • Create a Flip node
      • Since UE uses a different coordinate system we need to change the data
      • Create a flip node
        • In the flip tab enable Flop 90 Degrees
      • Connect the output of the sop import node to the input of the flip node
    • Create a Convert node
      • Unreal expects the data to be in 16 bit so lets convert the data
      • Create a Convert node
        • Set the Raster Depth to 16 Bit Interger
        • Set the scope to which planes you want to affect or leave at * to convert all
        • If we do not do this you will see some “stepping” artifacts in the hf in unreal
    • Create a ROP File Output
      • Set the Valid Frame Range to Current Frame
      • Set the Color Plane to the layer you wish to export (for instance height)
      • Set Alpha Plane to (None)
      • Disable Convert to Image Format’s Colorspace
        • We do not want a gamma curve applied to the height data so lets turn off Convert to Image Format’s Colorspace
        • If we do not turn this off the gamma curve will be baked into the heightfield, meaning the height data will be “transformed” by the gamma.
      • Set the Output Picture Path
      • Render

Unreal

Landscape

  • Create the Landscape
    • Create or open up the Level you want to add the landscape to
    • Press Shift + 2 or select Landscape in the top left dropdown of the menu bar.
    • Make sure the Import from file tab is selected and browse to the heightfield file we just exported.
    • The preview will look a bit off. To fix this we need to set the Location and the Scale before we import the data.
    • Match Unreal HF to Houdini HF size & position
      • To calculate this we need some info about our Houdini Heightfield, we need
        • HF height min
        • HF Height
        • HF size
        • HF resolution (the grid samples)
        • Note You can get this data from the heightfield primitive
          • resolution = prim.resolution()
          • bounds = prim.intrinsicValue(‘bounds’)
          • height_max = prim.volumeMax()
          • height_min = prim.volumeMin()
      • Calculating Heightmap Z Scale
        • Unreal Engine calculates your heightmap’s height by using values between -256 and 255.992, stored with 16-bit precision. The calculated height is then multiplied by the Z scale value that you input when you import the heightmap data. For example, a Z scale value of 1 results in a maximum height of roughly 256 cm and a maximum depth of -256 cm. Therefore, at the default Z scale value of 100, your height values will be between 256 m and -256 m.
      • UE Scale
        • ratio = 1.0/512
        • ue_scale_x = size * 100 / resolution
        • ue_scale_y = size * 100 / resolution
        • ue_scale_z = (height*100)*ratio
      • UE Location
        • ue_location_x = (min_x + size*.5)*100
        • ue_location_y = (min_z + size*.5)*100
        • ue_location_z = (height_min + height*.5)*100
      • Enter Theese values in the Location and Scale parameters
    • Click import
  • Import Layers
    • To be able to import the “texture” layers we exported we first need to create a landscape material and assign it to the landscape. This will populate the Layers section of the Paint tab in the landscape pane.

Landscape Material

  • Create a Landscape Material
    • We will create a minimalistic material just to show the process
    • Create a Material and open it in the material editor.
      • Select the result node and enable Use Material Attributes in the details panel
    • Create Set Material Attributes
      • Press tab and start typing “attr…” select Set Material Attributes
      • With the node selected, in the details panel, click the + button the right hand side of Material Attributes > Attributes Set Type
        • This will create the BaseColor by default which is what we want
      • Base Color
        • Hold 3 and LMB click
        • Set the color to a dark grey
        • Connect the output to the Base Color input of the Set Material Attributes node
      • Duplicate
        • We will use these nodes for the “base” layer and we also need one for the “debris” layer so we will select the color node and the set material attributes node and press Ctrl + D to duplicate
        • Then we will change the color to a pink so that we can clearly see it in the editor
    • Landscape Layer Blend
      • Press tab and start typing “lan…” select Landscape Layer Blend
      • With the node selected, in the details panel, click the + button the right hand side of Layers 2 times
      • Name the layers
        • Expand the layers and rename the first Layer Name to “base” and the second to “debris”
        • Gotcha The layer names can not contain underscores ("_"). If it does the layers is not displayed correctly (tested in UE 5.3)
    • Setup Layers & Material Attributes
      • Connect the output of the “grey base” Set Material Attributes node to the layer base input of the Landscape Layer Blend node.
      • Connect the output of the “pink debris” Set Material Attributes node to the layer debris input of the Landscape Layer Blend node.
      • Then connect the output of the Landscape Layer Blend node to the Material Attributes input of the material result node.
    • Our simplified landscape material is done.
  • Assign Material
    • Create material instance
      • RMB click the material in the content browser > Create Material Instance and give it a good name.
    • Make sure we are in the Selection Mode Shift + 1
    • Select the landscape, in the Details panel scroll down to Landscape > Landscape Material and drag and drop the material instance.
    • The landscape should turn black, and we need to do some additional steps.

Import Layers

  • Import Layers
    • Create Layer Info
      • Make sure we are in Landscape mode Shift + 2
      • In the Landscape tab switch over to the Paint tab
      • Under Target Layers > Layes we should now see base and debris Click the + icon on the right hand side and select Weight-blended Layer (Normal) and select a place where you want to store the Landscape Layer Info Object. Do this for both of the layers.
      • Then we will switch to the manage tab (we can also do this by rmb clicking the layer in the paint tab and the select Import From / export to file, I guess this is just a “shortcut”)
    • Import Layers
      • On the Manage tab enable the “base” layer and set the path ot the base.png file we exported from Houdini
      • Enable the “debris” layer and set the path ot the debris.png file we exported from Houdini
      • Click the Import button
    • We can now switch back to selection mode and see our landscape in all its glory!

RVT

A Runtime Virtual Texture (RVT) creates its texel data on demand using the GPU at runtime, and works similarly to traditional texture mapping. The RVT caches shading data over large areas, making them a good fit for Landscape shading that uses decal-like materials and splines that are well suited to conform to the terrain.

  • Materials are compiled in one of two contexts for use with RVT:
    • To render to the RVT
    • To render to other passes

The Runtime Virtual Texture Replace expression is ideal when wanting part of your material logic to render to the RVT.

  • Select how the material is rendered to the RVT
    • Lets say that you have set up a material based on the distance to the camera. When the material is rendering to the RVT there is no concept of a camera, it is just “rendering top down”.
    • If we want to be able to be explicit in how we want to render to the RVT we can use a Runtime Virtual Texture Replace.
    • The Default pin will be used when it is rendering the default material…
    • …and the VirtualTextureOutput will be used when it is renering to the RVT.

Resources