1/* 2 * Mesa 3-D graphics library 3 * 4 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included 14 * in all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 * 24 * 25 * Authors: 26 * Brian Paul Keith Whitwell <keithw@vmware.com> 27 */ 28 29 30#if IDX & LIGHT_TWOSIDE 31# define NR_SIDES 2 32#else 33# define NR_SIDES 1 34#endif 35 36 37/* define TRACE to trace lighting code */ 38/* #define TRACE 1 */ 39 40/* 41 * ctx is the current context 42 * VB is the vertex buffer 43 * stage is the lighting stage-private data 44 * input is the vector of eye or object-space vertex coordinates 45 */ 46static void TAG(light_rgba_spec)( struct gl_context *ctx, 47 struct vertex_buffer *VB, 48 struct tnl_pipeline_stage *stage, 49 GLvector4f *input ) 50{ 51 struct light_stage_data *store = LIGHT_STAGE_DATA(stage); 52 GLfloat (*base)[3] = ctx->Light._BaseColor; 53 GLfloat sumA[2]; 54 GLuint j; 55 56 const GLuint vstride = input->stride; 57 const GLfloat *vertex = (GLfloat *)input->data; 58 const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride; 59 const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data; 60 61 GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; 62 GLfloat (*Fspec)[4] = (GLfloat (*)[4]) store->LitSecondary[0].data; 63#if IDX & LIGHT_TWOSIDE 64 GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; 65 GLfloat (*Bspec)[4] = (GLfloat (*)[4]) store->LitSecondary[1].data; 66#endif 67 68 const GLuint nr = VB->Count; 69 70#ifdef TRACE 71 fprintf(stderr, "%s\n", __func__ ); 72#endif 73 74 VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0]; 75 VB->AttribPtr[_TNL_ATTRIB_COLOR1] = &store->LitSecondary[0]; 76 sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; 77 78#if IDX & LIGHT_TWOSIDE 79 VB->BackfaceColorPtr = &store->LitColor[1]; 80 VB->BackfaceSecondaryColorPtr = &store->LitSecondary[1]; 81 sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; 82#endif 83 84 85 store->LitColor[0].stride = 16; 86 store->LitColor[1].stride = 16; 87 88 for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) { 89 GLfloat sum[2][3], spec[2][3]; 90 GLbitfield mask; 91 92#if IDX & LIGHT_MATERIAL 93 update_materials( ctx, store ); 94 sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; 95#if IDX & LIGHT_TWOSIDE 96 sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; 97#endif 98#endif 99 100 COPY_3V(sum[0], base[0]); 101 ZERO_3V(spec[0]); 102 103#if IDX & LIGHT_TWOSIDE 104 COPY_3V(sum[1], base[1]); 105 ZERO_3V(spec[1]); 106#endif 107 108 /* Add contribution from each enabled light source */ 109 mask = ctx->Light._EnabledLights; 110 while (mask) { 111 const int l = u_bit_scan(&mask); 112 struct gl_light *light = &ctx->Light.Light[l]; 113 struct gl_light_uniforms *lu = &ctx->Light.LightSource[l]; 114 GLfloat n_dot_h; 115 GLfloat correction; 116 GLint side; 117 GLfloat contrib[3]; 118 GLfloat attenuation; 119 GLfloat VP[3]; /* unit vector from vertex to light */ 120 GLfloat n_dot_VP; /* n dot VP */ 121 GLfloat *h; 122 123 /* compute VP and attenuation */ 124 if (!(light->_Flags & LIGHT_POSITIONAL)) { 125 /* directional light */ 126 COPY_3V(VP, light->_VP_inf_norm); 127 attenuation = light->_VP_inf_spot_attenuation; 128 } 129 else { 130 GLfloat d; /* distance from vertex to light */ 131 132 SUB_3V(VP, light->_Position, vertex); 133 134 d = (GLfloat) LEN_3FV( VP ); 135 136 if (d > 1e-6F) { 137 GLfloat invd = 1.0F / d; 138 SELF_SCALE_SCALAR_3V(VP, invd); 139 } 140 141 attenuation = 1.0F / (lu->ConstantAttenuation + d * 142 (lu->LinearAttenuation + d * 143 lu->QuadraticAttenuation)); 144 145 /* spotlight attenuation */ 146 if (light->_Flags & LIGHT_SPOT) { 147 GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection); 148 149 if (PV_dot_dir<lu->_CosCutoff) { 150 continue; /* this light makes no contribution */ 151 } 152 else { 153 GLfloat spot = powf(PV_dot_dir, lu->SpotExponent); 154 attenuation *= spot; 155 } 156 } 157 } 158 159 if (attenuation < 1e-3F) 160 continue; /* this light makes no contribution */ 161 162 /* Compute dot product or normal and vector from V to light pos */ 163 n_dot_VP = DOT3( normal, VP ); 164 165 /* Which side gets the diffuse & specular terms? */ 166 if (n_dot_VP < 0.0F) { 167 ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]); 168#if IDX & LIGHT_TWOSIDE 169 side = 1; 170 correction = -1; 171 n_dot_VP = -n_dot_VP; 172#else 173 continue; 174#endif 175 } 176 else { 177#if IDX & LIGHT_TWOSIDE 178 ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); 179#endif 180 side = 0; 181 correction = 1; 182 } 183 184 /* diffuse term */ 185 COPY_3V(contrib, light->_MatAmbient[side]); 186 ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]); 187 ACC_SCALE_SCALAR_3V(sum[side], attenuation, contrib ); 188 189 /* specular term - cannibalize VP... */ 190 if (ctx->Light.Model.LocalViewer) { 191 GLfloat v[3]; 192 COPY_3V(v, vertex); 193 NORMALIZE_3FV(v); 194 SUB_3V(VP, VP, v); /* h = VP + VPe */ 195 h = VP; 196 NORMALIZE_3FV(h); 197 } 198 else if (light->_Flags & LIGHT_POSITIONAL) { 199 h = VP; 200 ACC_3V(h, ctx->_EyeZDir); 201 NORMALIZE_3FV(h); 202 } 203 else { 204 h = light->_h_inf_norm; 205 } 206 207 n_dot_h = correction * DOT3(normal, h); 208 209 if (n_dot_h > 0.0F) { 210 GLfloat spec_coef = lookup_shininess(ctx, side, n_dot_h); 211 if (spec_coef > 1.0e-10F) { 212 spec_coef *= attenuation; 213 ACC_SCALE_SCALAR_3V( spec[side], spec_coef, 214 light->_MatSpecular[side]); 215 } 216 } 217 } /*loop over lights*/ 218 219 COPY_3V( Fcolor[j], sum[0] ); 220 COPY_3V( Fspec[j], spec[0] ); 221 Fcolor[j][3] = sumA[0]; 222 223#if IDX & LIGHT_TWOSIDE 224 COPY_3V( Bcolor[j], sum[1] ); 225 COPY_3V( Bspec[j], spec[1] ); 226 Bcolor[j][3] = sumA[1]; 227#endif 228 } 229} 230 231 232static void TAG(light_rgba)( struct gl_context *ctx, 233 struct vertex_buffer *VB, 234 struct tnl_pipeline_stage *stage, 235 GLvector4f *input ) 236{ 237 struct light_stage_data *store = LIGHT_STAGE_DATA(stage); 238 GLuint j; 239 240 GLfloat (*base)[3] = ctx->Light._BaseColor; 241 GLfloat sumA[2]; 242 243 const GLuint vstride = input->stride; 244 const GLfloat *vertex = (GLfloat *) input->data; 245 const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride; 246 const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data; 247 248 GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; 249#if IDX & LIGHT_TWOSIDE 250 GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; 251#endif 252 253 const GLuint nr = VB->Count; 254 255#ifdef TRACE 256 fprintf(stderr, "%s\n", __func__ ); 257#endif 258 259 VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0]; 260 sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; 261 262#if IDX & LIGHT_TWOSIDE 263 VB->BackfaceColorPtr = &store->LitColor[1]; 264 sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; 265#endif 266 267 store->LitColor[0].stride = 16; 268 store->LitColor[1].stride = 16; 269 270 for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) { 271 GLfloat sum[2][3]; 272 GLbitfield mask; 273 274#if IDX & LIGHT_MATERIAL 275 update_materials( ctx, store ); 276 sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; 277#if IDX & LIGHT_TWOSIDE 278 sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; 279#endif 280#endif 281 282 COPY_3V(sum[0], base[0]); 283 284#if IDX & LIGHT_TWOSIDE 285 COPY_3V(sum[1], base[1]); 286#endif 287 288 /* Add contribution from each enabled light source */ 289 mask = ctx->Light._EnabledLights; 290 while (mask) { 291 const int l = u_bit_scan(&mask); 292 struct gl_light *light = &ctx->Light.Light[l]; 293 struct gl_light_uniforms *lu = &ctx->Light.LightSource[l]; 294 GLfloat n_dot_h; 295 GLfloat correction; 296 GLint side; 297 GLfloat contrib[3]; 298 GLfloat attenuation; 299 GLfloat VP[3]; /* unit vector from vertex to light */ 300 GLfloat n_dot_VP; /* n dot VP */ 301 GLfloat *h; 302 303 /* compute VP and attenuation */ 304 if (!(light->_Flags & LIGHT_POSITIONAL)) { 305 /* directional light */ 306 COPY_3V(VP, light->_VP_inf_norm); 307 attenuation = light->_VP_inf_spot_attenuation; 308 } 309 else { 310 GLfloat d; /* distance from vertex to light */ 311 312 SUB_3V(VP, light->_Position, vertex); 313 314 d = (GLfloat) LEN_3FV( VP ); 315 316 if (d > 1e-6F) { 317 GLfloat invd = 1.0F / d; 318 SELF_SCALE_SCALAR_3V(VP, invd); 319 } 320 321 attenuation = 1.0F / (lu->ConstantAttenuation + d * 322 (lu->LinearAttenuation + d * 323 lu->QuadraticAttenuation)); 324 325 /* spotlight attenuation */ 326 if (light->_Flags & LIGHT_SPOT) { 327 GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection); 328 329 if (PV_dot_dir<lu->_CosCutoff) { 330 continue; /* this light makes no contribution */ 331 } 332 else { 333 GLfloat spot = powf(PV_dot_dir, lu->SpotExponent); 334 attenuation *= spot; 335 } 336 } 337 } 338 339 if (attenuation < 1e-3F) 340 continue; /* this light makes no contribution */ 341 342 /* Compute dot product or normal and vector from V to light pos */ 343 n_dot_VP = DOT3( normal, VP ); 344 345 /* which side are we lighting? */ 346 if (n_dot_VP < 0.0F) { 347 ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]); 348#if IDX & LIGHT_TWOSIDE 349 side = 1; 350 correction = -1; 351 n_dot_VP = -n_dot_VP; 352#else 353 continue; 354#endif 355 } 356 else { 357#if IDX & LIGHT_TWOSIDE 358 ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]); 359#endif 360 side = 0; 361 correction = 1; 362 } 363 364 COPY_3V(contrib, light->_MatAmbient[side]); 365 366 /* diffuse term */ 367 ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]); 368 369 /* specular term - cannibalize VP... */ 370 { 371 if (ctx->Light.Model.LocalViewer) { 372 GLfloat v[3]; 373 COPY_3V(v, vertex); 374 NORMALIZE_3FV(v); 375 SUB_3V(VP, VP, v); /* h = VP + VPe */ 376 h = VP; 377 NORMALIZE_3FV(h); 378 } 379 else if (light->_Flags & LIGHT_POSITIONAL) { 380 h = VP; 381 ACC_3V(h, ctx->_EyeZDir); 382 NORMALIZE_3FV(h); 383 } 384 else { 385 h = light->_h_inf_norm; 386 } 387 388 n_dot_h = correction * DOT3(normal, h); 389 390 if (n_dot_h > 0.0F) { 391 GLfloat spec_coef = lookup_shininess(ctx, side, n_dot_h); 392 ACC_SCALE_SCALAR_3V( contrib, spec_coef, 393 light->_MatSpecular[side]); 394 } 395 } 396 397 ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib ); 398 } 399 400 COPY_3V( Fcolor[j], sum[0] ); 401 Fcolor[j][3] = sumA[0]; 402 403#if IDX & LIGHT_TWOSIDE 404 COPY_3V( Bcolor[j], sum[1] ); 405 Bcolor[j][3] = sumA[1]; 406#endif 407 } 408} 409 410 411 412 413/* As below, but with just a single light. 414 */ 415static void TAG(light_fast_rgba_single)( struct gl_context *ctx, 416 struct vertex_buffer *VB, 417 struct tnl_pipeline_stage *stage, 418 GLvector4f *input ) 419 420{ 421 struct light_stage_data *store = LIGHT_STAGE_DATA(stage); 422 const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride; 423 const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data; 424 GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; 425#if IDX & LIGHT_TWOSIDE 426 GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; 427#endif 428 const struct gl_light *light = 429 &ctx->Light.Light[ffs(ctx->Light._EnabledLights) - 1]; 430 GLuint j = 0; 431 GLfloat base[2][4]; 432#if IDX & LIGHT_MATERIAL 433 const GLuint nr = VB->Count; 434#else 435 const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count; 436#endif 437 438#ifdef TRACE 439 fprintf(stderr, "%s\n", __func__ ); 440#endif 441 442 (void) input; /* doesn't refer to Eye or Obj */ 443 444 VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0]; 445#if IDX & LIGHT_TWOSIDE 446 VB->BackfaceColorPtr = &store->LitColor[1]; 447#endif 448 449 if (nr > 1) { 450 store->LitColor[0].stride = 16; 451 store->LitColor[1].stride = 16; 452 } 453 else { 454 store->LitColor[0].stride = 0; 455 store->LitColor[1].stride = 0; 456 } 457 458 for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) { 459 460 GLfloat n_dot_VP; 461 462#if IDX & LIGHT_MATERIAL 463 update_materials( ctx, store ); 464#endif 465 466 /* No attenuation, so incoporate _MatAmbient into base color. 467 */ 468#if !(IDX & LIGHT_MATERIAL) 469 if ( j == 0 ) 470#endif 471 { 472 COPY_3V(base[0], light->_MatAmbient[0]); 473 ACC_3V(base[0], ctx->Light._BaseColor[0] ); 474 base[0][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; 475 476#if IDX & LIGHT_TWOSIDE 477 COPY_3V(base[1], light->_MatAmbient[1]); 478 ACC_3V(base[1], ctx->Light._BaseColor[1]); 479 base[1][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; 480#endif 481 } 482 483 n_dot_VP = DOT3(normal, light->_VP_inf_norm); 484 485 if (n_dot_VP < 0.0F) { 486#if IDX & LIGHT_TWOSIDE 487 GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm); 488 GLfloat sum[3]; 489 COPY_3V(sum, base[1]); 490 ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]); 491 if (n_dot_h > 0.0F) { 492 GLfloat spec = lookup_shininess(ctx, 1, n_dot_h); 493 ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]); 494 } 495 COPY_3V(Bcolor[j], sum ); 496 Bcolor[j][3] = base[1][3]; 497#endif 498 COPY_4FV(Fcolor[j], base[0]); 499 } 500 else { 501 GLfloat n_dot_h = DOT3(normal, light->_h_inf_norm); 502 GLfloat sum[3]; 503 COPY_3V(sum, base[0]); 504 ACC_SCALE_SCALAR_3V(sum, n_dot_VP, light->_MatDiffuse[0]); 505 if (n_dot_h > 0.0F) { 506 GLfloat spec = lookup_shininess(ctx, 0, n_dot_h); 507 ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]); 508 } 509 COPY_3V(Fcolor[j], sum ); 510 Fcolor[j][3] = base[0][3]; 511#if IDX & LIGHT_TWOSIDE 512 COPY_4FV(Bcolor[j], base[1]); 513#endif 514 } 515 } 516} 517 518 519/* Light infinite lights 520 */ 521static void TAG(light_fast_rgba)( struct gl_context *ctx, 522 struct vertex_buffer *VB, 523 struct tnl_pipeline_stage *stage, 524 GLvector4f *input ) 525{ 526 struct light_stage_data *store = LIGHT_STAGE_DATA(stage); 527 GLfloat sumA[2]; 528 const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride; 529 const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data; 530 GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data; 531#if IDX & LIGHT_TWOSIDE 532 GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; 533#endif 534 GLuint j = 0; 535#if IDX & LIGHT_MATERIAL 536 const GLuint nr = VB->Count; 537#else 538 const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count; 539#endif 540 541#ifdef TRACE 542 fprintf(stderr, "%s %d\n", __func__, nr ); 543#endif 544 545 (void) input; 546 547 sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; 548 sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; 549 550 VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0]; 551#if IDX & LIGHT_TWOSIDE 552 VB->BackfaceColorPtr = &store->LitColor[1]; 553#endif 554 555 if (nr > 1) { 556 store->LitColor[0].stride = 16; 557 store->LitColor[1].stride = 16; 558 } 559 else { 560 store->LitColor[0].stride = 0; 561 store->LitColor[1].stride = 0; 562 } 563 564 for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) { 565 566 GLfloat sum[2][3]; 567 GLbitfield mask; 568 569#if IDX & LIGHT_MATERIAL 570 update_materials( ctx, store ); 571 572 sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; 573#if IDX & LIGHT_TWOSIDE 574 sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; 575#endif 576#endif 577 578 579 COPY_3V(sum[0], ctx->Light._BaseColor[0]); 580#if IDX & LIGHT_TWOSIDE 581 COPY_3V(sum[1], ctx->Light._BaseColor[1]); 582#endif 583 584 mask = ctx->Light._EnabledLights; 585 while (mask) { 586 const int l = u_bit_scan(&mask); 587 const struct gl_light *light = &ctx->Light.Light[l]; 588 GLfloat n_dot_h, n_dot_VP, spec; 589 590 ACC_3V(sum[0], light->_MatAmbient[0]); 591#if IDX & LIGHT_TWOSIDE 592 ACC_3V(sum[1], light->_MatAmbient[1]); 593#endif 594 595 n_dot_VP = DOT3(normal, light->_VP_inf_norm); 596 597 if (n_dot_VP > 0.0F) { 598 ACC_SCALE_SCALAR_3V(sum[0], n_dot_VP, light->_MatDiffuse[0]); 599 n_dot_h = DOT3(normal, light->_h_inf_norm); 600 if (n_dot_h > 0.0F) { 601 spec = lookup_shininess(ctx, 0, n_dot_h); 602 ACC_SCALE_SCALAR_3V( sum[0], spec, light->_MatSpecular[0]); 603 } 604 } 605#if IDX & LIGHT_TWOSIDE 606 else { 607 ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]); 608 n_dot_h = -DOT3(normal, light->_h_inf_norm); 609 if (n_dot_h > 0.0F) { 610 spec = lookup_shininess(ctx, 1, n_dot_h); 611 ACC_SCALE_SCALAR_3V( sum[1], spec, light->_MatSpecular[1]); 612 } 613 } 614#endif 615 } 616 617 COPY_3V( Fcolor[j], sum[0] ); 618 Fcolor[j][3] = sumA[0]; 619 620#if IDX & LIGHT_TWOSIDE 621 COPY_3V( Bcolor[j], sum[1] ); 622 Bcolor[j][3] = sumA[1]; 623#endif 624 } 625} 626 627 628 629 630static void TAG(init_light_tab)( void ) 631{ 632 _tnl_light_tab[IDX] = TAG(light_rgba); 633 _tnl_light_fast_tab[IDX] = TAG(light_fast_rgba); 634 _tnl_light_fast_single_tab[IDX] = TAG(light_fast_rgba_single); 635 _tnl_light_spec_tab[IDX] = TAG(light_rgba_spec); 636} 637 638 639#undef TAG 640#undef IDX 641#undef NR_SIDES 642