Light diminishing

From DoomWiki.org

Diminishing light can be seen as banding on the walls and floor in this view of Doom II's MAP23: Barrels o' Fun.
"Another touch adding realism is light diminishing. With distance, your surroundings become enshrouded in darkness. This makes areas seem huge and intensifies the experience."
― Doom press release [source]

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[edit]

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[edit]

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 frustum 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 lightness, but during construction of the COLORMAP these colors must be re-quantized back into the base palette, so distortions may occur in hue and saturation as the lighting decreases.

Comparison of a pure lightness gradient (top) to Doom's re-quantized COLORMAP light levels (bottom).
Colormap Comparison.png

Other methods[edit]

CRY[edit]

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 B_IINC which adjusts the Y value of colors as they are drawn.

Flat polygon shading[edit]

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[edit]

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[edit]

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

Gallery[edit]

See also[edit]