The application may supply a fog table to the hardware via the function grFogTable(). To enable table-based fogging, the fog mode must be set to GR_FOG_WITH_TABLE. This fog table should consist of 64 density values of type GrFog_t, which is an unsigned 8-bit quantity. A value of 0 indicates minimum density, and 255 indicates maximum density. This density determines the amount of blending that occurs between the incoming pixel and the global fog color, set by grFogColorValue(). The order of the entries within the table corresponds roughly to their distance from the viewer. Entries within the table are calculated as a function of world w where world w @ 2i/4 where i is the index into the fog table and (0 £ i < 64). To minimize “fog banding”, the Voodoo Graphics hardware linearly blends between adjacent fog levels within the fog table. The difference between consecutive fog values must be less than 64. void grFogTable( const GrFog_t table[GR_FOG_TABLE_SIZE] )
grFogTable() downloads a new table of 8-bit values that are logically viewed as fog opacity values corresponding to various depths. The table entries control the amount of blending between the fog color and the pixel’s color. A value of 0x00 indicates no fog blending and a value of 0xFF indicates complete fog.
The fog operation blends the fog color (cfog) with each rasterized pixel’s color (cin) using a blending factor f. When grFogMode() is set to GR_FOG_WITH_TABLE, then the factor f is computed by interpolating between fog table entries, where the fog table is indexed with a floating point representation of the pixel’s w component.
cout = ffog[w] · cfog + (1- ffog[w]) · cin The order of the entries within the fog table corresponds roughly to their distance from the viewer. The exact world w corresponding to fog table entry i can be found by calling guFogTableIndexToW()with argument i.