by Gez » Tue Jul 03, 2012 10:51
NeuralStunner wrote:* If there's a better utility for this, we haven't heard of one. If Slade3 could handle DeuTex scripts it would be a joy indeed.
I've thought about it.
Cage wrote:The range is smooth, but it's just interrupted. That's because of Deutex, but having a unique colour for transparency is a lot more convenient than using black - I'd have to triple check everything if there's no "poke-holes"
I'm used to a separate transparent colour, and it seems there's no problems with it, at least in ZDoom.
ZDoom automatically sacrifices one of the palette colors to make it transparent. It does so by looking for any duplicate color.
Code: Select all
// In ZDoom's new texture system, color 0 is used as the transparent color.
// But color 0 is also a valid color for Doom engine graphics. What to do?
// Simple. The default palette for every game has at least one duplicate
// color, so find a duplicate pair of palette entries, make one of them a
// duplicate of color 0, and remap every graphic so that it uses that entry
// instead of entry 0.
void FPalette::MakeGoodRemap ()
{
PalEntry color0 = BaseColors[0];
int i;
// First try for an exact match of color 0. Only Hexen does not have one.
for (i = 1; i < 256; ++i)
{
if (BaseColors[i] == color0)
{
Remap[0] = i;
break;
}
}
// If there is no duplicate of color 0, find the first set of duplicate
// colors and make one of them a duplicate of color 0. In Hexen's PLAYPAL
// colors 209 and 229 are the only duplicates, but we cannot assume
// anything because the player might be using a custom PLAYPAL where those
// entries are not duplicates.
if (Remap[0] == 0)
{
PalEntry sortcopy[256];
for (i = 0; i < 256; ++i)
{
sortcopy[i] = BaseColors[i] | (i << 24);
}
qsort (sortcopy, 256, 4, sortforremap);
for (i = 255; i > 0; --i)
{
if ((sortcopy[i] & 0xFFFFFF) == (sortcopy[i-1] & 0xFFFFFF))
{
int new0 = sortcopy[i].a;
int dup = sortcopy[i-1].a;
if (new0 > dup)
{
// Make the lower-numbered entry a copy of color 0. (Just because.)
swapvalues (new0, dup);
}
Remap[0] = new0;
Remap[new0] = dup;
BaseColors[new0] = color0;
break;
}
}
}
// If there were no duplicates, InitPalette() will remap color 0 to the
// closest matching color. Hopefully nobody will use a palette where all
// 256 entries are different. :-)
}
So having color 0 identical to color 255 (at least in the finished IWAD) is the safest guideline I can provide.
[quote="NeuralStunner"][size=85]* If there's a better utility for this, we haven't heard of one. If Slade3 could handle DeuTex scripts it would be a joy indeed.[/size][/quote]
I've thought about it.
[quote="Cage"]The range is smooth, but it's just interrupted. That's because of Deutex, but having a unique colour for transparency is a lot more convenient than using black - I'd have to triple check everything if there's no "poke-holes" :P I'm used to a separate transparent colour, and it seems there's no problems with it, at least in ZDoom.[/quote]
ZDoom automatically sacrifices one of the palette colors to make it transparent. It does so by looking for any duplicate color.
[code]// In ZDoom's new texture system, color 0 is used as the transparent color.
// But color 0 is also a valid color for Doom engine graphics. What to do?
// Simple. The default palette for every game has at least one duplicate
// color, so find a duplicate pair of palette entries, make one of them a
// duplicate of color 0, and remap every graphic so that it uses that entry
// instead of entry 0.
void FPalette::MakeGoodRemap ()
{
PalEntry color0 = BaseColors[0];
int i;
// First try for an exact match of color 0. Only Hexen does not have one.
for (i = 1; i < 256; ++i)
{
if (BaseColors[i] == color0)
{
Remap[0] = i;
break;
}
}
// If there is no duplicate of color 0, find the first set of duplicate
// colors and make one of them a duplicate of color 0. In Hexen's PLAYPAL
// colors 209 and 229 are the only duplicates, but we cannot assume
// anything because the player might be using a custom PLAYPAL where those
// entries are not duplicates.
if (Remap[0] == 0)
{
PalEntry sortcopy[256];
for (i = 0; i < 256; ++i)
{
sortcopy[i] = BaseColors[i] | (i << 24);
}
qsort (sortcopy, 256, 4, sortforremap);
for (i = 255; i > 0; --i)
{
if ((sortcopy[i] & 0xFFFFFF) == (sortcopy[i-1] & 0xFFFFFF))
{
int new0 = sortcopy[i].a;
int dup = sortcopy[i-1].a;
if (new0 > dup)
{
// Make the lower-numbered entry a copy of color 0. (Just because.)
swapvalues (new0, dup);
}
Remap[0] = new0;
Remap[new0] = dup;
BaseColors[new0] = color0;
break;
}
}
}
// If there were no duplicates, InitPalette() will remap color 0 to the
// closest matching color. Hopefully nobody will use a palette where all
// 256 entries are different. :-)
}[/code]
So having color 0 identical to color 255 (at least in the finished IWAD) is the safest guideline I can provide.