00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #include "vp_global.h"
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 #define USE_SHADOW_BUFFER
00069
00070
00071
00072
00073
00074 #undef UNROLL_RUN_LOOP
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 #define MULTIPLE_MATERIALS
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 #define RGB
00128
00129
00130
00131
00132
00133
00134
00135 #define RLEVOLUME
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 #undef INDEX_VOLUME
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 #define ALL_ZERO 0
00162 #define TOP_NONZERO 1
00163 #define BOT_NONZERO 2
00164 #define ALL_NONZERO 3
00165
00166
00167 #define ALL_ZERO__ALL_ZERO ((ALL_ZERO << 2) | ALL_ZERO)
00168 #define ALL_ZERO__TOP_NONZERO ((ALL_ZERO << 2) | TOP_NONZERO)
00169 #define ALL_ZERO__BOT_NONZERO ((ALL_ZERO << 2) | BOT_NONZERO)
00170 #define ALL_ZERO__ALL_NONZERO ((ALL_ZERO << 2) | ALL_NONZERO)
00171 #define TOP_NONZERO__ALL_ZERO ((TOP_NONZERO << 2) | ALL_ZERO)
00172 #define TOP_NONZERO__TOP_NONZERO ((TOP_NONZERO << 2) | TOP_NONZERO)
00173 #define TOP_NONZERO__BOT_NONZERO ((TOP_NONZERO << 2) | BOT_NONZERO)
00174 #define TOP_NONZERO__ALL_NONZERO ((TOP_NONZERO << 2) | ALL_NONZERO)
00175 #define BOT_NONZERO__ALL_ZERO ((BOT_NONZERO << 2) | ALL_ZERO)
00176 #define BOT_NONZERO__TOP_NONZERO ((BOT_NONZERO << 2) | TOP_NONZERO)
00177 #define BOT_NONZERO__BOT_NONZERO ((BOT_NONZERO << 2) | BOT_NONZERO)
00178 #define BOT_NONZERO__ALL_NONZERO ((BOT_NONZERO << 2) | ALL_NONZERO)
00179 #define ALL_NONZERO__ALL_ZERO ((ALL_NONZERO << 2) | ALL_ZERO)
00180 #define ALL_NONZERO__TOP_NONZERO ((ALL_NONZERO << 2) | TOP_NONZERO)
00181 #define ALL_NONZERO__BOT_NONZERO ((ALL_NONZERO << 2) | BOT_NONZERO)
00182 #define ALL_NONZERO__ALL_NONZERO ((ALL_NONZERO << 2) | ALL_NONZERO)
00183
00184 #ifdef SKIP_ERT
00185 #define PIXEL_IS_OPAQUE(ipixel) 0
00186 #else
00187 #define PIXEL_IS_OPAQUE(ipixel) ((ipixel)->lnk != 0)
00188 #endif
00189
00190 #ifdef STATISTICS
00191 extern int vpResampleCount;
00192 extern int vpCompositeCount;
00193 extern int vpERTSkipCount;
00194 extern int vpERTSkipAgainCount;
00195 extern int vpERTUpdateCount;
00196 extern int vpSpecialZeroSkipCount;
00197 extern int vpRunFragmentCount;
00198 #define COUNT_RESAMPLE vpResampleCount++
00199 #define COUNT_COMPOSITE vpCompositeCount++
00200 #define COUNT_ERT_SKIP vpERTSkipCount++
00201 #define COUNT_ERT_SKIP_AGAIN vpERTSkipAgainCount++
00202 #define COUNT_ERT_UPDATE vpERTUpdateCount++
00203 #define COUNT_SPECIAL_ZERO_SKIP vpSpecialZeroSkipCount++
00204 #define COUNT_RUN_FRAGMENT vpRunFragmentCount++
00205 #else
00206 #define COUNT_RESAMPLE
00207 #define COUNT_COMPOSITE
00208 #define COUNT_ERT_SKIP
00209 #define COUNT_ERT_SKIP_AGAIN
00210 #define COUNT_ERT_UPDATE
00211 #define COUNT_SPECIAL_ZERO_SKIP
00212 #define COUNT_RUN_FRAGMENT
00213 #endif
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223 void
00224 VPCompAC3NS (vpc, icount, jcount, k, slice_depth_cueing_dbl, intimage,
00225 weightTLdbl, weightBLdbl, weightTRdbl, weightBRdbl,
00226 run_lengths, voxel_data , shadow_buffer)
00227 vpContext *vpc;
00228 int icount;
00229 int jcount;
00230 int k;
00231 double slice_depth_cueing_dbl;
00232 RGBIntPixel *intimage;
00233 double weightTLdbl;
00234 double weightBLdbl;
00235 double weightTRdbl;
00236 double weightBRdbl;
00237
00238 unsigned char *run_lengths;
00239 void *voxel_data;
00240 GrayIntPixel *shadow_buffer;
00241 {
00242 int i, j;
00243 RGBIntPixel *ipixel;
00244 RGBIntPixel *ipixel2;
00245 int update_interval;
00246 float iopc;
00247 float iopc_inv;
00248 float acc_opc;
00249 float top_opc, bot_opc;
00250 #ifdef NO_REUSE_VOXEL
00251 #define voxels_loaded 0
00252 #define CLEAR_VOXELS_LOADED
00253 #define SET_VOXELS_LOADED
00254 #else
00255 int voxels_loaded;
00256
00257 #define CLEAR_VOXELS_LOADED voxels_loaded = 0
00258 #define SET_VOXELS_LOADED voxels_loaded = 1
00259 #endif
00260 float wgtTL, wgtBL,
00261 wgtTR, wgtBR;
00262
00263
00264 unsigned char *topRLElen;
00265 unsigned char *botRLElen;
00266 char *topRLEdata;
00267 char *botRLEdata;
00268 int toprun_count;
00269 int botrun_count;
00270 int last_run_state;
00271 int run_state;
00272 int final_run_state;
00273 float min_opacity;
00274 float max_opacity;
00275 float slice_depth_cueing;
00276 float *opac_correct;
00277 int ert_skip_count;
00278 int intermediate_width;
00279 int count;
00280 float *shade_table;
00281 int norm_offset;
00282 int shade_index;
00283 float shade_factor;
00284
00285
00286 #ifdef MULTIPLE_MATERIALS
00287 float *weight_table;
00288 int wgt_offset;
00289 int weight_index;
00290 int m, num_materials;
00291 float weight1, weight2;
00292 #endif
00293
00294 #ifdef GRAYSCALE
00295 float acc_clr;
00296 float top_clr, bot_clr;
00297 #endif
00298
00299 #ifdef RGB
00300 float acc_rclr;
00301 float acc_gclr;
00302 float acc_bclr;
00303 float top_rclr;
00304 float bot_rclr;
00305 float top_gclr;
00306 float bot_gclr;
00307 float top_bclr;
00308 float bot_bclr;
00309 #endif
00310
00311 #ifdef RLEVOLUME
00312 int voxel_istride;
00313 #endif
00314
00315 #ifdef RAWVOLUME
00316 int use_octree;
00317 MMOctreeLevel level_stack[VP_MAX_OCTREE_LEVELS];
00318
00319 int scans_left;
00320 int best_view_axis;
00321 unsigned char runlen_buf1[VP_MAX_VOLUME_DIM];
00322 unsigned char runlen_buf2[VP_MAX_VOLUME_DIM];
00323 unsigned char *top_len_base;
00324 unsigned char *bot_len_base;
00325 int opac_param;
00326 float opacity;
00327 int opacity_int;
00328 int param0_offset;
00329 int param0_size;
00330 float *param0_table;
00331 int param1_offset;
00332 int param1_size;
00333 float *param1_table;
00334 int param2_offset;
00335 int param2_size;
00336 float *param2_table;
00337 #endif
00338
00339 #ifdef INDEX_VOLUME
00340 unsigned char *scanline_topRLElen;
00341 unsigned char *scanline_botRLElen;
00342 char *scanline_topRLEdata;
00343 char *scanline_botRLEdata;
00344 VoxelLocation *top_voxel_index;
00345 VoxelLocation *bot_voxel_index;
00346 VoxelLocation *vindex;
00347 int next_i;
00348 int next_scan;
00349 #endif
00350
00351 #ifdef CALLBACK
00352
00353 #ifdef GRAYSCALE
00354 void (*shade_func) ANSI_ARGS((void *, float *, void *));
00355 #endif
00356 #ifdef RGB
00357 void (*shade_func) ANSI_ARGS((void *, float *, float *, float *, void *));
00358 #endif
00359 void *client_data;
00360 #endif
00361
00362 #ifdef USE_SHADOW_BUFFER
00363 float *shadow_table;
00364 int shadow_width;
00365 GrayIntPixel *shadow_pixel;
00366 #ifdef GRAYSCALE
00367 float top_sclr, bot_sclr;
00368 #endif
00369 #ifdef RGB
00370 float top_rsclr;
00371 float bot_rsclr;
00372 float top_gsclr;
00373 float bot_gsclr;
00374 float top_bsclr;
00375 float bot_bsclr;
00376 #endif
00377 #endif
00378
00379 #ifdef DEBUG
00380 float trace_opcTL, trace_opcBL, trace_opcTR, trace_opcBR;
00381 float trace_rsclrTL, trace_rsclrBL, trace_rsclrTR, trace_rsclrBR;
00382 float trace_rclrTL, trace_rclrBL, trace_rclrTR, trace_rclrBR;
00383 float trace_gclrTL, trace_gclrBL, trace_gclrTR, trace_gclrBR;
00384 float trace_bclrTL, trace_bclrBL, trace_bclrTR, trace_bclrBR;
00385 RGBIntPixel *trace_pixel_ptr;
00386
00387 #ifdef COMPUTE_SHADOW_BUFFER
00388 int slice_u_int, shadow_slice_u_int;
00389 int slice_v_int, shadow_slice_v_int;
00390 #endif
00391 #endif
00392
00393 DECLARE_HIRES_TIME(t0);
00394 DECLARE_HIRES_TIME(t1);
00395
00396
00397
00398
00399
00400 GET_HIRES_TIME(vpc, t0);
00401
00402 wgtTL = weightTLdbl;
00403 wgtBL = weightBLdbl;
00404 wgtTR = weightTRdbl;
00405 wgtBR = weightBRdbl;
00406 slice_depth_cueing = slice_depth_cueing_dbl;
00407 min_opacity = vpc->min_opacity;
00408 max_opacity = vpc->max_opacity;
00409 #ifdef USE_SHADOW_BUFFER
00410 opac_correct = vpc->shadow_opac_correct;
00411 #else
00412 opac_correct = vpc->affine_opac_correct;
00413 #endif
00414 #ifdef COMPUTE_SHADOW_BUFFER
00415 intermediate_width = vpc->shadow_width;
00416 #else
00417 intermediate_width = vpc->intermediate_width;
00418 #endif
00419 #ifdef USE_SHADOW_BUFFER
00420 shadow_table = vpc->shadow_color_table;
00421 shadow_width = vpc->shadow_width;
00422 shadow_pixel = shadow_buffer;
00423 #endif
00424 ipixel = intimage;
00425 shade_table = vpc->shade_color_table;
00426 norm_offset = vpc->field_offset[vpc->color_field];
00427
00428 #ifdef MULTIPLE_MATERIALS
00429 weight_table = vpc->shade_weight_table;
00430 wgt_offset = vpc->field_offset[vpc->weight_field];
00431 num_materials = vpc->num_materials;
00432 #endif
00433
00434 #ifdef RLEVOLUME
00435 topRLEdata = voxel_data;
00436 botRLEdata = voxel_data;
00437 topRLElen = run_lengths;
00438 botRLElen = run_lengths;
00439 voxel_istride = vpc->rle_bytes_per_voxel;
00440 #endif
00441
00442 #ifdef RAWVOLUME
00443 ASSERT(vpc->num_clsfy_params > 0);
00444 ASSERT(vpc->num_clsfy_params < 3);
00445 param0_offset = vpc->field_offset[vpc->param_field[0]];
00446 param0_size = vpc->field_size[vpc->param_field[0]];
00447 param0_table = vpc->clsfy_table[0];
00448 if (vpc->num_clsfy_params > 1) {
00449 param1_offset = vpc->field_offset[vpc->param_field[1]];
00450 param1_size = vpc->field_size[vpc->param_field[1]];
00451 param1_table = vpc->clsfy_table[1];
00452 } else {
00453 param1_offset = 0;
00454 param1_size = 0;
00455 param1_table = NULL;
00456 }
00457 if (vpc->num_clsfy_params > 2) {
00458 param2_offset = vpc->field_offset[vpc->param_field[2]];
00459 param2_size = vpc->field_size[vpc->param_field[2]];
00460 param2_table = vpc->clsfy_table[2];
00461 } else {
00462 param2_offset = 0;
00463 param2_size = 0;
00464 param2_table = NULL;
00465 }
00466 if (vpc->mm_octree == NULL) {
00467 use_octree = 0;
00468 } else {
00469 use_octree = 1;
00470 best_view_axis = vpc->best_view_axis;
00471 VPInitOctreeLevelStack(vpc, level_stack, best_view_axis, k);
00472 scans_left = 0;
00473 bot_len_base = runlen_buf1;
00474 }
00475 #endif
00476
00477 #ifdef CALLBACK
00478 shade_func = vpc->shade_func;
00479 client_data = vpc->client_data;
00480 ASSERT(shade_func != NULL);
00481 #endif
00482
00483 #ifdef DEBUG
00484 trace_pixel_ptr = 0;
00485 if (vpc->trace_u >= 0 && vpc->trace_v >= 0) {
00486 #ifdef GRAYSCALE
00487 trace_pixel_ptr = &vpc->int_image.gray_intim[vpc->trace_u +
00488 vpc->trace_v*vpc->intermediate_width];
00489 #endif
00490 #ifdef RGB
00491 trace_pixel_ptr = &vpc->int_image.rgb_intim[vpc->trace_u +
00492 vpc->trace_v*vpc->intermediate_width];
00493 #endif
00494 #ifdef COMPUTE_SHADOW_BUFFER
00495 slice_u_int = (int)ceil(vpc->shear_i * vpc->trace_shadow_k +
00496 vpc->trans_i) - 1;
00497 shadow_slice_u_int = (int)ceil(vpc->shadow_shear_i *
00498 vpc->trace_shadow_k + vpc->shadow_trans_i) - 1;
00499 slice_v_int = (int)ceil(vpc->shear_j * vpc->trace_shadow_k
00500 + vpc->trans_j) - 1;
00501 shadow_slice_v_int = (int)ceil(vpc->shadow_shear_j *
00502 vpc->trace_shadow_k + vpc->shadow_trans_j) - 1;
00503 trace_pixel_ptr = &vpc->shadow_buffer[vpc->trace_u +
00504 shadow_slice_u_int - slice_u_int +
00505 (vpc->trace_v + shadow_slice_v_int -
00506 slice_v_int)*vpc->shadow_width];
00507 #endif
00508 }
00509 #endif
00510
00511
00512
00513
00514
00515 for (j = 0; j <= jcount; j++) {
00516
00517
00518
00519
00520
00521 i = icount;
00522 CLEAR_VOXELS_LOADED;
00523 last_run_state = ALL_ZERO;
00524
00525 #ifdef RAWVOLUME
00526 botRLEdata = (char *)voxel_data + j*voxel_jstride;
00527 topRLEdata = botRLEdata - voxel_jstride;
00528 if (!use_octree) {
00529 if (j == 0) {
00530 run_state = BOT_NONZERO;
00531 toprun_count = icount+2;
00532 botrun_count = icount;
00533 } else if (j == jcount) {
00534 run_state = TOP_NONZERO;
00535 toprun_count = icount;
00536 botrun_count = icount+2;
00537 } else {
00538 run_state = ALL_NONZERO;
00539 toprun_count = icount;
00540 botrun_count = icount;
00541 }
00542 } else
00543 #endif
00544 if (j == 0) {
00545 run_state = BOT_NONZERO;
00546 toprun_count = icount+2;
00547 botrun_count = 0;
00548 } else if (j == jcount) {
00549 run_state = TOP_NONZERO;
00550 toprun_count = 0;
00551 botrun_count = icount+2;
00552 } else {
00553 run_state = ALL_NONZERO;
00554 toprun_count = 0;
00555 botrun_count = 0;
00556 }
00557
00558 #ifdef INDEX_VOLUME
00559 scanline_topRLElen = topRLElen;
00560 scanline_botRLElen = botRLElen;
00561 scanline_topRLEdata = topRLEdata;
00562 scanline_botRLEdata = botRLEdata;
00563 if (j == 0) {
00564 top_voxel_index = voxel_index;
00565 bot_voxel_index = voxel_index;
00566 } else {
00567 top_voxel_index = bot_voxel_index;
00568 bot_voxel_index += icount;
00569 }
00570 #endif
00571
00572
00573
00574
00575
00576
00577 #ifdef RAWVOLUME
00578 if (use_octree) {
00579 top_len_base = bot_len_base;
00580 if (scans_left == 0) {
00581 if (bot_len_base == runlen_buf1)
00582 bot_len_base = runlen_buf2;
00583 else
00584 bot_len_base = runlen_buf1;
00585
00586 GET_HIRES_TIME(vpc, t1);
00587 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00588 COPY_HIRES_TIME(t0, t1);
00589
00590 scans_left = VPComputeScanRuns(vpc, level_stack, bot_len_base,
00591 best_view_axis, j, icount);
00592
00593 GET_HIRES_TIME(vpc, t1);
00594 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_OCTREE, t0, t1);
00595 COPY_HIRES_TIME(t0, t1);
00596 }
00597 #ifdef DEBUG
00598 if (j > 0)
00599 VPCheckRuns(vpc, top_len_base, best_view_axis, k, j-1);
00600 if (j < jcount)
00601 VPCheckRuns(vpc, bot_len_base, best_view_axis, k, j);
00602 #endif
00603 scans_left--;
00604 topRLElen = top_len_base;
00605 botRLElen = bot_len_base;
00606 }
00607 #endif
00608
00609
00610
00611
00612
00613 Debug((vpc, VPDEBUG_COMPOSITE, "StartIScan(u=%d,v=%d)\n",
00614 (((int)ipixel - (int)vpc->int_image.gray_intim) /
00615 sizeof(RGBIntPixel)) % vpc->intermediate_width,
00616 (((int)ipixel - (int)vpc->int_image.gray_intim) /
00617 sizeof(RGBIntPixel)) / vpc->intermediate_width));
00618
00619 #ifdef UNROLL_RUN_LOOP
00620 while (i > 0) {
00621 #else
00622 while (i >= 0) {
00623 #endif
00624
00625
00626
00627
00628 if (last_run_state == ALL_ZERO) {
00629 #ifndef UNROLL_RUN_LOOP
00630 if (i == 0) {
00631 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00632 ipixel += 1; shadow_pixel += 1;
00633 final_run_state = ALL_ZERO;
00634 i = -1;
00635 break;
00636 }
00637 #endif
00638
00639
00640 while (toprun_count == 0) {
00641 toprun_count = *topRLElen++;
00642 run_state ^= 1;
00643 }
00644 while (botrun_count == 0) {
00645 botrun_count = *botRLElen++;
00646 run_state ^= 2;
00647 }
00648 if (run_state == ALL_ZERO) {
00649 COUNT_SPECIAL_ZERO_SKIP;
00650
00651
00652 count = MIN(toprun_count, botrun_count);
00653 toprun_count -= count;
00654 botrun_count -= count;
00655 ipixel += count; shadow_pixel += count;
00656 ;
00657 ;
00658 i -= count;
00659 ASSERT(i >= 0);
00660 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(%d)\n", count));
00661 continue;
00662 }
00663 }
00664
00665 #ifndef SKIP_ERT
00666
00667
00668
00669
00670 if ((ert_skip_count = ipixel->lnk) != 0) {
00671
00672 GET_HIRES_TIME(vpc, t1);
00673 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00674 COPY_HIRES_TIME(t0, t1);
00675
00676 COUNT_ERT_SKIP;
00677
00678 #ifndef UNROLL_RUN_LOOP
00679 if (i == 0) {
00680 ipixel += 1; shadow_pixel += 1;
00681 final_run_state = last_run_state;
00682 i = -1;
00683 Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00684 break;
00685 }
00686 #endif
00687
00688
00689 if (ert_skip_count < i &&
00690 (count = ipixel[ert_skip_count].lnk) != 0) {
00691
00692 do {
00693 COUNT_ERT_SKIP_AGAIN;
00694 ert_skip_count += count;
00695 } while (ert_skip_count < i &&
00696 (count = ipixel[ert_skip_count].lnk) != 0);
00697
00698
00699
00700
00701
00702
00703 ipixel2 = ipixel;
00704 update_interval = 1;
00705 count = ert_skip_count - 1;
00706 while (count > 0) {
00707 COUNT_ERT_UPDATE;
00708 ipixel2 += update_interval;
00709 if (count > 255)
00710 ipixel2->lnk = 255;
00711 else
00712 ipixel2->lnk = count;
00713 update_interval *= 2;
00714 count -= update_interval;
00715 }
00716
00717
00718 COUNT_ERT_UPDATE;
00719 if (ert_skip_count > 255)
00720 ert_skip_count = 255;
00721 ipixel->lnk = ert_skip_count;
00722 }
00723
00724
00725 if (ert_skip_count > i)
00726 ert_skip_count = i;
00727 Debug((vpc, VPDEBUG_COMPOSITE,"ERTSkip(%d)\n",ert_skip_count));
00728 ipixel += ert_skip_count; shadow_pixel += ert_skip_count;
00729 CLEAR_VOXELS_LOADED;
00730
00731 #ifdef INDEX_VOLUME
00732
00733 next_i = icount - i + ert_skip_count;
00734 if (next_i == icount) {
00735 next_i--;
00736 next_scan = 1;
00737 } else {
00738 next_scan = 0;
00739 }
00740
00741
00742 vindex = &top_voxel_index[next_i];
00743 toprun_count = vindex->run_count;
00744 topRLElen = scanline_topRLElen + vindex->len_offset;
00745 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00746 run_state &= ~1;
00747 topRLEdata = scanline_topRLEdata +
00748 (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00749 } else {
00750 run_state |= 1;
00751 topRLEdata = scanline_topRLEdata + vindex->data_offset;
00752 }
00753
00754
00755 vindex = &bot_voxel_index[next_i];
00756 botrun_count = vindex->run_count;
00757 botRLElen = scanline_botRLElen + vindex->len_offset;
00758 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00759 run_state &= ~2;
00760 botRLEdata = scanline_botRLEdata +
00761 (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00762 } else {
00763 run_state |= 2;
00764 botRLEdata = scanline_botRLEdata + vindex->data_offset;
00765 }
00766
00767
00768 if (next_scan) {
00769
00770 while (toprun_count == 0) {
00771 toprun_count = *topRLElen++;
00772 run_state ^= 1;
00773 }
00774 toprun_count--;
00775 if (run_state & 1) {
00776 topRLEdata += 1 * voxel_istride;
00777 } else {
00778 ;
00779 }
00780
00781
00782 while (botrun_count == 0) {
00783 botrun_count = *botRLElen++;
00784 run_state ^= 2;
00785 }
00786 botrun_count--;
00787 if (run_state & 2) {
00788 botRLEdata += 1 * voxel_istride;
00789 } else {
00790 ;
00791 }
00792 }
00793
00794 #else
00795
00796 count = ert_skip_count;
00797 for (;;) {
00798 if (toprun_count >= count) {
00799 toprun_count -= count;
00800 if (run_state & 1) {
00801 topRLEdata += count * voxel_istride;
00802 } else {
00803 ;
00804 }
00805 break;
00806 } else {
00807 count -= toprun_count;
00808 if (run_state & 1) {
00809 topRLEdata += toprun_count * voxel_istride;
00810 } else {
00811 ;
00812 }
00813 toprun_count = *topRLElen++;
00814 if (toprun_count == 0)
00815 toprun_count = *topRLElen++;
00816 else
00817 run_state ^= 1;
00818 }
00819 }
00820
00821
00822 count = ert_skip_count;
00823 for (;;) {
00824 if (botrun_count >= count) {
00825 botrun_count -= count;
00826 if (run_state & 2) {
00827 botRLEdata += count * voxel_istride;
00828 } else {
00829 ;
00830 }
00831 break;
00832 } else {
00833 count -= botrun_count;
00834 if (run_state & 2) {
00835 botRLEdata += botrun_count * voxel_istride;
00836 } else {
00837 ;
00838 }
00839 botrun_count = *botRLElen++;
00840 if (botrun_count == 0)
00841 botrun_count = *botRLElen++;
00842 else
00843 run_state ^= 2;
00844 }
00845 }
00846 #endif
00847 i -= ert_skip_count;
00848 last_run_state = run_state;
00849 if (i == 0) {
00850 #ifdef UNROLL_RUN_LOOP
00851 break;
00852 #else
00853 if (last_run_state == ALL_ZERO) {
00854 ipixel += 1; shadow_pixel += 1;
00855 final_run_state = ALL_ZERO;
00856 i = -1;
00857 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00858 break;
00859 }
00860 if (ipixel->lnk != 0) {
00861 ipixel += 1; shadow_pixel += 1;
00862 final_run_state = last_run_state;
00863 i = -1;
00864 Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00865 break;
00866 }
00867 #endif
00868 }
00869
00870 GET_HIRES_TIME(vpc, t1);
00871 STORE_HIRES_TIME(vpc, VPTIMER_ERT, t0, t1);
00872 COPY_HIRES_TIME(t0, t1);
00873 }
00874 ASSERT(ipixel->opcflt < max_opacity);
00875 #endif
00876
00877
00878
00879
00880
00881 #ifndef UNROLL_RUN_LOOP
00882 if (i == 0) {
00883 final_run_state = last_run_state;
00884 run_state = ALL_ZERO;
00885 i = -1;
00886 count = 1;
00887 Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
00888 } else {
00889 #endif
00890
00891 while (toprun_count == 0) {
00892 toprun_count = *topRLElen++;
00893 run_state ^= 1;
00894 }
00895 while (botrun_count == 0) {
00896 botrun_count = *botRLElen++;
00897 run_state ^= 2;
00898 }
00899
00900
00901 count = MIN(toprun_count, botrun_count);
00902 toprun_count -= count;
00903 botrun_count -= count;
00904 i -= count;
00905 Debug((vpc, VPDEBUG_COMPOSITE, "Run(%d)\n", count));
00906 ASSERT(i >= 0);
00907 #ifndef UNROLL_RUN_LOOP
00908 }
00909 #endif
00910 COUNT_RUN_FRAGMENT;
00911
00912
00913
00914
00915
00916 GET_HIRES_TIME(vpc, t1);
00917 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00918 COPY_HIRES_TIME(t0, t1);
00919
00920 #ifdef SKIP_COMPOSITE
00921 switch (run_state) {
00922 case ALL_ZERO:
00923 ipixel += count; shadow_pixel += count;
00924 ;
00925 ;
00926 count = 0;
00927 break;
00928 case TOP_NONZERO:
00929 ipixel += count; shadow_pixel += count;
00930 topRLEdata += count * voxel_istride;
00931 ;
00932 count = 0;
00933 break;
00934 case BOT_NONZERO:
00935 ipixel += count; shadow_pixel += count;
00936 ;
00937 botRLEdata += count * voxel_istride;
00938 count = 0;
00939 break;
00940 case ALL_NONZERO:
00941 ipixel += count; shadow_pixel += count;
00942 topRLEdata += count * voxel_istride;
00943 botRLEdata += count * voxel_istride;
00944 count = 0;
00945 break;
00946 }
00947 #else
00948 #ifdef UNROLL_RUN_LOOP
00949
00950 switch ((last_run_state << 2) | run_state) {
00951 case ALL_ZERO__ALL_ZERO:
00952
00953 ipixel += count; shadow_pixel += count;
00954 ;
00955 ;
00956 count = 0;
00957 break;
00958 case TOP_NONZERO__ALL_ZERO:
00959
00960
00961 if (!voxels_loaded) {
00962
00963 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
00964
00965
00966 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
00967 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
00968
00969
00970
00971 top_rclr =
00972 shade_table[shade_index + 3*0 + 0] *
00973 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00974
00975 top_gclr =
00976 shade_table[shade_index + 3*0 + 1] *
00977 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00978
00979 top_bclr =
00980 shade_table[shade_index + 3*0 + 2] *
00981 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00982
00983 top_rsclr =
00984 shadow_table[shade_index + 3*0 + 0] *
00985 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00986
00987 top_gsclr =
00988 shadow_table[shade_index + 3*0 + 1] *
00989 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00990
00991 top_bsclr =
00992 shadow_table[shade_index + 3*0 + 2] *
00993 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
00994 for (m = 1; m < num_materials; m++) {
00995
00996
00997 top_rclr +=
00998 shade_table[shade_index + 3*m + 0] *
00999 weight_table[weight_index + m];
01000
01001 top_gclr +=
01002 shade_table[shade_index + 3*m + 1] *
01003 weight_table[weight_index + m];
01004
01005 top_bclr +=
01006 shade_table[shade_index + 3*m + 2] *
01007 weight_table[weight_index + m];
01008
01009 top_rsclr +=
01010 shadow_table[shade_index + 3*m + 0] *
01011 weight_table[weight_index + m];
01012
01013 top_gsclr +=
01014 shadow_table[shade_index + 3*m + 1] *
01015 weight_table[weight_index + m];
01016
01017 top_bsclr +=
01018 shadow_table[shade_index + 3*m + 2] *
01019 weight_table[weight_index + m];
01020 };
01021 shade_factor = top_opc * slice_depth_cueing;
01022
01023 top_rclr *= shade_factor;
01024 top_gclr *= shade_factor;
01025 top_bclr *= shade_factor;
01026
01027 top_rsclr *= shade_factor;
01028 top_gsclr *= shade_factor;
01029 top_bsclr *= shade_factor;
01030 }
01031
01032 #ifdef DEBUG
01033 if (ipixel == trace_pixel_ptr) {
01034 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01035 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01036 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01037 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01038 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01039 }
01040 #endif
01041 ;
01042
01043 acc_opc = top_opc * wgtTL;
01044
01045 acc_rclr = (top_rclr + top_rsclr *
01046 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01047 acc_gclr = (top_gclr + top_gsclr *
01048 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01049 acc_bclr = (top_bclr + top_bsclr *
01050 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01051
01052 #ifdef DEBUG
01053 if (ipixel == trace_pixel_ptr) {
01054 trace_opcTL = top_opc;
01055 trace_rclrTL = top_rclr;
01056 trace_gclrTL = top_gclr;
01057 trace_bclrTL = top_bclr;
01058
01059 }
01060 #endif
01061 ;
01062
01063 COUNT_RESAMPLE;
01064 if (acc_opc > min_opacity) {
01065 COUNT_COMPOSITE;
01066 iopc = ipixel->opcflt;
01067 # ifndef SKIP_ERT
01068 ASSERT(iopc < max_opacity);
01069 # endif
01070 iopc_inv = (float)1. - iopc;
01071
01072 ipixel->rclrflt += acc_rclr * iopc_inv;
01073 ipixel->gclrflt += acc_gclr * iopc_inv;
01074 ipixel->bclrflt += acc_bclr * iopc_inv;
01075 iopc += acc_opc * iopc_inv;
01076 ipixel->opcflt = iopc;
01077
01078 #ifdef DEBUG
01079 if (ipixel == trace_pixel_ptr) {
01080 #ifdef COMPUTE_SHADOW_BUFFER
01081 printf("{%3d} %3d %3d", k, icount-i-count, j);
01082 #else
01083 printf("[%3d] %3d %3d", k, icount-i-count, j);
01084 #endif
01085 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01086 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01087 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01088 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01089 printf(" %3.0f %3.0f\n", iopc*255.,
01090 ipixel->rclrflt);
01091
01092 printf(" ");
01093 printf(" %3.0f ",trace_rsclrTL);
01094 printf(" %3.0f ",trace_rsclrBL);
01095 printf(" %3.0f ",trace_rsclrTR);
01096 printf(" %3.0f ",trace_rsclrBR);
01097 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
01098
01099 printf(" ");
01100 printf(" %3.0f ",trace_gclrTL);
01101 printf(" %3.0f ",trace_gclrBL);
01102 printf(" %3.0f ",trace_gclrTR);
01103 printf(" %3.0f ",trace_gclrBR);
01104 printf(" %3.0f\n", ipixel->gclrflt);
01105 printf(" ");
01106 printf(" %3.0f ",trace_bclrTL);
01107 printf(" %3.0f ",trace_bclrBL);
01108 printf(" %3.0f ",trace_bclrTR);
01109 printf(" %3.0f ",trace_bclrBR);
01110 printf(" %3.0f\n", ipixel->bclrflt);
01111 }
01112 #endif
01113 ;
01114 # ifndef SKIP_ERT
01115 if (iopc >= max_opacity) {
01116 ASSERT(ipixel->lnk == 0);
01117 ipixel->lnk = 1;
01118 }
01119 # endif
01120 };
01121 ipixel += count; shadow_pixel += count;
01122 ;
01123 ;
01124 count = 0;
01125 break;
01126 case BOT_NONZERO__ALL_ZERO:
01127
01128
01129 if (!voxels_loaded) {
01130
01131 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01132
01133
01134 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
01135 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01136
01137
01138
01139 bot_rclr =
01140 shade_table[shade_index + 3*0 + 0] *
01141 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01142
01143 bot_gclr =
01144 shade_table[shade_index + 3*0 + 1] *
01145 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01146
01147 bot_bclr =
01148 shade_table[shade_index + 3*0 + 2] *
01149 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01150
01151 bot_rsclr =
01152 shadow_table[shade_index + 3*0 + 0] *
01153 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01154
01155 bot_gsclr =
01156 shadow_table[shade_index + 3*0 + 1] *
01157 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01158
01159 bot_bsclr =
01160 shadow_table[shade_index + 3*0 + 2] *
01161 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01162 for (m = 1; m < num_materials; m++) {
01163
01164
01165 bot_rclr +=
01166 shade_table[shade_index + 3*m + 0] *
01167 weight_table[weight_index + m];
01168
01169 bot_gclr +=
01170 shade_table[shade_index + 3*m + 1] *
01171 weight_table[weight_index + m];
01172
01173 bot_bclr +=
01174 shade_table[shade_index + 3*m + 2] *
01175 weight_table[weight_index + m];
01176
01177 bot_rsclr +=
01178 shadow_table[shade_index + 3*m + 0] *
01179 weight_table[weight_index + m];
01180
01181 bot_gsclr +=
01182 shadow_table[shade_index + 3*m + 1] *
01183 weight_table[weight_index + m];
01184
01185 bot_bsclr +=
01186 shadow_table[shade_index + 3*m + 2] *
01187 weight_table[weight_index + m];
01188 };
01189 shade_factor = bot_opc * slice_depth_cueing;
01190
01191 bot_rclr *= shade_factor;
01192 bot_gclr *= shade_factor;
01193 bot_bclr *= shade_factor;
01194
01195 bot_rsclr *= shade_factor;
01196 bot_gsclr *= shade_factor;
01197 bot_bsclr *= shade_factor;
01198 }
01199
01200 #ifdef DEBUG
01201 if (ipixel == trace_pixel_ptr) {
01202 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01203 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01204 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01205 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01206 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01207 }
01208 #endif
01209 ;
01210
01211 acc_opc = bot_opc * wgtBL;
01212
01213 acc_rclr = (bot_rclr + bot_rsclr *
01214 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
01215 acc_gclr = (bot_gclr + bot_gsclr *
01216 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
01217 acc_bclr = (bot_bclr + bot_bsclr *
01218 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
01219
01220 #ifdef DEBUG
01221 if (ipixel == trace_pixel_ptr) {
01222 trace_opcBL = bot_opc;
01223 trace_rclrBL = bot_rclr;
01224 trace_gclrBL = bot_gclr;
01225 trace_bclrBL = bot_bclr;
01226
01227 }
01228 #endif
01229 ;
01230
01231 COUNT_RESAMPLE;
01232 if (acc_opc > min_opacity) {
01233 COUNT_COMPOSITE;
01234 iopc = ipixel->opcflt;
01235 # ifndef SKIP_ERT
01236 ASSERT(iopc < max_opacity);
01237 # endif
01238 iopc_inv = (float)1. - iopc;
01239
01240 ipixel->rclrflt += acc_rclr * iopc_inv;
01241 ipixel->gclrflt += acc_gclr * iopc_inv;
01242 ipixel->bclrflt += acc_bclr * iopc_inv;
01243 iopc += acc_opc * iopc_inv;
01244 ipixel->opcflt = iopc;
01245
01246 #ifdef DEBUG
01247 if (ipixel == trace_pixel_ptr) {
01248 #ifdef COMPUTE_SHADOW_BUFFER
01249 printf("{%3d} %3d %3d", k, icount-i-count, j);
01250 #else
01251 printf("[%3d] %3d %3d", k, icount-i-count, j);
01252 #endif
01253 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01254 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01255 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01256 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01257 printf(" %3.0f %3.0f\n", iopc*255.,
01258 ipixel->rclrflt);
01259
01260 printf(" ");
01261 printf(" %3.0f ",trace_rsclrTL);
01262 printf(" %3.0f ",trace_rsclrBL);
01263 printf(" %3.0f ",trace_rsclrTR);
01264 printf(" %3.0f ",trace_rsclrBR);
01265 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
01266
01267 printf(" ");
01268 printf(" %3.0f ",trace_gclrTL);
01269 printf(" %3.0f ",trace_gclrBL);
01270 printf(" %3.0f ",trace_gclrTR);
01271 printf(" %3.0f ",trace_gclrBR);
01272 printf(" %3.0f\n", ipixel->gclrflt);
01273 printf(" ");
01274 printf(" %3.0f ",trace_bclrTL);
01275 printf(" %3.0f ",trace_bclrBL);
01276 printf(" %3.0f ",trace_bclrTR);
01277 printf(" %3.0f ",trace_bclrBR);
01278 printf(" %3.0f\n", ipixel->bclrflt);
01279 }
01280 #endif
01281 ;
01282 # ifndef SKIP_ERT
01283 if (iopc >= max_opacity) {
01284 ASSERT(ipixel->lnk == 0);
01285 ipixel->lnk = 1;
01286 }
01287 # endif
01288 };
01289 ipixel += count; shadow_pixel += count;
01290 ;
01291 ;
01292 count = 0;
01293 break;
01294 case ALL_NONZERO__ALL_ZERO:
01295
01296
01297 if (!voxels_loaded) {
01298
01299 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01300
01301
01302 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
01303 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01304
01305
01306
01307 top_rclr =
01308 shade_table[shade_index + 3*0 + 0] *
01309 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01310
01311 top_gclr =
01312 shade_table[shade_index + 3*0 + 1] *
01313 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01314
01315 top_bclr =
01316 shade_table[shade_index + 3*0 + 2] *
01317 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01318
01319 top_rsclr =
01320 shadow_table[shade_index + 3*0 + 0] *
01321 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01322
01323 top_gsclr =
01324 shadow_table[shade_index + 3*0 + 1] *
01325 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01326
01327 top_bsclr =
01328 shadow_table[shade_index + 3*0 + 2] *
01329 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01330 for (m = 1; m < num_materials; m++) {
01331
01332
01333 top_rclr +=
01334 shade_table[shade_index + 3*m + 0] *
01335 weight_table[weight_index + m];
01336
01337 top_gclr +=
01338 shade_table[shade_index + 3*m + 1] *
01339 weight_table[weight_index + m];
01340
01341 top_bclr +=
01342 shade_table[shade_index + 3*m + 2] *
01343 weight_table[weight_index + m];
01344
01345 top_rsclr +=
01346 shadow_table[shade_index + 3*m + 0] *
01347 weight_table[weight_index + m];
01348
01349 top_gsclr +=
01350 shadow_table[shade_index + 3*m + 1] *
01351 weight_table[weight_index + m];
01352
01353 top_bsclr +=
01354 shadow_table[shade_index + 3*m + 2] *
01355 weight_table[weight_index + m];
01356 };
01357 shade_factor = top_opc * slice_depth_cueing;
01358
01359 top_rclr *= shade_factor;
01360 top_gclr *= shade_factor;
01361 top_bclr *= shade_factor;
01362
01363 top_rsclr *= shade_factor;
01364 top_gsclr *= shade_factor;
01365 top_bsclr *= shade_factor;
01366
01367 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01368
01369
01370 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
01371 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
01372
01373
01374
01375 bot_rclr =
01376 shade_table[shade_index + 3*0 + 0] *
01377 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01378
01379 bot_gclr =
01380 shade_table[shade_index + 3*0 + 1] *
01381 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01382
01383 bot_bclr =
01384 shade_table[shade_index + 3*0 + 2] *
01385 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01386
01387 bot_rsclr =
01388 shadow_table[shade_index + 3*0 + 0] *
01389 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01390
01391 bot_gsclr =
01392 shadow_table[shade_index + 3*0 + 1] *
01393 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01394
01395 bot_bsclr =
01396 shadow_table[shade_index + 3*0 + 2] *
01397 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01398 for (m = 1; m < num_materials; m++) {
01399
01400
01401 bot_rclr +=
01402 shade_table[shade_index + 3*m + 0] *
01403 weight_table[weight_index + m];
01404
01405 bot_gclr +=
01406 shade_table[shade_index + 3*m + 1] *
01407 weight_table[weight_index + m];
01408
01409 bot_bclr +=
01410 shade_table[shade_index + 3*m + 2] *
01411 weight_table[weight_index + m];
01412
01413 bot_rsclr +=
01414 shadow_table[shade_index + 3*m + 0] *
01415 weight_table[weight_index + m];
01416
01417 bot_gsclr +=
01418 shadow_table[shade_index + 3*m + 1] *
01419 weight_table[weight_index + m];
01420
01421 bot_bsclr +=
01422 shadow_table[shade_index + 3*m + 2] *
01423 weight_table[weight_index + m];
01424 };
01425 shade_factor = bot_opc * slice_depth_cueing;
01426
01427 bot_rclr *= shade_factor;
01428 bot_gclr *= shade_factor;
01429 bot_bclr *= shade_factor;
01430
01431 bot_rsclr *= shade_factor;
01432 bot_gsclr *= shade_factor;
01433 bot_bsclr *= shade_factor;
01434 }
01435
01436 #ifdef DEBUG
01437 if (ipixel == trace_pixel_ptr) {
01438 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01439 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01440 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01441 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01442 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01443 }
01444 #endif
01445 ;
01446
01447 acc_opc = top_opc * wgtTL;
01448
01449 acc_rclr = (top_rclr + top_rsclr *
01450 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01451 acc_gclr = (top_gclr + top_gsclr *
01452 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01453 acc_bclr = (top_bclr + top_bsclr *
01454 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01455
01456 #ifdef DEBUG
01457 if (ipixel == trace_pixel_ptr) {
01458 trace_opcTL = top_opc;
01459 trace_rclrTL = top_rclr;
01460 trace_gclrTL = top_gclr;
01461 trace_bclrTL = top_bclr;
01462
01463 }
01464 #endif
01465 ;
01466
01467 acc_opc += bot_opc * wgtBL;
01468
01469 acc_rclr += (bot_rclr + bot_rsclr *
01470 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
01471 acc_gclr += (bot_gclr + bot_gsclr *
01472 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
01473 acc_bclr += (bot_bclr + bot_bsclr *
01474 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
01475
01476 #ifdef DEBUG
01477 if (ipixel == trace_pixel_ptr) {
01478 trace_opcBL = bot_opc;
01479 trace_rclrBL = bot_rclr;
01480 trace_gclrBL = bot_gclr;
01481 trace_bclrBL = bot_bclr;
01482
01483 }
01484 #endif
01485 ;
01486
01487 COUNT_RESAMPLE;
01488 if (acc_opc > min_opacity) {
01489 COUNT_COMPOSITE;
01490 iopc = ipixel->opcflt;
01491 # ifndef SKIP_ERT
01492 ASSERT(iopc < max_opacity);
01493 # endif
01494 iopc_inv = (float)1. - iopc;
01495
01496 ipixel->rclrflt += acc_rclr * iopc_inv;
01497 ipixel->gclrflt += acc_gclr * iopc_inv;
01498 ipixel->bclrflt += acc_bclr * iopc_inv;
01499 iopc += acc_opc * iopc_inv;
01500 ipixel->opcflt = iopc;
01501
01502 #ifdef DEBUG
01503 if (ipixel == trace_pixel_ptr) {
01504 #ifdef COMPUTE_SHADOW_BUFFER
01505 printf("{%3d} %3d %3d", k, icount-i-count, j);
01506 #else
01507 printf("[%3d] %3d %3d", k, icount-i-count, j);
01508 #endif
01509 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01510 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01511 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01512 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01513 printf(" %3.0f %3.0f\n", iopc*255.,
01514 ipixel->rclrflt);
01515
01516 printf(" ");
01517 printf(" %3.0f ",trace_rsclrTL);
01518 printf(" %3.0f ",trace_rsclrBL);
01519 printf(" %3.0f ",trace_rsclrTR);
01520 printf(" %3.0f ",trace_rsclrBR);
01521 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
01522
01523 printf(" ");
01524 printf(" %3.0f ",trace_gclrTL);
01525 printf(" %3.0f ",trace_gclrBL);
01526 printf(" %3.0f ",trace_gclrTR);
01527 printf(" %3.0f ",trace_gclrBR);
01528 printf(" %3.0f\n", ipixel->gclrflt);
01529 printf(" ");
01530 printf(" %3.0f ",trace_bclrTL);
01531 printf(" %3.0f ",trace_bclrBL);
01532 printf(" %3.0f ",trace_bclrTR);
01533 printf(" %3.0f ",trace_bclrBR);
01534 printf(" %3.0f\n", ipixel->bclrflt);
01535 }
01536 #endif
01537 ;
01538 # ifndef SKIP_ERT
01539 if (iopc >= max_opacity) {
01540 ASSERT(ipixel->lnk == 0);
01541 ipixel->lnk = 1;
01542 }
01543 # endif
01544 };
01545 ipixel += count; shadow_pixel += count;
01546 ;
01547 ;
01548 count = 0;
01549 break;
01550 case ALL_ZERO__TOP_NONZERO:
01551
01552
01553 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01554
01555
01556 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
01557 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01558
01559
01560
01561 top_rclr =
01562 shade_table[shade_index + 3*0 + 0] *
01563 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01564
01565 top_gclr =
01566 shade_table[shade_index + 3*0 + 1] *
01567 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01568
01569 top_bclr =
01570 shade_table[shade_index + 3*0 + 2] *
01571 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01572
01573 top_rsclr =
01574 shadow_table[shade_index + 3*0 + 0] *
01575 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01576
01577 top_gsclr =
01578 shadow_table[shade_index + 3*0 + 1] *
01579 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01580
01581 top_bsclr =
01582 shadow_table[shade_index + 3*0 + 2] *
01583 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01584 for (m = 1; m < num_materials; m++) {
01585
01586
01587 top_rclr +=
01588 shade_table[shade_index + 3*m + 0] *
01589 weight_table[weight_index + m];
01590
01591 top_gclr +=
01592 shade_table[shade_index + 3*m + 1] *
01593 weight_table[weight_index + m];
01594
01595 top_bclr +=
01596 shade_table[shade_index + 3*m + 2] *
01597 weight_table[weight_index + m];
01598
01599 top_rsclr +=
01600 shadow_table[shade_index + 3*m + 0] *
01601 weight_table[weight_index + m];
01602
01603 top_gsclr +=
01604 shadow_table[shade_index + 3*m + 1] *
01605 weight_table[weight_index + m];
01606
01607 top_bsclr +=
01608 shadow_table[shade_index + 3*m + 2] *
01609 weight_table[weight_index + m];
01610 };
01611 shade_factor = top_opc * slice_depth_cueing;
01612
01613 top_rclr *= shade_factor;
01614 top_gclr *= shade_factor;
01615 top_bclr *= shade_factor;
01616
01617 top_rsclr *= shade_factor;
01618 top_gsclr *= shade_factor;
01619 top_bsclr *= shade_factor;
01620
01621 #ifdef DEBUG
01622 if (ipixel == trace_pixel_ptr) {
01623 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01624 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01625 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01626 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01627 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01628 }
01629 #endif
01630 ;
01631
01632 acc_opc = top_opc * wgtTR;
01633
01634 acc_rclr = (top_rclr + top_rsclr *
01635 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
01636 acc_gclr = (top_gclr + top_gsclr *
01637 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
01638 acc_bclr = (top_bclr + top_bsclr *
01639 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
01640
01641 #ifdef DEBUG
01642 if (ipixel == trace_pixel_ptr) {
01643 trace_opcTR = top_opc;
01644 trace_rclrTR = top_rclr;
01645 trace_gclrTR = top_gclr;
01646 trace_bclrTR = top_bclr;
01647
01648 }
01649 #endif
01650 ;
01651
01652 COUNT_RESAMPLE;
01653 if (acc_opc > min_opacity) {
01654 COUNT_COMPOSITE;
01655 iopc = ipixel->opcflt;
01656 # ifndef SKIP_ERT
01657 ASSERT(iopc < max_opacity);
01658 # endif
01659 iopc_inv = (float)1. - iopc;
01660
01661 ipixel->rclrflt += acc_rclr * iopc_inv;
01662 ipixel->gclrflt += acc_gclr * iopc_inv;
01663 ipixel->bclrflt += acc_bclr * iopc_inv;
01664 iopc += acc_opc * iopc_inv;
01665 ipixel->opcflt = iopc;
01666
01667 #ifdef DEBUG
01668 if (ipixel == trace_pixel_ptr) {
01669 #ifdef COMPUTE_SHADOW_BUFFER
01670 printf("{%3d} %3d %3d", k, icount-i-count, j);
01671 #else
01672 printf("[%3d] %3d %3d", k, icount-i-count, j);
01673 #endif
01674 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01675 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01676 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01677 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01678 printf(" %3.0f %3.0f\n", iopc*255.,
01679 ipixel->rclrflt);
01680
01681 printf(" ");
01682 printf(" %3.0f ",trace_rsclrTL);
01683 printf(" %3.0f ",trace_rsclrBL);
01684 printf(" %3.0f ",trace_rsclrTR);
01685 printf(" %3.0f ",trace_rsclrBR);
01686 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
01687
01688 printf(" ");
01689 printf(" %3.0f ",trace_gclrTL);
01690 printf(" %3.0f ",trace_gclrBL);
01691 printf(" %3.0f ",trace_gclrTR);
01692 printf(" %3.0f ",trace_gclrBR);
01693 printf(" %3.0f\n", ipixel->gclrflt);
01694 printf(" ");
01695 printf(" %3.0f ",trace_bclrTL);
01696 printf(" %3.0f ",trace_bclrBL);
01697 printf(" %3.0f ",trace_bclrTR);
01698 printf(" %3.0f ",trace_bclrBR);
01699 printf(" %3.0f\n", ipixel->bclrflt);
01700 }
01701 #endif
01702 ;
01703 # ifndef SKIP_ERT
01704 if (iopc >= max_opacity) {
01705 ASSERT(ipixel->lnk == 0);
01706 ipixel->lnk = 1;
01707 }
01708 # endif
01709 };
01710 ipixel += 1; shadow_pixel += 1;
01711 topRLEdata += 1 * voxel_istride;
01712 ;
01713 count--;
01714 SET_VOXELS_LOADED;
01715
01716
01717
01718 while (count > 0) {
01719 if (PIXEL_IS_OPAQUE(ipixel))
01720 break;
01721 if (!voxels_loaded) {
01722
01723 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01724
01725
01726 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
01727 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01728
01729
01730
01731 top_rclr =
01732 shade_table[shade_index + 3*0 + 0] *
01733 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01734
01735 top_gclr =
01736 shade_table[shade_index + 3*0 + 1] *
01737 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01738
01739 top_bclr =
01740 shade_table[shade_index + 3*0 + 2] *
01741 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01742
01743 top_rsclr =
01744 shadow_table[shade_index + 3*0 + 0] *
01745 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01746
01747 top_gsclr =
01748 shadow_table[shade_index + 3*0 + 1] *
01749 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01750
01751 top_bsclr =
01752 shadow_table[shade_index + 3*0 + 2] *
01753 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01754 for (m = 1; m < num_materials; m++) {
01755
01756
01757 top_rclr +=
01758 shade_table[shade_index + 3*m + 0] *
01759 weight_table[weight_index + m];
01760
01761 top_gclr +=
01762 shade_table[shade_index + 3*m + 1] *
01763 weight_table[weight_index + m];
01764
01765 top_bclr +=
01766 shade_table[shade_index + 3*m + 2] *
01767 weight_table[weight_index + m];
01768
01769 top_rsclr +=
01770 shadow_table[shade_index + 3*m + 0] *
01771 weight_table[weight_index + m];
01772
01773 top_gsclr +=
01774 shadow_table[shade_index + 3*m + 1] *
01775 weight_table[weight_index + m];
01776
01777 top_bsclr +=
01778 shadow_table[shade_index + 3*m + 2] *
01779 weight_table[weight_index + m];
01780 };
01781 shade_factor = top_opc * slice_depth_cueing;
01782
01783 top_rclr *= shade_factor;
01784 top_gclr *= shade_factor;
01785 top_bclr *= shade_factor;
01786
01787 top_rsclr *= shade_factor;
01788 top_gsclr *= shade_factor;
01789 top_bsclr *= shade_factor;
01790 }
01791
01792 #ifdef DEBUG
01793 if (ipixel == trace_pixel_ptr) {
01794 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01795 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01796 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01797 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01798 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01799 }
01800 #endif
01801 ;
01802
01803 acc_opc = top_opc * wgtTL;
01804
01805 acc_rclr = (top_rclr + top_rsclr *
01806 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01807 acc_gclr = (top_gclr + top_gsclr *
01808 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01809 acc_bclr = (top_bclr + top_bsclr *
01810 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
01811
01812 #ifdef DEBUG
01813 if (ipixel == trace_pixel_ptr) {
01814 trace_opcTL = top_opc;
01815 trace_rclrTL = top_rclr;
01816 trace_gclrTL = top_gclr;
01817 trace_bclrTL = top_bclr;
01818
01819 }
01820 #endif
01821 ;
01822
01823 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01824
01825
01826 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
01827 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
01828
01829
01830
01831 top_rclr =
01832 shade_table[shade_index + 3*0 + 0] *
01833 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01834
01835 top_gclr =
01836 shade_table[shade_index + 3*0 + 1] *
01837 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01838
01839 top_bclr =
01840 shade_table[shade_index + 3*0 + 2] *
01841 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01842
01843 top_rsclr =
01844 shadow_table[shade_index + 3*0 + 0] *
01845 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01846
01847 top_gsclr =
01848 shadow_table[shade_index + 3*0 + 1] *
01849 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01850
01851 top_bsclr =
01852 shadow_table[shade_index + 3*0 + 2] *
01853 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01854 for (m = 1; m < num_materials; m++) {
01855
01856
01857 top_rclr +=
01858 shade_table[shade_index + 3*m + 0] *
01859 weight_table[weight_index + m];
01860
01861 top_gclr +=
01862 shade_table[shade_index + 3*m + 1] *
01863 weight_table[weight_index + m];
01864
01865 top_bclr +=
01866 shade_table[shade_index + 3*m + 2] *
01867 weight_table[weight_index + m];
01868
01869 top_rsclr +=
01870 shadow_table[shade_index + 3*m + 0] *
01871 weight_table[weight_index + m];
01872
01873 top_gsclr +=
01874 shadow_table[shade_index + 3*m + 1] *
01875 weight_table[weight_index + m];
01876
01877 top_bsclr +=
01878 shadow_table[shade_index + 3*m + 2] *
01879 weight_table[weight_index + m];
01880 };
01881 shade_factor = top_opc * slice_depth_cueing;
01882
01883 top_rclr *= shade_factor;
01884 top_gclr *= shade_factor;
01885 top_bclr *= shade_factor;
01886
01887 top_rsclr *= shade_factor;
01888 top_gsclr *= shade_factor;
01889 top_bsclr *= shade_factor;
01890
01891 acc_opc += top_opc * wgtTR;
01892
01893 acc_rclr += (top_rclr + top_rsclr *
01894 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
01895 acc_gclr += (top_gclr + top_gsclr *
01896 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
01897 acc_bclr += (top_bclr + top_bsclr *
01898 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
01899
01900 #ifdef DEBUG
01901 if (ipixel == trace_pixel_ptr) {
01902 trace_opcTR = top_opc;
01903 trace_rclrTR = top_rclr;
01904 trace_gclrTR = top_gclr;
01905 trace_bclrTR = top_bclr;
01906
01907 }
01908 #endif
01909 ;
01910
01911 COUNT_RESAMPLE;
01912 if (acc_opc > min_opacity) {
01913 COUNT_COMPOSITE;
01914 iopc = ipixel->opcflt;
01915 # ifndef SKIP_ERT
01916 ASSERT(iopc < max_opacity);
01917 # endif
01918 iopc_inv = (float)1. - iopc;
01919
01920 ipixel->rclrflt += acc_rclr * iopc_inv;
01921 ipixel->gclrflt += acc_gclr * iopc_inv;
01922 ipixel->bclrflt += acc_bclr * iopc_inv;
01923 iopc += acc_opc * iopc_inv;
01924 ipixel->opcflt = iopc;
01925
01926 #ifdef DEBUG
01927 if (ipixel == trace_pixel_ptr) {
01928 #ifdef COMPUTE_SHADOW_BUFFER
01929 printf("{%3d} %3d %3d", k, icount-i-count, j);
01930 #else
01931 printf("[%3d] %3d %3d", k, icount-i-count, j);
01932 #endif
01933 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01934 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01935 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01936 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01937 printf(" %3.0f %3.0f\n", iopc*255.,
01938 ipixel->rclrflt);
01939
01940 printf(" ");
01941 printf(" %3.0f ",trace_rsclrTL);
01942 printf(" %3.0f ",trace_rsclrBL);
01943 printf(" %3.0f ",trace_rsclrTR);
01944 printf(" %3.0f ",trace_rsclrBR);
01945 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
01946
01947 printf(" ");
01948 printf(" %3.0f ",trace_gclrTL);
01949 printf(" %3.0f ",trace_gclrBL);
01950 printf(" %3.0f ",trace_gclrTR);
01951 printf(" %3.0f ",trace_gclrBR);
01952 printf(" %3.0f\n", ipixel->gclrflt);
01953 printf(" ");
01954 printf(" %3.0f ",trace_bclrTL);
01955 printf(" %3.0f ",trace_bclrBL);
01956 printf(" %3.0f ",trace_bclrTR);
01957 printf(" %3.0f ",trace_bclrBR);
01958 printf(" %3.0f\n", ipixel->bclrflt);
01959 }
01960 #endif
01961 ;
01962 # ifndef SKIP_ERT
01963 if (iopc >= max_opacity) {
01964 ASSERT(ipixel->lnk == 0);
01965 ipixel->lnk = 1;
01966 }
01967 # endif
01968 };
01969 ipixel += 1; shadow_pixel += 1;
01970 topRLEdata += 1 * voxel_istride;
01971 ;
01972 count--;
01973 SET_VOXELS_LOADED;
01974 }
01975 break;
01976 case TOP_NONZERO__TOP_NONZERO:
01977
01978
01979 while (count > 0) {
01980 if (PIXEL_IS_OPAQUE(ipixel))
01981 break;
01982 if (!voxels_loaded) {
01983
01984 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01985
01986
01987 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
01988 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
01989
01990
01991
01992 top_rclr =
01993 shade_table[shade_index + 3*0 + 0] *
01994 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01995
01996 top_gclr =
01997 shade_table[shade_index + 3*0 + 1] *
01998 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
01999
02000 top_bclr =
02001 shade_table[shade_index + 3*0 + 2] *
02002 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02003
02004 top_rsclr =
02005 shadow_table[shade_index + 3*0 + 0] *
02006 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02007
02008 top_gsclr =
02009 shadow_table[shade_index + 3*0 + 1] *
02010 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02011
02012 top_bsclr =
02013 shadow_table[shade_index + 3*0 + 2] *
02014 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02015 for (m = 1; m < num_materials; m++) {
02016
02017
02018 top_rclr +=
02019 shade_table[shade_index + 3*m + 0] *
02020 weight_table[weight_index + m];
02021
02022 top_gclr +=
02023 shade_table[shade_index + 3*m + 1] *
02024 weight_table[weight_index + m];
02025
02026 top_bclr +=
02027 shade_table[shade_index + 3*m + 2] *
02028 weight_table[weight_index + m];
02029
02030 top_rsclr +=
02031 shadow_table[shade_index + 3*m + 0] *
02032 weight_table[weight_index + m];
02033
02034 top_gsclr +=
02035 shadow_table[shade_index + 3*m + 1] *
02036 weight_table[weight_index + m];
02037
02038 top_bsclr +=
02039 shadow_table[shade_index + 3*m + 2] *
02040 weight_table[weight_index + m];
02041 };
02042 shade_factor = top_opc * slice_depth_cueing;
02043
02044 top_rclr *= shade_factor;
02045 top_gclr *= shade_factor;
02046 top_bclr *= shade_factor;
02047
02048 top_rsclr *= shade_factor;
02049 top_gsclr *= shade_factor;
02050 top_bsclr *= shade_factor;
02051 }
02052
02053 #ifdef DEBUG
02054 if (ipixel == trace_pixel_ptr) {
02055 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02056 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02057 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02058 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02059 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02060 }
02061 #endif
02062 ;
02063
02064 acc_opc = top_opc * wgtTL;
02065
02066 acc_rclr = (top_rclr + top_rsclr *
02067 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02068 acc_gclr = (top_gclr + top_gsclr *
02069 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02070 acc_bclr = (top_bclr + top_bsclr *
02071 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02072
02073 #ifdef DEBUG
02074 if (ipixel == trace_pixel_ptr) {
02075 trace_opcTL = top_opc;
02076 trace_rclrTL = top_rclr;
02077 trace_gclrTL = top_gclr;
02078 trace_bclrTL = top_bclr;
02079
02080 }
02081 #endif
02082 ;
02083
02084 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02085
02086
02087 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
02088 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02089
02090
02091
02092 top_rclr =
02093 shade_table[shade_index + 3*0 + 0] *
02094 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02095
02096 top_gclr =
02097 shade_table[shade_index + 3*0 + 1] *
02098 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02099
02100 top_bclr =
02101 shade_table[shade_index + 3*0 + 2] *
02102 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02103
02104 top_rsclr =
02105 shadow_table[shade_index + 3*0 + 0] *
02106 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02107
02108 top_gsclr =
02109 shadow_table[shade_index + 3*0 + 1] *
02110 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02111
02112 top_bsclr =
02113 shadow_table[shade_index + 3*0 + 2] *
02114 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02115 for (m = 1; m < num_materials; m++) {
02116
02117
02118 top_rclr +=
02119 shade_table[shade_index + 3*m + 0] *
02120 weight_table[weight_index + m];
02121
02122 top_gclr +=
02123 shade_table[shade_index + 3*m + 1] *
02124 weight_table[weight_index + m];
02125
02126 top_bclr +=
02127 shade_table[shade_index + 3*m + 2] *
02128 weight_table[weight_index + m];
02129
02130 top_rsclr +=
02131 shadow_table[shade_index + 3*m + 0] *
02132 weight_table[weight_index + m];
02133
02134 top_gsclr +=
02135 shadow_table[shade_index + 3*m + 1] *
02136 weight_table[weight_index + m];
02137
02138 top_bsclr +=
02139 shadow_table[shade_index + 3*m + 2] *
02140 weight_table[weight_index + m];
02141 };
02142 shade_factor = top_opc * slice_depth_cueing;
02143
02144 top_rclr *= shade_factor;
02145 top_gclr *= shade_factor;
02146 top_bclr *= shade_factor;
02147
02148 top_rsclr *= shade_factor;
02149 top_gsclr *= shade_factor;
02150 top_bsclr *= shade_factor;
02151
02152 acc_opc += top_opc * wgtTR;
02153
02154 acc_rclr += (top_rclr + top_rsclr *
02155 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02156 acc_gclr += (top_gclr + top_gsclr *
02157 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02158 acc_bclr += (top_bclr + top_bsclr *
02159 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02160
02161 #ifdef DEBUG
02162 if (ipixel == trace_pixel_ptr) {
02163 trace_opcTR = top_opc;
02164 trace_rclrTR = top_rclr;
02165 trace_gclrTR = top_gclr;
02166 trace_bclrTR = top_bclr;
02167
02168 }
02169 #endif
02170 ;
02171
02172 COUNT_RESAMPLE;
02173 if (acc_opc > min_opacity) {
02174 COUNT_COMPOSITE;
02175 iopc = ipixel->opcflt;
02176 # ifndef SKIP_ERT
02177 ASSERT(iopc < max_opacity);
02178 # endif
02179 iopc_inv = (float)1. - iopc;
02180
02181 ipixel->rclrflt += acc_rclr * iopc_inv;
02182 ipixel->gclrflt += acc_gclr * iopc_inv;
02183 ipixel->bclrflt += acc_bclr * iopc_inv;
02184 iopc += acc_opc * iopc_inv;
02185 ipixel->opcflt = iopc;
02186
02187 #ifdef DEBUG
02188 if (ipixel == trace_pixel_ptr) {
02189 #ifdef COMPUTE_SHADOW_BUFFER
02190 printf("{%3d} %3d %3d", k, icount-i-count, j);
02191 #else
02192 printf("[%3d] %3d %3d", k, icount-i-count, j);
02193 #endif
02194 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02195 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02196 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02197 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02198 printf(" %3.0f %3.0f\n", iopc*255.,
02199 ipixel->rclrflt);
02200
02201 printf(" ");
02202 printf(" %3.0f ",trace_rsclrTL);
02203 printf(" %3.0f ",trace_rsclrBL);
02204 printf(" %3.0f ",trace_rsclrTR);
02205 printf(" %3.0f ",trace_rsclrBR);
02206 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
02207
02208 printf(" ");
02209 printf(" %3.0f ",trace_gclrTL);
02210 printf(" %3.0f ",trace_gclrBL);
02211 printf(" %3.0f ",trace_gclrTR);
02212 printf(" %3.0f ",trace_gclrBR);
02213 printf(" %3.0f\n", ipixel->gclrflt);
02214 printf(" ");
02215 printf(" %3.0f ",trace_bclrTL);
02216 printf(" %3.0f ",trace_bclrBL);
02217 printf(" %3.0f ",trace_bclrTR);
02218 printf(" %3.0f ",trace_bclrBR);
02219 printf(" %3.0f\n", ipixel->bclrflt);
02220 }
02221 #endif
02222 ;
02223 # ifndef SKIP_ERT
02224 if (iopc >= max_opacity) {
02225 ASSERT(ipixel->lnk == 0);
02226 ipixel->lnk = 1;
02227 }
02228 # endif
02229 };
02230 ipixel += 1; shadow_pixel += 1;
02231 topRLEdata += 1 * voxel_istride;
02232 ;
02233 count--;
02234 SET_VOXELS_LOADED;
02235 }
02236 break;
02237 case BOT_NONZERO__TOP_NONZERO:
02238
02239
02240 if (!voxels_loaded) {
02241
02242 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02243
02244
02245 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
02246 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02247
02248
02249
02250 bot_rclr =
02251 shade_table[shade_index + 3*0 + 0] *
02252 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02253
02254 bot_gclr =
02255 shade_table[shade_index + 3*0 + 1] *
02256 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02257
02258 bot_bclr =
02259 shade_table[shade_index + 3*0 + 2] *
02260 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02261
02262 bot_rsclr =
02263 shadow_table[shade_index + 3*0 + 0] *
02264 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02265
02266 bot_gsclr =
02267 shadow_table[shade_index + 3*0 + 1] *
02268 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02269
02270 bot_bsclr =
02271 shadow_table[shade_index + 3*0 + 2] *
02272 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02273 for (m = 1; m < num_materials; m++) {
02274
02275
02276 bot_rclr +=
02277 shade_table[shade_index + 3*m + 0] *
02278 weight_table[weight_index + m];
02279
02280 bot_gclr +=
02281 shade_table[shade_index + 3*m + 1] *
02282 weight_table[weight_index + m];
02283
02284 bot_bclr +=
02285 shade_table[shade_index + 3*m + 2] *
02286 weight_table[weight_index + m];
02287
02288 bot_rsclr +=
02289 shadow_table[shade_index + 3*m + 0] *
02290 weight_table[weight_index + m];
02291
02292 bot_gsclr +=
02293 shadow_table[shade_index + 3*m + 1] *
02294 weight_table[weight_index + m];
02295
02296 bot_bsclr +=
02297 shadow_table[shade_index + 3*m + 2] *
02298 weight_table[weight_index + m];
02299 };
02300 shade_factor = bot_opc * slice_depth_cueing;
02301
02302 bot_rclr *= shade_factor;
02303 bot_gclr *= shade_factor;
02304 bot_bclr *= shade_factor;
02305
02306 bot_rsclr *= shade_factor;
02307 bot_gsclr *= shade_factor;
02308 bot_bsclr *= shade_factor;
02309 }
02310
02311 #ifdef DEBUG
02312 if (ipixel == trace_pixel_ptr) {
02313 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02314 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02315 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02316 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02317 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02318 }
02319 #endif
02320 ;
02321
02322 acc_opc = bot_opc * wgtBL;
02323
02324 acc_rclr = (bot_rclr + bot_rsclr *
02325 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
02326 acc_gclr = (bot_gclr + bot_gsclr *
02327 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
02328 acc_bclr = (bot_bclr + bot_bsclr *
02329 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
02330
02331 #ifdef DEBUG
02332 if (ipixel == trace_pixel_ptr) {
02333 trace_opcBL = bot_opc;
02334 trace_rclrBL = bot_rclr;
02335 trace_gclrBL = bot_gclr;
02336 trace_bclrBL = bot_bclr;
02337
02338 }
02339 #endif
02340 ;
02341
02342 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02343
02344
02345 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
02346 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02347
02348
02349
02350 top_rclr =
02351 shade_table[shade_index + 3*0 + 0] *
02352 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02353
02354 top_gclr =
02355 shade_table[shade_index + 3*0 + 1] *
02356 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02357
02358 top_bclr =
02359 shade_table[shade_index + 3*0 + 2] *
02360 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02361
02362 top_rsclr =
02363 shadow_table[shade_index + 3*0 + 0] *
02364 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02365
02366 top_gsclr =
02367 shadow_table[shade_index + 3*0 + 1] *
02368 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02369
02370 top_bsclr =
02371 shadow_table[shade_index + 3*0 + 2] *
02372 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02373 for (m = 1; m < num_materials; m++) {
02374
02375
02376 top_rclr +=
02377 shade_table[shade_index + 3*m + 0] *
02378 weight_table[weight_index + m];
02379
02380 top_gclr +=
02381 shade_table[shade_index + 3*m + 1] *
02382 weight_table[weight_index + m];
02383
02384 top_bclr +=
02385 shade_table[shade_index + 3*m + 2] *
02386 weight_table[weight_index + m];
02387
02388 top_rsclr +=
02389 shadow_table[shade_index + 3*m + 0] *
02390 weight_table[weight_index + m];
02391
02392 top_gsclr +=
02393 shadow_table[shade_index + 3*m + 1] *
02394 weight_table[weight_index + m];
02395
02396 top_bsclr +=
02397 shadow_table[shade_index + 3*m + 2] *
02398 weight_table[weight_index + m];
02399 };
02400 shade_factor = top_opc * slice_depth_cueing;
02401
02402 top_rclr *= shade_factor;
02403 top_gclr *= shade_factor;
02404 top_bclr *= shade_factor;
02405
02406 top_rsclr *= shade_factor;
02407 top_gsclr *= shade_factor;
02408 top_bsclr *= shade_factor;
02409
02410 acc_opc += top_opc * wgtTR;
02411
02412 acc_rclr += (top_rclr + top_rsclr *
02413 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02414 acc_gclr += (top_gclr + top_gsclr *
02415 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02416 acc_bclr += (top_bclr + top_bsclr *
02417 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02418
02419 #ifdef DEBUG
02420 if (ipixel == trace_pixel_ptr) {
02421 trace_opcTR = top_opc;
02422 trace_rclrTR = top_rclr;
02423 trace_gclrTR = top_gclr;
02424 trace_bclrTR = top_bclr;
02425
02426 }
02427 #endif
02428 ;
02429
02430 COUNT_RESAMPLE;
02431 if (acc_opc > min_opacity) {
02432 COUNT_COMPOSITE;
02433 iopc = ipixel->opcflt;
02434 # ifndef SKIP_ERT
02435 ASSERT(iopc < max_opacity);
02436 # endif
02437 iopc_inv = (float)1. - iopc;
02438
02439 ipixel->rclrflt += acc_rclr * iopc_inv;
02440 ipixel->gclrflt += acc_gclr * iopc_inv;
02441 ipixel->bclrflt += acc_bclr * iopc_inv;
02442 iopc += acc_opc * iopc_inv;
02443 ipixel->opcflt = iopc;
02444
02445 #ifdef DEBUG
02446 if (ipixel == trace_pixel_ptr) {
02447 #ifdef COMPUTE_SHADOW_BUFFER
02448 printf("{%3d} %3d %3d", k, icount-i-count, j);
02449 #else
02450 printf("[%3d] %3d %3d", k, icount-i-count, j);
02451 #endif
02452 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02453 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02454 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02455 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02456 printf(" %3.0f %3.0f\n", iopc*255.,
02457 ipixel->rclrflt);
02458
02459 printf(" ");
02460 printf(" %3.0f ",trace_rsclrTL);
02461 printf(" %3.0f ",trace_rsclrBL);
02462 printf(" %3.0f ",trace_rsclrTR);
02463 printf(" %3.0f ",trace_rsclrBR);
02464 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
02465
02466 printf(" ");
02467 printf(" %3.0f ",trace_gclrTL);
02468 printf(" %3.0f ",trace_gclrBL);
02469 printf(" %3.0f ",trace_gclrTR);
02470 printf(" %3.0f ",trace_gclrBR);
02471 printf(" %3.0f\n", ipixel->gclrflt);
02472 printf(" ");
02473 printf(" %3.0f ",trace_bclrTL);
02474 printf(" %3.0f ",trace_bclrBL);
02475 printf(" %3.0f ",trace_bclrTR);
02476 printf(" %3.0f ",trace_bclrBR);
02477 printf(" %3.0f\n", ipixel->bclrflt);
02478 }
02479 #endif
02480 ;
02481 # ifndef SKIP_ERT
02482 if (iopc >= max_opacity) {
02483 ASSERT(ipixel->lnk == 0);
02484 ipixel->lnk = 1;
02485 }
02486 # endif
02487 };
02488 ipixel += 1; shadow_pixel += 1;
02489 topRLEdata += 1 * voxel_istride;
02490 ;
02491 count--;
02492 SET_VOXELS_LOADED;
02493
02494
02495
02496 while (count > 0) {
02497 if (PIXEL_IS_OPAQUE(ipixel))
02498 break;
02499 if (!voxels_loaded) {
02500
02501 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02502
02503
02504 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
02505 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02506
02507
02508
02509 top_rclr =
02510 shade_table[shade_index + 3*0 + 0] *
02511 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02512
02513 top_gclr =
02514 shade_table[shade_index + 3*0 + 1] *
02515 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02516
02517 top_bclr =
02518 shade_table[shade_index + 3*0 + 2] *
02519 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02520
02521 top_rsclr =
02522 shadow_table[shade_index + 3*0 + 0] *
02523 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02524
02525 top_gsclr =
02526 shadow_table[shade_index + 3*0 + 1] *
02527 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02528
02529 top_bsclr =
02530 shadow_table[shade_index + 3*0 + 2] *
02531 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02532 for (m = 1; m < num_materials; m++) {
02533
02534
02535 top_rclr +=
02536 shade_table[shade_index + 3*m + 0] *
02537 weight_table[weight_index + m];
02538
02539 top_gclr +=
02540 shade_table[shade_index + 3*m + 1] *
02541 weight_table[weight_index + m];
02542
02543 top_bclr +=
02544 shade_table[shade_index + 3*m + 2] *
02545 weight_table[weight_index + m];
02546
02547 top_rsclr +=
02548 shadow_table[shade_index + 3*m + 0] *
02549 weight_table[weight_index + m];
02550
02551 top_gsclr +=
02552 shadow_table[shade_index + 3*m + 1] *
02553 weight_table[weight_index + m];
02554
02555 top_bsclr +=
02556 shadow_table[shade_index + 3*m + 2] *
02557 weight_table[weight_index + m];
02558 };
02559 shade_factor = top_opc * slice_depth_cueing;
02560
02561 top_rclr *= shade_factor;
02562 top_gclr *= shade_factor;
02563 top_bclr *= shade_factor;
02564
02565 top_rsclr *= shade_factor;
02566 top_gsclr *= shade_factor;
02567 top_bsclr *= shade_factor;
02568 }
02569
02570 #ifdef DEBUG
02571 if (ipixel == trace_pixel_ptr) {
02572 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02573 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02574 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02575 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02576 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02577 }
02578 #endif
02579 ;
02580
02581 acc_opc = top_opc * wgtTL;
02582
02583 acc_rclr = (top_rclr + top_rsclr *
02584 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02585 acc_gclr = (top_gclr + top_gsclr *
02586 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02587 acc_bclr = (top_bclr + top_bsclr *
02588 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02589
02590 #ifdef DEBUG
02591 if (ipixel == trace_pixel_ptr) {
02592 trace_opcTL = top_opc;
02593 trace_rclrTL = top_rclr;
02594 trace_gclrTL = top_gclr;
02595 trace_bclrTL = top_bclr;
02596
02597 }
02598 #endif
02599 ;
02600
02601 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02602
02603
02604 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
02605 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02606
02607
02608
02609 top_rclr =
02610 shade_table[shade_index + 3*0 + 0] *
02611 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02612
02613 top_gclr =
02614 shade_table[shade_index + 3*0 + 1] *
02615 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02616
02617 top_bclr =
02618 shade_table[shade_index + 3*0 + 2] *
02619 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02620
02621 top_rsclr =
02622 shadow_table[shade_index + 3*0 + 0] *
02623 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02624
02625 top_gsclr =
02626 shadow_table[shade_index + 3*0 + 1] *
02627 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02628
02629 top_bsclr =
02630 shadow_table[shade_index + 3*0 + 2] *
02631 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02632 for (m = 1; m < num_materials; m++) {
02633
02634
02635 top_rclr +=
02636 shade_table[shade_index + 3*m + 0] *
02637 weight_table[weight_index + m];
02638
02639 top_gclr +=
02640 shade_table[shade_index + 3*m + 1] *
02641 weight_table[weight_index + m];
02642
02643 top_bclr +=
02644 shade_table[shade_index + 3*m + 2] *
02645 weight_table[weight_index + m];
02646
02647 top_rsclr +=
02648 shadow_table[shade_index + 3*m + 0] *
02649 weight_table[weight_index + m];
02650
02651 top_gsclr +=
02652 shadow_table[shade_index + 3*m + 1] *
02653 weight_table[weight_index + m];
02654
02655 top_bsclr +=
02656 shadow_table[shade_index + 3*m + 2] *
02657 weight_table[weight_index + m];
02658 };
02659 shade_factor = top_opc * slice_depth_cueing;
02660
02661 top_rclr *= shade_factor;
02662 top_gclr *= shade_factor;
02663 top_bclr *= shade_factor;
02664
02665 top_rsclr *= shade_factor;
02666 top_gsclr *= shade_factor;
02667 top_bsclr *= shade_factor;
02668
02669 acc_opc += top_opc * wgtTR;
02670
02671 acc_rclr += (top_rclr + top_rsclr *
02672 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02673 acc_gclr += (top_gclr + top_gsclr *
02674 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02675 acc_bclr += (top_bclr + top_bsclr *
02676 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
02677
02678 #ifdef DEBUG
02679 if (ipixel == trace_pixel_ptr) {
02680 trace_opcTR = top_opc;
02681 trace_rclrTR = top_rclr;
02682 trace_gclrTR = top_gclr;
02683 trace_bclrTR = top_bclr;
02684
02685 }
02686 #endif
02687 ;
02688
02689 COUNT_RESAMPLE;
02690 if (acc_opc > min_opacity) {
02691 COUNT_COMPOSITE;
02692 iopc = ipixel->opcflt;
02693 # ifndef SKIP_ERT
02694 ASSERT(iopc < max_opacity);
02695 # endif
02696 iopc_inv = (float)1. - iopc;
02697
02698 ipixel->rclrflt += acc_rclr * iopc_inv;
02699 ipixel->gclrflt += acc_gclr * iopc_inv;
02700 ipixel->bclrflt += acc_bclr * iopc_inv;
02701 iopc += acc_opc * iopc_inv;
02702 ipixel->opcflt = iopc;
02703
02704 #ifdef DEBUG
02705 if (ipixel == trace_pixel_ptr) {
02706 #ifdef COMPUTE_SHADOW_BUFFER
02707 printf("{%3d} %3d %3d", k, icount-i-count, j);
02708 #else
02709 printf("[%3d] %3d %3d", k, icount-i-count, j);
02710 #endif
02711 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02712 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02713 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02714 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02715 printf(" %3.0f %3.0f\n", iopc*255.,
02716 ipixel->rclrflt);
02717
02718 printf(" ");
02719 printf(" %3.0f ",trace_rsclrTL);
02720 printf(" %3.0f ",trace_rsclrBL);
02721 printf(" %3.0f ",trace_rsclrTR);
02722 printf(" %3.0f ",trace_rsclrBR);
02723 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
02724
02725 printf(" ");
02726 printf(" %3.0f ",trace_gclrTL);
02727 printf(" %3.0f ",trace_gclrBL);
02728 printf(" %3.0f ",trace_gclrTR);
02729 printf(" %3.0f ",trace_gclrBR);
02730 printf(" %3.0f\n", ipixel->gclrflt);
02731 printf(" ");
02732 printf(" %3.0f ",trace_bclrTL);
02733 printf(" %3.0f ",trace_bclrBL);
02734 printf(" %3.0f ",trace_bclrTR);
02735 printf(" %3.0f ",trace_bclrBR);
02736 printf(" %3.0f\n", ipixel->bclrflt);
02737 }
02738 #endif
02739 ;
02740 # ifndef SKIP_ERT
02741 if (iopc >= max_opacity) {
02742 ASSERT(ipixel->lnk == 0);
02743 ipixel->lnk = 1;
02744 }
02745 # endif
02746 };
02747 ipixel += 1; shadow_pixel += 1;
02748 topRLEdata += 1 * voxel_istride;
02749 ;
02750 count--;
02751 SET_VOXELS_LOADED;
02752 }
02753 break;
02754 case ALL_NONZERO__TOP_NONZERO:
02755
02756
02757 if (!voxels_loaded) {
02758
02759 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02760
02761
02762 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
02763 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
02764
02765
02766
02767 top_rclr =
02768 shade_table[shade_index + 3*0 + 0] *
02769 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02770
02771 top_gclr =
02772 shade_table[shade_index + 3*0 + 1] *
02773 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02774
02775 top_bclr =
02776 shade_table[shade_index + 3*0 + 2] *
02777 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02778
02779 top_rsclr =
02780 shadow_table[shade_index + 3*0 + 0] *
02781 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02782
02783 top_gsclr =
02784 shadow_table[shade_index + 3*0 + 1] *
02785 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02786
02787 top_bsclr =
02788 shadow_table[shade_index + 3*0 + 2] *
02789 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02790 for (m = 1; m < num_materials; m++) {
02791
02792
02793 top_rclr +=
02794 shade_table[shade_index + 3*m + 0] *
02795 weight_table[weight_index + m];
02796
02797 top_gclr +=
02798 shade_table[shade_index + 3*m + 1] *
02799 weight_table[weight_index + m];
02800
02801 top_bclr +=
02802 shade_table[shade_index + 3*m + 2] *
02803 weight_table[weight_index + m];
02804
02805 top_rsclr +=
02806 shadow_table[shade_index + 3*m + 0] *
02807 weight_table[weight_index + m];
02808
02809 top_gsclr +=
02810 shadow_table[shade_index + 3*m + 1] *
02811 weight_table[weight_index + m];
02812
02813 top_bsclr +=
02814 shadow_table[shade_index + 3*m + 2] *
02815 weight_table[weight_index + m];
02816 };
02817 shade_factor = top_opc * slice_depth_cueing;
02818
02819 top_rclr *= shade_factor;
02820 top_gclr *= shade_factor;
02821 top_bclr *= shade_factor;
02822
02823 top_rsclr *= shade_factor;
02824 top_gsclr *= shade_factor;
02825 top_bsclr *= shade_factor;
02826
02827 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02828
02829
02830 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
02831 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
02832
02833
02834
02835 bot_rclr =
02836 shade_table[shade_index + 3*0 + 0] *
02837 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02838
02839 bot_gclr =
02840 shade_table[shade_index + 3*0 + 1] *
02841 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02842
02843 bot_bclr =
02844 shade_table[shade_index + 3*0 + 2] *
02845 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02846
02847 bot_rsclr =
02848 shadow_table[shade_index + 3*0 + 0] *
02849 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02850
02851 bot_gsclr =
02852 shadow_table[shade_index + 3*0 + 1] *
02853 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02854
02855 bot_bsclr =
02856 shadow_table[shade_index + 3*0 + 2] *
02857 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02858 for (m = 1; m < num_materials; m++) {
02859
02860
02861 bot_rclr +=
02862 shade_table[shade_index + 3*m + 0] *
02863 weight_table[weight_index + m];
02864
02865 bot_gclr +=
02866 shade_table[shade_index + 3*m + 1] *
02867 weight_table[weight_index + m];
02868
02869 bot_bclr +=
02870 shade_table[shade_index + 3*m + 2] *
02871 weight_table[weight_index + m];
02872
02873 bot_rsclr +=
02874 shadow_table[shade_index + 3*m + 0] *
02875 weight_table[weight_index + m];
02876
02877 bot_gsclr +=
02878 shadow_table[shade_index + 3*m + 1] *
02879 weight_table[weight_index + m];
02880
02881 bot_bsclr +=
02882 shadow_table[shade_index + 3*m + 2] *
02883 weight_table[weight_index + m];
02884 };
02885 shade_factor = bot_opc * slice_depth_cueing;
02886
02887 bot_rclr *= shade_factor;
02888 bot_gclr *= shade_factor;
02889 bot_bclr *= shade_factor;
02890
02891 bot_rsclr *= shade_factor;
02892 bot_gsclr *= shade_factor;
02893 bot_bsclr *= shade_factor;
02894 }
02895
02896 #ifdef DEBUG
02897 if (ipixel == trace_pixel_ptr) {
02898 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02899 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02900 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02901 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02902 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02903 }
02904 #endif
02905 ;
02906
02907 acc_opc = top_opc * wgtTL;
02908
02909 acc_rclr = (top_rclr + top_rsclr *
02910 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02911 acc_gclr = (top_gclr + top_gsclr *
02912 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02913 acc_bclr = (top_bclr + top_bsclr *
02914 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
02915
02916 #ifdef DEBUG
02917 if (ipixel == trace_pixel_ptr) {
02918 trace_opcTL = top_opc;
02919 trace_rclrTL = top_rclr;
02920 trace_gclrTL = top_gclr;
02921 trace_bclrTL = top_bclr;
02922
02923 }
02924 #endif
02925 ;
02926
02927 acc_opc += bot_opc * wgtBL;
02928
02929 acc_rclr += (bot_rclr + bot_rsclr *
02930 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
02931 acc_gclr += (bot_gclr + bot_gsclr *
02932 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
02933 acc_bclr += (bot_bclr + bot_bsclr *
02934 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
02935
02936 #ifdef DEBUG
02937 if (ipixel == trace_pixel_ptr) {
02938 trace_opcBL = bot_opc;
02939 trace_rclrBL = bot_rclr;
02940 trace_gclrBL = bot_gclr;
02941 trace_bclrBL = bot_bclr;
02942
02943 }
02944 #endif
02945 ;
02946
02947 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02948
02949
02950 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
02951 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
02952
02953
02954
02955 top_rclr =
02956 shade_table[shade_index + 3*0 + 0] *
02957 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02958
02959 top_gclr =
02960 shade_table[shade_index + 3*0 + 1] *
02961 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02962
02963 top_bclr =
02964 shade_table[shade_index + 3*0 + 2] *
02965 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02966
02967 top_rsclr =
02968 shadow_table[shade_index + 3*0 + 0] *
02969 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02970
02971 top_gsclr =
02972 shadow_table[shade_index + 3*0 + 1] *
02973 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02974
02975 top_bsclr =
02976 shadow_table[shade_index + 3*0 + 2] *
02977 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
02978 for (m = 1; m < num_materials; m++) {
02979
02980
02981 top_rclr +=
02982 shade_table[shade_index + 3*m + 0] *
02983 weight_table[weight_index + m];
02984
02985 top_gclr +=
02986 shade_table[shade_index + 3*m + 1] *
02987 weight_table[weight_index + m];
02988
02989 top_bclr +=
02990 shade_table[shade_index + 3*m + 2] *
02991 weight_table[weight_index + m];
02992
02993 top_rsclr +=
02994 shadow_table[shade_index + 3*m + 0] *
02995 weight_table[weight_index + m];
02996
02997 top_gsclr +=
02998 shadow_table[shade_index + 3*m + 1] *
02999 weight_table[weight_index + m];
03000
03001 top_bsclr +=
03002 shadow_table[shade_index + 3*m + 2] *
03003 weight_table[weight_index + m];
03004 };
03005 shade_factor = top_opc * slice_depth_cueing;
03006
03007 top_rclr *= shade_factor;
03008 top_gclr *= shade_factor;
03009 top_bclr *= shade_factor;
03010
03011 top_rsclr *= shade_factor;
03012 top_gsclr *= shade_factor;
03013 top_bsclr *= shade_factor;
03014
03015 acc_opc += top_opc * wgtTR;
03016
03017 acc_rclr += (top_rclr + top_rsclr *
03018 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
03019 acc_gclr += (top_gclr + top_gsclr *
03020 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
03021 acc_bclr += (top_bclr + top_bsclr *
03022 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
03023
03024 #ifdef DEBUG
03025 if (ipixel == trace_pixel_ptr) {
03026 trace_opcTR = top_opc;
03027 trace_rclrTR = top_rclr;
03028 trace_gclrTR = top_gclr;
03029 trace_bclrTR = top_bclr;
03030
03031 }
03032 #endif
03033 ;
03034
03035 COUNT_RESAMPLE;
03036 if (acc_opc > min_opacity) {
03037 COUNT_COMPOSITE;
03038 iopc = ipixel->opcflt;
03039 # ifndef SKIP_ERT
03040 ASSERT(iopc < max_opacity);
03041 # endif
03042 iopc_inv = (float)1. - iopc;
03043
03044 ipixel->rclrflt += acc_rclr * iopc_inv;
03045 ipixel->gclrflt += acc_gclr * iopc_inv;
03046 ipixel->bclrflt += acc_bclr * iopc_inv;
03047 iopc += acc_opc * iopc_inv;
03048 ipixel->opcflt = iopc;
03049
03050 #ifdef DEBUG
03051 if (ipixel == trace_pixel_ptr) {
03052 #ifdef COMPUTE_SHADOW_BUFFER
03053 printf("{%3d} %3d %3d", k, icount-i-count, j);
03054 #else
03055 printf("[%3d] %3d %3d", k, icount-i-count, j);
03056 #endif
03057 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03058 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03059 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03060 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03061 printf(" %3.0f %3.0f\n", iopc*255.,
03062 ipixel->rclrflt);
03063
03064 printf(" ");
03065 printf(" %3.0f ",trace_rsclrTL);
03066 printf(" %3.0f ",trace_rsclrBL);
03067 printf(" %3.0f ",trace_rsclrTR);
03068 printf(" %3.0f ",trace_rsclrBR);
03069 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
03070
03071 printf(" ");
03072 printf(" %3.0f ",trace_gclrTL);
03073 printf(" %3.0f ",trace_gclrBL);
03074 printf(" %3.0f ",trace_gclrTR);
03075 printf(" %3.0f ",trace_gclrBR);
03076 printf(" %3.0f\n", ipixel->gclrflt);
03077 printf(" ");
03078 printf(" %3.0f ",trace_bclrTL);
03079 printf(" %3.0f ",trace_bclrBL);
03080 printf(" %3.0f ",trace_bclrTR);
03081 printf(" %3.0f ",trace_bclrBR);
03082 printf(" %3.0f\n", ipixel->bclrflt);
03083 }
03084 #endif
03085 ;
03086 # ifndef SKIP_ERT
03087 if (iopc >= max_opacity) {
03088 ASSERT(ipixel->lnk == 0);
03089 ipixel->lnk = 1;
03090 }
03091 # endif
03092 };
03093 ipixel += 1; shadow_pixel += 1;
03094 topRLEdata += 1 * voxel_istride;
03095 ;
03096 count--;
03097 SET_VOXELS_LOADED;
03098
03099
03100
03101 while (count > 0) {
03102 if (PIXEL_IS_OPAQUE(ipixel))
03103 break;
03104 if (!voxels_loaded) {
03105
03106 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03107
03108
03109 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
03110 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
03111
03112
03113
03114 top_rclr =
03115 shade_table[shade_index + 3*0 + 0] *
03116 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03117
03118 top_gclr =
03119 shade_table[shade_index + 3*0 + 1] *
03120 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03121
03122 top_bclr =
03123 shade_table[shade_index + 3*0 + 2] *
03124 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03125
03126 top_rsclr =
03127 shadow_table[shade_index + 3*0 + 0] *
03128 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03129
03130 top_gsclr =
03131 shadow_table[shade_index + 3*0 + 1] *
03132 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03133
03134 top_bsclr =
03135 shadow_table[shade_index + 3*0 + 2] *
03136 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03137 for (m = 1; m < num_materials; m++) {
03138
03139
03140 top_rclr +=
03141 shade_table[shade_index + 3*m + 0] *
03142 weight_table[weight_index + m];
03143
03144 top_gclr +=
03145 shade_table[shade_index + 3*m + 1] *
03146 weight_table[weight_index + m];
03147
03148 top_bclr +=
03149 shade_table[shade_index + 3*m + 2] *
03150 weight_table[weight_index + m];
03151
03152 top_rsclr +=
03153 shadow_table[shade_index + 3*m + 0] *
03154 weight_table[weight_index + m];
03155
03156 top_gsclr +=
03157 shadow_table[shade_index + 3*m + 1] *
03158 weight_table[weight_index + m];
03159
03160 top_bsclr +=
03161 shadow_table[shade_index + 3*m + 2] *
03162 weight_table[weight_index + m];
03163 };
03164 shade_factor = top_opc * slice_depth_cueing;
03165
03166 top_rclr *= shade_factor;
03167 top_gclr *= shade_factor;
03168 top_bclr *= shade_factor;
03169
03170 top_rsclr *= shade_factor;
03171 top_gsclr *= shade_factor;
03172 top_bsclr *= shade_factor;
03173 }
03174
03175 #ifdef DEBUG
03176 if (ipixel == trace_pixel_ptr) {
03177 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03178 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03179 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03180 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03181 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03182 }
03183 #endif
03184 ;
03185
03186 acc_opc = top_opc * wgtTL;
03187
03188 acc_rclr = (top_rclr + top_rsclr *
03189 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
03190 acc_gclr = (top_gclr + top_gsclr *
03191 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
03192 acc_bclr = (top_bclr + top_bsclr *
03193 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
03194
03195 #ifdef DEBUG
03196 if (ipixel == trace_pixel_ptr) {
03197 trace_opcTL = top_opc;
03198 trace_rclrTL = top_rclr;
03199 trace_gclrTL = top_gclr;
03200 trace_bclrTL = top_bclr;
03201
03202 }
03203 #endif
03204 ;
03205
03206 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
03207
03208
03209 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
03210 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
03211
03212
03213
03214 top_rclr =
03215 shade_table[shade_index + 3*0 + 0] *
03216 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03217
03218 top_gclr =
03219 shade_table[shade_index + 3*0 + 1] *
03220 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03221
03222 top_bclr =
03223 shade_table[shade_index + 3*0 + 2] *
03224 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03225
03226 top_rsclr =
03227 shadow_table[shade_index + 3*0 + 0] *
03228 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03229
03230 top_gsclr =
03231 shadow_table[shade_index + 3*0 + 1] *
03232 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03233
03234 top_bsclr =
03235 shadow_table[shade_index + 3*0 + 2] *
03236 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03237 for (m = 1; m < num_materials; m++) {
03238
03239
03240 top_rclr +=
03241 shade_table[shade_index + 3*m + 0] *
03242 weight_table[weight_index + m];
03243
03244 top_gclr +=
03245 shade_table[shade_index + 3*m + 1] *
03246 weight_table[weight_index + m];
03247
03248 top_bclr +=
03249 shade_table[shade_index + 3*m + 2] *
03250 weight_table[weight_index + m];
03251
03252 top_rsclr +=
03253 shadow_table[shade_index + 3*m + 0] *
03254 weight_table[weight_index + m];
03255
03256 top_gsclr +=
03257 shadow_table[shade_index + 3*m + 1] *
03258 weight_table[weight_index + m];
03259
03260 top_bsclr +=
03261 shadow_table[shade_index + 3*m + 2] *
03262 weight_table[weight_index + m];
03263 };
03264 shade_factor = top_opc * slice_depth_cueing;
03265
03266 top_rclr *= shade_factor;
03267 top_gclr *= shade_factor;
03268 top_bclr *= shade_factor;
03269
03270 top_rsclr *= shade_factor;
03271 top_gsclr *= shade_factor;
03272 top_bsclr *= shade_factor;
03273
03274 acc_opc += top_opc * wgtTR;
03275
03276 acc_rclr += (top_rclr + top_rsclr *
03277 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
03278 acc_gclr += (top_gclr + top_gsclr *
03279 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
03280 acc_bclr += (top_bclr + top_bsclr *
03281 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
03282
03283 #ifdef DEBUG
03284 if (ipixel == trace_pixel_ptr) {
03285 trace_opcTR = top_opc;
03286 trace_rclrTR = top_rclr;
03287 trace_gclrTR = top_gclr;
03288 trace_bclrTR = top_bclr;
03289
03290 }
03291 #endif
03292 ;
03293
03294 COUNT_RESAMPLE;
03295 if (acc_opc > min_opacity) {
03296 COUNT_COMPOSITE;
03297 iopc = ipixel->opcflt;
03298 # ifndef SKIP_ERT
03299 ASSERT(iopc < max_opacity);
03300 # endif
03301 iopc_inv = (float)1. - iopc;
03302
03303 ipixel->rclrflt += acc_rclr * iopc_inv;
03304 ipixel->gclrflt += acc_gclr * iopc_inv;
03305 ipixel->bclrflt += acc_bclr * iopc_inv;
03306 iopc += acc_opc * iopc_inv;
03307 ipixel->opcflt = iopc;
03308
03309 #ifdef DEBUG
03310 if (ipixel == trace_pixel_ptr) {
03311 #ifdef COMPUTE_SHADOW_BUFFER
03312 printf("{%3d} %3d %3d", k, icount-i-count, j);
03313 #else
03314 printf("[%3d] %3d %3d", k, icount-i-count, j);
03315 #endif
03316 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03317 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03318 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03319 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03320 printf(" %3.0f %3.0f\n", iopc*255.,
03321 ipixel->rclrflt);
03322
03323 printf(" ");
03324 printf(" %3.0f ",trace_rsclrTL);
03325 printf(" %3.0f ",trace_rsclrBL);
03326 printf(" %3.0f ",trace_rsclrTR);
03327 printf(" %3.0f ",trace_rsclrBR);
03328 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
03329
03330 printf(" ");
03331 printf(" %3.0f ",trace_gclrTL);
03332 printf(" %3.0f ",trace_gclrBL);
03333 printf(" %3.0f ",trace_gclrTR);
03334 printf(" %3.0f ",trace_gclrBR);
03335 printf(" %3.0f\n", ipixel->gclrflt);
03336 printf(" ");
03337 printf(" %3.0f ",trace_bclrTL);
03338 printf(" %3.0f ",trace_bclrBL);
03339 printf(" %3.0f ",trace_bclrTR);
03340 printf(" %3.0f ",trace_bclrBR);
03341 printf(" %3.0f\n", ipixel->bclrflt);
03342 }
03343 #endif
03344 ;
03345 # ifndef SKIP_ERT
03346 if (iopc >= max_opacity) {
03347 ASSERT(ipixel->lnk == 0);
03348 ipixel->lnk = 1;
03349 }
03350 # endif
03351 };
03352 ipixel += 1; shadow_pixel += 1;
03353 topRLEdata += 1 * voxel_istride;
03354 ;
03355 count--;
03356 SET_VOXELS_LOADED;
03357 }
03358 break;
03359 case ALL_ZERO__BOT_NONZERO:
03360
03361
03362 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03363
03364
03365 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
03366 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03367
03368
03369
03370 bot_rclr =
03371 shade_table[shade_index + 3*0 + 0] *
03372 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03373
03374 bot_gclr =
03375 shade_table[shade_index + 3*0 + 1] *
03376 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03377
03378 bot_bclr =
03379 shade_table[shade_index + 3*0 + 2] *
03380 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03381
03382 bot_rsclr =
03383 shadow_table[shade_index + 3*0 + 0] *
03384 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03385
03386 bot_gsclr =
03387 shadow_table[shade_index + 3*0 + 1] *
03388 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03389
03390 bot_bsclr =
03391 shadow_table[shade_index + 3*0 + 2] *
03392 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03393 for (m = 1; m < num_materials; m++) {
03394
03395
03396 bot_rclr +=
03397 shade_table[shade_index + 3*m + 0] *
03398 weight_table[weight_index + m];
03399
03400 bot_gclr +=
03401 shade_table[shade_index + 3*m + 1] *
03402 weight_table[weight_index + m];
03403
03404 bot_bclr +=
03405 shade_table[shade_index + 3*m + 2] *
03406 weight_table[weight_index + m];
03407
03408 bot_rsclr +=
03409 shadow_table[shade_index + 3*m + 0] *
03410 weight_table[weight_index + m];
03411
03412 bot_gsclr +=
03413 shadow_table[shade_index + 3*m + 1] *
03414 weight_table[weight_index + m];
03415
03416 bot_bsclr +=
03417 shadow_table[shade_index + 3*m + 2] *
03418 weight_table[weight_index + m];
03419 };
03420 shade_factor = bot_opc * slice_depth_cueing;
03421
03422 bot_rclr *= shade_factor;
03423 bot_gclr *= shade_factor;
03424 bot_bclr *= shade_factor;
03425
03426 bot_rsclr *= shade_factor;
03427 bot_gsclr *= shade_factor;
03428 bot_bsclr *= shade_factor;
03429
03430 #ifdef DEBUG
03431 if (ipixel == trace_pixel_ptr) {
03432 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03433 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03434 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03435 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03436 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03437 }
03438 #endif
03439 ;
03440
03441 acc_opc = bot_opc * wgtBR;
03442
03443 acc_rclr = (bot_rclr + bot_rsclr *
03444 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03445 acc_gclr = (bot_gclr + bot_gsclr *
03446 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03447 acc_bclr = (bot_bclr + bot_bsclr *
03448 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03449
03450 #ifdef DEBUG
03451 if (ipixel == trace_pixel_ptr) {
03452 trace_opcBR = bot_opc;
03453 trace_rclrBR = bot_rclr;
03454 trace_gclrBR = bot_gclr;
03455 trace_bclrBR = bot_bclr;
03456
03457 }
03458 #endif
03459 ;
03460
03461 COUNT_RESAMPLE;
03462 if (acc_opc > min_opacity) {
03463 COUNT_COMPOSITE;
03464 iopc = ipixel->opcflt;
03465 # ifndef SKIP_ERT
03466 ASSERT(iopc < max_opacity);
03467 # endif
03468 iopc_inv = (float)1. - iopc;
03469
03470 ipixel->rclrflt += acc_rclr * iopc_inv;
03471 ipixel->gclrflt += acc_gclr * iopc_inv;
03472 ipixel->bclrflt += acc_bclr * iopc_inv;
03473 iopc += acc_opc * iopc_inv;
03474 ipixel->opcflt = iopc;
03475
03476 #ifdef DEBUG
03477 if (ipixel == trace_pixel_ptr) {
03478 #ifdef COMPUTE_SHADOW_BUFFER
03479 printf("{%3d} %3d %3d", k, icount-i-count, j);
03480 #else
03481 printf("[%3d] %3d %3d", k, icount-i-count, j);
03482 #endif
03483 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03484 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03485 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03486 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03487 printf(" %3.0f %3.0f\n", iopc*255.,
03488 ipixel->rclrflt);
03489
03490 printf(" ");
03491 printf(" %3.0f ",trace_rsclrTL);
03492 printf(" %3.0f ",trace_rsclrBL);
03493 printf(" %3.0f ",trace_rsclrTR);
03494 printf(" %3.0f ",trace_rsclrBR);
03495 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
03496
03497 printf(" ");
03498 printf(" %3.0f ",trace_gclrTL);
03499 printf(" %3.0f ",trace_gclrBL);
03500 printf(" %3.0f ",trace_gclrTR);
03501 printf(" %3.0f ",trace_gclrBR);
03502 printf(" %3.0f\n", ipixel->gclrflt);
03503 printf(" ");
03504 printf(" %3.0f ",trace_bclrTL);
03505 printf(" %3.0f ",trace_bclrBL);
03506 printf(" %3.0f ",trace_bclrTR);
03507 printf(" %3.0f ",trace_bclrBR);
03508 printf(" %3.0f\n", ipixel->bclrflt);
03509 }
03510 #endif
03511 ;
03512 # ifndef SKIP_ERT
03513 if (iopc >= max_opacity) {
03514 ASSERT(ipixel->lnk == 0);
03515 ipixel->lnk = 1;
03516 }
03517 # endif
03518 };
03519 ipixel += 1; shadow_pixel += 1;
03520 ;
03521 botRLEdata += 1 * voxel_istride;
03522 count--;
03523 SET_VOXELS_LOADED;
03524
03525
03526
03527 while (count > 0) {
03528 if (PIXEL_IS_OPAQUE(ipixel))
03529 break;
03530 if (!voxels_loaded) {
03531
03532 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03533
03534
03535 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
03536 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
03537
03538
03539
03540 bot_rclr =
03541 shade_table[shade_index + 3*0 + 0] *
03542 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03543
03544 bot_gclr =
03545 shade_table[shade_index + 3*0 + 1] *
03546 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03547
03548 bot_bclr =
03549 shade_table[shade_index + 3*0 + 2] *
03550 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03551
03552 bot_rsclr =
03553 shadow_table[shade_index + 3*0 + 0] *
03554 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03555
03556 bot_gsclr =
03557 shadow_table[shade_index + 3*0 + 1] *
03558 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03559
03560 bot_bsclr =
03561 shadow_table[shade_index + 3*0 + 2] *
03562 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03563 for (m = 1; m < num_materials; m++) {
03564
03565
03566 bot_rclr +=
03567 shade_table[shade_index + 3*m + 0] *
03568 weight_table[weight_index + m];
03569
03570 bot_gclr +=
03571 shade_table[shade_index + 3*m + 1] *
03572 weight_table[weight_index + m];
03573
03574 bot_bclr +=
03575 shade_table[shade_index + 3*m + 2] *
03576 weight_table[weight_index + m];
03577
03578 bot_rsclr +=
03579 shadow_table[shade_index + 3*m + 0] *
03580 weight_table[weight_index + m];
03581
03582 bot_gsclr +=
03583 shadow_table[shade_index + 3*m + 1] *
03584 weight_table[weight_index + m];
03585
03586 bot_bsclr +=
03587 shadow_table[shade_index + 3*m + 2] *
03588 weight_table[weight_index + m];
03589 };
03590 shade_factor = bot_opc * slice_depth_cueing;
03591
03592 bot_rclr *= shade_factor;
03593 bot_gclr *= shade_factor;
03594 bot_bclr *= shade_factor;
03595
03596 bot_rsclr *= shade_factor;
03597 bot_gsclr *= shade_factor;
03598 bot_bsclr *= shade_factor;
03599 }
03600
03601 #ifdef DEBUG
03602 if (ipixel == trace_pixel_ptr) {
03603 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03604 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03605 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03606 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03607 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03608 }
03609 #endif
03610 ;
03611
03612 acc_opc = bot_opc * wgtBL;
03613
03614 acc_rclr = (bot_rclr + bot_rsclr *
03615 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
03616 acc_gclr = (bot_gclr + bot_gsclr *
03617 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
03618 acc_bclr = (bot_bclr + bot_bsclr *
03619 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
03620
03621 #ifdef DEBUG
03622 if (ipixel == trace_pixel_ptr) {
03623 trace_opcBL = bot_opc;
03624 trace_rclrBL = bot_rclr;
03625 trace_gclrBL = bot_gclr;
03626 trace_bclrBL = bot_bclr;
03627
03628 }
03629 #endif
03630 ;
03631
03632 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03633
03634
03635 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
03636 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03637
03638
03639
03640 bot_rclr =
03641 shade_table[shade_index + 3*0 + 0] *
03642 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03643
03644 bot_gclr =
03645 shade_table[shade_index + 3*0 + 1] *
03646 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03647
03648 bot_bclr =
03649 shade_table[shade_index + 3*0 + 2] *
03650 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03651
03652 bot_rsclr =
03653 shadow_table[shade_index + 3*0 + 0] *
03654 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03655
03656 bot_gsclr =
03657 shadow_table[shade_index + 3*0 + 1] *
03658 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03659
03660 bot_bsclr =
03661 shadow_table[shade_index + 3*0 + 2] *
03662 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03663 for (m = 1; m < num_materials; m++) {
03664
03665
03666 bot_rclr +=
03667 shade_table[shade_index + 3*m + 0] *
03668 weight_table[weight_index + m];
03669
03670 bot_gclr +=
03671 shade_table[shade_index + 3*m + 1] *
03672 weight_table[weight_index + m];
03673
03674 bot_bclr +=
03675 shade_table[shade_index + 3*m + 2] *
03676 weight_table[weight_index + m];
03677
03678 bot_rsclr +=
03679 shadow_table[shade_index + 3*m + 0] *
03680 weight_table[weight_index + m];
03681
03682 bot_gsclr +=
03683 shadow_table[shade_index + 3*m + 1] *
03684 weight_table[weight_index + m];
03685
03686 bot_bsclr +=
03687 shadow_table[shade_index + 3*m + 2] *
03688 weight_table[weight_index + m];
03689 };
03690 shade_factor = bot_opc * slice_depth_cueing;
03691
03692 bot_rclr *= shade_factor;
03693 bot_gclr *= shade_factor;
03694 bot_bclr *= shade_factor;
03695
03696 bot_rsclr *= shade_factor;
03697 bot_gsclr *= shade_factor;
03698 bot_bsclr *= shade_factor;
03699
03700 acc_opc += bot_opc * wgtBR;
03701
03702 acc_rclr += (bot_rclr + bot_rsclr *
03703 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03704 acc_gclr += (bot_gclr + bot_gsclr *
03705 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03706 acc_bclr += (bot_bclr + bot_bsclr *
03707 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03708
03709 #ifdef DEBUG
03710 if (ipixel == trace_pixel_ptr) {
03711 trace_opcBR = bot_opc;
03712 trace_rclrBR = bot_rclr;
03713 trace_gclrBR = bot_gclr;
03714 trace_bclrBR = bot_bclr;
03715
03716 }
03717 #endif
03718 ;
03719
03720 COUNT_RESAMPLE;
03721 if (acc_opc > min_opacity) {
03722 COUNT_COMPOSITE;
03723 iopc = ipixel->opcflt;
03724 # ifndef SKIP_ERT
03725 ASSERT(iopc < max_opacity);
03726 # endif
03727 iopc_inv = (float)1. - iopc;
03728
03729 ipixel->rclrflt += acc_rclr * iopc_inv;
03730 ipixel->gclrflt += acc_gclr * iopc_inv;
03731 ipixel->bclrflt += acc_bclr * iopc_inv;
03732 iopc += acc_opc * iopc_inv;
03733 ipixel->opcflt = iopc;
03734
03735 #ifdef DEBUG
03736 if (ipixel == trace_pixel_ptr) {
03737 #ifdef COMPUTE_SHADOW_BUFFER
03738 printf("{%3d} %3d %3d", k, icount-i-count, j);
03739 #else
03740 printf("[%3d] %3d %3d", k, icount-i-count, j);
03741 #endif
03742 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03743 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03744 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03745 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03746 printf(" %3.0f %3.0f\n", iopc*255.,
03747 ipixel->rclrflt);
03748
03749 printf(" ");
03750 printf(" %3.0f ",trace_rsclrTL);
03751 printf(" %3.0f ",trace_rsclrBL);
03752 printf(" %3.0f ",trace_rsclrTR);
03753 printf(" %3.0f ",trace_rsclrBR);
03754 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
03755
03756 printf(" ");
03757 printf(" %3.0f ",trace_gclrTL);
03758 printf(" %3.0f ",trace_gclrBL);
03759 printf(" %3.0f ",trace_gclrTR);
03760 printf(" %3.0f ",trace_gclrBR);
03761 printf(" %3.0f\n", ipixel->gclrflt);
03762 printf(" ");
03763 printf(" %3.0f ",trace_bclrTL);
03764 printf(" %3.0f ",trace_bclrBL);
03765 printf(" %3.0f ",trace_bclrTR);
03766 printf(" %3.0f ",trace_bclrBR);
03767 printf(" %3.0f\n", ipixel->bclrflt);
03768 }
03769 #endif
03770 ;
03771 # ifndef SKIP_ERT
03772 if (iopc >= max_opacity) {
03773 ASSERT(ipixel->lnk == 0);
03774 ipixel->lnk = 1;
03775 }
03776 # endif
03777 };
03778 ipixel += 1; shadow_pixel += 1;
03779 ;
03780 botRLEdata += 1 * voxel_istride;
03781 count--;
03782 SET_VOXELS_LOADED;
03783 }
03784 break;
03785 case TOP_NONZERO__BOT_NONZERO:
03786
03787 if (!voxels_loaded) {
03788
03789 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03790
03791
03792 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
03793 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
03794
03795
03796
03797 top_rclr =
03798 shade_table[shade_index + 3*0 + 0] *
03799 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03800
03801 top_gclr =
03802 shade_table[shade_index + 3*0 + 1] *
03803 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03804
03805 top_bclr =
03806 shade_table[shade_index + 3*0 + 2] *
03807 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03808
03809 top_rsclr =
03810 shadow_table[shade_index + 3*0 + 0] *
03811 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03812
03813 top_gsclr =
03814 shadow_table[shade_index + 3*0 + 1] *
03815 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03816
03817 top_bsclr =
03818 shadow_table[shade_index + 3*0 + 2] *
03819 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03820 for (m = 1; m < num_materials; m++) {
03821
03822
03823 top_rclr +=
03824 shade_table[shade_index + 3*m + 0] *
03825 weight_table[weight_index + m];
03826
03827 top_gclr +=
03828 shade_table[shade_index + 3*m + 1] *
03829 weight_table[weight_index + m];
03830
03831 top_bclr +=
03832 shade_table[shade_index + 3*m + 2] *
03833 weight_table[weight_index + m];
03834
03835 top_rsclr +=
03836 shadow_table[shade_index + 3*m + 0] *
03837 weight_table[weight_index + m];
03838
03839 top_gsclr +=
03840 shadow_table[shade_index + 3*m + 1] *
03841 weight_table[weight_index + m];
03842
03843 top_bsclr +=
03844 shadow_table[shade_index + 3*m + 2] *
03845 weight_table[weight_index + m];
03846 };
03847 shade_factor = top_opc * slice_depth_cueing;
03848
03849 top_rclr *= shade_factor;
03850 top_gclr *= shade_factor;
03851 top_bclr *= shade_factor;
03852
03853 top_rsclr *= shade_factor;
03854 top_gsclr *= shade_factor;
03855 top_bsclr *= shade_factor;
03856 }
03857
03858 #ifdef DEBUG
03859 if (ipixel == trace_pixel_ptr) {
03860 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03861 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03862 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03863 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03864 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03865 }
03866 #endif
03867 ;
03868
03869 acc_opc = top_opc * wgtTL;
03870
03871 acc_rclr = (top_rclr + top_rsclr *
03872 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
03873 acc_gclr = (top_gclr + top_gsclr *
03874 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
03875 acc_bclr = (top_bclr + top_bsclr *
03876 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
03877
03878 #ifdef DEBUG
03879 if (ipixel == trace_pixel_ptr) {
03880 trace_opcTL = top_opc;
03881 trace_rclrTL = top_rclr;
03882 trace_gclrTL = top_gclr;
03883 trace_bclrTL = top_bclr;
03884
03885 }
03886 #endif
03887 ;
03888
03889 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03890
03891
03892 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
03893 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
03894
03895
03896
03897 bot_rclr =
03898 shade_table[shade_index + 3*0 + 0] *
03899 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03900
03901 bot_gclr =
03902 shade_table[shade_index + 3*0 + 1] *
03903 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03904
03905 bot_bclr =
03906 shade_table[shade_index + 3*0 + 2] *
03907 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03908
03909 bot_rsclr =
03910 shadow_table[shade_index + 3*0 + 0] *
03911 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03912
03913 bot_gsclr =
03914 shadow_table[shade_index + 3*0 + 1] *
03915 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03916
03917 bot_bsclr =
03918 shadow_table[shade_index + 3*0 + 2] *
03919 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
03920 for (m = 1; m < num_materials; m++) {
03921
03922
03923 bot_rclr +=
03924 shade_table[shade_index + 3*m + 0] *
03925 weight_table[weight_index + m];
03926
03927 bot_gclr +=
03928 shade_table[shade_index + 3*m + 1] *
03929 weight_table[weight_index + m];
03930
03931 bot_bclr +=
03932 shade_table[shade_index + 3*m + 2] *
03933 weight_table[weight_index + m];
03934
03935 bot_rsclr +=
03936 shadow_table[shade_index + 3*m + 0] *
03937 weight_table[weight_index + m];
03938
03939 bot_gsclr +=
03940 shadow_table[shade_index + 3*m + 1] *
03941 weight_table[weight_index + m];
03942
03943 bot_bsclr +=
03944 shadow_table[shade_index + 3*m + 2] *
03945 weight_table[weight_index + m];
03946 };
03947 shade_factor = bot_opc * slice_depth_cueing;
03948
03949 bot_rclr *= shade_factor;
03950 bot_gclr *= shade_factor;
03951 bot_bclr *= shade_factor;
03952
03953 bot_rsclr *= shade_factor;
03954 bot_gsclr *= shade_factor;
03955 bot_bsclr *= shade_factor;
03956
03957 acc_opc += bot_opc * wgtBR;
03958
03959 acc_rclr += (bot_rclr + bot_rsclr *
03960 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03961 acc_gclr += (bot_gclr + bot_gsclr *
03962 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03963 acc_bclr += (bot_bclr + bot_bsclr *
03964 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
03965
03966 #ifdef DEBUG
03967 if (ipixel == trace_pixel_ptr) {
03968 trace_opcBR = bot_opc;
03969 trace_rclrBR = bot_rclr;
03970 trace_gclrBR = bot_gclr;
03971 trace_bclrBR = bot_bclr;
03972
03973 }
03974 #endif
03975 ;
03976
03977 COUNT_RESAMPLE;
03978 if (acc_opc > min_opacity) {
03979 COUNT_COMPOSITE;
03980 iopc = ipixel->opcflt;
03981 # ifndef SKIP_ERT
03982 ASSERT(iopc < max_opacity);
03983 # endif
03984 iopc_inv = (float)1. - iopc;
03985
03986 ipixel->rclrflt += acc_rclr * iopc_inv;
03987 ipixel->gclrflt += acc_gclr * iopc_inv;
03988 ipixel->bclrflt += acc_bclr * iopc_inv;
03989 iopc += acc_opc * iopc_inv;
03990 ipixel->opcflt = iopc;
03991
03992 #ifdef DEBUG
03993 if (ipixel == trace_pixel_ptr) {
03994 #ifdef COMPUTE_SHADOW_BUFFER
03995 printf("{%3d} %3d %3d", k, icount-i-count, j);
03996 #else
03997 printf("[%3d] %3d %3d", k, icount-i-count, j);
03998 #endif
03999 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04000 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04001 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04002 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04003 printf(" %3.0f %3.0f\n", iopc*255.,
04004 ipixel->rclrflt);
04005
04006 printf(" ");
04007 printf(" %3.0f ",trace_rsclrTL);
04008 printf(" %3.0f ",trace_rsclrBL);
04009 printf(" %3.0f ",trace_rsclrTR);
04010 printf(" %3.0f ",trace_rsclrBR);
04011 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
04012
04013 printf(" ");
04014 printf(" %3.0f ",trace_gclrTL);
04015 printf(" %3.0f ",trace_gclrBL);
04016 printf(" %3.0f ",trace_gclrTR);
04017 printf(" %3.0f ",trace_gclrBR);
04018 printf(" %3.0f\n", ipixel->gclrflt);
04019 printf(" ");
04020 printf(" %3.0f ",trace_bclrTL);
04021 printf(" %3.0f ",trace_bclrBL);
04022 printf(" %3.0f ",trace_bclrTR);
04023 printf(" %3.0f ",trace_bclrBR);
04024 printf(" %3.0f\n", ipixel->bclrflt);
04025 }
04026 #endif
04027 ;
04028 # ifndef SKIP_ERT
04029 if (iopc >= max_opacity) {
04030 ASSERT(ipixel->lnk == 0);
04031 ipixel->lnk = 1;
04032 }
04033 # endif
04034 };
04035 ipixel += 1; shadow_pixel += 1;
04036 ;
04037 botRLEdata += 1 * voxel_istride;
04038 count--;
04039 SET_VOXELS_LOADED;
04040
04041
04042
04043 while (count > 0) {
04044 if (PIXEL_IS_OPAQUE(ipixel))
04045 break;
04046 if (!voxels_loaded) {
04047
04048 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04049
04050
04051 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
04052 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04053
04054
04055
04056 bot_rclr =
04057 shade_table[shade_index + 3*0 + 0] *
04058 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04059
04060 bot_gclr =
04061 shade_table[shade_index + 3*0 + 1] *
04062 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04063
04064 bot_bclr =
04065 shade_table[shade_index + 3*0 + 2] *
04066 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04067
04068 bot_rsclr =
04069 shadow_table[shade_index + 3*0 + 0] *
04070 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04071
04072 bot_gsclr =
04073 shadow_table[shade_index + 3*0 + 1] *
04074 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04075
04076 bot_bsclr =
04077 shadow_table[shade_index + 3*0 + 2] *
04078 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04079 for (m = 1; m < num_materials; m++) {
04080
04081
04082 bot_rclr +=
04083 shade_table[shade_index + 3*m + 0] *
04084 weight_table[weight_index + m];
04085
04086 bot_gclr +=
04087 shade_table[shade_index + 3*m + 1] *
04088 weight_table[weight_index + m];
04089
04090 bot_bclr +=
04091 shade_table[shade_index + 3*m + 2] *
04092 weight_table[weight_index + m];
04093
04094 bot_rsclr +=
04095 shadow_table[shade_index + 3*m + 0] *
04096 weight_table[weight_index + m];
04097
04098 bot_gsclr +=
04099 shadow_table[shade_index + 3*m + 1] *
04100 weight_table[weight_index + m];
04101
04102 bot_bsclr +=
04103 shadow_table[shade_index + 3*m + 2] *
04104 weight_table[weight_index + m];
04105 };
04106 shade_factor = bot_opc * slice_depth_cueing;
04107
04108 bot_rclr *= shade_factor;
04109 bot_gclr *= shade_factor;
04110 bot_bclr *= shade_factor;
04111
04112 bot_rsclr *= shade_factor;
04113 bot_gsclr *= shade_factor;
04114 bot_bsclr *= shade_factor;
04115 }
04116
04117 #ifdef DEBUG
04118 if (ipixel == trace_pixel_ptr) {
04119 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04120 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04121 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04122 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04123 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04124 }
04125 #endif
04126 ;
04127
04128 acc_opc = bot_opc * wgtBL;
04129
04130 acc_rclr = (bot_rclr + bot_rsclr *
04131 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04132 acc_gclr = (bot_gclr + bot_gsclr *
04133 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04134 acc_bclr = (bot_bclr + bot_bsclr *
04135 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04136
04137 #ifdef DEBUG
04138 if (ipixel == trace_pixel_ptr) {
04139 trace_opcBL = bot_opc;
04140 trace_rclrBL = bot_rclr;
04141 trace_gclrBL = bot_gclr;
04142 trace_bclrBL = bot_bclr;
04143
04144 }
04145 #endif
04146 ;
04147
04148 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04149
04150
04151 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
04152 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04153
04154
04155
04156 bot_rclr =
04157 shade_table[shade_index + 3*0 + 0] *
04158 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04159
04160 bot_gclr =
04161 shade_table[shade_index + 3*0 + 1] *
04162 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04163
04164 bot_bclr =
04165 shade_table[shade_index + 3*0 + 2] *
04166 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04167
04168 bot_rsclr =
04169 shadow_table[shade_index + 3*0 + 0] *
04170 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04171
04172 bot_gsclr =
04173 shadow_table[shade_index + 3*0 + 1] *
04174 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04175
04176 bot_bsclr =
04177 shadow_table[shade_index + 3*0 + 2] *
04178 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04179 for (m = 1; m < num_materials; m++) {
04180
04181
04182 bot_rclr +=
04183 shade_table[shade_index + 3*m + 0] *
04184 weight_table[weight_index + m];
04185
04186 bot_gclr +=
04187 shade_table[shade_index + 3*m + 1] *
04188 weight_table[weight_index + m];
04189
04190 bot_bclr +=
04191 shade_table[shade_index + 3*m + 2] *
04192 weight_table[weight_index + m];
04193
04194 bot_rsclr +=
04195 shadow_table[shade_index + 3*m + 0] *
04196 weight_table[weight_index + m];
04197
04198 bot_gsclr +=
04199 shadow_table[shade_index + 3*m + 1] *
04200 weight_table[weight_index + m];
04201
04202 bot_bsclr +=
04203 shadow_table[shade_index + 3*m + 2] *
04204 weight_table[weight_index + m];
04205 };
04206 shade_factor = bot_opc * slice_depth_cueing;
04207
04208 bot_rclr *= shade_factor;
04209 bot_gclr *= shade_factor;
04210 bot_bclr *= shade_factor;
04211
04212 bot_rsclr *= shade_factor;
04213 bot_gsclr *= shade_factor;
04214 bot_bsclr *= shade_factor;
04215
04216 acc_opc += bot_opc * wgtBR;
04217
04218 acc_rclr += (bot_rclr + bot_rsclr *
04219 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04220 acc_gclr += (bot_gclr + bot_gsclr *
04221 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04222 acc_bclr += (bot_bclr + bot_bsclr *
04223 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04224
04225 #ifdef DEBUG
04226 if (ipixel == trace_pixel_ptr) {
04227 trace_opcBR = bot_opc;
04228 trace_rclrBR = bot_rclr;
04229 trace_gclrBR = bot_gclr;
04230 trace_bclrBR = bot_bclr;
04231
04232 }
04233 #endif
04234 ;
04235
04236 COUNT_RESAMPLE;
04237 if (acc_opc > min_opacity) {
04238 COUNT_COMPOSITE;
04239 iopc = ipixel->opcflt;
04240 # ifndef SKIP_ERT
04241 ASSERT(iopc < max_opacity);
04242 # endif
04243 iopc_inv = (float)1. - iopc;
04244
04245 ipixel->rclrflt += acc_rclr * iopc_inv;
04246 ipixel->gclrflt += acc_gclr * iopc_inv;
04247 ipixel->bclrflt += acc_bclr * iopc_inv;
04248 iopc += acc_opc * iopc_inv;
04249 ipixel->opcflt = iopc;
04250
04251 #ifdef DEBUG
04252 if (ipixel == trace_pixel_ptr) {
04253 #ifdef COMPUTE_SHADOW_BUFFER
04254 printf("{%3d} %3d %3d", k, icount-i-count, j);
04255 #else
04256 printf("[%3d] %3d %3d", k, icount-i-count, j);
04257 #endif
04258 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04259 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04260 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04261 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04262 printf(" %3.0f %3.0f\n", iopc*255.,
04263 ipixel->rclrflt);
04264
04265 printf(" ");
04266 printf(" %3.0f ",trace_rsclrTL);
04267 printf(" %3.0f ",trace_rsclrBL);
04268 printf(" %3.0f ",trace_rsclrTR);
04269 printf(" %3.0f ",trace_rsclrBR);
04270 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
04271
04272 printf(" ");
04273 printf(" %3.0f ",trace_gclrTL);
04274 printf(" %3.0f ",trace_gclrBL);
04275 printf(" %3.0f ",trace_gclrTR);
04276 printf(" %3.0f ",trace_gclrBR);
04277 printf(" %3.0f\n", ipixel->gclrflt);
04278 printf(" ");
04279 printf(" %3.0f ",trace_bclrTL);
04280 printf(" %3.0f ",trace_bclrBL);
04281 printf(" %3.0f ",trace_bclrTR);
04282 printf(" %3.0f ",trace_bclrBR);
04283 printf(" %3.0f\n", ipixel->bclrflt);
04284 }
04285 #endif
04286 ;
04287 # ifndef SKIP_ERT
04288 if (iopc >= max_opacity) {
04289 ASSERT(ipixel->lnk == 0);
04290 ipixel->lnk = 1;
04291 }
04292 # endif
04293 };
04294 ipixel += 1; shadow_pixel += 1;
04295 ;
04296 botRLEdata += 1 * voxel_istride;
04297 count--;
04298 SET_VOXELS_LOADED;
04299 }
04300 break;
04301 case BOT_NONZERO__BOT_NONZERO:
04302
04303
04304 while (count > 0) {
04305 if (PIXEL_IS_OPAQUE(ipixel))
04306 break;
04307 if (!voxels_loaded) {
04308
04309 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04310
04311
04312 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
04313 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04314
04315
04316
04317 bot_rclr =
04318 shade_table[shade_index + 3*0 + 0] *
04319 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04320
04321 bot_gclr =
04322 shade_table[shade_index + 3*0 + 1] *
04323 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04324
04325 bot_bclr =
04326 shade_table[shade_index + 3*0 + 2] *
04327 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04328
04329 bot_rsclr =
04330 shadow_table[shade_index + 3*0 + 0] *
04331 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04332
04333 bot_gsclr =
04334 shadow_table[shade_index + 3*0 + 1] *
04335 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04336
04337 bot_bsclr =
04338 shadow_table[shade_index + 3*0 + 2] *
04339 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04340 for (m = 1; m < num_materials; m++) {
04341
04342
04343 bot_rclr +=
04344 shade_table[shade_index + 3*m + 0] *
04345 weight_table[weight_index + m];
04346
04347 bot_gclr +=
04348 shade_table[shade_index + 3*m + 1] *
04349 weight_table[weight_index + m];
04350
04351 bot_bclr +=
04352 shade_table[shade_index + 3*m + 2] *
04353 weight_table[weight_index + m];
04354
04355 bot_rsclr +=
04356 shadow_table[shade_index + 3*m + 0] *
04357 weight_table[weight_index + m];
04358
04359 bot_gsclr +=
04360 shadow_table[shade_index + 3*m + 1] *
04361 weight_table[weight_index + m];
04362
04363 bot_bsclr +=
04364 shadow_table[shade_index + 3*m + 2] *
04365 weight_table[weight_index + m];
04366 };
04367 shade_factor = bot_opc * slice_depth_cueing;
04368
04369 bot_rclr *= shade_factor;
04370 bot_gclr *= shade_factor;
04371 bot_bclr *= shade_factor;
04372
04373 bot_rsclr *= shade_factor;
04374 bot_gsclr *= shade_factor;
04375 bot_bsclr *= shade_factor;
04376 }
04377
04378 #ifdef DEBUG
04379 if (ipixel == trace_pixel_ptr) {
04380 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04381 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04382 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04383 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04384 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04385 }
04386 #endif
04387 ;
04388
04389 acc_opc = bot_opc * wgtBL;
04390
04391 acc_rclr = (bot_rclr + bot_rsclr *
04392 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04393 acc_gclr = (bot_gclr + bot_gsclr *
04394 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04395 acc_bclr = (bot_bclr + bot_bsclr *
04396 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04397
04398 #ifdef DEBUG
04399 if (ipixel == trace_pixel_ptr) {
04400 trace_opcBL = bot_opc;
04401 trace_rclrBL = bot_rclr;
04402 trace_gclrBL = bot_gclr;
04403 trace_bclrBL = bot_bclr;
04404
04405 }
04406 #endif
04407 ;
04408
04409 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04410
04411
04412 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
04413 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04414
04415
04416
04417 bot_rclr =
04418 shade_table[shade_index + 3*0 + 0] *
04419 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04420
04421 bot_gclr =
04422 shade_table[shade_index + 3*0 + 1] *
04423 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04424
04425 bot_bclr =
04426 shade_table[shade_index + 3*0 + 2] *
04427 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04428
04429 bot_rsclr =
04430 shadow_table[shade_index + 3*0 + 0] *
04431 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04432
04433 bot_gsclr =
04434 shadow_table[shade_index + 3*0 + 1] *
04435 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04436
04437 bot_bsclr =
04438 shadow_table[shade_index + 3*0 + 2] *
04439 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04440 for (m = 1; m < num_materials; m++) {
04441
04442
04443 bot_rclr +=
04444 shade_table[shade_index + 3*m + 0] *
04445 weight_table[weight_index + m];
04446
04447 bot_gclr +=
04448 shade_table[shade_index + 3*m + 1] *
04449 weight_table[weight_index + m];
04450
04451 bot_bclr +=
04452 shade_table[shade_index + 3*m + 2] *
04453 weight_table[weight_index + m];
04454
04455 bot_rsclr +=
04456 shadow_table[shade_index + 3*m + 0] *
04457 weight_table[weight_index + m];
04458
04459 bot_gsclr +=
04460 shadow_table[shade_index + 3*m + 1] *
04461 weight_table[weight_index + m];
04462
04463 bot_bsclr +=
04464 shadow_table[shade_index + 3*m + 2] *
04465 weight_table[weight_index + m];
04466 };
04467 shade_factor = bot_opc * slice_depth_cueing;
04468
04469 bot_rclr *= shade_factor;
04470 bot_gclr *= shade_factor;
04471 bot_bclr *= shade_factor;
04472
04473 bot_rsclr *= shade_factor;
04474 bot_gsclr *= shade_factor;
04475 bot_bsclr *= shade_factor;
04476
04477 acc_opc += bot_opc * wgtBR;
04478
04479 acc_rclr += (bot_rclr + bot_rsclr *
04480 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04481 acc_gclr += (bot_gclr + bot_gsclr *
04482 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04483 acc_bclr += (bot_bclr + bot_bsclr *
04484 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04485
04486 #ifdef DEBUG
04487 if (ipixel == trace_pixel_ptr) {
04488 trace_opcBR = bot_opc;
04489 trace_rclrBR = bot_rclr;
04490 trace_gclrBR = bot_gclr;
04491 trace_bclrBR = bot_bclr;
04492
04493 }
04494 #endif
04495 ;
04496
04497 COUNT_RESAMPLE;
04498 if (acc_opc > min_opacity) {
04499 COUNT_COMPOSITE;
04500 iopc = ipixel->opcflt;
04501 # ifndef SKIP_ERT
04502 ASSERT(iopc < max_opacity);
04503 # endif
04504 iopc_inv = (float)1. - iopc;
04505
04506 ipixel->rclrflt += acc_rclr * iopc_inv;
04507 ipixel->gclrflt += acc_gclr * iopc_inv;
04508 ipixel->bclrflt += acc_bclr * iopc_inv;
04509 iopc += acc_opc * iopc_inv;
04510 ipixel->opcflt = iopc;
04511
04512 #ifdef DEBUG
04513 if (ipixel == trace_pixel_ptr) {
04514 #ifdef COMPUTE_SHADOW_BUFFER
04515 printf("{%3d} %3d %3d", k, icount-i-count, j);
04516 #else
04517 printf("[%3d] %3d %3d", k, icount-i-count, j);
04518 #endif
04519 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04520 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04521 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04522 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04523 printf(" %3.0f %3.0f\n", iopc*255.,
04524 ipixel->rclrflt);
04525
04526 printf(" ");
04527 printf(" %3.0f ",trace_rsclrTL);
04528 printf(" %3.0f ",trace_rsclrBL);
04529 printf(" %3.0f ",trace_rsclrTR);
04530 printf(" %3.0f ",trace_rsclrBR);
04531 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
04532
04533 printf(" ");
04534 printf(" %3.0f ",trace_gclrTL);
04535 printf(" %3.0f ",trace_gclrBL);
04536 printf(" %3.0f ",trace_gclrTR);
04537 printf(" %3.0f ",trace_gclrBR);
04538 printf(" %3.0f\n", ipixel->gclrflt);
04539 printf(" ");
04540 printf(" %3.0f ",trace_bclrTL);
04541 printf(" %3.0f ",trace_bclrBL);
04542 printf(" %3.0f ",trace_bclrTR);
04543 printf(" %3.0f ",trace_bclrBR);
04544 printf(" %3.0f\n", ipixel->bclrflt);
04545 }
04546 #endif
04547 ;
04548 # ifndef SKIP_ERT
04549 if (iopc >= max_opacity) {
04550 ASSERT(ipixel->lnk == 0);
04551 ipixel->lnk = 1;
04552 }
04553 # endif
04554 };
04555 ipixel += 1; shadow_pixel += 1;
04556 ;
04557 botRLEdata += 1 * voxel_istride;
04558 count--;
04559 SET_VOXELS_LOADED;
04560 }
04561 break;
04562 case ALL_NONZERO__BOT_NONZERO:
04563
04564
04565 if (!voxels_loaded) {
04566
04567 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04568
04569
04570 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
04571 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
04572
04573
04574
04575 top_rclr =
04576 shade_table[shade_index + 3*0 + 0] *
04577 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04578
04579 top_gclr =
04580 shade_table[shade_index + 3*0 + 1] *
04581 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04582
04583 top_bclr =
04584 shade_table[shade_index + 3*0 + 2] *
04585 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04586
04587 top_rsclr =
04588 shadow_table[shade_index + 3*0 + 0] *
04589 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04590
04591 top_gsclr =
04592 shadow_table[shade_index + 3*0 + 1] *
04593 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04594
04595 top_bsclr =
04596 shadow_table[shade_index + 3*0 + 2] *
04597 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04598 for (m = 1; m < num_materials; m++) {
04599
04600
04601 top_rclr +=
04602 shade_table[shade_index + 3*m + 0] *
04603 weight_table[weight_index + m];
04604
04605 top_gclr +=
04606 shade_table[shade_index + 3*m + 1] *
04607 weight_table[weight_index + m];
04608
04609 top_bclr +=
04610 shade_table[shade_index + 3*m + 2] *
04611 weight_table[weight_index + m];
04612
04613 top_rsclr +=
04614 shadow_table[shade_index + 3*m + 0] *
04615 weight_table[weight_index + m];
04616
04617 top_gsclr +=
04618 shadow_table[shade_index + 3*m + 1] *
04619 weight_table[weight_index + m];
04620
04621 top_bsclr +=
04622 shadow_table[shade_index + 3*m + 2] *
04623 weight_table[weight_index + m];
04624 };
04625 shade_factor = top_opc * slice_depth_cueing;
04626
04627 top_rclr *= shade_factor;
04628 top_gclr *= shade_factor;
04629 top_bclr *= shade_factor;
04630
04631 top_rsclr *= shade_factor;
04632 top_gsclr *= shade_factor;
04633 top_bsclr *= shade_factor;
04634
04635 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04636
04637
04638 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
04639 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04640
04641
04642
04643 bot_rclr =
04644 shade_table[shade_index + 3*0 + 0] *
04645 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04646
04647 bot_gclr =
04648 shade_table[shade_index + 3*0 + 1] *
04649 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04650
04651 bot_bclr =
04652 shade_table[shade_index + 3*0 + 2] *
04653 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04654
04655 bot_rsclr =
04656 shadow_table[shade_index + 3*0 + 0] *
04657 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04658
04659 bot_gsclr =
04660 shadow_table[shade_index + 3*0 + 1] *
04661 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04662
04663 bot_bsclr =
04664 shadow_table[shade_index + 3*0 + 2] *
04665 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04666 for (m = 1; m < num_materials; m++) {
04667
04668
04669 bot_rclr +=
04670 shade_table[shade_index + 3*m + 0] *
04671 weight_table[weight_index + m];
04672
04673 bot_gclr +=
04674 shade_table[shade_index + 3*m + 1] *
04675 weight_table[weight_index + m];
04676
04677 bot_bclr +=
04678 shade_table[shade_index + 3*m + 2] *
04679 weight_table[weight_index + m];
04680
04681 bot_rsclr +=
04682 shadow_table[shade_index + 3*m + 0] *
04683 weight_table[weight_index + m];
04684
04685 bot_gsclr +=
04686 shadow_table[shade_index + 3*m + 1] *
04687 weight_table[weight_index + m];
04688
04689 bot_bsclr +=
04690 shadow_table[shade_index + 3*m + 2] *
04691 weight_table[weight_index + m];
04692 };
04693 shade_factor = bot_opc * slice_depth_cueing;
04694
04695 bot_rclr *= shade_factor;
04696 bot_gclr *= shade_factor;
04697 bot_bclr *= shade_factor;
04698
04699 bot_rsclr *= shade_factor;
04700 bot_gsclr *= shade_factor;
04701 bot_bsclr *= shade_factor;
04702 }
04703
04704 #ifdef DEBUG
04705 if (ipixel == trace_pixel_ptr) {
04706 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04707 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04708 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04709 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04710 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04711 }
04712 #endif
04713 ;
04714
04715 acc_opc = top_opc * wgtTL;
04716
04717 acc_rclr = (top_rclr + top_rsclr *
04718 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
04719 acc_gclr = (top_gclr + top_gsclr *
04720 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
04721 acc_bclr = (top_bclr + top_bsclr *
04722 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
04723
04724 #ifdef DEBUG
04725 if (ipixel == trace_pixel_ptr) {
04726 trace_opcTL = top_opc;
04727 trace_rclrTL = top_rclr;
04728 trace_gclrTL = top_gclr;
04729 trace_bclrTL = top_bclr;
04730
04731 }
04732 #endif
04733 ;
04734
04735 acc_opc += bot_opc * wgtBL;
04736
04737 acc_rclr += (bot_rclr + bot_rsclr *
04738 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04739 acc_gclr += (bot_gclr + bot_gsclr *
04740 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04741 acc_bclr += (bot_bclr + bot_bsclr *
04742 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04743
04744 #ifdef DEBUG
04745 if (ipixel == trace_pixel_ptr) {
04746 trace_opcBL = bot_opc;
04747 trace_rclrBL = bot_rclr;
04748 trace_gclrBL = bot_gclr;
04749 trace_bclrBL = bot_bclr;
04750
04751 }
04752 #endif
04753 ;
04754
04755 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04756
04757
04758 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
04759 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
04760
04761
04762
04763 bot_rclr =
04764 shade_table[shade_index + 3*0 + 0] *
04765 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04766
04767 bot_gclr =
04768 shade_table[shade_index + 3*0 + 1] *
04769 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04770
04771 bot_bclr =
04772 shade_table[shade_index + 3*0 + 2] *
04773 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04774
04775 bot_rsclr =
04776 shadow_table[shade_index + 3*0 + 0] *
04777 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04778
04779 bot_gsclr =
04780 shadow_table[shade_index + 3*0 + 1] *
04781 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04782
04783 bot_bsclr =
04784 shadow_table[shade_index + 3*0 + 2] *
04785 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04786 for (m = 1; m < num_materials; m++) {
04787
04788
04789 bot_rclr +=
04790 shade_table[shade_index + 3*m + 0] *
04791 weight_table[weight_index + m];
04792
04793 bot_gclr +=
04794 shade_table[shade_index + 3*m + 1] *
04795 weight_table[weight_index + m];
04796
04797 bot_bclr +=
04798 shade_table[shade_index + 3*m + 2] *
04799 weight_table[weight_index + m];
04800
04801 bot_rsclr +=
04802 shadow_table[shade_index + 3*m + 0] *
04803 weight_table[weight_index + m];
04804
04805 bot_gsclr +=
04806 shadow_table[shade_index + 3*m + 1] *
04807 weight_table[weight_index + m];
04808
04809 bot_bsclr +=
04810 shadow_table[shade_index + 3*m + 2] *
04811 weight_table[weight_index + m];
04812 };
04813 shade_factor = bot_opc * slice_depth_cueing;
04814
04815 bot_rclr *= shade_factor;
04816 bot_gclr *= shade_factor;
04817 bot_bclr *= shade_factor;
04818
04819 bot_rsclr *= shade_factor;
04820 bot_gsclr *= shade_factor;
04821 bot_bsclr *= shade_factor;
04822
04823 acc_opc += bot_opc * wgtBR;
04824
04825 acc_rclr += (bot_rclr + bot_rsclr *
04826 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04827 acc_gclr += (bot_gclr + bot_gsclr *
04828 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04829 acc_bclr += (bot_bclr + bot_bsclr *
04830 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
04831
04832 #ifdef DEBUG
04833 if (ipixel == trace_pixel_ptr) {
04834 trace_opcBR = bot_opc;
04835 trace_rclrBR = bot_rclr;
04836 trace_gclrBR = bot_gclr;
04837 trace_bclrBR = bot_bclr;
04838
04839 }
04840 #endif
04841 ;
04842
04843 COUNT_RESAMPLE;
04844 if (acc_opc > min_opacity) {
04845 COUNT_COMPOSITE;
04846 iopc = ipixel->opcflt;
04847 # ifndef SKIP_ERT
04848 ASSERT(iopc < max_opacity);
04849 # endif
04850 iopc_inv = (float)1. - iopc;
04851
04852 ipixel->rclrflt += acc_rclr * iopc_inv;
04853 ipixel->gclrflt += acc_gclr * iopc_inv;
04854 ipixel->bclrflt += acc_bclr * iopc_inv;
04855 iopc += acc_opc * iopc_inv;
04856 ipixel->opcflt = iopc;
04857
04858 #ifdef DEBUG
04859 if (ipixel == trace_pixel_ptr) {
04860 #ifdef COMPUTE_SHADOW_BUFFER
04861 printf("{%3d} %3d %3d", k, icount-i-count, j);
04862 #else
04863 printf("[%3d] %3d %3d", k, icount-i-count, j);
04864 #endif
04865 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04866 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04867 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04868 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04869 printf(" %3.0f %3.0f\n", iopc*255.,
04870 ipixel->rclrflt);
04871
04872 printf(" ");
04873 printf(" %3.0f ",trace_rsclrTL);
04874 printf(" %3.0f ",trace_rsclrBL);
04875 printf(" %3.0f ",trace_rsclrTR);
04876 printf(" %3.0f ",trace_rsclrBR);
04877 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
04878
04879 printf(" ");
04880 printf(" %3.0f ",trace_gclrTL);
04881 printf(" %3.0f ",trace_gclrBL);
04882 printf(" %3.0f ",trace_gclrTR);
04883 printf(" %3.0f ",trace_gclrBR);
04884 printf(" %3.0f\n", ipixel->gclrflt);
04885 printf(" ");
04886 printf(" %3.0f ",trace_bclrTL);
04887 printf(" %3.0f ",trace_bclrBL);
04888 printf(" %3.0f ",trace_bclrTR);
04889 printf(" %3.0f ",trace_bclrBR);
04890 printf(" %3.0f\n", ipixel->bclrflt);
04891 }
04892 #endif
04893 ;
04894 # ifndef SKIP_ERT
04895 if (iopc >= max_opacity) {
04896 ASSERT(ipixel->lnk == 0);
04897 ipixel->lnk = 1;
04898 }
04899 # endif
04900 };
04901 ipixel += 1; shadow_pixel += 1;
04902 ;
04903 botRLEdata += 1 * voxel_istride;
04904 count--;
04905 SET_VOXELS_LOADED;
04906
04907
04908
04909 while (count > 0) {
04910 if (PIXEL_IS_OPAQUE(ipixel))
04911 break;
04912 if (!voxels_loaded) {
04913
04914 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04915
04916
04917 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
04918 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
04919
04920
04921
04922 bot_rclr =
04923 shade_table[shade_index + 3*0 + 0] *
04924 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04925
04926 bot_gclr =
04927 shade_table[shade_index + 3*0 + 1] *
04928 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04929
04930 bot_bclr =
04931 shade_table[shade_index + 3*0 + 2] *
04932 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04933
04934 bot_rsclr =
04935 shadow_table[shade_index + 3*0 + 0] *
04936 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04937
04938 bot_gsclr =
04939 shadow_table[shade_index + 3*0 + 1] *
04940 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04941
04942 bot_bsclr =
04943 shadow_table[shade_index + 3*0 + 2] *
04944 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
04945 for (m = 1; m < num_materials; m++) {
04946
04947
04948 bot_rclr +=
04949 shade_table[shade_index + 3*m + 0] *
04950 weight_table[weight_index + m];
04951
04952 bot_gclr +=
04953 shade_table[shade_index + 3*m + 1] *
04954 weight_table[weight_index + m];
04955
04956 bot_bclr +=
04957 shade_table[shade_index + 3*m + 2] *
04958 weight_table[weight_index + m];
04959
04960 bot_rsclr +=
04961 shadow_table[shade_index + 3*m + 0] *
04962 weight_table[weight_index + m];
04963
04964 bot_gsclr +=
04965 shadow_table[shade_index + 3*m + 1] *
04966 weight_table[weight_index + m];
04967
04968 bot_bsclr +=
04969 shadow_table[shade_index + 3*m + 2] *
04970 weight_table[weight_index + m];
04971 };
04972 shade_factor = bot_opc * slice_depth_cueing;
04973
04974 bot_rclr *= shade_factor;
04975 bot_gclr *= shade_factor;
04976 bot_bclr *= shade_factor;
04977
04978 bot_rsclr *= shade_factor;
04979 bot_gsclr *= shade_factor;
04980 bot_bsclr *= shade_factor;
04981 }
04982
04983 #ifdef DEBUG
04984 if (ipixel == trace_pixel_ptr) {
04985 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04986 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04987 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04988 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04989 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04990 }
04991 #endif
04992 ;
04993
04994 acc_opc = bot_opc * wgtBL;
04995
04996 acc_rclr = (bot_rclr + bot_rsclr *
04997 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
04998 acc_gclr = (bot_gclr + bot_gsclr *
04999 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
05000 acc_bclr = (bot_bclr + bot_bsclr *
05001 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
05002
05003 #ifdef DEBUG
05004 if (ipixel == trace_pixel_ptr) {
05005 trace_opcBL = bot_opc;
05006 trace_rclrBL = bot_rclr;
05007 trace_gclrBL = bot_gclr;
05008 trace_bclrBL = bot_bclr;
05009
05010 }
05011 #endif
05012 ;
05013
05014 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
05015
05016
05017 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
05018 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
05019
05020
05021
05022 bot_rclr =
05023 shade_table[shade_index + 3*0 + 0] *
05024 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05025
05026 bot_gclr =
05027 shade_table[shade_index + 3*0 + 1] *
05028 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05029
05030 bot_bclr =
05031 shade_table[shade_index + 3*0 + 2] *
05032 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05033
05034 bot_rsclr =
05035 shadow_table[shade_index + 3*0 + 0] *
05036 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05037
05038 bot_gsclr =
05039 shadow_table[shade_index + 3*0 + 1] *
05040 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05041
05042 bot_bsclr =
05043 shadow_table[shade_index + 3*0 + 2] *
05044 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05045 for (m = 1; m < num_materials; m++) {
05046
05047
05048 bot_rclr +=
05049 shade_table[shade_index + 3*m + 0] *
05050 weight_table[weight_index + m];
05051
05052 bot_gclr +=
05053 shade_table[shade_index + 3*m + 1] *
05054 weight_table[weight_index + m];
05055
05056 bot_bclr +=
05057 shade_table[shade_index + 3*m + 2] *
05058 weight_table[weight_index + m];
05059
05060 bot_rsclr +=
05061 shadow_table[shade_index + 3*m + 0] *
05062 weight_table[weight_index + m];
05063
05064 bot_gsclr +=
05065 shadow_table[shade_index + 3*m + 1] *
05066 weight_table[weight_index + m];
05067
05068 bot_bsclr +=
05069 shadow_table[shade_index + 3*m + 2] *
05070 weight_table[weight_index + m];
05071 };
05072 shade_factor = bot_opc * slice_depth_cueing;
05073
05074 bot_rclr *= shade_factor;
05075 bot_gclr *= shade_factor;
05076 bot_bclr *= shade_factor;
05077
05078 bot_rsclr *= shade_factor;
05079 bot_gsclr *= shade_factor;
05080 bot_bsclr *= shade_factor;
05081
05082 acc_opc += bot_opc * wgtBR;
05083
05084 acc_rclr += (bot_rclr + bot_rsclr *
05085 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05086 acc_gclr += (bot_gclr + bot_gsclr *
05087 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05088 acc_bclr += (bot_bclr + bot_bsclr *
05089 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05090
05091 #ifdef DEBUG
05092 if (ipixel == trace_pixel_ptr) {
05093 trace_opcBR = bot_opc;
05094 trace_rclrBR = bot_rclr;
05095 trace_gclrBR = bot_gclr;
05096 trace_bclrBR = bot_bclr;
05097
05098 }
05099 #endif
05100 ;
05101
05102 COUNT_RESAMPLE;
05103 if (acc_opc > min_opacity) {
05104 COUNT_COMPOSITE;
05105 iopc = ipixel->opcflt;
05106 # ifndef SKIP_ERT
05107 ASSERT(iopc < max_opacity);
05108 # endif
05109 iopc_inv = (float)1. - iopc;
05110
05111 ipixel->rclrflt += acc_rclr * iopc_inv;
05112 ipixel->gclrflt += acc_gclr * iopc_inv;
05113 ipixel->bclrflt += acc_bclr * iopc_inv;
05114 iopc += acc_opc * iopc_inv;
05115 ipixel->opcflt = iopc;
05116
05117 #ifdef DEBUG
05118 if (ipixel == trace_pixel_ptr) {
05119 #ifdef COMPUTE_SHADOW_BUFFER
05120 printf("{%3d} %3d %3d", k, icount-i-count, j);
05121 #else
05122 printf("[%3d] %3d %3d", k, icount-i-count, j);
05123 #endif
05124 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05125 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05126 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05127 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05128 printf(" %3.0f %3.0f\n", iopc*255.,
05129 ipixel->rclrflt);
05130
05131 printf(" ");
05132 printf(" %3.0f ",trace_rsclrTL);
05133 printf(" %3.0f ",trace_rsclrBL);
05134 printf(" %3.0f ",trace_rsclrTR);
05135 printf(" %3.0f ",trace_rsclrBR);
05136 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
05137
05138 printf(" ");
05139 printf(" %3.0f ",trace_gclrTL);
05140 printf(" %3.0f ",trace_gclrBL);
05141 printf(" %3.0f ",trace_gclrTR);
05142 printf(" %3.0f ",trace_gclrBR);
05143 printf(" %3.0f\n", ipixel->gclrflt);
05144 printf(" ");
05145 printf(" %3.0f ",trace_bclrTL);
05146 printf(" %3.0f ",trace_bclrBL);
05147 printf(" %3.0f ",trace_bclrTR);
05148 printf(" %3.0f ",trace_bclrBR);
05149 printf(" %3.0f\n", ipixel->bclrflt);
05150 }
05151 #endif
05152 ;
05153 # ifndef SKIP_ERT
05154 if (iopc >= max_opacity) {
05155 ASSERT(ipixel->lnk == 0);
05156 ipixel->lnk = 1;
05157 }
05158 # endif
05159 };
05160 ipixel += 1; shadow_pixel += 1;
05161 ;
05162 botRLEdata += 1 * voxel_istride;
05163 count--;
05164 SET_VOXELS_LOADED;
05165 }
05166 break;
05167 case ALL_ZERO__ALL_NONZERO:
05168
05169
05170 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
05171
05172
05173 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
05174 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
05175
05176
05177
05178 top_rclr =
05179 shade_table[shade_index + 3*0 + 0] *
05180 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05181
05182 top_gclr =
05183 shade_table[shade_index + 3*0 + 1] *
05184 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05185
05186 top_bclr =
05187 shade_table[shade_index + 3*0 + 2] *
05188 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05189
05190 top_rsclr =
05191 shadow_table[shade_index + 3*0 + 0] *
05192 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05193
05194 top_gsclr =
05195 shadow_table[shade_index + 3*0 + 1] *
05196 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05197
05198 top_bsclr =
05199 shadow_table[shade_index + 3*0 + 2] *
05200 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05201 for (m = 1; m < num_materials; m++) {
05202
05203
05204 top_rclr +=
05205 shade_table[shade_index + 3*m + 0] *
05206 weight_table[weight_index + m];
05207
05208 top_gclr +=
05209 shade_table[shade_index + 3*m + 1] *
05210 weight_table[weight_index + m];
05211
05212 top_bclr +=
05213 shade_table[shade_index + 3*m + 2] *
05214 weight_table[weight_index + m];
05215
05216 top_rsclr +=
05217 shadow_table[shade_index + 3*m + 0] *
05218 weight_table[weight_index + m];
05219
05220 top_gsclr +=
05221 shadow_table[shade_index + 3*m + 1] *
05222 weight_table[weight_index + m];
05223
05224 top_bsclr +=
05225 shadow_table[shade_index + 3*m + 2] *
05226 weight_table[weight_index + m];
05227 };
05228 shade_factor = top_opc * slice_depth_cueing;
05229
05230 top_rclr *= shade_factor;
05231 top_gclr *= shade_factor;
05232 top_bclr *= shade_factor;
05233
05234 top_rsclr *= shade_factor;
05235 top_gsclr *= shade_factor;
05236 top_bsclr *= shade_factor;
05237
05238 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
05239
05240
05241 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
05242 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
05243
05244
05245
05246 bot_rclr =
05247 shade_table[shade_index + 3*0 + 0] *
05248 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05249
05250 bot_gclr =
05251 shade_table[shade_index + 3*0 + 1] *
05252 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05253
05254 bot_bclr =
05255 shade_table[shade_index + 3*0 + 2] *
05256 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05257
05258 bot_rsclr =
05259 shadow_table[shade_index + 3*0 + 0] *
05260 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05261
05262 bot_gsclr =
05263 shadow_table[shade_index + 3*0 + 1] *
05264 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05265
05266 bot_bsclr =
05267 shadow_table[shade_index + 3*0 + 2] *
05268 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05269 for (m = 1; m < num_materials; m++) {
05270
05271
05272 bot_rclr +=
05273 shade_table[shade_index + 3*m + 0] *
05274 weight_table[weight_index + m];
05275
05276 bot_gclr +=
05277 shade_table[shade_index + 3*m + 1] *
05278 weight_table[weight_index + m];
05279
05280 bot_bclr +=
05281 shade_table[shade_index + 3*m + 2] *
05282 weight_table[weight_index + m];
05283
05284 bot_rsclr +=
05285 shadow_table[shade_index + 3*m + 0] *
05286 weight_table[weight_index + m];
05287
05288 bot_gsclr +=
05289 shadow_table[shade_index + 3*m + 1] *
05290 weight_table[weight_index + m];
05291
05292 bot_bsclr +=
05293 shadow_table[shade_index + 3*m + 2] *
05294 weight_table[weight_index + m];
05295 };
05296 shade_factor = bot_opc * slice_depth_cueing;
05297
05298 bot_rclr *= shade_factor;
05299 bot_gclr *= shade_factor;
05300 bot_bclr *= shade_factor;
05301
05302 bot_rsclr *= shade_factor;
05303 bot_gsclr *= shade_factor;
05304 bot_bsclr *= shade_factor;
05305
05306 #ifdef DEBUG
05307 if (ipixel == trace_pixel_ptr) {
05308 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05309 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05310 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05311 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05312 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05313 }
05314 #endif
05315 ;
05316
05317 acc_opc = top_opc * wgtTR;
05318
05319 acc_rclr = (top_rclr + top_rsclr *
05320 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
05321 acc_gclr = (top_gclr + top_gsclr *
05322 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
05323 acc_bclr = (top_bclr + top_bsclr *
05324 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
05325
05326 #ifdef DEBUG
05327 if (ipixel == trace_pixel_ptr) {
05328 trace_opcTR = top_opc;
05329 trace_rclrTR = top_rclr;
05330 trace_gclrTR = top_gclr;
05331 trace_bclrTR = top_bclr;
05332
05333 }
05334 #endif
05335 ;
05336
05337 acc_opc += bot_opc * wgtBR;
05338
05339 acc_rclr += (bot_rclr + bot_rsclr *
05340 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05341 acc_gclr += (bot_gclr + bot_gsclr *
05342 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05343 acc_bclr += (bot_bclr + bot_bsclr *
05344 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05345
05346 #ifdef DEBUG
05347 if (ipixel == trace_pixel_ptr) {
05348 trace_opcBR = bot_opc;
05349 trace_rclrBR = bot_rclr;
05350 trace_gclrBR = bot_gclr;
05351 trace_bclrBR = bot_bclr;
05352
05353 }
05354 #endif
05355 ;
05356
05357 COUNT_RESAMPLE;
05358 if (acc_opc > min_opacity) {
05359 COUNT_COMPOSITE;
05360 iopc = ipixel->opcflt;
05361 # ifndef SKIP_ERT
05362 ASSERT(iopc < max_opacity);
05363 # endif
05364 iopc_inv = (float)1. - iopc;
05365
05366 ipixel->rclrflt += acc_rclr * iopc_inv;
05367 ipixel->gclrflt += acc_gclr * iopc_inv;
05368 ipixel->bclrflt += acc_bclr * iopc_inv;
05369 iopc += acc_opc * iopc_inv;
05370 ipixel->opcflt = iopc;
05371
05372 #ifdef DEBUG
05373 if (ipixel == trace_pixel_ptr) {
05374 #ifdef COMPUTE_SHADOW_BUFFER
05375 printf("{%3d} %3d %3d", k, icount-i-count, j);
05376 #else
05377 printf("[%3d] %3d %3d", k, icount-i-count, j);
05378 #endif
05379 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05380 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05381 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05382 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05383 printf(" %3.0f %3.0f\n", iopc*255.,
05384 ipixel->rclrflt);
05385
05386 printf(" ");
05387 printf(" %3.0f ",trace_rsclrTL);
05388 printf(" %3.0f ",trace_rsclrBL);
05389 printf(" %3.0f ",trace_rsclrTR);
05390 printf(" %3.0f ",trace_rsclrBR);
05391 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
05392
05393 printf(" ");
05394 printf(" %3.0f ",trace_gclrTL);
05395 printf(" %3.0f ",trace_gclrBL);
05396 printf(" %3.0f ",trace_gclrTR);
05397 printf(" %3.0f ",trace_gclrBR);
05398 printf(" %3.0f\n", ipixel->gclrflt);
05399 printf(" ");
05400 printf(" %3.0f ",trace_bclrTL);
05401 printf(" %3.0f ",trace_bclrBL);
05402 printf(" %3.0f ",trace_bclrTR);
05403 printf(" %3.0f ",trace_bclrBR);
05404 printf(" %3.0f\n", ipixel->bclrflt);
05405 }
05406 #endif
05407 ;
05408 # ifndef SKIP_ERT
05409 if (iopc >= max_opacity) {
05410 ASSERT(ipixel->lnk == 0);
05411 ipixel->lnk = 1;
05412 }
05413 # endif
05414 };
05415 ipixel += 1; shadow_pixel += 1;
05416 topRLEdata += 1 * voxel_istride;
05417 botRLEdata += 1 * voxel_istride;
05418 count--;
05419 SET_VOXELS_LOADED;
05420
05421
05422
05423 while (count > 0) {
05424 if (PIXEL_IS_OPAQUE(ipixel))
05425 break;
05426 if (!voxels_loaded) {
05427
05428 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
05429
05430
05431 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
05432 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
05433
05434
05435
05436 top_rclr =
05437 shade_table[shade_index + 3*0 + 0] *
05438 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05439
05440 top_gclr =
05441 shade_table[shade_index + 3*0 + 1] *
05442 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05443
05444 top_bclr =
05445 shade_table[shade_index + 3*0 + 2] *
05446 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05447
05448 top_rsclr =
05449 shadow_table[shade_index + 3*0 + 0] *
05450 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05451
05452 top_gsclr =
05453 shadow_table[shade_index + 3*0 + 1] *
05454 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05455
05456 top_bsclr =
05457 shadow_table[shade_index + 3*0 + 2] *
05458 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05459 for (m = 1; m < num_materials; m++) {
05460
05461
05462 top_rclr +=
05463 shade_table[shade_index + 3*m + 0] *
05464 weight_table[weight_index + m];
05465
05466 top_gclr +=
05467 shade_table[shade_index + 3*m + 1] *
05468 weight_table[weight_index + m];
05469
05470 top_bclr +=
05471 shade_table[shade_index + 3*m + 2] *
05472 weight_table[weight_index + m];
05473
05474 top_rsclr +=
05475 shadow_table[shade_index + 3*m + 0] *
05476 weight_table[weight_index + m];
05477
05478 top_gsclr +=
05479 shadow_table[shade_index + 3*m + 1] *
05480 weight_table[weight_index + m];
05481
05482 top_bsclr +=
05483 shadow_table[shade_index + 3*m + 2] *
05484 weight_table[weight_index + m];
05485 };
05486 shade_factor = top_opc * slice_depth_cueing;
05487
05488 top_rclr *= shade_factor;
05489 top_gclr *= shade_factor;
05490 top_bclr *= shade_factor;
05491
05492 top_rsclr *= shade_factor;
05493 top_gsclr *= shade_factor;
05494 top_bsclr *= shade_factor;
05495
05496 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
05497
05498
05499 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
05500 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
05501
05502
05503
05504 bot_rclr =
05505 shade_table[shade_index + 3*0 + 0] *
05506 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05507
05508 bot_gclr =
05509 shade_table[shade_index + 3*0 + 1] *
05510 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05511
05512 bot_bclr =
05513 shade_table[shade_index + 3*0 + 2] *
05514 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05515
05516 bot_rsclr =
05517 shadow_table[shade_index + 3*0 + 0] *
05518 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05519
05520 bot_gsclr =
05521 shadow_table[shade_index + 3*0 + 1] *
05522 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05523
05524 bot_bsclr =
05525 shadow_table[shade_index + 3*0 + 2] *
05526 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05527 for (m = 1; m < num_materials; m++) {
05528
05529
05530 bot_rclr +=
05531 shade_table[shade_index + 3*m + 0] *
05532 weight_table[weight_index + m];
05533
05534 bot_gclr +=
05535 shade_table[shade_index + 3*m + 1] *
05536 weight_table[weight_index + m];
05537
05538 bot_bclr +=
05539 shade_table[shade_index + 3*m + 2] *
05540 weight_table[weight_index + m];
05541
05542 bot_rsclr +=
05543 shadow_table[shade_index + 3*m + 0] *
05544 weight_table[weight_index + m];
05545
05546 bot_gsclr +=
05547 shadow_table[shade_index + 3*m + 1] *
05548 weight_table[weight_index + m];
05549
05550 bot_bsclr +=
05551 shadow_table[shade_index + 3*m + 2] *
05552 weight_table[weight_index + m];
05553 };
05554 shade_factor = bot_opc * slice_depth_cueing;
05555
05556 bot_rclr *= shade_factor;
05557 bot_gclr *= shade_factor;
05558 bot_bclr *= shade_factor;
05559
05560 bot_rsclr *= shade_factor;
05561 bot_gsclr *= shade_factor;
05562 bot_bsclr *= shade_factor;
05563 }
05564
05565 #ifdef DEBUG
05566 if (ipixel == trace_pixel_ptr) {
05567 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05568 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05569 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05570 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05571 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05572 }
05573 #endif
05574 ;
05575
05576 acc_opc = top_opc * wgtTL;
05577
05578 acc_rclr = (top_rclr + top_rsclr *
05579 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
05580 acc_gclr = (top_gclr + top_gsclr *
05581 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
05582 acc_bclr = (top_bclr + top_bsclr *
05583 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
05584
05585 #ifdef DEBUG
05586 if (ipixel == trace_pixel_ptr) {
05587 trace_opcTL = top_opc;
05588 trace_rclrTL = top_rclr;
05589 trace_gclrTL = top_gclr;
05590 trace_bclrTL = top_bclr;
05591
05592 }
05593 #endif
05594 ;
05595
05596 acc_opc += bot_opc * wgtBL;
05597
05598 acc_rclr += (bot_rclr + bot_rsclr *
05599 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
05600 acc_gclr += (bot_gclr + bot_gsclr *
05601 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
05602 acc_bclr += (bot_bclr + bot_bsclr *
05603 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
05604
05605 #ifdef DEBUG
05606 if (ipixel == trace_pixel_ptr) {
05607 trace_opcBL = bot_opc;
05608 trace_rclrBL = bot_rclr;
05609 trace_gclrBL = bot_gclr;
05610 trace_bclrBL = bot_bclr;
05611
05612 }
05613 #endif
05614 ;
05615
05616 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
05617
05618
05619 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
05620 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
05621
05622
05623
05624 top_rclr =
05625 shade_table[shade_index + 3*0 + 0] *
05626 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05627
05628 top_gclr =
05629 shade_table[shade_index + 3*0 + 1] *
05630 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05631
05632 top_bclr =
05633 shade_table[shade_index + 3*0 + 2] *
05634 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05635
05636 top_rsclr =
05637 shadow_table[shade_index + 3*0 + 0] *
05638 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05639
05640 top_gsclr =
05641 shadow_table[shade_index + 3*0 + 1] *
05642 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05643
05644 top_bsclr =
05645 shadow_table[shade_index + 3*0 + 2] *
05646 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05647 for (m = 1; m < num_materials; m++) {
05648
05649
05650 top_rclr +=
05651 shade_table[shade_index + 3*m + 0] *
05652 weight_table[weight_index + m];
05653
05654 top_gclr +=
05655 shade_table[shade_index + 3*m + 1] *
05656 weight_table[weight_index + m];
05657
05658 top_bclr +=
05659 shade_table[shade_index + 3*m + 2] *
05660 weight_table[weight_index + m];
05661
05662 top_rsclr +=
05663 shadow_table[shade_index + 3*m + 0] *
05664 weight_table[weight_index + m];
05665
05666 top_gsclr +=
05667 shadow_table[shade_index + 3*m + 1] *
05668 weight_table[weight_index + m];
05669
05670 top_bsclr +=
05671 shadow_table[shade_index + 3*m + 2] *
05672 weight_table[weight_index + m];
05673 };
05674 shade_factor = top_opc * slice_depth_cueing;
05675
05676 top_rclr *= shade_factor;
05677 top_gclr *= shade_factor;
05678 top_bclr *= shade_factor;
05679
05680 top_rsclr *= shade_factor;
05681 top_gsclr *= shade_factor;
05682 top_bsclr *= shade_factor;
05683
05684 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
05685
05686
05687 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
05688 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
05689
05690
05691
05692 bot_rclr =
05693 shade_table[shade_index + 3*0 + 0] *
05694 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05695
05696 bot_gclr =
05697 shade_table[shade_index + 3*0 + 1] *
05698 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05699
05700 bot_bclr =
05701 shade_table[shade_index + 3*0 + 2] *
05702 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05703
05704 bot_rsclr =
05705 shadow_table[shade_index + 3*0 + 0] *
05706 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05707
05708 bot_gsclr =
05709 shadow_table[shade_index + 3*0 + 1] *
05710 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05711
05712 bot_bsclr =
05713 shadow_table[shade_index + 3*0 + 2] *
05714 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05715 for (m = 1; m < num_materials; m++) {
05716
05717
05718 bot_rclr +=
05719 shade_table[shade_index + 3*m + 0] *
05720 weight_table[weight_index + m];
05721
05722 bot_gclr +=
05723 shade_table[shade_index + 3*m + 1] *
05724 weight_table[weight_index + m];
05725
05726 bot_bclr +=
05727 shade_table[shade_index + 3*m + 2] *
05728 weight_table[weight_index + m];
05729
05730 bot_rsclr +=
05731 shadow_table[shade_index + 3*m + 0] *
05732 weight_table[weight_index + m];
05733
05734 bot_gsclr +=
05735 shadow_table[shade_index + 3*m + 1] *
05736 weight_table[weight_index + m];
05737
05738 bot_bsclr +=
05739 shadow_table[shade_index + 3*m + 2] *
05740 weight_table[weight_index + m];
05741 };
05742 shade_factor = bot_opc * slice_depth_cueing;
05743
05744 bot_rclr *= shade_factor;
05745 bot_gclr *= shade_factor;
05746 bot_bclr *= shade_factor;
05747
05748 bot_rsclr *= shade_factor;
05749 bot_gsclr *= shade_factor;
05750 bot_bsclr *= shade_factor;
05751
05752 acc_opc += top_opc * wgtTR;
05753
05754 acc_rclr += (top_rclr + top_rsclr *
05755 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
05756 acc_gclr += (top_gclr + top_gsclr *
05757 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
05758 acc_bclr += (top_bclr + top_bsclr *
05759 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
05760
05761 #ifdef DEBUG
05762 if (ipixel == trace_pixel_ptr) {
05763 trace_opcTR = top_opc;
05764 trace_rclrTR = top_rclr;
05765 trace_gclrTR = top_gclr;
05766 trace_bclrTR = top_bclr;
05767
05768 }
05769 #endif
05770 ;
05771
05772 acc_opc += bot_opc * wgtBR;
05773
05774 acc_rclr += (bot_rclr + bot_rsclr *
05775 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05776 acc_gclr += (bot_gclr + bot_gsclr *
05777 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05778 acc_bclr += (bot_bclr + bot_bsclr *
05779 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
05780
05781 #ifdef DEBUG
05782 if (ipixel == trace_pixel_ptr) {
05783 trace_opcBR = bot_opc;
05784 trace_rclrBR = bot_rclr;
05785 trace_gclrBR = bot_gclr;
05786 trace_bclrBR = bot_bclr;
05787
05788 }
05789 #endif
05790 ;
05791
05792 COUNT_RESAMPLE;
05793 if (acc_opc > min_opacity) {
05794 COUNT_COMPOSITE;
05795 iopc = ipixel->opcflt;
05796 # ifndef SKIP_ERT
05797 ASSERT(iopc < max_opacity);
05798 # endif
05799 iopc_inv = (float)1. - iopc;
05800
05801 ipixel->rclrflt += acc_rclr * iopc_inv;
05802 ipixel->gclrflt += acc_gclr * iopc_inv;
05803 ipixel->bclrflt += acc_bclr * iopc_inv;
05804 iopc += acc_opc * iopc_inv;
05805 ipixel->opcflt = iopc;
05806
05807 #ifdef DEBUG
05808 if (ipixel == trace_pixel_ptr) {
05809 #ifdef COMPUTE_SHADOW_BUFFER
05810 printf("{%3d} %3d %3d", k, icount-i-count, j);
05811 #else
05812 printf("[%3d] %3d %3d", k, icount-i-count, j);
05813 #endif
05814 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05815 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05816 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05817 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05818 printf(" %3.0f %3.0f\n", iopc*255.,
05819 ipixel->rclrflt);
05820
05821 printf(" ");
05822 printf(" %3.0f ",trace_rsclrTL);
05823 printf(" %3.0f ",trace_rsclrBL);
05824 printf(" %3.0f ",trace_rsclrTR);
05825 printf(" %3.0f ",trace_rsclrBR);
05826 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
05827
05828 printf(" ");
05829 printf(" %3.0f ",trace_gclrTL);
05830 printf(" %3.0f ",trace_gclrBL);
05831 printf(" %3.0f ",trace_gclrTR);
05832 printf(" %3.0f ",trace_gclrBR);
05833 printf(" %3.0f\n", ipixel->gclrflt);
05834 printf(" ");
05835 printf(" %3.0f ",trace_bclrTL);
05836 printf(" %3.0f ",trace_bclrBL);
05837 printf(" %3.0f ",trace_bclrTR);
05838 printf(" %3.0f ",trace_bclrBR);
05839 printf(" %3.0f\n", ipixel->bclrflt);
05840 }
05841 #endif
05842 ;
05843 # ifndef SKIP_ERT
05844 if (iopc >= max_opacity) {
05845 ASSERT(ipixel->lnk == 0);
05846 ipixel->lnk = 1;
05847 }
05848 # endif
05849 };
05850 ipixel += 1; shadow_pixel += 1;
05851 topRLEdata += 1 * voxel_istride;
05852 botRLEdata += 1 * voxel_istride;
05853 count--;
05854 SET_VOXELS_LOADED;
05855 }
05856 break;
05857 case TOP_NONZERO__ALL_NONZERO:
05858
05859
05860 if (!voxels_loaded) {
05861
05862 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
05863
05864
05865 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
05866 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
05867
05868
05869
05870 top_rclr =
05871 shade_table[shade_index + 3*0 + 0] *
05872 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05873
05874 top_gclr =
05875 shade_table[shade_index + 3*0 + 1] *
05876 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05877
05878 top_bclr =
05879 shade_table[shade_index + 3*0 + 2] *
05880 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05881
05882 top_rsclr =
05883 shadow_table[shade_index + 3*0 + 0] *
05884 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05885
05886 top_gsclr =
05887 shadow_table[shade_index + 3*0 + 1] *
05888 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05889
05890 top_bsclr =
05891 shadow_table[shade_index + 3*0 + 2] *
05892 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05893 for (m = 1; m < num_materials; m++) {
05894
05895
05896 top_rclr +=
05897 shade_table[shade_index + 3*m + 0] *
05898 weight_table[weight_index + m];
05899
05900 top_gclr +=
05901 shade_table[shade_index + 3*m + 1] *
05902 weight_table[weight_index + m];
05903
05904 top_bclr +=
05905 shade_table[shade_index + 3*m + 2] *
05906 weight_table[weight_index + m];
05907
05908 top_rsclr +=
05909 shadow_table[shade_index + 3*m + 0] *
05910 weight_table[weight_index + m];
05911
05912 top_gsclr +=
05913 shadow_table[shade_index + 3*m + 1] *
05914 weight_table[weight_index + m];
05915
05916 top_bsclr +=
05917 shadow_table[shade_index + 3*m + 2] *
05918 weight_table[weight_index + m];
05919 };
05920 shade_factor = top_opc * slice_depth_cueing;
05921
05922 top_rclr *= shade_factor;
05923 top_gclr *= shade_factor;
05924 top_bclr *= shade_factor;
05925
05926 top_rsclr *= shade_factor;
05927 top_gsclr *= shade_factor;
05928 top_bsclr *= shade_factor;
05929 }
05930
05931 #ifdef DEBUG
05932 if (ipixel == trace_pixel_ptr) {
05933 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05934 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05935 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05936 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05937 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05938 }
05939 #endif
05940 ;
05941
05942 acc_opc = top_opc * wgtTL;
05943
05944 acc_rclr = (top_rclr + top_rsclr *
05945 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
05946 acc_gclr = (top_gclr + top_gsclr *
05947 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
05948 acc_bclr = (top_bclr + top_bsclr *
05949 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
05950
05951 #ifdef DEBUG
05952 if (ipixel == trace_pixel_ptr) {
05953 trace_opcTL = top_opc;
05954 trace_rclrTL = top_rclr;
05955 trace_gclrTL = top_gclr;
05956 trace_bclrTL = top_bclr;
05957
05958 }
05959 #endif
05960 ;
05961
05962 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
05963
05964
05965 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
05966 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
05967
05968
05969
05970 top_rclr =
05971 shade_table[shade_index + 3*0 + 0] *
05972 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05973
05974 top_gclr =
05975 shade_table[shade_index + 3*0 + 1] *
05976 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05977
05978 top_bclr =
05979 shade_table[shade_index + 3*0 + 2] *
05980 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05981
05982 top_rsclr =
05983 shadow_table[shade_index + 3*0 + 0] *
05984 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05985
05986 top_gsclr =
05987 shadow_table[shade_index + 3*0 + 1] *
05988 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05989
05990 top_bsclr =
05991 shadow_table[shade_index + 3*0 + 2] *
05992 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
05993 for (m = 1; m < num_materials; m++) {
05994
05995
05996 top_rclr +=
05997 shade_table[shade_index + 3*m + 0] *
05998 weight_table[weight_index + m];
05999
06000 top_gclr +=
06001 shade_table[shade_index + 3*m + 1] *
06002 weight_table[weight_index + m];
06003
06004 top_bclr +=
06005 shade_table[shade_index + 3*m + 2] *
06006 weight_table[weight_index + m];
06007
06008 top_rsclr +=
06009 shadow_table[shade_index + 3*m + 0] *
06010 weight_table[weight_index + m];
06011
06012 top_gsclr +=
06013 shadow_table[shade_index + 3*m + 1] *
06014 weight_table[weight_index + m];
06015
06016 top_bsclr +=
06017 shadow_table[shade_index + 3*m + 2] *
06018 weight_table[weight_index + m];
06019 };
06020 shade_factor = top_opc * slice_depth_cueing;
06021
06022 top_rclr *= shade_factor;
06023 top_gclr *= shade_factor;
06024 top_bclr *= shade_factor;
06025
06026 top_rsclr *= shade_factor;
06027 top_gsclr *= shade_factor;
06028 top_bsclr *= shade_factor;
06029
06030 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
06031
06032
06033 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
06034 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
06035
06036
06037
06038 bot_rclr =
06039 shade_table[shade_index + 3*0 + 0] *
06040 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06041
06042 bot_gclr =
06043 shade_table[shade_index + 3*0 + 1] *
06044 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06045
06046 bot_bclr =
06047 shade_table[shade_index + 3*0 + 2] *
06048 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06049
06050 bot_rsclr =
06051 shadow_table[shade_index + 3*0 + 0] *
06052 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06053
06054 bot_gsclr =
06055 shadow_table[shade_index + 3*0 + 1] *
06056 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06057
06058 bot_bsclr =
06059 shadow_table[shade_index + 3*0 + 2] *
06060 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06061 for (m = 1; m < num_materials; m++) {
06062
06063
06064 bot_rclr +=
06065 shade_table[shade_index + 3*m + 0] *
06066 weight_table[weight_index + m];
06067
06068 bot_gclr +=
06069 shade_table[shade_index + 3*m + 1] *
06070 weight_table[weight_index + m];
06071
06072 bot_bclr +=
06073 shade_table[shade_index + 3*m + 2] *
06074 weight_table[weight_index + m];
06075
06076 bot_rsclr +=
06077 shadow_table[shade_index + 3*m + 0] *
06078 weight_table[weight_index + m];
06079
06080 bot_gsclr +=
06081 shadow_table[shade_index + 3*m + 1] *
06082 weight_table[weight_index + m];
06083
06084 bot_bsclr +=
06085 shadow_table[shade_index + 3*m + 2] *
06086 weight_table[weight_index + m];
06087 };
06088 shade_factor = bot_opc * slice_depth_cueing;
06089
06090 bot_rclr *= shade_factor;
06091 bot_gclr *= shade_factor;
06092 bot_bclr *= shade_factor;
06093
06094 bot_rsclr *= shade_factor;
06095 bot_gsclr *= shade_factor;
06096 bot_bsclr *= shade_factor;
06097
06098 acc_opc += top_opc * wgtTR;
06099
06100 acc_rclr += (top_rclr + top_rsclr *
06101 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
06102 acc_gclr += (top_gclr + top_gsclr *
06103 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
06104 acc_bclr += (top_bclr + top_bsclr *
06105 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
06106
06107 #ifdef DEBUG
06108 if (ipixel == trace_pixel_ptr) {
06109 trace_opcTR = top_opc;
06110 trace_rclrTR = top_rclr;
06111 trace_gclrTR = top_gclr;
06112 trace_bclrTR = top_bclr;
06113
06114 }
06115 #endif
06116 ;
06117
06118 acc_opc += bot_opc * wgtBR;
06119
06120 acc_rclr += (bot_rclr + bot_rsclr *
06121 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
06122 acc_gclr += (bot_gclr + bot_gsclr *
06123 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
06124 acc_bclr += (bot_bclr + bot_bsclr *
06125 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
06126
06127 #ifdef DEBUG
06128 if (ipixel == trace_pixel_ptr) {
06129 trace_opcBR = bot_opc;
06130 trace_rclrBR = bot_rclr;
06131 trace_gclrBR = bot_gclr;
06132 trace_bclrBR = bot_bclr;
06133
06134 }
06135 #endif
06136 ;
06137
06138 COUNT_RESAMPLE;
06139 if (acc_opc > min_opacity) {
06140 COUNT_COMPOSITE;
06141 iopc = ipixel->opcflt;
06142 # ifndef SKIP_ERT
06143 ASSERT(iopc < max_opacity);
06144 # endif
06145 iopc_inv = (float)1. - iopc;
06146
06147 ipixel->rclrflt += acc_rclr * iopc_inv;
06148 ipixel->gclrflt += acc_gclr * iopc_inv;
06149 ipixel->bclrflt += acc_bclr * iopc_inv;
06150 iopc += acc_opc * iopc_inv;
06151 ipixel->opcflt = iopc;
06152
06153 #ifdef DEBUG
06154 if (ipixel == trace_pixel_ptr) {
06155 #ifdef COMPUTE_SHADOW_BUFFER
06156 printf("{%3d} %3d %3d", k, icount-i-count, j);
06157 #else
06158 printf("[%3d] %3d %3d", k, icount-i-count, j);
06159 #endif
06160 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06161 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06162 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06163 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06164 printf(" %3.0f %3.0f\n", iopc*255.,
06165 ipixel->rclrflt);
06166
06167 printf(" ");
06168 printf(" %3.0f ",trace_rsclrTL);
06169 printf(" %3.0f ",trace_rsclrBL);
06170 printf(" %3.0f ",trace_rsclrTR);
06171 printf(" %3.0f ",trace_rsclrBR);
06172 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
06173
06174 printf(" ");
06175 printf(" %3.0f ",trace_gclrTL);
06176 printf(" %3.0f ",trace_gclrBL);
06177 printf(" %3.0f ",trace_gclrTR);
06178 printf(" %3.0f ",trace_gclrBR);
06179 printf(" %3.0f\n", ipixel->gclrflt);
06180 printf(" ");
06181 printf(" %3.0f ",trace_bclrTL);
06182 printf(" %3.0f ",trace_bclrBL);
06183 printf(" %3.0f ",trace_bclrTR);
06184 printf(" %3.0f ",trace_bclrBR);
06185 printf(" %3.0f\n", ipixel->bclrflt);
06186 }
06187 #endif
06188 ;
06189 # ifndef SKIP_ERT
06190 if (iopc >= max_opacity) {
06191 ASSERT(ipixel->lnk == 0);
06192 ipixel->lnk = 1;
06193 }
06194 # endif
06195 };
06196 ipixel += 1; shadow_pixel += 1;
06197 topRLEdata += 1 * voxel_istride;
06198 botRLEdata += 1 * voxel_istride;
06199 count--;
06200 SET_VOXELS_LOADED;
06201
06202
06203
06204 while (count > 0) {
06205 if (PIXEL_IS_OPAQUE(ipixel))
06206 break;
06207 if (!voxels_loaded) {
06208
06209 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
06210
06211
06212 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
06213 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
06214
06215
06216
06217 top_rclr =
06218 shade_table[shade_index + 3*0 + 0] *
06219 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06220
06221 top_gclr =
06222 shade_table[shade_index + 3*0 + 1] *
06223 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06224
06225 top_bclr =
06226 shade_table[shade_index + 3*0 + 2] *
06227 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06228
06229 top_rsclr =
06230 shadow_table[shade_index + 3*0 + 0] *
06231 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06232
06233 top_gsclr =
06234 shadow_table[shade_index + 3*0 + 1] *
06235 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06236
06237 top_bsclr =
06238 shadow_table[shade_index + 3*0 + 2] *
06239 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06240 for (m = 1; m < num_materials; m++) {
06241
06242
06243 top_rclr +=
06244 shade_table[shade_index + 3*m + 0] *
06245 weight_table[weight_index + m];
06246
06247 top_gclr +=
06248 shade_table[shade_index + 3*m + 1] *
06249 weight_table[weight_index + m];
06250
06251 top_bclr +=
06252 shade_table[shade_index + 3*m + 2] *
06253 weight_table[weight_index + m];
06254
06255 top_rsclr +=
06256 shadow_table[shade_index + 3*m + 0] *
06257 weight_table[weight_index + m];
06258
06259 top_gsclr +=
06260 shadow_table[shade_index + 3*m + 1] *
06261 weight_table[weight_index + m];
06262
06263 top_bsclr +=
06264 shadow_table[shade_index + 3*m + 2] *
06265 weight_table[weight_index + m];
06266 };
06267 shade_factor = top_opc * slice_depth_cueing;
06268
06269 top_rclr *= shade_factor;
06270 top_gclr *= shade_factor;
06271 top_bclr *= shade_factor;
06272
06273 top_rsclr *= shade_factor;
06274 top_gsclr *= shade_factor;
06275 top_bsclr *= shade_factor;
06276
06277 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
06278
06279
06280 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
06281 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
06282
06283
06284
06285 bot_rclr =
06286 shade_table[shade_index + 3*0 + 0] *
06287 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06288
06289 bot_gclr =
06290 shade_table[shade_index + 3*0 + 1] *
06291 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06292
06293 bot_bclr =
06294 shade_table[shade_index + 3*0 + 2] *
06295 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06296
06297 bot_rsclr =
06298 shadow_table[shade_index + 3*0 + 0] *
06299 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06300
06301 bot_gsclr =
06302 shadow_table[shade_index + 3*0 + 1] *
06303 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06304
06305 bot_bsclr =
06306 shadow_table[shade_index + 3*0 + 2] *
06307 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06308 for (m = 1; m < num_materials; m++) {
06309
06310
06311 bot_rclr +=
06312 shade_table[shade_index + 3*m + 0] *
06313 weight_table[weight_index + m];
06314
06315 bot_gclr +=
06316 shade_table[shade_index + 3*m + 1] *
06317 weight_table[weight_index + m];
06318
06319 bot_bclr +=
06320 shade_table[shade_index + 3*m + 2] *
06321 weight_table[weight_index + m];
06322
06323 bot_rsclr +=
06324 shadow_table[shade_index + 3*m + 0] *
06325 weight_table[weight_index + m];
06326
06327 bot_gsclr +=
06328 shadow_table[shade_index + 3*m + 1] *
06329 weight_table[weight_index + m];
06330
06331 bot_bsclr +=
06332 shadow_table[shade_index + 3*m + 2] *
06333 weight_table[weight_index + m];
06334 };
06335 shade_factor = bot_opc * slice_depth_cueing;
06336
06337 bot_rclr *= shade_factor;
06338 bot_gclr *= shade_factor;
06339 bot_bclr *= shade_factor;
06340
06341 bot_rsclr *= shade_factor;
06342 bot_gsclr *= shade_factor;
06343 bot_bsclr *= shade_factor;
06344 }
06345
06346 #ifdef DEBUG
06347 if (ipixel == trace_pixel_ptr) {
06348 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
06349 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
06350 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
06351 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
06352 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
06353 }
06354 #endif
06355 ;
06356
06357 acc_opc = top_opc * wgtTL;
06358
06359 acc_rclr = (top_rclr + top_rsclr *
06360 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
06361 acc_gclr = (top_gclr + top_gsclr *
06362 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
06363 acc_bclr = (top_bclr + top_bsclr *
06364 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
06365
06366 #ifdef DEBUG
06367 if (ipixel == trace_pixel_ptr) {
06368 trace_opcTL = top_opc;
06369 trace_rclrTL = top_rclr;
06370 trace_gclrTL = top_gclr;
06371 trace_bclrTL = top_bclr;
06372
06373 }
06374 #endif
06375 ;
06376
06377 acc_opc += bot_opc * wgtBL;
06378
06379 acc_rclr += (bot_rclr + bot_rsclr *
06380 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
06381 acc_gclr += (bot_gclr + bot_gsclr *
06382 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
06383 acc_bclr += (bot_bclr + bot_bsclr *
06384 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
06385
06386 #ifdef DEBUG
06387 if (ipixel == trace_pixel_ptr) {
06388 trace_opcBL = bot_opc;
06389 trace_rclrBL = bot_rclr;
06390 trace_gclrBL = bot_gclr;
06391 trace_bclrBL = bot_bclr;
06392
06393 }
06394 #endif
06395 ;
06396
06397 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
06398
06399
06400 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
06401 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
06402
06403
06404
06405 top_rclr =
06406 shade_table[shade_index + 3*0 + 0] *
06407 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06408
06409 top_gclr =
06410 shade_table[shade_index + 3*0 + 1] *
06411 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06412
06413 top_bclr =
06414 shade_table[shade_index + 3*0 + 2] *
06415 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06416
06417 top_rsclr =
06418 shadow_table[shade_index + 3*0 + 0] *
06419 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06420
06421 top_gsclr =
06422 shadow_table[shade_index + 3*0 + 1] *
06423 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06424
06425 top_bsclr =
06426 shadow_table[shade_index + 3*0 + 2] *
06427 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06428 for (m = 1; m < num_materials; m++) {
06429
06430
06431 top_rclr +=
06432 shade_table[shade_index + 3*m + 0] *
06433 weight_table[weight_index + m];
06434
06435 top_gclr +=
06436 shade_table[shade_index + 3*m + 1] *
06437 weight_table[weight_index + m];
06438
06439 top_bclr +=
06440 shade_table[shade_index + 3*m + 2] *
06441 weight_table[weight_index + m];
06442
06443 top_rsclr +=
06444 shadow_table[shade_index + 3*m + 0] *
06445 weight_table[weight_index + m];
06446
06447 top_gsclr +=
06448 shadow_table[shade_index + 3*m + 1] *
06449 weight_table[weight_index + m];
06450
06451 top_bsclr +=
06452 shadow_table[shade_index + 3*m + 2] *
06453 weight_table[weight_index + m];
06454 };
06455 shade_factor = top_opc * slice_depth_cueing;
06456
06457 top_rclr *= shade_factor;
06458 top_gclr *= shade_factor;
06459 top_bclr *= shade_factor;
06460
06461 top_rsclr *= shade_factor;
06462 top_gsclr *= shade_factor;
06463 top_bsclr *= shade_factor;
06464
06465 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
06466
06467
06468 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
06469 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
06470
06471
06472
06473 bot_rclr =
06474 shade_table[shade_index + 3*0 + 0] *
06475 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06476
06477 bot_gclr =
06478 shade_table[shade_index + 3*0 + 1] *
06479 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06480
06481 bot_bclr =
06482 shade_table[shade_index + 3*0 + 2] *
06483 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06484
06485 bot_rsclr =
06486 shadow_table[shade_index + 3*0 + 0] *
06487 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06488
06489 bot_gsclr =
06490 shadow_table[shade_index + 3*0 + 1] *
06491 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06492
06493 bot_bsclr =
06494 shadow_table[shade_index + 3*0 + 2] *
06495 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06496 for (m = 1; m < num_materials; m++) {
06497
06498
06499 bot_rclr +=
06500 shade_table[shade_index + 3*m + 0] *
06501 weight_table[weight_index + m];
06502
06503 bot_gclr +=
06504 shade_table[shade_index + 3*m + 1] *
06505 weight_table[weight_index + m];
06506
06507 bot_bclr +=
06508 shade_table[shade_index + 3*m + 2] *
06509 weight_table[weight_index + m];
06510
06511 bot_rsclr +=
06512 shadow_table[shade_index + 3*m + 0] *
06513 weight_table[weight_index + m];
06514
06515 bot_gsclr +=
06516 shadow_table[shade_index + 3*m + 1] *
06517 weight_table[weight_index + m];
06518
06519 bot_bsclr +=
06520 shadow_table[shade_index + 3*m + 2] *
06521 weight_table[weight_index + m];
06522 };
06523 shade_factor = bot_opc * slice_depth_cueing;
06524
06525 bot_rclr *= shade_factor;
06526 bot_gclr *= shade_factor;
06527 bot_bclr *= shade_factor;
06528
06529 bot_rsclr *= shade_factor;
06530 bot_gsclr *= shade_factor;
06531 bot_bsclr *= shade_factor;
06532
06533 acc_opc += top_opc * wgtTR;
06534
06535 acc_rclr += (top_rclr + top_rsclr *
06536 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
06537 acc_gclr += (top_gclr + top_gsclr *
06538 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
06539 acc_bclr += (top_bclr + top_bsclr *
06540 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
06541
06542 #ifdef DEBUG
06543 if (ipixel == trace_pixel_ptr) {
06544 trace_opcTR = top_opc;
06545 trace_rclrTR = top_rclr;
06546 trace_gclrTR = top_gclr;
06547 trace_bclrTR = top_bclr;
06548
06549 }
06550 #endif
06551 ;
06552
06553 acc_opc += bot_opc * wgtBR;
06554
06555 acc_rclr += (bot_rclr + bot_rsclr *
06556 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
06557 acc_gclr += (bot_gclr + bot_gsclr *
06558 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
06559 acc_bclr += (bot_bclr + bot_bsclr *
06560 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
06561
06562 #ifdef DEBUG
06563 if (ipixel == trace_pixel_ptr) {
06564 trace_opcBR = bot_opc;
06565 trace_rclrBR = bot_rclr;
06566 trace_gclrBR = bot_gclr;
06567 trace_bclrBR = bot_bclr;
06568
06569 }
06570 #endif
06571 ;
06572
06573 COUNT_RESAMPLE;
06574 if (acc_opc > min_opacity) {
06575 COUNT_COMPOSITE;
06576 iopc = ipixel->opcflt;
06577 # ifndef SKIP_ERT
06578 ASSERT(iopc < max_opacity);
06579 # endif
06580 iopc_inv = (float)1. - iopc;
06581
06582 ipixel->rclrflt += acc_rclr * iopc_inv;
06583 ipixel->gclrflt += acc_gclr * iopc_inv;
06584 ipixel->bclrflt += acc_bclr * iopc_inv;
06585 iopc += acc_opc * iopc_inv;
06586 ipixel->opcflt = iopc;
06587
06588 #ifdef DEBUG
06589 if (ipixel == trace_pixel_ptr) {
06590 #ifdef COMPUTE_SHADOW_BUFFER
06591 printf("{%3d} %3d %3d", k, icount-i-count, j);
06592 #else
06593 printf("[%3d] %3d %3d", k, icount-i-count, j);
06594 #endif
06595 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06596 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06597 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06598 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06599 printf(" %3.0f %3.0f\n", iopc*255.,
06600 ipixel->rclrflt);
06601
06602 printf(" ");
06603 printf(" %3.0f ",trace_rsclrTL);
06604 printf(" %3.0f ",trace_rsclrBL);
06605 printf(" %3.0f ",trace_rsclrTR);
06606 printf(" %3.0f ",trace_rsclrBR);
06607 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
06608
06609 printf(" ");
06610 printf(" %3.0f ",trace_gclrTL);
06611 printf(" %3.0f ",trace_gclrBL);
06612 printf(" %3.0f ",trace_gclrTR);
06613 printf(" %3.0f ",trace_gclrBR);
06614 printf(" %3.0f\n", ipixel->gclrflt);
06615 printf(" ");
06616 printf(" %3.0f ",trace_bclrTL);
06617 printf(" %3.0f ",trace_bclrBL);
06618 printf(" %3.0f ",trace_bclrTR);
06619 printf(" %3.0f ",trace_bclrBR);
06620 printf(" %3.0f\n", ipixel->bclrflt);
06621 }
06622 #endif
06623 ;
06624 # ifndef SKIP_ERT
06625 if (iopc >= max_opacity) {
06626 ASSERT(ipixel->lnk == 0);
06627 ipixel->lnk = 1;
06628 }
06629 # endif
06630 };
06631 ipixel += 1; shadow_pixel += 1;
06632 topRLEdata += 1 * voxel_istride;
06633 botRLEdata += 1 * voxel_istride;
06634 count--;
06635 SET_VOXELS_LOADED;
06636 }
06637 break;
06638 case BOT_NONZERO__ALL_NONZERO:
06639
06640
06641 if (!voxels_loaded) {
06642
06643 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
06644
06645
06646 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
06647 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
06648
06649
06650
06651 bot_rclr =
06652 shade_table[shade_index + 3*0 + 0] *
06653 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06654
06655 bot_gclr =
06656 shade_table[shade_index + 3*0 + 1] *
06657 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06658
06659 bot_bclr =
06660 shade_table[shade_index + 3*0 + 2] *
06661 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06662
06663 bot_rsclr =
06664 shadow_table[shade_index + 3*0 + 0] *
06665 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06666
06667 bot_gsclr =
06668 shadow_table[shade_index + 3*0 + 1] *
06669 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06670
06671 bot_bsclr =
06672 shadow_table[shade_index + 3*0 + 2] *
06673 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06674 for (m = 1; m < num_materials; m++) {
06675
06676
06677 bot_rclr +=
06678 shade_table[shade_index + 3*m + 0] *
06679 weight_table[weight_index + m];
06680
06681 bot_gclr +=
06682 shade_table[shade_index + 3*m + 1] *
06683 weight_table[weight_index + m];
06684
06685 bot_bclr +=
06686 shade_table[shade_index + 3*m + 2] *
06687 weight_table[weight_index + m];
06688
06689 bot_rsclr +=
06690 shadow_table[shade_index + 3*m + 0] *
06691 weight_table[weight_index + m];
06692
06693 bot_gsclr +=
06694 shadow_table[shade_index + 3*m + 1] *
06695 weight_table[weight_index + m];
06696
06697 bot_bsclr +=
06698 shadow_table[shade_index + 3*m + 2] *
06699 weight_table[weight_index + m];
06700 };
06701 shade_factor = bot_opc * slice_depth_cueing;
06702
06703 bot_rclr *= shade_factor;
06704 bot_gclr *= shade_factor;
06705 bot_bclr *= shade_factor;
06706
06707 bot_rsclr *= shade_factor;
06708 bot_gsclr *= shade_factor;
06709 bot_bsclr *= shade_factor;
06710 }
06711
06712 #ifdef DEBUG
06713 if (ipixel == trace_pixel_ptr) {
06714 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
06715 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
06716 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
06717 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
06718 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
06719 }
06720 #endif
06721 ;
06722
06723 acc_opc = bot_opc * wgtBL;
06724
06725 acc_rclr = (bot_rclr + bot_rsclr *
06726 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
06727 acc_gclr = (bot_gclr + bot_gsclr *
06728 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
06729 acc_bclr = (bot_bclr + bot_bsclr *
06730 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
06731
06732 #ifdef DEBUG
06733 if (ipixel == trace_pixel_ptr) {
06734 trace_opcBL = bot_opc;
06735 trace_rclrBL = bot_rclr;
06736 trace_gclrBL = bot_gclr;
06737 trace_bclrBL = bot_bclr;
06738
06739 }
06740 #endif
06741 ;
06742
06743 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
06744
06745
06746 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
06747 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
06748
06749
06750
06751 top_rclr =
06752 shade_table[shade_index + 3*0 + 0] *
06753 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06754
06755 top_gclr =
06756 shade_table[shade_index + 3*0 + 1] *
06757 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06758
06759 top_bclr =
06760 shade_table[shade_index + 3*0 + 2] *
06761 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06762
06763 top_rsclr =
06764 shadow_table[shade_index + 3*0 + 0] *
06765 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06766
06767 top_gsclr =
06768 shadow_table[shade_index + 3*0 + 1] *
06769 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06770
06771 top_bsclr =
06772 shadow_table[shade_index + 3*0 + 2] *
06773 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06774 for (m = 1; m < num_materials; m++) {
06775
06776
06777 top_rclr +=
06778 shade_table[shade_index + 3*m + 0] *
06779 weight_table[weight_index + m];
06780
06781 top_gclr +=
06782 shade_table[shade_index + 3*m + 1] *
06783 weight_table[weight_index + m];
06784
06785 top_bclr +=
06786 shade_table[shade_index + 3*m + 2] *
06787 weight_table[weight_index + m];
06788
06789 top_rsclr +=
06790 shadow_table[shade_index + 3*m + 0] *
06791 weight_table[weight_index + m];
06792
06793 top_gsclr +=
06794 shadow_table[shade_index + 3*m + 1] *
06795 weight_table[weight_index + m];
06796
06797 top_bsclr +=
06798 shadow_table[shade_index + 3*m + 2] *
06799 weight_table[weight_index + m];
06800 };
06801 shade_factor = top_opc * slice_depth_cueing;
06802
06803 top_rclr *= shade_factor;
06804 top_gclr *= shade_factor;
06805 top_bclr *= shade_factor;
06806
06807 top_rsclr *= shade_factor;
06808 top_gsclr *= shade_factor;
06809 top_bsclr *= shade_factor;
06810
06811 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
06812
06813
06814 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
06815 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
06816
06817
06818
06819 bot_rclr =
06820 shade_table[shade_index + 3*0 + 0] *
06821 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06822
06823 bot_gclr =
06824 shade_table[shade_index + 3*0 + 1] *
06825 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06826
06827 bot_bclr =
06828 shade_table[shade_index + 3*0 + 2] *
06829 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06830
06831 bot_rsclr =
06832 shadow_table[shade_index + 3*0 + 0] *
06833 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06834
06835 bot_gsclr =
06836 shadow_table[shade_index + 3*0 + 1] *
06837 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06838
06839 bot_bsclr =
06840 shadow_table[shade_index + 3*0 + 2] *
06841 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
06842 for (m = 1; m < num_materials; m++) {
06843
06844
06845 bot_rclr +=
06846 shade_table[shade_index + 3*m + 0] *
06847 weight_table[weight_index + m];
06848
06849 bot_gclr +=
06850 shade_table[shade_index + 3*m + 1] *
06851 weight_table[weight_index + m];
06852
06853 bot_bclr +=
06854 shade_table[shade_index + 3*m + 2] *
06855 weight_table[weight_index + m];
06856
06857 bot_rsclr +=
06858 shadow_table[shade_index + 3*m + 0] *
06859 weight_table[weight_index + m];
06860
06861 bot_gsclr +=
06862 shadow_table[shade_index + 3*m + 1] *
06863 weight_table[weight_index + m];
06864
06865 bot_bsclr +=
06866 shadow_table[shade_index + 3*m + 2] *
06867 weight_table[weight_index + m];
06868 };
06869 shade_factor = bot_opc * slice_depth_cueing;
06870
06871 bot_rclr *= shade_factor;
06872 bot_gclr *= shade_factor;
06873 bot_bclr *= shade_factor;
06874
06875 bot_rsclr *= shade_factor;
06876 bot_gsclr *= shade_factor;
06877 bot_bsclr *= shade_factor;
06878
06879 acc_opc += top_opc * wgtTR;
06880
06881 acc_rclr += (top_rclr + top_rsclr *
06882 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
06883 acc_gclr += (top_gclr + top_gsclr *
06884 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
06885 acc_bclr += (top_bclr + top_bsclr *
06886 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
06887
06888 #ifdef DEBUG
06889 if (ipixel == trace_pixel_ptr) {
06890 trace_opcTR = top_opc;
06891 trace_rclrTR = top_rclr;
06892 trace_gclrTR = top_gclr;
06893 trace_bclrTR = top_bclr;
06894
06895 }
06896 #endif
06897 ;
06898
06899 acc_opc += bot_opc * wgtBR;
06900
06901 acc_rclr += (bot_rclr + bot_rsclr *
06902 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
06903 acc_gclr += (bot_gclr + bot_gsclr *
06904 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
06905 acc_bclr += (bot_bclr + bot_bsclr *
06906 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
06907
06908 #ifdef DEBUG
06909 if (ipixel == trace_pixel_ptr) {
06910 trace_opcBR = bot_opc;
06911 trace_rclrBR = bot_rclr;
06912 trace_gclrBR = bot_gclr;
06913 trace_bclrBR = bot_bclr;
06914
06915 }
06916 #endif
06917 ;
06918
06919 COUNT_RESAMPLE;
06920 if (acc_opc > min_opacity) {
06921 COUNT_COMPOSITE;
06922 iopc = ipixel->opcflt;
06923 # ifndef SKIP_ERT
06924 ASSERT(iopc < max_opacity);
06925 # endif
06926 iopc_inv = (float)1. - iopc;
06927
06928 ipixel->rclrflt += acc_rclr * iopc_inv;
06929 ipixel->gclrflt += acc_gclr * iopc_inv;
06930 ipixel->bclrflt += acc_bclr * iopc_inv;
06931 iopc += acc_opc * iopc_inv;
06932 ipixel->opcflt = iopc;
06933
06934 #ifdef DEBUG
06935 if (ipixel == trace_pixel_ptr) {
06936 #ifdef COMPUTE_SHADOW_BUFFER
06937 printf("{%3d} %3d %3d", k, icount-i-count, j);
06938 #else
06939 printf("[%3d] %3d %3d", k, icount-i-count, j);
06940 #endif
06941 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06942 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06943 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06944 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06945 printf(" %3.0f %3.0f\n", iopc*255.,
06946 ipixel->rclrflt);
06947
06948 printf(" ");
06949 printf(" %3.0f ",trace_rsclrTL);
06950 printf(" %3.0f ",trace_rsclrBL);
06951 printf(" %3.0f ",trace_rsclrTR);
06952 printf(" %3.0f ",trace_rsclrBR);
06953 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
06954
06955 printf(" ");
06956 printf(" %3.0f ",trace_gclrTL);
06957 printf(" %3.0f ",trace_gclrBL);
06958 printf(" %3.0f ",trace_gclrTR);
06959 printf(" %3.0f ",trace_gclrBR);
06960 printf(" %3.0f\n", ipixel->gclrflt);
06961 printf(" ");
06962 printf(" %3.0f ",trace_bclrTL);
06963 printf(" %3.0f ",trace_bclrBL);
06964 printf(" %3.0f ",trace_bclrTR);
06965 printf(" %3.0f ",trace_bclrBR);
06966 printf(" %3.0f\n", ipixel->bclrflt);
06967 }
06968 #endif
06969 ;
06970 # ifndef SKIP_ERT
06971 if (iopc >= max_opacity) {
06972 ASSERT(ipixel->lnk == 0);
06973 ipixel->lnk = 1;
06974 }
06975 # endif
06976 };
06977 ipixel += 1; shadow_pixel += 1;
06978 topRLEdata += 1 * voxel_istride;
06979 botRLEdata += 1 * voxel_istride;
06980 count--;
06981 SET_VOXELS_LOADED;
06982
06983
06984
06985 while (count > 0) {
06986 if (PIXEL_IS_OPAQUE(ipixel))
06987 break;
06988 if (!voxels_loaded) {
06989
06990 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
06991
06992
06993 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
06994 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
06995
06996
06997
06998 top_rclr =
06999 shade_table[shade_index + 3*0 + 0] *
07000 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07001
07002 top_gclr =
07003 shade_table[shade_index + 3*0 + 1] *
07004 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07005
07006 top_bclr =
07007 shade_table[shade_index + 3*0 + 2] *
07008 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07009
07010 top_rsclr =
07011 shadow_table[shade_index + 3*0 + 0] *
07012 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07013
07014 top_gsclr =
07015 shadow_table[shade_index + 3*0 + 1] *
07016 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07017
07018 top_bsclr =
07019 shadow_table[shade_index + 3*0 + 2] *
07020 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07021 for (m = 1; m < num_materials; m++) {
07022
07023
07024 top_rclr +=
07025 shade_table[shade_index + 3*m + 0] *
07026 weight_table[weight_index + m];
07027
07028 top_gclr +=
07029 shade_table[shade_index + 3*m + 1] *
07030 weight_table[weight_index + m];
07031
07032 top_bclr +=
07033 shade_table[shade_index + 3*m + 2] *
07034 weight_table[weight_index + m];
07035
07036 top_rsclr +=
07037 shadow_table[shade_index + 3*m + 0] *
07038 weight_table[weight_index + m];
07039
07040 top_gsclr +=
07041 shadow_table[shade_index + 3*m + 1] *
07042 weight_table[weight_index + m];
07043
07044 top_bsclr +=
07045 shadow_table[shade_index + 3*m + 2] *
07046 weight_table[weight_index + m];
07047 };
07048 shade_factor = top_opc * slice_depth_cueing;
07049
07050 top_rclr *= shade_factor;
07051 top_gclr *= shade_factor;
07052 top_bclr *= shade_factor;
07053
07054 top_rsclr *= shade_factor;
07055 top_gsclr *= shade_factor;
07056 top_bsclr *= shade_factor;
07057
07058 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
07059
07060
07061 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
07062 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
07063
07064
07065
07066 bot_rclr =
07067 shade_table[shade_index + 3*0 + 0] *
07068 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07069
07070 bot_gclr =
07071 shade_table[shade_index + 3*0 + 1] *
07072 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07073
07074 bot_bclr =
07075 shade_table[shade_index + 3*0 + 2] *
07076 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07077
07078 bot_rsclr =
07079 shadow_table[shade_index + 3*0 + 0] *
07080 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07081
07082 bot_gsclr =
07083 shadow_table[shade_index + 3*0 + 1] *
07084 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07085
07086 bot_bsclr =
07087 shadow_table[shade_index + 3*0 + 2] *
07088 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07089 for (m = 1; m < num_materials; m++) {
07090
07091
07092 bot_rclr +=
07093 shade_table[shade_index + 3*m + 0] *
07094 weight_table[weight_index + m];
07095
07096 bot_gclr +=
07097 shade_table[shade_index + 3*m + 1] *
07098 weight_table[weight_index + m];
07099
07100 bot_bclr +=
07101 shade_table[shade_index + 3*m + 2] *
07102 weight_table[weight_index + m];
07103
07104 bot_rsclr +=
07105 shadow_table[shade_index + 3*m + 0] *
07106 weight_table[weight_index + m];
07107
07108 bot_gsclr +=
07109 shadow_table[shade_index + 3*m + 1] *
07110 weight_table[weight_index + m];
07111
07112 bot_bsclr +=
07113 shadow_table[shade_index + 3*m + 2] *
07114 weight_table[weight_index + m];
07115 };
07116 shade_factor = bot_opc * slice_depth_cueing;
07117
07118 bot_rclr *= shade_factor;
07119 bot_gclr *= shade_factor;
07120 bot_bclr *= shade_factor;
07121
07122 bot_rsclr *= shade_factor;
07123 bot_gsclr *= shade_factor;
07124 bot_bsclr *= shade_factor;
07125 }
07126
07127 #ifdef DEBUG
07128 if (ipixel == trace_pixel_ptr) {
07129 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
07130 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
07131 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
07132 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
07133 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
07134 }
07135 #endif
07136 ;
07137
07138 acc_opc = top_opc * wgtTL;
07139
07140 acc_rclr = (top_rclr + top_rsclr *
07141 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
07142 acc_gclr = (top_gclr + top_gsclr *
07143 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
07144 acc_bclr = (top_bclr + top_bsclr *
07145 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
07146
07147 #ifdef DEBUG
07148 if (ipixel == trace_pixel_ptr) {
07149 trace_opcTL = top_opc;
07150 trace_rclrTL = top_rclr;
07151 trace_gclrTL = top_gclr;
07152 trace_bclrTL = top_bclr;
07153
07154 }
07155 #endif
07156 ;
07157
07158 acc_opc += bot_opc * wgtBL;
07159
07160 acc_rclr += (bot_rclr + bot_rsclr *
07161 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
07162 acc_gclr += (bot_gclr + bot_gsclr *
07163 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
07164 acc_bclr += (bot_bclr + bot_bsclr *
07165 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
07166
07167 #ifdef DEBUG
07168 if (ipixel == trace_pixel_ptr) {
07169 trace_opcBL = bot_opc;
07170 trace_rclrBL = bot_rclr;
07171 trace_gclrBL = bot_gclr;
07172 trace_bclrBL = bot_bclr;
07173
07174 }
07175 #endif
07176 ;
07177
07178 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
07179
07180
07181 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
07182 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
07183
07184
07185
07186 top_rclr =
07187 shade_table[shade_index + 3*0 + 0] *
07188 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07189
07190 top_gclr =
07191 shade_table[shade_index + 3*0 + 1] *
07192 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07193
07194 top_bclr =
07195 shade_table[shade_index + 3*0 + 2] *
07196 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07197
07198 top_rsclr =
07199 shadow_table[shade_index + 3*0 + 0] *
07200 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07201
07202 top_gsclr =
07203 shadow_table[shade_index + 3*0 + 1] *
07204 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07205
07206 top_bsclr =
07207 shadow_table[shade_index + 3*0 + 2] *
07208 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07209 for (m = 1; m < num_materials; m++) {
07210
07211
07212 top_rclr +=
07213 shade_table[shade_index + 3*m + 0] *
07214 weight_table[weight_index + m];
07215
07216 top_gclr +=
07217 shade_table[shade_index + 3*m + 1] *
07218 weight_table[weight_index + m];
07219
07220 top_bclr +=
07221 shade_table[shade_index + 3*m + 2] *
07222 weight_table[weight_index + m];
07223
07224 top_rsclr +=
07225 shadow_table[shade_index + 3*m + 0] *
07226 weight_table[weight_index + m];
07227
07228 top_gsclr +=
07229 shadow_table[shade_index + 3*m + 1] *
07230 weight_table[weight_index + m];
07231
07232 top_bsclr +=
07233 shadow_table[shade_index + 3*m + 2] *
07234 weight_table[weight_index + m];
07235 };
07236 shade_factor = top_opc * slice_depth_cueing;
07237
07238 top_rclr *= shade_factor;
07239 top_gclr *= shade_factor;
07240 top_bclr *= shade_factor;
07241
07242 top_rsclr *= shade_factor;
07243 top_gsclr *= shade_factor;
07244 top_bsclr *= shade_factor;
07245
07246 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
07247
07248
07249 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
07250 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
07251
07252
07253
07254 bot_rclr =
07255 shade_table[shade_index + 3*0 + 0] *
07256 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07257
07258 bot_gclr =
07259 shade_table[shade_index + 3*0 + 1] *
07260 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07261
07262 bot_bclr =
07263 shade_table[shade_index + 3*0 + 2] *
07264 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07265
07266 bot_rsclr =
07267 shadow_table[shade_index + 3*0 + 0] *
07268 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07269
07270 bot_gsclr =
07271 shadow_table[shade_index + 3*0 + 1] *
07272 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07273
07274 bot_bsclr =
07275 shadow_table[shade_index + 3*0 + 2] *
07276 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07277 for (m = 1; m < num_materials; m++) {
07278
07279
07280 bot_rclr +=
07281 shade_table[shade_index + 3*m + 0] *
07282 weight_table[weight_index + m];
07283
07284 bot_gclr +=
07285 shade_table[shade_index + 3*m + 1] *
07286 weight_table[weight_index + m];
07287
07288 bot_bclr +=
07289 shade_table[shade_index + 3*m + 2] *
07290 weight_table[weight_index + m];
07291
07292 bot_rsclr +=
07293 shadow_table[shade_index + 3*m + 0] *
07294 weight_table[weight_index + m];
07295
07296 bot_gsclr +=
07297 shadow_table[shade_index + 3*m + 1] *
07298 weight_table[weight_index + m];
07299
07300 bot_bsclr +=
07301 shadow_table[shade_index + 3*m + 2] *
07302 weight_table[weight_index + m];
07303 };
07304 shade_factor = bot_opc * slice_depth_cueing;
07305
07306 bot_rclr *= shade_factor;
07307 bot_gclr *= shade_factor;
07308 bot_bclr *= shade_factor;
07309
07310 bot_rsclr *= shade_factor;
07311 bot_gsclr *= shade_factor;
07312 bot_bsclr *= shade_factor;
07313
07314 acc_opc += top_opc * wgtTR;
07315
07316 acc_rclr += (top_rclr + top_rsclr *
07317 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
07318 acc_gclr += (top_gclr + top_gsclr *
07319 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
07320 acc_bclr += (top_bclr + top_bsclr *
07321 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
07322
07323 #ifdef DEBUG
07324 if (ipixel == trace_pixel_ptr) {
07325 trace_opcTR = top_opc;
07326 trace_rclrTR = top_rclr;
07327 trace_gclrTR = top_gclr;
07328 trace_bclrTR = top_bclr;
07329
07330 }
07331 #endif
07332 ;
07333
07334 acc_opc += bot_opc * wgtBR;
07335
07336 acc_rclr += (bot_rclr + bot_rsclr *
07337 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
07338 acc_gclr += (bot_gclr + bot_gsclr *
07339 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
07340 acc_bclr += (bot_bclr + bot_bsclr *
07341 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
07342
07343 #ifdef DEBUG
07344 if (ipixel == trace_pixel_ptr) {
07345 trace_opcBR = bot_opc;
07346 trace_rclrBR = bot_rclr;
07347 trace_gclrBR = bot_gclr;
07348 trace_bclrBR = bot_bclr;
07349
07350 }
07351 #endif
07352 ;
07353
07354 COUNT_RESAMPLE;
07355 if (acc_opc > min_opacity) {
07356 COUNT_COMPOSITE;
07357 iopc = ipixel->opcflt;
07358 # ifndef SKIP_ERT
07359 ASSERT(iopc < max_opacity);
07360 # endif
07361 iopc_inv = (float)1. - iopc;
07362
07363 ipixel->rclrflt += acc_rclr * iopc_inv;
07364 ipixel->gclrflt += acc_gclr * iopc_inv;
07365 ipixel->bclrflt += acc_bclr * iopc_inv;
07366 iopc += acc_opc * iopc_inv;
07367 ipixel->opcflt = iopc;
07368
07369 #ifdef DEBUG
07370 if (ipixel == trace_pixel_ptr) {
07371 #ifdef COMPUTE_SHADOW_BUFFER
07372 printf("{%3d} %3d %3d", k, icount-i-count, j);
07373 #else
07374 printf("[%3d] %3d %3d", k, icount-i-count, j);
07375 #endif
07376 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
07377 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
07378 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
07379 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
07380 printf(" %3.0f %3.0f\n", iopc*255.,
07381 ipixel->rclrflt);
07382
07383 printf(" ");
07384 printf(" %3.0f ",trace_rsclrTL);
07385 printf(" %3.0f ",trace_rsclrBL);
07386 printf(" %3.0f ",trace_rsclrTR);
07387 printf(" %3.0f ",trace_rsclrBR);
07388 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
07389
07390 printf(" ");
07391 printf(" %3.0f ",trace_gclrTL);
07392 printf(" %3.0f ",trace_gclrBL);
07393 printf(" %3.0f ",trace_gclrTR);
07394 printf(" %3.0f ",trace_gclrBR);
07395 printf(" %3.0f\n", ipixel->gclrflt);
07396 printf(" ");
07397 printf(" %3.0f ",trace_bclrTL);
07398 printf(" %3.0f ",trace_bclrBL);
07399 printf(" %3.0f ",trace_bclrTR);
07400 printf(" %3.0f ",trace_bclrBR);
07401 printf(" %3.0f\n", ipixel->bclrflt);
07402 }
07403 #endif
07404 ;
07405 # ifndef SKIP_ERT
07406 if (iopc >= max_opacity) {
07407 ASSERT(ipixel->lnk == 0);
07408 ipixel->lnk = 1;
07409 }
07410 # endif
07411 };
07412 ipixel += 1; shadow_pixel += 1;
07413 topRLEdata += 1 * voxel_istride;
07414 botRLEdata += 1 * voxel_istride;
07415 count--;
07416 SET_VOXELS_LOADED;
07417 }
07418 break;
07419 case ALL_NONZERO__ALL_NONZERO:
07420
07421 while (count > 0) {
07422 if (PIXEL_IS_OPAQUE(ipixel))
07423 break;
07424 if (!voxels_loaded) {
07425
07426 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
07427
07428
07429 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
07430 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
07431
07432
07433
07434 top_rclr =
07435 shade_table[shade_index + 3*0 + 0] *
07436 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07437
07438 top_gclr =
07439 shade_table[shade_index + 3*0 + 1] *
07440 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07441
07442 top_bclr =
07443 shade_table[shade_index + 3*0 + 2] *
07444 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07445
07446 top_rsclr =
07447 shadow_table[shade_index + 3*0 + 0] *
07448 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07449
07450 top_gsclr =
07451 shadow_table[shade_index + 3*0 + 1] *
07452 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07453
07454 top_bsclr =
07455 shadow_table[shade_index + 3*0 + 2] *
07456 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07457 for (m = 1; m < num_materials; m++) {
07458
07459
07460 top_rclr +=
07461 shade_table[shade_index + 3*m + 0] *
07462 weight_table[weight_index + m];
07463
07464 top_gclr +=
07465 shade_table[shade_index + 3*m + 1] *
07466 weight_table[weight_index + m];
07467
07468 top_bclr +=
07469 shade_table[shade_index + 3*m + 2] *
07470 weight_table[weight_index + m];
07471
07472 top_rsclr +=
07473 shadow_table[shade_index + 3*m + 0] *
07474 weight_table[weight_index + m];
07475
07476 top_gsclr +=
07477 shadow_table[shade_index + 3*m + 1] *
07478 weight_table[weight_index + m];
07479
07480 top_bsclr +=
07481 shadow_table[shade_index + 3*m + 2] *
07482 weight_table[weight_index + m];
07483 };
07484 shade_factor = top_opc * slice_depth_cueing;
07485
07486 top_rclr *= shade_factor;
07487 top_gclr *= shade_factor;
07488 top_bclr *= shade_factor;
07489
07490 top_rsclr *= shade_factor;
07491 top_gsclr *= shade_factor;
07492 top_bsclr *= shade_factor;
07493
07494 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
07495
07496
07497 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
07498 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
07499
07500
07501
07502 bot_rclr =
07503 shade_table[shade_index + 3*0 + 0] *
07504 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07505
07506 bot_gclr =
07507 shade_table[shade_index + 3*0 + 1] *
07508 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07509
07510 bot_bclr =
07511 shade_table[shade_index + 3*0 + 2] *
07512 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07513
07514 bot_rsclr =
07515 shadow_table[shade_index + 3*0 + 0] *
07516 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07517
07518 bot_gsclr =
07519 shadow_table[shade_index + 3*0 + 1] *
07520 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07521
07522 bot_bsclr =
07523 shadow_table[shade_index + 3*0 + 2] *
07524 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07525 for (m = 1; m < num_materials; m++) {
07526
07527
07528 bot_rclr +=
07529 shade_table[shade_index + 3*m + 0] *
07530 weight_table[weight_index + m];
07531
07532 bot_gclr +=
07533 shade_table[shade_index + 3*m + 1] *
07534 weight_table[weight_index + m];
07535
07536 bot_bclr +=
07537 shade_table[shade_index + 3*m + 2] *
07538 weight_table[weight_index + m];
07539
07540 bot_rsclr +=
07541 shadow_table[shade_index + 3*m + 0] *
07542 weight_table[weight_index + m];
07543
07544 bot_gsclr +=
07545 shadow_table[shade_index + 3*m + 1] *
07546 weight_table[weight_index + m];
07547
07548 bot_bsclr +=
07549 shadow_table[shade_index + 3*m + 2] *
07550 weight_table[weight_index + m];
07551 };
07552 shade_factor = bot_opc * slice_depth_cueing;
07553
07554 bot_rclr *= shade_factor;
07555 bot_gclr *= shade_factor;
07556 bot_bclr *= shade_factor;
07557
07558 bot_rsclr *= shade_factor;
07559 bot_gsclr *= shade_factor;
07560 bot_bsclr *= shade_factor;
07561 }
07562
07563 #ifdef DEBUG
07564 if (ipixel == trace_pixel_ptr) {
07565 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
07566 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
07567 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
07568 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
07569 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
07570 }
07571 #endif
07572 ;
07573
07574 acc_opc = top_opc * wgtTL;
07575
07576 acc_rclr = (top_rclr + top_rsclr *
07577 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
07578 acc_gclr = (top_gclr + top_gsclr *
07579 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
07580 acc_bclr = (top_bclr + top_bsclr *
07581 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
07582
07583 #ifdef DEBUG
07584 if (ipixel == trace_pixel_ptr) {
07585 trace_opcTL = top_opc;
07586 trace_rclrTL = top_rclr;
07587 trace_gclrTL = top_gclr;
07588 trace_bclrTL = top_bclr;
07589
07590 }
07591 #endif
07592 ;
07593
07594 acc_opc += bot_opc * wgtBL;
07595
07596 acc_rclr += (bot_rclr + bot_rsclr *
07597 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
07598 acc_gclr += (bot_gclr + bot_gsclr *
07599 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
07600 acc_bclr += (bot_bclr + bot_bsclr *
07601 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
07602
07603 #ifdef DEBUG
07604 if (ipixel == trace_pixel_ptr) {
07605 trace_opcBL = bot_opc;
07606 trace_rclrBL = bot_rclr;
07607 trace_gclrBL = bot_gclr;
07608 trace_bclrBL = bot_bclr;
07609
07610 }
07611 #endif
07612 ;
07613
07614 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
07615
07616
07617 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
07618 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
07619
07620
07621
07622 top_rclr =
07623 shade_table[shade_index + 3*0 + 0] *
07624 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07625
07626 top_gclr =
07627 shade_table[shade_index + 3*0 + 1] *
07628 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07629
07630 top_bclr =
07631 shade_table[shade_index + 3*0 + 2] *
07632 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07633
07634 top_rsclr =
07635 shadow_table[shade_index + 3*0 + 0] *
07636 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07637
07638 top_gsclr =
07639 shadow_table[shade_index + 3*0 + 1] *
07640 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07641
07642 top_bsclr =
07643 shadow_table[shade_index + 3*0 + 2] *
07644 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07645 for (m = 1; m < num_materials; m++) {
07646
07647
07648 top_rclr +=
07649 shade_table[shade_index + 3*m + 0] *
07650 weight_table[weight_index + m];
07651
07652 top_gclr +=
07653 shade_table[shade_index + 3*m + 1] *
07654 weight_table[weight_index + m];
07655
07656 top_bclr +=
07657 shade_table[shade_index + 3*m + 2] *
07658 weight_table[weight_index + m];
07659
07660 top_rsclr +=
07661 shadow_table[shade_index + 3*m + 0] *
07662 weight_table[weight_index + m];
07663
07664 top_gsclr +=
07665 shadow_table[shade_index + 3*m + 1] *
07666 weight_table[weight_index + m];
07667
07668 top_bsclr +=
07669 shadow_table[shade_index + 3*m + 2] *
07670 weight_table[weight_index + m];
07671 };
07672 shade_factor = top_opc * slice_depth_cueing;
07673
07674 top_rclr *= shade_factor;
07675 top_gclr *= shade_factor;
07676 top_bclr *= shade_factor;
07677
07678 top_rsclr *= shade_factor;
07679 top_gsclr *= shade_factor;
07680 top_bsclr *= shade_factor;
07681
07682 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
07683
07684
07685 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
07686 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
07687
07688
07689
07690 bot_rclr =
07691 shade_table[shade_index + 3*0 + 0] *
07692 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07693
07694 bot_gclr =
07695 shade_table[shade_index + 3*0 + 1] *
07696 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07697
07698 bot_bclr =
07699 shade_table[shade_index + 3*0 + 2] *
07700 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07701
07702 bot_rsclr =
07703 shadow_table[shade_index + 3*0 + 0] *
07704 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07705
07706 bot_gsclr =
07707 shadow_table[shade_index + 3*0 + 1] *
07708 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07709
07710 bot_bsclr =
07711 shadow_table[shade_index + 3*0 + 2] *
07712 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07713 for (m = 1; m < num_materials; m++) {
07714
07715
07716 bot_rclr +=
07717 shade_table[shade_index + 3*m + 0] *
07718 weight_table[weight_index + m];
07719
07720 bot_gclr +=
07721 shade_table[shade_index + 3*m + 1] *
07722 weight_table[weight_index + m];
07723
07724 bot_bclr +=
07725 shade_table[shade_index + 3*m + 2] *
07726 weight_table[weight_index + m];
07727
07728 bot_rsclr +=
07729 shadow_table[shade_index + 3*m + 0] *
07730 weight_table[weight_index + m];
07731
07732 bot_gsclr +=
07733 shadow_table[shade_index + 3*m + 1] *
07734 weight_table[weight_index + m];
07735
07736 bot_bsclr +=
07737 shadow_table[shade_index + 3*m + 2] *
07738 weight_table[weight_index + m];
07739 };
07740 shade_factor = bot_opc * slice_depth_cueing;
07741
07742 bot_rclr *= shade_factor;
07743 bot_gclr *= shade_factor;
07744 bot_bclr *= shade_factor;
07745
07746 bot_rsclr *= shade_factor;
07747 bot_gsclr *= shade_factor;
07748 bot_bsclr *= shade_factor;
07749
07750 acc_opc += top_opc * wgtTR;
07751
07752 acc_rclr += (top_rclr + top_rsclr *
07753 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
07754 acc_gclr += (top_gclr + top_gsclr *
07755 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
07756 acc_bclr += (top_bclr + top_bsclr *
07757 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
07758
07759 #ifdef DEBUG
07760 if (ipixel == trace_pixel_ptr) {
07761 trace_opcTR = top_opc;
07762 trace_rclrTR = top_rclr;
07763 trace_gclrTR = top_gclr;
07764 trace_bclrTR = top_bclr;
07765
07766 }
07767 #endif
07768 ;
07769
07770 acc_opc += bot_opc * wgtBR;
07771
07772 acc_rclr += (bot_rclr + bot_rsclr *
07773 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
07774 acc_gclr += (bot_gclr + bot_gsclr *
07775 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
07776 acc_bclr += (bot_bclr + bot_bsclr *
07777 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
07778
07779 #ifdef DEBUG
07780 if (ipixel == trace_pixel_ptr) {
07781 trace_opcBR = bot_opc;
07782 trace_rclrBR = bot_rclr;
07783 trace_gclrBR = bot_gclr;
07784 trace_bclrBR = bot_bclr;
07785
07786 }
07787 #endif
07788 ;
07789
07790 COUNT_RESAMPLE;
07791 if (acc_opc > min_opacity) {
07792 COUNT_COMPOSITE;
07793 iopc = ipixel->opcflt;
07794 # ifndef SKIP_ERT
07795 ASSERT(iopc < max_opacity);
07796 # endif
07797 iopc_inv = (float)1. - iopc;
07798
07799 ipixel->rclrflt += acc_rclr * iopc_inv;
07800 ipixel->gclrflt += acc_gclr * iopc_inv;
07801 ipixel->bclrflt += acc_bclr * iopc_inv;
07802 iopc += acc_opc * iopc_inv;
07803 ipixel->opcflt = iopc;
07804
07805 #ifdef DEBUG
07806 if (ipixel == trace_pixel_ptr) {
07807 #ifdef COMPUTE_SHADOW_BUFFER
07808 printf("{%3d} %3d %3d", k, icount-i-count, j);
07809 #else
07810 printf("[%3d] %3d %3d", k, icount-i-count, j);
07811 #endif
07812 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
07813 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
07814 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
07815 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
07816 printf(" %3.0f %3.0f\n", iopc*255.,
07817 ipixel->rclrflt);
07818
07819 printf(" ");
07820 printf(" %3.0f ",trace_rsclrTL);
07821 printf(" %3.0f ",trace_rsclrBL);
07822 printf(" %3.0f ",trace_rsclrTR);
07823 printf(" %3.0f ",trace_rsclrBR);
07824 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
07825
07826 printf(" ");
07827 printf(" %3.0f ",trace_gclrTL);
07828 printf(" %3.0f ",trace_gclrBL);
07829 printf(" %3.0f ",trace_gclrTR);
07830 printf(" %3.0f ",trace_gclrBR);
07831 printf(" %3.0f\n", ipixel->gclrflt);
07832 printf(" ");
07833 printf(" %3.0f ",trace_bclrTL);
07834 printf(" %3.0f ",trace_bclrBL);
07835 printf(" %3.0f ",trace_bclrTR);
07836 printf(" %3.0f ",trace_bclrBR);
07837 printf(" %3.0f\n", ipixel->bclrflt);
07838 }
07839 #endif
07840 ;
07841 # ifndef SKIP_ERT
07842 if (iopc >= max_opacity) {
07843 ASSERT(ipixel->lnk == 0);
07844 ipixel->lnk = 1;
07845 }
07846 # endif
07847 };
07848 ipixel += 1; shadow_pixel += 1;
07849 topRLEdata += 1 * voxel_istride;
07850 botRLEdata += 1 * voxel_istride;
07851 count--;
07852 SET_VOXELS_LOADED;
07853 }
07854 break;
07855 default:
07856 VPBug("illegal value for run states in compositing loop");
07857 }
07858 #else
07859
07860 while (count > 0) {
07861 if (last_run_state == ALL_ZERO && run_state == ALL_ZERO) {
07862 ipixel += count; shadow_pixel += count;
07863 if (i != -1) {
07864 ;
07865 ;
07866 }
07867 count = 0;
07868 break;
07869 }
07870 if (ipixel->lnk != 0)
07871 break;
07872
07873 #ifdef DEBUG
07874 if (ipixel == trace_pixel_ptr) {
07875 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
07876 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
07877 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
07878 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
07879 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
07880 }
07881 #endif
07882 ;
07883
07884 acc_opc = 0;
07885 acc_rclr = acc_gclr = acc_bclr = 0;
07886 if (last_run_state & TOP_NONZERO) {
07887 if (!voxels_loaded) {
07888
07889 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
07890
07891
07892 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
07893 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
07894
07895
07896
07897 top_rclr =
07898 shade_table[shade_index + 3*0 + 0] *
07899 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07900
07901 top_gclr =
07902 shade_table[shade_index + 3*0 + 1] *
07903 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07904
07905 top_bclr =
07906 shade_table[shade_index + 3*0 + 2] *
07907 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07908
07909 top_rsclr =
07910 shadow_table[shade_index + 3*0 + 0] *
07911 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07912
07913 top_gsclr =
07914 shadow_table[shade_index + 3*0 + 1] *
07915 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07916
07917 top_bsclr =
07918 shadow_table[shade_index + 3*0 + 2] *
07919 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07920 for (m = 1; m < num_materials; m++) {
07921
07922
07923 top_rclr +=
07924 shade_table[shade_index + 3*m + 0] *
07925 weight_table[weight_index + m];
07926
07927 top_gclr +=
07928 shade_table[shade_index + 3*m + 1] *
07929 weight_table[weight_index + m];
07930
07931 top_bclr +=
07932 shade_table[shade_index + 3*m + 2] *
07933 weight_table[weight_index + m];
07934
07935 top_rsclr +=
07936 shadow_table[shade_index + 3*m + 0] *
07937 weight_table[weight_index + m];
07938
07939 top_gsclr +=
07940 shadow_table[shade_index + 3*m + 1] *
07941 weight_table[weight_index + m];
07942
07943 top_bsclr +=
07944 shadow_table[shade_index + 3*m + 2] *
07945 weight_table[weight_index + m];
07946 };
07947 shade_factor = top_opc * slice_depth_cueing;
07948
07949 top_rclr *= shade_factor;
07950 top_gclr *= shade_factor;
07951 top_bclr *= shade_factor;
07952
07953 top_rsclr *= shade_factor;
07954 top_gsclr *= shade_factor;
07955 top_bsclr *= shade_factor;
07956 }
07957
07958 acc_opc += top_opc * wgtTL;
07959
07960 acc_rclr += (top_rclr + top_rsclr *
07961 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
07962 acc_gclr += (top_gclr + top_gsclr *
07963 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
07964 acc_bclr += (top_bclr + top_bsclr *
07965 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
07966
07967 #ifdef DEBUG
07968 if (ipixel == trace_pixel_ptr) {
07969 trace_opcTL = top_opc;
07970 trace_rclrTL = top_rclr;
07971 trace_gclrTL = top_gclr;
07972 trace_bclrTL = top_bclr;
07973
07974 }
07975 #endif
07976 ;
07977 }
07978 if (last_run_state & BOT_NONZERO) {
07979 if (!voxels_loaded) {
07980
07981 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
07982
07983
07984 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
07985 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
07986
07987
07988
07989 bot_rclr =
07990 shade_table[shade_index + 3*0 + 0] *
07991 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07992
07993 bot_gclr =
07994 shade_table[shade_index + 3*0 + 1] *
07995 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
07996
07997 bot_bclr =
07998 shade_table[shade_index + 3*0 + 2] *
07999 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08000
08001 bot_rsclr =
08002 shadow_table[shade_index + 3*0 + 0] *
08003 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08004
08005 bot_gsclr =
08006 shadow_table[shade_index + 3*0 + 1] *
08007 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08008
08009 bot_bsclr =
08010 shadow_table[shade_index + 3*0 + 2] *
08011 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08012 for (m = 1; m < num_materials; m++) {
08013
08014
08015 bot_rclr +=
08016 shade_table[shade_index + 3*m + 0] *
08017 weight_table[weight_index + m];
08018
08019 bot_gclr +=
08020 shade_table[shade_index + 3*m + 1] *
08021 weight_table[weight_index + m];
08022
08023 bot_bclr +=
08024 shade_table[shade_index + 3*m + 2] *
08025 weight_table[weight_index + m];
08026
08027 bot_rsclr +=
08028 shadow_table[shade_index + 3*m + 0] *
08029 weight_table[weight_index + m];
08030
08031 bot_gsclr +=
08032 shadow_table[shade_index + 3*m + 1] *
08033 weight_table[weight_index + m];
08034
08035 bot_bsclr +=
08036 shadow_table[shade_index + 3*m + 2] *
08037 weight_table[weight_index + m];
08038 };
08039 shade_factor = bot_opc * slice_depth_cueing;
08040
08041 bot_rclr *= shade_factor;
08042 bot_gclr *= shade_factor;
08043 bot_bclr *= shade_factor;
08044
08045 bot_rsclr *= shade_factor;
08046 bot_gsclr *= shade_factor;
08047 bot_bsclr *= shade_factor;
08048 }
08049
08050 acc_opc += bot_opc * wgtBL;
08051
08052 acc_rclr += (bot_rclr + bot_rsclr *
08053 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
08054 acc_gclr += (bot_gclr + bot_gsclr *
08055 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
08056 acc_bclr += (bot_bclr + bot_bsclr *
08057 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
08058
08059 #ifdef DEBUG
08060 if (ipixel == trace_pixel_ptr) {
08061 trace_opcBL = bot_opc;
08062 trace_rclrBL = bot_rclr;
08063 trace_gclrBL = bot_gclr;
08064 trace_bclrBL = bot_bclr;
08065
08066 }
08067 #endif
08068 ;
08069 }
08070 if (run_state & TOP_NONZERO) {
08071
08072 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
08073
08074
08075 shade_index=num_materials*3*ShortField(topRLEdata,norm_offset);
08076 weight_index = num_materials * ByteField(topRLEdata, wgt_offset);
08077
08078
08079
08080 top_rclr =
08081 shade_table[shade_index + 3*0 + 0] *
08082 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08083
08084 top_gclr =
08085 shade_table[shade_index + 3*0 + 1] *
08086 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08087
08088 top_bclr =
08089 shade_table[shade_index + 3*0 + 2] *
08090 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08091
08092 top_rsclr =
08093 shadow_table[shade_index + 3*0 + 0] *
08094 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08095
08096 top_gsclr =
08097 shadow_table[shade_index + 3*0 + 1] *
08098 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08099
08100 top_bsclr =
08101 shadow_table[shade_index + 3*0 + 2] *
08102 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08103 for (m = 1; m < num_materials; m++) {
08104
08105
08106 top_rclr +=
08107 shade_table[shade_index + 3*m + 0] *
08108 weight_table[weight_index + m];
08109
08110 top_gclr +=
08111 shade_table[shade_index + 3*m + 1] *
08112 weight_table[weight_index + m];
08113
08114 top_bclr +=
08115 shade_table[shade_index + 3*m + 2] *
08116 weight_table[weight_index + m];
08117
08118 top_rsclr +=
08119 shadow_table[shade_index + 3*m + 0] *
08120 weight_table[weight_index + m];
08121
08122 top_gsclr +=
08123 shadow_table[shade_index + 3*m + 1] *
08124 weight_table[weight_index + m];
08125
08126 top_bsclr +=
08127 shadow_table[shade_index + 3*m + 2] *
08128 weight_table[weight_index + m];
08129 };
08130 shade_factor = top_opc * slice_depth_cueing;
08131
08132 top_rclr *= shade_factor;
08133 top_gclr *= shade_factor;
08134 top_bclr *= shade_factor;
08135
08136 top_rsclr *= shade_factor;
08137 top_gsclr *= shade_factor;
08138 top_bsclr *= shade_factor;
08139
08140 acc_opc += top_opc * wgtTR;
08141
08142 acc_rclr += (top_rclr + top_rsclr *
08143 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
08144 acc_gclr += (top_gclr + top_gsclr *
08145 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
08146 acc_bclr += (top_bclr + top_bsclr *
08147 ((float)1.0 - shadow_pixel->opcflt)) * wgtTR;
08148
08149 #ifdef DEBUG
08150 if (ipixel == trace_pixel_ptr) {
08151 trace_opcTR = top_opc;
08152 trace_rclrTR = top_rclr;
08153 trace_gclrTR = top_gclr;
08154 trace_bclrTR = top_bclr;
08155
08156 }
08157 #endif
08158 ;
08159 topRLEdata += 1 * voxel_istride;
08160 } else {
08161 if (i != -1) {
08162 ;
08163 }
08164 }
08165 if (run_state & BOT_NONZERO) {
08166
08167 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
08168
08169
08170 shade_index=num_materials*3*ShortField(botRLEdata,norm_offset);
08171 weight_index = num_materials * ByteField(botRLEdata, wgt_offset);
08172
08173
08174
08175 bot_rclr =
08176 shade_table[shade_index + 3*0 + 0] *
08177 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08178
08179 bot_gclr =
08180 shade_table[shade_index + 3*0 + 1] *
08181 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08182
08183 bot_bclr =
08184 shade_table[shade_index + 3*0 + 2] *
08185 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08186
08187 bot_rsclr =
08188 shadow_table[shade_index + 3*0 + 0] *
08189 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08190
08191 bot_gsclr =
08192 shadow_table[shade_index + 3*0 + 1] *
08193 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08194
08195 bot_bsclr =
08196 shadow_table[shade_index + 3*0 + 2] *
08197 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08198 for (m = 1; m < num_materials; m++) {
08199
08200
08201 bot_rclr +=
08202 shade_table[shade_index + 3*m + 0] *
08203 weight_table[weight_index + m];
08204
08205 bot_gclr +=
08206 shade_table[shade_index + 3*m + 1] *
08207 weight_table[weight_index + m];
08208
08209 bot_bclr +=
08210 shade_table[shade_index + 3*m + 2] *
08211 weight_table[weight_index + m];
08212
08213 bot_rsclr +=
08214 shadow_table[shade_index + 3*m + 0] *
08215 weight_table[weight_index + m];
08216
08217 bot_gsclr +=
08218 shadow_table[shade_index + 3*m + 1] *
08219 weight_table[weight_index + m];
08220
08221 bot_bsclr +=
08222 shadow_table[shade_index + 3*m + 2] *
08223 weight_table[weight_index + m];
08224 };
08225 shade_factor = bot_opc * slice_depth_cueing;
08226
08227 bot_rclr *= shade_factor;
08228 bot_gclr *= shade_factor;
08229 bot_bclr *= shade_factor;
08230
08231 bot_rsclr *= shade_factor;
08232 bot_gsclr *= shade_factor;
08233 bot_bsclr *= shade_factor;
08234
08235 acc_opc += bot_opc * wgtBR;
08236
08237 acc_rclr += (bot_rclr + bot_rsclr *
08238 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
08239 acc_gclr += (bot_gclr + bot_gsclr *
08240 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
08241 acc_bclr += (bot_bclr + bot_bsclr *
08242 ((float)1.0 - shadow_pixel->opcflt)) * wgtBR;
08243
08244 #ifdef DEBUG
08245 if (ipixel == trace_pixel_ptr) {
08246 trace_opcBR = bot_opc;
08247 trace_rclrBR = bot_rclr;
08248 trace_gclrBR = bot_gclr;
08249 trace_bclrBR = bot_bclr;
08250
08251 }
08252 #endif
08253 ;
08254 botRLEdata += 1 * voxel_istride;
08255 } else {
08256 if (i != -1) {
08257 ;
08258 }
08259 }
08260
08261 COUNT_RESAMPLE;
08262 if (acc_opc > min_opacity) {
08263 COUNT_COMPOSITE;
08264 iopc = ipixel->opcflt;
08265 # ifndef SKIP_ERT
08266 ASSERT(iopc < max_opacity);
08267 # endif
08268 iopc_inv = (float)1. - iopc;
08269
08270 ipixel->rclrflt += acc_rclr * iopc_inv;
08271 ipixel->gclrflt += acc_gclr * iopc_inv;
08272 ipixel->bclrflt += acc_bclr * iopc_inv;
08273 iopc += acc_opc * iopc_inv;
08274 ipixel->opcflt = iopc;
08275
08276 #ifdef DEBUG
08277 if (ipixel == trace_pixel_ptr) {
08278 #ifdef COMPUTE_SHADOW_BUFFER
08279 printf("{%3d} %3d %3d", k, icount-i-count, j);
08280 #else
08281 printf("[%3d] %3d %3d", k, icount-i-count, j);
08282 #endif
08283 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
08284 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
08285 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
08286 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
08287 printf(" %3.0f %3.0f\n", iopc*255.,
08288 ipixel->rclrflt);
08289
08290 printf(" ");
08291 printf(" %3.0f ",trace_rsclrTL);
08292 printf(" %3.0f ",trace_rsclrBL);
08293 printf(" %3.0f ",trace_rsclrTR);
08294 printf(" %3.0f ",trace_rsclrBR);
08295 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
08296
08297 printf(" ");
08298 printf(" %3.0f ",trace_gclrTL);
08299 printf(" %3.0f ",trace_gclrBL);
08300 printf(" %3.0f ",trace_gclrTR);
08301 printf(" %3.0f ",trace_gclrBR);
08302 printf(" %3.0f\n", ipixel->gclrflt);
08303 printf(" ");
08304 printf(" %3.0f ",trace_bclrTL);
08305 printf(" %3.0f ",trace_bclrBL);
08306 printf(" %3.0f ",trace_bclrTR);
08307 printf(" %3.0f ",trace_bclrBR);
08308 printf(" %3.0f\n", ipixel->bclrflt);
08309 }
08310 #endif
08311 ;
08312 # ifndef SKIP_ERT
08313 if (iopc >= max_opacity) {
08314 ASSERT(ipixel->lnk == 0);
08315 ipixel->lnk = 1;
08316 }
08317 # endif
08318 };
08319 ipixel += 1; shadow_pixel += 1;
08320 count--;
08321 SET_VOXELS_LOADED;
08322 last_run_state = run_state;
08323 }
08324 #endif
08325
08326 GET_HIRES_TIME(vpc, t1);
08327 STORE_HIRES_TIME(vpc, VPTIMER_PROCESS_VOXELS, t0, t1);
08328 COPY_HIRES_TIME(t0, t1);
08329
08330 if (count > 0) {
08331 Debug((vpc, VPDEBUG_COMPOSITE, "Backup(%d)\n", count));
08332 toprun_count += count;
08333 botrun_count += count;
08334 i += count;
08335 }
08336 #endif
08337
08338
08339
08340
08341
08342 last_run_state = run_state;
08343 }
08344
08345
08346
08347
08348
08349 #ifdef UNROLL_RUN_LOOP
08350 ASSERT(i == 0);
08351 #else
08352 ASSERT(i == -1);
08353 #endif
08354
08355 #ifndef SKIP_COMPOSITE
08356 #ifdef UNROLL_RUN_LOOP
08357
08358 if (last_run_state != ALL_ZERO && !PIXEL_IS_OPAQUE(ipixel)) {
08359
08360
08361 Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
08362 switch (last_run_state) {
08363 case TOP_NONZERO:
08364
08365 if (!voxels_loaded) {
08366
08367 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
08368
08369
08370 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
08371 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
08372
08373
08374
08375 top_rclr =
08376 shade_table[shade_index + 3*0 + 0] *
08377 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08378
08379 top_gclr =
08380 shade_table[shade_index + 3*0 + 1] *
08381 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08382
08383 top_bclr =
08384 shade_table[shade_index + 3*0 + 2] *
08385 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08386
08387 top_rsclr =
08388 shadow_table[shade_index + 3*0 + 0] *
08389 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08390
08391 top_gsclr =
08392 shadow_table[shade_index + 3*0 + 1] *
08393 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08394
08395 top_bsclr =
08396 shadow_table[shade_index + 3*0 + 2] *
08397 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08398 for (m = 1; m < num_materials; m++) {
08399
08400
08401 top_rclr +=
08402 shade_table[shade_index + 3*m + 0] *
08403 weight_table[weight_index + m];
08404
08405 top_gclr +=
08406 shade_table[shade_index + 3*m + 1] *
08407 weight_table[weight_index + m];
08408
08409 top_bclr +=
08410 shade_table[shade_index + 3*m + 2] *
08411 weight_table[weight_index + m];
08412
08413 top_rsclr +=
08414 shadow_table[shade_index + 3*m + 0] *
08415 weight_table[weight_index + m];
08416
08417 top_gsclr +=
08418 shadow_table[shade_index + 3*m + 1] *
08419 weight_table[weight_index + m];
08420
08421 top_bsclr +=
08422 shadow_table[shade_index + 3*m + 2] *
08423 weight_table[weight_index + m];
08424 };
08425 shade_factor = top_opc * slice_depth_cueing;
08426
08427 top_rclr *= shade_factor;
08428 top_gclr *= shade_factor;
08429 top_bclr *= shade_factor;
08430
08431 top_rsclr *= shade_factor;
08432 top_gsclr *= shade_factor;
08433 top_bsclr *= shade_factor;
08434 }
08435
08436 #ifdef DEBUG
08437 if (ipixel == trace_pixel_ptr) {
08438 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
08439 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
08440 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
08441 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
08442 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
08443 }
08444 #endif
08445 ;
08446
08447 acc_opc = top_opc * wgtTL;
08448
08449 acc_rclr = (top_rclr + top_rsclr *
08450 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
08451 acc_gclr = (top_gclr + top_gsclr *
08452 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
08453 acc_bclr = (top_bclr + top_bsclr *
08454 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
08455
08456 #ifdef DEBUG
08457 if (ipixel == trace_pixel_ptr) {
08458 trace_opcTL = top_opc;
08459 trace_rclrTL = top_rclr;
08460 trace_gclrTL = top_gclr;
08461 trace_bclrTL = top_bclr;
08462
08463 }
08464 #endif
08465 ;
08466
08467 COUNT_RESAMPLE;
08468 if (acc_opc > min_opacity) {
08469 COUNT_COMPOSITE;
08470 iopc = ipixel->opcflt;
08471 # ifndef SKIP_ERT
08472 ASSERT(iopc < max_opacity);
08473 # endif
08474 iopc_inv = (float)1. - iopc;
08475
08476 ipixel->rclrflt += acc_rclr * iopc_inv;
08477 ipixel->gclrflt += acc_gclr * iopc_inv;
08478 ipixel->bclrflt += acc_bclr * iopc_inv;
08479 iopc += acc_opc * iopc_inv;
08480 ipixel->opcflt = iopc;
08481
08482 #ifdef DEBUG
08483 if (ipixel == trace_pixel_ptr) {
08484 #ifdef COMPUTE_SHADOW_BUFFER
08485 printf("{%3d} %3d %3d", k, icount-i-count, j);
08486 #else
08487 printf("[%3d] %3d %3d", k, icount-i-count, j);
08488 #endif
08489 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
08490 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
08491 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
08492 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
08493 printf(" %3.0f %3.0f\n", iopc*255.,
08494 ipixel->rclrflt);
08495
08496 printf(" ");
08497 printf(" %3.0f ",trace_rsclrTL);
08498 printf(" %3.0f ",trace_rsclrBL);
08499 printf(" %3.0f ",trace_rsclrTR);
08500 printf(" %3.0f ",trace_rsclrBR);
08501 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
08502
08503 printf(" ");
08504 printf(" %3.0f ",trace_gclrTL);
08505 printf(" %3.0f ",trace_gclrBL);
08506 printf(" %3.0f ",trace_gclrTR);
08507 printf(" %3.0f ",trace_gclrBR);
08508 printf(" %3.0f\n", ipixel->gclrflt);
08509 printf(" ");
08510 printf(" %3.0f ",trace_bclrTL);
08511 printf(" %3.0f ",trace_bclrBL);
08512 printf(" %3.0f ",trace_bclrTR);
08513 printf(" %3.0f ",trace_bclrBR);
08514 printf(" %3.0f\n", ipixel->bclrflt);
08515 }
08516 #endif
08517 ;
08518 # ifndef SKIP_ERT
08519 if (iopc >= max_opacity) {
08520 ASSERT(ipixel->lnk == 0);
08521 ipixel->lnk = 1;
08522 }
08523 # endif
08524 };
08525 break;
08526 case BOT_NONZERO:
08527
08528 if (!voxels_loaded) {
08529
08530 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
08531
08532
08533 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
08534 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
08535
08536
08537
08538 bot_rclr =
08539 shade_table[shade_index + 3*0 + 0] *
08540 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08541
08542 bot_gclr =
08543 shade_table[shade_index + 3*0 + 1] *
08544 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08545
08546 bot_bclr =
08547 shade_table[shade_index + 3*0 + 2] *
08548 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08549
08550 bot_rsclr =
08551 shadow_table[shade_index + 3*0 + 0] *
08552 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08553
08554 bot_gsclr =
08555 shadow_table[shade_index + 3*0 + 1] *
08556 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08557
08558 bot_bsclr =
08559 shadow_table[shade_index + 3*0 + 2] *
08560 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08561 for (m = 1; m < num_materials; m++) {
08562
08563
08564 bot_rclr +=
08565 shade_table[shade_index + 3*m + 0] *
08566 weight_table[weight_index + m];
08567
08568 bot_gclr +=
08569 shade_table[shade_index + 3*m + 1] *
08570 weight_table[weight_index + m];
08571
08572 bot_bclr +=
08573 shade_table[shade_index + 3*m + 2] *
08574 weight_table[weight_index + m];
08575
08576 bot_rsclr +=
08577 shadow_table[shade_index + 3*m + 0] *
08578 weight_table[weight_index + m];
08579
08580 bot_gsclr +=
08581 shadow_table[shade_index + 3*m + 1] *
08582 weight_table[weight_index + m];
08583
08584 bot_bsclr +=
08585 shadow_table[shade_index + 3*m + 2] *
08586 weight_table[weight_index + m];
08587 };
08588 shade_factor = bot_opc * slice_depth_cueing;
08589
08590 bot_rclr *= shade_factor;
08591 bot_gclr *= shade_factor;
08592 bot_bclr *= shade_factor;
08593
08594 bot_rsclr *= shade_factor;
08595 bot_gsclr *= shade_factor;
08596 bot_bsclr *= shade_factor;
08597 }
08598
08599 #ifdef DEBUG
08600 if (ipixel == trace_pixel_ptr) {
08601 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
08602 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
08603 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
08604 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
08605 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
08606 }
08607 #endif
08608 ;
08609
08610 acc_opc = bot_opc * wgtBL;
08611
08612 acc_rclr = (bot_rclr + bot_rsclr *
08613 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
08614 acc_gclr = (bot_gclr + bot_gsclr *
08615 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
08616 acc_bclr = (bot_bclr + bot_bsclr *
08617 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
08618
08619 #ifdef DEBUG
08620 if (ipixel == trace_pixel_ptr) {
08621 trace_opcBL = bot_opc;
08622 trace_rclrBL = bot_rclr;
08623 trace_gclrBL = bot_gclr;
08624 trace_bclrBL = bot_bclr;
08625
08626 }
08627 #endif
08628 ;
08629
08630 COUNT_RESAMPLE;
08631 if (acc_opc > min_opacity) {
08632 COUNT_COMPOSITE;
08633 iopc = ipixel->opcflt;
08634 # ifndef SKIP_ERT
08635 ASSERT(iopc < max_opacity);
08636 # endif
08637 iopc_inv = (float)1. - iopc;
08638
08639 ipixel->rclrflt += acc_rclr * iopc_inv;
08640 ipixel->gclrflt += acc_gclr * iopc_inv;
08641 ipixel->bclrflt += acc_bclr * iopc_inv;
08642 iopc += acc_opc * iopc_inv;
08643 ipixel->opcflt = iopc;
08644
08645 #ifdef DEBUG
08646 if (ipixel == trace_pixel_ptr) {
08647 #ifdef COMPUTE_SHADOW_BUFFER
08648 printf("{%3d} %3d %3d", k, icount-i-count, j);
08649 #else
08650 printf("[%3d] %3d %3d", k, icount-i-count, j);
08651 #endif
08652 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
08653 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
08654 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
08655 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
08656 printf(" %3.0f %3.0f\n", iopc*255.,
08657 ipixel->rclrflt);
08658
08659 printf(" ");
08660 printf(" %3.0f ",trace_rsclrTL);
08661 printf(" %3.0f ",trace_rsclrBL);
08662 printf(" %3.0f ",trace_rsclrTR);
08663 printf(" %3.0f ",trace_rsclrBR);
08664 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
08665
08666 printf(" ");
08667 printf(" %3.0f ",trace_gclrTL);
08668 printf(" %3.0f ",trace_gclrBL);
08669 printf(" %3.0f ",trace_gclrTR);
08670 printf(" %3.0f ",trace_gclrBR);
08671 printf(" %3.0f\n", ipixel->gclrflt);
08672 printf(" ");
08673 printf(" %3.0f ",trace_bclrTL);
08674 printf(" %3.0f ",trace_bclrBL);
08675 printf(" %3.0f ",trace_bclrTR);
08676 printf(" %3.0f ",trace_bclrBR);
08677 printf(" %3.0f\n", ipixel->bclrflt);
08678 }
08679 #endif
08680 ;
08681 # ifndef SKIP_ERT
08682 if (iopc >= max_opacity) {
08683 ASSERT(ipixel->lnk == 0);
08684 ipixel->lnk = 1;
08685 }
08686 # endif
08687 };
08688 break;
08689 case ALL_NONZERO:
08690
08691 if (!voxels_loaded) {
08692
08693 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
08694
08695
08696 shade_index=num_materials*3*ShortField(topRLEdata - voxel_istride,norm_offset);
08697 weight_index = num_materials * ByteField(topRLEdata - voxel_istride, wgt_offset);
08698
08699
08700
08701 top_rclr =
08702 shade_table[shade_index + 3*0 + 0] *
08703 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08704
08705 top_gclr =
08706 shade_table[shade_index + 3*0 + 1] *
08707 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08708
08709 top_bclr =
08710 shade_table[shade_index + 3*0 + 2] *
08711 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08712
08713 top_rsclr =
08714 shadow_table[shade_index + 3*0 + 0] *
08715 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08716
08717 top_gsclr =
08718 shadow_table[shade_index + 3*0 + 1] *
08719 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08720
08721 top_bsclr =
08722 shadow_table[shade_index + 3*0 + 2] *
08723 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08724 for (m = 1; m < num_materials; m++) {
08725
08726
08727 top_rclr +=
08728 shade_table[shade_index + 3*m + 0] *
08729 weight_table[weight_index + m];
08730
08731 top_gclr +=
08732 shade_table[shade_index + 3*m + 1] *
08733 weight_table[weight_index + m];
08734
08735 top_bclr +=
08736 shade_table[shade_index + 3*m + 2] *
08737 weight_table[weight_index + m];
08738
08739 top_rsclr +=
08740 shadow_table[shade_index + 3*m + 0] *
08741 weight_table[weight_index + m];
08742
08743 top_gsclr +=
08744 shadow_table[shade_index + 3*m + 1] *
08745 weight_table[weight_index + m];
08746
08747 top_bsclr +=
08748 shadow_table[shade_index + 3*m + 2] *
08749 weight_table[weight_index + m];
08750 };
08751 shade_factor = top_opc * slice_depth_cueing;
08752
08753 top_rclr *= shade_factor;
08754 top_gclr *= shade_factor;
08755 top_bclr *= shade_factor;
08756
08757 top_rsclr *= shade_factor;
08758 top_gsclr *= shade_factor;
08759 top_bsclr *= shade_factor;
08760
08761 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
08762
08763
08764 shade_index=num_materials*3*ShortField(botRLEdata - voxel_istride,norm_offset);
08765 weight_index = num_materials * ByteField(botRLEdata - voxel_istride, wgt_offset);
08766
08767
08768
08769 bot_rclr =
08770 shade_table[shade_index + 3*0 + 0] *
08771 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08772
08773 bot_gclr =
08774 shade_table[shade_index + 3*0 + 1] *
08775 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08776
08777 bot_bclr =
08778 shade_table[shade_index + 3*0 + 2] *
08779 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08780
08781 bot_rsclr =
08782 shadow_table[shade_index + 3*0 + 0] *
08783 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08784
08785 bot_gsclr =
08786 shadow_table[shade_index + 3*0 + 1] *
08787 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08788
08789 bot_bsclr =
08790 shadow_table[shade_index + 3*0 + 2] *
08791 ((num_materials > 1) ? weight_table[weight_index] : (float)1.0);
08792 for (m = 1; m < num_materials; m++) {
08793
08794
08795 bot_rclr +=
08796 shade_table[shade_index + 3*m + 0] *
08797 weight_table[weight_index + m];
08798
08799 bot_gclr +=
08800 shade_table[shade_index + 3*m + 1] *
08801 weight_table[weight_index + m];
08802
08803 bot_bclr +=
08804 shade_table[shade_index + 3*m + 2] *
08805 weight_table[weight_index + m];
08806
08807 bot_rsclr +=
08808 shadow_table[shade_index + 3*m + 0] *
08809 weight_table[weight_index + m];
08810
08811 bot_gsclr +=
08812 shadow_table[shade_index + 3*m + 1] *
08813 weight_table[weight_index + m];
08814
08815 bot_bsclr +=
08816 shadow_table[shade_index + 3*m + 2] *
08817 weight_table[weight_index + m];
08818 };
08819 shade_factor = bot_opc * slice_depth_cueing;
08820
08821 bot_rclr *= shade_factor;
08822 bot_gclr *= shade_factor;
08823 bot_bclr *= shade_factor;
08824
08825 bot_rsclr *= shade_factor;
08826 bot_gsclr *= shade_factor;
08827 bot_bsclr *= shade_factor;
08828 }
08829
08830 #ifdef DEBUG
08831 if (ipixel == trace_pixel_ptr) {
08832 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
08833 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
08834 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
08835 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
08836 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
08837 }
08838 #endif
08839 ;
08840
08841 acc_opc = top_opc * wgtTL;
08842
08843 acc_rclr = (top_rclr + top_rsclr *
08844 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
08845 acc_gclr = (top_gclr + top_gsclr *
08846 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
08847 acc_bclr = (top_bclr + top_bsclr *
08848 ((float)1.0 - shadow_pixel->opcflt)) * wgtTL;
08849
08850 #ifdef DEBUG
08851 if (ipixel == trace_pixel_ptr) {
08852 trace_opcTL = top_opc;
08853 trace_rclrTL = top_rclr;
08854 trace_gclrTL = top_gclr;
08855 trace_bclrTL = top_bclr;
08856
08857 }
08858 #endif
08859 ;
08860
08861 acc_opc += bot_opc * wgtBL;
08862
08863 acc_rclr += (bot_rclr + bot_rsclr *
08864 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
08865 acc_gclr += (bot_gclr + bot_gsclr *
08866 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
08867 acc_bclr += (bot_bclr + bot_bsclr *
08868 ((float)1.0 - shadow_pixel->opcflt)) * wgtBL;
08869
08870 #ifdef DEBUG
08871 if (ipixel == trace_pixel_ptr) {
08872 trace_opcBL = bot_opc;
08873 trace_rclrBL = bot_rclr;
08874 trace_gclrBL = bot_gclr;
08875 trace_bclrBL = bot_bclr;
08876
08877 }
08878 #endif
08879 ;
08880
08881 COUNT_RESAMPLE;
08882 if (acc_opc > min_opacity) {
08883 COUNT_COMPOSITE;
08884 iopc = ipixel->opcflt;
08885 # ifndef SKIP_ERT
08886 ASSERT(iopc < max_opacity);
08887 # endif
08888 iopc_inv = (float)1. - iopc;
08889
08890 ipixel->rclrflt += acc_rclr * iopc_inv;
08891 ipixel->gclrflt += acc_gclr * iopc_inv;
08892 ipixel->bclrflt += acc_bclr * iopc_inv;
08893 iopc += acc_opc * iopc_inv;
08894 ipixel->opcflt = iopc;
08895
08896 #ifdef DEBUG
08897 if (ipixel == trace_pixel_ptr) {
08898 #ifdef COMPUTE_SHADOW_BUFFER
08899 printf("{%3d} %3d %3d", k, icount-i-count, j);
08900 #else
08901 printf("[%3d] %3d %3d", k, icount-i-count, j);
08902 #endif
08903 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
08904 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
08905 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
08906 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
08907 printf(" %3.0f %3.0f\n", iopc*255.,
08908 ipixel->rclrflt);
08909
08910 printf(" ");
08911 printf(" %3.0f ",trace_rsclrTL);
08912 printf(" %3.0f ",trace_rsclrBL);
08913 printf(" %3.0f ",trace_rsclrTR);
08914 printf(" %3.0f ",trace_rsclrBR);
08915 printf(" %3.0f\n", shadow_pixel->opcflt * 255.);
08916
08917 printf(" ");
08918 printf(" %3.0f ",trace_gclrTL);
08919 printf(" %3.0f ",trace_gclrBL);
08920 printf(" %3.0f ",trace_gclrTR);
08921 printf(" %3.0f ",trace_gclrBR);
08922 printf(" %3.0f\n", ipixel->gclrflt);
08923 printf(" ");
08924 printf(" %3.0f ",trace_bclrTL);
08925 printf(" %3.0f ",trace_bclrBL);
08926 printf(" %3.0f ",trace_bclrTR);
08927 printf(" %3.0f ",trace_bclrBR);
08928 printf(" %3.0f\n", ipixel->bclrflt);
08929 }
08930 #endif
08931 ;
08932 # ifndef SKIP_ERT
08933 if (iopc >= max_opacity) {
08934 ASSERT(ipixel->lnk == 0);
08935 ipixel->lnk = 1;
08936 }
08937 # endif
08938 };
08939 break;
08940 default:
08941 VPBug("illegal value for run state at end of scanline");
08942 }
08943 } else if (last_run_state == ALL_ZERO) {
08944 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
08945 } else {
08946 Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
08947 }
08948 #endif
08949 #endif
08950
08951 #ifndef UNROLL_RUN_LOOP
08952 run_state = final_run_state;
08953 #endif
08954
08955 if (j != 0 && ((run_state & 1) == 0)) {
08956 toprun_count = *topRLElen++;
08957 ASSERT(toprun_count == 0);
08958 }
08959 if (j != jcount && ((run_state & 2) == 0)) {
08960 botrun_count = *botRLElen++;
08961 ASSERT(botrun_count == 0);
08962 }
08963
08964
08965 #ifdef UNROLL_RUN_LOOP
08966 ipixel += intermediate_width - icount;
08967 #ifdef USE_SHADOW_BUFFER
08968 shadow_pixel += shadow_width - icount;
08969 #endif
08970 #else
08971 ipixel += intermediate_width - (icount+1);
08972 #ifdef USE_SHADOW_BUFFER
08973 shadow_pixel += shadow_width - (icount+1);
08974 #endif
08975 #endif
08976
08977 Debug((vpc, VPDEBUG_COMPOSITE, "ScanDone\n"));
08978 }
08979
08980
08981
08982
08983
08984 GET_HIRES_TIME(vpc, t1);
08985 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
08986
08987 Debug((vpc, VPDEBUG_COMPOSITE, "SliceDone\n"));
08988 }