1Name 2 3 NV_texgen_emboss 4 5Name Strings 6 7 GL_NV_texgen_emboss 8 9Contact 10 11 Mark J. Kilgard, NVIDIA Corporation (mjk 'at' nvidia.com) 12 13Notice 14 15 Copyright NVIDIA Corporation, 1999, 2001. 16 17IP Status 18 19 NVIDIA Proprietary. 20 21Status 22 23 Discontinued. 24 25 NVIDIA no longer supports this extension in driver updates 26 after November 2002. Instead, use either ARB_vertex_program & 27 NV_vertex_program. 28 29Version 30 31 NVIDIA Date: January 3, 2003 32 $Date$ $Revision$ 33 $Id: //sw/main/docs/OpenGL/specs/old/GL_NV_texgen_emboss.txt#2 $ 34 35Number 36 37 193 38 39Dependencies 40 41 ARB_multitexture. 42 43 Written based on the wording of the OpenGL 1.2 specification and the 44 ARB_multitexture extension. 45 46Overview 47 48 This extension provides a new texture coordinate generation mode 49 suitable for multitexture-based embossing (or bump mapping) effects. 50 51 Given two texture units, this extension generates the texture 52 coordinates of a second texture unit (an odd-numbered texture unit) 53 as a perturbation of a first texture unit (an even-numbered texture 54 unit one less than the second texture unit). The perturbation is 55 based on the normal, tangent, and light vectors. The normal vector 56 is supplied by glNormal; the light vector is supplied as a direction 57 vector to a specified OpenGL light's position; and the tanget 58 vector is supplied by the second texture unit's current texture 59 coordinate. The perturbation is also scaled by program-supplied 60 scaling constants. 61 62 If both texture units are bound to the same texture representing a 63 height field, by subtracting the difference between the resulting two 64 filtered texels, programs can achieve a per-pixel embossing effect. 65 66Issues 67 68 Can you do embossing on any texture unit? 69 70 NO. Just odd numbered units. This meets a constraint of the 71 proposed hardware implementation, and because embossing takes two 72 texture units anyway, it shouldn't be a real limitation. 73 74 Can you just enable one coordinate of a texture unit for embossing? 75 76 Yes but NOT REALLY. The texture coordinate generation formula 77 is specified such that only when ALL the coordinates are enabled 78 and are using embossing, do you get the embossing computation. 79 Otherwise, you get undefined values for texture coordinates enabled 80 for texture coordinate generation and setup for embossing. 81 82 Does the light specified have to be enabled for embossing to work? 83 84 Yes, currently. But perhaps we could require implementations to 85 enable a phantom light (the light colors would be black). 86 87 Could the emboss constant just be the reciprocal of the width and 88 height of the texture units texture if that's what the programmer 89 will have it be most of the time? 90 91 NO. Too much work and there may be reasons for the programmer to 92 control this. 93 94 OpenGL's base texture environment functionality isn't powerful enough 95 to do the subtraction needed for embossing. Where would you get 96 powerful enough texture environment functionality. 97 98 Another extension. Try NV_register_combiners. 99 100 What is the interpretation of CT? 101 102 For the purposes of embossing, CT should be thought of as the 103 vertex's tangent vector. This tangent vector indicates the direction 104 on the "surface" where PCTs is not changing and PCTt is increasing. 105 106 Are the CT and PCT variables the user-supplied current texture 107 coordinates? 108 109 YES. Except when the texture unit's texture coordinate evaluator 110 is enabled, then CT and PCT use the respective evaluated texture 111 coordinates. 112 113 This extension specification's language "Denote as CT the texture 114 unit's current texture coordinates" and "Denote as PCT the previous 115 texture unit's current texture coordinates" refers to the "current 116 texture coordinates" OpenGL state which is the state specified 117 via glTexCoord. Plus the exception for evaluators. 118 119 To be explicit, PCT is NOT the result of texgen or the texture 120 matrix. Likewise, CT is NOT the result of texgen or the 121 texture matrix. PCT and CT are the respective texture unit's 122 evaluated texture coordinate if the vertex is evaluated with 123 texture coordinate evaluation enabled, otherwise if the vertex is 124 generated via vertex arrays with the respective texture coordinate 125 array enabled, the texture coordinate from the texture coordinate 126 array, otherwise the respective current texture coordinate is used. 127 128New Procedures and Functions 129 130 None 131 132New Tokens 133 134 Accepted by the <param> parameters of TexGend, TexGenf, and TexGeni 135 when <pname> parameter is TEXTURE_GEN_MODE: 136 137 EMBOSS_MAP_NV 0x855F 138 139 When the <pname> parameter of TexGendv, TexGenfv, and TexGeniv is 140 TEXTURE_GEN_MODE, then the array <params> may also contain 141 EMBOSS_MAP_NV. 142 143 Accepted by the <pname> parameters of GetTexGendv, GetTexGenfv, 144 GetTexGeniv, TexGend, TexGendv, TexGenf, TexGenfv, TexGeni, and 145 TexGeniv: 146 147 EMBOSS_LIGHT_NV 0x855D 148 EMBOSS_CONSTANT_NV 0x855E 149 150Additions to Chapter 2 of the 1.2 Specification (OpenGL Operation) 151 152-- Section 2.10.4 "Generating Texture Coordinates" 153 154 Change the last sentence in the 1st paragraph to: 155 156 "If <pname> is TEXTURE_GEN_MODE, then either <params> points to 157 or <param> is an integer that is one of the symbolic constants 158 OBJECT_LINEAR, EYE_LINEAR, SPHERE_MAP, or EMBOSS_MAP_NV." 159 160 Add these paragraphs after the 4th paragraph: 161 162 "When used with a suitable texture, suitable explicit texture 163 coordinates, a suitable (extended) texture environment, 164 suitable lighting parameters, and suitable embossing parameters, 165 calling TexGen with TEXTURE_GEN_MODE indicating EMBOSS_MAP_NV 166 can simulate the lighting effect of embossing on a polygon. 167 The error INVALID_ENUM occurs when the active texture unit has an 168 even number. 169 170 The emboss constant and emboss light parameters for controlling 171 the EMBOSS_MAP_NV mode are specified by calling TexGen with pname 172 set to EMBOSS_CONSTANT_NV and EMBOSS_LIGHT_NV respectively. 173 174 When pname is EMBOSS_CONSTANT_NV, param or what params points 175 to is a scalar value. An error INVALID_ENUM occurs if pname is 176 EMBOSS_CONSTANT_NV and coord is R or Q. An error INVALID_ENUM 177 also occurs if pname is EMBOSS_CONSTANT_NV and the active texture 178 unit number is even. 179 180 When pname is EMBOSS_LIGHT_NV, param or what params points to is 181 a symbolic constant of the form LIGHTi, indicating that light i 182 is to have the specified parameter set. An error INVALID_ENUM 183 occurs if pname is EMBOSS_LIGHT_NV and coord is R or Q. An error 184 INVALID_ENUM occurs if pname is EMBOSS_LIGHT_NV and the active 185 texture unit number is even. An error INVALID_ENUM occurs if 186 pname is EMBOSS_LIGHT_NV and the value i for LIGHTi is negative 187 or is greater than or equal to the value of MAX_LIGHTS. 188 189 If TEXTURE_GEN_MODE indicates EMBOSS_MAP_NV, the generation function 190 for the coordinates S, T, R, and Q is computed as follows. 191 192 Denote as L the light direction vector from the vertex's eye 193 position to the position of the light specified by the coordinate's 194 EMBOSS_LIGHT_NV state (the direction vector is computed as described 195 in Section 3.13.1). 196 197 Denote as N the current normal after transformation to eye 198 coordinates. 199 200 Denote as CT the texture unit's current texture coordinates 201 transformed to eye coordinates by normal transformation (as 202 described in Section 3.10.3) and normalized. 203 204 However, if the vertex is evaluated (as described in Section 5.1) 205 and the texture unit's texture coordinate map is enabled, use the 206 texture unit's evaluated texture coordinate to compute CT. 207 208 Denote as B the cross product of N and the <s,t,r> vector of CT. 209 210 Bx = Ny*CTr - CTt*Nz 211 By = Nz*CTs - CTr*Nx 212 Bz = Nx*CTt - CTs*Ny 213 214 Denote as BN the normalized version of the vector B. 215 216 BNx = Bx / sqrt(Bx*Bx + By*By + Bz*Bz); 217 BNy = By / sqrt(Bx*Bx + By*By + Bz*Bz); 218 BNz = Bz / sqrt(Bx*Bx + By*By + Bz*Bz); 219 220 Denote as T the cross product of B and N. 221 222 Tx = BNy*Nz - Ny*BNz 223 Ty = BNz*Nx - Nz*BNx 224 Tz = BNx*Ny - Nx*BNy 225 226 Observe that BN and T are orthonormal. 227 228 Denote as PCT the previous texture unit's current texture 229 coordinates. If the number of the texture unit for the texture 230 coordinates being generated is n, then the previous texture unit 231 is texture unit number n-1. Note that n is restricted to be odd. 232 233 However, if the vertex is evaluated (as described in Section 5.1) 234 and the previous texture unit's texture coordinate map is enabled, 235 use the previous texture unit's evaluated texture coordinate to 236 compute PCT. 237 238 Denote Ks as the S coordinate's EMBOSS_CONSTANT_NV state. Denote Kt 239 as the T coordinate's EMBOSS_CONSTANT_NV state. These constants 240 should typically be set to the reciprocal of the width and height 241 respectively of the texture map used for embossing. 242 243 Denote E as follows: 244 245 Es = PCTs + Ks * (Lx*BNx + Ly*BNy + Lz*BNz) * PCTq 246 Et = PCTt - Kt * (Lx*Tx + Ly*Ty + Lz*Tz) * PCTq 247 Er = PCTr 248 Eq = PCTq 249 250 Then the value assigned to an s, t, r, and q coordinates are Es, 251 Et, Er, and Eq respectively. However, for this assignment to 252 occur, the following three conditions must be met. First, all the 253 texture coordinate generation modes of all the texture coordinates 254 (S, T, R, and Q) of the texture unit must be set to EMBOSS_MAP_NV. 255 Second, all the texture coordinate generation modes of the texture 256 unit must be enabled. Third, the EMBOSS_LIGHT_NV parameters of 257 coordinates S and T must be identical and the light and lighting 258 must be enabled. If these conditions are not met, the values of 259 all coordinates in the texture unit with the EMBOSS_MAP_NV mode 260 are undefined." 261 262 The last paragraph's first sentence should be changed to: 263 264 "The state required for texture coordinate generation comprises 265 a five-valued integer for each coordinate indicating coordinate 266 generation mode, and a bit for each coordinate to indicate whether 267 texture coordinate generation is enabled or disabled. In addition, 268 four coefficients are required for the four coordinates for each 269 of EYE_LINEAR and OBJECT_LINEAR; also, an emboss constant and 270 emboss light are required for each of the four coordinates.... 271 The initial values for emboss constants and emboss lights are 1.0 272 and LIGHT0 respectively." 273 274Additions to Chapter 3 of the 1.2 Specification (Rasterization) 275 276 None 277 278Additions to Chapter 4 of the 1.2 Specification (Per-Fragment Operations 279and the Frame Buffer) 280 281 None 282 283Additions to Chapter 5 of the 1.2 Specification (Special Functions) 284 285 None 286 287Additions to Chapter 6 of the 1.2 Specification (State and State Requests) 288 289 None 290 291Additions to the AGL/GLX/WGL Specifications 292 293 None 294 295GLX Protocol 296 297 None 298 299Errors 300 301 INVALID_ENUM is generated when TexGen is called with a <pname> 302 of TEXTURE_GEN_MODE, a <param> value or value of what <params> 303 points to of EMBOSS_MAP_NV, and the active texture unit is even. 304 305 INVALID_ENUM is generated when TexGen is called with a <pname> 306 of EMBOSS_CONSTANT_NV and the active texture unit is even. 307 308 INVALID_ENUM is generated when TexGen is called with a <pname> 309 of EMBOSS_LIGHT_NV and the active texture unit is even. 310 311 INVALID_ENUM is generated when TexGen is called with a <coord> 312 of R or Q when <pname> indicates EMBOSS_CONSTANT_NV. 313 314 INVALID_ENUM is generated when TexGen is called with a <coord> 315 of R or Q when <pname> indicates EMBOSS_LIGHT_NV. 316 317 INVALID_ENUM is generated when TexGen is called with a <pname> 318 of EMBOSS_LIGHT_NV and the value of i for the parameter LIGHTi is 319 negative or is greater than or equal to the value of MAX_LIGHTS. 320 321New State 322 323(table 6.14, p204) change the entry for TEXTURE_GEN_MODE to: 324 325 Get Value Type Get Command Initial Value Description Sec Attribute 326 --------- ---- ----------- ------------- ----------- ------ --------- 327 TEXTURE_GEN_MODE 4xZ5 GetTexGeniv EYE_LINEAR Function used for 2.10.4 texture 328 texgen (for s,t,r, 329 and q) 330 EMBOSS_CONSTANT_NV 4xR GetTexGenfv 1.0 Scaling constant 2.10.4 texture 331 for emboss texgen 332 EMBOSS_LIGHT_NV 4xZ8* GetTexGeniv LIGHT0 Light used for 2.10.4 texture 333 embossing. 334 335When ARB_multitexture is supported, the Type column is per-texture unit. 336 337(the TEXTURE_GEN_MODE type changes from 4xZ3 to 4xZ5) 338 339New Implementation State 340 341 None 342 343Revision History 344 345 2001/02/20 - Status changed to deprecated. 346 1/3/2003 changed status to "discontinued" 347