Results 1 to 7 of 7

Thread: Everything You Need to Know About Portraits

  1. #1

    Default Everything You Need to Know About Portraits

    Introduction

    Portraits in Medieval II are used for custom generals, generic generals, agents, family members, and captains and the process of making portraits for each is the same. Making portraits is almost trivially easy but collecting entire sets for generic pools can be quite time consuming. The most important thing to remember when making portraits is consistency. Small differences in the exposure, content-to-background ratio, headspace, and sharpness are highly noticeable in-game. In this video/text guide, I will walk through the process of creating a portrait, referencing custom portraits, and setting up generic portrait pools making use of all 'tricks of the trade' that I'm aware of.


    Required Applications


    You will need a suitable image editor such as Adobe Photoshop (expensive) or Gimp (free). As a minimum requirement, the editor must be able to work with layers and masks.

    Download Gimp

    I strongly recommend Pictus for viewing TGA file previews. This will make it significantly easier to locate portraits as well as loading screens, etc.

    Pictus Image Viewer

    Criteria for a Good Portrait


    The first step to creating a new portrait or set of portraits is finding a source image. Here are some things to look for:

    1. Thematic Consistency - the portrait should be consistent with the other portraits in the mod. This means avoiding 3D renders and 2D art if the other portraits in the mod are photographs and vice versa. Consistency is very important for generic portraits but is still a factor for custom portraits who may stand out for the wrong reasons next to generic generals in the same army.

    2. Resolution - the native resolution of the source file should be at least high enough that the head fills a 69x96 pixel area. You can usually tell intuitively if a source image will give you a suitable portrait. In the image below (from the 2004 King Arthur movie), I've circled characters who will likely give good portraits in green, characters who might give good portraits in orange, and characters who will likely give poor portraits in red either because they are too small (too low resolution) or obscured by mist or fog. The other background characters aren't worth considering because they are partly obscured by foreground characters.


    3. Quality - this isn't necessarily the same as resolution. You will find many images that are suitable resolution but poor quality. The image below is from a painting of Boudica. It has 250x250 resolution, however, there appears to be a fuzziness due to the paint brush strokes or repeated compression and expansion of the original photograph. Hence, it is unsuitable as a portrait.


    4. Recognizable - for generic portraits, it's usually a good idea to avoid using recognizable actors such as Til Schweiger in the King Arthur example. It is up to your artistic discretion whether to use recognizable actors for custom portraits or to use alternatives such as 3D renders or 2D art.

    I. Making a Portrait


    In this video, I walk through the process of creating a generic general portrait in Gimp.

    Here are the steps.

    1. Open a reference image.

    2. Drop in the background image as a layer.

    3. Cut the head out of the source image and drop it in as a layer.

    4. Scale the head to match the reference image as closely as possible being sure that the head will fit completely within the 69x96 image dimensions.

    5. Delete the reference layer and add a layer mask to the new head's layer.

    6. Using the pencil tool (hard brush), do a first pass crop by painting black in the alpha channel.

    7. Using the brush tool (soft brush) on a smaller size setting), do a close pass "close shave" crop being sure to remove any traces of background color or glare on helmets or hair. If the glare cannot be brushed out without shaving off too much, consider using the Clone tool to copy elements of the surrounding texture onto the problem area and then using the smudge tool to partly blur any hard borders. If the glare is too pervasive, use a different source image.

    8. Show the layer mask and use the pencil tool (hard brush) to paint black over any "floaters" of white or grey that obviously don't belong. Copy the contents of the layer mask and then apply it and make the background layer visible.

    9. Apply the sharpness filter to the head layer being sure not to "over-cook" the image. Sharpen just enough to remove blur when viewing the portrait at the approximate in-game distance. You may also want to use the brightness & contrast tool to increase the sharpness. The Curves tool can be used to adjust overexposed images. The Color Temperature and Hue-Saturation tools can correct for color filters in the source image (movie stills typically have orange or blue filters applied).

    10. Merge the head layer down onto the background layer. Apply a layer mask and paste in the alpha channel contents from before. Apply the layer mask.

    11. Export the portrait as a TGA file. There should be only one layer remaining in the final product (TGA format does not support layers).

    II. Custom Portraits


    If a custom character spawned in descr_strat (DS) or campaign_script (CS) is not assigned a custom portrait, the game will assign a portrait from a generic pool. In order to assign a custom portrait, we use the 'portrait' attribute either in DS or CS as in the examples below.

    descr_strat.txt
    Code:
    character    Halbarad, named character, male, leader, age 32, x 163, y 398, portrait Halbarad, battle_model halbarad, hero_ability CAPTAIN, label halbarad_1
    traits        Halbarad 1, CustomStratModel 1, FactionLeaderCustom 1, Hero 1, DunedainRace 1, HeroAbilityCaptain 1, BattleChivalry 2, CaptorChivalry 1, Energetic 1, GoodCommander 3, HaleAndHearty 1, LoyaltyStarter 1, ReligionStarter 1, Scout 1, LogisticalSkill 2
    ancillaries    grey_banner, arnorian_armour
    army
    unit        Dunedain Horsearchers            exp 3 armour 4 weapon_lvl 1
    ...
    campaign_script.txt
    Code:
           spawn_army
                faction turks
                character    Araphor, named character, age 34, x 158, y 404, portrait Araphor, battle_model araphor, hero_ability CAPTAIN, direction S, label araphor_1
                traits        Araphor 1, CustomStratModel 1, DunedainRace 1, Brave 2, FathersLegacy 1, GoodCommander 2, InspiringSpeaker 1, Just 1, ReligionStarter 1, TacticalSkill 3, Scout 1, LogisticalSkill 1
                unit        Dunedain Aragorn Bodyguard            exp 3 armour 0 weapon_lvl 1
            end
    The portrait name must match a folder name in data/ui/custom_portraits. The portrait name does not need to match the character name. The subfolder in the custom_portraits folder must contain 3 portrait files as shown below (if you don't download Pictus, you won't see these uesful previews for TGA files).



    The three files must have the above names. These names do exactly what they say. The old portrait is used when the character reaches 'old_age' as defined in descr_campaign_db.xml.

    Agents can only be assigned custom portraits in DS, not in CS. Attempting to assign a portrait to a spawned agent such as a diplomat, spy, princess, etc. in CS will result in the file failing to parse. There is only one known method to spawn agents with custom portraits which was discovered by Gigantus. It seems that the spawn_army command permits the portrait tag regardless of agent type. The agent will spawn without the BG unit.

    Code:
        monitor_event FactionTurnStart FactionType england
            spawn_army 
                faction england
                character    random_name, merchant, age 40, x 105, y 145, family, portrait mansfeld
                traits IAmPrincess 1 , NaturalPrincess 2 , GoodPrincess 1 
                unit    NE Bodyguard    exp 6 armour 0 weapon_lvl 0
            end
            terminate_monitor
        end_monitor
    The problem with this script is that the agent will die when the game is reloaded likely because they are missing a BG unit.

    III. Generic Portrait Pools - Religion Sub-folders

    All other characters use generic portraits. These are found in data/ui/culture_name/portraits/portraits. Like custom portraits, they are divided between young, old, and dead. Only generals make use of the old and dead folders. The young and old folders contain portrait pools for generals, spies (rouges), diplomats (civilians), witches, etc. Each of these folders can be divided by religion as in the following example for the northern_european culture's young folder.



    As an example, if we have a faction in the northern_european culture which uses the orthodox religion, its generals will use the default "generals" subfolder for their portraits as there is no orthodox_generals subfolder present for this culture. However, any factions which use the heretic religion will use the heretic_general subfolder for their general portraits and likewise for their diplomats and spies.

    It is not possible to have faction-specific portrait pools. However, Medieval II has 7 hard coded cultures and 10 hard coded religions which means 70 portrait pools (for each agent type) are theoretically possible. So, if none of your 31 factions share the same culture & religion combo, then all 31 can have unique portrait pools.

    It is possible to change a faction's religion mid-campaign using the 'set_religion' command. All subsequent generic generals (born, adopted, married in, trained, converted, etc.) will use the new religion's pool. Generic generals who existed before the religion change will retain their portraits until the campaign is reloaded at which time they will be assigned portraits from the new religion's pool.

    IV. Renaming Generic Files in Sequence Using PowerShell


    It is critical that all religion sub-folders for any agent type have the same number of files. I.e. the northern_european/islam_generals folder must have the same number of files as the northern_european/greek_generals folder. If these folders do not have the same number of files, the game may still assign generals a portrait number that doesn't exist in their pool. The game will then use some random UI element as the portrait which is obviously undesirable. This also applies to other agent types such as spies (rouges), diplomats (civilians), etc.

    Let's say our mod uses 201 files per generic general pool. If we make a new pool, we might not want to go to the trouble of finding and making 201 unique portraits or we might not be able to. A reasonable minimum number of unique portraits is 50 when we have 201 total. This means that for a faction with 20 generals, there will only be approximately a 5% chance of two generals having the same portrait assuming portraits in the pool are assigned with equal probability (less than 1% chance of three or more generals having the same portrait). If we make 50 portraits, we then need to copy these to have 201 portraits while keeping the number of each type of portrait approximately equal (i.e. there should be ~4 of each unique portrait). Renaming the TGA files from 000 to 200 manually will take forever. Instead we can use the following method.

    Use a combination of ctrl-a, ctrl-c, ctrl-v repeatedly until you have enough files in the folder then delete any extras. Hold the SHIFT key and right-click in the File Explorer to open the Windows PowerShell (make sure you are in the correct folder). Input the following commands to format the files into a sequential list from 000 to 200.

    This command puts the files in sequential order.
    Code:
    Dir | %{Rename-Item $_ -NewName ("{0}.tga" -f $nr++)}
    This command removes the unnecessary first digit from the file names.
    Code:
    get-childitem *.tga | Rename-Item -NewName { [string]($_.name).substring(1) }
    Conversely, this command will add a 0 to the beginning of all the file names if you need that.
    Code:
    (get-childItem -File) | Rename-Item -NewName {$_.Name -replace "^","0"}
    Once the PowerShell is done running the commands, manually rename any problem files at the beginning and end (it is likely you will have a file with no name, ".tga"). This technique is also quite useful for renaming loading screens although slightly different PowerShell code is required.

    V. Changing Portraits Mid-Campaign


    There is no known way to change a character's custom portrait mid-campaign. Sending a character off map and respawning will return a character with the same custom portrait. Changing the faction religion will not affect custom portraits. It will change the generic portraits but not until the campaign is reloaded. In the event of a conversion (i.e. using the give_everything_to_faction command), generals will retain their original faction's portraits.

    You can replace the TGA files for custom or generic portraits at any time but you must reload the game before this change will have effect (the game must load the new TGA files into memory). Some mods use a batch file (list of Windows console commands) to perform such a file swap automatically, but the game must still be reloaded. There is no way to do this with scripts or any other 'internal' means.

    Further Reading


    Gigantus' character portrait manual.

    The Spartan Warlord's tutorial using FaceGen to make 3D renders.


    Please let me know if any part of this guide is unclear or if there is anything I'm leaving out. Thanks!
    Last edited by Callistonian; June 19, 2020 at 02:42 PM.

  2. #2
    paleologos's Avatar You need burrito love!!
    Join Date
    Feb 2011
    Location
    Variable
    Posts
    8,496

    Default Re: Everything You Need to Know About Portraits

    Truth be told, I never bothered making my own portraits for a mod, so I am not in the position to evaluate the full usefulness of this tutorial for other people.
    And yet, I cannot help remarking that this is one of the tidiest and most consummate looking tutorial threads in this part of the forums.
    So thumbs up to you and +1 rep!

  3. #3

    Default Re: Everything You Need to Know About Portraits

    Great tutorial!

    As a further tip for reference photos, when I was looking for some for character textures, I often found profile shots of rugby/football players useful. You quite often get a fairly bland passport-style photo of them as part of the team profile pages, and they're not too recognisable out of context, especially with helmet etc added!

  4. #4
    Araval's Avatar Protector Domesticus
    Join Date
    Nov 2010
    Location
    Tartu, Estonia
    Posts
    4,754

    Default Re: Everything You Need to Know About Portraits

    Good effort!

    Some tips.

    The actual files may be oversharpened to some degree because the game adds blur to them.

    It's possible to edit the source image the increase the quality and make it match the rest of the pool better. An example:
    Spoiler Alert, click show to read: 


    It is possible to use FaceApp to make faces look younger/older.

    There is a useful tool by Withwnar that allows you to compare the portrait pools you've made (for example to see if the young and old variants match), generate duplicates to the needed amount and generate dead pools, check if all the portraits indeed have a correct alpha channel (because it displays only the visible part of the portrait). Link: http://www.twcenter.net/forums/showthread.php?624259

    Also, I'd flip the kinds of portraits as you made a video from because about 1/4 of the left side of the portrait may be blocked by chevron and upgrade icons in the game, so you might not see his main facial features at all at some point.

  5. #5

    Default Re: Everything You Need to Know About Portraits

    @Araval - Thanks for the suggestions. There are quite a lot of tools in Gimp that can be used to get the quality and style to match the other portraits in the mod. So I just mention a few and leave the rest to the end user.

    Do you know of any PC apps that can age photos in the same way without uploading/downloading images to somebody's servers each time? Or at least an app without as much... shall we say 'political heat' as FaceApp?

  6. #6
    Araval's Avatar Protector Domesticus
    Join Date
    Nov 2010
    Location
    Tartu, Estonia
    Posts
    4,754

    Default Re: Everything You Need to Know About Portraits

    You're welcome!

    Do you know of any PC apps that can age photos in the same way without uploading/downloading images to somebody's servers each time? Or at least an app without as much... shall we say 'political heat' as FaceApp?
    No, I don't but I haven't looked for any. But a few years ago I did use an android simulator on PC, which could maybe make things a bit less tedious.

  7. #7
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Everything You Need to Know About Portraits

    Nice tutorial.

    It is possible to change a faction's religion mid-campaign using the 'set_religion' command. This can have only one of three possible effects:

    1. ...

    2. All subsequent generic generals (born, adopted, married in, trained, converted, etc.) will use the new religion's pool but generic generals who existed before the religion change will retain their portraits.
    From memory, after a game reload all of the existing ones will now use the new religion's pool too.

Posting Permissions

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