UE5 - Landscapes
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
- 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)
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
- Click
- 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 bi 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
- 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)
- Set the Output Picture Path
- Note! (Raster Depth)
- Since we want as much info as possible in the height layer we need to convert the data to 16 bit Integers
- Create a Convert node and set the Raster Depth to 16 Bit Integer
- If we do not do this you will see some “stepping” artifacts in the hf in unreal
- Note! (Gamma)
- Since we do not want gamma curve applied to the height data 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.
- 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
- To calculate this we need some info about our Houdini Heightfield, we need
- 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.
- Create material instance
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!
- Create Layer Info
Material Layers
- Create master material
- Create a “root” material folder
- First lets create a folder for our material assets. Call it Landsacpe_material
- Create Master Material
- In the root folder RMB > Material. call it M_landscape and double click it to open it up.
- Enable Material > Use Material Attributes
- Create Material Attribute Layers
- Add a Material Attribute Layers node
- Press tab start typing “layers…” select Material Attribute Layers
- Connect the output of the Material Attribute Layers node to the input of the Result node of the material
- Create a “root” material folder
- Create Material Layer
- In the root folder RMB > Material > Material Layer
- Call it ML_landscape_basic and open it up
- Create Attribute set elements
- Select the SetMaterialAttributes node and in the Details panel click the + button 5 times
- Material Attributes > Attribute Set Types > +
- Lets rename and reorder the elements so that we have:
- BaseColor
- Specular
- Roughness
- Normal
- Ambient Occlusion
- Select the SetMaterialAttributes node and in the Details panel click the + button 5 times
- Create Texture Sample Parameters
- Create a Texture Sample Parameters
- Press tab and start typing “text…” select TextureSampleParameter2D
- Duplicate it so that we hace 4 samplers, and name them to:
- BaseColor
- Roughness
- Normal
- Ambient Occlusion
- Note To increase the number of samplers we can use inside a material (and avoid the error if this is not set) select all the samplers and then set the Material Expression Texture Sample > Sampler Source to Shared: Wrap
- Set the Sampler type. If we set the defualt texure we also set the sampler type.
- BaseColor
- DefaultTexture (keep as is)
- Normal
- Select the normal sampler and in the Material Expression Texture Base > Click the dropdown that says DefaultTexture and strat typing basef… select BaseFlattenNormalMap.
- Note this will also set the Sampler Type to Normal
- Roughness
- Ambient Occlusion
- Select both nodes (roughness & AO)
- Click the dropdown and start typing “whitesq…” select WhiteSquareTexture
- here we might want to set the sampler to Masks?? or??
- BaseColor
- Connect the samplers to the SetMaterialAttributes node
- BaseColor & Normal
- RGB output
- Roughness & AO
- R (since we only use one channel)
- BaseColor & Normal
- We will control the Specular with a scalar parameter
- Hold S and LMB click
- Name it Specular
- Default value : 0.5
- Min : 0
- max : 1
- Connect the parameter to the specular input of the SetMaterialAttributes node
- Create a Texture Sample Parameters
Resources
- Documentation
- Tutorials
- Video