-
Notifications
You must be signed in to change notification settings - Fork 94
/
glFog.xhtml
331 lines (319 loc) · 20.6 KB
/
glFog.xhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<div class="refentry" lang="en" xml:lang="en"><a id="glFog"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glFog — specify fog parameters</p></div><div class="refsynopsisdiv"><h2>C Specification</h2><div class="funcsynopsis"><table><tr><td><code class="funcdef">void <b class="fsfunc">glFogf</b>(</code></td><td>GLenum </td><td><var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLfloat </td><td><var class="pdparam">param</var><code>)</code>;</td></tr></table></div><div class="funcsynopsis"><table><tr><td><code class="funcdef">void <b class="fsfunc">glFogi</b>(</code></td><td>GLenum </td><td><var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLint </td><td><var class="pdparam">param</var><code>)</code>;</td></tr></table></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>pname</code></em></span></dt><dd><p>
Specifies a single-valued fog parameter.
<code class="constant">GL_FOG_MODE</code>,
<code class="constant">GL_FOG_DENSITY</code>,
<code class="constant">GL_FOG_START</code>,
<code class="constant">GL_FOG_END</code>,
<code class="constant">GL_FOG_INDEX</code>, and
<code class="constant">GL_FOG_COORD_SRC</code>
are accepted.
</p></dd><dt><span class="term"><em class="parameter"><code>param</code></em></span></dt><dd><p>
Specifies the value that <em class="parameter"><code>pname</code></em> will be set to.
</p></dd></dl></div></div><div class="refsynopsisdiv"><h2>C Specification</h2><div class="funcsynopsis"><table><tr><td><code class="funcdef">void <b class="fsfunc">glFogfv</b>(</code></td><td>GLenum </td><td><var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>const GLfloat * </td><td><var class="pdparam">params</var><code>)</code>;</td></tr></table></div><div class="funcsynopsis"><table><tr><td><code class="funcdef">void <b class="fsfunc">glFogiv</b>(</code></td><td>GLenum </td><td><var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>const GLint * </td><td><var class="pdparam">params</var><code>)</code>;</td></tr></table></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="parameters2"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>pname</code></em></span></dt><dd><p>
Specifies a fog parameter.
<code class="constant">GL_FOG_MODE</code>,
<code class="constant">GL_FOG_DENSITY</code>,
<code class="constant">GL_FOG_START</code>,
<code class="constant">GL_FOG_END</code>,
<code class="constant">GL_FOG_INDEX</code>,
<code class="constant">GL_FOG_COLOR</code>, and
<code class="constant">GL_FOG_COORD_SRC</code>
are accepted.
</p></dd><dt><span class="term"><em class="parameter"><code>params</code></em></span></dt><dd><p>
Specifies the value or values to be assigned to <em class="parameter"><code>pname</code></em>.
<code class="constant">GL_FOG_COLOR</code> requires an array of four values.
All other parameters accept an array containing only a single value.
</p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="description"></a><h2>Description</h2><p>
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 <a class="citerefentry" href="glEnable"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a> and <a class="citerefentry" href="glDisable"><span class="citerefentry"><span class="refentrytitle">glDisable</span></span></a> with argument
<code class="constant">GL_FOG</code>.
</p><p>
<code class="function">glFog</code> assigns the value or values in <em class="parameter"><code>params</code></em> to the fog parameter
specified by <em class="parameter"><code>pname</code></em>.
The following values are accepted for <em class="parameter"><code>pname</code></em>:
</p><div class="variablelist"><dl><dt><span class="term"><code class="constant">GL_FOG_MODE</code></span></dt><dd><p>
<em class="parameter"><code>params</code></em> is a single integer or floating-point value that specifies
the equation to be used to compute the fog blend factor,
<math overflow="scroll"><mi mathvariant="italic">f</mi></math>.
Three symbolic constants are accepted:
<code class="constant">GL_LINEAR</code>,
<code class="constant">GL_EXP</code>,
and <code class="constant">GL_EXP2</code>.
The equations corresponding to these symbolic constants are defined below.
The initial fog mode is <code class="constant">GL_EXP</code>.
</p></dd><dt><span class="term"><code class="constant">GL_FOG_DENSITY</code></span></dt><dd><p>
<em class="parameter"><code>params</code></em> is a single integer or floating-point value that specifies
<math overflow="scroll"><mi mathvariant="italic">density</mi></math>,
the fog density used in both exponential fog equations.
Only nonnegative densities are accepted.
The initial fog density is 1.
</p></dd><dt><span class="term"><code class="constant">GL_FOG_START</code></span></dt><dd><p>
<em class="parameter"><code>params</code></em> is a single integer or floating-point value that specifies
<math overflow="scroll"><mi mathvariant="italic">start</mi></math>,
the near distance used in the linear fog equation.
The initial near distance is 0.
</p></dd><dt><span class="term"><code class="constant">GL_FOG_END</code></span></dt><dd><p>
<em class="parameter"><code>params</code></em> is a single integer or floating-point value that specifies
<math overflow="scroll"><mi mathvariant="italic">end</mi></math>,
the far distance used in the linear fog equation.
The initial far distance is 1.
</p></dd><dt><span class="term"><code class="constant">GL_FOG_INDEX</code></span></dt><dd><p>
<em class="parameter"><code>params</code></em> is a single integer or floating-point value that specifies
<math overflow="scroll">
<msub><mi mathvariant="italic">i</mi>
<mi mathvariant="italic">f</mi>
</msub>
</math>,
the fog color index.
The initial fog index is 0.
</p></dd><dt><span class="term"><code class="constant">GL_FOG_COLOR</code></span></dt><dd><p>
<em class="parameter"><code>params</code></em> contains four integer or floating-point values that specify
<math overflow="scroll">
<msub><mi mathvariant="italic">C</mi>
<mi mathvariant="italic">f</mi>
</msub>
</math>,
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
<math overflow="scroll">
<mn>-1.0</mn>
</math>.
Floating-point values are mapped directly.
After conversion,
all color components are clamped to the range
<math overflow="scroll">
<mfenced open="[" close="]">
<mn>0</mn>
<mn>1</mn>
</mfenced>
</math>.
The initial fog color is (0, 0, 0, 0).
</p></dd><dt><span class="term"><code class="constant">GL_FOG_COORD_SRC</code></span></dt><dd><p>
<em class="parameter"><code>params</code></em> contains either of the following symbolic constants:
<code class="constant">GL_FOG_COORD</code> or <code class="constant">GL_FRAGMENT_DEPTH</code>. <code class="constant">GL_FOG_COORD</code>
specifies that the current fog coordinate should be used as distance value
in the fog color computation. <code class="constant">GL_FRAGMENT_DEPTH</code> specifies that the
current fragment depth should be used as distance value in the fog
computation.
</p></dd></dl></div><p>
Fog blends a fog color with each rasterized pixel fragment's post-texturing
color using a blending factor
<math overflow="scroll"><mi mathvariant="italic">f</mi></math>.
Factor
<math overflow="scroll"><mi mathvariant="italic">f</mi></math>
is computed in one of three ways,
depending on the fog mode.
Let
<math overflow="scroll"><mi mathvariant="italic">c</mi></math>
be either the distance in eye coordinate from the origin (in the
case that the <code class="constant">GL_FOG_COORD_SRC</code> is <code class="constant">GL_FRAGMENT_DEPTH</code>) or
the current fog coordinate (in the case that <code class="constant">GL_FOG_COORD_SRC</code>
is <code class="constant">GL_FOG_COORD</code>).
The equation for <code class="constant">GL_LINEAR</code> fog is
</p><div class="informalequation"><math overflow="scroll">
<mrow>
<mi mathvariant="italic">f</mi>
<mo>=</mo>
<mfrac>
<mfenced open="" close="">
<mrow>
<mi mathvariant="italic">end</mi>
<mo>-</mo>
<mi mathvariant="italic">c</mi>
</mrow>
</mfenced>
<mfenced open="" close="">
<mrow>
<mi mathvariant="italic">end</mi>
<mo>-</mo>
<mi mathvariant="italic">start</mi>
</mrow>
</mfenced>
</mfrac>
</mrow>
</math></div><p>
</p><p>
The equation for <code class="constant">GL_EXP</code> fog is
</p><div class="informalequation"><math overflow="scroll">
<mrow>
<mi mathvariant="italic">f</mi>
<mo>=</mo>
<msup><mi mathvariant="italic">e</mi>
<mfenced open="" close="">
<mrow>
<mo>-</mo>
<mfenced open="(" close=")">
<mrow>
<mi mathvariant="italic">density</mi>
<mo>·</mo>
<mi mathvariant="italic">c</mi>
</mrow>
</mfenced>
</mrow>
</mfenced>
</msup>
</mrow>
</math></div><p>
</p><p>
The equation for <code class="constant">GL_EXP2</code> fog is
</p><div class="informalequation"><math overflow="scroll">
<mrow>
<mi mathvariant="italic">f</mi>
<mo>=</mo>
<msup><mi mathvariant="italic">e</mi>
<msup><mfenced open="" close="">
<mrow>
<mo>-</mo>
<mfenced open="(" close=")">
<mrow>
<mi mathvariant="italic">density</mi>
<mo>·</mo>
<mi mathvariant="italic">c</mi>
</mrow>
</mfenced>
</mrow>
</mfenced>
<mn>2</mn>
</msup></msup>
</mrow>
</math></div><p>
</p><p>
Regardless of the fog mode,
<math overflow="scroll"><mi mathvariant="italic">f</mi></math>
is clamped to the range
<math overflow="scroll">
<mfenced open="[" close="]">
<mn>0</mn>
<mn>1</mn>
</mfenced>
</math>
after it is computed.
Then,
if the GL is in RGBA color mode,
the fragment's red, green, and blue colors, represented by
<math overflow="scroll">
<msub><mi mathvariant="italic">C</mi>
<mi mathvariant="italic">r</mi>
</msub>
</math>,
are replaced by
</p><p>
</p><div class="informalequation"><math overflow="scroll">
<mrow>
<msup><mfenced open="" close="">
<msub><mi mathvariant="italic">C</mi>
<mi mathvariant="italic">r</mi>
</msub>
</mfenced>
<mo>″</mo>
</msup>
<mo>=</mo>
<mrow>
<mrow>
<mi mathvariant="italic">f</mi>
<mo>×</mo>
<msub><mi mathvariant="italic">C</mi>
<mi mathvariant="italic">r</mi>
</msub>
</mrow>
<mo>+</mo>
<mrow>
<mfenced open="(" close=")">
<mrow>
<mn>1</mn>
<mo>-</mo>
<mi mathvariant="italic">f</mi>
</mrow>
</mfenced>
<mo>×</mo>
<msub><mi mathvariant="italic">C</mi>
<mi mathvariant="italic">f</mi>
</msub>
</mrow>
</mrow>
</mrow>
</math></div><p>
</p><p>
Fog does not affect a fragment's alpha component.
</p><p>
In color index mode, the fragment's color index
<math overflow="scroll">
<msub><mi mathvariant="italic">i</mi>
<mi mathvariant="italic">r</mi>
</msub>
</math>
is replaced by
</p><p>
</p><div class="informalequation"><math overflow="scroll">
<mrow>
<msup><mfenced open="" close="">
<msub><mi mathvariant="italic">i</mi>
<mi mathvariant="italic">r</mi>
</msub>
</mfenced>
<mo>″</mo>
</msup>
<mo>=</mo>
<mrow>
<msub><mi mathvariant="italic">i</mi>
<mi mathvariant="italic">r</mi>
</msub>
<mo>+</mo>
<mrow>
<mfenced open="(" close=")">
<mrow>
<mn>1</mn>
<mo>-</mo>
<mi mathvariant="italic">f</mi>
</mrow>
</mfenced>
<mo>×</mo>
<msub><mi mathvariant="italic">i</mi>
<mi mathvariant="italic">f</mi>
</msub>
</mrow>
</mrow>
</mrow>
</math></div><p>
</p><p>
</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="notes"></a><h2>Notes</h2><p>
<code class="constant">GL_FOG_COORD_SRC</code> is available only if the GL version is 1.4 or
greater.
</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="errors"></a><h2>Errors</h2><p>
<code class="constant">GL_INVALID_ENUM</code> is generated if <em class="parameter"><code>pname</code></em> is not an accepted value,
or if <em class="parameter"><code>pname</code></em> is <code class="constant">GL_FOG_MODE</code> and <em class="parameter"><code>params</code></em> is not an accepted value.
</p><p>
<code class="constant">GL_INVALID_VALUE</code> is generated if <em class="parameter"><code>pname</code></em> is <code class="constant">GL_FOG_DENSITY</code>
and <em class="parameter"><code>params</code></em> is negative.
</p><p>
<code class="constant">GL_INVALID_OPERATION</code> is generated if <code class="function">glFog</code>
is executed between the execution of <a class="citerefentry" href="glBegin"><span class="citerefentry"><span class="refentrytitle">glBegin</span></span></a>
and the corresponding execution of <a class="citerefentry" href="glEnd"><span class="citerefentry"><span class="refentrytitle">glEnd</span></span></a>.
</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="associatedgets"></a><h2>Associated Gets</h2><p>
<a class="citerefentry" href="glIsEnabled"><span class="citerefentry"><span class="refentrytitle">glIsEnabled</span></span></a> with argument <code class="constant">GL_FOG</code>
</p><p>
<a class="citerefentry" href="glGet"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_COLOR</code>
</p><p>
<a class="citerefentry" href="glGet"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_INDEX</code>
</p><p>
<a class="citerefentry" href="glGet"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_DENSITY</code>
</p><p>
<a class="citerefentry" href="glGet"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_START</code>
</p><p>
<a class="citerefentry" href="glGet"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_END</code>
</p><p>
<a class="citerefentry" href="glGet"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_FOG_MODE</code>
</p></div>
{$pipelinestall}{$examples}
<div class="refsect1" lang="en" xml:lang="en"><a id="seealso"></a><h2>See Also</h2><p>
<a class="citerefentry" href="glEnable"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a>
</p></div><div class="refsect1" lang="en" xml:lang="en"><div id="Copyright"><h2>Copyright</h2><p>
Copyright © 1991-2006
Silicon Graphics, Inc. This document is licensed under the SGI
Free Software B License. For details, see
<a class="ulink" href="https://web.archive.org/web/20171022161616/http://oss.sgi.com/projects/FreeB/" target="_top">https://web.archive.org/web/20171022161616/http://oss.sgi.com/projects/FreeB/</a>.
</p></div></div></div>