Correct sizes for Unit and Unit Portrait icons

maconnolly

Warlord
Joined
Jun 3, 2019
Messages
209
OK, so I'm fairly confused.

The game specifies a number of sizes of atlas for each of the Unit and Unit Portrait icon-sets. They are specified clearly and are easy to pick out from the base-game files.

For the units, the information is in the Icons_Units.xml and appears as below:

Spoiler :
Code:
<IconTextureAtlases>
    <Row Name="ICON_ATLAS_UNITS" IconSize="256" IconsPerRow="16" IconsPerColumn="8" Filename="Units256.dds"/>
      <Row Name="ICON_ATLAS_UNITS" IconSize="80" IconsPerRow="16" IconsPerColumn="8" Filename="Units80.dds"/>
      <Row Name="ICON_ATLAS_UNITS" IconSize="50" IconsPerRow="16" IconsPerColumn="8" Filename="Units50.dds"/>
      <Row Name="ICON_ATLAS_UNITS" IconSize="38" IconsPerRow="16" IconsPerColumn="8" Filename="Units38.dds"/>
      <Row Name="ICON_ATLAS_UNITS" IconSize="32" IconsPerRow="16" IconsPerColumn="8" Filename="Units32.dds"/>
        <Row Name="ICON_ATLAS_UNITS" IconSize="22" IconsPerRow="16" IconsPerColumn="8" Filename="Units22.dds"/>
        <Row Name="ICON_ATLAS_UNITS_FOW" IconSize="32" IconsPerRow="16" IconsPerColumn="8" Filename="Units32.dds"/>
  </IconTextureAtlases>

For the unit portraits, we have it in the Icons_UnitPortraits.xml. An extract (excluding cultural variations) is as below:

Spoiler :
Code:
<IconTextureAtlases>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS"   IconSize="256" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits256_1"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS_2" IconSize="256" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits256_2"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS"   IconSize="200" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits200_1"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS_2" IconSize="200" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits200_2"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS"   IconSize="95" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits95_1"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS_2" IconSize="95" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits95_2"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS"   IconSize="70" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits70_1"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS_2" IconSize="70" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits70_2"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS"   IconSize="50" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits50_1"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS_2" IconSize="50" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits50_2"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS"   IconSize="38" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits38_1"/>
    <Row Name="ICON_ATLAS_UNIT_PORTRAITS_2" IconSize="38" IconsPerRow="8" IconsPerColumn="8" Filename="UnitPortraits38_2"/>
</IconTextureAtlases>

Therefore, it stands to reason that unit icons are in sizes: 22px, 32px, 38px, 50px, 80px, 256px.
Similarly, unit portraits are in sizes: 38px, 50px, 70px, 95px, 200px, 256px.

However, when I configure my mods to match these specifications, the units icons work like a charm. However, unit portraits do not work correctly when they are in these sizes.

If I include unit portraits at the same sizes as the unit icons, they work just fine. Therefore, my workflow is to ignore what I can see in the base-game and simply go with what works. But I'm interested to understand what I'm missing.

I can't see anything in either of the Expansions that suggests Firaxis have modified the unit portraits atlases to use any sizes other than those quoted in code, above. Can anyone unravel this mystery for me?
 
I can confidently say that only 95px size for unit portraits is actually required. I haven't created in any other size for Steel & Thunder for a long time now.

Not sure which unit icon sizes are actually used. Probably only 2 or 3 of them.

This is the Icons XML for Steel & Thunder: Unique Units:
https://github.com/deliverator23/Mo...MoarUniqueUnits/Data/MOARUniqueUnitsIcons.xml

Thanks for the reply! But I am fairly confused around the unit portraits element of this. I have not had any success when using the 95px (along with other) sizes and, yet, when I use the same sizes I've been using for unit icons (256, 80, 50, 38, 32 and 22) it definitely works.

In the next mod I stand up I am going to configure just the 95px size and see what happens. Clearly you have a functional and very-well-established mod that followed this sizing-definition that works - so it can only be something at my end.
 
I think it might be important to include .dds in the Filename.
 
I think it might be important to include .dds in the Filename.

Yes, indeed. I am pretty sure that my code is accurate - as mentioned, it works fine when using the same sizes for unit portraits as for unit icons. The mystery, I guess, is why.

This is a code extract for the functional version:

Code:
INSERT INTO        IconTextureAtlases
                (Name,                                            IconSize,    IconsPerRow,    IconsPerColumn,        Filename                                )
VALUES            ('DIVERSITY_TECH_ICON_ATLAS',                    160,        4,                1,                    'DiversityNewTech160.dds'                ),
                ('DIVERSITY_TECH_ICON_ATLAS',                    128,        4,                1,                    'DiversityNewTech128.dds'                ),
                ('DIVERSITY_TECH_ICON_ATLAS',                    42,            4,                1,                    'DiversityNewTech42.dds'                ),
                ('DIVERSITY_TECH_ICON_ATLAS',                    38,            4,                1,                    'DiversityNewTech38.dds'                ),
                ('DIVERSITY_TECH_ICON_ATLAS',                    30,            4,                1,                    'DiversityNewTech30.dds'                ),
                ('DIVERSITY_TECH_ICON_ATLAS_FOW',                42,            4,                1,                    'DiversityNewTech42_FOW.dds'            ),
               
                ('DIVERSITY_COREUNITS_ICON_ATLAS',                256,        4,                1,                    'DiversityCoreUnits256.dds'                ),
                ('DIVERSITY_COREUNITS_ICON_ATLAS',                80,            4,                1,                    'DiversityCoreUnits80.dds'                ),
                ('DIVERSITY_COREUNITS_ICON_ATLAS',                50,            4,                1,                    'DiversityCoreUnits50.dds'                ),
                ('DIVERSITY_COREUNITS_ICON_ATLAS',                38,            4,                1,                    'DiversityCoreUnits38.dds'                ),
                ('DIVERSITY_COREUNITS_ICON_ATLAS',                32,            4,                1,                    'DiversityCoreUnits32.dds'                ),
                ('DIVERSITY_COREUNITS_ICON_ATLAS',                22,            4,                1,                    'DiversityCoreUnits22.dds'                ),
               
                ('DIVERSITY_COREUNITS_ICON_ATLAS_PORTRAITS',    256,        4,                1,                    'DiversityCoreUnitsPortraits256.dds'    ),
                ('DIVERSITY_COREUNITS_ICON_ATLAS_PORTRAITS',    80,            4,                1,                    'DiversityCoreUnitsPortraits80.dds'        ),
                ('DIVERSITY_COREUNITS_ICON_ATLAS_PORTRAITS',    50,            4,                1,                    'DiversityCoreUnitsPortraits50.dds'        ),
                ('DIVERSITY_COREUNITS_ICON_ATLAS_PORTRAITS',    38,            4,                1,                    'DiversityCoreUnitsPortraits38.dds'        ),
                ('DIVERSITY_COREUNITS_ICON_ATLAS_PORTRAITS',    32,            4,                1,                    'DiversityCoreUnitsPortraits32.dds'        ),
                ('DIVERSITY_COREUNITS_ICON_ATLAS_PORTRAITS',    22,            4,                1,                    'DiversityCoreUnitsPortraits22.dds'        );

I will create a brand-new mod with nothing included and just recreate one unit, include only the portrait at 95px and see what happens.
 
Another thing is that AFAIK the engine is capable of resizing icons if it doesn't have the correct size available, but it can do a very poor quality job of it.
 
Top Bottom