Model modding

From Europa Universalis 4 Wiki
Jump to navigation Jump to search

Europa Universalis IV uses 3D models to represent many graphical objects in game, such as the units, buildings, trees, etc.

Overview[edit | edit source]

All models and their respective animations can be found in /Europa Universalis IV/gfx/models/.

A typical model will have the following files:

  • <model>.mesh - The model file itself.
  • <mode>_diffuse.dds - The diffuse texture for the model.
  • <mode>_normal.dds - The bump texture for the model.
  • <mode>_spec.dds - The specular texture for the model.

If the model uses animations, they tend to follow this format:

  • <model>_<anim name>.anim

Asset definitions for 3D models can be found in /Europa Universalis IV/interface/assets/.

A model must be given a script name in an .gfx file in this directory before it can be used. Here is a basic example of an asset definition:

pdxmesh = {
    name = "empty_mesh"
    file = "gfx/models/Mapitems/empty.mesh"
    scale = 1.0
}

Entity definitions for 3D models can be found in /Europa Universalis IV/gfx/entities/.

A model with a script name must be defined as an entity before it will work in game. An entity controls the the association between a model (pdxmesh) and any animations. Here is a basic example of an entity definition:

entity = {
	name = "selection"
	pdxmesh = "selection"
	state = { name = "idle" 		animation = "idle" }
}

Animation definitions are found in the .asset files within the subfolders in /Europa Universalis IV/gfx/models/.

An animation definition controls the script name of an animation, which is what is referred to in the entity definitions, not the actual filename. Here is a basic example of an animation definition:

animation = {
	name = "AO_Eagle"
	file = "eagle_idle.anim"
}

Unit Models[edit | edit source]

Unit models (or incorrectly, sprites) are ingame representations of armies and fleets. As with other Paradox grand strategies, Europa Universalis IV models are notoriously hard to mod. This guide will go into detail about the technical side of dealing with unit models, but won't cover artistic or Photoshop skills.

Before you can begin modding, you need an understanding of how the sprites work ingame.

Armies[edit | edit source]

For land armies, there are four "sprite levels" which display how advanced a country is in terms of military technology. The game also selects the dominant land unit type to represent the army - either infantry, cavalry or artillery.

The four sprite levels of England

The following information can be found in /Europa Universalis IV/common/technologies/mil.txt:

sprite_level MIL Tech Year Description
1 0 1350 Late medieval pike and armour
2 12 1557 Thirty years war musketeers
3 21 1674 Seven years war musketeers
4 26 1745 Napoleonic infantry
5* 30 1805 Not used by EU4!

Fleets[edit | edit source]

For naval fleets, the sprite level signifies the highest level of the dominant ship type (from heavy ship, light ship, galley, or transport). Unlike land units, existing naval units don't automatically upgrade with technology level.

DLC[edit | edit source]

The unit packs DLCs have some of the best-looking units in the game, so it can be very tempting to use them in your mod. You need to be careful about compatibility though, because not everybody will have the DLC that you use.

3D models[edit | edit source]

Since early 2015 it is possible for players to create custom 3D models and animations, and then import them into the game, via the JoroDox mod making tool. Alternatively this git repo (IO PDX MESH) provides an extension to import and export models into Blender/Maya. Previously it was only possible to use existing models from the base game and DLCs, which can be manipulated through text, hex, and image editors.

Types of models[edit | edit source]

3D models are used by various types of visual representations in EU4, almost exclusively in the 3D map interface.

  • Unit models - The visual representation of armies and fleets. Also displayed in the post-combat dialog.
  • Unit part models - Unit models can be extended by placing other models in specific places in the base model. For example: weapons, shields and horse riders.
  • Province activity models - Indications of province activity, such as colony building or the construction of units and/or buildings.
  • Province building models - City representations are created by a multitude of small buildings, using more buildings for larger cities. Specific province buildings are also shown in the city, or at the harbor location of a sea province. The flag representing the province owner is also part of this type.
  • Map decoration models - Non-province bound decorative additions to the map, such as bears, seagulls and other animals. This also includes the borders around the 3D map.
  • Tree models - The models used to create tree / forest visuals. (at various LODs)
  • Trade network models - The node points of the trade network, and travelling ships/wagons are visualized by 3D models.

Shaders[edit | edit source]

There are a number of different shaders which can be used in the Paradox Mesh format (.mesh). Each will have a different visual effect on (part of) the 3D model. New shaders may be created by placing new shader code in the 'gfx/FX/pdxmesh.lua' file. This requires expert knowledge of vertex and pixel shaders.

Shader Name Description
PdxMeshStandard Standard mesh. Diffuse RGB, normal map and specular ("shininess") values from specular map alpha channel.
PdxMeshColor Specular map's RGB channels represent Primary, Secondary and Tertiary colours of a nation. The most common shader used for units.
PdxMeshTextureAtlas Shader which prints the flag of the nation on the unit (flag UV range 0.05-0.95). A second UV map can be added to merge a texture into the flag.
PdxMeshSnow Adds snow to top-facing surfaces in winter.
PdxMeshAlphaBlend Transparency from diffuse map alpha channel.
PdxMeshAlphaBlendNoZWrite Transparency from diffuse map alpha channel. More expensive but less glitchy
PdxMesh_NoFoW_NoTI Never hidden by Fog of war or Terra Incognita
Collision Does not render the mesh, instead represents the "clickable" area.

Unit Models[edit | edit source]

Previous 3D modeling knowledge is required to create new unit models. It is best to start experimenting by importing existing units and doing minor changes in such a way that doesn't require new rigging and skinning (use meshes that don't utilize the colour shader - denoted by a country tag -). Unit entities can then be combined into sprite packs (as seen in the custom nation screen) in gfx/sprite_packs.

When texture drawing it's important to keep in mind that the textures are generated with mipmaps, which can cause weird issues (in that case export to a simpler format -png- to draw on and then transform back). The settings which caused me the least issues are: "Compression: BC3/DXT5" and "Generate mipmaps: on". Specular maps are encoded in such a way that the alpha channel represents "shininess"; additionally, if it is a mesh that uses the PdxMeshColor material, red green and blue represent the nation primary colours to be filled in (this is also a range). When editing existing specular maps there are a lot of areas that have 0 for alpha channel (completely dull), but still contain a colour, this effect can be achieved by drawing on a surface and then erasing it again.

Documentation EffectsTriggersModifiersScopesVariablesLocalisationCustomizable localizationRun files
Scripting Scripted functionAdvisorsAgesBookmarksBuildingsCasus belliColonial regionsCountriesCultureDecisionsDefinesDiplomatic actionsDisastersEmpire of ChinaEstatesEventsFactionsGovernmentGreat projectsHistoryHoly Roman EmpireIdea groupsInstitutionsMercenariesMissionsModifiersNation designerOn ActionsParliamentPeace treatiesPoliciesRebel typesReligionSubject typesTechnologyTrade companiesTrade goodsUnits
Map MapNation designerRandom New WorldTrade nodes
Graphics 3D ModelsInterfaceGraphical AssetsFontsParticlesShadersUnit models
Audio MusicSound
Other Console commandsChecksumJoroDox mod making toolMod structureTroubleshootingThe ValidatorRun files
Guides Adding a provinceSave-game editingScripting Tutorial