Palette question

Moderators: Xaser, Dr_Nostromo

User avatar
Gez
Developer
Developer
Posts: 1399
Joined: Mon Oct 22, 2007 16:47

Palette question

Post by Gez »

Is there a good reason for index 247 to be what it is? Any reason that includes the letters X, W, and E in that order is not a good reason.

If it were swapped with index 255, it'd make a nice, beautiful range from 240 to 254. Here that smooth range is murdered by index 247.

(Also, ZDoom would be happier if there was a duplicate color somewhere.)
User avatar
NeuralStunner
Posts: 253
Joined: Tue Dec 29, 2009 3:46
Location: IN SPACE
Contact:

Re: Palette question

Post by NeuralStunner »

The IWad is assembled by ye olde DeuTex*, which expects that particular color at that particular place.

When it's me, color 0 or 255 is reserved for transparancy, though ZDoom never hears of it. The mod itself gets a palette where that color's black.


* 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.
Dean Koontz wrote:Human beings can always be relied upon to exert, with vigor, their God-given right to be stupid.
Spoiler: System Specs
User avatar
Cage
Posts: 75
Joined: Sat Dec 24, 2011 11:04

Re: Palette question

Post by 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.
User avatar
Gez
Developer
Developer
Posts: 1399
Joined: Mon Oct 22, 2007 16:47

Re: Palette question

Post by Gez »

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" :P 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.
User avatar
Cage
Posts: 75
Joined: Sat Dec 24, 2011 11:04

Re: Palette question

Post by Cage »

So during the development we can use the current one, for convenience, and for the release IWAD we should use a PLAYPAL which will have the index 247 as a duplicate of an other colour?
User avatar
Gez
Developer
Developer
Posts: 1399
Joined: Mon Oct 22, 2007 16:47

Re: Palette question

Post by Gez »

I'd even advise for the release to swap out 247 to last place, shifting 248-255 to be 247-254; and to use SLADE's color remap feature on all graphics (248:255=247:254).

Are you running DeuTex on Windows or Linux? I might provide a hacked version of it that uses index 255 for transparency instead of index 247. I really dislike seeing this beautiful range murdered by DeuTex's pigheadedness.
User avatar
Xaser
Developer
Developer
Posts: 112
Joined: Sat Jul 16, 2005 2:51

Re: Palette question

Post by Xaser »

Yeah, that index was changed to deal with certain editors making silly assumptions about index 247. I also have to ask the flipside question: Is there any good reason to change it at this point? All that would effectively do is force us to convert a bunch of graphics for something that's less-than-cosmetic as it makes no in-game difference at all.

Also, what does ZDoom do if there are no duplicate colors in a palette? That seems like an odd expectation and something I'd rather see a "transparentindex" variable in GAMEINFO for.
Blzut3
Developer
Developer
Posts: 491
Joined: Sun Jan 24, 2010 22:21

Re: Palette question

Post by Blzut3 »

Xaser wrote:Also, what does ZDoom do if there are no duplicate colors in a palette? That seems like an odd expectation and something I'd rather see a "transparentindex" variable in GAMEINFO for.
It finds the color closest to index 0 and pretends it's a duplicate. ZDoom always uses 0 as transparent (since it's faster this way), but does remapping so this is a non-issue. While it is optimal to have it a contrasting color during development, I would recommend switching it to a duplicate when finished. Heck you can make things easy and make 247 a duplicate of 246 or 248. :P
User avatar
Cage
Posts: 75
Joined: Sat Dec 24, 2011 11:04

Re: Palette question

Post by Cage »

Xaser wrote:Is there any good reason to change it at this point? All that would effectively do is force us to convert a bunch of graphics for something that's less-than-cosmetic as it makes no in-game difference at all.
I'd say no - if this doesnt matter from a technical standpoint, and doesnt effect ease/amount of work on GFX (at least in my case, but I'm the guy who's doing the most in this field :P at least at the moment!) then why bother?
Post Reply

Return to “Hacx Development”