Doom Wiki
(Corrected comment about gamma correction.)
m (Also fixed up note about RGB values that I didn't pay attention to. DOOM uses 8-bit color, so the palette is in hardware.)
Line 7: Line 7:
 
The data for each column is divided into ''posts'', which are lines of colored pixels going downward on the screen. Each post is described by its starting height (relative to the top of the picture) and number of pixels, followed by a value for each of the pixels. Picture descriptions can (and do) skip over some pixel positions; these pixels are transparent. (Since transparent pixels are not changed when drawing a particular picture, whatever was drawn into the frame buffer previously will show through.)
 
The data for each column is divided into ''posts'', which are lines of colored pixels going downward on the screen. Each post is described by its starting height (relative to the top of the picture) and number of pixels, followed by a value for each of the pixels. Picture descriptions can (and do) skip over some pixel positions; these pixels are transparent. (Since transparent pixels are not changed when drawing a particular picture, whatever was drawn into the frame buffer previously will show through.)
   
Each pixel is given as an unsigned byte (and thus is valued from 0 to 255). The pixel value is first used as an index into the current [[COLORMAP]], which gives a new pixel value (from 0 to 255) adjusted for the desired light level. (At full brightness, the pixel value is unchanged.) Then this new pixel value is used as an index into the current [[palette]], which yields values for the red, green and blue components of a particular color (each value ranging from 0 to 255). The resulting red, green and blue values are stored at the proper position in a ''frame buffer'', for eventual output to the display hardware when the rendering of a frame is complete.
+
Each pixel is given as an unsigned byte (and thus is valued from 0 to 255). The pixel value is first used as an index into the current [[COLORMAP]], which gives a new pixel value (from 0 to 255) adjusted for the desired light level. (At full brightness, the pixel value is unchanged.) Then this new pixel value is written into the ''frame buffer''. The actual red, green, and blue values corresponding to the palette index in the current [[palette]] are stored in the VGA graphics card's 8-bit hardware palette.
   
 
Note that ''gamma correction'', a user-adjustable setting that can lighten the colors for dark-looking monitors, is handled when setting the game's palette and not when actually drawing the graphics themselves. This avoids an additional indirection.
 
Note that ''gamma correction'', a user-adjustable setting that can lighten the colors for dark-looking monitors, is handled when setting the game's palette and not when actually drawing the graphics themselves. This avoids an additional indirection.

Revision as of 04:46, 25 June 2006

Many of the Doom engine graphics, including wall patches and sprites, are stored in the WAD files in a special picture format. Notably excepted are the textures for floors and ceilings, which are known as flats.

Details of the picture format in Doom are given in the Unofficial Doom Specs.

A picture header gives its width and height, and offset values. Following the header are pointers to data for each column of pixels; the number of these pointers is equal to the picture width.

The data for each column is divided into posts, which are lines of colored pixels going downward on the screen. Each post is described by its starting height (relative to the top of the picture) and number of pixels, followed by a value for each of the pixels. Picture descriptions can (and do) skip over some pixel positions; these pixels are transparent. (Since transparent pixels are not changed when drawing a particular picture, whatever was drawn into the frame buffer previously will show through.)

Each pixel is given as an unsigned byte (and thus is valued from 0 to 255). The pixel value is first used as an index into the current COLORMAP, which gives a new pixel value (from 0 to 255) adjusted for the desired light level. (At full brightness, the pixel value is unchanged.) Then this new pixel value is written into the frame buffer. The actual red, green, and blue values corresponding to the palette index in the current palette are stored in the VGA graphics card's 8-bit hardware palette.

Note that gamma correction, a user-adjustable setting that can lighten the colors for dark-looking monitors, is handled when setting the game's palette and not when actually drawing the graphics themselves. This avoids an additional indirection.