This guide explains how to import meshes into Dying Light 2's C Engine, set up materials, add skins, and optimize complex meshes for better performance.
Prerequisites
Before we start, you need the following prerequisites in order to import meshes:
- Dying Light 1 Developer Tools
- Dying Light 2 Developer Tools
- Textures that are in .png image files and have a power of 2 (for example, 1024 1024, 2048 2048 etc, all must be perfectly divisible by the number two without resulting in decimals)
- A text editing program, for example the default windows notepad or notepad++
Step one
For the first step we will be importing our mesh into Dying Light 1's Chrome Engine 6
Open up Dev-Tools of Dl1 and head to this section in order to import meshes
Once you click the import assets button, this window will greet you
You need an .fbx model file in order to import meshes into this engine, and from this window you can select the one that you want to import.
Some things to keep in mind:
In blender you must make sure that there are no dots anywhere in the material name. You must also give the material a unique name just incase so that it does not collide with in game materials.
A good trick to do this is to follow a naming convention of your own, for example you can see how this shield material is called "dl_gt_heatershield_a", the "dl_gt" part is simply a short form of my project name which is Dying Light: Gothic.
After you click open on the .fbx file this window will appear
You don't have to do anything here, just simply click the ok button at the bottom.
After that you can search up the name of your mesh and find it in the browser like this.
Right click on it and select "Show in Explorer"
The steps to do in Dying Light 1's CE6 are complete, now we can focus on setting up materials of the mesh inside Dying Light 2's C Engine.
Step two
Now you must select these three files of your mesh from the explorer.
the .dmt file, .msh file and .skn file.
Copy and paste this in your Dying Light 2's project folder, for example
I suggest adding a folder here for your custom meshes in order to keep things organized, however its not a necessary step.
Once this is done, copy paste your .dmt, .msh and .skn file into the folder
now you must change the .dmt file by renaming it to .mat
Open your .mat file, delete all contents inside it and then open one of these mat file templates that I created, copy the contents of them into yours:
MATERIAL FOR WEAPONS OR ITEMS THAT PLAYER HOLDS IN HANDS
Supported texture sets for this one: Diffuse/Base Color, Normal, Roughness, Specular
OR
MATERIAL FOR WALLS OR VERTICAL SURFACES THAT SUPPORT REPEATING TEXTURES
Supported texture sets for this one: Depth (or heightmap that can be used for Parallax Occlusion Mapping to fake displacement)Diffuse/Base Color, Normal,
Roughness, Specular
OR
MATERIAL FOR HIGH QUALITY GROUND SURFACES THAT HAVE DISPLACEMENT
Supported texture sets for this one: Depth (or heightmap that can be used for Parallax Occlusion Mapping to fake displacement)Diffuse/Base Color, Normal,
Roughness, Specular
OR
MATERIAL FOR MESHES THAT HAVE OPACITY OR CLIPPING TEXTURES
Supported texture sets for this one: Clp(Black and white texture, should only have black and white information and no greyish texture), Diffuse/BaseColor, Normal,
Roughness
Once you have selected the type of material you want and have copy pasted the templates it should look like this:
Please note that you don't have to do anything to the mat file at this point, leave the template as it is and follow the next steps where we directly edit the file through C Engine's Material Editor.
At this stage you must also add your textures of the mesh into the meshes folder, I have done it like this:
Important note:
For your textures you must follow Techland's naming convention of textures in order for them to appear inside the material editor easily. For example, Diffuse textures will have _dif at the end, normal textures will have _nrm at the end etc. And it must be a .png file.
Once this part is done, open up your C Engine project and search for your mesh. As you can see here, it is currently invisible, this is normal.
To make the material work, go to windows and add "Asset inspector"
Your asset inspector should look like this while your mesh is selected:
Double click on your mat name in order to open the material editor
Inside the material editor simply click the plus icon to make your material work
Now we must add textures in this stage
Click the 3 dots icon to browse for your textures and add them one by one
As can be seen, now the mesh and the material is perfectly working.
If you have clp textures you have to copy paste its name over here in the "Mask" section
Note that not all of the features work inside the material editor as of the time this is being written. Only this section here is somewhat functional.
Now we will move onto how we can add skins to our custom meshes and how we can optimize the meshes for more performance.
POTENTIAL BUGS WITH MESH IMPORT AND HOW TO FIX THEM
Invisible meshes while playtesting:
Click the red "Needs Build" button and select these options, start building.
Now the meshes should be visible and working during play testing.
ADDING SKINS: This section is still being worked on, due to some bugs it is a bit difficult to make this guide)
OPTIMIZATION: Still being worked on, but very in depth as well