Can't Get Icon Atlas to Work

mjdgoldeneye

Chieftain
Joined
Sep 1, 2007
Messages
18
Hello.

I'm trying to get my icon atlases to work in a mod I'm making. I feel like I've done everything necessary, so I'm stumped.

I, so far, have my leader icon and civilization icon completed. Using the templates provided in the SDK (the 8x8 grids in Photoshop format), I placed my icons on the 256 grid (both leader and Civ), saved in whatever format, loaded them into GIMP 2, removed the extraneous background layer (the templates have a black background layer beneath the layer with the alpha circles and .dds files for Civ need to be 1 layer), and saved as a .dds file with no compression and default format.

I then scaled the files to match all the remaining necessary sizes (128, 80, 64, 45, 32). In case you're wondering, no, I didn't make them 128x128 and so on. I made them 1024x1024 and so on as I am supposed to.

I imported all the files into ModBuddy. I set them all to import into VFS.

Under my custom Civilization's XML, I have:

Code:
<PortraitIndex>1</PortraitIndex>
<IconAtlas>MJD_ATLAS</IconAtlas>

Under my Leader's XML, I have:

Code:
<PortraitIndex>0</PortraitIndex>
<IconAtlas>MJD_ATLAS</IconAtlas>

Here, the "0" means top left-most icon and "1" means the icon to the immediate right of "0".

Under an XML file for defining the atlas stuff (which I have set to OnModActivated -> Update Database), I have (and this is the entire file contents):

Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
	<IconTextureAtlases>
		<Row>
			<Atlas>MJD_ATLAS</Atlas>
			<IconSize>256</IconSize>
			<Filename>MJDAtlas256.dds</Filename>
			<IconsPerRow>8</IconsPerRow>
			<IconsPerColumn>8</IconsPerColumn>
		</Row>
		<Row>
			<Atlas>MJD_ATLAS</Atlas>
			<IconSize>128</IconSize>
			<Filename>MJDAtlas128.dds</Filename>
			<IconsPerRow>8</IconsPerRow>
			<IconsPerColumn>8</IconsPerColumn>
		</Row>
		<Row>
			<Atlas>MJD_ATLAS</Atlas>
			<IconSize>80</IconSize>
			<Filename>MJDAtlas80.dds</Filename>
			<IconsPerRow>8</IconsPerRow>
			<IconsPerColumn>8</IconsPerColumn>
		</Row>
		<Row>
			<Atlas>MJD_ATLAS</Atlas>
			<IconSize>64</IconSize>
			<Filename>MJDAtlas64.dds</Filename>
			<IconsPerRow>8</IconsPerRow>
			<IconsPerColumn>8</IconsPerColumn>
		</Row>
		<Row>
			<Atlas>MJD_ATLAS</Atlas>
			<IconSize>45</IconSize>
			<Filename>MJDAtlas45.dds</Filename>
			<IconsPerRow>8</IconsPerRow>
			<IconsPerColumn>8</IconsPerColumn>
		</Row>
		<Row>
			<Atlas>MJD_ATLAS</Atlas>
			<IconSize>32</IconSize>
			<Filename>MJDAtlas32.dds</Filename>
			<IconsPerRow>8</IconsPerRow>
			<IconsPerColumn>8</IconsPerColumn>
		</Row>
		<Row>
			<Atlas>MJD_ALPHA_ATLAS</Atlas>
			<IconSize>64</IconSize>
			<Filename>MJDAlphaAtlas64.dds</Filename>
			<IconsPerRow>1</IconsPerRow>
			<IconsPerColumn>1</IconsPerColumn>
		</Row>
		<Row>
			<Atlas>MJD_ALPHA_ATLAS</Atlas>
			<IconSize>48</IconSize>
			<Filename>MJDAlphaAtlas48.dds</Filename>
			<IconsPerRow>1</IconsPerRow>
			<IconsPerColumn>1</IconsPerColumn>
		</Row>
		<Row>
			<Atlas>MJD_ALPHA_ATLAS</Atlas>
			<IconSize>32</IconSize>
			<Filename>MJDAlphaAtlas32.dds</Filename>
			<IconsPerRow>1</IconsPerRow>
			<IconsPerColumn>1</IconsPerColumn>
		</Row>
		<Row>
			<Atlas>MJD_ALPHA_ATLAS</Atlas>
			<IconSize>24</IconSize>
			<Filename>MJDAlphaAtlas24.dds</Filename>
			<IconsPerRow>1</IconsPerRow>
			<IconsPerColumn>1</IconsPerColumn>
		</Row>
	</IconTextureAtlases>
</GameData>

(I made the Alpha icons for the Civ symbol too, but they haven't thrown any errors for me.)

Does anyone know what might be wrong?

When I load the mod, upon selection "Set Up Game" and trying to select a Civ, it stalls for a very short moment and then two alerts pop up saying "Can't load texture MJDAtlas128.dds" and whatever the smaller one is. I imagine they're the 128x128 sized leader icon and the smaller civ icon because both are replaced by garish red squares where the leader and civ icon should go in the civ select menu.
 
...
Does anyone know what might be wrong?

When I load the mod, upon selection "Set Up Game" and trying to select a Civ, it stalls for a very short moment and then two alerts pop up saying "Can't load texture MJDAtlas128.dds" and whatever the smaller one is. I imagine they're the 128x128 sized leader icon and the smaller civ icon because both are replaced by garish red squares where the leader and civ icon should go in the civ select menu.

Did you import the .DDS files? set the VFS to true? Better if you could zip and attached the whole MOD.
 
Did you import the .DDS files? set the VFS to true? Better if you could zip and attached the whole MOD.

Yea, I said that above.

There's very little I didn't outline above that's relevant. The mod consists of 1 civ and everything besides these .dds files works (switching everything to American/Washington art solves the problem). If nobody has any idea based on the description, I'll go through the trouble.
 
I think I found the problem. I need to mess around with the .dds format that I'm saving in. Consider this problem solved.
 
When making your own mod with custom icons, you define the atlases and make the icon sheet yourself. It doesn't really matter whether my Leader has a PortraitIndex of 0, 1, or 17, as long as it matches with the sheet you provided yourself.

Take this example (Taken from my Whomp's Fortress mod):
Spoiler :

Here, when the game wants to display the Icon for the Whomp King (Leader), it checks which atlas it needs to reference (TRL_WHOMP_FORTRESS_ICON_ATLAS), then determines which file it needs to select (depending on the icon size), and then determines the position that icon in that file.
Code:
[..]snipped code[..]
<Leaders>
        <Row>
            <Type>LEADER_TRL_WHOMP_KING</Type>
            [..]snipped code[..]
            <PortraitIndex>1</PortraitIndex>
            <IconAtlas>TRL_WHOMP_FORTRESS_ICON_ATLAS</IconAtlas>
        </Row>
    </Leaders>
[..]snipped code[..]
Code:
<IconTextureAtlases>
        <!--Building/Unit/Civ/etc. icons.-->
        <Row>
            <Atlas>TRL_WHOMP_FORTRESS_ICON_ATLAS</Atlas>
            <IconSize>256</IconSize>
            <Filename>Art/TRL_WhompIconAtlas256.dds</Filename>
            <IconsPerRow>8</IconsPerRow>
            <IconsPerColumn>8</IconsPerColumn>
        </Row>
        <Row>
            <Atlas>TRL_WHOMP_FORTRESS_ICON_ATLAS</Atlas>
            <IconSize>128</IconSize>
            <Filename>Art/TRL_WhompIconAtlas128.dds</Filename>
            <IconsPerRow>8</IconsPerRow>
            <IconsPerColumn>8</IconsPerColumn>
        </Row>
        <Row>
            <Atlas>TRL_WHOMP_FORTRESS_ICON_ATLAS</Atlas>
            <IconSize>80</IconSize>
            <Filename>Art/TRL_WhompIconAtlas80.dds</Filename>
            <IconsPerRow>8</IconsPerRow>
            <IconsPerColumn>8</IconsPerColumn>
        </Row>
        <Row>
            <Atlas>TRL_WHOMP_FORTRESS_ICON_ATLAS</Atlas>
            <IconSize>64</IconSize>
            <Filename>Art/TRL_WhompIconAtlas64.dds</Filename>
            <IconsPerRow>8</IconsPerRow>
            <IconsPerColumn>8</IconsPerColumn>
        </Row>
        <Row>
            <Atlas>TRL_WHOMP_FORTRESS_ICON_ATLAS</Atlas>
            <IconSize>45</IconSize>
            <Filename>Art/TRL_WhompIconAtlas45.dds</Filename>
            <IconsPerRow>8</IconsPerRow>
            <IconsPerColumn>8</IconsPerColumn>
        </Row>
        <Row>
            <Atlas>TRL_WHOMP_FORTRESS_ICON_ATLAS</Atlas>
            <IconSize>32</IconSize>
            <Filename>Art/TRL_WhompIconAtlas32.dds</Filename>
            <IconsPerRow>8</IconsPerRow>
            <IconsPerColumn>8</IconsPerColumn>
        </Row>
</IconTextureAtlases>
Spoiler :




Note that I could as well have put the leader icon in place of the 3rd icon from the left, and then changed the portraitindex to 2. This is just an 'arbitrary' order I decided to go with.
NOTE: Different icons require different sizes (E.g. technology icons require different sizes than leader icons), though it doesn't matter if you add an 'unused' size. E.g. no 32px leader icon is required, though I also defined that in my code above.
 
I usually use the 256px template I attached to this post (zipped as civfanatics doesn't allow GIMP files). I then add my icons to that file (just using basic editing, I'm by no means a janboruta ;)).
If using multiple layers, merge all of them to a single one before exporting. In this case, also re-add the layer mask to the icons by right-clicking your layer and choosing 'Layers alpha channel' in the 'Add layer mask'-menu.
Then, using this plugin, I export to dds. When making icons, choose RGB8A (or RGBA8, can't specifically remember which one it was) encoding and leave all other settings to their defaults.
You now have 1 correct .dds icon sheet. To get the other formats, I usually just scale my GIMP-icon sheet to the required size, and then export that one to dds again.

NOTE: The zip also includes other template files, for example for 32px promotion icons, or the basic blue background you might want to use sometimes for specific icons.
 

Attachments

  • civ5_icon_atlast_xcf_templates.zip
    488.9 KB · Views: 108
Also, what would be the sizes for Leader icons?
See this thread for the icon sizes that you'll need for pretty much any icon you would ever want to make.

Actually, could you go through all of these and what they do?
<PortraitIndex>6</PortraitIndex>
This is the offset of the icon in your atlas that you define in IconAtlas or AlphaIconAtlas (more on those below).
E.g. If your IconAtlas is defined to have 8 icons per row, and 8 icons per column then a PortraitIndex of:
  • 0 means the icon in the topleft corner
  • 1 means the 2nd icon from the topleft corner
  • 7 means the icon in the topright corner
  • 8 means the first icon on the 2nd row
  • etc.
In the example I gave earlier (about 5 posts up) you can check out how the Whomp King gets assigned his proper icon. Just open up the 'Spoiler' I have there.

<IconAtlas>CIV_COLOR_ATLAS</IconAtlas>
This mentions which atlas the game needs to look in. This atlas needs to have several entries in the <IconTextureAtlases>-table. (One entry for each required icon size).

<AlphaIconAtlas>CIV_ALPHA_ATLAS</AlphaIconAtlas>
The Icon Alpha Atlas is a bit different from a 'normal' icon atlas. This one only needs to be defined for a Civ-icon. Say you have running two copies of CIVILIZATION_AMERICA in a single game, then the game gives the 2nd instance of that civ different civ-colours to avoid confusion. But as the 'normal icon' is just an image, it cannot just replace colours there. And that's why we need this extra icon alpha!
When making an icon alpha, the only colour you need is white. Whenever another copy of your civ is running, the game will take the icon defined here instead and fill the white part with the foreground colour you defined for your civ. Likewise, the transparent parts of the icon will be filled with the background colour you defined for your civ.

Note that the PortraitIndex is used for both the IconAtlas AND the AlphaIconAtlas! In other words, both these icons need to be in the same position on a different icon sheet. (This is why you generally have the civ-icon to be in the topleft corner, as that means that the icon-alpha icon sheet can be snipped to be only one icon)

Spoiler :

Icon Alpha:


Civ Icon:


Both Screenshots are taken directly from GIMP, so the black-grey blocky part is transparent.


NOTE: Unit-flags follow the same principle, but require different tags to be entered. Download a mod from the Steam workshop and find out how unit-flags are done by checking the code for the Unit-definition in that mod. Note that, in contrast to a civ icon alpha, a Unit Icon alpha (for the flag) and a Unit Icon CAN have different PortraitIndexes as both of them use a different column for that.
 
Last edited:
Top Bottom