• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    EXT_fog_coord
4
5Name Strings
6
7    GL_EXT_fog_coord
8
9Contact
10
11    Jon Leech, Silicon Graphics (ljp 'at' sgi.com)
12
13Status
14
15    Shipping (version 1.6)
16
17Version
18
19    $Date: 1999/06/21 19:57:19 $ $Revision: 1.11 $
20
21Number
22
23    149
24
25Dependencies
26
27    OpenGL 1.1 is required.
28    The extension is written against the OpenGL 1.2 Specification.
29
30Overview
31
32    This extension allows specifying an explicit per-vertex fog
33    coordinate to be used in fog computations, rather than using a
34    fragment depth-based fog equation.
35
36Issues
37
38  * Should the specified value be used directly as the fog weighting
39    factor, or in place of the z input to the fog equations?
40
41        As the z input; more flexible and meets ISV requests.
42
43  * Do we want vertex array entry points? Interleaved array formats?
44
45        Yes for entry points, no for interleaved formats, following the
46        argument for secondary_color.
47
48  * Which scalar types should FogCoord accept? The full range, or just
49    the unsigned and float versions? At the moment it follows Index(),
50    which takes unsigned byte, signed short, signed int, float, and
51    double.
52
53        Since we're now specifying a number which behaves like an
54        eye-space distance, rather than a [0,1] quantity, integer types
55        are less useful. However, restricting the commands to floating
56        point forms only introduces some nonorthogonality.
57
58        Restrict to only float and double, for now.
59
60  * Interpolation of the fog coordinate may be perspective-correct or
61    not. Should this be affected by PERSPECTIVE_CORRECTION_HINT,
62    FOG_HINT, or another to-be-defined hint?
63
64        PERSPECTIVE_CORRECTION_HINT; this is already defined to affect
65        all interpolated parameters. Admittedly this is a loss of
66        orthogonality.
67
68  * Should the current fog coordinate be queryable?
69
70        Yes, but it's not returned by feedback.
71
72  * Control the fog coordinate source via an Enable instead of a fog
73    parameter?
74
75        No. We might want to add more sources later.
76
77  * Should the fog coordinate be restricted to non-negative values?
78
79        Perhaps. Eye-coordinate distance of fragments will be
80        non-negative due to clipping. Specifying explicit negative
81        coordinates may result in very large computed f values, although
82        they are defined to be clipped after computation.
83
84  * Use existing DEPTH enum instead of FRAGMENT_DEPTH? Change name of
85    FRAGMENT_DEPTH_EXT to FOG_FRAGMENT_DEPTH_EXT?
86
87        Use FRAGMENT_DEPTH_EXT; FOG_FRAGMENT_DEPTH_EXT is somewhat
88        misleading, since fragment depth itself has no dependence on
89        fog.
90
91New Procedures and Functions
92
93    void FogCoord[fd]EXT(T coord)
94    void FogCoord[fd]vEXT(T coord)
95    void FogCoordPointerEXT(enum type, sizei stride, void *pointer)
96
97New Tokens
98
99    Accepted by the <pname> parameter of Fogi and Fogf:
100
101        FOG_COORDINATE_SOURCE_EXT           0x8450
102
103    Accepted by the <param> parameter of Fogi and Fogf:
104
105        FOG_COORDINATE_EXT                  0x8451
106        FRAGMENT_DEPTH_EXT                  0x8452
107
108    Accepted by the <pname> parameter of GetBooleanv, GetIntegerv,
109    GetFloatv, and GetDoublev:
110
111        CURRENT_FOG_COORDINATE_EXT          0x8453
112        FOG_COORDINATE_ARRAY_TYPE_EXT       0x8454
113        FOG_COORDINATE_ARRAY_STRIDE_EXT     0x8455
114
115    Accepted by the <pname> parameter of GetPointerv:
116
117        FOG_COORDINATE_ARRAY_POINTER_EXT    0x8456
118
119    Accepted by the <array> parameter of EnableClientState and
120    DisableClientState:
121
122        FOG_COORDINATE_ARRAY_EXT            0x8457
123
124Additions to Chapter 2 of the OpenGL 1.2 Specification (OpenGL Operation)
125
126  These changes describe a new current state type, the fog coordinate,
127  and the commands to specify it:
128
129  - (2.6, p. 12) Second paragraph changed to:
130
131        "Each vertex is specified with two, three, or four coordinates.
132        In addition, a current normal, current texture coordinates,
133        current color, and current fog coordinate may be used in
134        processing each vertex."
135
136  - 2.6.3, p. 19) First paragraph changed to
137
138        "The only GL commands that are allowed within any Begin/End
139        pairs are the commands for specifying vertex coordinates, vertex
140        colors, normal coordinates, texture coordinates, and fog
141        coordinates (Vertex, Color, Index, Normal, TexCoord,
142        FogCoord)..."
143
144  - (2.7, p. 20) Insert the following paragraph following the third
145        paragraph describing current normals:
146
147        "   The current fog coodinate is set using
148                void FogCoord[fd]EXT(T coord)
149                void FogCoord[fd]vEXT(T coord)."
150
151    The last paragraph is changed to read:
152
153        "The state required to support vertex specification consists of
154        four floating-point numbers to store the current texture
155        coordinates s, t, r, and q, one floating-point value to store
156        the current fog coordinate, four floating-point values to store
157        the current RGBA color, and one floating-point value to store
158        the current color index. There is no notion of a current vertex,
159        so no state is devoted to vertex coordinates. The initial values
160        of s, t, and r of the current texture coordinates are zero; the
161        initial value of q is one. The initial fog coordinate is zero.
162        The initial current normal has coordinates (0,0,1). The initial
163        RGBA color is (R,G,B,A) = (1,1,1,1). The initial color index is
164        1."
165
166  - (2.8, p. 21) Added fog coordinate command for vertex arrays:
167
168    Change first paragraph to read:
169
170        "The vertex specification commands described in section 2.7
171        accept data in almost any format, but their use requires many
172        command executions to specify even simple geometry. Vertex data
173        may also be placed into arrays that are stored in the client's
174        address space. Blocks of data in these arrays may then be used
175        to specify multiple geometric primitives through the execution
176        of a single GL command. The client may specify up to seven
177        arrays: one each to store edge flags, texture coordinates, fog
178        coordinates, colors, color indices, normals, and vertices. The
179        commands"
180
181    Add to functions listed following first paragraph:
182
183        void FogCoordPointerEXT(enum type, sizei stride, void *pointer)
184
185    Add to table 2.4 (p. 22):
186
187        Command                     Sizes   Types
188        -------                     -----   -----
189        FogCoordPointerEXT          1       float,double
190
191    Starting with the second paragraph on p. 23, change to add
192    FOG_COORDINATE_ARRAY_EXT:
193
194        "An individual array is enabled or disabled by calling one of
195
196            void EnableClientState(enum array)
197            void DisableClientState(enum array)
198
199        with array set to EDGE_FLAG_ARRAY, TEXTURE_COORD_ARRAY,
200        FOG_COORDINATE_ARRAY_EXT, COLOR_ARRAY, INDEX_ARRAY,
201        NORMAL_ARRAY, or VERTEX_ARRAY, for the edge flag, texture
202        coordinate, fog coordinate, color, color index, normal, or
203        vertex array, respectively.
204
205        The ith element of every enabled array is transferred to the GL
206        by calling
207
208            void ArrayElement(int i)
209
210        For each enabled array, it is as though the corresponding
211        command from section 2.7 or section 2.6.2 were called with a
212        pointer to element i. For the vertex array, the corresponding
213        command is Vertex<size><type>v, where <size> is one of [2,3,4],
214        and <type> is one of [s,i,f,d], corresponding to array types
215        short, int, float, and double respectively. The corresponding
216        commands for the edge flag, texture coordinate, fog coordinate,
217        color, color, color index, and normal arrays are EdgeFlagv,
218        TexCoord<size><type>v, FogCoord<type>v, Color<size><type>v,
219        Index<type>v, and Normal<type>v, respectively..."
220
221    Change pseudocode on p. 27 to disable fog coordinate array for
222    canned interleaved array formats. After the lines
223
224            DisableClientState(EDGE_FLAG_ARRAY);
225            DisableClientState(INDEX_ARRAY);
226
227        insert the line
228
229            DisableClientState(FOG_COORDINATE_ARRAY_EXT);
230
231    Substitute "seven" for every occurence of "six" in the final
232    paragraph on p. 27.
233
234  - (2.12, p. 41) Add fog coordinate to the current rasterpos state.
235
236    Change the first sentence of the first paragraph to read
237
238        "The state required for the current raster position consists of
239        three window coordinates x_w, y_w, and z_w, a clip coordinate
240        w_c value, an eye coordinate distance, a fog coordinate, a valid
241        bit, and associated data consisting of a color and texture
242        coordinates."
243
244    Change the last paragraph to read
245
246        "The current raster position requires six single-precision
247        floating-point values for its x_w, y_w, and z_w window
248        coordinates, its w_c clip coordinate, its eye coordinate
249        distance, and its fog coordinate, a single valid bit, a color
250        (RGBA color and color index), and texture coordinates for
251        associated data. In the initial state, the coordinates and
252        texture coordinates are both (0,0,0,1), the fog coordinate is 0,
253        the eye coordinate distance is 0, the valid bit is set, the
254        associated RGBA color is (1,1,1,1), and the associated color
255        index color is 1. In RGBA mode, the associated color index
256        always has its initial value; in color index mode, the RGBA
257        color always maintains its initial value."
258
259  - (3.10, p. 139) Change the second and third paragraphs to read
260
261        "This factor f may be computed according to one of three
262        equations:"
263
264            f = exp(-d*c)       (3.24)
265            f = exp(-(d*c)^2)   (3.25)
266            f = (e-c)/(e-s)     (3.26)
267
268        If the fog source (as defined below) is FRAGMENT_DEPTH_EXT, then
269        c is the eye-coordinate distance from the eye, (0 0 0 1) in eye
270        coordinates, to the fragment center. If the fog source is
271        FOG_COORDINATE_EXT, then c is the interpolated value of the fog
272        coordinate for this fragment. The equation and the fog source,
273        along with either d or e and s, is specified with
274
275            void Fog{if}(enum pname, T param);
276            void Fog{if}v(enum pname, T params);
277
278        If <pname> is FOG_MODE, then <param> must be, or <param> must
279        point to an integer that is one of the symbolic constants EXP,
280        EXP2, or LINEAR, in which case equation 3.24, 3.25, or 3.26,,
281        respectively, is selected for the fog calculation (if, when 3.26
282        is selected, e = s, results are undefined). If <pname> is
283        FOG_COORDINATE_SOURCE_EXT, then <param> is or <params> points to
284        an integer that is one of the symbolic constants
285        FRAGMENT_DEPTH_EXT or FOG_COORDINATE_EXT. If <pname> is
286        FOG_DENSITY, FOG_START, or FOG_END, then <param> is or <params>
287        points to a value that is d, s, or e, respectively. If d is
288        specified less than zero, the error INVALID_VALUE results."
289
290  - (3.10, p. 140) Change the last paragraph preceding section 3.11
291    to read
292
293        "The state required for fog consists of a three valued integer
294        to select the fog equation, three floating-point values d, e,
295        and s, an RGBA fog color and a fog color index, a two-valued
296        integer to select the fog coordinate source, and a single bit to
297        indicate whether or not fog is enabled. In the initial state,
298        fog is disabled, FOG_COORDINATE_SOURCE_EXT is
299        FRAGMENT_DEPTH_EXT, FOG_MODE is EXP, d = 1.0, e = 1.0, and s =
300        0.0; C_f = (0,0,0,0) and i_f=0."
301
302Additions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization)
303
304    None
305
306Additions to Chapter 4 of the OpenGL 1.2.1 Specification (Per-Fragment
307Operations and the Frame Buffer)
308
309    None
310
311Additions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions)
312
313    None
314
315Additions to Chapter 6 of the OpenGL 1.2 Specification (State and State
316Requests)
317
318    None
319
320Additions to Appendix A of the OpenGL 1.2.1 Specification (Invariance)
321
322    None
323
324Additions to the GLX / WGL / AGL Specifications
325
326    None
327
328GLX Protocol
329
330    Two new GL rendering commands are added. The following commands are
331    sent to the server as part of a glXRender request:
332
333        FogCoordfvEXT
334            2           8               rendering command length
335            2           4124            rendering command opcode
336            4           FLOAT32         v[0]
337
338        FogCoorddvEXT
339            2           12              rendering command length
340            2           4125            rendering command opcode
341            8           FLOAT64         v[0]
342
343Errors
344
345    INVALID_ENUM is generated if FogCoordPointerEXT parameter <type> is
346    not FLOAT or DOUBLE.
347
348    INVALID_VALUE is generated if FogCoordPointerEXT parameter <stride>
349    is negative.
350
351New State
352
353(table 6.5, p. 195)
354    Get Value                   Type    Get Command     Initial Value   Description     Sec Attribute
355    ---------                   ----    -----------     -------------   -----------     --- ---------
356    CURRENT_FOG_COORDINATE_EXT  R       GetIntegerv,    0               Current         2.7 current
357                                        GetFloatv                       fog coordinate
358
359(table 6.6, p. 197)
360    Get Value                           Type    Get Command     Initial Value   Description                     Sec Attribute
361    ---------                           ----    -----------     -------------   -----------                     --- ---------
362    FOG_COORDINATE_ARRAY_EXT            B       IsEnabled       False           Fog coord array enable          2.8 vertex-array
363    FOG_COORDINATE_ARRAY_TYPE_EXT       Z8      GetIntegerv     FLOAT           Type of fog coordinate          2.8 vertex-array
364    FOG_COORDINATE_ARRAY_STRIDE_EXT     Z+      GetIntegerv     0               Stride between fog coords       2.8 vertex-array
365    FOG_COORDINATE_ARRAY_POINTER_EXT    Y       GetPointerv     0               Pointer to the fog coord array  2.8 vertex-array
366
367
368(table 6.8, p. 198)
369    Get Value                   Type    Get Command     Initial Value       Description     Sec     Attribute
370    ---------                   ----    -----------     -------------       -----------     ---     ---------
371    FOG_COORDINATE_SOURCE_EXT   Z2      GetIntegerv,    FRAGMENT_DEPTH_EXT  Source of fog   3.10    fog
372                                        GetFloatv                           coordinate for
373                                                                            fog calculation
374
375Revision History
376
377  * Revision 1.6 - Functionality complete
378
379  * Revision 1.7-1.9 - Fix typos and add fields to bring up to date with
380    the new extension template. No functionality changes.
381