+ Reply to Thread
Page 1 of 9 1 2 3 ... LastLast
Results 1 to 20 of 166

Thread: Crusader Kings II - Dev Diary 7 - Character Portraits and Modding

  1. #1
    Oberkommando HOI4 Paradox Dev Team podcat's Avatar
    200k clubHoI AnthologyDiplomacyFor the MotherlandHearts of Iron III
    HOI3: Their Finest HourEuropa Universalis: RomeSemper FiSengokuVictoria II: A House Divided
    Victoria II: Heart of DarknessMount & Blade: WarbandEuropa Universalis IV: Pre-order

    Join Date
    Jul 2007
    Location
    Werfing Nebels
    Posts
    8,223

    Crusader Kings II - Dev Diary 7 - Character Portraits and Modding

    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:

    Click image for larger version

Name:	stenkil.png
Views:	35256
Size:	167.5 KB
ID:	34343

    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:
    # portraits.gfx
    # graphical look of character portraits
    
    # middle age
    portraitType = {
        name = "PORTRAIT_norsegfx_male1"
        effectFile = "gfx\\FX\\portrait.fx"
        layer = { # GFX_TYPE:[d|p]INDEX:COLOR_LINK
            "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"
        }
    
        hair_color_index = 8 # which DNA gene sets hair color
        hair_color = { # dark, base, highlight
            { 15 8 0 } { 173 158 102 } { 255 255 255 }
            { 10 10 10 } { 125 100 82 } { 255 255 255 }
            { 30 22 18 } { 194 132 97 } { 255 255 255 }
        }
    
        eye_color_index = 9 # which DNA gene sets eye color
        eye_color = {
            { 58 109 193}
            { 120 74 46 }
            { 34 103 36 }
        }
    }
    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:

    Name:  western_male_clothes.png
Views: 25853
Size:  74.7 KB


    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:
    # p3 clothes
    3 = {
        0 = { # mail armour
            factor = 1
            modifier = {
                factor = 2.0
                martial = 5
            }
            modifier = {
                factor = 100.0
                has_job_title  = job_marshal
                OR = {
                    is_ruler = no
                    is_theocracy = no
                    NOT = { religion_group = christian }
                }
            }
        }
        1 = { # fancy shirt
            factor = 5
            modifier = {
                factor = 10.0
                OR = {
                    has_job_title = job_treasurer
                    has_job_title = job_chancellor
                }
            }
        }
        2 = { # Catholic vestments
            factor = 100
            modifier = {
                factor = 0
                NOT = { religion_group = christian }
            }
            modifier = {
                factor = 0
                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:
    # p6 props
    6 = {
        0 = { # empty, dont use props, this is default
            factor = 1
        }
        1 = { # new prop. overrule all if character qualifies
            factor = 100
            modifier = {
                factor = 0
                trait = cool
            }
        }
    }
    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:

    Name:  cool.png
Views: 28246
Size:  126.1 KB


    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 by podcat; 07-04-2011 at 12:53.
    Reject reason to make the impossible possible!

  2. #2
    Quote Originally Posted by podcat View Post
    ...YEAAAAAAAAAAAAAH!...
    Can't wait.

    EDIT: Can the 11 DNA genes & properties be increased further from the final value that PDox settles at?
    EDIT: The artwork is looking really good btw. I was skeptical at first, but it seems amazing so far.
    Last edited by Innocent Beard; 07-04-2011 at 12:57.
    Please Sign the Non-Steam Version Request Petition for SOTS II: http://forum.paradoxplaza.com/forum/...-1-post-person
    QUOTES USED IN POSTS: Always refer to the Original quote to ensure no misunderstandings occur. Click on the small arrows to do so.
    GREATEST NECRO EVER!: http://forum.paradoxplaza.com/forum/...1#post12291291

  3. #3
    Eye of the Storm TempestDK's Avatar
    200k clubCities in MotionCrusader Kings IIDeus VultEuropa Universalis 3
    For The GloryHearts of Iron IIIHeir to the ThroneEuropa Universalis III: In NomineEU3 Napoleon's Ambition
    Victoria: RevolutionsEuropa Universalis: RomeVictoria 2Rome: Vae VictisCK2: Holy Knight
    500k club

    Join Date
    Mar 2002
    Location
    Fairytale Town (CPH)
    Posts
    3,438
    Aweeeesooommee
    I love my copy of CK so much, I am thinking of marrying it

    New Paradox games icons ... get some new cool game icons for your PI games. (of course now updated with CKII icon )

  4. #4
    General tului's Avatar
    Achtung PanzerA Game of DwarvesArsenal of DemocracyCities in MotionCrusader Kings II
    Commander: Conquest of the AmericasDeus VultEast India Company CollectionElven Legacy CollectionEuropa Universalis 3
    Europa Universalis: ChroniclesEU3 CompleteDivine WindFor The GloryFor the Motherland
    Hearts of Iron IIIHOI3: Their Finest HourHeir to the ThroneImpireKing Arthur II
    The Kings CrusadeMagickaNaval War: Arctic CirclePirates of Black CoveVictoria: Revolutions
    Rome GoldSemper FiSengokuShip Simulator ExtremesSword of the Stars
    Sword of the Stars IIVictoria 2Victoria II: A House DividedVictoria II: Heart of DarknessMount & Blade: Warband
    Mount & Blade: With Fire and SwordWar of the RosesV2 AHD BetaPride of NationsCK2: Holy Knight
    500k clubEuropa Universalis IV: Pre-orderEUIV: Call to arms event

    Join Date
    Oct 2009
    Location
    North Carolina
    Posts
    1,736
    Come on, make the sunglasses a "cheat code" from the console. Make the code Johan_is_cool or something.

  5. #5
    Major CatalanNation's Avatar
    200k clubCities in MotionCities in Motion 2Crusader Kings IIDeus Vult
    Europa Universalis 3Europa Universalis: ChroniclesHearts of Iron IIIRome GoldSengoku
    Victoria 2Victoria II: A House DividedVictoria II: Heart of DarknessCK2: Holy Knight500k club
    Europa Universalis IV: Pre-orderCrusader Kings II: Legacy of RomeCrusader Kings II: Sword of IslamCrusader Kings II: The RepublicCrusader Kings II: The Old Gods
    Crusader Kings II: Sons of AbrahamCrusader Kings II: Rajas of India

    Join Date
    Apr 2006
    Location
    Standing on the corner
    Posts
    633
    You can always include sunglasses and cool trait as a pre-order DLC goodie. :P

    BTW, absolutely brilliant system, it exceeds all expectations!
    Last edited by CatalanNation; 07-04-2011 at 13:19.
    1 Clerk
    Nationality: Catalan
    Religion: Atheist
    Ideology: Liberal
    Issues: Protectionism / 5 Hour Max Work Day
    Current Work: Cement Factory
    Cash Reserves: Enough
    Revolt Risk: 1.8%
    Militancy: 4.3
    Consciousness: 7.8

  6. #6
    El Caballero jonlucero's Avatar
    Cities in MotionCrusader Kings IIDeus VultEU3 CompleteDivine Wind
    Hearts of Iron IIIHeir to the ThroneVictoria 2Victoria II: A House DividedMount & Blade: Warband
    500k clubEUIV: Call to arms event

    Join Date
    Apr 2008
    Location
    Ciudad de Cebú
    Posts
    1,129
    cool features! 4 stages and the DNA thing.. I bet scripting for arab women would be so much more easier, just my two cents..
    /MCMLXXXIX

  7. #7
    Crusader Kaleidoscope's Avatar
    200k clubArsenal of DemocracyCrusader Kings IIDeus VultEuropa Universalis: Chronicles
    EU3 CompleteDivine WindFor the MotherlandHearts of Iron IIIHeir to the Throne
    Lead and GoldMagickaMajesty 2Penumbra - Black PlagueVictoria: Revolutions
    Europa Universalis: RomeSemper FiSengokuVictoria 2Rome: Vae Victis
    Mount & Blade: WarbandCK2: Holy Knight500k clubEuropa Universalis IV

    Join Date
    Aug 2008
    Location
    Dong City
    Posts
    397
    Another month, another dev diary that tells us nothing about gameplay mechanics. :|
    Sola Virtus Invicta

  8. #8
    Quote Originally Posted by podcat View Post
    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:

    Attachment 34341

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

    YEAAAAAAAAAAAAAH!
    STRIDER STYLE

    Seriously though, this looks really neat, even without the Homestuck reference. Keep up the good work!

  9. #9
    Not really a fascist brony monsterfurby's Avatar
    Cities in MotionCrusader Kings IIDarkest HourDeus VultDungeonland
    Europa Universalis 3Divine WindFor The GloryHearts of Iron IIIHeir to the Throne
    Europa Universalis III: In NomineMagickaMarch of the EaglesEU3 Napoleon's AmbitionVictoria: Revolutions
    Europa Universalis: RomeSemper FiSengokuSupreme Ruler 2020Victoria 2
    Victoria II: A House DividedVictoria II: Heart of DarknessRome: Vae VictisMount & Blade: Warband500k club
    Europa Universalis IV: Pre-orderEUIV: Wealth of NationsEUIV: Conquest of ParadiseEUIV: Res PublicaCrusader Kings II: Legacy of Rome
    Crusader Kings II: Sword of IslamCrusader Kings II: Sunset InvasionCrusader Kings II: The RepublicCrusader Kings II: The Old GodsCrusader Kings II: Sons of Abraham
    Crusader Kings II: Rajas of IndiaCrusader Kings II: Charlemagne

    Join Date
    Jul 2005
    Location
    Kingdom of Hannover
    Posts
    1,540
    Well, what to say?

    "Awesome!", that's what.
    Last edited by monsterfurby; 07-04-2011 at 13:55.
    Public Service Announcement:
    "...this is still a free country and anyone telling a
    fellow like me "brother you're full of ****" better be
    good and ready to answer politely when asked if he'd care
    to say why!"

  10. #10
    This is BRILLIANT. It's great this system can be modded to such an extend. It surprised me.

  11. #11
    Wow, brilliant!
    It seems like a lot of work has gone into creating these, especially with all of those layers.

  12. #12
    Corporal Hellblazer's Avatar
    Crusader Kings IIEU3 CompleteDivine WindFor the MotherlandHearts of Iron III
    Heir to the ThroneMagickaSemper FiVictoria 2Victoria II: A House Divided

    Join Date
    Dec 2010
    Location
    Alberta,Canada
    Posts
    47
    Haha, sun glasses look hilarious

  13. #13
    Somewhat off-topic, but will Sengoku also use this system?

  14. #14
    Colonel Kuipy's Avatar
    200k clubHearts of Iron 2: ArmageddonCrusader Kings IIDeus VultEuropa Universalis 3
    Divine WindHearts of Iron IIIHeir to the ThroneEuropa Universalis III: In NomineEU3 Napoleon's Ambition
    Victoria: RevolutionsRome GoldSemper FiVictoria 2CK2: Holy Knight
    500k club

    Join Date
    Jan 2007
    Location
    Back in th'old country.,France
    Posts
    989
    (disclaimer: there probably wont be any sunglasses in the real game)
    So there will be a "cool" trait ?

  15. #15
    Maybe there could be a 'hipster' trait, with thick-rimmed glasses...

  16. #16
    Major Tyson_48's Avatar
    Crusader Kings IIDarkest HourDeus VultEU3 CompleteHearts of Iron III
    Europa Universalis: RomeVictoria 2Rome: Vae VictisCK2: Holy Knight500k club
    Europa Universalis IVEUIV: Wealth of NationsEUIV: Res Publica

    Join Date
    Apr 2008
    Location
    Berlin,Afghanistan
    Posts
    613
    Blog Entries
    1
    Very nice so far... Thanks!

    Is there a chance we will get some effects from traits?
    Perhaps a "crazed" character get some insane eyes or something...

  17. #17


    So were you serious about offspring of dubious origin looking different from their "father"? And will they look like their actual father? That would be awesome.
    v = {sx mod n : n,s∈N, n≥3, s<n, x∈Zn*, x≥y ∀y∈Zn*, sx mod n ≠ s}
    No no no no no
    No no no no no no no
    No no no no ...yes?

  18. #18
    Quote Originally Posted by Tyson_48 View Post
    Very nice so far... Thanks!

    Is there a chance we will get some effects from traits?
    Perhaps a "crazed" character get some insane eyes or something...
    No it seems it wouldn't be feasible in terms of effort required.
    See the actual comments from Danevang (who is actually doing the artwork):
    Quote Originally Posted by Danevang View Post
    Well, consider the many required facial expressions if one was to have say 15 different eyebrows, and multiply them for the what...40 or how many traits are in the game, and add to that the same amount for women, for several looks (european, arab). That's 2400 eyebrows, if every trait was to have seperate facial features. Even with only half of the traits having distinct eyebrows it would be 1200 eyebrows in game, plus 1200 foreheads, ears, mouths and so on. Not very practical. So portraits stuff is either dna inherited or scriptable. Anyway, in real life a nice guy can be born with mean looking eyebrows, and a mean guy can look ever so kind, so it's realistic enough.

    On another note, I like the fact that some people are now liking the portraits better, even though I asked that they not be too quick to judge on the last few images. The faces you see now is of the same batch of work as the last ones released. Hehe. Nothing has changed regarding the faces yet, so I'm glad you're liking them better. But seriously, the women are coming along, and don't look too shabby.
    Quote Originally Posted by Danevang View Post
    I understand what he meant, and what I tried to explain is that if in 2d layers facial expressions could vary in the many dna facial features, it would require a huge amount of images. For X mouth you'd need to have x= smile, x=angry and so on variants. I.e. most mouths will be "I'm feeling okay look", but some people have their mouth slightly open when feeling okay, others will have it somewhat hanging (in a frown), others will have a slightly psychotic smile. Heh. Short answer = faces are dna controlled, anything else would really require true 3d faces (or a bad solution where all sad people have the same face..not good).
    Please Sign the Non-Steam Version Request Petition for SOTS II: http://forum.paradoxplaza.com/forum/...-1-post-person
    QUOTES USED IN POSTS: Always refer to the Original quote to ensure no misunderstandings occur. Click on the small arrows to do so.
    GREATEST NECRO EVER!: http://forum.paradoxplaza.com/forum/...1#post12291291

  19. #19
    Modding Paladin RedRooster81's Avatar
    Cities in MotionCrusader Kings IIDeus VultEU3 CompleteDivine Wind
    Heir to the ThroneRome GoldMount & Blade: Warband500k club

    Join Date
    Feb 2010
    Location
    The Castle of Aaaggggggh
    Posts
    5,646
    Cool. I can imagine all kinds of interesting props that could be added. I like that these are tied to traits, and clothing is tied to a variety of factors, including court positions.

    Just a technical question: how often are these factors checked? As in once a month, once a year, only on game load? If I name John Knottinghill as my spiritual lord then change him to chancellor, will his clothing change immediately? Keep up the good work. Thanks.

  20. #20
    Oberkommando HOI4 Paradox Dev Team podcat's Avatar
    200k clubHoI AnthologyDiplomacyFor the MotherlandHearts of Iron III
    HOI3: Their Finest HourEuropa Universalis: RomeSemper FiSengokuVictoria II: A House Divided
    Victoria II: Heart of DarknessMount & Blade: WarbandEuropa Universalis IV: Pre-order

    Join Date
    Jul 2007
    Location
    Werfing Nebels
    Posts
    8,223
    Quote Originally Posted by RedRooster81 View Post
    Just a technical question: how often are these factors checked? As in once a month, once a year, only on game load? If I name John Knottinghill as my spiritual lord then change him to chancellor, will his clothing change immediately? Keep up the good work. Thanks.
    This is subject to change as we come up with more things that can change the look but right now always if you get a new trait or a new title or job. I think I also put in a random update once a year, but I cant remember right now. That would depend on performance impact if it stays in the final version but could be used for changing hair styles etc every few years if wanted by modders etc.
    Reject reason to make the impossible possible!

+ Reply to Thread
Page 1 of 9 1 2 3 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts