Setting Up Landscapes (Killing Floor 2)

From Killing Floor 2 Wiki
Jump to: navigation, search


This page will give a comprehensive guide to implementing landscapes into your map and editing them. It will also provide some workarounds for some of the limitations of the current system.

In this documentation we will be using 'Landscapes' instead of  'Terrains'. Although we can refer to them representing the same thing, they are actually completely different systems within the SDK. The Terrain system is an early UDK implementation and does not contain as many features as the Landscape system and should be avoided for KF2. You can toggle the Landscape on and off by pressing 'T'.

Please refer to the technical documentation for further understanding of the system:

Step 1 - Creating a Landscape

Click on the Landscape Mode. This will prompt you with options for creating Landscapes, chose what size you want and plug the corresponding values into the prompt. See Figure 1.1.

The UDK documentation provides us with optimal sizes to create a landscape for the best performance in your map. You should use these and not custom sizes. Below are the recommended sizes for KF2 maps:

Size (vertices) Quads per Section Sections per Component Component size (quads) Total Components Relative Size in Editor
64x64 63 1 63x63 1 ~8000uu

Use for small ground portions of a map, like snowy sections used in Outpost and Krampus Lair or small grass sections in Manor. Usually exported for static mesh use.

127x127 63 4 (2x2) 126x126 1 ~16,000uu

Use for medium sized areas that require landscapes. Used in the arenas for Nightmare.

127x127 63 1 63x63 4 (2x2 Components) ~16,000uu

This was used for Farmhouse.

253x253 63 4 (2x2) 126x126 4 (2x2 Components) ~32,000uu

Larger maps like Zed Landing and Blackforest.

  • Size - Simply the amount of vertices of the landscape mesh - look at the relative size column for a better understanding of the actual size.
    • You can scale landscapes as well, but avoid doing it if you can.
  • Sections - these are used for Level of Detail (LOD)
  • Component - these are different sections of the map
    • Components create a splatter-map seam where they meet. Small maps should try to use 1 component, while larger ones should use more.
    • If seams exist, try and cover it up as much as you can with props and decoration.
  • From the documentation:

"Each component has a render-thread CPU processing cost and each section is a draw call, so try to keep these number to a minimum." [Source]

Figure 1.1: Options for creating the Landscape - plug the corresponding values from the table into here.

Step 2 - Adding a Material

Once the landscape is created you will need to give it a material. The materials that we use will be based off the LMAT_BlackForest_LandscapeMaterialBase Parent Material. Here are the following materials that are currently available for you to use from the official Maps:

  • Environment
    • ENV_BlackForest
      • ENV_BlackForest_MAT
        • Landscape
          • LMAT_BlackForest_Landscape_MIC
    • ENV_Farmhouse
      • ENV_Farmhouse_MAT
        • Landscape
          • ENV_Farmhouse_Landscape_MIC
    • ENV_Nightmare
      • ENV_Nightmare_MAT
        • LMAT_Nightmare_Landscape_01_MIC
        • LMAT_Nightmare_Landscape_04_MIC
        • LMAT_Nightmare_Landscape_MIC
    • ENV_SummerSideshow
      • ENV_SummerSideshow_MAT
        • Landscape
          • LMAT_ENV_SummerSideshow_LandscapeMaterial_Base_MIC
    • ENV_ZedLanding
      • ENV_ZedLanding_MAT
        • Landscape
          • LMAT_ENV_ZedLanding_LandscapeMaterialBase_MIC (uses a different parent material - so some of the steps with Layers below will not apply)

Select the material that closest represents to textures you wish to use and assign it to the Landscape > Landscape Material property of your Landscape. See Figure 1.2. You will notice the Landscape turn black and distort funny in Lit Mode within the viewport. This is because the Landscape has not been painted yet, and first we need to set it up so we can:

  1. Within the Landscape Window, scroll down to the Target Layer and select the Edit radio button.
  2. Under the Add New Layer section there is a text field that allows you to use a named layer to create paintable texture layer. The Landscape material uses 5 named channels to determine what texture to use. Type in one of the following below and then press the '+' Button. See Figure 1.3.
    1. Layer 1 - Grass
    2. Layer 2 - Dirt
    3. Layer 3 - Rock
    4. Layer 4 - Leaves
    5. Layer 3 - Water (uses same texture as Layer 3, duplicated so you can give it a different Physical Material)
  3. Click on the 'None' radio button once you are finished.

We can now move on to editing and painting our Landscape.

If the Landscape materials provided do not offer what you are looking for, you will need to create a new Material Instance Constant (MIC) and edit it exactly the same you would with any other MIC. The layers you edit will correspond to the names listed above. It is recommended to make the MIC from the Black Forest material.  

!--T:1--> Important Important: Any modifications you make to your MIC AFTER you paint your Landscape may require you to repaint the ENTIRE Landscape again. Not doing so can result in your Landscape having the default checker pattern. This will only show up in the actual game, the SDK will not notify you of this. You may not need to do it if you are simply replacing textures, but if you adding and removing layers you will definitely need to repaint.

Figure 1.2: Assigning a Material to Landscape Properties. The black trippy effect is normal, it will go away when we paint on to it.
Figure 1.3: Input Layer names here.

Step 3 - Editing

Make sure the Paint option is selected under Paint Tools, then select one of the Layers we just created. Move over to your Landscape and press Ctrl + Left Click, this will paint your Landscape with the desired layer. We can adjust the brush strength, size and falloff indicated in Figure 1.4.

Editing the height of the Landscape is done in the exact same manner, we just use the 'Height map' Layer instead of the ones we created earlier. Ctrl + Left Click will add height and Ctrl + Shift + Left Click will subtract height. There are a number other tools here that we can mess with to 'Smooth' or 'Flatten' the edges and even tools to generate randomness in the ground.

This should be all you need to know to use Landscapes for your Map!

!--T:1--> Warning Warning: One tool you should not use is the 'Visibility' tool. Although it will work in the Editor, when you go to the Content Browser and scroll through your map the SDK will crash. This is an issue with the public branch of the SDK. The internal branch does not have this issue and for whatever reason, the patch has not been pushed to the public branch.

Nearly all official maps use the Visibility Tool, so it is uncertain why this has not been addressed. If you require your map to have cut-out parts of it (for things such as a hole, cave or just because otherwise it would intersect with the map), you will need to employ the tactics in the section below.

Bug Report Thread:

Figure 1.4: Yellow - Tools to Edit our Landscape. Red - Brush properties we can edit. Do not use the Visibility Tool crossed out.

Working Around Visibility and Vertex Painting

!--T:1--> Warning Warning: This section will be using some more advanced techniques that require some external prerequisites including how to use a 3D Modelling Program and basic understanding of Material creation. If you are just starting out in the editor it is recommended to avoid map design that is overly complex or the techniques discussed below.

Basically, we are going to export the Landscape mesh, edit it in our 3D modelling program of choice (I will be using Blender here) and reimporting it as a StaticMesh back into the Map. We will then use Vertex Painting to paint the mesh.

Aside from just using it as a workaround for the Visibility tool bug, you can use it for small pieces of land in your map that would look more naturally formed. Eg: The snowy sections in Outpost and Krampus Lair, or the grass/courtyard in Manor. These are usually small enough to not require the extra processing used to calculate LOD for Landscapes.

Exporting from SDK

We are going to start off assuming that you have already created a landscape and have sculpted the heightmap for it. You should make the sculpt as close as you can estimate it in its final form. Any edits to the Landscape will need be done in the modelling program of choice, or restarting the below process if major edits are required.

The SDK will not allow us export the landscape as a .FBX unfortunately. We will need to export it as an .OBJ. This will likely mean that our mesh scale will be much larger when we import it into Blender. However when we export, we also want to export any boundary meshes or relevant meshes that give us and indication on what we will need to remove/edit on the Landscape. Select all relevant meshes and go to File > Export > Selected Only... and export as an .OBJ. Do not include an textures/materials if it asks you, we wont need it.

Afterwards just import the .OBJ into your modelling program.

Figure 2.1 shows the front courtyard of KF-Desolation, the Landscape was selected plus the additional meshes that aim to cover up parts of the Landscape.

Figure 2.1: Exported Landscape and boundary meshes into Blender

Editing the Landscape to a Mesh

If importing into Blender (might be the same for other programs), you will need to rescale all the meshes. Scaling it down by 0.01 gets it back into its actual mesh scale for KF2.

Take note, the exported Landscape will have it's pivot point set at the origin. This can be excellent in most cases, because we can instantly export it from Blender later, and when it is placed in the map we can set its Location to (0,0,0) and it will be in the exact same position we originally exported the Landscape from. You can of course can change the pivot point in case you want to align it with a mesh or specific position instead.

Depending on the sort of Landscape you created you may need to remove any duplicate vertices and weld parts together. Go ahead and do that and do whatever you need to do to the landscape such as deleting the unneeded parts of the mesh or tweaking vertices. Once you have completed it. You will need to create 3 UV channels for the Mesh:

  • UV0 - Texture
  • UV1 - Lightmap
  • UV2 - Splatter Map

Most of time, these sections are usually flat and you can do perfectly well with a top planar projection for all the UVs. Just make sure to scale the UV0 so the textures will repeat appropriately.

You do not need to create a collision mesh for this mesh as we'll change some settings after the import into UDK.

Figure 2.2 shows the final edited Mesh. When you are ready (in Blender) Select your edited Landscape only and go over to File > Export > FBX (.fbx). You can leave most the parameters default, however make sure you have set the following correct settings:

  • Export as Version FBX 7.4 binary
  • Enable Selected Objects only under the Main tab (so we do not re-export the additional meshes we have in the scene)
  • For Smoothing select Edge in the Geometry tab.

When ready hit Export FBX.

Figure 2.2: Edited Landscape. Left panel shows UV0 scale for texture

Importing the new Landscape Static Mesh

Head back into the SDK and navigate to External > KF-YourMapName within the Content Browser (if it is not here, it is probably under NewPackages instead of External). Either right click the map name or within the Browser space and select Import..., find your exported .FBX from Blender and import it in, you do not need to change any settings here (except maybe changing the name). You shouldn't get any errors when you hit OK (if a prompt says something along the line of smoothing groups make sure the export settings are set to Edge as mentioned previously).

When the import is completed, you can open up the newly imported mesh and inspect to see if it is correct. To make sure we have collision for our new mesh, go to properties of the mesh and untick the following (See Figure 2.3):

  • Use Simple Box Collision
  • Use Simple Line Collision
  • Use Simple Rigid Body Collisions

You should be able to place the mesh in the scene now and adjust its position accordingly (if you use the origin pivot point, you simple need to set the Location to (0,0,0)).

At this point you should inspect the mesh in the scene to see if it lost any detail or if vertex positions had changed during the edits in Blender. You can tweak the mesh pretty easily now by:

  1. Tweaking it in Blender and re-exporting using the same settings, NAME AND LOCATION (very important).
  2. Right Clicking on the mesh in the SDK Content Browser and selecting Reimport Static Mesh. This will automatically reimport and update the mesh if the name and location didn't change, if not, you will have to relocate it.

Figure 2.3: Setting the collision for the imported Mesh

Vertex Painting the Mesh

Unfortunately we don't have the luxury of using the same Landscape materials to paint our new mesh, and creating a texture for it is not a realistic or sensible thing to do for it. Our best and fastest option is to use Vertex Painting. Vertex painting is a technique where we paint Red, Green and Blue channels directly onto the mesh within the SDK. The R, G and B channels each contain their own texture/normal/look, and material simply blends them together based on their proximity to vertices; it works pretty much the same as Landscape painting with some additional limitations. The vertex painting also requires the mesh to be decently subdivided with vertices for better blending, luckily our landscape is already like this, so we do not need to change anything here.

Here are some of the Vertex Paint materials in the SDK that you can use/base your material off:

Material Instance Constant

  • ENV_Catacombs_Cavern_Stone_Ground_VERTEX_MIC [1]
  • ENV_Catacombs_Cavern_Stone_Ground_2_VERTEX_MIC [1]
  • ENV_Catacombs_Crypt_Stone_Walls_VERTEX_MIC [1]
  • ENV_CoalMine_Floor_VERTEX_MIC [1]
  • ENV_Krampus_Floor_Interior_VERTEX_MIC [1]
  • Christmas_Snow_01_MIC [3]
  • Christmas_Snow_Facade_MIC [3]
  • ENV_Manor_Cliffside_MIC [2]
  • ENV_Manor_Garden_Terrain_MIC [2]
  • ENV_Manor_Mountain_MIC [2]
  • ENV_ZedLanding_CargoPlane_VERTEX_MIC [1]
  • ENV_ZedLanding_Ruined_Walls_MIC [2]
  • ENV_ZedLanding_Stone_Blocks_MIC [2]

Parent Materials

  • [1] = Env_Basic_Vertex_Paint_PM
  • [2] = Env_Basic_Static_Terrain_PM
  • [3] = PM_Vertex_Paint_Complex
  • Env_Concete_Snow_VPaint_MAT

As with most materials, you can just choose what is best for you and edit accordingly. However some things to note:

  • Parent Materials [1] and [2] only use 2 channels for Vertex Painting, this is fine for small meshes that just need some slight texture variation like moss on stone or ruins
  • The [3] PM_Vertex_Paint_Complex has 3 channels for Vertex Painting, so it is more appropriate to use in Landscape meshes.

Vertex painting works much the same as Landscape painting. We first assign the material we want to use, then select the Mesh Paint Tool and in the prompt we have nearly the same options as Landscape painting. However, instead of working with Layers we now select a RGB channel to paint with. See Figure 2.4. We do not want to use the colour wheel, and instead just manually assign the channels instead. To correctly use Vertex Painting, use the settings also listed in Figure 2.4.

You can turn on the Mesh Outline to help visualize where vertices are. Go to Flags Menu > Show > Advanced > Mesh Edges. If your mesh is also very large, you can scale it down to make painting faster and reset it after you have finished.

Vertex Painting will be saved per instance of the mesh that it is painted on to. However if you want to save it to the actual Static Mesh within the Content Browser hit the button Copies instance vertex colors to the source mesh. See Figure 2.5.

Figure 2.4: Red - Mesh Paint Tool. Yellow - Keep these options. Blue - Only assign RGB values here to keep things simple. You usually stick with one full channel, but feel free to experiment
Figure 2.5: Pressing the highlighted button will save the Vertex Painting to the Static Mesh object within the Content Browser