Quake palette

From Quake Wiki

The Quake palette.

Color 255 is transparent for sprites, 2d lmps, and gfx.wad entries (excluding conchars, in which case it is black (color 0) that's made transparent). It is important that palette index 0 is black. The parameters for the color console command are the row #, but is restricted to rows 0 - 13.

It is important that the latter 8 palette rows are "backwards" (light-to-dark instead of dark-to-light). It appears that the ID artists did this for no good reason in the original Quake palette, and the engine programmers were forced to add a hack to accommodate it (along with the comment "the artists made some backwards ranges. sigh"). The only area this affects is player shirt/pants color translation (where one palette row must be mapped to another).


White (0) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Brown (1) 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Light blue (2) 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
Green (3) 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
Red (4) 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
Orange (5) 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
Gold (6) 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
Peach (7) 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
Purple (8) 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
Magenta (9) 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
Tan (10) 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
Light green (11) 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
Yellow (12) 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
Blue (13) 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
Fire (14) 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
Brights (15) 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255


palette.lmp[edit]

The palette is stored in gfx/palette.lmp. It consists of 256 RGB values using one byte per component, coming out to 768 bytes in total.

Download[edit]

  • File:quake palette.zip - The Quake palette in following formats: .aco, .act, .ase, .pal and the original palette.lmp (raw lump of RGB values, 768-bit). Also has a plaintext hex matrix and a .png preview.

Colormap[edit]

The Quake colormap.

The colormap is a table used for lighting in software Quake engines. It contains a column of 64 values for each palette color. Each value is an index into the palette representing as closely as possible the original color brightened or darkened: shade 0 is double bright, shade 32 is the original color, and shade 63 is black.

"Fullbright" colors are those which are not lit in the colormap, simply using the original color for all 64 shades. These colors, when used in textures and model skins, will not be affected by lighting. Fullbrights are used for things like fire and glowing lights. In Quake these are the last 32 colors in the palette.

Since the GLQuake engine ignores the colormap, it doesn't support fullbrights. Most user-modified engines have fixed this problem, being hard-coded to treat the last 32 colors as fullbright. For this reason, you shouldn't generate a colormap with a different amount of fullbrights, since it will work in software engines but not in modern GL engines.

colormap.lmp[edit]

The colormap is stored in gfx/colormap.lmp. The version included with Quake is 16385 bytes. Since the colormap only requires 16384 bytes (256 * 64), I'm not exactly sure what the extra byte (0x20) at the end is for.

Generating the colormap[edit]

The following C code will generate a colormap.lmp that is nearly (but not exactly) identical to the Quake colormap. Written by metlslime who placed it in the public domain.

/* sample a 24-bit RGB value to one of the colours on the existing 8-bit palette */
unsigned char convert_24_to_8(const unsigned char palette[768], const int rgb[3])
{
  int i, j;
  int best_index = -1;
  int best_dist = 0;

  for (i = 0; i < 256; i++)
  {
    int dist = 0;

    for (j = 0; j < 3; j++)
    {
    /* note that we could use RGB luminosity bias for greater accuracy, but quake's colormap apparently didn't do this */
      int d = abs(rgb[j] - palette[i*3+j]);
      dist += d * d;
    }

    if (best_index == -1 || dist < best_dist)
    {
      best_index = i;
      best_dist = dist;
    }
  }

  return (unsigned char)best_index;
}

void generate_colormap(const unsigned char palette[768], unsigned char out_colormap[16384])
{
  int num_fullbrights = 32; /* the last 32 colours will be full bright */
  int x, y, i;

  for (x = 0; x < 256; x++)
  {
    for (y = 0; y < 64; y++)
    {
      if (x < 256 - num_fullbrights)
      {
        int rgb[3];

        for (i = 0; i < 3; i++)
        {
          rgb[i] = (palette[x*3+i] * (63 - y) + 16) >> 5; /* divide by 32, rounding to nearest integer */
          if (rgb[i] > 255)
            rgb[i] = 255;
        }

        out_colormap[y*256+x] = convert_24_to_8(palette, rgb);
      }
      else
      {
      /* this colour is a fullbright, just keep the original colour */
        out_colormap[y*256+x] = x;
      }
    }
  }
}

Legal status[edit]

John Carmack officially put palette.lmp in the public domainTemplate:citation needed to make Quake ports easier, so it is legal to, for example, embed it right into an engine executable. Colormap.lmp can also be considered public domain as it is trivially derived from the palette.

Related Info[edit]

  • Most engine mods use 32-bit colour, so you need not worry about palettes. With 32-bit textures, shirt/pants colour changing and fullbrights are only possible if engines support a new implementation of them, for example DarkPlaces's DP_GFX_EXTERNALTEXTURES extension, which allows additional _glow, _pants, _shirt, etc textures on top of the main one)