PLAYPAL

From DoomWiki.org

(Redirected from Palette)
Doom Palette 0, by columns
Doom palette 0, by rows, with each color numbered

The PLAYPAL lump is a set of color palettes the Doom engine uses to set the main colors for all graphics, including full color fades and tinting effects. Since the Doom engine can only display a maximum of 256 simultaneous colors, it performs a series of palette swaps to achieve these effects. Each palette in the PLAYPAL lump contains 256 colors totaling 768 bytes, where each color is broken into three unsigned bytes. Each of these color components (red, green, and blue) range between 0 and 255.

The COLORMAP resource is built using the PLAYPAL and consists of a number of tables of indices into the palette through which colors can be remapped for sector lighting, distance fading, and partial screen color changes (such as the invulnerability effect). Any changes to the PLAYPAL will be reflected in the COLORMAP, and if those changes are significant, they will require the COLORMAP to be rebuilt in order to remain consistent with the palette.

Since only one palette can be displayed at a time, any effects that use PLAYPAL cannot be combined; e.g. picking up a radiation suit (green tint) and a berserk pack (red tint) will not display a yellow tint. However, a COLORMAP change can be combined with a PLAYPAL change with no issues.

Doom[edit]

The Doom PLAYPAL contains a total of 14 palettes, where each palette has a specific function:

Palette number Use
0 Normal.
1 Unused.

11% red tint of RGB(255, 0, 0).

2-8 Progressively more red (8 is most red). Used to show pain when the player is hurt, and reddens the screen when the player picks up a berserk pack.

Each of these palettes tints the screen red progressively by 1/9×100%, so the highest pain palette makes the screen 89% red, by RGB(255, 0, 0).

9 Unused.

12.5% yellow tint of RGB(215, 186, 69).

10-12 Progressively more yellow. Used very briefly as the player picks up items.

25%, 37.5%, and 50% of RGB(215, 186, 69).

13 Green tint, used when the radiation suit is being worn.

12.5% of RGB(0, 256, 0).[notes 1]

An examination of the Doom source code reveals that the unused palettes (1 and 9) were likely intended to be the first levels of the red and yellow tinting effects, but because of the logic used in the palette code, they are never used:

   if (cnt)
   {
	palette = (cnt+7)>>3;
	
	if (palette >= NUMREDPALS)
	    palette = NUMREDPALS-1;

	palette += STARTREDPALS;
   }

   else if (plyr->bonuscount)
   {
	palette = (plyr->bonuscount+7)>>3;

	if (palette >= NUMBONUSPALS)
	    palette = NUMBONUSPALS-1;

	palette += STARTBONUSPALS;
   }

Since the computer palette will always be at least 1 + START(RED|BONUS)PALS, the first palette is skipped. This could have been fixed subtracting 1 while adding the STARTPAL (and therefore not while capping the palette).

The precise algorithm used to tint the palettes can be found in dcolors.c, a part of the Doom utilities.

Tools which can be used to manipulate the PLAYPAL include Inkworks, DeePsea and SLADE 3.

Notes[edit]

  1. Although a color level over 255 is a non-sequitur in the standard 24-bit RGB format, the DCOLORS utility written by John Carmack to generate the additional palettes calculates the green tint by incrementing the green channel by 12.5% of the difference between the current green value and a theoretical green value of 256.

Heretic[edit]

Heretic's PLAYPAL is laid out identically to Doom's, using the same generator. The "radiation suit" palette is present despite not being used. Heretic also uses a second lump, E2PAL, with an "underwater" palette for episode 2's ending screen.

Hexen[edit]

In Hexen, the engine uses an extended PLAYPAL lump containing 28 palettes, of which the additional palettes are used for several new effects.

Palette number Use
0 Normal
1-8 Progressively more red. Used to show pain when the player is hurt. Generated identically to the Doom palettes of the same number.
9-12 Progressively more yellow. Used briefly as the player picks up items. Generated identically to the Doom palettes of the same number.
13-20 Progressively more green, used when a player is poisoned or hit with projectiles from the Quietus or serpent staff. 10%, 20%, 30%, 40%, 50%, 60%, 70% and 80% of RGB(44, 92, 36).
21 Deep blue tint, used when the player has been frozen. 50% of RGB(0, 0, 224).
22-24 White, progressively darker. Used briefly when the Cleric fires the Wraithverge. 50% of RGB(130, 130, 130), RGB(100, 100, 100), and RGB(70, 70, 70).
25-27 Orange/red, progressively darker. Used briefly when the Mage fires the Bloodscourge. 50% of RGB(150, 110, 0), RGB(125, 92, 0), and RGB(100, 73, 0).

Strife[edit]

Strife's PLAYPAL is laid out identically to Doom's. The radiation suit palette is used for poisoning effects from certain types of damaging floors. With the way this effect is implemented in Strife, the palette change happens before damage starts being inflicted, serving as a warning to the player.

Index 247[edit]

Many specialized editing tools (notably NWT, SLumpEd and XWE) rely on the assumption that palette index 247 is not used and can safely be used as a "transparent color", which they display as cyan because it contrasts well with the rest of the Doom palette. This assumption, however, is incorrect. Palette index 247 is used by some Doom II graphics, and it is black (0, 0, 0), not cyan. All 256 colors of the palette are shown in the patches and sprites picture format, as a different mechanism for transparency is used. Palette index 247 is used even more in other Doom engine games such as Hexen. The mistaken assumption created by having these tools treating cyan as a transparent color when importing pictures and converting them to Doom-format graphics, or by giving transparency to pixels indexed 247 when exporting, results in many problems: patches and sprites exported from the IWADs might have "holes" that they shouldn't have, and attempts to actually use cyan as a color in graphics (with a palette that does contain this color) are hindered.

Technical limitations[edit]

The VGA display hardware on which Doom-engine games were designed to run (specifically, in an unchained variant of Mode 13h known as "Mode Y") only internally stores 6-bit values for red, green, and blue; all 8-bit values passed to the hardware have the two least significant bits dropped. The result of this is that VGA hardware can only display 64 different levels of red, green, or blue, and any more fine-grained differences will not be displayed.

The Doom palette appears to have been designed with this limitation in mind, as there are no gradients with variations smaller than 4 in any of the three component colors. However, the tinted palettes for taking damage, picking up items, and the radiation suit, as well as the colors for the gamma correction levels, were all algorithmically generated assuming that the full 24-bit color range would be available, and so they contain some slight color variations that are not faithfully represented when displayed on VGA hardware.

All other Doom-engine games have base palettes that contain colors which do not gracefully degrade to a 6-bit representation, and so some slight color accuracy is lost when they are displayed on VGA hardware. This can even result in colors being lost entirely. For instance, Heretic's base palette contains two similar grays: color #28 is (216, 216, 216), and color #29 is (219,219,219). These two colors are both displayed on VGA hardware as a gray of (54,54,54).

PLAYPAL replacements[edit]

Many WADs rely on the standard Doom palette to color their levels, but replacements also exist. Sometimes they are included by way of a texture pack, sometimes they appear standalone. A notable list of alternative palettes are:

See also[edit]

Source[edit]

External links[edit]