3D models

From CK3 Wiki
Jump to navigation Jump to search

Crusader Kings III uses 3d models to represent objects in the game such as portraits, units and holdings, as well as map objects such as trees. This guide is intended to help CK3 modders with some existing knowledge of 3d modelling and materials. This guide is similar to other 3d modelling guides for Clausewitz like Imperator: Rome. To create a 3d model, you will need modelling software like Autodesk Maya or Blender. You will also need an addon to import and export Crusader Kings III models. To create a texture, you will need image-editing software like Adobe Photoshop or GIMP with an addon to import and export DDS textures.

Overview[edit]

All models and their respective textures and animations can be found in /Crusader Kings III/gfx/models/

A typical model will have the following files:

  • <model>.mesh - The 3d model itself.
  • <model>.asset - The script adding the model to the game.
  • <model>_diffuse.dds - The diffuse texture for the model.
  • <model>_normal.dds - A normal map texture.
  • <model>_properties.dds - A joint texture with specular, metalness and roughness.

More textures for other 3d models include:

  • <model>_unique.dds - Used with the standard_atlas shader. The B channel is the models’ ambient occlusion texture.

Tutorial: Setup[edit]

Tools[edit]

  • Autodesk Maya. A program used to create 3d models and animation. Needs the Clausewitz Maya Exporter installed.
  • Clausewitz Maya Exporter. A Maya plugin from Paradox. Setup models based on installed games and exports model and asset. Installation instructions linked in the forum post and below.
  • Blender. A free program used to create 3d models and animation.
  • IO PDX Mesh addon. Addon that can be installed to Blender or Autodesk Maya. Setup models from compatible games. Installation instructions on their page.

Setup Clausewitz Maya exporter[edit]

There is a full setup guide for the exporters. The below guide is shortened.

To setup CK3 for the exporter, open the clausewitz.settings file using a code editor, edit the folder paths and then save. The folder paths for CK3 are as follows:

  • "name": "CrusaderKingsIII"
  • "path": "C:/SteamLibrary/steamaps/common/Crusader Kings III/game/tools"
  • "export_path": "Your personal mod’s folder"
  • "target_exe": "C:/SteamLibrary/steamaps/common/Crusader Kings III/binaries/ck3.exe"

Notes:

  • Your mod’s gfx/models folder can be anywhere on your C drive. You can choose to edit the settings for every mod you edit, or use one folder and copy your models from there to your mod.
  • The / slash (forward slash) is important, Windows Explorer uses \ (backwards slash). If you copy from Windows Explorer, you will need to edit the folder paths to use /.
  • The name must be one word, no spaces.

Preparing Maya 3d model[edit]

UVs[edit]

Order of UV maps for the standard_atlas shader:

  1. map1 - uv mapped to AO "<model>_unique"
  2. map2 - uv mapped material atlas

Issues with UV maps[edit]

This can catch you off guard when creating your model, map1 must be above map2, map1 must be the default uv set in Maya. If you’re importing the model from Blender as a .dae file, the uv maps must be in the correct order in Blender too. If your uvs are not in the correct order, then use this method to rearrange them. I do not know a method to delete the default uv set in Maya. The issue is that map1 is mapped to your material atlas.

  1. UV - UV Set Editor. Copy map1.
  2. Select map2 in the UV Set Editor.
  3. UV - UV Editor. Then in the UV Editor, UV Sets – Copy UVs to UV Set. Choose map1.
  4. In the UV Set Editor delete map2.
  5. Rename UVSet1 (originally copied from map1 in step 1) to “map2”.
  6. Select map1 and click Update.

Broken normals[edit]

Use Maya’s Mesh Cleanup tool (with default settings) to solve Error! Mesh contains broken normals, tangents and/or bitangents.

Tutorial: Getting them on the map[edit]

You'll want to make building models appear in the game; this requires editing a few other files.

First off, the asset file for a building must contain an entity-block and a pdxmesh-block, the former essentially containing just a reference to the latter. You'll want to reference either the mesh or the entity in different places.

Holdings[edit]

To make holding buildings for your modded religion or culture, you must first make sure they are considered as entities to be placed on the map: you will need to reference them by editing the vanilla file all_buildings.asset, under gfx/models/buildings. It is unclear what all the settings do here, but you can just follow the pattern and add a locator and attach-block for each of your new holding models, e.g. like so:

locator = { name = "pos_11_a" position = { @[gap *  6.5] 000 @[gap * -1.5 ] } }
locator = { name = "pos_11_b" position = { @[gap *  6.5] 000 @[gap * -0.5 ] } }
locator = { name = "pos_11_c" position = { @[gap *  6.5] 000 @[gap *  0.5 ] } }
locator = { name = "pos_11_d" position = { @[gap *  6.5] 000 @[gap *  1.5 ] } }
attach = {         "pos_11_a" = "building_[mymod]_city_01_entity" }
attach = {         "pos_11_b" = "building_[mymod]_city_02_entity" }
attach = {         "pos_11_c" = "building_[mymod]_temple_01_entity" }
attach = {         "pos_11_d" = "building_[mymod]_temple_02_entity" }

Now, for the second part there's a distinction between temple holdings and castle/city holdings. The choice of temple holding is primarily determined by a religion, and for castles and cities it is culture. In order to have a culture make use of your new city and castle holdings, you define a new graphical_culture for your culture. This is just a tag and does not need to be declared anywhere; just put e.g. [mymod]_building_gfx in the graphical_cultures block at the top of your culture definition. Religions, on the other hand, define a graphical_faith. It is similarly defined at the top of a religion definition.

Then to string everything together, you edit the vanilla file for the buildings (not holdings as one would expect). E.g. to add a new temple holding mesh, you edit 00_temple_buildings.txt. Each of the four tiers of the holding (of the core building, really) has a series of asset blocks defining potential meshes to use for that building. You add one for your own new holding model like this:

asset = {
	type = pdxmesh
	name = "building_[mymod]_temple_01_mesh"
	illustration = "gfx/interface/illustrations/holding_types/temple_[mymod].dds"
	soundeffect = { soundeffect = "event:/SFX/Ambience/3DMapEmitters/Holdings/Temples/[mymod]_temple" soundparameter = { "Tier" = 0 } }
	graphical_faiths = { "[mymod]_gfx" }
	graphical_regions = { "graphical_[mymod]_region" }
}

In name you reference the mesh tag from your asset file. illustration specifies the art forming the background of the holding UI (in vanilla a variable is used instead, with the underlying path at the top of the file). soundeffect references ambient sound you hear when you hover over the holding in the game. And here graphical_faiths references one or multiple graphical_faiths that you can define for your new religion.

Finally, graphical_region is a fully optional way to restrict the geographic usage of the model. It can be used if you have several versions of the same model, using e.g. different materials so they blend in with different locales. They reference to a graphical_region in map_data/geographical_regions.txt, where you can add new ones too.

This syntax works the same for cities and castles; just use graphical_cultures in the place of graphical_faiths.