Skip to main content

Setup

Persistent Layer

To spawn persistent brushes you need to place the ElRtPersistentLayerPartitions actor on the level and scale it to cover the whole area where you need runtime modifications to take place.

ElRtPersistentLayerPartitionsCreation

Landscape weightmaps and material setup

Unreal Engine optimizes out the weigthmap data during the project cooking. If a certain weightmap is not painted on a landscape component, its data is removed from the cooked game in that region. This prevents Errant Landscape Runtime from modifying its weights.

To prevent this, you need to decide which weightmaps are meant to be modified by the Errant Landscape Runtime and fill them with non-zero weights over the area to be modified at runtime.

info

Note that Runtime Landscape supports only Non Weight-Blended weightmaps.

In the future we will likely automate this process. For now however it requires a bit of manual work. We want to fill the chosen weightmaps with an integer value of 1 (of 255). That means a floating value of ~0.005.

We can fill the weightmap by adding a stamp brush that affects only the chosen weightmaps:

  1. Enter Errant Landscape editor mode and click "Create New Errant Layer" if you haven't done so before.
  2. Select the Create tool and select ElStampBrushActor in the "Actor Class to Spawn" dropdown. Click anywhere on the landscape to spawn the brush.
  3. Select the brush and adjust its location and scale so that its bounds cover the desired landscape area.
  4. Make sure the brush doesn't affect the heightmap - heightmap source texture should be cleared in the properties.
  5. Finally, select the runtime weightmaps to paint and set their source to a fully white texture (create one if missing). In the video we have just one weigthmap to fill named "RuntimeHole".
  6. For each of the weightmaps expand the "Adjustment" group and set the "Multiplier" to 0.005.
  7. Depending on the settings in the Errant Landscape Bridge actor (ElLayer type), the new brush may have filled the landscape with a default/first weightmap automatically. You might need to clear the first weightmap in the "Errant Landscape" Edit Layer in Landscape Editor Mode -> Paint -> right-click on the first layer -> Clear Layer.
  8. To avoid filling the area with the default weightmap - select the Errant Landscape Bridge actor and change "Weightmap Method" to "Weight Blend No Default" or to "No Weight Blending".

At this point, the chosen weightmaps will be filled with the lowest non-zero value which guarantees they won't be optimized away during cooking.

The last part of the setup is to make sure the weightmaps don't affect the landscape appearance becuse of that non-zero weight we filled them with. We can solve this problem by remapping the weightmap value in the landscape material from the <0.005, 1> range to <0, 1> range. The remapping will make the value 0.005 behave as if it was zero. Other values will work normally. For that you can use the material function we provide in the RuntimeLandscapeDemo named "MF_RemapLayerWeight".

runtime landscape material

Here is the logic of that Material Function:

Remap Layer Weight

Performance

Painting weightmaps at runtime can negatively affect the rendering performance of the landscape. For offline painted weightmaps, Unreal can optimize the weightmap data and only store the data for weightmaps with non-zero weights in a given landscape component. Later, when rendering a landscape component, the engine can use the least complex variant of the material/shader that supports only the painted weightmaps.

In case of the runtime weightmap painting we don't know over what region a weightmap will be painted during the gameplay. We thus cannot allow the cooking process to optimize the weightmap data and as a consequence need to always run a more complex and costly variant of the material/shader when rendering landscape components.

In the future we will likely optimize this solution by switching the shader variants ourselves, at runtime. In the meantime however, one way to improve the performance would be to use Runtime Virtual Texturing in the landscape material in order to cache the shading results. This is generally considered an effective optimization for all kinds of landscapes. Using RVT with Runtime Landscape requires that RVT update is triggered after a brush is spawned. Our systems don't trigger RVT update yet, so this must be done by the game logic.

While the Errant Landscape runtime system will call navmesh updates automatically you need to make sure you have set up the landscape in a way that will allow runtime navigation updates.

  1. Set the Navigation Geometry Gathering Mode in your landscape actor details to Lazy.
  2. Set the Runtime Generation in your navmesh actor details to Dynamic.

It's also recommended that the resolution of the navmesh be decreased when used on larger maps by changing the Tile Size UU in your navmesh actor to a larger value.