1Name 2 3 EXT_texture_env_combine 4 5Name Strings 6 7 GL_EXT_texture_env_combine 8 9Contact 10 11 Michael Gold (gold 'at' nvidia.com) 12 Tom Frisinger, AMD (tom.frisinger 'at' amd.com) 13 14Status 15 16 Shipping (NVIDIA, ATI) 17 18Version 19 20 $Date$ $Revision$ 21 Last Modified Date: 2006/11/04 02:49:00 Revision: 1.8 22 23Number 24 25 158 26 27Dependencies 28 29 SGI_texture_color_table affects the definition of this extension 30 SGIX_texture_scale_bias affects the definition of this extension 31 32Overview 33 34 New texture environment function COMBINE_EXT allows programmable 35 texture combiner operations, including: 36 37 REPLACE Arg0 38 MODULATE Arg0 * Arg1 39 ADD Arg0 + Arg1 40 ADD_SIGNED_EXT Arg0 + Arg1 - 0.5 41 INTERPOLATE_EXT Arg0 * (Arg2) + Arg1 * (1-Arg2) 42 43 where Arg0, Arg1 and Arg2 are derived from 44 45 PRIMARY_COLOR_EXT primary color of incoming fragment 46 TEXTURE texture color of corresponding texture unit 47 CONSTANT_EXT texture environment constant color 48 PREVIOUS_EXT result of previous texture environment; on 49 texture unit 0, this maps to PRIMARY_COLOR_EXT 50 51 and Arg2 is restricted to the alpha component of the corresponding source. 52 53 In addition, the result may be scaled by 1.0, 2.0 or 4.0. 54 55Issues 56 57 Should the explicit bias be removed in favor of an implcit bias as 58 part of a ADD_SIGNED_EXT function? 59 60 - Yes. This pre-scale bias is a special case and will be treated 61 as such. 62 63 Should the primary color of the incoming fragment be available to 64 all texture environments? Currently it is only available to the 65 texture environment of texture unit 0. 66 67 - Yes, PRIMARY_COLOR_EXT has been added as an input source. 68 69 Should textures from other texture units be allowed as sources? 70 71 - No, not in the base spec. Too many vendors have expressed 72 concerns about the scalability of such functionality. This can 73 be added as a subsequent extension. 74 75 All of the 1.2 modes except BLEND can be expressed in terms of 76 this extension. Should texture color be allowed as a source for 77 Arg2, so all of the 1.2 modes can be expressed? If so, should all 78 color sources be allowed, to maintain orthogonality? 79 80 - No, not in the base spec. This can be added as a subsequent 81 extension. 82 83New Procedures and Functions 84 85 None 86 87New Tokens 88 89 Accepted by the <params> parameter of TexEnvf, TexEnvi, TexEnvfv, 90 and TexEnviv when the <pname> parameter value is TEXTURE_ENV_MODE 91 92 COMBINE_EXT 0x8570 93 94 Accepted by the <pname> parameter of TexEnvf, TexEnvi, TexEnvfv, 95 and TexEnviv when the <target> parameter value is TEXTURE_ENV 96 97 COMBINE_RGB_EXT 0x8571 98 COMBINE_ALPHA_EXT 0x8572 99 SOURCE0_RGB_EXT 0x8580 100 SOURCE1_RGB_EXT 0x8581 101 SOURCE2_RGB_EXT 0x8582 102 SOURCE0_ALPHA_EXT 0x8588 103 SOURCE1_ALPHA_EXT 0x8589 104 SOURCE2_ALPHA_EXT 0x858A 105 OPERAND0_RGB_EXT 0x8590 106 OPERAND1_RGB_EXT 0x8591 107 OPERAND2_RGB_EXT 0x8592 108 OPERAND0_ALPHA_EXT 0x8598 109 OPERAND1_ALPHA_EXT 0x8599 110 OPERAND2_ALPHA_EXT 0x859A 111 RGB_SCALE_EXT 0x8573 112 ALPHA_SCALE 113 114 Accepted by the <params> parameter of TexEnvf, TexEnvi, TexEnvfv, 115 and TexEnviv when the <pname> parameter value is COMBINE_RGB_EXT 116 or COMBINE_ALPHA_EXT 117 118 REPLACE 119 MODULATE 120 ADD 121 ADD_SIGNED_EXT 0x8574 122 INTERPOLATE_EXT 0x8575 123 124 Accepted by the <params> parameter of TexEnvf, TexEnvi, TexEnvfv, 125 and TexEnviv when the <pname> parameter value is SOURCE0_RGB_EXT, 126 SOURCE1_RGB_EXT, SOURCE2_RGB_EXT, SOURCE0_ALPHA_EXT, 127 SOURCE1_ALPHA_EXT, or SOURCE2_ALPHA_EXT 128 129 TEXTURE 130 CONSTANT_EXT 0x8576 131 PRIMARY_COLOR_EXT 0x8577 132 PREVIOUS_EXT 0x8578 133 134 Accepted by the <params> parameter of TexEnvf, TexEnvi, TexEnvfv, 135 and TexEnviv when the <pname> parameter value is 136 OPERAND0_RGB_EXT or OPERAND1_RGB_EXT 137 138 SRC_COLOR 139 ONE_MINUS_SRC_COLOR 140 SRC_ALPHA 141 ONE_MINUS_SRC_ALPHA 142 143 Accepted by the <params> parameter of TexEnvf, TexEnvi, TexEnvfv, 144 and TexEnviv when the <pname> parameter value is 145 OPERAND0_ALPHA_EXT or OPERAND1_ALPHA_EXT 146 147 SRC_ALPHA 148 ONE_MINUS_SRC_ALPHA 149 150 Accepted by the <params> parameter of TexEnvf, TexEnvi, TexEnvfv, 151 and TexEnviv when the <pname> parameter value is 152 OPERAND2_RGB_EXT or OPERAND2_ALPHA_EXT 153 154 SRC_ALPHA 155 156 Accepted by the <params> parameter of TexEnvf, TexEnvi, TexEnvfv, 157 and TexEnviv when the <pname> parameter value is RGB_SCALE_EXT or 158 ALPHA_SCALE 159 160 1.0 161 2.0 162 4.0 163 164Additions to Chapter 2 of the GL Specification (OpenGL Operation) 165 166 None 167 168Additions to Chapter 3 of the GL Specification (Rasterization) 169 170 Added to subsection 3.8.9, before the paragraph describing the 171 state requirements: 172 173 If the value of TEXTURE_ENV_MODE is COMBINE_EXT, the form of the 174 texture function depends on the values of COMBINE_RGB_EXT and 175 COMBINE_ALPHA_EXT, according to table 3.20. The RGB and ALPHA 176 results of the texture function are then multiplied by the values 177 of RGB_SCALE_EXT and ALPHA_SCALE, respectively. The results are 178 clamped to [0,1]. 179 180 181 COMBINE_RGB_EXT or 182 COMBINE_ALPHA_EXT Texture Function 183 ------------------ ---------------- 184 REPLACE Arg0 185 MODULATE Arg0 * Arg1 186 ADD Arg0 + Arg1 187 ADD_SIGNED_EXT Arg0 + Arg1 - 0.5 188 INTERPOLATE_EXT Arg0 * (Arg2) + Arg1 * (1-Arg2) 189 190 Table 3.20: COMBINE_EXT texture functions 191 192 The arguments Arg0, Arg1 and Arg2 are determined by the values of 193 SOURCE<n>_RGB_EXT, SOURCE<n>_ALPHA_EXT, OPERAND<n>_RGB_EXT and 194 OPERAND<n>_ALPHA_EXT. In the following two tables, Ct and At are 195 the filtered texture RGB and alpha values; Cc and Ac are the 196 texture environment RGB and alpha values; Cf and Af are the RGB 197 and alpha of the primary color of the incoming fragment; and Cp 198 and Ap are the RGB and alpha values resulting from the previous 199 texture environment. On texture environment 0, Cp and Ap are 200 identical to Cf and Af, respectively. The relationship is 201 described in tables 3.21 and 3.22. 202 203 SOURCE<n>_RGB_EXT OPERAND<n>_RGB_EXT Argument 204 ----------------- -------------- -------- 205 TEXTURE SRC_COLOR Ct 206 ONE_MINUS_SRC_COLOR (1-Ct) 207 SRC_ALPHA At 208 ONE_MINUS_SRC_ALPHA (1-At) 209 CONSTANT_EXT SRC_COLOR Cc 210 ONE_MINUS_SRC_COLOR (1-Cc) 211 SRC_ALPHA Ac 212 ONE_MINUS_SRC_ALPHA (1-Ac) 213 PRIMARY_COLOR_EXT SRC_COLOR Cf 214 ONE_MINUS_SRC_COLOR (1-Cf) 215 SRC_ALPHA Af 216 ONE_MINUS_SRC_ALPHA (1-Af) 217 PREVIOUS_EXT SRC_COLOR Cp 218 ONE_MINUS_SRC_COLOR (1-Cp) 219 SRC_ALPHA Ap 220 ONE_MINUS_SRC_ALPHA (1-Ap) 221 222 Table 3.21: Arguments for COMBINE_RGB_EXT functions 223 224 SOURCE<n>_ALPHA_EXT OPERAND<n>_ALPHA_EXT Argument 225 ----------------- -------------- -------- 226 TEXTURE SRC_ALPHA At 227 ONE_MINUS_SRC_ALPHA (1-At) 228 CONSTANT_EXT SRC_ALPHA Ac 229 ONE_MINUS_SRC_ALPHA (1-Ac) 230 PRIMARY_COLOR_EXT SRC_ALPHA Af 231 ONE_MINUS_SRC_ALPHA (1-Af) 232 PREVIOUS_EXT SRC_ALPHA Ap 233 ONE_MINUS_SRC_ALPHA (1-Ap) 234 235 Table 3.22: Arguments for COMBINE_ALPHA_EXT functions 236 237 The mapping of texture components to source components is 238 summarized in Table 3.23. In the following table, At, Lt, It, Rt, 239 Gt and Bt are the filtered texel values. 240 241 Base Internal Format RGB Values Alpha Value 242 -------------------- ---------- ----------- 243 ALPHA 0, 0, 0 At 244 LUMINANCE Lt, Lt, Lt 1 245 LUMINANCE_ALPHA Lt, Lt, Lt At 246 INTENSITY It, It, It It 247 RGB Rt, Gt, Bt 1 248 RGBA Rt, Gt, Bt At 249 250 Table 3.23: Correspondence of texture components to source 251 components for COMBINE_RGB_EXT and COMBINE_ALPHA_EXT arguments 252 253Additions to Chapter 4 of the GL Specification (Per-Fragment Operations 254and the Framebuffer) 255 256 None 257 258Additions to Chapter 5 of the GL Specification (Special Functions) 259 260 None 261 262Additions to Chapter 6 of the GL Specification (State and State Requests) 263 264 None 265 266Additions to the GLX Specification 267 268 None 269 270GLX Protocol 271 272 None 273 274Errors 275 276 INVALID_ENUM is generated if <params> value for COMBINE_RGB_EXT or 277 COMBINE_ALPHA_EXT is not one of REPLACE, MODULATE, ADD, 278 ADD_SIGNED_EXT, or INTERPOLATE_EXT. 279 280 INVALID_ENUM is generated if <params> value for SOURCE0_RGB_EXT, 281 SOURCE1_RGB_EXT, SOURCE2_RGB_EXT, SOURCE0_ALPHA_EXT, 282 SOURCE1_ALPHA_EXT or SOURCE2_ALPHA_EXT is not one of TEXTURE, 283 CONSTANT_EXT, PRIMARY_COLOR_EXT or PREVIOUS_EXT. 284 285 INVALID_ENUM is generated if <params> value for OPERAND0_RGB_EXT 286 or OPERAND1_RGB_EXT is not one of SRC_COLOR, ONE_MINUS_SRC_COLOR, 287 SRC_ALPHA or ONE_MINUS_SRC_ALPHA. 288 289 INVALID_ENUM is generated if <params> value for OPERAND0_ALPHA_EXT 290 or OPERAND1_ALPHA_EXT is not one of SRC_ALPHA or 291 ONE_MINUS_SRC_ALPHA. 292 293 INVALID_ENUM is generated if <params> value for OPERAND2_RGB_EXT 294 or OPERAND2_ALPHA_EXT is not SRC_ALPHA. 295 296 INVALID_VALUE is generated if <params> value for RGB_SCALE_EXT or 297 ALPHA_SCALE is not one of 1.0, 2.0, or 4.0. 298 299Dependencies on SGI_texture_color_table 300 301 If SGI_texture_color_table is implemented, the expanded Rt, Gt, 302 Bt, and At values are used directly instead of the expansion 303 described by Table 3.23. 304 305Dependencies on SGIX_texture_scale_bias 306 307 If SGIX_texture_scale_bias is implemented, the expanded Rt, Gt, 308 Bt, and At values are used directly instead of the expansion 309 described by Table 3.23. 310 311New State 312 313 Get Value Get Command Type Initial Value Attribute 314 --------- ----------- ---- ------------- --------- 315 COMBINE_RGB_EXT GetTexEnviv n x Z4 MODULATE texture 316 COMBINE_ALPHA_EXT GetTexEnviv n x Z4 MODULATE texture 317 SOURCE0_RGB_EXT GetTexEnviv n x Z3 TEXTURE texture 318 SOURCE1_RGB_EXT GetTexEnviv n x Z3 PREVIOUS_EXT texture 319 SOURCE2_RGB_EXT GetTexEnviv n x Z3 CONSTANT_EXT texture 320 SOURCE0_ALPHA_EXT GetTexEnviv n x Z3 TEXTURE texture 321 SOURCE1_ALPHA_EXT GetTexEnviv n x Z3 PREVIOUS_EXT texture 322 SOURCE2_ALPHA_EXT GetTexEnviv n x Z3 CONSTANT_EXT texture 323 OPERAND0_RGB_EXT GetTexEnviv n x Z6 SRC_COLOR texture 324 OPERAND1_RGB_EXT GetTexEnviv n x Z6 SRC_COLOR texture 325 OPERAND2_RGB_EXT GetTexEnviv n x Z1 SRC_ALPHA texture 326 OPERAND0_ALPHA_EXT GetTexEnviv n x Z4 SRC_ALPHA texture 327 OPERAND1_ALPHA_EXT GetTexEnviv n x Z4 SRC_ALPHA texture 328 OPERAND2_ALPHA_EXT GetTexEnviv n x Z1 SRC_ALPHA texture 329 RGB_SCALE_EXT GetTexEnvfv n x R3 1.0 texture 330 ALPHA_SCALE GetTexEnvfv n x R3 1.0 texture 331 332New Implementation Dependent State 333 334 None 335 336NVIDIA Implementation Details 337 338 Because of a hardware limitation, TNT, TNT2, GeForce, and Quadro 339 treat "scale by 4.0" with the COMBINE_RGB_EXT or COMBINE_ALPHA_EXT 340 mode of ADD_SIGNED_EXT as "scale by 2.0". 341 342 GeForce 6 Series and later GPUs (NV40 and on) support "scale by 4.0" 343 properly. 344 345Revision History 346 347 2/22/00 mjk - added NVIDIA Implementation Details 348