_C_ License Applicability. Except to the extent portions of this file are
_C_ made subject to an alternative license as permitted in the SGI Free
_C_ Software License B, Version 1.1 (the "License"), the contents of this
_C_ file are subject only to the provisions of the License. You may not use
_C_ this file except in compliance with the License. You may obtain a copy
_C_ of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
_C_ Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
_C_ 
_C_ http://oss.sgi.com/projects/FreeB
_C_ 
_C_ Note that, as provided in the License, the Software is distributed on an
_C_ "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
_C_ DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
_C_ CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
_C_ PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
_C_ 
_C_ Original Code. The Original Code is: OpenGL Sample Implementation,
_C_ Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
_C_ Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
_C_ Copyright in any portions created by third parties is as indicated
_C_ elsewhere herein. All Rights Reserved.
_C_ 
_C_ Additional Notice Provisions: The application programming interfaces
_C_ established by SGI in conjunction with the Original Code are The
_C_ OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
_C_ April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
_C_ 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
_C_ Window System(R) (Version 1.3), released October 19, 1998. This software
_C_ was created using the OpenGL(R) version 1.2.1 Sample Implementation
_C_ published by SGI, but has not been independently verified as being
_C_ compliant with the OpenGL(R) version 1.2.1 Specification.
_C_
_C_ The first character in this file must be an '_'!
_C_ Anything on a line after _C_ is ignored
_define(_filters,eqn)_C_
_C_      eqn is automatically replaced with neqn for nroff
_header(Fog,specify fog parameters)
_names(Fog,[fi])
.EQ
delim $$
.EN
.SH PARAMETERS
_phead(_param1)
Specifies a single-valued fog parameter.
_const(FOG_MODE),
_const(FOG_DENSITY),
_const(FOG_START),
_const(FOG_END),
and
_const(FOG_INDEX)
are accepted.
_phead(_param2)
Specifies the value that _param1 will be set to.
_names(Fog,[fi]v)
.SH PARAMETERS
_phead(_param1)
Specifies a fog parameter.
_const(FOG_MODE),
_const(FOG_DENSITY),
_const(FOG_START),
_const(FOG_END),
_const(FOG_INDEX),
and
_const(FOG_COLOR)
are accepted.
_phead(_param2)
Specifies the value or values to be assigned to _param1.
_const(FOG_COLOR) requires an array of four values.
All other parameters accept an array containing only a single value.
.SH DESCRIPTION
Fog is initially disabled.
While enabled, fog affects rasterized geometry,
bitmaps, and pixel blocks, but not buffer clear operations. To enable
and disable fog, call _cmnd(Enable) and _cmnd(Disable) with argument
_const(FOG). 
.P
_cmnd assigns the value or values in _param2 to the fog parameter
specified by _param1.
The following values are accepted for _param1:
.TP 20
_const(FOG_MODE)
_param2 is a single integer or floating-point value that specifies
the equation to be used to compute the fog blend factor, $f$.
Three symbolic constants are accepted:
_const(LINEAR),
_const(EXP),
and _const(EXP2).
The equations corresponding to these symbolic constants are defined below.
The initial fog mode is _const(EXP).
.TP
_const(FOG_DENSITY)
_param2 is a single integer or floating-point value that specifies $density$,
the fog density used in both exponential fog equations.
Only nonnegative densities are accepted.
The initial fog density is 1.
.TP
_const(FOG_START)
_param2 is a single integer or floating-point value that specifies $start$,
the near distance used in the linear fog equation.
The initial near distance is 0.
.TP
_const(FOG_END)
_param2 is a single integer or floating-point value that specifies $end$,
the far distance used in the linear fog equation.
The initial far distance is 1.
.TP
_const(FOG_INDEX)
_param2 is a single integer or floating-point value that specifies
$i sub f$,
the fog color index.
The initial fog index is 0.
.TP
_const(FOG_COLOR)
_param2 contains four integer or floating-point values that specify
$C sub f$, the fog color.
Integer values are mapped linearly such that the most positive representable
value maps to 1.0,
and the most negative representable value maps to \-1.0.
Floating-point values are mapped directly.
After conversion,
all color components are clamped to the range [0,1].
The initial fog color is (0, 0, 0, 0).
.P
Fog blends a fog color with each rasterized pixel fragment's posttexturing
color using a blending factor $f$.
Factor $f$ is computed in one of three ways,
depending on the fog mode.
Let $z$ be the distance in eye coordinates from the origin to the fragment
being fogged.
The equation for _const(LINEAR) fog is
.ce

.EQ
f ~=~ {end ~-~ z} over {end ~-~ start}
.EN

.RE
.P
The equation for _const(EXP) fog is
.ce

.EQ
f ~=~ e sup {-^(density ~cdot~ z)}
.EN

.P
The equation for _const(EXP2) fog is
.ce

.EQ
f ~=~ e sup {-^(density ~cdot~ z)} sup 2
.EN

.P
Regardless of the fog mode,
$f$ is clamped to the range [0,\ 1] after it is computed.
Then,
if the GL is in RGBA color mode,
the fragment's red, green, and blue colors, represented by $C sub r$,
are replaced by
.sp
.ce
.EQ
{C sub r} sup prime ~=~ f^C sub r ~+~ (1 - f)^C sub f 
.EN

.sp
Fog does not affect a fragment's alpha component.
.P
In color index mode, the fragment's color index $i sub r$ is replaced by
.sp
.ce
.EQ
{i sub r} sup prime ~=~ i sub r ~+~ (1 - f)^i sub f 
.EN
.P
.SH ERRORS
_const(INVALID_ENUM) is generated if _param1 is not an accepted value,
or if _param1 is _const(FOG_MODE) and _param2 is not an accepted value.
.P
_const(INVALID_VALUE) is generated if _param1 is _const(FOG_DENSITY), 
and _param2 is negative.
.P
_const(INVALID_OPERATION) is generated if _cmnd
is executed between the execution of _cmnd(Begin)
and the corresponding execution of _cmnd(End).
.SH ASSOCIATED GETS
_cmnd(IsEnabled) with argument _const(FOG)
.br
_cmnd(Get) with argument _const(FOG_COLOR)
.br
_cmnd(Get) with argument _const(FOG_INDEX)
.br
_cmnd(Get) with argument _const(FOG_DENSITY)
.br
_cmnd(Get) with argument _const(FOG_START)
.br
_cmnd(Get) with argument _const(FOG_END)
.br
_cmnd(Get) with argument _const(FOG_MODE)
.SH SEE ALSO
_cmnd(Enable)
