st/mesa: factor ucp-lowering logic into helper
[mesa.git] / src / mesa / tnl / t_vb_lighttmp.h
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 */
46 static 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 GLfloat n_dot_h;
114 GLfloat correction;
115 GLint side;
116 GLfloat contrib[3];
117 GLfloat attenuation;
118 GLfloat VP[3]; /* unit vector from vertex to light */
119 GLfloat n_dot_VP; /* n dot VP */
120 GLfloat *h;
121
122 /* compute VP and attenuation */
123 if (!(light->_Flags & LIGHT_POSITIONAL)) {
124 /* directional light */
125 COPY_3V(VP, light->_VP_inf_norm);
126 attenuation = light->_VP_inf_spot_attenuation;
127 }
128 else {
129 GLfloat d; /* distance from vertex to light */
130
131 SUB_3V(VP, light->_Position, vertex);
132
133 d = (GLfloat) LEN_3FV( VP );
134
135 if (d > 1e-6F) {
136 GLfloat invd = 1.0F / d;
137 SELF_SCALE_SCALAR_3V(VP, invd);
138 }
139
140 attenuation = 1.0F / (light->ConstantAttenuation + d *
141 (light->LinearAttenuation + d *
142 light->QuadraticAttenuation));
143
144 /* spotlight attenuation */
145 if (light->_Flags & LIGHT_SPOT) {
146 GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
147
148 if (PV_dot_dir<light->_CosCutoff) {
149 continue; /* this light makes no contribution */
150 }
151 else {
152 GLfloat spot = powf(PV_dot_dir, light->SpotExponent);
153 attenuation *= spot;
154 }
155 }
156 }
157
158 if (attenuation < 1e-3F)
159 continue; /* this light makes no contribution */
160
161 /* Compute dot product or normal and vector from V to light pos */
162 n_dot_VP = DOT3( normal, VP );
163
164 /* Which side gets the diffuse & specular terms? */
165 if (n_dot_VP < 0.0F) {
166 ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
167 #if IDX & LIGHT_TWOSIDE
168 side = 1;
169 correction = -1;
170 n_dot_VP = -n_dot_VP;
171 #else
172 continue;
173 #endif
174 }
175 else {
176 #if IDX & LIGHT_TWOSIDE
177 ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
178 #endif
179 side = 0;
180 correction = 1;
181 }
182
183 /* diffuse term */
184 COPY_3V(contrib, light->_MatAmbient[side]);
185 ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]);
186 ACC_SCALE_SCALAR_3V(sum[side], attenuation, contrib );
187
188 /* specular term - cannibalize VP... */
189 if (ctx->Light.Model.LocalViewer) {
190 GLfloat v[3];
191 COPY_3V(v, vertex);
192 NORMALIZE_3FV(v);
193 SUB_3V(VP, VP, v); /* h = VP + VPe */
194 h = VP;
195 NORMALIZE_3FV(h);
196 }
197 else if (light->_Flags & LIGHT_POSITIONAL) {
198 h = VP;
199 ACC_3V(h, ctx->_EyeZDir);
200 NORMALIZE_3FV(h);
201 }
202 else {
203 h = light->_h_inf_norm;
204 }
205
206 n_dot_h = correction * DOT3(normal, h);
207
208 if (n_dot_h > 0.0F) {
209 GLfloat spec_coef = lookup_shininess(ctx, side, n_dot_h);
210 if (spec_coef > 1.0e-10F) {
211 spec_coef *= attenuation;
212 ACC_SCALE_SCALAR_3V( spec[side], spec_coef,
213 light->_MatSpecular[side]);
214 }
215 }
216 } /*loop over lights*/
217
218 COPY_3V( Fcolor[j], sum[0] );
219 COPY_3V( Fspec[j], spec[0] );
220 Fcolor[j][3] = sumA[0];
221
222 #if IDX & LIGHT_TWOSIDE
223 COPY_3V( Bcolor[j], sum[1] );
224 COPY_3V( Bspec[j], spec[1] );
225 Bcolor[j][3] = sumA[1];
226 #endif
227 }
228 }
229
230
231 static void TAG(light_rgba)( struct gl_context *ctx,
232 struct vertex_buffer *VB,
233 struct tnl_pipeline_stage *stage,
234 GLvector4f *input )
235 {
236 struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
237 GLuint j;
238
239 GLfloat (*base)[3] = ctx->Light._BaseColor;
240 GLfloat sumA[2];
241
242 const GLuint vstride = input->stride;
243 const GLfloat *vertex = (GLfloat *) input->data;
244 const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
245 const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
246
247 GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
248 #if IDX & LIGHT_TWOSIDE
249 GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
250 #endif
251
252 const GLuint nr = VB->Count;
253
254 #ifdef TRACE
255 fprintf(stderr, "%s\n", __func__ );
256 #endif
257
258 VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
259 sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
260
261 #if IDX & LIGHT_TWOSIDE
262 VB->BackfaceColorPtr = &store->LitColor[1];
263 sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
264 #endif
265
266 store->LitColor[0].stride = 16;
267 store->LitColor[1].stride = 16;
268
269 for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
270 GLfloat sum[2][3];
271 GLbitfield mask;
272
273 #if IDX & LIGHT_MATERIAL
274 update_materials( ctx, store );
275 sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
276 #if IDX & LIGHT_TWOSIDE
277 sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
278 #endif
279 #endif
280
281 COPY_3V(sum[0], base[0]);
282
283 #if IDX & LIGHT_TWOSIDE
284 COPY_3V(sum[1], base[1]);
285 #endif
286
287 /* Add contribution from each enabled light source */
288 mask = ctx->Light._EnabledLights;
289 while (mask) {
290 const int l = u_bit_scan(&mask);
291 struct gl_light *light = &ctx->Light.Light[l];
292 GLfloat n_dot_h;
293 GLfloat correction;
294 GLint side;
295 GLfloat contrib[3];
296 GLfloat attenuation;
297 GLfloat VP[3]; /* unit vector from vertex to light */
298 GLfloat n_dot_VP; /* n dot VP */
299 GLfloat *h;
300
301 /* compute VP and attenuation */
302 if (!(light->_Flags & LIGHT_POSITIONAL)) {
303 /* directional light */
304 COPY_3V(VP, light->_VP_inf_norm);
305 attenuation = light->_VP_inf_spot_attenuation;
306 }
307 else {
308 GLfloat d; /* distance from vertex to light */
309
310 SUB_3V(VP, light->_Position, vertex);
311
312 d = (GLfloat) LEN_3FV( VP );
313
314 if (d > 1e-6F) {
315 GLfloat invd = 1.0F / d;
316 SELF_SCALE_SCALAR_3V(VP, invd);
317 }
318
319 attenuation = 1.0F / (light->ConstantAttenuation + d *
320 (light->LinearAttenuation + d *
321 light->QuadraticAttenuation));
322
323 /* spotlight attenuation */
324 if (light->_Flags & LIGHT_SPOT) {
325 GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
326
327 if (PV_dot_dir<light->_CosCutoff) {
328 continue; /* this light makes no contribution */
329 }
330 else {
331 GLfloat spot = powf(PV_dot_dir, light->SpotExponent);
332 attenuation *= spot;
333 }
334 }
335 }
336
337 if (attenuation < 1e-3F)
338 continue; /* this light makes no contribution */
339
340 /* Compute dot product or normal and vector from V to light pos */
341 n_dot_VP = DOT3( normal, VP );
342
343 /* which side are we lighting? */
344 if (n_dot_VP < 0.0F) {
345 ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
346 #if IDX & LIGHT_TWOSIDE
347 side = 1;
348 correction = -1;
349 n_dot_VP = -n_dot_VP;
350 #else
351 continue;
352 #endif
353 }
354 else {
355 #if IDX & LIGHT_TWOSIDE
356 ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
357 #endif
358 side = 0;
359 correction = 1;
360 }
361
362 COPY_3V(contrib, light->_MatAmbient[side]);
363
364 /* diffuse term */
365 ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]);
366
367 /* specular term - cannibalize VP... */
368 {
369 if (ctx->Light.Model.LocalViewer) {
370 GLfloat v[3];
371 COPY_3V(v, vertex);
372 NORMALIZE_3FV(v);
373 SUB_3V(VP, VP, v); /* h = VP + VPe */
374 h = VP;
375 NORMALIZE_3FV(h);
376 }
377 else if (light->_Flags & LIGHT_POSITIONAL) {
378 h = VP;
379 ACC_3V(h, ctx->_EyeZDir);
380 NORMALIZE_3FV(h);
381 }
382 else {
383 h = light->_h_inf_norm;
384 }
385
386 n_dot_h = correction * DOT3(normal, h);
387
388 if (n_dot_h > 0.0F) {
389 GLfloat spec_coef = lookup_shininess(ctx, side, n_dot_h);
390 ACC_SCALE_SCALAR_3V( contrib, spec_coef,
391 light->_MatSpecular[side]);
392 }
393 }
394
395 ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib );
396 }
397
398 COPY_3V( Fcolor[j], sum[0] );
399 Fcolor[j][3] = sumA[0];
400
401 #if IDX & LIGHT_TWOSIDE
402 COPY_3V( Bcolor[j], sum[1] );
403 Bcolor[j][3] = sumA[1];
404 #endif
405 }
406 }
407
408
409
410
411 /* As below, but with just a single light.
412 */
413 static void TAG(light_fast_rgba_single)( struct gl_context *ctx,
414 struct vertex_buffer *VB,
415 struct tnl_pipeline_stage *stage,
416 GLvector4f *input )
417
418 {
419 struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
420 const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
421 const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
422 GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
423 #if IDX & LIGHT_TWOSIDE
424 GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
425 #endif
426 const struct gl_light *light =
427 &ctx->Light.Light[ffs(ctx->Light._EnabledLights) - 1];
428 GLuint j = 0;
429 GLfloat base[2][4];
430 #if IDX & LIGHT_MATERIAL
431 const GLuint nr = VB->Count;
432 #else
433 const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count;
434 #endif
435
436 #ifdef TRACE
437 fprintf(stderr, "%s\n", __func__ );
438 #endif
439
440 (void) input; /* doesn't refer to Eye or Obj */
441
442 VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
443 #if IDX & LIGHT_TWOSIDE
444 VB->BackfaceColorPtr = &store->LitColor[1];
445 #endif
446
447 if (nr > 1) {
448 store->LitColor[0].stride = 16;
449 store->LitColor[1].stride = 16;
450 }
451 else {
452 store->LitColor[0].stride = 0;
453 store->LitColor[1].stride = 0;
454 }
455
456 for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
457
458 GLfloat n_dot_VP;
459
460 #if IDX & LIGHT_MATERIAL
461 update_materials( ctx, store );
462 #endif
463
464 /* No attenuation, so incoporate _MatAmbient into base color.
465 */
466 #if !(IDX & LIGHT_MATERIAL)
467 if ( j == 0 )
468 #endif
469 {
470 COPY_3V(base[0], light->_MatAmbient[0]);
471 ACC_3V(base[0], ctx->Light._BaseColor[0] );
472 base[0][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
473
474 #if IDX & LIGHT_TWOSIDE
475 COPY_3V(base[1], light->_MatAmbient[1]);
476 ACC_3V(base[1], ctx->Light._BaseColor[1]);
477 base[1][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
478 #endif
479 }
480
481 n_dot_VP = DOT3(normal, light->_VP_inf_norm);
482
483 if (n_dot_VP < 0.0F) {
484 #if IDX & LIGHT_TWOSIDE
485 GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm);
486 GLfloat sum[3];
487 COPY_3V(sum, base[1]);
488 ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]);
489 if (n_dot_h > 0.0F) {
490 GLfloat spec = lookup_shininess(ctx, 1, n_dot_h);
491 ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]);
492 }
493 COPY_3V(Bcolor[j], sum );
494 Bcolor[j][3] = base[1][3];
495 #endif
496 COPY_4FV(Fcolor[j], base[0]);
497 }
498 else {
499 GLfloat n_dot_h = DOT3(normal, light->_h_inf_norm);
500 GLfloat sum[3];
501 COPY_3V(sum, base[0]);
502 ACC_SCALE_SCALAR_3V(sum, n_dot_VP, light->_MatDiffuse[0]);
503 if (n_dot_h > 0.0F) {
504 GLfloat spec = lookup_shininess(ctx, 0, n_dot_h);
505 ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]);
506 }
507 COPY_3V(Fcolor[j], sum );
508 Fcolor[j][3] = base[0][3];
509 #if IDX & LIGHT_TWOSIDE
510 COPY_4FV(Bcolor[j], base[1]);
511 #endif
512 }
513 }
514 }
515
516
517 /* Light infinite lights
518 */
519 static void TAG(light_fast_rgba)( struct gl_context *ctx,
520 struct vertex_buffer *VB,
521 struct tnl_pipeline_stage *stage,
522 GLvector4f *input )
523 {
524 struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
525 GLfloat sumA[2];
526 const GLuint nstride = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
527 const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->data;
528 GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
529 #if IDX & LIGHT_TWOSIDE
530 GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
531 #endif
532 GLuint j = 0;
533 #if IDX & LIGHT_MATERIAL
534 const GLuint nr = VB->Count;
535 #else
536 const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count;
537 #endif
538
539 #ifdef TRACE
540 fprintf(stderr, "%s %d\n", __func__, nr );
541 #endif
542
543 (void) input;
544
545 sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
546 sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
547
548 VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
549 #if IDX & LIGHT_TWOSIDE
550 VB->BackfaceColorPtr = &store->LitColor[1];
551 #endif
552
553 if (nr > 1) {
554 store->LitColor[0].stride = 16;
555 store->LitColor[1].stride = 16;
556 }
557 else {
558 store->LitColor[0].stride = 0;
559 store->LitColor[1].stride = 0;
560 }
561
562 for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
563
564 GLfloat sum[2][3];
565 GLbitfield mask;
566
567 #if IDX & LIGHT_MATERIAL
568 update_materials( ctx, store );
569
570 sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
571 #if IDX & LIGHT_TWOSIDE
572 sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
573 #endif
574 #endif
575
576
577 COPY_3V(sum[0], ctx->Light._BaseColor[0]);
578 #if IDX & LIGHT_TWOSIDE
579 COPY_3V(sum[1], ctx->Light._BaseColor[1]);
580 #endif
581
582 mask = ctx->Light._EnabledLights;
583 while (mask) {
584 const int l = u_bit_scan(&mask);
585 const struct gl_light *light = &ctx->Light.Light[l];
586 GLfloat n_dot_h, n_dot_VP, spec;
587
588 ACC_3V(sum[0], light->_MatAmbient[0]);
589 #if IDX & LIGHT_TWOSIDE
590 ACC_3V(sum[1], light->_MatAmbient[1]);
591 #endif
592
593 n_dot_VP = DOT3(normal, light->_VP_inf_norm);
594
595 if (n_dot_VP > 0.0F) {
596 ACC_SCALE_SCALAR_3V(sum[0], n_dot_VP, light->_MatDiffuse[0]);
597 n_dot_h = DOT3(normal, light->_h_inf_norm);
598 if (n_dot_h > 0.0F) {
599 spec = lookup_shininess(ctx, 0, n_dot_h);
600 ACC_SCALE_SCALAR_3V( sum[0], spec, light->_MatSpecular[0]);
601 }
602 }
603 #if IDX & LIGHT_TWOSIDE
604 else {
605 ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]);
606 n_dot_h = -DOT3(normal, light->_h_inf_norm);
607 if (n_dot_h > 0.0F) {
608 spec = lookup_shininess(ctx, 1, n_dot_h);
609 ACC_SCALE_SCALAR_3V( sum[1], spec, light->_MatSpecular[1]);
610 }
611 }
612 #endif
613 }
614
615 COPY_3V( Fcolor[j], sum[0] );
616 Fcolor[j][3] = sumA[0];
617
618 #if IDX & LIGHT_TWOSIDE
619 COPY_3V( Bcolor[j], sum[1] );
620 Bcolor[j][3] = sumA[1];
621 #endif
622 }
623 }
624
625
626
627
628 static void TAG(init_light_tab)( void )
629 {
630 _tnl_light_tab[IDX] = TAG(light_rgba);
631 _tnl_light_fast_tab[IDX] = TAG(light_fast_rgba);
632 _tnl_light_fast_single_tab[IDX] = TAG(light_fast_rgba_single);
633 _tnl_light_spec_tab[IDX] = TAG(light_rgba_spec);
634 }
635
636
637 #undef TAG
638 #undef IDX
639 #undef NR_SIDES