Jump to content

How does Infinity Engine sprite recoloring actually work?


FatDog

Recommended Posts

Hello,

 

Not sure if this is the right place to post this, it's not strictly a modding question, just one of general curiosity about the IE. But if one of you knowledgeable people knows the answer in any case, I'd be very grateful.

 

I'm curious about the process for creating and drawing character sprites with user selected colors, both regarding the recoloring step in the game itself, and what it was specifically that they asked their 3d guys to render to create the bam files.

 

If we look at the bam files for player characters we see something like this:

 

CHFF4A5_zpsxb8clufs.png

 

From poking around the HSV values with a color picker it looks the hue is being used to represent the layer index, i.e to distinguish hair, skin, armor and the the two clothing colors, with six layers in total. Most of the pixels then are completely saturated, except for what look like some highlights, mostly on the hair, skin and metallic objects. So it's almost as though they are using the saturation to represent the specular lighting contribution.

 

Although I don't know if specular is really the right term here. (I'm only an amateur graphics person.) Since isn't it the case that when you choose a color in the game, you are in fact choosing two colors? As in a base color and a highlight color? So it isn't just one color being modulated, but rather two colors that you interpolate between. But what scheme exactly do they use to do this?

 

I'm also curious if this process changed at all in the enhanced editions. I remember that in the original games the dark hair options never looked that great, since the highlights always made the hair look grey. But in the EE they have a better looking black hair option, shown here on the bottom right:

 

20170308140024_1_zps3pmtyvox.jpg

Link to comment

Interesting question. I believe I have part of the answer. Firstly, the BAM file format is basically an 8-bit paletted bitmap that supports multiple image frames (all mapped to the same palette). The colors in the palette use the BGRA colorspace. Detailed BAM format description. Now, the character animations (and their weapons) that are "paletted" (colors are remapped to something else) are set up almost exclusively like this:

post-3522-0-19616900-1488992706_thumb.png

The first two palette entries are reserved. The first (green) is the transparent background color, and the second (black) is the semi-transparent shadow color. You will notice the rest of the palette is split up into a number of color gradients, where each gradient is used for something specific e.g. hair, major clothing color, minor clothing color, skin, weapon hilt, etc. Now take a look at the Color Gradients page on the IESDP. These are the original color gradients that you could (in-game) remap the BAM's color gradients to (including skin color, hair color, etc.) Now what I'm not 100% sure of is whether the 'colors' in the BAM's palette are remapped to the game gradients, or whether a range of the BAM's palette indices are remapped to the game gradients. I suspect the latter, partially because many of the paletted character's INV paperdolls use a BAM palette with slightly different colors than the norm.

 

It's interesting that you noticed a trend to the color gradients in a non RGB colorspace, which is the only colorspace I have thought of them in since that is the one in which they are stored in the file format.

 

Did that explanation make sense?

Link to comment

From Erephine's Developer Files - Colour Guide:

**** PALETTE ENTRIES ****

The following depicts the BG standard colour scheme. Each entry represents one gradient in the palette.
Pure colours:
grey
teal
pink
yellow
red
blue
green
==--
Colour gradients, mixed between pure colours:
grey, teal
grey, pink
grey, yellow
grey, red
grey, blue
grey, green
teal, pink
teal, yellow
teal, red
teal, blue
teal, green
pink, yellow
pink, red
pink, blue
pink, green
yellow, red
yellow, blue
yellow, green
red, blue
red, green
blue, green
==21
To calculate mixed colours, add the two pure RGB values and divide by two. Always round down. Here are the eight mix shades and their correspondence to pure colour shades:
I
3rd
II
4th
III
5th
IV
6th
V
7th
VI
8th
VII
9th
VIII
10th
If you need a mixed shade darker than the 10th, or brighter than the 3rd, you're out of luck.
**** STANDARD COLOUR USAGE ****
For character/monster animations:
GREY - Belt buckles, small metal things
TEAL - Minor clothing colour
PINK - Major clothing colour
YELLOW - Skin colour
RED - Leather colour
BLUE - Armour colour
GREEN - Hair colour (nice!)
**** COLOUR LOCATIONS ****
---WEAPONS---
16 -- GREY
17 -- TEAL
18 -- PINK
19 -- YELLOW
20 -- RED
21 -- BLUE
22 -- GREEN
---HELMETS---
48 -- GREY
49 -- TEAL
50 -- PINK
51 -- YELLOW
52 -- RED
53 -- BLUE
54 -- GREEN
---SHIELDS---
32 -- GREY
33 -- TEAL
34 -- PINK
35 -- YELLOW
36 -- RED
37 -- BLUE
38 -- GREEN
**** COLOUR FALLBACK SCHEME ****
If a colour is not set by the item, it will fall back on the character colour set for its gradient.
For instance, if you have a sword with a pink hilt but don't assign pink a colour, the hilt will always have the major clothing colour of the character who has it equipped (since pink is the major clothing colour on characters). If you change your character's colours, the item will change as well.
If you do have an item colour set, but it happens to be one of the colours you can set on your character (hair, skin, clothing major, clothing minor) it will *appear* to change if you change your colour. It will change on the paperdoll and the avater, but only until a new animation sequence is loaded. As soon as that happens, it is reset to its assigned colour.
Things causing a reload are for instance attacking (loading the attack idle sequence), yawning, waiting, re-equipping the item, clicking on the quickbar.
**** PLANESCAPE TORMENT ****
Planescape Torment uses a different colour mapping system than Baldur's Gate. It more closely resembles the PLT way of doing things in that there are no anti-aliasing colours in favour of more shades per gradient.
The paletted animations of Planescape Torment are all found in the D series. The C series is entirely pre-rendered. Unlike BG paletted animations, they may be partially paletted (that is, part is a selectable colour while the rest is pre-rendered).
The Planescape palette is divided into eight blocks with 32 colours each. Each of these blocks may be used for a selectable gradient or fixed colours. A block always must start at a clean 32 colour interval, so colours are often left blank in between.
The first 32 colours may not be used as a gradient.
Setting the colours is a two step process in PST:
First you set the colours you wish to use. You can set up to seven different colours per animation.
Now you assign a colour placement to each of the colours you set: This determines which part of the palette will be replaced by the selected colour. The placement setting is also a control for special effects (pulsing, etc.).
This means there are seven placement possibilities, though one is unused.
As such the distinctions aren't as clear as with the Baldur's Gate series but there is a general colour scheme as follows:
TEAL 1 - Metal accessory*
BLUE - Major clothing colour
TEAL 2 - Minor clothing colour
RED - Hair & fur, leather**
PINK - Tertiary clothing colour*** (rarely used)
YELLOW - Skin
* e.g. Annah's dagger, Metal on hammer, Dakkon's Blade, Armour parts
** These share the same gradient, but have different placements.
*** Shares placement with leather
Teal 1 and Teal 2 are different in that Teal 1 is not a clear teal gradient while Teal 2 is. In comparison to Teal 2 (0,255,255 -> 0,75,75) it contains some red (75,255,255 -> 0,63,63).
Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...