Working with Custom Assets (Killing Floor 2)

From Killing Floor 2 Wiki
Jump to navigation Jump to search

Introduction

This page will give you a guide on the requirements on importing custom assets into your maps. This guide is for intermediate to advanced users who wish to understand the requirements of different asset types and custom packages for your maps.

Storing Assets

For things to work smoothly in the SDK, you should be using the following directory to store your maps and packages:

C:\Users\username\Documents\My Games\KillingFloor2\KFGame\Unpublished

The SDK will look here for maps and packages to cook and put in the corresponding Published directory when you upload or cook your maps. It is recommended to use this directory over the steam game files 'Maps' directory as if you have duplicate file names, it may be confusing in terms of which Map or package is actually going to be used.

!--T:1--> Warning Warning: Your Map (.KFM) will not keep any assets that are not used/placed in the map/scene when you save and close the SDK. You will need to make sure they are placed somewhere in the scene so they can be saved into the Map package.


Importing assets is pretty straight-forward, but you should import directly into your Map (located at "External > KF-MapName" in the Content Browser directory). You can Import assets directly by right clicking within the Content Browser or clicking the "Import" button at the bottom left of the Content Browser. When you import an asset, you will get a pop-up window, look carefully at the import Options as you may need to reimport assets again if you get something wrong.

Extracting Assets

Depending on the sort of asset there may be multiple ways to extract it. However not all the below methods are guaranteed to work.

Method 1: Extracting Meshes from your Map Scene

  1. Select all the meshes in the scene you wish to export
  2. Right click and select "Export (.FBX)..."
  3. Choose a save location and file name and Save.

OR

  1. Select all the meshes in the scene you wish to export
  2. Go to "File > Export > Selected Only..."
  3. Choose a save location and file name and Save.
    1. If nothing happens you may need to save the map and try again.


Method 2: Extracting Assets from the Content Browser

  1. Navigate to the asset in the Content Browser
  2. Right click on it and select "Export to File..."
    1. If the option is greyed out you need to Save the parent package. (eg: If I want to export ENV_Paris_Ambulance, I will need to save the parent package ENV_Paris_Three_MESH)
    2. This will create a duplicate package within the "Unpublished" directory. This is so you do not edit or override the base game assets.
  3. Select a save location and File Type and save
    1. For meshes we want .FBX, .OBJ files will not be correctly scaled.
    2. You can also export animations and frames from animations onto a model
!--T:1--> Note Note: Exporting Textures is a complete gamble on whether it will succeed or not. If the texture does not show up in the directory you chose, use the method below


Method 3: Extracting Assets using Umodel

  1. Download and Extract Umodel/UE Viewer: https://www.gildor.org/en/projects/umodel
  2. Open Umodel and select the directory containing the saved package from the above method located in Unpublished
  3. !--T:1--> Important Important: Under "Engine classes to load", ONLY select the file you want to find. In this case Textures. If not, it will most likely crash Umodel.
  4. Click "OK" and select the package you want to export files from and click "Export"
  5. Wait for the Export to complete.
  6. The exported files should appear within the Umodel folder in a folder called "UmodelExport"


Method 4: Extracting Landscapes

Wiki Guide: Setting Up Landscapes (Killing Floor 2)#Exporting from SDK

Custom Mesh Requirements

  • Snapping for modular kit works best if you set your snaps around 0.8 units and scale up and down proportionately from there.
    • EG: 1.6, 0.8, 0.4, 0.2, 0.04
  • Export your Meshes as .FBX from your 3D program
    • If you are using Blender use the following settings in the Export FBX window:
      • Selected Objects Only
      • Geometry > Smoothing > Face (Using Edge will give similar/same results - it doesn't matter too much)
        • If you do not, you will get an error when importing and the mesh shading will not be correct.
  • UV Channels:
  • Collisions:
    • Guide: https://docs.unrealengine.com/udk/Three/FBXStaticMeshPipeline.html#Collision
    • The guide above uses 3DS Max, but the exporting and naming conventions remain the same in Blender. Just select both the mesh and collision mesh/s for export.
      • EG: Mesh name: AStaticMesh, Collision name: UCX_AStaticMesh
    • For very complex objects that may require multiple collision meshes you can suffix the collision mesh name with _001, _002, etc.
      • In Blender you can can have multiple elements in the single collision mesh instead of having maybe 30 or more of the above, they cannot share vertices however or be connected.
      • Mesh Normals need to be correct as well, if not the import into the editor will not work.

Custom Texture Requirements

  • Texture formats: .TGA preferred but .PNG also works. Avoid .JPG.
  • Textures size must be a power of 2. If it isn't the engine cannot perform mipping on the texture at different resolutions.
    • eg: 8x8, 16x16, 32x32, 64x64, 128x128 256x256, 512x512, 1024x1024, etc
    • Textures do not need to be square, as long as they use the power of 2. eg: 512x256 or 512x1024
  • The engine will handle most of the import settings but double check the right settings are applied.
    • Diffuse Maps: sRGB ticked, Compression Settings - TC_Default, LODGroup - World
    • Normal Maps: sRGB unticked, Compression Settings - TC_Normalmap, LODGroup - WorldNormalMap
    • Masks: sRGB unticked, Compression Settings - TC_Default, LODGroup - World

Custom Material Requirements

This is referring to Parent Materials, not Material Instance Constants (MICs). You can actually create and use your own custom materials in your maps but there are some things to remember:

  • When you create Materials, the editor will create a "LocalShaderCache-PC-D3D-SM5.upk" located in your Unpublished folder.
    • As the name suggests, this is local and specific to your machine, you cannot share this with other people.
    • The Base Game will NOT build this ShaderCache, only the Editor can.
    • Basically no one but you will be able to see your Custom Materials unless you package additional data into your map.
  • To make Materials work on other people's machines and in Servers, you have to cook your map using the "Publish map by cooking" button along the toolbar.
    • Publishing the map to the workshop also cooks the map to allow people see custom materials.
  • This will create a locked version of your map in the following location: C:\Users\username\Documents\My Games\KillingFloor2\KFGame\Published
  • You share this Published version of the map with other players and put it on the server.
  • To make sure that your map's custom materials are actually working:
    • Put the Published map into the 'Maps' folder in the game files.
    • Remove the .kfm created in the published folder
    • Delete the LocalShaderCache-PC-D3D-SM5.upk in the Unpublished folder.
      • The shadercache can be used by your local machine and may deceptively tell you the materials are working in the game.

Custom Packages (.UPKs)

You can create custom packages (.UPK) via the "New" button at the bottom left of the Content Browser, it will open up a new window with the following properties:

  • Package: Will be the name of the new package. There is no naming convention needed but think of it as a Zip folder of Unreal assets.
    • eg: I name my simply DeltaAssets
  • Grouping: These are basically organizational folders. If you want sub folders then add a "." between folders
    • eg: "ENV_Biolapse_TEX.Labels" in the grouping text field will create the directory "DeltaAssets > ENV_Biolapse_TEX > Labels"
  • Name: Name of the asset you are technically supposed to be importing, you can leave this blank if you are just wanting to create a .UPK
  • Factory: The sort of asset the package will be populated with, you don't have to change this
    • By default it has AkBank, but after you save your package you can just delete the asset.


UPKs have the benefit of not needing the assets to be present within the level for the assets to be saved. They also allow you to load in assets into other maps if you have a large library of them or share them with other people. However it is not a good idea to upload your map using a separate .UPK and .KFM files. It is best to migrate all used assets in your UPKs into the Map as so to reduce the likelihood of user error on those who subscribe to your maps.

Asset migration is straight-forward:

  1. Save both your Map and UPKs
  2. Close the SDK and make backups of both your Map and UPKs!
  3. !--T:1--> Warning Warning: I mean it. Back them up. This process has a high chance for SDK crashing or user error as these actions are destructive.
  4. Open up the SDK and load only your map - hopefully only the assets your Map uses will be loaded from your UPK
  5. Select all the assets you want to Migrate in the Content Browser
  6. Right click and select "Move or Rename..."
  7. The same window when you created the package will pop-up, the only thing you need to change is the Package from your UPK's name to your Map's name (Look for KF- from the drop down)
    1. You can leave all the other settings the same to retain the Folder structure from your package.
  8. Click "OK" (or "OK to All" if you have multiple assets)
  9. Save the map once the migration happens

If things worked correctly, you will not need to replace any assets in the scene as you simply changed the redirector for where the Map needs to look up for your assets. If things did not happen correctly, then it was a good thing you backed up your Map and Packages, wasn't it?


!--T:1--> Note Note: The assets for Biolapse and Desolation assets have unconventionally been packaged within their Map files. If you wish to use their assets you will need to duplicate and migrate them to your Map or UPK.