• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.
Since there was some discussions and curious people in the last dev diary thread I thought I should take a break from HOI3: For the Motherland and describe how the character portrait system works. If there are any art questions perhaps Danevang who is doing the actual art can answer those for you, I will focus more on the technical aspects. Remember that all of these pictures are still very much in progress and things will change and a lot of things will be added.


The primordial goo

The way a character looks is based on two things: inheritance (we call this DNA) and other factors (we call these properties). Your DNA is created when you are born and cant be changed. Its a mix of your characters parents DNA plus a small "mutation chance" to simulate genes from ancestors and to make people look different despite not having millions of characters. Properties on the other hand change during a characters lifetime depending on traits, social status etc.

For example DNA will tell if you inherited the big 'ol family potato nose and blond hair (and if not it might cast some suspicions on what your mom was up to while your dad was busy crusading) and properties will tell what kind of hair style you prefer and if you are likely to wear a crown because you're king and how fancy your clothes are.
Currently there are 11 DNA genes and 6 properties for each character, but its not unlikely that we will increase these during the project.

Below is a picture showing inheritance, sadly none of our female portraits are ready for showing yet so I'v shown only the male line:

stenkil.png

You can also see the effects of properties, our character in the middle is a king with a crown and one of his sons is a bishop, above him is his late father. This picture also shows the effect of aging. We currently have 4 age levels for the portraits so you will see your characters grow wrinklier, get bigger ears and their hair thinning and becoming white.

The DNA is scriptable in history files for character if we want to make someone look like their historic counter part (arguably this was more important in EU: Rome because the romans were pretty good at making statues so we could see what people looked like), then during startup the game will run through characters outwards from scripted ones and propagate their genes for a plausible result for all the ones not scripted.


Hey, you said this was about modding not biology!

ok ok, lets see some code and I'll show you how characters can be modded.
Character portraits are described in two files, one for the graphics and one for scripting logic around properties.

Graphical portrait setup
Code:
[COLOR=YellowGreen]# portraits.gfx[/COLOR]
[COLOR=YellowGreen]# graphical look of character portraits[/COLOR]

[COLOR=YellowGreen]# middle age[/COLOR]
portraitType = {
    name = [COLOR=Magenta]"PORTRAIT_norsegfx_male1"[/COLOR]
    effectFile = [COLOR=Magenta]"gfx\\FX\\portrait.fx"[/COLOR]
    layer = { [COLOR=YellowGreen]# GFX_TYPE:[d|p]INDEX:COLOR_LINK[/COLOR]
        [COLOR=Magenta]"GFX_character_western_background:p0"
        "GFX_western_male_clothes_behind:p3"
        "GFX_western_male_headgear_behind:p5"
        "GFX_western_male_beard_behind_midage:p4:h"
        "GFX_western_male_base_midage:p2"
        "GFX_western_male_neck:d0"
        "GFX_western_male_chin:d1"
        "GFX_western_male_mouth_midage:d2"
        "GFX_western_male_nose_midage:d3"
        "GFX_western_male_cheeks_midage:d4"
        "GFX_western_male_head:d5"
        "GFX_western_male_eyes_midage:d6"
        "GFX_western_male_eyes2:d6:e"
        "GFX_western_male_clothes:p3"
        "GFX_western_male_beard_midage:p4:h"
        "GFX_western_male_ear_midage:d7"
        "GFX_western_male_clothes_infront:p3"
        "GFX_western_male_headgear:p5"[/COLOR]
    }

    hair_color_index = [COLOR=Cyan]8[/COLOR] [COLOR=YellowGreen]# which DNA gene sets hair color[/COLOR]
    hair_color = { [COLOR=YellowGreen]# dark, base, highlight[/COLOR]
        { [COLOR=Cyan]15 8 0[/COLOR] } { [COLOR=Cyan]173 158 102[/COLOR] } { [COLOR=Cyan]255 255 255[/COLOR] }
        { [COLOR=Cyan]10 10 10[/COLOR] } { [COLOR=Cyan]125 100 82[/COLOR] } { [COLOR=Cyan]255 255 255[/COLOR] }
        { [COLOR=Cyan]30 22 18[/COLOR] } { [COLOR=Cyan]194 132 97[/COLOR] } { [COLOR=Cyan]255 255 255[/COLOR] }
    }

    eye_color_index = [COLOR=Cyan]9[/COLOR] [COLOR=YellowGreen]# which DNA gene sets eye color[/COLOR]
    eye_color = {
        { [COLOR=Cyan]58 109 193[/COLOR]}
        { [COLOR=Cyan]120 74 46[/COLOR] }
        { [COLOR=Cyan]34 103 36[/COLOR] }
    }
}
The name for the portrait type specifies that this is used for the norse graphical culture group and that he is male and middle aged (the number at the end sets age). The portrait is made up of 18 layers (this can change between ages and cultures as well if wanted) and each layer has a string describing it. Lets use "GFX_western_male_beard_midage:p4:h" as an example. This specifies that it should use an image from the GFX_western_male_beard_midage icon strip (specified higher up in the file), that it should use property 4 :)p4) from the character to decide which beard to pick and the last ":h" means that it should be colored using the characters Hair color. If we had wanted to connect to DNA instead of a property (like for the nose) we would write :d4 instead of p4.

Layers are free to connect to the same property and this is done quite a bit for clothes and beard/hair etc that needs to show both behind and in front of other layers. This is what GFX_western_male_clothes looks like for the first 3 options:

western_male_clothes.png

Further down are hair and eye colors specified. For hair there is 3 colors for each property so we can tint hair highlights differently from base colors etc.

Property scripting
A separate file "portrait_properties.txt" specifies what properties a character should have. These are updated on major changes on the character like a new trait, a new title etc and also randomly once in a while. Scripting properties looks like this this, any property not mentioned will basically have a random value picked (so if we don't specify anything for hair/beards you will just get a random beard):
Code:
[COLOR=YellowGreen]# p3 clothes[/COLOR]
[COLOR=Cyan]3 [/COLOR]= {
    [COLOR=Cyan]0[/COLOR] = { [COLOR=YellowGreen]# mail armour[/COLOR]
        factor = [COLOR=Cyan]1[/COLOR]
        modifier = {
            factor = [COLOR=Cyan]2.0[/COLOR]
            martial = [COLOR=Cyan]5[/COLOR]
        }
        modifier = {
            factor = [COLOR=Cyan]100.0[/COLOR]
            has_job_title  = job_marshal
            OR = {
                is_ruler = no
                is_theocracy = no
                NOT = { religion_group = christian }
            }
        }
    }
    [COLOR=Cyan]1[/COLOR] = { [COLOR=YellowGreen]# fancy shirt[/COLOR]
        factor = [COLOR=Cyan]5[/COLOR]
        modifier = {
            factor = [COLOR=Cyan]10.0[/COLOR]
            OR = {
                has_job_title = job_treasurer
                has_job_title = job_chancellor
            }
        }
    }
    [COLOR=Cyan]2[/COLOR] = { [COLOR=YellowGreen]# Catholic vestments[/COLOR]
        factor = [COLOR=Cyan]100[/COLOR]
        modifier = {
            factor = 0
            NOT = { religion_group = christian }
        }
        modifier = {
            factor = [COLOR=Cyan]0[/COLOR]
            OR = {
                is_ruler = no
                is_theocracy = no
            }
            NOT = { has_job_title  = job_spiritual }
        }
    }
}
The top level is the property, so 3 is the same as :p3 in the graphical description we showed above. The next level in specifies which entry among the icons to pick, this script basically selects between 3 options: chain mail, fancy shirt and a more spiritual outfit. The factors you see are just percentages, but if something is specified with a value of 100 or above it always overrules any other option after it.

Alright, hopefully that was clear. So lets test this with an example. We want to add another layer connected to property 6 to our portrait. lets call it "props" so first we declare a sprite like normally in our gfx file and refer to it in the portrait description at the very end with "GFX_western_male_props:p6". Then we add a rule in the properties script like so:
Code:
[COLOR=YellowGreen]# p6 props[/COLOR]
[COLOR=Cyan]6 [/COLOR]= {
    [COLOR=Cyan]0[/COLOR] = { [COLOR=YellowGreen]# empty, dont use props, this is default[/COLOR]
        factor = [COLOR=Cyan]1[/COLOR]
    }
    [COLOR=Cyan]1[/COLOR] = { [COLOR=YellowGreen]# new prop. overrule all if character qualifies[/COLOR]
        factor = [COLOR=Cyan]100[/COLOR]
        modifier = {
            factor = [COLOR=Cyan]0[/COLOR]
            trait = [COLOR=Red]cool[/COLOR]
        }
    }
}
This means that if our character gains the "cool" trait and we have done our modding correctly his portrait will be changed to something like this:

cool.png

Looks like this
*puts on sunglasses*
wraps up this developer diary.

YEAAAAAAAAAAAAAH!

(disclaimer: there probably wont be any sunglasses in the real game)
 
Last edited:
I don't really remember Biology lessons that well but isn't it possible for 2 black haired people to get a blond haired child (like 25% percent or something if the both have the Aa Aa alleles? (ie they inherited the recessive blond allel from one of the grandparents) Or is this only for eye color? This is probably off topic though so don't know if we should get into it :)

Yes it is possible, if both are heterozygote(Aa) black because then there is a 25 % chance of having an offspring with blonde(aa) hair. But I was refering to the offspring of a homozygote(AA) black-haired and a blonde(aa) haired. In this case 100% of the offspring would become heterozygote(Aa) black-haired. But maybe its not a big deal after all since most people dont seem to care much about it beside me.
 
Lol what an argument is that? Why should they even try to improve the physics of, lets say battles then, if all you care about is how historical accurate characthers are?

A practical one. No game can ever model reality completely. So by definition and necessaity, it selects a subset of reality to model. This may well be your personal bugbear, but it isn't likely to have much significance beyond that.

Plus, there are no "physics" in CK battles. If you were doing, say, a flight sim, then physics would be an important factor. Neither physics nor genetics are important factors in CK. That's all there is to it.
 
Yes it is possible, if both are heterozygote(Aa) black because then there is a 25 % chance of having an offspring with blonde(aa) hair. But I was refering to the offspring of a homozygote(AA) black-haired and a blonde(aa) haired. In this case 100% of the offspring would become heterozygote(Aa) black-haired. But maybe its not a big deal after all since most people dont seem to care much about it beside me.

Genetics isn't quite as simple as you suggest. For one, you can't tell if a person is AA or Aa just by looking at them, since the A will be displayed in either case. In the case of codominant genes, it gets more complicated. In terms of "race" (which really doesn't exist at the genetic level, but we'll classify in terms of skin tone), there is almost always some sort of blending of the skin tones of the mother and father.

So you're right, I don't think anybody cares about it besides you. And I think the people who would care (i.e. people who are really into genetics) probably would challenge your understanding of the subject.
 
But genetics can be simplified by the Mendel laws. It's not really about simulating genetics, but simulating phenotypes (i.e. appearance). Also, Mendel laws can be calculated, as they are binomes. I'd really like this to be modelled into the game.
 
So I think interracial marriages happened and we had mixed-race people, so why not good potraits of them? (But yeah only muslims admit this happening so... dont really know if this is too not relevant to the game)

Good point. What you quote from Wikipedia talks about Muslim men having multiracial children, but you would find similar things wherever there were, for lack of a better term, racial frontiers, where the incoming population, often as conquerers, were predominantly young males. And we have to make allowances not just for historical cases but also given the nature of the game, what could happen. What if the AI Normans in Sicily do what they regularly did in my CK1 games and conquer a nice swath of North Africa and push into Nubia? Or as many people have expressed concern over, what if Mongols lay roots down in Eastern Europe or the Berbers take over Iceland? What would the nobility of those countries look like in a generation or two?

Well, the idea of "race" did not exist as such (religion and descent were more important distinctions; I would say that we are more interested in what powerful people *looked* like than our medieval forbears), but putting that aside, I would say that you would find a good deal of multiracial children in the medieval Mediterranean, and then again the question would be how or if the devs define "races." The important *so what* question here is whether children such unions were recognized into the nobility, which is our concern in CK2. If Roger Borsa de Hauteville had conquered Tunisia and married a Muslim woman or a convert and had offspring, would his sons be recognized as nobles and only then should we start obsessing over what they would look like. The Mediterranean was a racially diverse place, if we apply current ideas to that time, with lots of different populations on the move and a strong slave trade from the Black Sea area, Sub-Saharan Africa, and Eastern Europe. But, like it or not, this may not have mattered, unless fathers recognized their children, which tended to happen more often in Islamic societies, but then again certain Western European peoples, including the Normans, Welsh, and Scandinavians, were more relaxed in accepting royal bastards than others were.

If phenotype is coded to work across a range, then you can work from Mendel's laws, as has been suggested here, with a Nubian father and Swedish mother (or vice versa) producing children with skin color, hair type, eye color, etc. being somewhere in between or a mix of traits from both sides.

If however, there are hardcoded "races," say one Northern European, one for Mediterranean folk, another for subsaharan Africans, etc., then the results I would assume would be similar to what happened in CK1, where in my experience race and culture tended to follow the father's, with out of six children, one or two having the race of the mother and so standing out in the crowd.
 
But genetics can be simplified by the Mendel laws. It's not really about simulating genetics, but simulating phenotypes (i.e. appearance). Also, Mendel laws can be calculated, as they are binomes. I'd really like this to be modelled into the game.

one reason not to go with genetics laws is that we have a limited set of characters unlike in the real world where there are billions of people. This means that there is a high risk of everyone looking like each others inbred cousins at the end of a long game if we model dominant genes. We also dont use genes from parents that might have been passed along but not become visible in the child. To simulate this to an extent we also have a small "mutation factor" of a few percent every time new dna is generated. In Rome we needed a pretty high mutation factor (20%) to make things look different enough but we are going to have more portraits and options and characters here in CK2 making something like 2-5% more of an option.

to support genetics rules we would also need a whole new rule system that would have to be made scriptable/moddable and we didnt think the result was worth the effort when it could also bring all sorts of problems with it.
 
Impressive, really.
This will be one great game...
 
one reason not to go with genetics laws is that we have a limited set of characters unlike in the real world where there are billions of people. This means that there is a high risk of everyone looking like each others inbred cousins at the end of a long game if we model dominant genes. We also dont use genes from parents that might have been passed along but not become visible in the child. To simulate this to an extent we also have a small "mutation factor" of a few percent every time new dna is generated. In Rome we needed a pretty high mutation factor (20%) to make things look different enough but we are going to have more portraits and options and characters here in CK2 making something like 2-5% more of an option.

to support genetics rules we would also need a whole new rule system that would have to be made scriptable/moddable and we didnt think the result was worth the effort when it could also bring all sorts of problems with it.

I guess here is where actual 3d portraits would be beneficial (no need to have tons of pre-rendered layers, and diversity of facial features limited only by number of textures). Perhaps in CK3? ;) How about 'ethnic groups' of portraits - would there be more of them than in CK1 (Muslim and Christian)?
 
I guess here is where actual 3d portraits would be beneficial (no need to have tons of pre-rendered layers, and diversity of facial features limited only by number of textures). Perhaps in CK3? ;) How about 'ethnic groups' of portraits - would there be more of them than in CK1 (Muslim and Christian)?

absolutely. a system like that lets you blend bone structure as well as part of the DNA so will let you get really cool results, but its a few magnitudes more work to do, so yeah maybe for CK3 if its successful enough *hint hint*
 
one reason not to go with genetics laws is that we have a limited set of characters unlike in the real world where there are billions of people. This means that there is a high risk of everyone looking like each others inbred cousins at the end of a long game if we model dominant genes. We also dont use genes from parents that might have been passed along but not become visible in the child. To simulate this to an extent we also have a small "mutation factor" of a few percent every time new dna is generated. In Rome we needed a pretty high mutation factor (20%) to make things look different enough but we are going to have more portraits and options and characters here in CK2 making something like 2-5% more of an option.

to support genetics rules we would also need a whole new rule system that would have to be made scriptable/moddable and we didnt think the result was worth the effort when it could also bring all sorts of problems with it.

Thanks for the elaborate response podcat.
 
one reason not to go with genetics laws is that we have a limited set of characters unlike in the real world where there are billions of people. This means that there is a high risk of everyone looking like each others inbred cousins at the end of a long game if we model dominant genes.

Sounds like real life to me

Czar Nicholas II & King George V.
ts
 
This game looks increasingly fun!
 
Sounds like real life to me

Czar Nicholas II & King George V.
ts

Yes, please. This example is delicious, but it's just one among many. For example, the King of Aragon, John II, and his cousin Ferrante of Naples, were very much alike.

****

Hey, I've been thinking: if this feature is so moddable, what about setting different cloth and hairstyles depending on the century?

Fashion changes a lot. Especially if you are to add military cloth into the portraits, a mail hauberk and a surcoat feels wrong for the XIVth Century, where transitional plate was so notorious. And being in the 1400's without plate armour is a serious letdown.

The same way I cannot imagine Frederick II in plate armour and typical haircut, I don't want to think of Matthias Corvinus without his flamant and shiny silvery plate armour, long renaissance-like hair and a crown of weath on his head.

Also, hairstyle and this kind of traits should depend on culture as well. In Eastern Euorpe, especially Orthodox countries, everyone should have a beard, with few exceptions. In the West, on the contrary, mostly every nobleman shaved until he had real power. When he grew old and powerful, he let his beard grow, because it was a symbol of the elder's authority. Still, many kings in the XII-XIIIth Centuires shaved, like Philippe II Auguste or Frederick II. Also, what would be of the XIVth without the big moustaches!?

So, even if the developers don't do that, I'd like to know if it's possible to assigne different cloth for each century, and also depending on the culture.
 
Yes, please. This example is delicious, but it's just one among many. For example, the King of Aragon, John II, and his cousin Ferrante of Naples, were very much alike.

****

Hey, I've been thinking: if this feature is so moddable, what about setting different cloth and hairstyles depending on the century?

Fashion changes a lot. Especially if you are to add military cloth into the portraits, a mail hauberk and a surcoat feels wrong for the XIVth Century, where transitional plate was so notorious. And being in the 1400's without plate armour is a serious letdown.

The same way I cannot imagine Frederick II in plate armour and typical haircut, I don't want to think of Matthias Corvinus without his flamant and shiny silvery plate armour, long renaissance-like hair and a crown of weath on his head.

Also, hairstyle and this kind of traits should depend on culture as well. In Eastern Euorpe, especially Orthodox countries, everyone should have a beard, with few exceptions. In the West, on the contrary, mostly every nobleman shaved until he had real power. When he grew old and powerful, he let his beard grow, because it was a symbol of the elder's authority. Still, many kings in the XII-XIIIth Centuires shaved, like Philippe II Auguste or Frederick II. Also, what would be of the XIVth without the big moustaches!?

So, even if the developers don't do that, I'd like to know if it's possible to assigne different cloth for each century, and also depending on the culture.

Cesar, see post #20. Some interesting possibilities on fashion and hairstyles would be, well, possible.
 
But genetics can be simplified by the Mendel laws. It's not really about simulating genetics, but simulating phenotypes (i.e. appearance). Also, Mendel laws can be calculated, as they are binomes. I'd really like this to be modelled into the game.

Skin color is much more complicated than just Mendel's laws.

Also people in CK do not know Mendel's laws, so they were not able to detect childs with another, biological father. I see no point in discussing this detail. Rome's random perutations are fine.
 
The only thing i didnt in this DD was the chain mail representation (i think they call it mail coif in English). It looks like someone put a carpet over these guy's heads. A simple helmet or even padded coif would look so much better, i think even if you just added some sort of material bellow mail would improve it quite a lot. That guy in the middle (2nd from above) looks kinda too old for mail anyway.
 
Skin color is much more complicated than just Mendel's laws.

Also people in CK do not know Mendel's laws, so they were not able to detect childs with another, biological father. I see no point in discussing this detail. Rome's random perutations are fine.

Phenotype does get complicated with the addition of generations. Mendel might be a good start: but here you can see the complexity. Plus skin color is not the only measure: there is also hair type, bone structure, and some finer details like nose and ear size and shape. What would be ideal would be FaceGen, as in M&B and TES IV: Oblivion, where you can generate true 3D faces with a number of different sliding scales.

I am nonetheless looking forward to seeing how diverse heredity will be resolved in CK2. I would prefer the possibility of mixing traits in children of say, a Swedish father and Greek mother or a Mongol father and Irish mother. In CK1, there were different racial types that read the DNA number code differently based on which type was assigned to a character. For me this is not a deal-breaker, but I would like one type for all characters.

As to details of paternity, there was a sense of heredity, not expressed in scientific terms of course, but lineage and legitimacy was a serious matter in all corners of our game map.