Palette question

Post a reply

Smilies
:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angel: :angry: :beer: :bfg: :chaingun: :cheers: :blergh:
View more smilies

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

If you wish to attach one or more files enter the details below.

Maximum filesize per attachment: 1.5 MiB.

Expand view Topic review: Palette question

Re: Palette question

by Cage » Fri Jul 06, 2012 15:34

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?

Re: Palette question

by Blzut3 » Fri Jul 06, 2012 5:54

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

Re: Palette question

by Xaser » Fri Jul 06, 2012 5:14

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.

Re: Palette question

by Gez » Wed Jul 04, 2012 14:53

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.

Re: Palette question

by Cage » Wed Jul 04, 2012 11:27

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?

Re: Palette question

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" :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.

Re: Palette question

by Cage » Tue Jul 03, 2012 10:17

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.

Re: Palette question

by NeuralStunner » Mon Jul 02, 2012 19:06

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.

Palette question

by Gez » Mon Jul 02, 2012 12:33

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.)

Top