• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    EXT_texture_env
4
5Name Strings
6
7    GL_EXT_texture_env
8
9Version
10
11    $Date: 1998/05/12 23:52:26 $ $Revision: 1.5 $
12
13Number
14
15    146
16
17Dependencies
18
19    OpenGL 1.1 is required.
20    OpenGL 1.2 affects the definition of this spec.
21    EXT_multitexture affects the definition of this spec.
22    This specification is written against the OpenGL 1.2 specification.
23
24Overview
25
26    A new texture environment is defined which supports the
27    following equations:
28
29                        Cv = Cf                 COPY
30                        Cv = Ct                 REPLACE
31                        Cv = Cf * Ct            MODULATE
32                        Cv = Cf + Ct            ADD
33                        Cv = Cf - Ct            SUBTRACT
34                        Cv = Ct - Cf            REVERSE_SUBTRACT
35                        Cv = aCf + (1-a)Ct      BLEND
36                        Cv = aCt + (1-a)Cf      REVERSE_BLEND
37        where a is the incoming fragment's alpha value
38
39    These functions may be independently selected for color and alpha
40    processing.  The BLEND function is not available for alpha processing.
41    Additionally a scale factor of 2^0, 2^1, or 2^2 may be applied to the final
42    result.
43
44Issues
45
46  * The functions are added as a `suite' in a new texture environment.  An
47    alternative would be to retrofit them into the existing texture
48    environment.  There would likely be a clash with SGIX_texture_add_env
49    and with the DECAL/BLEND environment which are similar yet different
50    from the new BLEND function.  Also the separate specification of
51    the alpha texture function seems awkward, and we specified a new
52    behavior for the new texture environment when texturing is disabled.
53
54  * I chose the name EXT_texture_env as it really is an extension to
55    texture environment to add a new environment.  Should it have some
56    other name, e.g., EXT_texture_env1?
57
58  * A new enable is defined for TEXTURE_ENV1_EXT which causes it to
59    be activated over TEXTURE_ENV.  No enable is defined for TEXTURE_ENV
60    as it is considered to be enabled always.  The OpenGL spec uses
61    the term 'currently bound environment' should we be doing something
62    that looks more bind like or changing the language to something like
63    currently selected/enabled environment?
64
65  * There is no constant color term in TEXTURE_ENV1_EXT.  The functionality
66    is still available in TEXTURE_ENV and I'm not sure there is a compelling
67    reason to integrate the constant term here.
68
69  * The BLEND function is fairly restrictive.  Should it be more general?
70    e.g. reverse the blending factor?
71
72    Resolved: YES.  add REVERSE_BLEND.
73
74  * The rules for alpha-only and alpha-less textures are very regular
75    the color components of an alpha-only texture are substituted with zero
76    and the alpha component of an alpha-less texture is substituted with one.
77    Are these the right rules?
78
79  * If texturing is disabled, environment computations are still
80    performed in this new texture environment, whereas they are not in the
81    old environment (to preserve compatibility).  This sets the stage for
82    texture environments performing functions which do not involve a
83    texture though perhaps it is a little awkward.
84
85  * Enumerants are screwy.  Should we add new _EXT enumerants for
86    COPY, REPLACE, ADD, MODULATE, BLEND, as was done for the original
87    texture extension or reuse these existing tokens and just add
88    SUBTRACT, REVERSE_SUBTRACT, and REVERSE_BLEND?
89
90    I chose to add new enumerants which are prefixed with ENV_. The
91    main reason is to allow them to have contiguous values and leave
92    some room for expansion to ensure that they can be switched
93    with minimal parameter validation cost.
94
95  * Should a scale & bias be defined as part of this extension or
96    as a separate add-on to the environment processing?
97
98  * Possible add-on extensions (in the context of multitexture):
99
100        1) source and blend factor specification for the BLEND/REVERSE_BLEND
101           functions by generalizing BLEND/REVERSE_BLEND to
102                x*Cf + y*Ct   /    x*Ct + y*Cf
103           and allow x to be specified by TEXTURE_ENV_SRC_FACTOR and
104           y by TEXTURE_ENV_DST_FACTOR with possible src and dst factors
105           ONE
106           ZERO
107           FRAGMENT_ALPHA    alpha from previous environment stage
108           TEXTURE_ALPHA     alpha from texture
109           PRETEXTURE_ALPHA  original pre-texture alpha value
110           FRAGMENT_ALPHA_MINUS_ONE
111           TEXTURE_ALPHA_MINUS_ONE
112           PRETEXTURE_ALPHA_MINUS_ONE
113
114        2) Add some muxing to the inputs of the equations.
115           The basic equation set is
116                Cf            (copy)
117                Cf*Ct         (modulate)
118                Cf+Ct         (add/sub/rsub)
119                a*Cf+(1-a)*Ct (blend/rblend)
120
121            so allow a more flexible binding on Cf & Ct
122            TEXTURE_ENV_SRC  (default is FRAGMENT)
123            TEXTURE_ENV_DST  (default is TEXTURE)
124                choices:
125                    FRAGMENT
126                    TEXTURE
127                    PRETEXTURE
128
129         3) extension 2) gives a good chunk of the functionality of 1)
130            perhaps we could avoid 1) altogether or change 1) to allow
131            a more restrictive selection of the blend factor (simultaneously
132            choosing both a and (1-a):
133
134            TEXTURE_ENV_BLEND_FACTOR
135                choices:
136                    FRAGMENT
137                    TEXTURE
138                    PRETEXTURE
139
140
141New Procedures and Functions
142
143    None
144
145New Tokens
146
147    Accepted by the <target> parameter of TexEnvf, TexEnvi, TexEnvfv, TexEnvfi,
148    GetTexEnviv, GetTexEnvfv, GetBooleanv, GetIntegerv, GetFloatv, GetDoublev,
149    and the <cap> parameter of Enable, Disable, and IsEnabled
150
151    TEXTURE_ENV0_EXT            0x????
152    TEXTURE_ENV1_EXT            TEXTURE_ENV0_EXT+1
153    <leave room for 14 more environments>
154
155    Accepted by the <pname> parameter of TexEnvf, TexEnvi, TexEnvfv, TexEnvfi,
156    GetTexEnviv and GetTexEnvfv when the <target> parameter value is
157    TEXTURE_ENV1_EXT
158
159    TEXTURE_ENV_MODE_ALPHA_EXT  0x????
160
161
162    Accepted by the <params> parameter of TexEnvf, TexEnvi, TexEnvfv, and
163    TexEnvfi when the <target> parameter value is TEXTURE_ENV1_EXT and the
164    <pname> parameter value is TEXTURE_ENV_MODE or
165    TEXTURE_ENV_MODE_ALPHA_EXT
166
167    ENV_COPY_EXT                0x????
168    ENV_REPLACE_EXT             0x????
169    ENV_MODULATE_EXT            0x????
170    ENV_ADD_EXT                 0x????
171    ENV_SUBTRACT_EXT            0x????
172    ENV_REVERSE_SUBTRACT_EXT    0x????
173    ENV_BLEND_EXT               0x????
174    ENV_REVERSE_BLEND_EXT       0x????
175
176    Accepted by the <pname> parameter of TexEnvf, TexEnvi, TexEnvfv,
177    TexEnvfi, GetTexEnviv, and GetTexEnvfv
178
179    TEXTURE_ENV_SHIFT_EXT       0x????
180
181
182
183Additions to Chapter 2 of the GL Specification (OpenGL Operation)
184
185        None
186
187Additions to Chapter 3 of the GL Specification (Rasterization)
188
189
190
191
192                                Texture Environment 1
193                                ----------------------
194
195        Base Texture Format     COPY  REPLACE  MODULATE  ADD
196        -------------------     ----  -------  --------  ---
197
198        ALPHA                    Rf     0        Rf*0    Rf+0
199                                 Gf     0        Gf*0    Rf+0
200                                 Bf     0        Bf*0    Rf+0
201                                 Af     At       Af*At   Af+At
202
203        LUMINANCE                Rf     Lt       Rf*Lt   Rf+Lt
204                                 Gf     Lt       Gf*Lt   Gf+Lt
205                                 Bf     Lt       Bf*Lt   Bf+Lt
206                                 Af     1        Af*1    Af+1
207
208        LUMINANCE_ALPHA          Rf     Lt       Rf*Lt   Rf+Lt
209                                 Gf     Lt       Gf*Lt   Gf+Lt
210                                 Bf     Lt       Bf*Lt   Bf+Lt
211                                 Af     At       Af*At   Af+At
212
213        INTENSITY                Rf     It       Rf*It   Rf+It
214                                 Gf     It       Gf*It   Gf+It
215                                 Bf     It       Bf*It   Bf+It
216                                 Af     It       Af*It   Af+It
217
218        RGB                      Rf     Rt       Rf*Rt   Rf+Rt
219                                 Gf     Gt       Gf*Gt   Gf+Gt
220                                 Bf     Bt       Bf*Bt   Bf+Bt
221                                 Af     1        Af*1    Af+1
222
223        RGBA                     Rf     Rt       Rf*Rt   Rf+Rt
224                                 Gf     Gt       Gf*Gt   Gf+Gt
225                                 Bf     Bt       Bf*Bt   Bf+Bt
226                                 Af     At       Af*At   Af+At
227
228
229        Base Texture Format  SUBTRACT  REVERSE_      BLEND        REVERSE_
230                                       SUBTRACT                   BLEND
231        -------------------  --------  --------  ---------------  -------------
232
233        ALPHA                Rf-0      0-Rf     Af*Rf+(1-Af)*0   Af*0+(1-Af)*Rf
234                             Gf-0      0-Gf     Af*Gf+(1-Af)*0   Af*0+(1-Af)*Gf
235                             Bf-0      0-Bf     Af*Bf+(1-Af)*0   Af*0+(1-Af)*Bf
236                             Af-At     At-Af    N/A              N/A
237
238        LUMINANCE            Rf-Lt     Lt-Rf    Af*Rf+(1-Af)*Lt  Af*Lt+(1-Af)*Rf
239                             Gf-Lt     Lt-Gf    Af*Gf+(1-Af)*Lt  Af*Lt+(1-Af)*Gf
240                             Bf-Lt     Lt-Bf    Af*Bf+(1-Af)*Lt  Af*Lt+(1-Af)*Bf
241                             Af-1      1-Af     N/A              N/A
242
243        LUMINANCE_ALPHA      Rf-Lt     Lt-Rf    Af*Rf+(1-Af)*Lt  Af*Lt+(1-Af)*Rf
244                             Gf-Lt     Lt-Gf    Af*Gf+(1-Af)*Lt  Af*Lt+(1-Af)*Gf
245                             Bf-Lt     Lt-Bf    Af*Bf+(1-Af)*Lt  Af*Lt+(1-Af)*Bf
246                             Af-At     At-Af    N/A              N/A
247
248        INTENSITY            Rf-It     It-Rf    Af*Rf+(1-Af)*It  Af*It+(1-Af)*Rf
249                             Gf-It     It-Gf    Af*Gf+(1-Af)*It  Af*It+(1-Af)*Gf
250                             Bf-It     It-Bf    Af*Bf+(1-Af)*It  Af*It+(1-Af)*Bf
251                             Af-It     It-Af    N/A              N/A
252
253        RGB                  Rf-Rt     Rt-Rf    Af*Rf+(1-Af)*Rt  Af*Rt+(1-Af)*Rf
254                             Gf-Gt     Gt-Gf    Af*Gf+(1-Af)*Gt  Af*Gt+(1-Af)*Gf
255                             Bf-Bt     Bt-Bf    Af*Bf+(1-Af)*Bt  Af*Bt+(1-Af)*Bf
256                             Af-1      1-Af     N/A              N/A
257
258        RGBA                 Rf-Rt     Rt-Rf    Af*Rf+(1-Af)*Rt  Af*Rt+(1-Af)*Rf
259                             Gf-Gt     Gt-Gf    Af*Gf+(1-Af)*Gt  Af*Gt+(1-Af)*Gf
260                             Bf-Bt     Bt-Bf    Af*Bf+(1-Af)*Bt  Af*Bt+(1-Af)*Bf
261                             Af-At     At-Af    N/A              N/A
262
263
264        Tables 3.12 and 3.13: Texture functions for TEXTURE_ENV1.
265
266    Section 3.8.5 Texture Environments and Texture Functions
267
268
269    The command
270
271    void TexEnv{if}( enum target, enum pname, T param ) ;
272    void TexEnv{if}v( enum target, enum pname, T params ) ;
273
274    sets parameters of the <texture environment> that specifies how texture
275    values are interpreted when texturing a fragment.  <target> must be the
276    symbolic constant TEXTURE_ENV0_EXT or TEXTURE_ENV1_EXT.  <pname> is a
277    symbolic constant indicating the parameter to be set.  In the first form of
278    the command, <param> is a value to which to set a single-valued parameter;
279    in the second form, <params> is point to an array of parameters: either a
280    single symbolic constant or a value or group of values to which the
281    parameter should be set.  The possible environment parameters are
282    TEXTURE_ENV_MODE, TEXTURE_ENV_COLOR, and TEXTURE_ENV_COORD_SET_EXT.
283    TEXTURE_ENV_MODE may be set to one of REPLACE, MODULATE, DECAL, or BLEND;
284    TEXTURE_ENV_COLOR is set to an RGBA color by providing four
285    single-precision floating-point values in the range [0,1](values outside
286    this range are clamped to it).  If integers are provided for
287    TEXTURE_ENV_COLOR, then they are converted to floating-point as specified
288    in Table 2.6 for signed integers.  TEXTURE_ENV_COORD_SET_EXT may be set to
289    one of TEXTURE0_EXT .. TEXTURE<n>_EXT where <n> is one less than the
290    number of supported texture coordinate sets.  If floating-point values
291    are supplied, they are rounded to the nearest integer.
292
293        The value of TEXTURE_ENV_MODE specifies a texture function.  The result
294    of this function depends on the fragment and the texture array value.  The
295    precise form of the function depends on the base internal formats of the
296    texture arrays that were last specified.  In the following two
297    tables Rf, Gf, Bf, and Af are the color components of the incoming
298    fragment; Rt, Gt, Bt, At, Lt, and It are the filtered texture values; Rc,
299    Gc, Bc, and Ac are the texture environment color values; and Rv, Gv, Bv,
300    and Av are the color components computed by the texture function.  All of
301    these color values are in the range [0,1].  The REPLACE and MODULATE
302    texture functions are specified in Table 3.10, and the DECAL and BLEND
303    texture functions are specified in Table 3.11.
304
305        The value of TEXTURE_ENV_COORD_SET_EXT specifies which set of fragment
306    texture coordinates are used to determine the texture value used in the
307    texture function.  The same set of texture coordinates may be
308    simultaneously used by multiple textures.
309
310        Specifying Enable with a <cap> parameter of TEXTURE_ENV1_EXT selects an
311    alternate texture environment with a different set of texture functions.
312    When TEXTURE_ENV1_EXT is enabled this environment supersedes texture
313    environment zero.
314
315        Specifying TexEnv with a <target> parameter of TEXTURE_ENV1_EXT
316    selects the TEXTURE_ENV1_EXT environment for modification.  The possible
317    environment parameters for TEXTURE_ENV1_EXT are TEXTURE_ENV_MODE,
318    TEXTURE_ENV_MODE_ALPHA_EXT, TEXTURE_ENV_SHIFT_EXT, and
319    TEXTURE_ENV_COORD_SET_EXT.  TEXTURE_ENV_MODE may be set to one of
320    ENV_COPY_EXT, ENV_REPLACE_EXT, ENV_MODULATE_EXT, ENV_ADD_EXT,
321    ENV_SUBTRACT_EXT, ENV_REVERSE_SUBTRACT_EXT, ENV_BLEND_EXT, or
322    ENV_REVERSE_BLEND_EXT.  TEXTURE_ENV_MODE_ALPHA_EXT may be set to one of
323    ENV_COPY_EXT, ENV_REPLACE_EXT, ENV_MODULATE_EXT, ENV_ADD_EXT,
324    ENV_SUBTRACT_EXT, or ENV_REVERSE_SUBTRACT_EXT.  TEXTURE_ENV_SHIFT_EXT is
325    set to a four-value integer scale factor by providing four integers in the
326    range [0,2].  TEXTURE_ENV_COORD_SET_EXT may be set to one of
327    TEXTURE0_EXT .. TEXTURE<n>_EXT where <n> is the one less than the number
328    of supported texture coordinate sets. If floating-point values are
329    specified for either TEXTURE_ENV_SHIFT_EXT or TEXTURE_ENV_COORD_SET_EXT
330    they are rounded to the nearest integer.
331
332        The value TEXTURE_ENV_MODE specifies a texture function for the R, G,
333    and B components and the value of TEXTURE_ENV_MODE_ALPHA_EXT specifies a
334    texture function for the A component.  The computed color components Rv,
335    Gv, Bv, and Av are given by the equations:
336
337            Rv = Rx*(2^Rs),
338            Gv = Gx*(2^Gs),
339            Bv = Bx*(2^Bs) and
340            Av = Ax*(2^As),
341
342    where the functions for Rx, Gx, Bx, and Ax are specified in Tables 3.12
343    and 3.13,  and Rs, Gs, Bs, and As are the scaling factors specified with
344    TEXTURE_ENV_SHIFT_EXT. The ENV_COPY_EXT, ENV_REPLACE_EXT,
345    ENV_MODULATE_EXT, and ENV_ADD_EXT functions are specified in Table 3.12,
346    and the ENV_SUBTRACT_EXT, ENV_REVERSE_SUBTRACT_EXT, ENV_BLEND_EXT, and
347    ENV_REVERSE_BLEND_EXT functions are specified in Table 3.13.
348
349        The state required for texture environment TEXTURE_ENV0_EXT consists of
350    the four-valued integer indicating the texture function, four floating-
351    point TEXTURE_ENV_COLOR values and one MAX_TEXTURE_COORD_SETS_EXT-valued
352    integer indicating the texture coordinate set binding.  The state required
353    for texture environment TEXTURE_ENV1_EXT consists of the seven-valued
354    integer indicating the texture function for the R,G, and B components, the
355    five-valued integer indicating the texture function for the A component,
356    four integer-valued TEXTURE_ENV_SHIFT_EXT values, one bit indicating
357    whether TEXTURE_ENV1 is enabled, and one MAX_TEXTURE_COORD_SETS_EXT-valued
358    integer indicating the texture coordinate set binding.  In the initial
359    state, the texture functions for both environments is given by MODULATE,
360    TEXTURE_ENV_COORD_SET_EXT is given by TEXTURE0_EXT in both environments,
361    TEXTURE_ENV_COLOR in environment zero is (0,0,0,0), TEXTURE_ENV_SHIFT_EXT
362    in environment one is (0,0,0,0) and TEXTURE_ENV1_EXT is FALSE.
363
364    3.8.6 Texture Application
365
366    Texture is enabled or disabled using the generic Enable and Disable
367    commands, respectively, with the symbolic constant TEXTURE_1D or TEXTURE_2D
368    to enable the one-dimensional or two-dimensional texture, respectively.
369    If both one- and two-dimensional textures are enabled, the two dimensional
370    texture is used. If all texturing is disabled and the currently bound
371    texture environment is TEXTURE_ENV0_EXT, a rasterized fragment is
372    passed on unaltered to the next stage of the GL (although its texture
373    coordinates may be discarded).  If TEXTURE_ENV1_EXT is the current
374    texture environment, the filtered texture values Rt, Gt, Bt, At, Lt, and
375    It are replaced with 1.  Otherwise, a texture value is found according
376    to the parameter values of the currently bound texture image of the
377    appropriate dimensionality using the rules given in sections 3.8.1 and
378    3.8.2.  This texture value is used along with the incoming fragment in
379    computing the texture function indicated by the currently bound texture
380    environment.  The result of this function replaces the incoming fragment's
381    R, G, B, and A values.  These are the color values passed to subsequent
382    operations.  Other data associated with the incoming fragment remain
383    unchanged, except that the texture coordinates may be discarded.
384        The required state us two bits indicating whether each of one- or
385    two-dimensional texturing is enabled or disabled.  In the initial state,
386    all texturing is disabled.
387
388
389Additions to Chapter 4 of the GL Specification (Per-Fragment Operations
390and the Framebuffer)
391
392    None
393
394Additions to Chapter 5 of the GL Specification (Special Functions)
395
396    None
397
398Additions to Chapter 6 of the GL Specification (State and State Requests)
399
400    The value of the texture environment shift is queried by calling
401    GetTexEnviv, and GetTexEnvfv with the <target> parameter set of TEXTURE_ENV1
402    and the <pname> parameter to TEXTURE_ENV_SHIFT_EXT.
403
404
405Additions to the GLX Specification
406
407    None
408
409GLX Protocol
410
411    TBD
412
413Dependencies on EXT_texture3D
414
415    If EXT_texture3D is not supported then the functionality and state
416    associated with EXT_texture3D does not exist and is not supported.
417    (this is more a note that section 3.8.6 should refer to texture3D too)
418
419Dependencies on EXT_multitexture
420
421   If EXT_multitexture is not supported then the functionality and state
422   associated with EXT_multitexture does not exist and the description of
423   TEXTURE_ENV_COORD_SET_EXT is void.  If it is supported, then the state
424   associated with texture environment TEXTURE_ENV1_EXT exists for each active
425   texture.
426
427Errors
428
429    INVALID_VALUE is generated if <params> value for TEXTURE_ENV_SHIFT
430    is not one of 0, 1, or 2.
431
432    INVALID_ENUM is generated if <target> parameter of TexEnvi or TexEnvf
433    is TEXTURE_ENV1_EXT and <pname> parameter is not TEXTURE_ENV_MODE
434    or TEXTURE_ENV_MODE_ALPHA_EXT.
435
436    INVALID_ENUM is generated if <target> parameter of TexEnvi, TexEnvf
437    TexEnviv, TexEnvfv, GetTexEnviv, or GetTexEnvfv is TEXTURE_ENV1_EXT
438    and <pname> parameter is not TEXTURE_ENV_MODE, TEXTURE_ENV_MODE_ALPHA_EXT,
439    or TEXTURE_ENV_SHIFT_EXT.
440
441    INVALID_ENUM is generated if <target> parameter of TexEnvi, TexEnvf
442    TexEnviv, or TexEnvfv is TEXTURE_ENV1_EXT, <pname> parameter is
443    TEXTURE_ENV_MODE and <param> or <params> value is not one of ENV_COPY_EXT,
444    ENV_REPLACE_EXT, ENV_MODULATE_EXT, ENV_ADD_EXT, ENV_SUBTRACT_EXT,
445    ENV_REVERSE_SUBTRACT_EXT, ENV_BLEND_EXT, or ENV_REVERSE_BLEND_EXT
446
447    INVALID_ENUM is generated if <target> parameter of TexEnvi, TexEnvf
448    TexEnviv, or TexEnvfv is TEXTURE_ENV1_EXT, <pname> parameter is
449    TEXTURE_ENV_MODE_ALPHA_EXT and <param> or <params> value is not one of
450    ENV_COPY_EXT, ENV_REPLACE_EXT, ENV_MODULATE_EXT, ENV_ADD_EXT,
451    ENV_SUBTRACT_EXT, or ENV_REVERSE_SUBTRACT_EXT.
452
453New State
454
455    Get Value               Get Command  Type   Initial Value   Attribute
456    ---------               -----------  ----   -------------   ---------
457    TEXTURE_ENV1_EXT        IsEnabled     B     FALSE           enable/texture
458    TEXTURE_ENV_SHIFT_EXT   GetTexEnviv   Z4    (0, 0, 0, 0)    texture
459    TEXTURE_ENV1,MODE       GetTexEnviv   Z7    MODULATE        texture
460    TEXTURE_ENV1,MODE_ALPHA GetTexEnviv   Z5    MODULATE        texture
461
462
463New Implementation Dependent State
464
465    None
466