Light diminishing

Light diminishing is a fundamental and characteristic feature of the Doom rendering engine whereby the brightness of areas in the player's view decreases as distance from the player increases. While not an effect that is photo-realistic, light diminishing contributes significantly to the atmosphere of Doom and other games implemented on its engine. The same mechanism underlying it can also be used to simulate fog and other colloid atmospheric conditions by varying the destination color of the fade to something other than black.

History
Light diminishing was first implemented by John Carmack in the Raven engine, originally designed for Shadowcaster. It was thus also present in the earliest versions of the Doom engine and can be observed in the Doom v0.2 alpha. Shadowcaster additionally uses the effect to implement both fog and a surreal type of magical atmosphere in some areas. This use was eventually resurrected in Hexen.

COLORMAP implementation
In the original engine, the COLORMAP lump is utilized to implement fading light with distance. When calculating the light level for vertical columns of sprites and walls, or horizontal spans of ceiling and floor textures, the engine first calculates an index into the COLORMAP based on the light level of the sector to which the surfaces belong. Then, the projected distance of each graphics primitive from the is calculated, scaled, and added to the base index to adjust the lighting further toward total darkness as distance increases.

The COLORMAP is a set of precomputed lookup tables which redirect indices into the game's basic 256-color palette - each level of the COLORMAP contains 256 entries, with the first 32 such levels being dedicated to implementing lighting. Ideally, each entry would contain the base palette's color reduced to the proper, but during construction of the COLORMAP these colors must be back into the base palette, so distortions may occur in hue and saturation as the lighting decreases.

CRY
In the Atari Jaguar port of Doom, the renderer is altered to use the CRY colorspace implemented in the Jaguar's Tom graphics chip. In the CRY colorspace, the lightness of colors can be altered simply by adjusting the Y value (with C and R representing a combined hue-saturation value), and the hardware blitter provides a register called which adjusts the Y value of colors as they are drawn.

Vertex lighting
The Sony PlayStation version of Doom factors distance into the calculation of primitive colors for the thin triangles it uses to draw walls, floors, and ceilings. This color is modulated with the texture texels by the hardware.

Fog
Doom 64 foregoes distance fading and instead implements hardware fog, which can fade at a specifiable rate to any desired color. Many hardware-accelerated source ports offer such an approach as an option as well.

Shader
It is possible to emulate the original light diminishing behavior in some hardware-accelerated ports using modern APIs through use of programs.