Kenshi
Not enough ratings
Morroshi Notes - Weapons
By Rimanah
This is the notes on my process of how to implement weapons from Morrowind into Kenshi.
   
Award
Favorite
Favorited
Unfavorite
Step 1: Preparations
You will need the following software:

BSAUnpacker[www.nexusmods.com]

NifSkope 2.0 Dev 7[github.com]

blender 2.79[download.blender.org] (.msi for install on Windows, .zip for standalone so you can use multiple versions; alternatively version 2.80+)

Kenshi OGRE export addon for blender version 2.79[www.lofigames.com] or version 2.80+[www.lofigames.com]

Blender 3.0-3.2 which can be found here[download.blender.org] with the newest Version of the OGRE Plugin from Github[github.com]. Extract folder within to blender\3.2\scripts\addons.

Optionally, the template file[www.lofigames.com] from the Lo-Fi Forums[www.lofigames.com].

GIMP[www.gimp.org] to edit textures.

And of course a Morrowind installation for the source files and Kenshi installation for the FCS.


Step 2: Obtaining game assets (meshes and textures)
Workflow:

Morrowind.bsa, etc. -> BSAUnpacker -> meshes.nif, textures.dds

1. start BSAUnpacker
2. click Open
3. select the .bsa file you want to extract (Morrowind, Bloodmoon, Tribunal)
4. click Extract all, select folder
5. open folder, go into "meshes" and "w" for weapons

Commentary:

For this conversion mod, I will be using the original meshes and textures from the Morrowind game files. Download and install the game via Steam or from CD/ISO. The game assets are stored in the three .bsa files the game has:

Morrowind.bsa
Bloodmoon.bsa
Tribunal.bsa

Under Windows, use BSAUnpacker to unpack these files.
Under Linux, use WINE to run BSAUnpacker (right click in folder, open in terminal, "wine BSAUnpacker.exe"). Same applies to NifSkope (right click in folder, open in terminal, "wine NifSkope.exe")

Note: I had missing meshes (cuirass and gloves) and textures (axe.BMP on Cleaver of St. Felms), so make sure your files are complete!

You now have the meshes (.nif) and textures (.dds) of Morrowind's game assets.
Step 3: Converting .nif to .obj (meshes)
weaponmesh.nif -> NifSkope 2.0 -> weaponmesh.obj -> blender

6. open NifSkope 2.0
7. select .nif mesh file you want to convert, right click > rename > ctrl + c (copy the file name)
8. drag and drop the .nif mesh file you want to convert into the program window
9. left-click and drag to rotate the camera, check the item. DON'T SELECT ANYTHING. If okay:
10. File > Export > Export .OBJ
11. click OK
12. click the file name window
13. ctrl + a, ctrl + v (paste the .nif mesh file name)
14. click Save
15. open blender & install Kenshi OGRE addon on first start (Edit > Preferences > Add-Ons > Install > select "io_mesh_kenshi.zip" for your version, check the box on "Import/Export Kenshi Tools")
16. open "kenshi_template.blend"
17. File > Import > Wavefront (.obj)
18. select .obj mesh file > Import OBJ



Commentary:

In order to work on them further, we convert the meshes from .nif to .obj using NifSkope 2.0 - using WINE in Linux works. Simply drag the .nif mesh file into the window and export to .obj and you're done. Then go into blender and import .obj - et voilá, there is your Morrowind game asset!
Step 4: Aligning and scaling your mesh
19. scroll out (mouse wheel), rotate camera (press mousewheel), pan camera (shift + press mousewheel) into comfortable position
20. in the top right click the eyes but "StaticObject" and your imported mesh
21. press "n" to bring up the Transform window on the right
22. set scale for X, Y, Z axis to 0.2-0.25 depending on weapon/armor, compare with template weapon
23. select your object (left click in 3D window or object list)
24. align rotation with template weapon (probably Rotation X and Z to 90°)
25. click small arrow top left below File and select Move
26. click the blue arrow and move the weapon up so the hand guards match
Step 5: Putting .dds textures onto .obj mesh materials (texturing)
Workflow:


27. hide the "StaticObject" template weapon
28. right side, small buttons, second from the bottom (red ball): Material Properties
29. select each Material (pink ball)
30. Base Color > press the circle
31. REMEMBER THE NAME
32. Link > Remove
15. open MW assets folder, go into "textures" and use search function
16. copy required .dds textures into your mod folder
33. Base Color > press the circle
34. Texture > Image Texture
35. Open
36. Search for the exact name of the .dds texture file you just removed, Open Image
37. Repeat for all the other materials
38. press z, select "Materal Preview" or "Rendered"
39. you now see the mesh with the textures you just added instead of pink, check if they are correct

Baking the UV map
40. right side, small buttons, third from the bottom (green triangle): Object Data Properties
41. UV Maps > +
42. make the new UV map active (click the camera symbol)
43. top row of tabs, select + > General > Shading (if it's not open already)
44. make sure it's the Shading node editor, not the Compositing node editor!
44. right side, small buttons, second from the bottom (red ball): Material Properties
45. select a material

46. click into the window below with the nodes
47. make sure "Use Nodes" is checked
48. shift + a > Texture > Image Texture
49. shift + a > Input > UV map
50. shift + a > Input > UV map (AGAIN)

51. first UV map node > UV (purple button), click and drag to Vector (purple button) on Image Texture .dds you put onto the material already; press black bar, select first UV map (original one)
52. second UV map node > UV (purple button), click and drag to Vector (purple button) on Image Texture you created just now; press black bar, select second UV map (new one)
53. Image Texture > New > give name > 2048 x 2048 or 4096 x 4096 texture size > uncheck alpha (transparency) > OK
54. shift + left click select all three nodes you created (UV map, UV map, Image Texture)
55. ctrl + c

56. right side, select next material, click inside node window, ctrl + v, connect unconnected UV map with respective Image Texture node of that material, repeat for all materials
57. make sure you have deselected all the nodes on all the materials! click into the empty background to deselect all!

The model you see now receives its textures in a way defined by UV map 1 from the individual .dds texture files we added to the materials that define the individual parts of the mesh. We now created a blank UV map for our new unified texture map. We practically cut up the model in a different way and place it flat onto our new texture map, all in one place, stamping the texture onto the texture map in a different way than on its original individual texture files. The new UV map tells the model how to get all textures into the right place from our new texture map instead of the old ones.

57. bottom left window, top left icon, Editor Type > UV Editor
58. browse image, choose the Image Texture we just created
59. top window (3D view), select the model, go to edit mode (top right > Object Mode > Edit Mode)
60. press a to select all vertices

61. press u > Smart UV project > Island Margin 0.03 > OK
62. You should now see grey UV map patterns on the bottom right; the model has been cut up onto one single texture map. Now we got to stamp the textures onto that map, which is called baking.
63. right side, small buttons, green triangle, make sure UV map 2 is active
64. right side, small buttons, white camera, set Render Engine from Evee to Cycles
65. scroll down to bake

66. Bake Type > Diffuse (or Emit)
67. Influence > Color only
68. Margin: 3 px
6IX9INE. press Bake

You should now see the texture in the shape of the new UV map on the bottom left on the new texture map.




Commentary:

We do now have the meshes and the textures. We can even stick them together in blender and they match up perfectly. But as said earlier, Kenshi wants one single texture.dds, not several.

We thus added all the individual textures from the MW game assets to the materials inside blender and baked the finished product onto one big texture atlas. Job done! Export thatn new texture.dds file with all necessary textures in one file.

Now we have to tell the game what texture goes where for our new texture. We select each material of the game object and remove the existing link, keeping in mind which .dds it wants and replace it with our custom texture.dds file. Then we tell the asset where that texture lies on our own custom texture map.

The way I do this (and I hope there's a simpler way) is by:
- opening up the mesh.obj file in blender, go to UV map and load the textures.dds we created into the left
- go to editing mode (top left) in the right window and while in solid mode (press Z) and face-select mode (top left)
- press B and drag over the visible part that you want to select, turn around and to it from the other side(s) as well
- press Z and go into wireframe mode, you can now see through the models surface
- shift-left click your way to select and de-select all the faces of the part you want to map out
- in the UV window to the right you will see your selected faces in orange when they are selected and grey when not selected
- take your selected UV map and rotate (R), scale (S) and move (M) it until it fits onto the respective part of the texture


This is a tedious manual task and I hope there exists a way to transfer the original UV map from the game assets in Morrowind onto our new texture without having to manually scale and align everything!

Lo and behold, indeed there is! It's called baking!

In any case, once you are done doing this for all parts of the model, you now have a completely textured .obj mesh with .dds textures. One last step and we are ready to import this file into the FSC!

Note: There are more maps than just the texture map! Normal maps, diffuse maps, etc. tell the game how to reflect light off of surfaces and give the optical illusion of depth, metal reflection, etc. to 2D surfaces - I will add those later.
Step 6: Putting the .dds textures onto a single .dds texture (baking)


Our mesh now has a new UV map and new texture. The texture is saved as a .dds, but the UV map is attached to the mesh file, so we need to save this, even though it has not changed structurally!

IF YOU MESS UP BY SELECTING THE WRONG UV MAPS, THE WRONG TEXTURE MAPS AND YOU EXPORT THE TEXTURE.DDS AND/OR THE MESH.OBJ/.MESH FILE, YOU WILL HAVE TO CORRECT THE NODES AND REDO THE STEPS TO EXPORT NEW MESHES AND TEXTURES! USING INCORRECT MESHES (WITH UV MAPS) AND/OR TEXTURES LEADS TO MISALIGNMENT OR ABSENCE OF TEXTURES! Why caps lock? Because I messed this up frequently! And quickly redoing them, I messed up the check boxes upon import and other details!

For whatever reason, the textures of Chrysamere, all except 04.dds, are missing the SRGB color space and thus can not be baked onto the texture atlas when using the Diffuse > Color option.

Might be a bug, might be that the texture has not yet been saved outside blender.

https://www.reddit.com/r/blender/comments/hlisrc/potential_bug_found_where_color_space_is/


Commentary:

SCRAP THIS, DUMB WAY TO DO THINGS!

weapontexture1.dds, weapontexture2.dds, etc. -> GIMP -> weapontextures.dds

As for the textures, here it gets tricky: Morrowind game assets use a number of materials with textures attached. You can see those materials in blender and might encounter an issue where the textures appear pink (when in material/rendered mode). You can fix this by manually going into the material tab of the selected asset (ball shape bottom right) and remove the link to the current texture, then choosing Image texture and choosing its respective texture .dds file. It will then appear correctly within blender.

Kenshi however does not work with those materials and requires a single .dds texture map for its game assets. Thus, attaching each of those individually does not do us any good here.

To get the Morrowind textures into Kenshi, we will open up a template texture map from Kenshi inside blender (you can create this by copying an existing one) and add all the individual texture files for our game asset into there by baking the textures from the game assets onto a texture atlas inside blender, not manually, you freaking madman!


In short, you can not only put textures onto meshes with UV maps, but you can also take the proper alignment of the textures on meshes and "stamp" them into one big happy texture map called a texture atlas. That way we have all textures on one map and don't have to manually move things around!

So open up the template, do not load mipmaps, go to "Layer" > "Transparency" > "Threshold Alpha" and set it to zero. You will not see the texture.

Now go to "File" > "Open As Layers" and select your Morrowind texture .dds files. They will appear as separate layers. Move them into a neat position and right click in the bottom right on the layer and select "merge down". Once you have one layer only, set the opacity above it to 10%, so you end up with the transparent state of the image you saw when opening up the template.

Now export this texture map as a .dds by going to "File" > "Export As", put in a name and press export. It will then ask you for parameters, here choose "Compression: DXT5" (I am not sure which one is the best, there are several) and "generate mipmaps" (I think; they are used to display lower resolutions of your texture for further away objects, saving resources when running the game).


I'm not sure if there has to be done something about the 10% opacity later on when baking textures inside blender. The video above recommends using some addons and works with nodes. But it works.

Done!
Step 7: Editing the texture further (normal & specular maps & greyscale mask)


https://cpetry.github.io/NormalMap-Online/



3b3b3b grey

-90 brightness

Diffusion

You don't have to use this in order to reduce gloss on the model, you can simply use the specularity factor in the FCS and set it to 0.1, see image below.

Actually scrap that, specularity factor is transparency of the metalness map, not the diffusion in the texture map!

Step 8: Converting .obj to .mesh and .xml (meshes/physics), icons
Note: I work on two systems, so this is where I export the mesh from Linux blender 2.80+ as an .obj file and import it into Windows blender 2.79!…

In the 3D window and in Object mode, select the model
File > Export > Wavefront (.obj) > Selection Only box checked > rename > Export OBJ
bottom left in the UV map window, three bars > Image > Save as... > rename (.png)
open up the .png in GIMP
set opacity to 10% (either in the layer on the right or using an eraser with 90% opacity)
File > Export As... > Select File Type (By Extension) > DDS Image > Export
Compression: DXT5 (I choose BC3 / DXT5)
Mipmaps: Generate mipmaps
Export

Move mesh.obj and texture.dds onto the USB stick, eject stick and transfer
open up blender 2.79 on Windows
delete the cube, light and camera
File > Import > Wavefront (.obj)
select the object
press Z choose Look Dev
You will notice the texture to be all over the place OR pink, this is due to the new UV map taking texture off the old individual texture maps, let's change this
Materials > choose each material > remove textures > change the texture to our newtexture.dds
select the model
File > Export > Kenshi OGRE (.mesh)
check Export tangents, Export Binormals and Apply Transform > Export MESH
now we add a rigidbody to the model, so it has physical properties
right side, small button, second blue from the bottom (moon circling planet)
Rigidbody > Type: Passive > Shape: Box or Mesh
File > Export > Kenshi Collision (.xml)
Objects: Selection, Transform: Scene


Commentary:

mesh.obj -> .nif to .ogre by oi__io -> mesh.mesh, mesh.xml

Now that our mesh is textured with a single texture.dds, we need to get it into a format that Kenshi likes. We download the "Kenshi OGRE/XML" addon by oi__io and install it in blender.

Under Windows, this works. Under Linux, you will face issues with the .exe used in the addon, I didn't get it to run with WINE.

Now we just take our textured mesh and go to "Export" > "Kenshi OGRE mesh" and export. Check "Export tangents", "Export Binormals" and "Apply Transforms".

We do the same with XML, but this did throw out a "no rigid body" warning to me. Rigid bodies are added in the Physics section of blender and give an object physical properties such as mass.

For now we just export the textured mesh as .mesh file.

mesh.mesh, texture.dds -> Forgotten Construction Set (FCS) -> custom weapon

Next we take our custom weaponmesh.mesh file and weapontexture.dds file and add them to a new item inside the Kenshi FSC editor.

The way Kenshi deals with those is a bit counter-intuitive at first. Weapons don't exist as standalone items, but there are weapon types and there are manufacturers and materials. The textures are determined by the manufacturers or materials. The model (mesh) is determined by the weapon type.

In short (will expand this later) we put in the files for our weaponmesh.mesh and weapontexture.dds into the respective fields, creating a new weapon, manufacturer and material. We also add a new character, a new squad and everything related to that (again, will expand later in detail) and create a new start scenario. In there, we add the weapon as a starting weapon. This way we can go into the game with our mod enabled and test what we did.

Done!




In blender, move to top of item, add light sun, light intensity 2, top, focus active camera on item, render image, export as png, remove background, export, open up auto generated icon, put this over there, done
Step 9: Implementing .mesh, .xml and .dds into Kenshi
Now open up the Kenshi FCS
create a new mod
create a new weapon
create a new model
create a new manufacturer
these three generate the plethora of weapons ingame
add the meshes to mesh lines
add the .xml to physics line
add the texture to texture line
add the weapon to lists of manufacturer/model
Step 10: Testing the result
For testing purposes:
add a character (by duplicating an existing one)
add a squad
add a start scenario
add weapon to character inventory, set the quality and chance to whatever you need (99, 100)