1XXX - Not complete yet!!! 2 3Name 4 5 SGIX_nonlinear_lighting_pervertex 6 7Name Strings 8 9 GL_SGIX_nonlinear_lighting_pervertex 10 11Version 12 13 $Date: 1997/09/23 23:20:38 $ $Revision: 1.1 $ 14 15Number 16 17 ??? 18 19Dependencies 20 21 OpenGL 1.1 is required. 22 23Overview 24 25 26 This extension adds new functionality to the per-vertex lighting 27 model of OpenGL. It facilitates a nonlinear approximation of 28 reflectance functions of materials. This extension is based upon 29 research conducted at Cornell University and detailed in the 30 SIGGRAPH 97 proceedings (LaFortune, pp. 117-126). When active, 31 this reflectance model replaces diffuse and specular (and ambient?) 32 reflection with a single, generalized material description. 33 34 The fundamental equation for nonlinear reflectance can be expressed 35 as the following weighte dot-product: 36 37 Fr(u,v) = Ps*(Cx*ux*vx + Cy*uy*vy + Cz*uz*vz)^n 38 39 Where: u = light vector at a vertex 40 v = eye vector at a vertex 41 Ps = maximum albedo (fully-illuminated material color) 42 C = nonlinear scaling coefficients 43 n = specular exponent (~shininess) 44 45 The magnitude of the C vector equals (n+2)/2pi and represents the 46 normalization constant. 47 48 A given material will be influenced by a number Ps, C coeffients 49 (analagous to specular, diffuse, ambient components in the basic 50 OpenGL lighting model). As in the OpenGL 1.1 lighting model, the 51 final color for a point is expressed as a sum of equations of the 52 same format as Fr: 53 54 55 Fr(u,v) = Sum(i,N)(Cx,i*ux*vx + Cy,i*uy*vy + Cz,i*uz*vz)^ni 56 57 Where the reflectance at a point is defined by the sum of N 58 expressions. Each dot product is characterized by the following 59 coefficients: 60 61 Ci = coefficient vectors with with color absorbed 62 ni = specular exponents 63 64 In the context of OpenGL, it makes sense to make the magnitude of 65 Ci be (ni+2)/2pi and keep the color (RGBA) vector separate. 66 67 This extension will be implemented in the OpenGL pipeline directly 68 in place of the per-vertex specular, diffuse lighting. 69 70Issues 71 72 * Should ambient lighting calculations remain active when nonlinear 73 reflectance is enabled? 74 75 * Should we only allow a single Alpha component to be used, as in 76 the OpenGL 1.1 model? 77 78 * Because of the potentially large amount of data associated (relative 79 to OpenGL 1.1 materials) with a material, should a "Material Object" 80 extension be considered? 81 82 * Should Nonlinear Lighting be allowed in Color_Index mode? 83 84 * Should the vertex colors be clamped positive? This will inhibit multipassing... 85 86 * Are there any dependencies on other extensions? 87 88 89New Procedures and Functions 90 91 Because of the potentially large number of nonlinear terms, special 92 "Nonlin" versions of Material, Light have been added in this extension. 93 These functions affect lighting state in a manner identical to Material 94 and Light, with a different calling convention. 95 96 void NonlinMaterialfvSGIX(enum face, enum pname, int terms, const float *params); 97 void GetNonlinMaterialfvSGIX(enum face, enum pname, int *terms, const float *data); 98 99 void NonlinLightfvSGIX(enum light, enum pname, int terms, float *params); 100 void GetNonlinLightfvSGIX(enum light, enum pname, int *terms, float *data); 101 102New Tokens 103 104 Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, by 105 the <pname> parameters of GetBooleanv, GetIntegerv, GetFloatv, and 106 GetDoublev: 107 108 NONLIN_LIGHTING_SGIX 0x???? 109 110 Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, 111 and GetDoublev: 112 113 MAX_NONLIN_TERMS_SGIX 0x???? 114 MAX_NONLIN_LIGHTS_SGIX 0x????+1 115 116 Accepted by the <pname> parameter of NonlinMaterialv, NonlinLightv: 117 118 COLOR_SGIX 0x???? 119 120 Accepted by the <pname> parameter of NonlinMaterialv: 121 122 WEIGHT_SGIX 0x???? 123 124 125Additions to Chapter 2 of the 1.1 Specification (OpenGL Operation) 126 127 Section 2.13.1 Lighting 128 129 ... <paragraph 2> 130 Lighting may be in one of three states: 131 132 ... 133 2. Lighting On, Nonlinear Reflectance Disabled. In this state, 134 a vertex's color is found by computing a value given the 135 current lighting parameters and using the specular/diffuse 136 reflectance model. 137 138 3. Lighting On, Nonlinear Reflectance Enabled. In this state, 139 a vertex's color is found by computing a value given the 140 current lighting parameters and using the nonlinear reflectance 141 model. 142 143 Lighting is turned either on or off using the generic Enable or 144 Disable commands with the symbolic value LIGHTING. Nonlinear 145 Reflectance is turned either on or off using the generic Enable or 146 Disable commands with the symbolic value NONLIN_LIGHTING_SGIX. 147 Nonlinear Reflectance has no effect if lighting is off. 148 149 ...<paragraph 3 - Lighting Operation> 150 A lighting parameter is one of seven types: color, position, direction, 151 weight, real, int, or boolean. 152 ... 153 A weight parameter consists of 3 floating-point elements, one for 154 each of Cx, Cy, and Cz, in that order. There are no restrictions on 155 the allowable values for the weight parameter. 156 ... 157 An int parameter is one integer value. 158 159 ...<table 2.7> 160 Nonlinear Material Parameters 161 wcm,j weight (0.0,0.0,0.0) jth reflectance weight of material 162 srm,j real 1.0 jth specular exponent of material 163 ccm,j color (0.8,0.8,0.8,1.0) jth color of material 164 tnlm int 0 Maximum (j+1) of material 165 ... 166 Nonlinear Light Source Parameters 167 ncli,j(i=0) color (1.0,1.0,1.0,1.0) jth intensity of light 0 168 ncli,j(i>0) color (0.0,0.0,0.0,1.0) jth intensity of light i 169 tnll int 0 Maximum (j+1) light 170 171 ...<Page 45> 172 If nonlinear reflectance is disabled, the color c produced... 173 ...If nonlinear reflectance is enabled, the color c produced by lighting a 174 vertex is given by 175 176 c = ecm + acm*acs + 177 178 sum<i=0,n-1>(sum<j=0,min(tnlm, tnll)-1>(acm*acli + 179 (fi)(nx*hx*wcmx,j + ny*hy*wcmy,j + nz*hz*wcmzj)^srm,j * 180 ccm,j*ncli,j)) 181 182 Section 2.13.2 Lighting Parameter Specification 183 184 ... <paragraph 1.5> 185 ...Material... 186 void NonlinMaterial{f}v( enum face, enum pname, int terms, T params ) ; 187 ...Light... 188 void NonlinLight{f}v( enum light, enum pname, int terms, T params ) ; 189 190 ... <paragraph 2> 191 ... params is a pointer... terms is an integer indicating how many terms 192 of a nonlinear lighting equation are being specified by a function call. 193 194 ...For the Material or NonlinMaterial commands, face must be one of... 195 196 ... <table 2.8> 197 198 Nonlinear Material Parameters(NonlinMaterial) 199 wcm,j WEIGHT 3*terms 200 ccm,j COLOR 4*terms 201 srm,j SHININESS terms 202 tnlm terms 1 203 204 ... 205 206 Nonlinear Light Source Parameters(NonlinLight) 207 208 ncli,j COLOR 4*terms 209 tnll terms 1 210 211 Section 2.13.3 ColorMaterial 212 213 ... <paragraph 1> 214 ...by calling Enable or Disable with the symbolic value COLOR_MATERIAL. 215 The error INVALID_OPERATION is generated if COLOR_MATERIAL is Enabled 216 while NONLIN_LIGHTING is enabled. 217 218 Section 2.14.4 Lighting State 219 220 ... <paragraph 1> 221 ...The state required...a bit indicating whether or not NONLINEAR_LIGHTING 222 is enabled, and a single... 223 224 225 226Additions to Chapter 3 of the 1.1 Specification (Rasterization) 227 228 None 229 230Additions to Chapter 4 of the 1.1 Specification (Per-Fragment Operations 231and the Frame Buffer) 232 233 None 234 235Additions to Chapter 5 of the 1.1 Specification (Special Functions) 236 237 None 238 239Additions to Chapter 6 of the 1.1 Specification (State and State Requests) 240 241 ... <page 145, list of functions> 242 243 void GetNonlinLight{f}v( enum light, enum value, int *terms, T *data ) ; 244 void GetNonlinMaterial{f}v( enum face, enum value, int *terms, T *data ) ; 245 246 ... <page 145, new paragraph between GetMaterial and GetTexParameter> 247 248 GetNonlinLight and GetNonlinMaterial are similar to their GetLight 249 and GetMaterial counterparts, except that they return by reference 250 the number of terms (int *terms) and an array of parameters (T *data). 251 The *data pointer passed to GetNonlinMaterial and GetNonlinLight should 252 point to an array large enough to contain MAX_NONLIN_TERMS*components, 253 where components equals the number of floats comprising a datum. 254 255 ... <table 6.3> 256 W Weight (floating-point Cx, Cy, Cz values) 257 258Additions to the GLX Specification 259 260 TBD 261 262Dependencies on SGI_extension_name 263 264 None? 265 266Errors 267 268 INVALID_OPERATION is generated if the user attempts to enable both 269 COLOR_MATERIAL and NONLINEAR_LIGHTING, irregardless of order. 270 271 INVALID_ENUM is generated if NonlinLight{f}vSGIX parameter <pname> is not 272 COLOR or <light> is not valid (LIGHT{0..MAX_NONLIN_LIGHTS-1}. 273 274 INVALID_VALUE is generated if NonlinLight{f}vSGIX parameter <terms> is 275 outside the range [0..MAX_NONLIN_TERMS). 276 277 INVALID_OPERATION is generated if the number of terms for an active 278 light differs from the current material, or if the number of terms 279 for SHININESS, WEIGHTS and COLOR differ. This error results from 280 primitive specification. 281 282 INVALID_ENUM is generated if NonlinMaterial{T}vSGIX parameter <face> is 283 not FRONT, BACK, or FRONT_AND_BACK. 284 285 INVALID_ENUM is generated if NonlinMaterial{T}vSGIX parameter <pname> is 286 not COLOR, SHININESS, or WEIGHT. 287 288 INVALID_VALUE is generated if NonlinMaterial{T}vSGIX parameter <terms> is 289 outside the range [0..MAX_NONLIN_TERMS). 290 291 INVALID_ENUM is generated if GetNonlinLight{t}vSGIX parameter <light> 292 is not valid (LIGHT{0..MAX_NONLIN_LIGHTS-1}. 293 294 INVALID_ENUM is generated if GetNonlinLight{t}vSGIX parameter <pname> 295 is not COLOR. 296 297 INVALID_ENUM is generated if GetNonlinMaterial{t}vSGIX parameter <face> 298 is not FRONT, BACK, or FRONT_AND_BACK. 299 300 INVALID_ENUM is generated if GetNonlinMaterial{t}vSGIX parameter <pname> 301 is not COLOR, SHININESS, or WEIGHT. 302 303New State 304 Initial 305 Get Value Get Command Type Value Attrib 306 --------- ----------- ---- ------- ------ 307 308 NONLINEAR_LIGHTING_SGIX IsEnabled B False lighting/enable 309 COLOR_SGIX GetNonlinLightfvSGIX 1*xC () lighting 310 COLOR_SGIX GetNonlinMaterialfvSGIX 1*xC () lighting 311 WEIGHT_SGIX GetNonlinMaterialfvSGIX 1*xW (1.0,1.0,1.0) lighting 312 SHININESS GetNonlinMaterialfvSGIX 1*xR 1.0 lighting 313 (material color terms) GetNonlinMaterialfvSGIX Z+ 0 lighting 314 (light color terms) GetNonlinLightfvSGIX Z+ 0 lighting 315 (material weight terms) GetNonlinMaterialfvSGIX Z+ 0 lighting 316 (material shininess terms) GetNonlinMaterialfvSGIX Z+ 0 lighting 317 318 319New Implementation Dependent State 320 Minimum 321 Get Value Get Command Type Value 322 --------- ----------- ---- ------- 323 MAX_NONLIN_LIGHTS_SGIX GetInteger Z+ 1 324 MAX_NONLIN_TERMS_SGIX GetIngeger Z+ 12