comparison Renderer/Engine/spe/DrawSpan.cc @ 792:f2497e0ecd7c

add light switch
author yutaka@localhost.localdomain
date Sun, 02 May 2010 04:17:34 +0900
parents 4455e7b0caf3
children c260205d3185
comparison
equal deleted inserted replaced
791:ab12634e6c51 792:f2497e0ecd7c
224 #else 224 #else
225 int alpha = color & 0xff000000; 225 int alpha = color & 0xff000000;
226 #endif 226 #endif
227 /*完全に透けているか判断*/ 227 /*完全に透けているか判断*/
228 int flag = (alpha != 0); 228 int flag = (alpha != 0);
229 229 int *light_sys_switch = (int*)smanager->global_get(LightSysSwitch);
230 color = infinity_light_calc(color,normal_x,normal_y,normal_z, 230
231 smanager,localx,localy,zpos, 231 if ( *light_sys_switch == 1) {
232 world_x,world_y,world_z); 232 color = infinity_light_calc(color,normal_x,normal_y,normal_z,
233 smanager,localx,localy,zpos,
234 world_x,world_y,world_z);
235 }
233 236
234 g->zRow[localx + (rangex*localy)] = zpos*flag + g->zRow[localx + (rangex*localy)]*(1-flag); 237 g->zRow[localx + (rangex*localy)] = zpos*flag + g->zRow[localx + (rangex*localy)]*(1-flag);
235 int *point = &g->linebuf[localy][localx] ; 238 int *point = &g->linebuf[localy][localx] ;
236 *point = color*flag + *point *(1-flag); 239 *point = color*flag + *point *(1-flag);
237 240
451 normalize(normal_vector, normal_vector); 454 normalize(normal_vector, normal_vector);
452 455
453 vector float vtmp_rgb __attribute__((aligned(16))) = {0,0,0,0}; 456 vector float vtmp_rgb __attribute__((aligned(16))) = {0,0,0,0};
454 457
455 int light_num = 4; 458 int light_num = 4;
459 int *light_switch = (int*)smanager->global_get(LightSwitch);
456 460
457 for (int i = 0; i < light_num; i++) { 461 for (int i = 0; i < light_num; i++) {
458 462
459 light_vector = spu_sub(v_world[i],light_xyz[i]); 463 if (light_switch[i] == 1) {
460 normalize(light_vector, light_vector); 464 light_vector = spu_sub(v_world[i],light_xyz[i]);
461 inner_product = innerProduct1(normal_vector,light_vector); 465 normalize(light_vector, light_vector);
462 v_inner = spu_splats(inner_product); 466 inner_product = innerProduct1(normal_vector,light_vector);
463 vtmp_rgb = spu_madd(v_rgb,v_inner,vtmp_rgb); 467 v_inner = spu_splats(inner_product);
468 vtmp_rgb = spu_madd(v_rgb,v_inner,vtmp_rgb);
469 }
464 470
465 } 471 }
466 472
467 vector unsigned int v_flag __attribute__((aligned(16))); 473 vector unsigned int v_flag __attribute__((aligned(16)));
468 vector float max_rgb __attribute__((aligned(16))) = (vector float)spu_splats((float)255.0f); 474 vector float max_rgb __attribute__((aligned(16))) = (vector float)spu_splats((float)255.0f);