October 30th, 2025
In 1993, Doom famously used a palette trick for its “light diminishing” effect. Walls, floors, and sprites became progressively darker farther away from the camera. It’s nothing special nowadays, but at the time, it must have appeared really atmospheric.
Darkening a color was no easy feat, because the game ran in a 256-color display mode. That meant each color was represented by an 8-bit index to a global color table, the palette, so the game couldn’t do blending math directly.
The solution was a precomputed lookup table with 32 lightness levels, also known as the colormap. Now any color could be quickly made darker with an array lookup:
darkened = colormap[color_index][shade], where shade is in range [0..31].
The colormap was shipped with the game. A tool created it by multiplying every palette color with a linear 32-step grayscale gradient. Multiplication was done in gamma-space, which is wrong in theory, but happens to give a pleasing nonlinear light falloff curve. New colors were mapped back to indices in the palette, and this is how it looks:
The tool code found the closest palette color for each newly-darkened 24-bit color by squared distance comparisons.
See this excerpt from the original dcolors.c:
bestdistortion = ( (long)r*r + (long)g*g + (long)b*b )*2;
bestcolor = 0;
pal = &palette[rangel*3];
for (i=rangel ; i<= rangeh ; i++)
{
dr = r - (int)pal[0];
dg = g - (int)pal[1];
db = b - (int)pal[2];
pal += 3;
distortion = dr*dr + dg*dg + db*db;
if (distortion < bestdistortion)
{
if (!distortion)
return i; // perfect match
bestdistortion = distortion;
bestcolor = i;
}
}It was all done in a color space that we now identify as sRGB, but here in 2025, when it comes to color differences, we know how to use a perceptual space. The Doom modding community is no stranger to the concept, and for example, the SLADE 3 editor already matches sprite pixels to palette colors in CIE LAB. But as far as I know, nobody has done so for the colormap. So I went and created a colormap in Oklab.
Below you can see the new version. The changes are barely perceptible but become somewhat visible in game.
Below are some new colormap screenshots that you can click and hold or press to switch to the original.
The effect is small, yet it does scrub off a thin layer of dignified 90’s patina. It could be argued that the original colormap, despite its flaws, was part of the game’s art direction. But Doom’s various ports did look different. For example the Jaguar version, done in-house at id Software, used the system’s native “CRY” color space for smoother lighting. It was convenient because the “Y” component encoded color brightness directly.
If MS-DOS had offered an easier way to mix colors, I’m sure it would’ve been employed in the game. In any case, Doom is ours now, and we can do whatever.
In case you want to try this yourself, here are the colormap files.
The conversion script modified from Freedoom’s tool:
colour-science library)I’m writing a book on color quantization. Sign up here if you’re interested.