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
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 #define MULTIPLE_MATERIALS
00094
00095
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 #define RGB
00126
00127
00128
00129
00130
00131
00132
00133 #define RLEVOLUME
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 #undef INDEX_VOLUME
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 #define ALL_ZERO 0
00161 #define TOP_NONZERO 1
00162 #define BOT_NONZERO 2
00163 #define ALL_NONZERO 3
00164
00165
00166 #define ALL_ZERO__ALL_ZERO ((ALL_ZERO << 2) | ALL_ZERO)
00167 #define ALL_ZERO__TOP_NONZERO ((ALL_ZERO << 2) | TOP_NONZERO)
00168 #define ALL_ZERO__BOT_NONZERO ((ALL_ZERO << 2) | BOT_NONZERO)
00169 #define ALL_ZERO__ALL_NONZERO ((ALL_ZERO << 2) | ALL_NONZERO)
00170 #define TOP_NONZERO__ALL_ZERO ((TOP_NONZERO << 2) | ALL_ZERO)
00171 #define TOP_NONZERO__TOP_NONZERO ((TOP_NONZERO << 2) | TOP_NONZERO)
00172 #define TOP_NONZERO__BOT_NONZERO ((TOP_NONZERO << 2) | BOT_NONZERO)
00173 #define TOP_NONZERO__ALL_NONZERO ((TOP_NONZERO << 2) | ALL_NONZERO)
00174 #define BOT_NONZERO__ALL_ZERO ((BOT_NONZERO << 2) | ALL_ZERO)
00175 #define BOT_NONZERO__TOP_NONZERO ((BOT_NONZERO << 2) | TOP_NONZERO)
00176 #define BOT_NONZERO__BOT_NONZERO ((BOT_NONZERO << 2) | BOT_NONZERO)
00177 #define BOT_NONZERO__ALL_NONZERO ((BOT_NONZERO << 2) | ALL_NONZERO)
00178 #define ALL_NONZERO__ALL_ZERO ((ALL_NONZERO << 2) | ALL_ZERO)
00179 #define ALL_NONZERO__TOP_NONZERO ((ALL_NONZERO << 2) | TOP_NONZERO)
00180 #define ALL_NONZERO__BOT_NONZERO ((ALL_NONZERO << 2) | BOT_NONZERO)
00181 #define ALL_NONZERO__ALL_NONZERO ((ALL_NONZERO << 2) | ALL_NONZERO)
00182
00183 #ifdef SKIP_ERT
00184 #define PIXEL_IS_OPAQUE(ipixel) 0
00185 #else
00186 #define PIXEL_IS_OPAQUE(ipixel) ((ipixel)->lnk != 0)
00187 #endif
00188
00189 #ifdef STATISTICS
00190 extern int vpResampleCount;
00191 extern int vpCompositeCount;
00192 extern int vpERTSkipCount;
00193 extern int vpERTSkipAgainCount;
00194 extern int vpERTUpdateCount;
00195 extern int vpSpecialZeroSkipCount;
00196 extern int vpRunFragmentCount;
00197 #define COUNT_RESAMPLE vpResampleCount++
00198 #define COUNT_COMPOSITE vpCompositeCount++
00199 #define COUNT_ERT_SKIP vpERTSkipCount++
00200 #define COUNT_ERT_SKIP_AGAIN vpERTSkipAgainCount++
00201 #define COUNT_ERT_UPDATE vpERTUpdateCount++
00202 #define COUNT_SPECIAL_ZERO_SKIP vpSpecialZeroSkipCount++
00203 #define COUNT_RUN_FRAGMENT vpRunFragmentCount++
00204 #else
00205 #define COUNT_RESAMPLE
00206 #define COUNT_COMPOSITE
00207 #define COUNT_ERT_SKIP
00208 #define COUNT_ERT_SKIP_AGAIN
00209 #define COUNT_ERT_UPDATE
00210 #define COUNT_SPECIAL_ZERO_SKIP
00211 #define COUNT_RUN_FRAGMENT
00212 #endif
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 void
00223 VPCompAC32B (vpc, icount, jcount, k, slice_depth_cueing_dbl, intimage,
00224 weightTLdbl, weightBLdbl, weightTRdbl, weightBRdbl,
00225 run_lengths, voxel_data )
00226 vpContext *vpc;
00227 int icount;
00228 int jcount;
00229 int k;
00230 double slice_depth_cueing_dbl;
00231 RGBIntPixel *intimage;
00232 double weightTLdbl;
00233 double weightBLdbl;
00234 double weightTRdbl;
00235 double weightBRdbl;
00236
00237 unsigned char *run_lengths;
00238 void *voxel_data;
00239
00240 {
00241 int i, j;
00242 RGBIntPixel *ipixel;
00243 RGBIntPixel *ipixel2;
00244 int update_interval;
00245 float iopc;
00246 float iopc_inv;
00247 float acc_opc;
00248 float top_opc, bot_opc;
00249 #ifdef NO_REUSE_VOXEL
00250 #define voxels_loaded 0
00251 #define CLEAR_VOXELS_LOADED
00252 #define SET_VOXELS_LOADED
00253 #else
00254 int voxels_loaded;
00255
00256 #define CLEAR_VOXELS_LOADED voxels_loaded = 0
00257 #define SET_VOXELS_LOADED voxels_loaded = 1
00258 #endif
00259 float wgtTL, wgtBL,
00260 wgtTR, wgtBR;
00261
00262
00263 unsigned char *topRLElen;
00264 unsigned char *botRLElen;
00265 char *topRLEdata;
00266 char *botRLEdata;
00267 int toprun_count;
00268 int botrun_count;
00269 int last_run_state;
00270 int run_state;
00271 int final_run_state;
00272 float min_opacity;
00273 float max_opacity;
00274 float slice_depth_cueing;
00275 float *opac_correct;
00276 int ert_skip_count;
00277 int intermediate_width;
00278 int count;
00279 float *shade_table;
00280 int norm_offset;
00281 int shade_index;
00282 float shade_factor;
00283
00284
00285 #ifdef MULTIPLE_MATERIALS
00286 float *weight_table;
00287 int wgt_offset;
00288 int weight_index;
00289 int m, num_materials;
00290 float weight1, weight2;
00291 #endif
00292
00293 #ifdef GRAYSCALE
00294 float acc_clr;
00295 float top_clr, bot_clr;
00296 #endif
00297
00298 #ifdef RGB
00299 float acc_rclr;
00300 float acc_gclr;
00301 float acc_bclr;
00302 float top_rclr;
00303 float bot_rclr;
00304 float top_gclr;
00305 float bot_gclr;
00306 float top_bclr;
00307 float bot_bclr;
00308 #endif
00309
00310 #ifdef RLEVOLUME
00311 int voxel_istride;
00312 #endif
00313
00314 #ifdef RAWVOLUME
00315 int use_octree;
00316 MMOctreeLevel level_stack[VP_MAX_OCTREE_LEVELS];
00317
00318 int scans_left;
00319 int best_view_axis;
00320 unsigned char runlen_buf1[VP_MAX_VOLUME_DIM];
00321 unsigned char runlen_buf2[VP_MAX_VOLUME_DIM];
00322 unsigned char *top_len_base;
00323 unsigned char *bot_len_base;
00324 int opac_param;
00325 float opacity;
00326 int opacity_int;
00327 int param0_offset;
00328 int param0_size;
00329 float *param0_table;
00330 int param1_offset;
00331 int param1_size;
00332 float *param1_table;
00333 int param2_offset;
00334 int param2_size;
00335 float *param2_table;
00336 #endif
00337
00338 #ifdef INDEX_VOLUME
00339 unsigned char *scanline_topRLElen;
00340 unsigned char *scanline_botRLElen;
00341 char *scanline_topRLEdata;
00342 char *scanline_botRLEdata;
00343 VoxelLocation *top_voxel_index;
00344 VoxelLocation *bot_voxel_index;
00345 VoxelLocation *vindex;
00346 int next_i;
00347 int next_scan;
00348 #endif
00349
00350 #ifdef CALLBACK
00351
00352 #ifdef GRAYSCALE
00353 void (*shade_func) ANSI_ARGS((void *, float *, void *));
00354 #endif
00355 #ifdef RGB
00356 void (*shade_func) ANSI_ARGS((void *, float *, float *, float *, void *));
00357 #endif
00358 void *client_data;
00359 #endif
00360
00361 #ifdef USE_SHADOW_BUFFER
00362 float *shadow_table;
00363 int shadow_width;
00364 GrayIntPixel *shadow_pixel;
00365 #ifdef GRAYSCALE
00366 float top_sclr, bot_sclr;
00367 #endif
00368 #ifdef RGB
00369 float top_rsclr;
00370 float bot_rsclr;
00371 float top_gsclr;
00372 float bot_gsclr;
00373 float top_bsclr;
00374 float bot_bsclr;
00375 #endif
00376 #endif
00377
00378 #ifdef DEBUG
00379 float trace_opcTL, trace_opcBL, trace_opcTR, trace_opcBR;
00380 float trace_rsclrTL, trace_rsclrBL, trace_rsclrTR, trace_rsclrBR;
00381 float trace_rclrTL, trace_rclrBL, trace_rclrTR, trace_rclrBR;
00382 float trace_gclrTL, trace_gclrBL, trace_gclrTR, trace_gclrBR;
00383 float trace_bclrTL, trace_bclrBL, trace_bclrTR, trace_bclrBR;
00384 RGBIntPixel *trace_pixel_ptr;
00385
00386 #ifdef COMPUTE_SHADOW_BUFFER
00387 int slice_u_int, shadow_slice_u_int;
00388 int slice_v_int, shadow_slice_v_int;
00389 #endif
00390 #endif
00391
00392 DECLARE_HIRES_TIME(t0);
00393 DECLARE_HIRES_TIME(t1);
00394
00395
00396
00397
00398
00399 GET_HIRES_TIME(vpc, t0);
00400
00401 wgtTL = weightTLdbl;
00402 wgtBL = weightBLdbl;
00403 wgtTR = weightTRdbl;
00404 wgtBR = weightBRdbl;
00405 slice_depth_cueing = slice_depth_cueing_dbl;
00406 min_opacity = vpc->min_opacity;
00407 max_opacity = vpc->max_opacity;
00408 #ifdef USE_SHADOW_BUFFER
00409 opac_correct = vpc->shadow_opac_correct;
00410 #else
00411 opac_correct = vpc->affine_opac_correct;
00412 #endif
00413 #ifdef COMPUTE_SHADOW_BUFFER
00414 intermediate_width = vpc->shadow_width;
00415 #else
00416 intermediate_width = vpc->intermediate_width;
00417 #endif
00418 #ifdef USE_SHADOW_BUFFER
00419 shadow_table = vpc->shadow_color_table;
00420 shadow_width = vpc->shadow_width;
00421 shadow_pixel = shadow_buffer;
00422 #endif
00423 ipixel = intimage;
00424 shade_table = vpc->shade_color_table;
00425 norm_offset = vpc->field_offset[vpc->color_field];
00426
00427 #ifdef MULTIPLE_MATERIALS
00428 weight_table = vpc->shade_weight_table;
00429 wgt_offset = vpc->field_offset[vpc->weight_field];
00430 num_materials = vpc->num_materials;
00431 #endif
00432
00433 #ifdef RLEVOLUME
00434 topRLEdata = voxel_data;
00435 botRLEdata = voxel_data;
00436 topRLElen = run_lengths;
00437 botRLElen = run_lengths;
00438 voxel_istride = vpc->rle_bytes_per_voxel;
00439 #endif
00440
00441 #ifdef RAWVOLUME
00442 ASSERT(vpc->num_clsfy_params > 0);
00443 ASSERT(vpc->num_clsfy_params < 3);
00444 param0_offset = vpc->field_offset[vpc->param_field[0]];
00445 param0_size = vpc->field_size[vpc->param_field[0]];
00446 param0_table = vpc->clsfy_table[0];
00447 if (vpc->num_clsfy_params > 1) {
00448 param1_offset = vpc->field_offset[vpc->param_field[1]];
00449 param1_size = vpc->field_size[vpc->param_field[1]];
00450 param1_table = vpc->clsfy_table[1];
00451 } else {
00452 param1_offset = 0;
00453 param1_size = 0;
00454 param1_table = NULL;
00455 }
00456 if (vpc->num_clsfy_params > 2) {
00457 param2_offset = vpc->field_offset[vpc->param_field[2]];
00458 param2_size = vpc->field_size[vpc->param_field[2]];
00459 param2_table = vpc->clsfy_table[2];
00460 } else {
00461 param2_offset = 0;
00462 param2_size = 0;
00463 param2_table = NULL;
00464 }
00465 if (vpc->mm_octree == NULL) {
00466 use_octree = 0;
00467 } else {
00468 use_octree = 1;
00469 best_view_axis = vpc->best_view_axis;
00470 VPInitOctreeLevelStack(vpc, level_stack, best_view_axis, k);
00471 scans_left = 0;
00472 bot_len_base = runlen_buf1;
00473 }
00474 #endif
00475
00476 #ifdef CALLBACK
00477 shade_func = vpc->shade_func;
00478 client_data = vpc->client_data;
00479 ASSERT(shade_func != NULL);
00480 #endif
00481
00482 #ifdef DEBUG
00483 trace_pixel_ptr = 0;
00484 if (vpc->trace_u >= 0 && vpc->trace_v >= 0) {
00485 #ifdef GRAYSCALE
00486 trace_pixel_ptr = &vpc->int_image.gray_intim[vpc->trace_u +
00487 vpc->trace_v*vpc->intermediate_width];
00488 #endif
00489 #ifdef RGB
00490 trace_pixel_ptr = &vpc->int_image.rgb_intim[vpc->trace_u +
00491 vpc->trace_v*vpc->intermediate_width];
00492 #endif
00493 #ifdef COMPUTE_SHADOW_BUFFER
00494 slice_u_int = (int)ceil(vpc->shear_i * vpc->trace_shadow_k +
00495 vpc->trans_i) - 1;
00496 shadow_slice_u_int = (int)ceil(vpc->shadow_shear_i *
00497 vpc->trace_shadow_k + vpc->shadow_trans_i) - 1;
00498 slice_v_int = (int)ceil(vpc->shear_j * vpc->trace_shadow_k
00499 + vpc->trans_j) - 1;
00500 shadow_slice_v_int = (int)ceil(vpc->shadow_shear_j *
00501 vpc->trace_shadow_k + vpc->shadow_trans_j) - 1;
00502 trace_pixel_ptr = &vpc->shadow_buffer[vpc->trace_u +
00503 shadow_slice_u_int - slice_u_int +
00504 (vpc->trace_v + shadow_slice_v_int -
00505 slice_v_int)*vpc->shadow_width];
00506 #endif
00507 }
00508 #endif
00509
00510
00511
00512
00513
00514 for (j = 0; j <= jcount; j++) {
00515
00516
00517
00518
00519
00520 i = icount;
00521 CLEAR_VOXELS_LOADED;
00522 last_run_state = ALL_ZERO;
00523
00524 #ifdef RAWVOLUME
00525 botRLEdata = (char *)voxel_data + j*voxel_jstride;
00526 topRLEdata = botRLEdata - voxel_jstride;
00527 if (!use_octree) {
00528 if (j == 0) {
00529 run_state = BOT_NONZERO;
00530 toprun_count = icount+2;
00531 botrun_count = icount;
00532 } else if (j == jcount) {
00533 run_state = TOP_NONZERO;
00534 toprun_count = icount;
00535 botrun_count = icount+2;
00536 } else {
00537 run_state = ALL_NONZERO;
00538 toprun_count = icount;
00539 botrun_count = icount;
00540 }
00541 } else
00542 #endif
00543 if (j == 0) {
00544 run_state = BOT_NONZERO;
00545 toprun_count = icount+2;
00546 botrun_count = 0;
00547 } else if (j == jcount) {
00548 run_state = TOP_NONZERO;
00549 toprun_count = 0;
00550 botrun_count = icount+2;
00551 } else {
00552 run_state = ALL_NONZERO;
00553 toprun_count = 0;
00554 botrun_count = 0;
00555 }
00556
00557 #ifdef INDEX_VOLUME
00558 scanline_topRLElen = topRLElen;
00559 scanline_botRLElen = botRLElen;
00560 scanline_topRLEdata = topRLEdata;
00561 scanline_botRLEdata = botRLEdata;
00562 if (j == 0) {
00563 top_voxel_index = voxel_index;
00564 bot_voxel_index = voxel_index;
00565 } else {
00566 top_voxel_index = bot_voxel_index;
00567 bot_voxel_index += icount;
00568 }
00569 #endif
00570
00571
00572
00573
00574
00575
00576 #ifdef RAWVOLUME
00577 if (use_octree) {
00578 top_len_base = bot_len_base;
00579 if (scans_left == 0) {
00580 if (bot_len_base == runlen_buf1)
00581 bot_len_base = runlen_buf2;
00582 else
00583 bot_len_base = runlen_buf1;
00584
00585 GET_HIRES_TIME(vpc, t1);
00586 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00587 COPY_HIRES_TIME(t0, t1);
00588
00589 scans_left = VPComputeScanRuns(vpc, level_stack, bot_len_base,
00590 best_view_axis, j, icount);
00591
00592 GET_HIRES_TIME(vpc, t1);
00593 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_OCTREE, t0, t1);
00594 COPY_HIRES_TIME(t0, t1);
00595 }
00596 #ifdef DEBUG
00597 if (j > 0)
00598 VPCheckRuns(vpc, top_len_base, best_view_axis, k, j-1);
00599 if (j < jcount)
00600 VPCheckRuns(vpc, bot_len_base, best_view_axis, k, j);
00601 #endif
00602 scans_left--;
00603 topRLElen = top_len_base;
00604 botRLElen = bot_len_base;
00605 }
00606 #endif
00607
00608
00609
00610
00611
00612 Debug((vpc, VPDEBUG_COMPOSITE, "StartIScan(u=%d,v=%d)\n",
00613 (((int)ipixel - (int)vpc->int_image.gray_intim) /
00614 sizeof(RGBIntPixel)) % vpc->intermediate_width,
00615 (((int)ipixel - (int)vpc->int_image.gray_intim) /
00616 sizeof(RGBIntPixel)) / vpc->intermediate_width));
00617
00618 #ifdef UNROLL_RUN_LOOP
00619 while (i > 0) {
00620 #else
00621 while (i >= 0) {
00622 #endif
00623
00624
00625
00626
00627 if (last_run_state == ALL_ZERO) {
00628 #ifndef UNROLL_RUN_LOOP
00629 if (i == 0) {
00630 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00631 ipixel += 1;
00632 final_run_state = ALL_ZERO;
00633 i = -1;
00634 break;
00635 }
00636 #endif
00637
00638
00639 while (toprun_count == 0) {
00640 toprun_count = *topRLElen++;
00641 run_state ^= 1;
00642 }
00643 while (botrun_count == 0) {
00644 botrun_count = *botRLElen++;
00645 run_state ^= 2;
00646 }
00647 if (run_state == ALL_ZERO) {
00648 COUNT_SPECIAL_ZERO_SKIP;
00649
00650
00651 count = MIN(toprun_count, botrun_count);
00652 toprun_count -= count;
00653 botrun_count -= count;
00654 ipixel += count;
00655 ;
00656 ;
00657 i -= count;
00658 ASSERT(i >= 0);
00659 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(%d)\n", count));
00660 continue;
00661 }
00662 }
00663
00664 #ifndef SKIP_ERT
00665
00666
00667
00668
00669 if ((ert_skip_count = ipixel->lnk) != 0) {
00670
00671 GET_HIRES_TIME(vpc, t1);
00672 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00673 COPY_HIRES_TIME(t0, t1);
00674
00675 COUNT_ERT_SKIP;
00676
00677 #ifndef UNROLL_RUN_LOOP
00678 if (i == 0) {
00679 ipixel += 1;
00680 final_run_state = last_run_state;
00681 i = -1;
00682 Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00683 break;
00684 }
00685 #endif
00686
00687
00688 if (ert_skip_count < i &&
00689 (count = ipixel[ert_skip_count].lnk) != 0) {
00690
00691 do {
00692 COUNT_ERT_SKIP_AGAIN;
00693 ert_skip_count += count;
00694 } while (ert_skip_count < i &&
00695 (count = ipixel[ert_skip_count].lnk) != 0);
00696
00697
00698
00699
00700
00701
00702 ipixel2 = ipixel;
00703 update_interval = 1;
00704 count = ert_skip_count - 1;
00705 while (count > 0) {
00706 COUNT_ERT_UPDATE;
00707 ipixel2 += update_interval;
00708 if (count > 255)
00709 ipixel2->lnk = 255;
00710 else
00711 ipixel2->lnk = count;
00712 update_interval *= 2;
00713 count -= update_interval;
00714 }
00715
00716
00717 COUNT_ERT_UPDATE;
00718 if (ert_skip_count > 255)
00719 ert_skip_count = 255;
00720 ipixel->lnk = ert_skip_count;
00721 }
00722
00723
00724 if (ert_skip_count > i)
00725 ert_skip_count = i;
00726 Debug((vpc, VPDEBUG_COMPOSITE,"ERTSkip(%d)\n",ert_skip_count));
00727 ipixel += ert_skip_count;
00728 CLEAR_VOXELS_LOADED;
00729
00730 #ifdef INDEX_VOLUME
00731
00732 next_i = icount - i + ert_skip_count;
00733 if (next_i == icount) {
00734 next_i--;
00735 next_scan = 1;
00736 } else {
00737 next_scan = 0;
00738 }
00739
00740
00741 vindex = &top_voxel_index[next_i];
00742 toprun_count = vindex->run_count;
00743 topRLElen = scanline_topRLElen + vindex->len_offset;
00744 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00745 run_state &= ~1;
00746 topRLEdata = scanline_topRLEdata +
00747 (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00748 } else {
00749 run_state |= 1;
00750 topRLEdata = scanline_topRLEdata + vindex->data_offset;
00751 }
00752
00753
00754 vindex = &bot_voxel_index[next_i];
00755 botrun_count = vindex->run_count;
00756 botRLElen = scanline_botRLElen + vindex->len_offset;
00757 if (vindex->data_offset & INDEX_RUN_IS_ZERO) {
00758 run_state &= ~2;
00759 botRLEdata = scanline_botRLEdata +
00760 (vindex->data_offset & ~INDEX_RUN_IS_ZERO);
00761 } else {
00762 run_state |= 2;
00763 botRLEdata = scanline_botRLEdata + vindex->data_offset;
00764 }
00765
00766
00767 if (next_scan) {
00768
00769 while (toprun_count == 0) {
00770 toprun_count = *topRLElen++;
00771 run_state ^= 1;
00772 }
00773 toprun_count--;
00774 if (run_state & 1) {
00775 topRLEdata += 1 * voxel_istride;
00776 } else {
00777 ;
00778 }
00779
00780
00781 while (botrun_count == 0) {
00782 botrun_count = *botRLElen++;
00783 run_state ^= 2;
00784 }
00785 botrun_count--;
00786 if (run_state & 2) {
00787 botRLEdata += 1 * voxel_istride;
00788 } else {
00789 ;
00790 }
00791 }
00792
00793 #else
00794
00795 count = ert_skip_count;
00796 for (;;) {
00797 if (toprun_count >= count) {
00798 toprun_count -= count;
00799 if (run_state & 1) {
00800 topRLEdata += count * voxel_istride;
00801 } else {
00802 ;
00803 }
00804 break;
00805 } else {
00806 count -= toprun_count;
00807 if (run_state & 1) {
00808 topRLEdata += toprun_count * voxel_istride;
00809 } else {
00810 ;
00811 }
00812 toprun_count = *topRLElen++;
00813 if (toprun_count == 0)
00814 toprun_count = *topRLElen++;
00815 else
00816 run_state ^= 1;
00817 }
00818 }
00819
00820
00821 count = ert_skip_count;
00822 for (;;) {
00823 if (botrun_count >= count) {
00824 botrun_count -= count;
00825 if (run_state & 2) {
00826 botRLEdata += count * voxel_istride;
00827 } else {
00828 ;
00829 }
00830 break;
00831 } else {
00832 count -= botrun_count;
00833 if (run_state & 2) {
00834 botRLEdata += botrun_count * voxel_istride;
00835 } else {
00836 ;
00837 }
00838 botrun_count = *botRLElen++;
00839 if (botrun_count == 0)
00840 botrun_count = *botRLElen++;
00841 else
00842 run_state ^= 2;
00843 }
00844 }
00845 #endif
00846 i -= ert_skip_count;
00847 last_run_state = run_state;
00848 if (i == 0) {
00849 #ifdef UNROLL_RUN_LOOP
00850 break;
00851 #else
00852 if (last_run_state == ALL_ZERO) {
00853 ipixel += 1;
00854 final_run_state = ALL_ZERO;
00855 i = -1;
00856 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
00857 break;
00858 }
00859 if (ipixel->lnk != 0) {
00860 ipixel += 1;
00861 final_run_state = last_run_state;
00862 i = -1;
00863 Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
00864 break;
00865 }
00866 #endif
00867 }
00868
00869 GET_HIRES_TIME(vpc, t1);
00870 STORE_HIRES_TIME(vpc, VPTIMER_ERT, t0, t1);
00871 COPY_HIRES_TIME(t0, t1);
00872 }
00873 ASSERT(ipixel->opcflt < max_opacity);
00874 #endif
00875
00876
00877
00878
00879
00880 #ifndef UNROLL_RUN_LOOP
00881 if (i == 0) {
00882 final_run_state = last_run_state;
00883 run_state = ALL_ZERO;
00884 i = -1;
00885 count = 1;
00886 Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
00887 } else {
00888 #endif
00889
00890 while (toprun_count == 0) {
00891 toprun_count = *topRLElen++;
00892 run_state ^= 1;
00893 }
00894 while (botrun_count == 0) {
00895 botrun_count = *botRLElen++;
00896 run_state ^= 2;
00897 }
00898
00899
00900 count = MIN(toprun_count, botrun_count);
00901 toprun_count -= count;
00902 botrun_count -= count;
00903 i -= count;
00904 Debug((vpc, VPDEBUG_COMPOSITE, "Run(%d)\n", count));
00905 ASSERT(i >= 0);
00906 #ifndef UNROLL_RUN_LOOP
00907 }
00908 #endif
00909 COUNT_RUN_FRAGMENT;
00910
00911
00912
00913
00914
00915 GET_HIRES_TIME(vpc, t1);
00916 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
00917 COPY_HIRES_TIME(t0, t1);
00918
00919 #ifdef SKIP_COMPOSITE
00920 switch (run_state) {
00921 case ALL_ZERO:
00922 ipixel += count;
00923 ;
00924 ;
00925 count = 0;
00926 break;
00927 case TOP_NONZERO:
00928 ipixel += count;
00929 topRLEdata += count * voxel_istride;
00930 ;
00931 count = 0;
00932 break;
00933 case BOT_NONZERO:
00934 ipixel += count;
00935 ;
00936 botRLEdata += count * voxel_istride;
00937 count = 0;
00938 break;
00939 case ALL_NONZERO:
00940 ipixel += count;
00941 topRLEdata += count * voxel_istride;
00942 botRLEdata += count * voxel_istride;
00943 count = 0;
00944 break;
00945 }
00946 #else
00947 #ifdef UNROLL_RUN_LOOP
00948
00949 switch ((last_run_state << 2) | run_state) {
00950 case ALL_ZERO__ALL_ZERO:
00951
00952 ipixel += count;
00953 ;
00954 ;
00955 count = 0;
00956 break;
00957 case TOP_NONZERO__ALL_ZERO:
00958
00959
00960 if (!voxels_loaded) {
00961
00962 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
00963
00964
00965 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
00966 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
00967
00968
00969
00970 top_rclr =
00971 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
00972
00973 top_gclr =
00974 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
00975
00976 top_bclr =
00977 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
00978 ;
00979 ;
00980 ;
00981
00982
00983 top_rclr +=
00984 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
00985
00986 top_gclr +=
00987 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
00988
00989 top_bclr +=
00990 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
00991 ;
00992 ;
00993 ;
00994 shade_factor = top_opc * slice_depth_cueing;
00995
00996 top_rclr *= shade_factor;
00997 top_gclr *= shade_factor;
00998 top_bclr *= shade_factor;
00999 ;
01000 }
01001
01002 #ifdef DEBUG
01003 if (ipixel == trace_pixel_ptr) {
01004 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01005 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01006 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01007 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01008 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01009 }
01010 #endif
01011 ;
01012
01013 acc_opc = top_opc * wgtTL;
01014
01015 acc_rclr = top_rclr * wgtTL;
01016 acc_gclr = top_gclr * wgtTL;
01017 acc_bclr = top_bclr * wgtTL;
01018
01019 #ifdef DEBUG
01020 if (ipixel == trace_pixel_ptr) {
01021 trace_opcTL = top_opc;
01022 trace_rclrTL = top_rclr;
01023 trace_gclrTL = top_gclr;
01024 trace_bclrTL = top_bclr;
01025
01026 }
01027 #endif
01028 ;
01029
01030 COUNT_RESAMPLE;
01031 if (acc_opc > min_opacity) {
01032 COUNT_COMPOSITE;
01033 iopc = ipixel->opcflt;
01034 # ifndef SKIP_ERT
01035 ASSERT(iopc < max_opacity);
01036 # endif
01037 iopc_inv = (float)1. - iopc;
01038
01039 ipixel->rclrflt += acc_rclr * iopc_inv;
01040 ipixel->gclrflt += acc_gclr * iopc_inv;
01041 ipixel->bclrflt += acc_bclr * iopc_inv;
01042 iopc += acc_opc * iopc_inv;
01043 ipixel->opcflt = iopc;
01044
01045 #ifdef DEBUG
01046 if (ipixel == trace_pixel_ptr) {
01047 #ifdef COMPUTE_SHADOW_BUFFER
01048 printf("{%3d} %3d %3d", k, icount-i-count, j);
01049 #else
01050 printf("[%3d] %3d %3d", k, icount-i-count, j);
01051 #endif
01052 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01053 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01054 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01055 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01056 printf(" %3.0f %3.0f\n", iopc*255.,
01057 ipixel->rclrflt);
01058
01059
01060 printf(" ");
01061 printf(" %3.0f ",trace_gclrTL);
01062 printf(" %3.0f ",trace_gclrBL);
01063 printf(" %3.0f ",trace_gclrTR);
01064 printf(" %3.0f ",trace_gclrBR);
01065 printf(" %3.0f\n", ipixel->gclrflt);
01066 printf(" ");
01067 printf(" %3.0f ",trace_bclrTL);
01068 printf(" %3.0f ",trace_bclrBL);
01069 printf(" %3.0f ",trace_bclrTR);
01070 printf(" %3.0f ",trace_bclrBR);
01071 printf(" %3.0f\n", ipixel->bclrflt);
01072 }
01073 #endif
01074 ;
01075 # ifndef SKIP_ERT
01076 if (iopc >= max_opacity) {
01077 ASSERT(ipixel->lnk == 0);
01078 ipixel->lnk = 1;
01079 }
01080 # endif
01081 };
01082 ipixel += count;
01083 ;
01084 ;
01085 count = 0;
01086 break;
01087 case BOT_NONZERO__ALL_ZERO:
01088
01089
01090 if (!voxels_loaded) {
01091
01092 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01093
01094
01095 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
01096 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
01097
01098
01099
01100 bot_rclr =
01101 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
01102
01103 bot_gclr =
01104 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
01105
01106 bot_bclr =
01107 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
01108 ;
01109 ;
01110 ;
01111
01112
01113 bot_rclr +=
01114 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
01115
01116 bot_gclr +=
01117 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
01118
01119 bot_bclr +=
01120 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
01121 ;
01122 ;
01123 ;
01124 shade_factor = bot_opc * slice_depth_cueing;
01125
01126 bot_rclr *= shade_factor;
01127 bot_gclr *= shade_factor;
01128 bot_bclr *= shade_factor;
01129 ;
01130 }
01131
01132 #ifdef DEBUG
01133 if (ipixel == trace_pixel_ptr) {
01134 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01135 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01136 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01137 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01138 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01139 }
01140 #endif
01141 ;
01142
01143 acc_opc = bot_opc * wgtBL;
01144
01145 acc_rclr = bot_rclr * wgtBL;
01146 acc_gclr = bot_gclr * wgtBL;
01147 acc_bclr = bot_bclr * wgtBL;
01148
01149 #ifdef DEBUG
01150 if (ipixel == trace_pixel_ptr) {
01151 trace_opcBL = bot_opc;
01152 trace_rclrBL = bot_rclr;
01153 trace_gclrBL = bot_gclr;
01154 trace_bclrBL = bot_bclr;
01155
01156 }
01157 #endif
01158 ;
01159
01160 COUNT_RESAMPLE;
01161 if (acc_opc > min_opacity) {
01162 COUNT_COMPOSITE;
01163 iopc = ipixel->opcflt;
01164 # ifndef SKIP_ERT
01165 ASSERT(iopc < max_opacity);
01166 # endif
01167 iopc_inv = (float)1. - iopc;
01168
01169 ipixel->rclrflt += acc_rclr * iopc_inv;
01170 ipixel->gclrflt += acc_gclr * iopc_inv;
01171 ipixel->bclrflt += acc_bclr * iopc_inv;
01172 iopc += acc_opc * iopc_inv;
01173 ipixel->opcflt = iopc;
01174
01175 #ifdef DEBUG
01176 if (ipixel == trace_pixel_ptr) {
01177 #ifdef COMPUTE_SHADOW_BUFFER
01178 printf("{%3d} %3d %3d", k, icount-i-count, j);
01179 #else
01180 printf("[%3d] %3d %3d", k, icount-i-count, j);
01181 #endif
01182 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01183 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01184 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01185 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01186 printf(" %3.0f %3.0f\n", iopc*255.,
01187 ipixel->rclrflt);
01188
01189
01190 printf(" ");
01191 printf(" %3.0f ",trace_gclrTL);
01192 printf(" %3.0f ",trace_gclrBL);
01193 printf(" %3.0f ",trace_gclrTR);
01194 printf(" %3.0f ",trace_gclrBR);
01195 printf(" %3.0f\n", ipixel->gclrflt);
01196 printf(" ");
01197 printf(" %3.0f ",trace_bclrTL);
01198 printf(" %3.0f ",trace_bclrBL);
01199 printf(" %3.0f ",trace_bclrTR);
01200 printf(" %3.0f ",trace_bclrBR);
01201 printf(" %3.0f\n", ipixel->bclrflt);
01202 }
01203 #endif
01204 ;
01205 # ifndef SKIP_ERT
01206 if (iopc >= max_opacity) {
01207 ASSERT(ipixel->lnk == 0);
01208 ipixel->lnk = 1;
01209 }
01210 # endif
01211 };
01212 ipixel += count;
01213 ;
01214 ;
01215 count = 0;
01216 break;
01217 case ALL_NONZERO__ALL_ZERO:
01218
01219
01220 if (!voxels_loaded) {
01221
01222 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01223
01224
01225 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
01226 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
01227
01228
01229
01230 top_rclr =
01231 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
01232
01233 top_gclr =
01234 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
01235
01236 top_bclr =
01237 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
01238 ;
01239 ;
01240 ;
01241
01242
01243 top_rclr +=
01244 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
01245
01246 top_gclr +=
01247 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
01248
01249 top_bclr +=
01250 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
01251 ;
01252 ;
01253 ;
01254 shade_factor = top_opc * slice_depth_cueing;
01255
01256 top_rclr *= shade_factor;
01257 top_gclr *= shade_factor;
01258 top_bclr *= shade_factor;
01259 ;
01260
01261 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01262
01263
01264 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
01265 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
01266
01267
01268
01269 bot_rclr =
01270 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
01271
01272 bot_gclr =
01273 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
01274
01275 bot_bclr =
01276 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
01277 ;
01278 ;
01279 ;
01280
01281
01282 bot_rclr +=
01283 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
01284
01285 bot_gclr +=
01286 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
01287
01288 bot_bclr +=
01289 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
01290 ;
01291 ;
01292 ;
01293 shade_factor = bot_opc * slice_depth_cueing;
01294
01295 bot_rclr *= shade_factor;
01296 bot_gclr *= shade_factor;
01297 bot_bclr *= shade_factor;
01298 ;
01299 }
01300
01301 #ifdef DEBUG
01302 if (ipixel == trace_pixel_ptr) {
01303 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01304 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01305 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01306 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01307 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01308 }
01309 #endif
01310 ;
01311
01312 acc_opc = top_opc * wgtTL;
01313
01314 acc_rclr = top_rclr * wgtTL;
01315 acc_gclr = top_gclr * wgtTL;
01316 acc_bclr = top_bclr * wgtTL;
01317
01318 #ifdef DEBUG
01319 if (ipixel == trace_pixel_ptr) {
01320 trace_opcTL = top_opc;
01321 trace_rclrTL = top_rclr;
01322 trace_gclrTL = top_gclr;
01323 trace_bclrTL = top_bclr;
01324
01325 }
01326 #endif
01327 ;
01328
01329 acc_opc += bot_opc * wgtBL;
01330
01331 acc_rclr += bot_rclr * wgtBL;
01332 acc_gclr += bot_gclr * wgtBL;
01333 acc_bclr += bot_bclr * wgtBL;
01334
01335 #ifdef DEBUG
01336 if (ipixel == trace_pixel_ptr) {
01337 trace_opcBL = bot_opc;
01338 trace_rclrBL = bot_rclr;
01339 trace_gclrBL = bot_gclr;
01340 trace_bclrBL = bot_bclr;
01341
01342 }
01343 #endif
01344 ;
01345
01346 COUNT_RESAMPLE;
01347 if (acc_opc > min_opacity) {
01348 COUNT_COMPOSITE;
01349 iopc = ipixel->opcflt;
01350 # ifndef SKIP_ERT
01351 ASSERT(iopc < max_opacity);
01352 # endif
01353 iopc_inv = (float)1. - iopc;
01354
01355 ipixel->rclrflt += acc_rclr * iopc_inv;
01356 ipixel->gclrflt += acc_gclr * iopc_inv;
01357 ipixel->bclrflt += acc_bclr * iopc_inv;
01358 iopc += acc_opc * iopc_inv;
01359 ipixel->opcflt = iopc;
01360
01361 #ifdef DEBUG
01362 if (ipixel == trace_pixel_ptr) {
01363 #ifdef COMPUTE_SHADOW_BUFFER
01364 printf("{%3d} %3d %3d", k, icount-i-count, j);
01365 #else
01366 printf("[%3d] %3d %3d", k, icount-i-count, j);
01367 #endif
01368 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01369 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01370 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01371 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01372 printf(" %3.0f %3.0f\n", iopc*255.,
01373 ipixel->rclrflt);
01374
01375
01376 printf(" ");
01377 printf(" %3.0f ",trace_gclrTL);
01378 printf(" %3.0f ",trace_gclrBL);
01379 printf(" %3.0f ",trace_gclrTR);
01380 printf(" %3.0f ",trace_gclrBR);
01381 printf(" %3.0f\n", ipixel->gclrflt);
01382 printf(" ");
01383 printf(" %3.0f ",trace_bclrTL);
01384 printf(" %3.0f ",trace_bclrBL);
01385 printf(" %3.0f ",trace_bclrTR);
01386 printf(" %3.0f ",trace_bclrBR);
01387 printf(" %3.0f\n", ipixel->bclrflt);
01388 }
01389 #endif
01390 ;
01391 # ifndef SKIP_ERT
01392 if (iopc >= max_opacity) {
01393 ASSERT(ipixel->lnk == 0);
01394 ipixel->lnk = 1;
01395 }
01396 # endif
01397 };
01398 ipixel += count;
01399 ;
01400 ;
01401 count = 0;
01402 break;
01403 case ALL_ZERO__TOP_NONZERO:
01404
01405
01406 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01407
01408
01409 shade_index=2*3*ShortField(topRLEdata,norm_offset);
01410 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
01411
01412
01413
01414 top_rclr =
01415 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
01416
01417 top_gclr =
01418 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
01419
01420 top_bclr =
01421 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
01422 ;
01423 ;
01424 ;
01425
01426
01427 top_rclr +=
01428 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
01429
01430 top_gclr +=
01431 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
01432
01433 top_bclr +=
01434 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
01435 ;
01436 ;
01437 ;
01438 shade_factor = top_opc * slice_depth_cueing;
01439
01440 top_rclr *= shade_factor;
01441 top_gclr *= shade_factor;
01442 top_bclr *= shade_factor;
01443 ;
01444
01445 #ifdef DEBUG
01446 if (ipixel == trace_pixel_ptr) {
01447 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01448 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01449 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01450 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01451 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01452 }
01453 #endif
01454 ;
01455
01456 acc_opc = top_opc * wgtTR;
01457
01458 acc_rclr = top_rclr * wgtTR;
01459 acc_gclr = top_gclr * wgtTR;
01460 acc_bclr = top_bclr * wgtTR;
01461
01462 #ifdef DEBUG
01463 if (ipixel == trace_pixel_ptr) {
01464 trace_opcTR = top_opc;
01465 trace_rclrTR = top_rclr;
01466 trace_gclrTR = top_gclr;
01467 trace_bclrTR = top_bclr;
01468
01469 }
01470 #endif
01471 ;
01472
01473 COUNT_RESAMPLE;
01474 if (acc_opc > min_opacity) {
01475 COUNT_COMPOSITE;
01476 iopc = ipixel->opcflt;
01477 # ifndef SKIP_ERT
01478 ASSERT(iopc < max_opacity);
01479 # endif
01480 iopc_inv = (float)1. - iopc;
01481
01482 ipixel->rclrflt += acc_rclr * iopc_inv;
01483 ipixel->gclrflt += acc_gclr * iopc_inv;
01484 ipixel->bclrflt += acc_bclr * iopc_inv;
01485 iopc += acc_opc * iopc_inv;
01486 ipixel->opcflt = iopc;
01487
01488 #ifdef DEBUG
01489 if (ipixel == trace_pixel_ptr) {
01490 #ifdef COMPUTE_SHADOW_BUFFER
01491 printf("{%3d} %3d %3d", k, icount-i-count, j);
01492 #else
01493 printf("[%3d] %3d %3d", k, icount-i-count, j);
01494 #endif
01495 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01496 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01497 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01498 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01499 printf(" %3.0f %3.0f\n", iopc*255.,
01500 ipixel->rclrflt);
01501
01502
01503 printf(" ");
01504 printf(" %3.0f ",trace_gclrTL);
01505 printf(" %3.0f ",trace_gclrBL);
01506 printf(" %3.0f ",trace_gclrTR);
01507 printf(" %3.0f ",trace_gclrBR);
01508 printf(" %3.0f\n", ipixel->gclrflt);
01509 printf(" ");
01510 printf(" %3.0f ",trace_bclrTL);
01511 printf(" %3.0f ",trace_bclrBL);
01512 printf(" %3.0f ",trace_bclrTR);
01513 printf(" %3.0f ",trace_bclrBR);
01514 printf(" %3.0f\n", ipixel->bclrflt);
01515 }
01516 #endif
01517 ;
01518 # ifndef SKIP_ERT
01519 if (iopc >= max_opacity) {
01520 ASSERT(ipixel->lnk == 0);
01521 ipixel->lnk = 1;
01522 }
01523 # endif
01524 };
01525 ipixel += 1;
01526 topRLEdata += 1 * voxel_istride;
01527 ;
01528 count--;
01529 SET_VOXELS_LOADED;
01530
01531
01532
01533 while (count > 0) {
01534 if (PIXEL_IS_OPAQUE(ipixel))
01535 break;
01536 if (!voxels_loaded) {
01537
01538 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01539
01540
01541 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
01542 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
01543
01544
01545
01546 top_rclr =
01547 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
01548
01549 top_gclr =
01550 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
01551
01552 top_bclr =
01553 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
01554 ;
01555 ;
01556 ;
01557
01558
01559 top_rclr +=
01560 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
01561
01562 top_gclr +=
01563 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
01564
01565 top_bclr +=
01566 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
01567 ;
01568 ;
01569 ;
01570 shade_factor = top_opc * slice_depth_cueing;
01571
01572 top_rclr *= shade_factor;
01573 top_gclr *= shade_factor;
01574 top_bclr *= shade_factor;
01575 ;
01576 }
01577
01578 #ifdef DEBUG
01579 if (ipixel == trace_pixel_ptr) {
01580 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01581 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01582 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01583 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01584 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01585 }
01586 #endif
01587 ;
01588
01589 acc_opc = top_opc * wgtTL;
01590
01591 acc_rclr = top_rclr * wgtTL;
01592 acc_gclr = top_gclr * wgtTL;
01593 acc_bclr = top_bclr * wgtTL;
01594
01595 #ifdef DEBUG
01596 if (ipixel == trace_pixel_ptr) {
01597 trace_opcTL = top_opc;
01598 trace_rclrTL = top_rclr;
01599 trace_gclrTL = top_gclr;
01600 trace_bclrTL = top_bclr;
01601
01602 }
01603 #endif
01604 ;
01605
01606 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01607
01608
01609 shade_index=2*3*ShortField(topRLEdata,norm_offset);
01610 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
01611
01612
01613
01614 top_rclr =
01615 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
01616
01617 top_gclr =
01618 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
01619
01620 top_bclr =
01621 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
01622 ;
01623 ;
01624 ;
01625
01626
01627 top_rclr +=
01628 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
01629
01630 top_gclr +=
01631 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
01632
01633 top_bclr +=
01634 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
01635 ;
01636 ;
01637 ;
01638 shade_factor = top_opc * slice_depth_cueing;
01639
01640 top_rclr *= shade_factor;
01641 top_gclr *= shade_factor;
01642 top_bclr *= shade_factor;
01643 ;
01644
01645 acc_opc += top_opc * wgtTR;
01646
01647 acc_rclr += top_rclr * wgtTR;
01648 acc_gclr += top_gclr * wgtTR;
01649 acc_bclr += top_bclr * wgtTR;
01650
01651 #ifdef DEBUG
01652 if (ipixel == trace_pixel_ptr) {
01653 trace_opcTR = top_opc;
01654 trace_rclrTR = top_rclr;
01655 trace_gclrTR = top_gclr;
01656 trace_bclrTR = top_bclr;
01657
01658 }
01659 #endif
01660 ;
01661
01662 COUNT_RESAMPLE;
01663 if (acc_opc > min_opacity) {
01664 COUNT_COMPOSITE;
01665 iopc = ipixel->opcflt;
01666 # ifndef SKIP_ERT
01667 ASSERT(iopc < max_opacity);
01668 # endif
01669 iopc_inv = (float)1. - iopc;
01670
01671 ipixel->rclrflt += acc_rclr * iopc_inv;
01672 ipixel->gclrflt += acc_gclr * iopc_inv;
01673 ipixel->bclrflt += acc_bclr * iopc_inv;
01674 iopc += acc_opc * iopc_inv;
01675 ipixel->opcflt = iopc;
01676
01677 #ifdef DEBUG
01678 if (ipixel == trace_pixel_ptr) {
01679 #ifdef COMPUTE_SHADOW_BUFFER
01680 printf("{%3d} %3d %3d", k, icount-i-count, j);
01681 #else
01682 printf("[%3d] %3d %3d", k, icount-i-count, j);
01683 #endif
01684 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01685 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01686 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01687 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01688 printf(" %3.0f %3.0f\n", iopc*255.,
01689 ipixel->rclrflt);
01690
01691
01692 printf(" ");
01693 printf(" %3.0f ",trace_gclrTL);
01694 printf(" %3.0f ",trace_gclrBL);
01695 printf(" %3.0f ",trace_gclrTR);
01696 printf(" %3.0f ",trace_gclrBR);
01697 printf(" %3.0f\n", ipixel->gclrflt);
01698 printf(" ");
01699 printf(" %3.0f ",trace_bclrTL);
01700 printf(" %3.0f ",trace_bclrBL);
01701 printf(" %3.0f ",trace_bclrTR);
01702 printf(" %3.0f ",trace_bclrBR);
01703 printf(" %3.0f\n", ipixel->bclrflt);
01704 }
01705 #endif
01706 ;
01707 # ifndef SKIP_ERT
01708 if (iopc >= max_opacity) {
01709 ASSERT(ipixel->lnk == 0);
01710 ipixel->lnk = 1;
01711 }
01712 # endif
01713 };
01714 ipixel += 1;
01715 topRLEdata += 1 * voxel_istride;
01716 ;
01717 count--;
01718 SET_VOXELS_LOADED;
01719 }
01720 break;
01721 case TOP_NONZERO__TOP_NONZERO:
01722
01723
01724 while (count > 0) {
01725 if (PIXEL_IS_OPAQUE(ipixel))
01726 break;
01727 if (!voxels_loaded) {
01728
01729 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
01730
01731
01732 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
01733 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
01734
01735
01736
01737 top_rclr =
01738 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
01739
01740 top_gclr =
01741 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
01742
01743 top_bclr =
01744 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
01745 ;
01746 ;
01747 ;
01748
01749
01750 top_rclr +=
01751 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
01752
01753 top_gclr +=
01754 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
01755
01756 top_bclr +=
01757 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
01758 ;
01759 ;
01760 ;
01761 shade_factor = top_opc * slice_depth_cueing;
01762
01763 top_rclr *= shade_factor;
01764 top_gclr *= shade_factor;
01765 top_bclr *= shade_factor;
01766 ;
01767 }
01768
01769 #ifdef DEBUG
01770 if (ipixel == trace_pixel_ptr) {
01771 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01772 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01773 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01774 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01775 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01776 }
01777 #endif
01778 ;
01779
01780 acc_opc = top_opc * wgtTL;
01781
01782 acc_rclr = top_rclr * wgtTL;
01783 acc_gclr = top_gclr * wgtTL;
01784 acc_bclr = top_bclr * wgtTL;
01785
01786 #ifdef DEBUG
01787 if (ipixel == trace_pixel_ptr) {
01788 trace_opcTL = top_opc;
01789 trace_rclrTL = top_rclr;
01790 trace_gclrTL = top_gclr;
01791 trace_bclrTL = top_bclr;
01792
01793 }
01794 #endif
01795 ;
01796
01797 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01798
01799
01800 shade_index=2*3*ShortField(topRLEdata,norm_offset);
01801 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
01802
01803
01804
01805 top_rclr =
01806 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
01807
01808 top_gclr =
01809 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
01810
01811 top_bclr =
01812 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
01813 ;
01814 ;
01815 ;
01816
01817
01818 top_rclr +=
01819 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
01820
01821 top_gclr +=
01822 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
01823
01824 top_bclr +=
01825 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
01826 ;
01827 ;
01828 ;
01829 shade_factor = top_opc * slice_depth_cueing;
01830
01831 top_rclr *= shade_factor;
01832 top_gclr *= shade_factor;
01833 top_bclr *= shade_factor;
01834 ;
01835
01836 acc_opc += top_opc * wgtTR;
01837
01838 acc_rclr += top_rclr * wgtTR;
01839 acc_gclr += top_gclr * wgtTR;
01840 acc_bclr += top_bclr * wgtTR;
01841
01842 #ifdef DEBUG
01843 if (ipixel == trace_pixel_ptr) {
01844 trace_opcTR = top_opc;
01845 trace_rclrTR = top_rclr;
01846 trace_gclrTR = top_gclr;
01847 trace_bclrTR = top_bclr;
01848
01849 }
01850 #endif
01851 ;
01852
01853 COUNT_RESAMPLE;
01854 if (acc_opc > min_opacity) {
01855 COUNT_COMPOSITE;
01856 iopc = ipixel->opcflt;
01857 # ifndef SKIP_ERT
01858 ASSERT(iopc < max_opacity);
01859 # endif
01860 iopc_inv = (float)1. - iopc;
01861
01862 ipixel->rclrflt += acc_rclr * iopc_inv;
01863 ipixel->gclrflt += acc_gclr * iopc_inv;
01864 ipixel->bclrflt += acc_bclr * iopc_inv;
01865 iopc += acc_opc * iopc_inv;
01866 ipixel->opcflt = iopc;
01867
01868 #ifdef DEBUG
01869 if (ipixel == trace_pixel_ptr) {
01870 #ifdef COMPUTE_SHADOW_BUFFER
01871 printf("{%3d} %3d %3d", k, icount-i-count, j);
01872 #else
01873 printf("[%3d] %3d %3d", k, icount-i-count, j);
01874 #endif
01875 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
01876 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
01877 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
01878 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
01879 printf(" %3.0f %3.0f\n", iopc*255.,
01880 ipixel->rclrflt);
01881
01882
01883 printf(" ");
01884 printf(" %3.0f ",trace_gclrTL);
01885 printf(" %3.0f ",trace_gclrBL);
01886 printf(" %3.0f ",trace_gclrTR);
01887 printf(" %3.0f ",trace_gclrBR);
01888 printf(" %3.0f\n", ipixel->gclrflt);
01889 printf(" ");
01890 printf(" %3.0f ",trace_bclrTL);
01891 printf(" %3.0f ",trace_bclrBL);
01892 printf(" %3.0f ",trace_bclrTR);
01893 printf(" %3.0f ",trace_bclrBR);
01894 printf(" %3.0f\n", ipixel->bclrflt);
01895 }
01896 #endif
01897 ;
01898 # ifndef SKIP_ERT
01899 if (iopc >= max_opacity) {
01900 ASSERT(ipixel->lnk == 0);
01901 ipixel->lnk = 1;
01902 }
01903 # endif
01904 };
01905 ipixel += 1;
01906 topRLEdata += 1 * voxel_istride;
01907 ;
01908 count--;
01909 SET_VOXELS_LOADED;
01910 }
01911 break;
01912 case BOT_NONZERO__TOP_NONZERO:
01913
01914
01915 if (!voxels_loaded) {
01916
01917 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
01918
01919
01920 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
01921 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
01922
01923
01924
01925 bot_rclr =
01926 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
01927
01928 bot_gclr =
01929 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
01930
01931 bot_bclr =
01932 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
01933 ;
01934 ;
01935 ;
01936
01937
01938 bot_rclr +=
01939 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
01940
01941 bot_gclr +=
01942 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
01943
01944 bot_bclr +=
01945 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
01946 ;
01947 ;
01948 ;
01949 shade_factor = bot_opc * slice_depth_cueing;
01950
01951 bot_rclr *= shade_factor;
01952 bot_gclr *= shade_factor;
01953 bot_bclr *= shade_factor;
01954 ;
01955 }
01956
01957 #ifdef DEBUG
01958 if (ipixel == trace_pixel_ptr) {
01959 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
01960 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
01961 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
01962 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
01963 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
01964 }
01965 #endif
01966 ;
01967
01968 acc_opc = bot_opc * wgtBL;
01969
01970 acc_rclr = bot_rclr * wgtBL;
01971 acc_gclr = bot_gclr * wgtBL;
01972 acc_bclr = bot_bclr * wgtBL;
01973
01974 #ifdef DEBUG
01975 if (ipixel == trace_pixel_ptr) {
01976 trace_opcBL = bot_opc;
01977 trace_rclrBL = bot_rclr;
01978 trace_gclrBL = bot_gclr;
01979 trace_bclrBL = bot_bclr;
01980
01981 }
01982 #endif
01983 ;
01984
01985 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
01986
01987
01988 shade_index=2*3*ShortField(topRLEdata,norm_offset);
01989 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
01990
01991
01992
01993 top_rclr =
01994 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
01995
01996 top_gclr =
01997 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
01998
01999 top_bclr =
02000 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02001 ;
02002 ;
02003 ;
02004
02005
02006 top_rclr +=
02007 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02008
02009 top_gclr +=
02010 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02011
02012 top_bclr +=
02013 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02014 ;
02015 ;
02016 ;
02017 shade_factor = top_opc * slice_depth_cueing;
02018
02019 top_rclr *= shade_factor;
02020 top_gclr *= shade_factor;
02021 top_bclr *= shade_factor;
02022 ;
02023
02024 acc_opc += top_opc * wgtTR;
02025
02026 acc_rclr += top_rclr * wgtTR;
02027 acc_gclr += top_gclr * wgtTR;
02028 acc_bclr += top_bclr * wgtTR;
02029
02030 #ifdef DEBUG
02031 if (ipixel == trace_pixel_ptr) {
02032 trace_opcTR = top_opc;
02033 trace_rclrTR = top_rclr;
02034 trace_gclrTR = top_gclr;
02035 trace_bclrTR = top_bclr;
02036
02037 }
02038 #endif
02039 ;
02040
02041 COUNT_RESAMPLE;
02042 if (acc_opc > min_opacity) {
02043 COUNT_COMPOSITE;
02044 iopc = ipixel->opcflt;
02045 # ifndef SKIP_ERT
02046 ASSERT(iopc < max_opacity);
02047 # endif
02048 iopc_inv = (float)1. - iopc;
02049
02050 ipixel->rclrflt += acc_rclr * iopc_inv;
02051 ipixel->gclrflt += acc_gclr * iopc_inv;
02052 ipixel->bclrflt += acc_bclr * iopc_inv;
02053 iopc += acc_opc * iopc_inv;
02054 ipixel->opcflt = iopc;
02055
02056 #ifdef DEBUG
02057 if (ipixel == trace_pixel_ptr) {
02058 #ifdef COMPUTE_SHADOW_BUFFER
02059 printf("{%3d} %3d %3d", k, icount-i-count, j);
02060 #else
02061 printf("[%3d] %3d %3d", k, icount-i-count, j);
02062 #endif
02063 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02064 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02065 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02066 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02067 printf(" %3.0f %3.0f\n", iopc*255.,
02068 ipixel->rclrflt);
02069
02070
02071 printf(" ");
02072 printf(" %3.0f ",trace_gclrTL);
02073 printf(" %3.0f ",trace_gclrBL);
02074 printf(" %3.0f ",trace_gclrTR);
02075 printf(" %3.0f ",trace_gclrBR);
02076 printf(" %3.0f\n", ipixel->gclrflt);
02077 printf(" ");
02078 printf(" %3.0f ",trace_bclrTL);
02079 printf(" %3.0f ",trace_bclrBL);
02080 printf(" %3.0f ",trace_bclrTR);
02081 printf(" %3.0f ",trace_bclrBR);
02082 printf(" %3.0f\n", ipixel->bclrflt);
02083 }
02084 #endif
02085 ;
02086 # ifndef SKIP_ERT
02087 if (iopc >= max_opacity) {
02088 ASSERT(ipixel->lnk == 0);
02089 ipixel->lnk = 1;
02090 }
02091 # endif
02092 };
02093 ipixel += 1;
02094 topRLEdata += 1 * voxel_istride;
02095 ;
02096 count--;
02097 SET_VOXELS_LOADED;
02098
02099
02100
02101 while (count > 0) {
02102 if (PIXEL_IS_OPAQUE(ipixel))
02103 break;
02104 if (!voxels_loaded) {
02105
02106 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02107
02108
02109 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
02110 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
02111
02112
02113
02114 top_rclr =
02115 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
02116
02117 top_gclr =
02118 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
02119
02120 top_bclr =
02121 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02122 ;
02123 ;
02124 ;
02125
02126
02127 top_rclr +=
02128 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02129
02130 top_gclr +=
02131 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02132
02133 top_bclr +=
02134 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02135 ;
02136 ;
02137 ;
02138 shade_factor = top_opc * slice_depth_cueing;
02139
02140 top_rclr *= shade_factor;
02141 top_gclr *= shade_factor;
02142 top_bclr *= shade_factor;
02143 ;
02144 }
02145
02146 #ifdef DEBUG
02147 if (ipixel == trace_pixel_ptr) {
02148 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02149 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02150 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02151 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02152 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02153 }
02154 #endif
02155 ;
02156
02157 acc_opc = top_opc * wgtTL;
02158
02159 acc_rclr = top_rclr * wgtTL;
02160 acc_gclr = top_gclr * wgtTL;
02161 acc_bclr = top_bclr * wgtTL;
02162
02163 #ifdef DEBUG
02164 if (ipixel == trace_pixel_ptr) {
02165 trace_opcTL = top_opc;
02166 trace_rclrTL = top_rclr;
02167 trace_gclrTL = top_gclr;
02168 trace_bclrTL = top_bclr;
02169
02170 }
02171 #endif
02172 ;
02173
02174 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02175
02176
02177 shade_index=2*3*ShortField(topRLEdata,norm_offset);
02178 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
02179
02180
02181
02182 top_rclr =
02183 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
02184
02185 top_gclr =
02186 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
02187
02188 top_bclr =
02189 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02190 ;
02191 ;
02192 ;
02193
02194
02195 top_rclr +=
02196 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02197
02198 top_gclr +=
02199 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02200
02201 top_bclr +=
02202 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02203 ;
02204 ;
02205 ;
02206 shade_factor = top_opc * slice_depth_cueing;
02207
02208 top_rclr *= shade_factor;
02209 top_gclr *= shade_factor;
02210 top_bclr *= shade_factor;
02211 ;
02212
02213 acc_opc += top_opc * wgtTR;
02214
02215 acc_rclr += top_rclr * wgtTR;
02216 acc_gclr += top_gclr * wgtTR;
02217 acc_bclr += top_bclr * wgtTR;
02218
02219 #ifdef DEBUG
02220 if (ipixel == trace_pixel_ptr) {
02221 trace_opcTR = top_opc;
02222 trace_rclrTR = top_rclr;
02223 trace_gclrTR = top_gclr;
02224 trace_bclrTR = top_bclr;
02225
02226 }
02227 #endif
02228 ;
02229
02230 COUNT_RESAMPLE;
02231 if (acc_opc > min_opacity) {
02232 COUNT_COMPOSITE;
02233 iopc = ipixel->opcflt;
02234 # ifndef SKIP_ERT
02235 ASSERT(iopc < max_opacity);
02236 # endif
02237 iopc_inv = (float)1. - iopc;
02238
02239 ipixel->rclrflt += acc_rclr * iopc_inv;
02240 ipixel->gclrflt += acc_gclr * iopc_inv;
02241 ipixel->bclrflt += acc_bclr * iopc_inv;
02242 iopc += acc_opc * iopc_inv;
02243 ipixel->opcflt = iopc;
02244
02245 #ifdef DEBUG
02246 if (ipixel == trace_pixel_ptr) {
02247 #ifdef COMPUTE_SHADOW_BUFFER
02248 printf("{%3d} %3d %3d", k, icount-i-count, j);
02249 #else
02250 printf("[%3d] %3d %3d", k, icount-i-count, j);
02251 #endif
02252 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02253 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02254 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02255 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02256 printf(" %3.0f %3.0f\n", iopc*255.,
02257 ipixel->rclrflt);
02258
02259
02260 printf(" ");
02261 printf(" %3.0f ",trace_gclrTL);
02262 printf(" %3.0f ",trace_gclrBL);
02263 printf(" %3.0f ",trace_gclrTR);
02264 printf(" %3.0f ",trace_gclrBR);
02265 printf(" %3.0f\n", ipixel->gclrflt);
02266 printf(" ");
02267 printf(" %3.0f ",trace_bclrTL);
02268 printf(" %3.0f ",trace_bclrBL);
02269 printf(" %3.0f ",trace_bclrTR);
02270 printf(" %3.0f ",trace_bclrBR);
02271 printf(" %3.0f\n", ipixel->bclrflt);
02272 }
02273 #endif
02274 ;
02275 # ifndef SKIP_ERT
02276 if (iopc >= max_opacity) {
02277 ASSERT(ipixel->lnk == 0);
02278 ipixel->lnk = 1;
02279 }
02280 # endif
02281 };
02282 ipixel += 1;
02283 topRLEdata += 1 * voxel_istride;
02284 ;
02285 count--;
02286 SET_VOXELS_LOADED;
02287 }
02288 break;
02289 case ALL_NONZERO__TOP_NONZERO:
02290
02291
02292 if (!voxels_loaded) {
02293
02294 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02295
02296
02297 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
02298 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
02299
02300
02301
02302 top_rclr =
02303 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
02304
02305 top_gclr =
02306 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
02307
02308 top_bclr =
02309 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02310 ;
02311 ;
02312 ;
02313
02314
02315 top_rclr +=
02316 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02317
02318 top_gclr +=
02319 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02320
02321 top_bclr +=
02322 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02323 ;
02324 ;
02325 ;
02326 shade_factor = top_opc * slice_depth_cueing;
02327
02328 top_rclr *= shade_factor;
02329 top_gclr *= shade_factor;
02330 top_bclr *= shade_factor;
02331 ;
02332
02333 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02334
02335
02336 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
02337 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
02338
02339
02340
02341 bot_rclr =
02342 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
02343
02344 bot_gclr =
02345 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
02346
02347 bot_bclr =
02348 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02349 ;
02350 ;
02351 ;
02352
02353
02354 bot_rclr +=
02355 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02356
02357 bot_gclr +=
02358 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02359
02360 bot_bclr +=
02361 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02362 ;
02363 ;
02364 ;
02365 shade_factor = bot_opc * slice_depth_cueing;
02366
02367 bot_rclr *= shade_factor;
02368 bot_gclr *= shade_factor;
02369 bot_bclr *= shade_factor;
02370 ;
02371 }
02372
02373 #ifdef DEBUG
02374 if (ipixel == trace_pixel_ptr) {
02375 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02376 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02377 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02378 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02379 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02380 }
02381 #endif
02382 ;
02383
02384 acc_opc = top_opc * wgtTL;
02385
02386 acc_rclr = top_rclr * wgtTL;
02387 acc_gclr = top_gclr * wgtTL;
02388 acc_bclr = top_bclr * wgtTL;
02389
02390 #ifdef DEBUG
02391 if (ipixel == trace_pixel_ptr) {
02392 trace_opcTL = top_opc;
02393 trace_rclrTL = top_rclr;
02394 trace_gclrTL = top_gclr;
02395 trace_bclrTL = top_bclr;
02396
02397 }
02398 #endif
02399 ;
02400
02401 acc_opc += bot_opc * wgtBL;
02402
02403 acc_rclr += bot_rclr * wgtBL;
02404 acc_gclr += bot_gclr * wgtBL;
02405 acc_bclr += bot_bclr * wgtBL;
02406
02407 #ifdef DEBUG
02408 if (ipixel == trace_pixel_ptr) {
02409 trace_opcBL = bot_opc;
02410 trace_rclrBL = bot_rclr;
02411 trace_gclrBL = bot_gclr;
02412 trace_bclrBL = bot_bclr;
02413
02414 }
02415 #endif
02416 ;
02417
02418 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02419
02420
02421 shade_index=2*3*ShortField(topRLEdata,norm_offset);
02422 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
02423
02424
02425
02426 top_rclr =
02427 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
02428
02429 top_gclr =
02430 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
02431
02432 top_bclr =
02433 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02434 ;
02435 ;
02436 ;
02437
02438
02439 top_rclr +=
02440 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02441
02442 top_gclr +=
02443 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02444
02445 top_bclr +=
02446 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02447 ;
02448 ;
02449 ;
02450 shade_factor = top_opc * slice_depth_cueing;
02451
02452 top_rclr *= shade_factor;
02453 top_gclr *= shade_factor;
02454 top_bclr *= shade_factor;
02455 ;
02456
02457 acc_opc += top_opc * wgtTR;
02458
02459 acc_rclr += top_rclr * wgtTR;
02460 acc_gclr += top_gclr * wgtTR;
02461 acc_bclr += top_bclr * wgtTR;
02462
02463 #ifdef DEBUG
02464 if (ipixel == trace_pixel_ptr) {
02465 trace_opcTR = top_opc;
02466 trace_rclrTR = top_rclr;
02467 trace_gclrTR = top_gclr;
02468 trace_bclrTR = top_bclr;
02469
02470 }
02471 #endif
02472 ;
02473
02474 COUNT_RESAMPLE;
02475 if (acc_opc > min_opacity) {
02476 COUNT_COMPOSITE;
02477 iopc = ipixel->opcflt;
02478 # ifndef SKIP_ERT
02479 ASSERT(iopc < max_opacity);
02480 # endif
02481 iopc_inv = (float)1. - iopc;
02482
02483 ipixel->rclrflt += acc_rclr * iopc_inv;
02484 ipixel->gclrflt += acc_gclr * iopc_inv;
02485 ipixel->bclrflt += acc_bclr * iopc_inv;
02486 iopc += acc_opc * iopc_inv;
02487 ipixel->opcflt = iopc;
02488
02489 #ifdef DEBUG
02490 if (ipixel == trace_pixel_ptr) {
02491 #ifdef COMPUTE_SHADOW_BUFFER
02492 printf("{%3d} %3d %3d", k, icount-i-count, j);
02493 #else
02494 printf("[%3d] %3d %3d", k, icount-i-count, j);
02495 #endif
02496 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02497 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02498 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02499 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02500 printf(" %3.0f %3.0f\n", iopc*255.,
02501 ipixel->rclrflt);
02502
02503
02504 printf(" ");
02505 printf(" %3.0f ",trace_gclrTL);
02506 printf(" %3.0f ",trace_gclrBL);
02507 printf(" %3.0f ",trace_gclrTR);
02508 printf(" %3.0f ",trace_gclrBR);
02509 printf(" %3.0f\n", ipixel->gclrflt);
02510 printf(" ");
02511 printf(" %3.0f ",trace_bclrTL);
02512 printf(" %3.0f ",trace_bclrBL);
02513 printf(" %3.0f ",trace_bclrTR);
02514 printf(" %3.0f ",trace_bclrBR);
02515 printf(" %3.0f\n", ipixel->bclrflt);
02516 }
02517 #endif
02518 ;
02519 # ifndef SKIP_ERT
02520 if (iopc >= max_opacity) {
02521 ASSERT(ipixel->lnk == 0);
02522 ipixel->lnk = 1;
02523 }
02524 # endif
02525 };
02526 ipixel += 1;
02527 topRLEdata += 1 * voxel_istride;
02528 ;
02529 count--;
02530 SET_VOXELS_LOADED;
02531
02532
02533
02534 while (count > 0) {
02535 if (PIXEL_IS_OPAQUE(ipixel))
02536 break;
02537 if (!voxels_loaded) {
02538
02539 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
02540
02541
02542 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
02543 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
02544
02545
02546
02547 top_rclr =
02548 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
02549
02550 top_gclr =
02551 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
02552
02553 top_bclr =
02554 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02555 ;
02556 ;
02557 ;
02558
02559
02560 top_rclr +=
02561 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02562
02563 top_gclr +=
02564 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02565
02566 top_bclr +=
02567 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02568 ;
02569 ;
02570 ;
02571 shade_factor = top_opc * slice_depth_cueing;
02572
02573 top_rclr *= shade_factor;
02574 top_gclr *= shade_factor;
02575 top_bclr *= shade_factor;
02576 ;
02577 }
02578
02579 #ifdef DEBUG
02580 if (ipixel == trace_pixel_ptr) {
02581 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02582 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02583 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02584 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02585 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02586 }
02587 #endif
02588 ;
02589
02590 acc_opc = top_opc * wgtTL;
02591
02592 acc_rclr = top_rclr * wgtTL;
02593 acc_gclr = top_gclr * wgtTL;
02594 acc_bclr = top_bclr * wgtTL;
02595
02596 #ifdef DEBUG
02597 if (ipixel == trace_pixel_ptr) {
02598 trace_opcTL = top_opc;
02599 trace_rclrTL = top_rclr;
02600 trace_gclrTL = top_gclr;
02601 trace_bclrTL = top_bclr;
02602
02603 }
02604 #endif
02605 ;
02606
02607 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
02608
02609
02610 shade_index=2*3*ShortField(topRLEdata,norm_offset);
02611 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
02612
02613
02614
02615 top_rclr =
02616 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
02617
02618 top_gclr =
02619 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
02620
02621 top_bclr =
02622 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02623 ;
02624 ;
02625 ;
02626
02627
02628 top_rclr +=
02629 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02630
02631 top_gclr +=
02632 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02633
02634 top_bclr +=
02635 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02636 ;
02637 ;
02638 ;
02639 shade_factor = top_opc * slice_depth_cueing;
02640
02641 top_rclr *= shade_factor;
02642 top_gclr *= shade_factor;
02643 top_bclr *= shade_factor;
02644 ;
02645
02646 acc_opc += top_opc * wgtTR;
02647
02648 acc_rclr += top_rclr * wgtTR;
02649 acc_gclr += top_gclr * wgtTR;
02650 acc_bclr += top_bclr * wgtTR;
02651
02652 #ifdef DEBUG
02653 if (ipixel == trace_pixel_ptr) {
02654 trace_opcTR = top_opc;
02655 trace_rclrTR = top_rclr;
02656 trace_gclrTR = top_gclr;
02657 trace_bclrTR = top_bclr;
02658
02659 }
02660 #endif
02661 ;
02662
02663 COUNT_RESAMPLE;
02664 if (acc_opc > min_opacity) {
02665 COUNT_COMPOSITE;
02666 iopc = ipixel->opcflt;
02667 # ifndef SKIP_ERT
02668 ASSERT(iopc < max_opacity);
02669 # endif
02670 iopc_inv = (float)1. - iopc;
02671
02672 ipixel->rclrflt += acc_rclr * iopc_inv;
02673 ipixel->gclrflt += acc_gclr * iopc_inv;
02674 ipixel->bclrflt += acc_bclr * iopc_inv;
02675 iopc += acc_opc * iopc_inv;
02676 ipixel->opcflt = iopc;
02677
02678 #ifdef DEBUG
02679 if (ipixel == trace_pixel_ptr) {
02680 #ifdef COMPUTE_SHADOW_BUFFER
02681 printf("{%3d} %3d %3d", k, icount-i-count, j);
02682 #else
02683 printf("[%3d] %3d %3d", k, icount-i-count, j);
02684 #endif
02685 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02686 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02687 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02688 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02689 printf(" %3.0f %3.0f\n", iopc*255.,
02690 ipixel->rclrflt);
02691
02692
02693 printf(" ");
02694 printf(" %3.0f ",trace_gclrTL);
02695 printf(" %3.0f ",trace_gclrBL);
02696 printf(" %3.0f ",trace_gclrTR);
02697 printf(" %3.0f ",trace_gclrBR);
02698 printf(" %3.0f\n", ipixel->gclrflt);
02699 printf(" ");
02700 printf(" %3.0f ",trace_bclrTL);
02701 printf(" %3.0f ",trace_bclrBL);
02702 printf(" %3.0f ",trace_bclrTR);
02703 printf(" %3.0f ",trace_bclrBR);
02704 printf(" %3.0f\n", ipixel->bclrflt);
02705 }
02706 #endif
02707 ;
02708 # ifndef SKIP_ERT
02709 if (iopc >= max_opacity) {
02710 ASSERT(ipixel->lnk == 0);
02711 ipixel->lnk = 1;
02712 }
02713 # endif
02714 };
02715 ipixel += 1;
02716 topRLEdata += 1 * voxel_istride;
02717 ;
02718 count--;
02719 SET_VOXELS_LOADED;
02720 }
02721 break;
02722 case ALL_ZERO__BOT_NONZERO:
02723
02724
02725 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02726
02727
02728 shade_index=2*3*ShortField(botRLEdata,norm_offset);
02729 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
02730
02731
02732
02733 bot_rclr =
02734 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
02735
02736 bot_gclr =
02737 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
02738
02739 bot_bclr =
02740 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02741 ;
02742 ;
02743 ;
02744
02745
02746 bot_rclr +=
02747 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02748
02749 bot_gclr +=
02750 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02751
02752 bot_bclr +=
02753 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02754 ;
02755 ;
02756 ;
02757 shade_factor = bot_opc * slice_depth_cueing;
02758
02759 bot_rclr *= shade_factor;
02760 bot_gclr *= shade_factor;
02761 bot_bclr *= shade_factor;
02762 ;
02763
02764 #ifdef DEBUG
02765 if (ipixel == trace_pixel_ptr) {
02766 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02767 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02768 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02769 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02770 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02771 }
02772 #endif
02773 ;
02774
02775 acc_opc = bot_opc * wgtBR;
02776
02777 acc_rclr = bot_rclr * wgtBR;
02778 acc_gclr = bot_gclr * wgtBR;
02779 acc_bclr = bot_bclr * wgtBR;
02780
02781 #ifdef DEBUG
02782 if (ipixel == trace_pixel_ptr) {
02783 trace_opcBR = bot_opc;
02784 trace_rclrBR = bot_rclr;
02785 trace_gclrBR = bot_gclr;
02786 trace_bclrBR = bot_bclr;
02787
02788 }
02789 #endif
02790 ;
02791
02792 COUNT_RESAMPLE;
02793 if (acc_opc > min_opacity) {
02794 COUNT_COMPOSITE;
02795 iopc = ipixel->opcflt;
02796 # ifndef SKIP_ERT
02797 ASSERT(iopc < max_opacity);
02798 # endif
02799 iopc_inv = (float)1. - iopc;
02800
02801 ipixel->rclrflt += acc_rclr * iopc_inv;
02802 ipixel->gclrflt += acc_gclr * iopc_inv;
02803 ipixel->bclrflt += acc_bclr * iopc_inv;
02804 iopc += acc_opc * iopc_inv;
02805 ipixel->opcflt = iopc;
02806
02807 #ifdef DEBUG
02808 if (ipixel == trace_pixel_ptr) {
02809 #ifdef COMPUTE_SHADOW_BUFFER
02810 printf("{%3d} %3d %3d", k, icount-i-count, j);
02811 #else
02812 printf("[%3d] %3d %3d", k, icount-i-count, j);
02813 #endif
02814 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
02815 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
02816 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
02817 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
02818 printf(" %3.0f %3.0f\n", iopc*255.,
02819 ipixel->rclrflt);
02820
02821
02822 printf(" ");
02823 printf(" %3.0f ",trace_gclrTL);
02824 printf(" %3.0f ",trace_gclrBL);
02825 printf(" %3.0f ",trace_gclrTR);
02826 printf(" %3.0f ",trace_gclrBR);
02827 printf(" %3.0f\n", ipixel->gclrflt);
02828 printf(" ");
02829 printf(" %3.0f ",trace_bclrTL);
02830 printf(" %3.0f ",trace_bclrBL);
02831 printf(" %3.0f ",trace_bclrTR);
02832 printf(" %3.0f ",trace_bclrBR);
02833 printf(" %3.0f\n", ipixel->bclrflt);
02834 }
02835 #endif
02836 ;
02837 # ifndef SKIP_ERT
02838 if (iopc >= max_opacity) {
02839 ASSERT(ipixel->lnk == 0);
02840 ipixel->lnk = 1;
02841 }
02842 # endif
02843 };
02844 ipixel += 1;
02845 ;
02846 botRLEdata += 1 * voxel_istride;
02847 count--;
02848 SET_VOXELS_LOADED;
02849
02850
02851
02852 while (count > 0) {
02853 if (PIXEL_IS_OPAQUE(ipixel))
02854 break;
02855 if (!voxels_loaded) {
02856
02857 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
02858
02859
02860 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
02861 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
02862
02863
02864
02865 bot_rclr =
02866 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
02867
02868 bot_gclr =
02869 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
02870
02871 bot_bclr =
02872 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02873 ;
02874 ;
02875 ;
02876
02877
02878 bot_rclr +=
02879 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02880
02881 bot_gclr +=
02882 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02883
02884 bot_bclr +=
02885 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02886 ;
02887 ;
02888 ;
02889 shade_factor = bot_opc * slice_depth_cueing;
02890
02891 bot_rclr *= shade_factor;
02892 bot_gclr *= shade_factor;
02893 bot_bclr *= shade_factor;
02894 ;
02895 }
02896
02897 #ifdef DEBUG
02898 if (ipixel == trace_pixel_ptr) {
02899 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
02900 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
02901 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
02902 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
02903 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
02904 }
02905 #endif
02906 ;
02907
02908 acc_opc = bot_opc * wgtBL;
02909
02910 acc_rclr = bot_rclr * wgtBL;
02911 acc_gclr = bot_gclr * wgtBL;
02912 acc_bclr = bot_bclr * wgtBL;
02913
02914 #ifdef DEBUG
02915 if (ipixel == trace_pixel_ptr) {
02916 trace_opcBL = bot_opc;
02917 trace_rclrBL = bot_rclr;
02918 trace_gclrBL = bot_gclr;
02919 trace_bclrBL = bot_bclr;
02920
02921 }
02922 #endif
02923 ;
02924
02925 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
02926
02927
02928 shade_index=2*3*ShortField(botRLEdata,norm_offset);
02929 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
02930
02931
02932
02933 bot_rclr =
02934 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
02935
02936 bot_gclr =
02937 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
02938
02939 bot_bclr =
02940 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
02941 ;
02942 ;
02943 ;
02944
02945
02946 bot_rclr +=
02947 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
02948
02949 bot_gclr +=
02950 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
02951
02952 bot_bclr +=
02953 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
02954 ;
02955 ;
02956 ;
02957 shade_factor = bot_opc * slice_depth_cueing;
02958
02959 bot_rclr *= shade_factor;
02960 bot_gclr *= shade_factor;
02961 bot_bclr *= shade_factor;
02962 ;
02963
02964 acc_opc += bot_opc * wgtBR;
02965
02966 acc_rclr += bot_rclr * wgtBR;
02967 acc_gclr += bot_gclr * wgtBR;
02968 acc_bclr += bot_bclr * wgtBR;
02969
02970 #ifdef DEBUG
02971 if (ipixel == trace_pixel_ptr) {
02972 trace_opcBR = bot_opc;
02973 trace_rclrBR = bot_rclr;
02974 trace_gclrBR = bot_gclr;
02975 trace_bclrBR = bot_bclr;
02976
02977 }
02978 #endif
02979 ;
02980
02981 COUNT_RESAMPLE;
02982 if (acc_opc > min_opacity) {
02983 COUNT_COMPOSITE;
02984 iopc = ipixel->opcflt;
02985 # ifndef SKIP_ERT
02986 ASSERT(iopc < max_opacity);
02987 # endif
02988 iopc_inv = (float)1. - iopc;
02989
02990 ipixel->rclrflt += acc_rclr * iopc_inv;
02991 ipixel->gclrflt += acc_gclr * iopc_inv;
02992 ipixel->bclrflt += acc_bclr * iopc_inv;
02993 iopc += acc_opc * iopc_inv;
02994 ipixel->opcflt = iopc;
02995
02996 #ifdef DEBUG
02997 if (ipixel == trace_pixel_ptr) {
02998 #ifdef COMPUTE_SHADOW_BUFFER
02999 printf("{%3d} %3d %3d", k, icount-i-count, j);
03000 #else
03001 printf("[%3d] %3d %3d", k, icount-i-count, j);
03002 #endif
03003 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03004 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03005 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03006 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03007 printf(" %3.0f %3.0f\n", iopc*255.,
03008 ipixel->rclrflt);
03009
03010
03011 printf(" ");
03012 printf(" %3.0f ",trace_gclrTL);
03013 printf(" %3.0f ",trace_gclrBL);
03014 printf(" %3.0f ",trace_gclrTR);
03015 printf(" %3.0f ",trace_gclrBR);
03016 printf(" %3.0f\n", ipixel->gclrflt);
03017 printf(" ");
03018 printf(" %3.0f ",trace_bclrTL);
03019 printf(" %3.0f ",trace_bclrBL);
03020 printf(" %3.0f ",trace_bclrTR);
03021 printf(" %3.0f ",trace_bclrBR);
03022 printf(" %3.0f\n", ipixel->bclrflt);
03023 }
03024 #endif
03025 ;
03026 # ifndef SKIP_ERT
03027 if (iopc >= max_opacity) {
03028 ASSERT(ipixel->lnk == 0);
03029 ipixel->lnk = 1;
03030 }
03031 # endif
03032 };
03033 ipixel += 1;
03034 ;
03035 botRLEdata += 1 * voxel_istride;
03036 count--;
03037 SET_VOXELS_LOADED;
03038 }
03039 break;
03040 case TOP_NONZERO__BOT_NONZERO:
03041
03042 if (!voxels_loaded) {
03043
03044 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03045
03046
03047 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
03048 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
03049
03050
03051
03052 top_rclr =
03053 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03054
03055 top_gclr =
03056 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03057
03058 top_bclr =
03059 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03060 ;
03061 ;
03062 ;
03063
03064
03065 top_rclr +=
03066 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03067
03068 top_gclr +=
03069 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03070
03071 top_bclr +=
03072 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03073 ;
03074 ;
03075 ;
03076 shade_factor = top_opc * slice_depth_cueing;
03077
03078 top_rclr *= shade_factor;
03079 top_gclr *= shade_factor;
03080 top_bclr *= shade_factor;
03081 ;
03082 }
03083
03084 #ifdef DEBUG
03085 if (ipixel == trace_pixel_ptr) {
03086 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03087 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03088 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03089 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03090 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03091 }
03092 #endif
03093 ;
03094
03095 acc_opc = top_opc * wgtTL;
03096
03097 acc_rclr = top_rclr * wgtTL;
03098 acc_gclr = top_gclr * wgtTL;
03099 acc_bclr = top_bclr * wgtTL;
03100
03101 #ifdef DEBUG
03102 if (ipixel == trace_pixel_ptr) {
03103 trace_opcTL = top_opc;
03104 trace_rclrTL = top_rclr;
03105 trace_gclrTL = top_gclr;
03106 trace_bclrTL = top_bclr;
03107
03108 }
03109 #endif
03110 ;
03111
03112 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03113
03114
03115 shade_index=2*3*ShortField(botRLEdata,norm_offset);
03116 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
03117
03118
03119
03120 bot_rclr =
03121 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03122
03123 bot_gclr =
03124 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03125
03126 bot_bclr =
03127 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03128 ;
03129 ;
03130 ;
03131
03132
03133 bot_rclr +=
03134 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03135
03136 bot_gclr +=
03137 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03138
03139 bot_bclr +=
03140 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03141 ;
03142 ;
03143 ;
03144 shade_factor = bot_opc * slice_depth_cueing;
03145
03146 bot_rclr *= shade_factor;
03147 bot_gclr *= shade_factor;
03148 bot_bclr *= shade_factor;
03149 ;
03150
03151 acc_opc += bot_opc * wgtBR;
03152
03153 acc_rclr += bot_rclr * wgtBR;
03154 acc_gclr += bot_gclr * wgtBR;
03155 acc_bclr += bot_bclr * wgtBR;
03156
03157 #ifdef DEBUG
03158 if (ipixel == trace_pixel_ptr) {
03159 trace_opcBR = bot_opc;
03160 trace_rclrBR = bot_rclr;
03161 trace_gclrBR = bot_gclr;
03162 trace_bclrBR = bot_bclr;
03163
03164 }
03165 #endif
03166 ;
03167
03168 COUNT_RESAMPLE;
03169 if (acc_opc > min_opacity) {
03170 COUNT_COMPOSITE;
03171 iopc = ipixel->opcflt;
03172 # ifndef SKIP_ERT
03173 ASSERT(iopc < max_opacity);
03174 # endif
03175 iopc_inv = (float)1. - iopc;
03176
03177 ipixel->rclrflt += acc_rclr * iopc_inv;
03178 ipixel->gclrflt += acc_gclr * iopc_inv;
03179 ipixel->bclrflt += acc_bclr * iopc_inv;
03180 iopc += acc_opc * iopc_inv;
03181 ipixel->opcflt = iopc;
03182
03183 #ifdef DEBUG
03184 if (ipixel == trace_pixel_ptr) {
03185 #ifdef COMPUTE_SHADOW_BUFFER
03186 printf("{%3d} %3d %3d", k, icount-i-count, j);
03187 #else
03188 printf("[%3d] %3d %3d", k, icount-i-count, j);
03189 #endif
03190 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03191 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03192 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03193 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03194 printf(" %3.0f %3.0f\n", iopc*255.,
03195 ipixel->rclrflt);
03196
03197
03198 printf(" ");
03199 printf(" %3.0f ",trace_gclrTL);
03200 printf(" %3.0f ",trace_gclrBL);
03201 printf(" %3.0f ",trace_gclrTR);
03202 printf(" %3.0f ",trace_gclrBR);
03203 printf(" %3.0f\n", ipixel->gclrflt);
03204 printf(" ");
03205 printf(" %3.0f ",trace_bclrTL);
03206 printf(" %3.0f ",trace_bclrBL);
03207 printf(" %3.0f ",trace_bclrTR);
03208 printf(" %3.0f ",trace_bclrBR);
03209 printf(" %3.0f\n", ipixel->bclrflt);
03210 }
03211 #endif
03212 ;
03213 # ifndef SKIP_ERT
03214 if (iopc >= max_opacity) {
03215 ASSERT(ipixel->lnk == 0);
03216 ipixel->lnk = 1;
03217 }
03218 # endif
03219 };
03220 ipixel += 1;
03221 ;
03222 botRLEdata += 1 * voxel_istride;
03223 count--;
03224 SET_VOXELS_LOADED;
03225
03226
03227
03228 while (count > 0) {
03229 if (PIXEL_IS_OPAQUE(ipixel))
03230 break;
03231 if (!voxels_loaded) {
03232
03233 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03234
03235
03236 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
03237 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
03238
03239
03240
03241 bot_rclr =
03242 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03243
03244 bot_gclr =
03245 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03246
03247 bot_bclr =
03248 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03249 ;
03250 ;
03251 ;
03252
03253
03254 bot_rclr +=
03255 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03256
03257 bot_gclr +=
03258 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03259
03260 bot_bclr +=
03261 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03262 ;
03263 ;
03264 ;
03265 shade_factor = bot_opc * slice_depth_cueing;
03266
03267 bot_rclr *= shade_factor;
03268 bot_gclr *= shade_factor;
03269 bot_bclr *= shade_factor;
03270 ;
03271 }
03272
03273 #ifdef DEBUG
03274 if (ipixel == trace_pixel_ptr) {
03275 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03276 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03277 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03278 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03279 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03280 }
03281 #endif
03282 ;
03283
03284 acc_opc = bot_opc * wgtBL;
03285
03286 acc_rclr = bot_rclr * wgtBL;
03287 acc_gclr = bot_gclr * wgtBL;
03288 acc_bclr = bot_bclr * wgtBL;
03289
03290 #ifdef DEBUG
03291 if (ipixel == trace_pixel_ptr) {
03292 trace_opcBL = bot_opc;
03293 trace_rclrBL = bot_rclr;
03294 trace_gclrBL = bot_gclr;
03295 trace_bclrBL = bot_bclr;
03296
03297 }
03298 #endif
03299 ;
03300
03301 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03302
03303
03304 shade_index=2*3*ShortField(botRLEdata,norm_offset);
03305 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
03306
03307
03308
03309 bot_rclr =
03310 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03311
03312 bot_gclr =
03313 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03314
03315 bot_bclr =
03316 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03317 ;
03318 ;
03319 ;
03320
03321
03322 bot_rclr +=
03323 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03324
03325 bot_gclr +=
03326 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03327
03328 bot_bclr +=
03329 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03330 ;
03331 ;
03332 ;
03333 shade_factor = bot_opc * slice_depth_cueing;
03334
03335 bot_rclr *= shade_factor;
03336 bot_gclr *= shade_factor;
03337 bot_bclr *= shade_factor;
03338 ;
03339
03340 acc_opc += bot_opc * wgtBR;
03341
03342 acc_rclr += bot_rclr * wgtBR;
03343 acc_gclr += bot_gclr * wgtBR;
03344 acc_bclr += bot_bclr * wgtBR;
03345
03346 #ifdef DEBUG
03347 if (ipixel == trace_pixel_ptr) {
03348 trace_opcBR = bot_opc;
03349 trace_rclrBR = bot_rclr;
03350 trace_gclrBR = bot_gclr;
03351 trace_bclrBR = bot_bclr;
03352
03353 }
03354 #endif
03355 ;
03356
03357 COUNT_RESAMPLE;
03358 if (acc_opc > min_opacity) {
03359 COUNT_COMPOSITE;
03360 iopc = ipixel->opcflt;
03361 # ifndef SKIP_ERT
03362 ASSERT(iopc < max_opacity);
03363 # endif
03364 iopc_inv = (float)1. - iopc;
03365
03366 ipixel->rclrflt += acc_rclr * iopc_inv;
03367 ipixel->gclrflt += acc_gclr * iopc_inv;
03368 ipixel->bclrflt += acc_bclr * iopc_inv;
03369 iopc += acc_opc * iopc_inv;
03370 ipixel->opcflt = iopc;
03371
03372 #ifdef DEBUG
03373 if (ipixel == trace_pixel_ptr) {
03374 #ifdef COMPUTE_SHADOW_BUFFER
03375 printf("{%3d} %3d %3d", k, icount-i-count, j);
03376 #else
03377 printf("[%3d] %3d %3d", k, icount-i-count, j);
03378 #endif
03379 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03380 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03381 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03382 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03383 printf(" %3.0f %3.0f\n", iopc*255.,
03384 ipixel->rclrflt);
03385
03386
03387 printf(" ");
03388 printf(" %3.0f ",trace_gclrTL);
03389 printf(" %3.0f ",trace_gclrBL);
03390 printf(" %3.0f ",trace_gclrTR);
03391 printf(" %3.0f ",trace_gclrBR);
03392 printf(" %3.0f\n", ipixel->gclrflt);
03393 printf(" ");
03394 printf(" %3.0f ",trace_bclrTL);
03395 printf(" %3.0f ",trace_bclrBL);
03396 printf(" %3.0f ",trace_bclrTR);
03397 printf(" %3.0f ",trace_bclrBR);
03398 printf(" %3.0f\n", ipixel->bclrflt);
03399 }
03400 #endif
03401 ;
03402 # ifndef SKIP_ERT
03403 if (iopc >= max_opacity) {
03404 ASSERT(ipixel->lnk == 0);
03405 ipixel->lnk = 1;
03406 }
03407 # endif
03408 };
03409 ipixel += 1;
03410 ;
03411 botRLEdata += 1 * voxel_istride;
03412 count--;
03413 SET_VOXELS_LOADED;
03414 }
03415 break;
03416 case BOT_NONZERO__BOT_NONZERO:
03417
03418
03419 while (count > 0) {
03420 if (PIXEL_IS_OPAQUE(ipixel))
03421 break;
03422 if (!voxels_loaded) {
03423
03424 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03425
03426
03427 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
03428 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
03429
03430
03431
03432 bot_rclr =
03433 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03434
03435 bot_gclr =
03436 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03437
03438 bot_bclr =
03439 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03440 ;
03441 ;
03442 ;
03443
03444
03445 bot_rclr +=
03446 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03447
03448 bot_gclr +=
03449 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03450
03451 bot_bclr +=
03452 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03453 ;
03454 ;
03455 ;
03456 shade_factor = bot_opc * slice_depth_cueing;
03457
03458 bot_rclr *= shade_factor;
03459 bot_gclr *= shade_factor;
03460 bot_bclr *= shade_factor;
03461 ;
03462 }
03463
03464 #ifdef DEBUG
03465 if (ipixel == trace_pixel_ptr) {
03466 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03467 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03468 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03469 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03470 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03471 }
03472 #endif
03473 ;
03474
03475 acc_opc = bot_opc * wgtBL;
03476
03477 acc_rclr = bot_rclr * wgtBL;
03478 acc_gclr = bot_gclr * wgtBL;
03479 acc_bclr = bot_bclr * wgtBL;
03480
03481 #ifdef DEBUG
03482 if (ipixel == trace_pixel_ptr) {
03483 trace_opcBL = bot_opc;
03484 trace_rclrBL = bot_rclr;
03485 trace_gclrBL = bot_gclr;
03486 trace_bclrBL = bot_bclr;
03487
03488 }
03489 #endif
03490 ;
03491
03492 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03493
03494
03495 shade_index=2*3*ShortField(botRLEdata,norm_offset);
03496 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
03497
03498
03499
03500 bot_rclr =
03501 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03502
03503 bot_gclr =
03504 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03505
03506 bot_bclr =
03507 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03508 ;
03509 ;
03510 ;
03511
03512
03513 bot_rclr +=
03514 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03515
03516 bot_gclr +=
03517 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03518
03519 bot_bclr +=
03520 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03521 ;
03522 ;
03523 ;
03524 shade_factor = bot_opc * slice_depth_cueing;
03525
03526 bot_rclr *= shade_factor;
03527 bot_gclr *= shade_factor;
03528 bot_bclr *= shade_factor;
03529 ;
03530
03531 acc_opc += bot_opc * wgtBR;
03532
03533 acc_rclr += bot_rclr * wgtBR;
03534 acc_gclr += bot_gclr * wgtBR;
03535 acc_bclr += bot_bclr * wgtBR;
03536
03537 #ifdef DEBUG
03538 if (ipixel == trace_pixel_ptr) {
03539 trace_opcBR = bot_opc;
03540 trace_rclrBR = bot_rclr;
03541 trace_gclrBR = bot_gclr;
03542 trace_bclrBR = bot_bclr;
03543
03544 }
03545 #endif
03546 ;
03547
03548 COUNT_RESAMPLE;
03549 if (acc_opc > min_opacity) {
03550 COUNT_COMPOSITE;
03551 iopc = ipixel->opcflt;
03552 # ifndef SKIP_ERT
03553 ASSERT(iopc < max_opacity);
03554 # endif
03555 iopc_inv = (float)1. - iopc;
03556
03557 ipixel->rclrflt += acc_rclr * iopc_inv;
03558 ipixel->gclrflt += acc_gclr * iopc_inv;
03559 ipixel->bclrflt += acc_bclr * iopc_inv;
03560 iopc += acc_opc * iopc_inv;
03561 ipixel->opcflt = iopc;
03562
03563 #ifdef DEBUG
03564 if (ipixel == trace_pixel_ptr) {
03565 #ifdef COMPUTE_SHADOW_BUFFER
03566 printf("{%3d} %3d %3d", k, icount-i-count, j);
03567 #else
03568 printf("[%3d] %3d %3d", k, icount-i-count, j);
03569 #endif
03570 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03571 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03572 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03573 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03574 printf(" %3.0f %3.0f\n", iopc*255.,
03575 ipixel->rclrflt);
03576
03577
03578 printf(" ");
03579 printf(" %3.0f ",trace_gclrTL);
03580 printf(" %3.0f ",trace_gclrBL);
03581 printf(" %3.0f ",trace_gclrTR);
03582 printf(" %3.0f ",trace_gclrBR);
03583 printf(" %3.0f\n", ipixel->gclrflt);
03584 printf(" ");
03585 printf(" %3.0f ",trace_bclrTL);
03586 printf(" %3.0f ",trace_bclrBL);
03587 printf(" %3.0f ",trace_bclrTR);
03588 printf(" %3.0f ",trace_bclrBR);
03589 printf(" %3.0f\n", ipixel->bclrflt);
03590 }
03591 #endif
03592 ;
03593 # ifndef SKIP_ERT
03594 if (iopc >= max_opacity) {
03595 ASSERT(ipixel->lnk == 0);
03596 ipixel->lnk = 1;
03597 }
03598 # endif
03599 };
03600 ipixel += 1;
03601 ;
03602 botRLEdata += 1 * voxel_istride;
03603 count--;
03604 SET_VOXELS_LOADED;
03605 }
03606 break;
03607 case ALL_NONZERO__BOT_NONZERO:
03608
03609
03610 if (!voxels_loaded) {
03611
03612 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
03613
03614
03615 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
03616 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
03617
03618
03619
03620 top_rclr =
03621 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03622
03623 top_gclr =
03624 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03625
03626 top_bclr =
03627 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03628 ;
03629 ;
03630 ;
03631
03632
03633 top_rclr +=
03634 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03635
03636 top_gclr +=
03637 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03638
03639 top_bclr +=
03640 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03641 ;
03642 ;
03643 ;
03644 shade_factor = top_opc * slice_depth_cueing;
03645
03646 top_rclr *= shade_factor;
03647 top_gclr *= shade_factor;
03648 top_bclr *= shade_factor;
03649 ;
03650
03651 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03652
03653
03654 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
03655 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
03656
03657
03658
03659 bot_rclr =
03660 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03661
03662 bot_gclr =
03663 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03664
03665 bot_bclr =
03666 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03667 ;
03668 ;
03669 ;
03670
03671
03672 bot_rclr +=
03673 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03674
03675 bot_gclr +=
03676 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03677
03678 bot_bclr +=
03679 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03680 ;
03681 ;
03682 ;
03683 shade_factor = bot_opc * slice_depth_cueing;
03684
03685 bot_rclr *= shade_factor;
03686 bot_gclr *= shade_factor;
03687 bot_bclr *= shade_factor;
03688 ;
03689 }
03690
03691 #ifdef DEBUG
03692 if (ipixel == trace_pixel_ptr) {
03693 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03694 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03695 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03696 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03697 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03698 }
03699 #endif
03700 ;
03701
03702 acc_opc = top_opc * wgtTL;
03703
03704 acc_rclr = top_rclr * wgtTL;
03705 acc_gclr = top_gclr * wgtTL;
03706 acc_bclr = top_bclr * wgtTL;
03707
03708 #ifdef DEBUG
03709 if (ipixel == trace_pixel_ptr) {
03710 trace_opcTL = top_opc;
03711 trace_rclrTL = top_rclr;
03712 trace_gclrTL = top_gclr;
03713 trace_bclrTL = top_bclr;
03714
03715 }
03716 #endif
03717 ;
03718
03719 acc_opc += bot_opc * wgtBL;
03720
03721 acc_rclr += bot_rclr * wgtBL;
03722 acc_gclr += bot_gclr * wgtBL;
03723 acc_bclr += bot_bclr * wgtBL;
03724
03725 #ifdef DEBUG
03726 if (ipixel == trace_pixel_ptr) {
03727 trace_opcBL = bot_opc;
03728 trace_rclrBL = bot_rclr;
03729 trace_gclrBL = bot_gclr;
03730 trace_bclrBL = bot_bclr;
03731
03732 }
03733 #endif
03734 ;
03735
03736 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03737
03738
03739 shade_index=2*3*ShortField(botRLEdata,norm_offset);
03740 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
03741
03742
03743
03744 bot_rclr =
03745 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03746
03747 bot_gclr =
03748 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03749
03750 bot_bclr =
03751 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03752 ;
03753 ;
03754 ;
03755
03756
03757 bot_rclr +=
03758 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03759
03760 bot_gclr +=
03761 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03762
03763 bot_bclr +=
03764 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03765 ;
03766 ;
03767 ;
03768 shade_factor = bot_opc * slice_depth_cueing;
03769
03770 bot_rclr *= shade_factor;
03771 bot_gclr *= shade_factor;
03772 bot_bclr *= shade_factor;
03773 ;
03774
03775 acc_opc += bot_opc * wgtBR;
03776
03777 acc_rclr += bot_rclr * wgtBR;
03778 acc_gclr += bot_gclr * wgtBR;
03779 acc_bclr += bot_bclr * wgtBR;
03780
03781 #ifdef DEBUG
03782 if (ipixel == trace_pixel_ptr) {
03783 trace_opcBR = bot_opc;
03784 trace_rclrBR = bot_rclr;
03785 trace_gclrBR = bot_gclr;
03786 trace_bclrBR = bot_bclr;
03787
03788 }
03789 #endif
03790 ;
03791
03792 COUNT_RESAMPLE;
03793 if (acc_opc > min_opacity) {
03794 COUNT_COMPOSITE;
03795 iopc = ipixel->opcflt;
03796 # ifndef SKIP_ERT
03797 ASSERT(iopc < max_opacity);
03798 # endif
03799 iopc_inv = (float)1. - iopc;
03800
03801 ipixel->rclrflt += acc_rclr * iopc_inv;
03802 ipixel->gclrflt += acc_gclr * iopc_inv;
03803 ipixel->bclrflt += acc_bclr * iopc_inv;
03804 iopc += acc_opc * iopc_inv;
03805 ipixel->opcflt = iopc;
03806
03807 #ifdef DEBUG
03808 if (ipixel == trace_pixel_ptr) {
03809 #ifdef COMPUTE_SHADOW_BUFFER
03810 printf("{%3d} %3d %3d", k, icount-i-count, j);
03811 #else
03812 printf("[%3d] %3d %3d", k, icount-i-count, j);
03813 #endif
03814 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
03815 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
03816 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
03817 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
03818 printf(" %3.0f %3.0f\n", iopc*255.,
03819 ipixel->rclrflt);
03820
03821
03822 printf(" ");
03823 printf(" %3.0f ",trace_gclrTL);
03824 printf(" %3.0f ",trace_gclrBL);
03825 printf(" %3.0f ",trace_gclrTR);
03826 printf(" %3.0f ",trace_gclrBR);
03827 printf(" %3.0f\n", ipixel->gclrflt);
03828 printf(" ");
03829 printf(" %3.0f ",trace_bclrTL);
03830 printf(" %3.0f ",trace_bclrBL);
03831 printf(" %3.0f ",trace_bclrTR);
03832 printf(" %3.0f ",trace_bclrBR);
03833 printf(" %3.0f\n", ipixel->bclrflt);
03834 }
03835 #endif
03836 ;
03837 # ifndef SKIP_ERT
03838 if (iopc >= max_opacity) {
03839 ASSERT(ipixel->lnk == 0);
03840 ipixel->lnk = 1;
03841 }
03842 # endif
03843 };
03844 ipixel += 1;
03845 ;
03846 botRLEdata += 1 * voxel_istride;
03847 count--;
03848 SET_VOXELS_LOADED;
03849
03850
03851
03852 while (count > 0) {
03853 if (PIXEL_IS_OPAQUE(ipixel))
03854 break;
03855 if (!voxels_loaded) {
03856
03857 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
03858
03859
03860 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
03861 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
03862
03863
03864
03865 bot_rclr =
03866 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03867
03868 bot_gclr =
03869 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03870
03871 bot_bclr =
03872 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03873 ;
03874 ;
03875 ;
03876
03877
03878 bot_rclr +=
03879 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03880
03881 bot_gclr +=
03882 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03883
03884 bot_bclr +=
03885 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03886 ;
03887 ;
03888 ;
03889 shade_factor = bot_opc * slice_depth_cueing;
03890
03891 bot_rclr *= shade_factor;
03892 bot_gclr *= shade_factor;
03893 bot_bclr *= shade_factor;
03894 ;
03895 }
03896
03897 #ifdef DEBUG
03898 if (ipixel == trace_pixel_ptr) {
03899 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
03900 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
03901 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
03902 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
03903 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
03904 }
03905 #endif
03906 ;
03907
03908 acc_opc = bot_opc * wgtBL;
03909
03910 acc_rclr = bot_rclr * wgtBL;
03911 acc_gclr = bot_gclr * wgtBL;
03912 acc_bclr = bot_bclr * wgtBL;
03913
03914 #ifdef DEBUG
03915 if (ipixel == trace_pixel_ptr) {
03916 trace_opcBL = bot_opc;
03917 trace_rclrBL = bot_rclr;
03918 trace_gclrBL = bot_gclr;
03919 trace_bclrBL = bot_bclr;
03920
03921 }
03922 #endif
03923 ;
03924
03925 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
03926
03927
03928 shade_index=2*3*ShortField(botRLEdata,norm_offset);
03929 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
03930
03931
03932
03933 bot_rclr =
03934 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
03935
03936 bot_gclr =
03937 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
03938
03939 bot_bclr =
03940 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
03941 ;
03942 ;
03943 ;
03944
03945
03946 bot_rclr +=
03947 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
03948
03949 bot_gclr +=
03950 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
03951
03952 bot_bclr +=
03953 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
03954 ;
03955 ;
03956 ;
03957 shade_factor = bot_opc * slice_depth_cueing;
03958
03959 bot_rclr *= shade_factor;
03960 bot_gclr *= shade_factor;
03961 bot_bclr *= shade_factor;
03962 ;
03963
03964 acc_opc += bot_opc * wgtBR;
03965
03966 acc_rclr += bot_rclr * wgtBR;
03967 acc_gclr += bot_gclr * wgtBR;
03968 acc_bclr += bot_bclr * wgtBR;
03969
03970 #ifdef DEBUG
03971 if (ipixel == trace_pixel_ptr) {
03972 trace_opcBR = bot_opc;
03973 trace_rclrBR = bot_rclr;
03974 trace_gclrBR = bot_gclr;
03975 trace_bclrBR = bot_bclr;
03976
03977 }
03978 #endif
03979 ;
03980
03981 COUNT_RESAMPLE;
03982 if (acc_opc > min_opacity) {
03983 COUNT_COMPOSITE;
03984 iopc = ipixel->opcflt;
03985 # ifndef SKIP_ERT
03986 ASSERT(iopc < max_opacity);
03987 # endif
03988 iopc_inv = (float)1. - iopc;
03989
03990 ipixel->rclrflt += acc_rclr * iopc_inv;
03991 ipixel->gclrflt += acc_gclr * iopc_inv;
03992 ipixel->bclrflt += acc_bclr * iopc_inv;
03993 iopc += acc_opc * iopc_inv;
03994 ipixel->opcflt = iopc;
03995
03996 #ifdef DEBUG
03997 if (ipixel == trace_pixel_ptr) {
03998 #ifdef COMPUTE_SHADOW_BUFFER
03999 printf("{%3d} %3d %3d", k, icount-i-count, j);
04000 #else
04001 printf("[%3d] %3d %3d", k, icount-i-count, j);
04002 #endif
04003 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04004 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04005 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04006 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04007 printf(" %3.0f %3.0f\n", iopc*255.,
04008 ipixel->rclrflt);
04009
04010
04011 printf(" ");
04012 printf(" %3.0f ",trace_gclrTL);
04013 printf(" %3.0f ",trace_gclrBL);
04014 printf(" %3.0f ",trace_gclrTR);
04015 printf(" %3.0f ",trace_gclrBR);
04016 printf(" %3.0f\n", ipixel->gclrflt);
04017 printf(" ");
04018 printf(" %3.0f ",trace_bclrTL);
04019 printf(" %3.0f ",trace_bclrBL);
04020 printf(" %3.0f ",trace_bclrTR);
04021 printf(" %3.0f ",trace_bclrBR);
04022 printf(" %3.0f\n", ipixel->bclrflt);
04023 }
04024 #endif
04025 ;
04026 # ifndef SKIP_ERT
04027 if (iopc >= max_opacity) {
04028 ASSERT(ipixel->lnk == 0);
04029 ipixel->lnk = 1;
04030 }
04031 # endif
04032 };
04033 ipixel += 1;
04034 ;
04035 botRLEdata += 1 * voxel_istride;
04036 count--;
04037 SET_VOXELS_LOADED;
04038 }
04039 break;
04040 case ALL_ZERO__ALL_NONZERO:
04041
04042
04043 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04044
04045
04046 shade_index=2*3*ShortField(topRLEdata,norm_offset);
04047 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
04048
04049
04050
04051 top_rclr =
04052 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04053
04054 top_gclr =
04055 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04056
04057 top_bclr =
04058 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04059 ;
04060 ;
04061 ;
04062
04063
04064 top_rclr +=
04065 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04066
04067 top_gclr +=
04068 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04069
04070 top_bclr +=
04071 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04072 ;
04073 ;
04074 ;
04075 shade_factor = top_opc * slice_depth_cueing;
04076
04077 top_rclr *= shade_factor;
04078 top_gclr *= shade_factor;
04079 top_bclr *= shade_factor;
04080 ;
04081
04082 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04083
04084
04085 shade_index=2*3*ShortField(botRLEdata,norm_offset);
04086 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
04087
04088
04089
04090 bot_rclr =
04091 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04092
04093 bot_gclr =
04094 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04095
04096 bot_bclr =
04097 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04098 ;
04099 ;
04100 ;
04101
04102
04103 bot_rclr +=
04104 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04105
04106 bot_gclr +=
04107 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04108
04109 bot_bclr +=
04110 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04111 ;
04112 ;
04113 ;
04114 shade_factor = bot_opc * slice_depth_cueing;
04115
04116 bot_rclr *= shade_factor;
04117 bot_gclr *= shade_factor;
04118 bot_bclr *= shade_factor;
04119 ;
04120
04121 #ifdef DEBUG
04122 if (ipixel == trace_pixel_ptr) {
04123 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04124 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04125 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04126 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04127 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04128 }
04129 #endif
04130 ;
04131
04132 acc_opc = top_opc * wgtTR;
04133
04134 acc_rclr = top_rclr * wgtTR;
04135 acc_gclr = top_gclr * wgtTR;
04136 acc_bclr = top_bclr * wgtTR;
04137
04138 #ifdef DEBUG
04139 if (ipixel == trace_pixel_ptr) {
04140 trace_opcTR = top_opc;
04141 trace_rclrTR = top_rclr;
04142 trace_gclrTR = top_gclr;
04143 trace_bclrTR = top_bclr;
04144
04145 }
04146 #endif
04147 ;
04148
04149 acc_opc += bot_opc * wgtBR;
04150
04151 acc_rclr += bot_rclr * wgtBR;
04152 acc_gclr += bot_gclr * wgtBR;
04153 acc_bclr += bot_bclr * wgtBR;
04154
04155 #ifdef DEBUG
04156 if (ipixel == trace_pixel_ptr) {
04157 trace_opcBR = bot_opc;
04158 trace_rclrBR = bot_rclr;
04159 trace_gclrBR = bot_gclr;
04160 trace_bclrBR = bot_bclr;
04161
04162 }
04163 #endif
04164 ;
04165
04166 COUNT_RESAMPLE;
04167 if (acc_opc > min_opacity) {
04168 COUNT_COMPOSITE;
04169 iopc = ipixel->opcflt;
04170 # ifndef SKIP_ERT
04171 ASSERT(iopc < max_opacity);
04172 # endif
04173 iopc_inv = (float)1. - iopc;
04174
04175 ipixel->rclrflt += acc_rclr * iopc_inv;
04176 ipixel->gclrflt += acc_gclr * iopc_inv;
04177 ipixel->bclrflt += acc_bclr * iopc_inv;
04178 iopc += acc_opc * iopc_inv;
04179 ipixel->opcflt = iopc;
04180
04181 #ifdef DEBUG
04182 if (ipixel == trace_pixel_ptr) {
04183 #ifdef COMPUTE_SHADOW_BUFFER
04184 printf("{%3d} %3d %3d", k, icount-i-count, j);
04185 #else
04186 printf("[%3d] %3d %3d", k, icount-i-count, j);
04187 #endif
04188 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04189 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04190 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04191 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04192 printf(" %3.0f %3.0f\n", iopc*255.,
04193 ipixel->rclrflt);
04194
04195
04196 printf(" ");
04197 printf(" %3.0f ",trace_gclrTL);
04198 printf(" %3.0f ",trace_gclrBL);
04199 printf(" %3.0f ",trace_gclrTR);
04200 printf(" %3.0f ",trace_gclrBR);
04201 printf(" %3.0f\n", ipixel->gclrflt);
04202 printf(" ");
04203 printf(" %3.0f ",trace_bclrTL);
04204 printf(" %3.0f ",trace_bclrBL);
04205 printf(" %3.0f ",trace_bclrTR);
04206 printf(" %3.0f ",trace_bclrBR);
04207 printf(" %3.0f\n", ipixel->bclrflt);
04208 }
04209 #endif
04210 ;
04211 # ifndef SKIP_ERT
04212 if (iopc >= max_opacity) {
04213 ASSERT(ipixel->lnk == 0);
04214 ipixel->lnk = 1;
04215 }
04216 # endif
04217 };
04218 ipixel += 1;
04219 topRLEdata += 1 * voxel_istride;
04220 botRLEdata += 1 * voxel_istride;
04221 count--;
04222 SET_VOXELS_LOADED;
04223
04224
04225
04226 while (count > 0) {
04227 if (PIXEL_IS_OPAQUE(ipixel))
04228 break;
04229 if (!voxels_loaded) {
04230
04231 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04232
04233
04234 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
04235 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
04236
04237
04238
04239 top_rclr =
04240 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04241
04242 top_gclr =
04243 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04244
04245 top_bclr =
04246 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04247 ;
04248 ;
04249 ;
04250
04251
04252 top_rclr +=
04253 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04254
04255 top_gclr +=
04256 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04257
04258 top_bclr +=
04259 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04260 ;
04261 ;
04262 ;
04263 shade_factor = top_opc * slice_depth_cueing;
04264
04265 top_rclr *= shade_factor;
04266 top_gclr *= shade_factor;
04267 top_bclr *= shade_factor;
04268 ;
04269
04270 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04271
04272
04273 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
04274 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
04275
04276
04277
04278 bot_rclr =
04279 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04280
04281 bot_gclr =
04282 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04283
04284 bot_bclr =
04285 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04286 ;
04287 ;
04288 ;
04289
04290
04291 bot_rclr +=
04292 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04293
04294 bot_gclr +=
04295 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04296
04297 bot_bclr +=
04298 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04299 ;
04300 ;
04301 ;
04302 shade_factor = bot_opc * slice_depth_cueing;
04303
04304 bot_rclr *= shade_factor;
04305 bot_gclr *= shade_factor;
04306 bot_bclr *= shade_factor;
04307 ;
04308 }
04309
04310 #ifdef DEBUG
04311 if (ipixel == trace_pixel_ptr) {
04312 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04313 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04314 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04315 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04316 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04317 }
04318 #endif
04319 ;
04320
04321 acc_opc = top_opc * wgtTL;
04322
04323 acc_rclr = top_rclr * wgtTL;
04324 acc_gclr = top_gclr * wgtTL;
04325 acc_bclr = top_bclr * wgtTL;
04326
04327 #ifdef DEBUG
04328 if (ipixel == trace_pixel_ptr) {
04329 trace_opcTL = top_opc;
04330 trace_rclrTL = top_rclr;
04331 trace_gclrTL = top_gclr;
04332 trace_bclrTL = top_bclr;
04333
04334 }
04335 #endif
04336 ;
04337
04338 acc_opc += bot_opc * wgtBL;
04339
04340 acc_rclr += bot_rclr * wgtBL;
04341 acc_gclr += bot_gclr * wgtBL;
04342 acc_bclr += bot_bclr * wgtBL;
04343
04344 #ifdef DEBUG
04345 if (ipixel == trace_pixel_ptr) {
04346 trace_opcBL = bot_opc;
04347 trace_rclrBL = bot_rclr;
04348 trace_gclrBL = bot_gclr;
04349 trace_bclrBL = bot_bclr;
04350
04351 }
04352 #endif
04353 ;
04354
04355 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04356
04357
04358 shade_index=2*3*ShortField(topRLEdata,norm_offset);
04359 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
04360
04361
04362
04363 top_rclr =
04364 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04365
04366 top_gclr =
04367 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04368
04369 top_bclr =
04370 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04371 ;
04372 ;
04373 ;
04374
04375
04376 top_rclr +=
04377 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04378
04379 top_gclr +=
04380 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04381
04382 top_bclr +=
04383 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04384 ;
04385 ;
04386 ;
04387 shade_factor = top_opc * slice_depth_cueing;
04388
04389 top_rclr *= shade_factor;
04390 top_gclr *= shade_factor;
04391 top_bclr *= shade_factor;
04392 ;
04393
04394 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04395
04396
04397 shade_index=2*3*ShortField(botRLEdata,norm_offset);
04398 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
04399
04400
04401
04402 bot_rclr =
04403 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04404
04405 bot_gclr =
04406 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04407
04408 bot_bclr =
04409 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04410 ;
04411 ;
04412 ;
04413
04414
04415 bot_rclr +=
04416 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04417
04418 bot_gclr +=
04419 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04420
04421 bot_bclr +=
04422 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04423 ;
04424 ;
04425 ;
04426 shade_factor = bot_opc * slice_depth_cueing;
04427
04428 bot_rclr *= shade_factor;
04429 bot_gclr *= shade_factor;
04430 bot_bclr *= shade_factor;
04431 ;
04432
04433 acc_opc += top_opc * wgtTR;
04434
04435 acc_rclr += top_rclr * wgtTR;
04436 acc_gclr += top_gclr * wgtTR;
04437 acc_bclr += top_bclr * wgtTR;
04438
04439 #ifdef DEBUG
04440 if (ipixel == trace_pixel_ptr) {
04441 trace_opcTR = top_opc;
04442 trace_rclrTR = top_rclr;
04443 trace_gclrTR = top_gclr;
04444 trace_bclrTR = top_bclr;
04445
04446 }
04447 #endif
04448 ;
04449
04450 acc_opc += bot_opc * wgtBR;
04451
04452 acc_rclr += bot_rclr * wgtBR;
04453 acc_gclr += bot_gclr * wgtBR;
04454 acc_bclr += bot_bclr * wgtBR;
04455
04456 #ifdef DEBUG
04457 if (ipixel == trace_pixel_ptr) {
04458 trace_opcBR = bot_opc;
04459 trace_rclrBR = bot_rclr;
04460 trace_gclrBR = bot_gclr;
04461 trace_bclrBR = bot_bclr;
04462
04463 }
04464 #endif
04465 ;
04466
04467 COUNT_RESAMPLE;
04468 if (acc_opc > min_opacity) {
04469 COUNT_COMPOSITE;
04470 iopc = ipixel->opcflt;
04471 # ifndef SKIP_ERT
04472 ASSERT(iopc < max_opacity);
04473 # endif
04474 iopc_inv = (float)1. - iopc;
04475
04476 ipixel->rclrflt += acc_rclr * iopc_inv;
04477 ipixel->gclrflt += acc_gclr * iopc_inv;
04478 ipixel->bclrflt += acc_bclr * iopc_inv;
04479 iopc += acc_opc * iopc_inv;
04480 ipixel->opcflt = iopc;
04481
04482 #ifdef DEBUG
04483 if (ipixel == trace_pixel_ptr) {
04484 #ifdef COMPUTE_SHADOW_BUFFER
04485 printf("{%3d} %3d %3d", k, icount-i-count, j);
04486 #else
04487 printf("[%3d] %3d %3d", k, icount-i-count, j);
04488 #endif
04489 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04490 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04491 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04492 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04493 printf(" %3.0f %3.0f\n", iopc*255.,
04494 ipixel->rclrflt);
04495
04496
04497 printf(" ");
04498 printf(" %3.0f ",trace_gclrTL);
04499 printf(" %3.0f ",trace_gclrBL);
04500 printf(" %3.0f ",trace_gclrTR);
04501 printf(" %3.0f ",trace_gclrBR);
04502 printf(" %3.0f\n", ipixel->gclrflt);
04503 printf(" ");
04504 printf(" %3.0f ",trace_bclrTL);
04505 printf(" %3.0f ",trace_bclrBL);
04506 printf(" %3.0f ",trace_bclrTR);
04507 printf(" %3.0f ",trace_bclrBR);
04508 printf(" %3.0f\n", ipixel->bclrflt);
04509 }
04510 #endif
04511 ;
04512 # ifndef SKIP_ERT
04513 if (iopc >= max_opacity) {
04514 ASSERT(ipixel->lnk == 0);
04515 ipixel->lnk = 1;
04516 }
04517 # endif
04518 };
04519 ipixel += 1;
04520 topRLEdata += 1 * voxel_istride;
04521 botRLEdata += 1 * voxel_istride;
04522 count--;
04523 SET_VOXELS_LOADED;
04524 }
04525 break;
04526 case TOP_NONZERO__ALL_NONZERO:
04527
04528
04529 if (!voxels_loaded) {
04530
04531 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04532
04533
04534 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
04535 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
04536
04537
04538
04539 top_rclr =
04540 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04541
04542 top_gclr =
04543 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04544
04545 top_bclr =
04546 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04547 ;
04548 ;
04549 ;
04550
04551
04552 top_rclr +=
04553 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04554
04555 top_gclr +=
04556 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04557
04558 top_bclr +=
04559 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04560 ;
04561 ;
04562 ;
04563 shade_factor = top_opc * slice_depth_cueing;
04564
04565 top_rclr *= shade_factor;
04566 top_gclr *= shade_factor;
04567 top_bclr *= shade_factor;
04568 ;
04569 }
04570
04571 #ifdef DEBUG
04572 if (ipixel == trace_pixel_ptr) {
04573 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04574 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04575 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04576 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04577 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04578 }
04579 #endif
04580 ;
04581
04582 acc_opc = top_opc * wgtTL;
04583
04584 acc_rclr = top_rclr * wgtTL;
04585 acc_gclr = top_gclr * wgtTL;
04586 acc_bclr = top_bclr * wgtTL;
04587
04588 #ifdef DEBUG
04589 if (ipixel == trace_pixel_ptr) {
04590 trace_opcTL = top_opc;
04591 trace_rclrTL = top_rclr;
04592 trace_gclrTL = top_gclr;
04593 trace_bclrTL = top_bclr;
04594
04595 }
04596 #endif
04597 ;
04598
04599 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04600
04601
04602 shade_index=2*3*ShortField(topRLEdata,norm_offset);
04603 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
04604
04605
04606
04607 top_rclr =
04608 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04609
04610 top_gclr =
04611 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04612
04613 top_bclr =
04614 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04615 ;
04616 ;
04617 ;
04618
04619
04620 top_rclr +=
04621 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04622
04623 top_gclr +=
04624 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04625
04626 top_bclr +=
04627 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04628 ;
04629 ;
04630 ;
04631 shade_factor = top_opc * slice_depth_cueing;
04632
04633 top_rclr *= shade_factor;
04634 top_gclr *= shade_factor;
04635 top_bclr *= shade_factor;
04636 ;
04637
04638 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04639
04640
04641 shade_index=2*3*ShortField(botRLEdata,norm_offset);
04642 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
04643
04644
04645
04646 bot_rclr =
04647 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04648
04649 bot_gclr =
04650 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04651
04652 bot_bclr =
04653 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04654 ;
04655 ;
04656 ;
04657
04658
04659 bot_rclr +=
04660 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04661
04662 bot_gclr +=
04663 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04664
04665 bot_bclr +=
04666 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04667 ;
04668 ;
04669 ;
04670 shade_factor = bot_opc * slice_depth_cueing;
04671
04672 bot_rclr *= shade_factor;
04673 bot_gclr *= shade_factor;
04674 bot_bclr *= shade_factor;
04675 ;
04676
04677 acc_opc += top_opc * wgtTR;
04678
04679 acc_rclr += top_rclr * wgtTR;
04680 acc_gclr += top_gclr * wgtTR;
04681 acc_bclr += top_bclr * wgtTR;
04682
04683 #ifdef DEBUG
04684 if (ipixel == trace_pixel_ptr) {
04685 trace_opcTR = top_opc;
04686 trace_rclrTR = top_rclr;
04687 trace_gclrTR = top_gclr;
04688 trace_bclrTR = top_bclr;
04689
04690 }
04691 #endif
04692 ;
04693
04694 acc_opc += bot_opc * wgtBR;
04695
04696 acc_rclr += bot_rclr * wgtBR;
04697 acc_gclr += bot_gclr * wgtBR;
04698 acc_bclr += bot_bclr * wgtBR;
04699
04700 #ifdef DEBUG
04701 if (ipixel == trace_pixel_ptr) {
04702 trace_opcBR = bot_opc;
04703 trace_rclrBR = bot_rclr;
04704 trace_gclrBR = bot_gclr;
04705 trace_bclrBR = bot_bclr;
04706
04707 }
04708 #endif
04709 ;
04710
04711 COUNT_RESAMPLE;
04712 if (acc_opc > min_opacity) {
04713 COUNT_COMPOSITE;
04714 iopc = ipixel->opcflt;
04715 # ifndef SKIP_ERT
04716 ASSERT(iopc < max_opacity);
04717 # endif
04718 iopc_inv = (float)1. - iopc;
04719
04720 ipixel->rclrflt += acc_rclr * iopc_inv;
04721 ipixel->gclrflt += acc_gclr * iopc_inv;
04722 ipixel->bclrflt += acc_bclr * iopc_inv;
04723 iopc += acc_opc * iopc_inv;
04724 ipixel->opcflt = iopc;
04725
04726 #ifdef DEBUG
04727 if (ipixel == trace_pixel_ptr) {
04728 #ifdef COMPUTE_SHADOW_BUFFER
04729 printf("{%3d} %3d %3d", k, icount-i-count, j);
04730 #else
04731 printf("[%3d] %3d %3d", k, icount-i-count, j);
04732 #endif
04733 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
04734 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
04735 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
04736 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
04737 printf(" %3.0f %3.0f\n", iopc*255.,
04738 ipixel->rclrflt);
04739
04740
04741 printf(" ");
04742 printf(" %3.0f ",trace_gclrTL);
04743 printf(" %3.0f ",trace_gclrBL);
04744 printf(" %3.0f ",trace_gclrTR);
04745 printf(" %3.0f ",trace_gclrBR);
04746 printf(" %3.0f\n", ipixel->gclrflt);
04747 printf(" ");
04748 printf(" %3.0f ",trace_bclrTL);
04749 printf(" %3.0f ",trace_bclrBL);
04750 printf(" %3.0f ",trace_bclrTR);
04751 printf(" %3.0f ",trace_bclrBR);
04752 printf(" %3.0f\n", ipixel->bclrflt);
04753 }
04754 #endif
04755 ;
04756 # ifndef SKIP_ERT
04757 if (iopc >= max_opacity) {
04758 ASSERT(ipixel->lnk == 0);
04759 ipixel->lnk = 1;
04760 }
04761 # endif
04762 };
04763 ipixel += 1;
04764 topRLEdata += 1 * voxel_istride;
04765 botRLEdata += 1 * voxel_istride;
04766 count--;
04767 SET_VOXELS_LOADED;
04768
04769
04770
04771 while (count > 0) {
04772 if (PIXEL_IS_OPAQUE(ipixel))
04773 break;
04774 if (!voxels_loaded) {
04775
04776 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
04777
04778
04779 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
04780 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
04781
04782
04783
04784 top_rclr =
04785 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04786
04787 top_gclr =
04788 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04789
04790 top_bclr =
04791 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04792 ;
04793 ;
04794 ;
04795
04796
04797 top_rclr +=
04798 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04799
04800 top_gclr +=
04801 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04802
04803 top_bclr +=
04804 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04805 ;
04806 ;
04807 ;
04808 shade_factor = top_opc * slice_depth_cueing;
04809
04810 top_rclr *= shade_factor;
04811 top_gclr *= shade_factor;
04812 top_bclr *= shade_factor;
04813 ;
04814
04815 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
04816
04817
04818 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
04819 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
04820
04821
04822
04823 bot_rclr =
04824 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04825
04826 bot_gclr =
04827 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04828
04829 bot_bclr =
04830 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04831 ;
04832 ;
04833 ;
04834
04835
04836 bot_rclr +=
04837 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04838
04839 bot_gclr +=
04840 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04841
04842 bot_bclr +=
04843 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04844 ;
04845 ;
04846 ;
04847 shade_factor = bot_opc * slice_depth_cueing;
04848
04849 bot_rclr *= shade_factor;
04850 bot_gclr *= shade_factor;
04851 bot_bclr *= shade_factor;
04852 ;
04853 }
04854
04855 #ifdef DEBUG
04856 if (ipixel == trace_pixel_ptr) {
04857 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
04858 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
04859 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
04860 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
04861 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
04862 }
04863 #endif
04864 ;
04865
04866 acc_opc = top_opc * wgtTL;
04867
04868 acc_rclr = top_rclr * wgtTL;
04869 acc_gclr = top_gclr * wgtTL;
04870 acc_bclr = top_bclr * wgtTL;
04871
04872 #ifdef DEBUG
04873 if (ipixel == trace_pixel_ptr) {
04874 trace_opcTL = top_opc;
04875 trace_rclrTL = top_rclr;
04876 trace_gclrTL = top_gclr;
04877 trace_bclrTL = top_bclr;
04878
04879 }
04880 #endif
04881 ;
04882
04883 acc_opc += bot_opc * wgtBL;
04884
04885 acc_rclr += bot_rclr * wgtBL;
04886 acc_gclr += bot_gclr * wgtBL;
04887 acc_bclr += bot_bclr * wgtBL;
04888
04889 #ifdef DEBUG
04890 if (ipixel == trace_pixel_ptr) {
04891 trace_opcBL = bot_opc;
04892 trace_rclrBL = bot_rclr;
04893 trace_gclrBL = bot_gclr;
04894 trace_bclrBL = bot_bclr;
04895
04896 }
04897 #endif
04898 ;
04899
04900 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
04901
04902
04903 shade_index=2*3*ShortField(topRLEdata,norm_offset);
04904 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
04905
04906
04907
04908 top_rclr =
04909 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04910
04911 top_gclr =
04912 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04913
04914 top_bclr =
04915 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04916 ;
04917 ;
04918 ;
04919
04920
04921 top_rclr +=
04922 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04923
04924 top_gclr +=
04925 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04926
04927 top_bclr +=
04928 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04929 ;
04930 ;
04931 ;
04932 shade_factor = top_opc * slice_depth_cueing;
04933
04934 top_rclr *= shade_factor;
04935 top_gclr *= shade_factor;
04936 top_bclr *= shade_factor;
04937 ;
04938
04939 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
04940
04941
04942 shade_index=2*3*ShortField(botRLEdata,norm_offset);
04943 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
04944
04945
04946
04947 bot_rclr =
04948 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
04949
04950 bot_gclr =
04951 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
04952
04953 bot_bclr =
04954 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
04955 ;
04956 ;
04957 ;
04958
04959
04960 bot_rclr +=
04961 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
04962
04963 bot_gclr +=
04964 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
04965
04966 bot_bclr +=
04967 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
04968 ;
04969 ;
04970 ;
04971 shade_factor = bot_opc * slice_depth_cueing;
04972
04973 bot_rclr *= shade_factor;
04974 bot_gclr *= shade_factor;
04975 bot_bclr *= shade_factor;
04976 ;
04977
04978 acc_opc += top_opc * wgtTR;
04979
04980 acc_rclr += top_rclr * wgtTR;
04981 acc_gclr += top_gclr * wgtTR;
04982 acc_bclr += top_bclr * wgtTR;
04983
04984 #ifdef DEBUG
04985 if (ipixel == trace_pixel_ptr) {
04986 trace_opcTR = top_opc;
04987 trace_rclrTR = top_rclr;
04988 trace_gclrTR = top_gclr;
04989 trace_bclrTR = top_bclr;
04990
04991 }
04992 #endif
04993 ;
04994
04995 acc_opc += bot_opc * wgtBR;
04996
04997 acc_rclr += bot_rclr * wgtBR;
04998 acc_gclr += bot_gclr * wgtBR;
04999 acc_bclr += bot_bclr * wgtBR;
05000
05001 #ifdef DEBUG
05002 if (ipixel == trace_pixel_ptr) {
05003 trace_opcBR = bot_opc;
05004 trace_rclrBR = bot_rclr;
05005 trace_gclrBR = bot_gclr;
05006 trace_bclrBR = bot_bclr;
05007
05008 }
05009 #endif
05010 ;
05011
05012 COUNT_RESAMPLE;
05013 if (acc_opc > min_opacity) {
05014 COUNT_COMPOSITE;
05015 iopc = ipixel->opcflt;
05016 # ifndef SKIP_ERT
05017 ASSERT(iopc < max_opacity);
05018 # endif
05019 iopc_inv = (float)1. - iopc;
05020
05021 ipixel->rclrflt += acc_rclr * iopc_inv;
05022 ipixel->gclrflt += acc_gclr * iopc_inv;
05023 ipixel->bclrflt += acc_bclr * iopc_inv;
05024 iopc += acc_opc * iopc_inv;
05025 ipixel->opcflt = iopc;
05026
05027 #ifdef DEBUG
05028 if (ipixel == trace_pixel_ptr) {
05029 #ifdef COMPUTE_SHADOW_BUFFER
05030 printf("{%3d} %3d %3d", k, icount-i-count, j);
05031 #else
05032 printf("[%3d] %3d %3d", k, icount-i-count, j);
05033 #endif
05034 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05035 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05036 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05037 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05038 printf(" %3.0f %3.0f\n", iopc*255.,
05039 ipixel->rclrflt);
05040
05041
05042 printf(" ");
05043 printf(" %3.0f ",trace_gclrTL);
05044 printf(" %3.0f ",trace_gclrBL);
05045 printf(" %3.0f ",trace_gclrTR);
05046 printf(" %3.0f ",trace_gclrBR);
05047 printf(" %3.0f\n", ipixel->gclrflt);
05048 printf(" ");
05049 printf(" %3.0f ",trace_bclrTL);
05050 printf(" %3.0f ",trace_bclrBL);
05051 printf(" %3.0f ",trace_bclrTR);
05052 printf(" %3.0f ",trace_bclrBR);
05053 printf(" %3.0f\n", ipixel->bclrflt);
05054 }
05055 #endif
05056 ;
05057 # ifndef SKIP_ERT
05058 if (iopc >= max_opacity) {
05059 ASSERT(ipixel->lnk == 0);
05060 ipixel->lnk = 1;
05061 }
05062 # endif
05063 };
05064 ipixel += 1;
05065 topRLEdata += 1 * voxel_istride;
05066 botRLEdata += 1 * voxel_istride;
05067 count--;
05068 SET_VOXELS_LOADED;
05069 }
05070 break;
05071 case BOT_NONZERO__ALL_NONZERO:
05072
05073
05074 if (!voxels_loaded) {
05075
05076 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
05077
05078
05079 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
05080 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
05081
05082
05083
05084 bot_rclr =
05085 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05086
05087 bot_gclr =
05088 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05089
05090 bot_bclr =
05091 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05092 ;
05093 ;
05094 ;
05095
05096
05097 bot_rclr +=
05098 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05099
05100 bot_gclr +=
05101 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05102
05103 bot_bclr +=
05104 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05105 ;
05106 ;
05107 ;
05108 shade_factor = bot_opc * slice_depth_cueing;
05109
05110 bot_rclr *= shade_factor;
05111 bot_gclr *= shade_factor;
05112 bot_bclr *= shade_factor;
05113 ;
05114 }
05115
05116 #ifdef DEBUG
05117 if (ipixel == trace_pixel_ptr) {
05118 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05119 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05120 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05121 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05122 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05123 }
05124 #endif
05125 ;
05126
05127 acc_opc = bot_opc * wgtBL;
05128
05129 acc_rclr = bot_rclr * wgtBL;
05130 acc_gclr = bot_gclr * wgtBL;
05131 acc_bclr = bot_bclr * wgtBL;
05132
05133 #ifdef DEBUG
05134 if (ipixel == trace_pixel_ptr) {
05135 trace_opcBL = bot_opc;
05136 trace_rclrBL = bot_rclr;
05137 trace_gclrBL = bot_gclr;
05138 trace_bclrBL = bot_bclr;
05139
05140 }
05141 #endif
05142 ;
05143
05144 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
05145
05146
05147 shade_index=2*3*ShortField(topRLEdata,norm_offset);
05148 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
05149
05150
05151
05152 top_rclr =
05153 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05154
05155 top_gclr =
05156 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05157
05158 top_bclr =
05159 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05160 ;
05161 ;
05162 ;
05163
05164
05165 top_rclr +=
05166 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05167
05168 top_gclr +=
05169 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05170
05171 top_bclr +=
05172 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05173 ;
05174 ;
05175 ;
05176 shade_factor = top_opc * slice_depth_cueing;
05177
05178 top_rclr *= shade_factor;
05179 top_gclr *= shade_factor;
05180 top_bclr *= shade_factor;
05181 ;
05182
05183 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
05184
05185
05186 shade_index=2*3*ShortField(botRLEdata,norm_offset);
05187 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
05188
05189
05190
05191 bot_rclr =
05192 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05193
05194 bot_gclr =
05195 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05196
05197 bot_bclr =
05198 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05199 ;
05200 ;
05201 ;
05202
05203
05204 bot_rclr +=
05205 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05206
05207 bot_gclr +=
05208 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05209
05210 bot_bclr +=
05211 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05212 ;
05213 ;
05214 ;
05215 shade_factor = bot_opc * slice_depth_cueing;
05216
05217 bot_rclr *= shade_factor;
05218 bot_gclr *= shade_factor;
05219 bot_bclr *= shade_factor;
05220 ;
05221
05222 acc_opc += top_opc * wgtTR;
05223
05224 acc_rclr += top_rclr * wgtTR;
05225 acc_gclr += top_gclr * wgtTR;
05226 acc_bclr += top_bclr * wgtTR;
05227
05228 #ifdef DEBUG
05229 if (ipixel == trace_pixel_ptr) {
05230 trace_opcTR = top_opc;
05231 trace_rclrTR = top_rclr;
05232 trace_gclrTR = top_gclr;
05233 trace_bclrTR = top_bclr;
05234
05235 }
05236 #endif
05237 ;
05238
05239 acc_opc += bot_opc * wgtBR;
05240
05241 acc_rclr += bot_rclr * wgtBR;
05242 acc_gclr += bot_gclr * wgtBR;
05243 acc_bclr += bot_bclr * wgtBR;
05244
05245 #ifdef DEBUG
05246 if (ipixel == trace_pixel_ptr) {
05247 trace_opcBR = bot_opc;
05248 trace_rclrBR = bot_rclr;
05249 trace_gclrBR = bot_gclr;
05250 trace_bclrBR = bot_bclr;
05251
05252 }
05253 #endif
05254 ;
05255
05256 COUNT_RESAMPLE;
05257 if (acc_opc > min_opacity) {
05258 COUNT_COMPOSITE;
05259 iopc = ipixel->opcflt;
05260 # ifndef SKIP_ERT
05261 ASSERT(iopc < max_opacity);
05262 # endif
05263 iopc_inv = (float)1. - iopc;
05264
05265 ipixel->rclrflt += acc_rclr * iopc_inv;
05266 ipixel->gclrflt += acc_gclr * iopc_inv;
05267 ipixel->bclrflt += acc_bclr * iopc_inv;
05268 iopc += acc_opc * iopc_inv;
05269 ipixel->opcflt = iopc;
05270
05271 #ifdef DEBUG
05272 if (ipixel == trace_pixel_ptr) {
05273 #ifdef COMPUTE_SHADOW_BUFFER
05274 printf("{%3d} %3d %3d", k, icount-i-count, j);
05275 #else
05276 printf("[%3d] %3d %3d", k, icount-i-count, j);
05277 #endif
05278 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05279 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05280 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05281 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05282 printf(" %3.0f %3.0f\n", iopc*255.,
05283 ipixel->rclrflt);
05284
05285
05286 printf(" ");
05287 printf(" %3.0f ",trace_gclrTL);
05288 printf(" %3.0f ",trace_gclrBL);
05289 printf(" %3.0f ",trace_gclrTR);
05290 printf(" %3.0f ",trace_gclrBR);
05291 printf(" %3.0f\n", ipixel->gclrflt);
05292 printf(" ");
05293 printf(" %3.0f ",trace_bclrTL);
05294 printf(" %3.0f ",trace_bclrBL);
05295 printf(" %3.0f ",trace_bclrTR);
05296 printf(" %3.0f ",trace_bclrBR);
05297 printf(" %3.0f\n", ipixel->bclrflt);
05298 }
05299 #endif
05300 ;
05301 # ifndef SKIP_ERT
05302 if (iopc >= max_opacity) {
05303 ASSERT(ipixel->lnk == 0);
05304 ipixel->lnk = 1;
05305 }
05306 # endif
05307 };
05308 ipixel += 1;
05309 topRLEdata += 1 * voxel_istride;
05310 botRLEdata += 1 * voxel_istride;
05311 count--;
05312 SET_VOXELS_LOADED;
05313
05314
05315
05316 while (count > 0) {
05317 if (PIXEL_IS_OPAQUE(ipixel))
05318 break;
05319 if (!voxels_loaded) {
05320
05321 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
05322
05323
05324 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
05325 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
05326
05327
05328
05329 top_rclr =
05330 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05331
05332 top_gclr =
05333 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05334
05335 top_bclr =
05336 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05337 ;
05338 ;
05339 ;
05340
05341
05342 top_rclr +=
05343 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05344
05345 top_gclr +=
05346 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05347
05348 top_bclr +=
05349 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05350 ;
05351 ;
05352 ;
05353 shade_factor = top_opc * slice_depth_cueing;
05354
05355 top_rclr *= shade_factor;
05356 top_gclr *= shade_factor;
05357 top_bclr *= shade_factor;
05358 ;
05359
05360 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
05361
05362
05363 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
05364 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
05365
05366
05367
05368 bot_rclr =
05369 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05370
05371 bot_gclr =
05372 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05373
05374 bot_bclr =
05375 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05376 ;
05377 ;
05378 ;
05379
05380
05381 bot_rclr +=
05382 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05383
05384 bot_gclr +=
05385 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05386
05387 bot_bclr +=
05388 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05389 ;
05390 ;
05391 ;
05392 shade_factor = bot_opc * slice_depth_cueing;
05393
05394 bot_rclr *= shade_factor;
05395 bot_gclr *= shade_factor;
05396 bot_bclr *= shade_factor;
05397 ;
05398 }
05399
05400 #ifdef DEBUG
05401 if (ipixel == trace_pixel_ptr) {
05402 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05403 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05404 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05405 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05406 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05407 }
05408 #endif
05409 ;
05410
05411 acc_opc = top_opc * wgtTL;
05412
05413 acc_rclr = top_rclr * wgtTL;
05414 acc_gclr = top_gclr * wgtTL;
05415 acc_bclr = top_bclr * wgtTL;
05416
05417 #ifdef DEBUG
05418 if (ipixel == trace_pixel_ptr) {
05419 trace_opcTL = top_opc;
05420 trace_rclrTL = top_rclr;
05421 trace_gclrTL = top_gclr;
05422 trace_bclrTL = top_bclr;
05423
05424 }
05425 #endif
05426 ;
05427
05428 acc_opc += bot_opc * wgtBL;
05429
05430 acc_rclr += bot_rclr * wgtBL;
05431 acc_gclr += bot_gclr * wgtBL;
05432 acc_bclr += bot_bclr * wgtBL;
05433
05434 #ifdef DEBUG
05435 if (ipixel == trace_pixel_ptr) {
05436 trace_opcBL = bot_opc;
05437 trace_rclrBL = bot_rclr;
05438 trace_gclrBL = bot_gclr;
05439 trace_bclrBL = bot_bclr;
05440
05441 }
05442 #endif
05443 ;
05444
05445 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
05446
05447
05448 shade_index=2*3*ShortField(topRLEdata,norm_offset);
05449 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
05450
05451
05452
05453 top_rclr =
05454 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05455
05456 top_gclr =
05457 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05458
05459 top_bclr =
05460 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05461 ;
05462 ;
05463 ;
05464
05465
05466 top_rclr +=
05467 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05468
05469 top_gclr +=
05470 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05471
05472 top_bclr +=
05473 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05474 ;
05475 ;
05476 ;
05477 shade_factor = top_opc * slice_depth_cueing;
05478
05479 top_rclr *= shade_factor;
05480 top_gclr *= shade_factor;
05481 top_bclr *= shade_factor;
05482 ;
05483
05484 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
05485
05486
05487 shade_index=2*3*ShortField(botRLEdata,norm_offset);
05488 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
05489
05490
05491
05492 bot_rclr =
05493 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05494
05495 bot_gclr =
05496 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05497
05498 bot_bclr =
05499 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05500 ;
05501 ;
05502 ;
05503
05504
05505 bot_rclr +=
05506 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05507
05508 bot_gclr +=
05509 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05510
05511 bot_bclr +=
05512 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05513 ;
05514 ;
05515 ;
05516 shade_factor = bot_opc * slice_depth_cueing;
05517
05518 bot_rclr *= shade_factor;
05519 bot_gclr *= shade_factor;
05520 bot_bclr *= shade_factor;
05521 ;
05522
05523 acc_opc += top_opc * wgtTR;
05524
05525 acc_rclr += top_rclr * wgtTR;
05526 acc_gclr += top_gclr * wgtTR;
05527 acc_bclr += top_bclr * wgtTR;
05528
05529 #ifdef DEBUG
05530 if (ipixel == trace_pixel_ptr) {
05531 trace_opcTR = top_opc;
05532 trace_rclrTR = top_rclr;
05533 trace_gclrTR = top_gclr;
05534 trace_bclrTR = top_bclr;
05535
05536 }
05537 #endif
05538 ;
05539
05540 acc_opc += bot_opc * wgtBR;
05541
05542 acc_rclr += bot_rclr * wgtBR;
05543 acc_gclr += bot_gclr * wgtBR;
05544 acc_bclr += bot_bclr * wgtBR;
05545
05546 #ifdef DEBUG
05547 if (ipixel == trace_pixel_ptr) {
05548 trace_opcBR = bot_opc;
05549 trace_rclrBR = bot_rclr;
05550 trace_gclrBR = bot_gclr;
05551 trace_bclrBR = bot_bclr;
05552
05553 }
05554 #endif
05555 ;
05556
05557 COUNT_RESAMPLE;
05558 if (acc_opc > min_opacity) {
05559 COUNT_COMPOSITE;
05560 iopc = ipixel->opcflt;
05561 # ifndef SKIP_ERT
05562 ASSERT(iopc < max_opacity);
05563 # endif
05564 iopc_inv = (float)1. - iopc;
05565
05566 ipixel->rclrflt += acc_rclr * iopc_inv;
05567 ipixel->gclrflt += acc_gclr * iopc_inv;
05568 ipixel->bclrflt += acc_bclr * iopc_inv;
05569 iopc += acc_opc * iopc_inv;
05570 ipixel->opcflt = iopc;
05571
05572 #ifdef DEBUG
05573 if (ipixel == trace_pixel_ptr) {
05574 #ifdef COMPUTE_SHADOW_BUFFER
05575 printf("{%3d} %3d %3d", k, icount-i-count, j);
05576 #else
05577 printf("[%3d] %3d %3d", k, icount-i-count, j);
05578 #endif
05579 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05580 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05581 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05582 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05583 printf(" %3.0f %3.0f\n", iopc*255.,
05584 ipixel->rclrflt);
05585
05586
05587 printf(" ");
05588 printf(" %3.0f ",trace_gclrTL);
05589 printf(" %3.0f ",trace_gclrBL);
05590 printf(" %3.0f ",trace_gclrTR);
05591 printf(" %3.0f ",trace_gclrBR);
05592 printf(" %3.0f\n", ipixel->gclrflt);
05593 printf(" ");
05594 printf(" %3.0f ",trace_bclrTL);
05595 printf(" %3.0f ",trace_bclrBL);
05596 printf(" %3.0f ",trace_bclrTR);
05597 printf(" %3.0f ",trace_bclrBR);
05598 printf(" %3.0f\n", ipixel->bclrflt);
05599 }
05600 #endif
05601 ;
05602 # ifndef SKIP_ERT
05603 if (iopc >= max_opacity) {
05604 ASSERT(ipixel->lnk == 0);
05605 ipixel->lnk = 1;
05606 }
05607 # endif
05608 };
05609 ipixel += 1;
05610 topRLEdata += 1 * voxel_istride;
05611 botRLEdata += 1 * voxel_istride;
05612 count--;
05613 SET_VOXELS_LOADED;
05614 }
05615 break;
05616 case ALL_NONZERO__ALL_NONZERO:
05617
05618 while (count > 0) {
05619 if (PIXEL_IS_OPAQUE(ipixel))
05620 break;
05621 if (!voxels_loaded) {
05622
05623 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
05624
05625
05626 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
05627 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
05628
05629
05630
05631 top_rclr =
05632 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05633
05634 top_gclr =
05635 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05636
05637 top_bclr =
05638 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05639 ;
05640 ;
05641 ;
05642
05643
05644 top_rclr +=
05645 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05646
05647 top_gclr +=
05648 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05649
05650 top_bclr +=
05651 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05652 ;
05653 ;
05654 ;
05655 shade_factor = top_opc * slice_depth_cueing;
05656
05657 top_rclr *= shade_factor;
05658 top_gclr *= shade_factor;
05659 top_bclr *= shade_factor;
05660 ;
05661
05662 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
05663
05664
05665 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
05666 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
05667
05668
05669
05670 bot_rclr =
05671 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05672
05673 bot_gclr =
05674 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05675
05676 bot_bclr =
05677 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05678 ;
05679 ;
05680 ;
05681
05682
05683 bot_rclr +=
05684 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05685
05686 bot_gclr +=
05687 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05688
05689 bot_bclr +=
05690 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05691 ;
05692 ;
05693 ;
05694 shade_factor = bot_opc * slice_depth_cueing;
05695
05696 bot_rclr *= shade_factor;
05697 bot_gclr *= shade_factor;
05698 bot_bclr *= shade_factor;
05699 ;
05700 }
05701
05702 #ifdef DEBUG
05703 if (ipixel == trace_pixel_ptr) {
05704 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05705 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05706 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05707 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05708 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05709 }
05710 #endif
05711 ;
05712
05713 acc_opc = top_opc * wgtTL;
05714
05715 acc_rclr = top_rclr * wgtTL;
05716 acc_gclr = top_gclr * wgtTL;
05717 acc_bclr = top_bclr * wgtTL;
05718
05719 #ifdef DEBUG
05720 if (ipixel == trace_pixel_ptr) {
05721 trace_opcTL = top_opc;
05722 trace_rclrTL = top_rclr;
05723 trace_gclrTL = top_gclr;
05724 trace_bclrTL = top_bclr;
05725
05726 }
05727 #endif
05728 ;
05729
05730 acc_opc += bot_opc * wgtBL;
05731
05732 acc_rclr += bot_rclr * wgtBL;
05733 acc_gclr += bot_gclr * wgtBL;
05734 acc_bclr += bot_bclr * wgtBL;
05735
05736 #ifdef DEBUG
05737 if (ipixel == trace_pixel_ptr) {
05738 trace_opcBL = bot_opc;
05739 trace_rclrBL = bot_rclr;
05740 trace_gclrBL = bot_gclr;
05741 trace_bclrBL = bot_bclr;
05742
05743 }
05744 #endif
05745 ;
05746
05747 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
05748
05749
05750 shade_index=2*3*ShortField(topRLEdata,norm_offset);
05751 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
05752
05753
05754
05755 top_rclr =
05756 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05757
05758 top_gclr =
05759 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05760
05761 top_bclr =
05762 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05763 ;
05764 ;
05765 ;
05766
05767
05768 top_rclr +=
05769 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05770
05771 top_gclr +=
05772 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05773
05774 top_bclr +=
05775 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05776 ;
05777 ;
05778 ;
05779 shade_factor = top_opc * slice_depth_cueing;
05780
05781 top_rclr *= shade_factor;
05782 top_gclr *= shade_factor;
05783 top_bclr *= shade_factor;
05784 ;
05785
05786 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
05787
05788
05789 shade_index=2*3*ShortField(botRLEdata,norm_offset);
05790 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
05791
05792
05793
05794 bot_rclr =
05795 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05796
05797 bot_gclr =
05798 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05799
05800 bot_bclr =
05801 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05802 ;
05803 ;
05804 ;
05805
05806
05807 bot_rclr +=
05808 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05809
05810 bot_gclr +=
05811 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05812
05813 bot_bclr +=
05814 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05815 ;
05816 ;
05817 ;
05818 shade_factor = bot_opc * slice_depth_cueing;
05819
05820 bot_rclr *= shade_factor;
05821 bot_gclr *= shade_factor;
05822 bot_bclr *= shade_factor;
05823 ;
05824
05825 acc_opc += top_opc * wgtTR;
05826
05827 acc_rclr += top_rclr * wgtTR;
05828 acc_gclr += top_gclr * wgtTR;
05829 acc_bclr += top_bclr * wgtTR;
05830
05831 #ifdef DEBUG
05832 if (ipixel == trace_pixel_ptr) {
05833 trace_opcTR = top_opc;
05834 trace_rclrTR = top_rclr;
05835 trace_gclrTR = top_gclr;
05836 trace_bclrTR = top_bclr;
05837
05838 }
05839 #endif
05840 ;
05841
05842 acc_opc += bot_opc * wgtBR;
05843
05844 acc_rclr += bot_rclr * wgtBR;
05845 acc_gclr += bot_gclr * wgtBR;
05846 acc_bclr += bot_bclr * wgtBR;
05847
05848 #ifdef DEBUG
05849 if (ipixel == trace_pixel_ptr) {
05850 trace_opcBR = bot_opc;
05851 trace_rclrBR = bot_rclr;
05852 trace_gclrBR = bot_gclr;
05853 trace_bclrBR = bot_bclr;
05854
05855 }
05856 #endif
05857 ;
05858
05859 COUNT_RESAMPLE;
05860 if (acc_opc > min_opacity) {
05861 COUNT_COMPOSITE;
05862 iopc = ipixel->opcflt;
05863 # ifndef SKIP_ERT
05864 ASSERT(iopc < max_opacity);
05865 # endif
05866 iopc_inv = (float)1. - iopc;
05867
05868 ipixel->rclrflt += acc_rclr * iopc_inv;
05869 ipixel->gclrflt += acc_gclr * iopc_inv;
05870 ipixel->bclrflt += acc_bclr * iopc_inv;
05871 iopc += acc_opc * iopc_inv;
05872 ipixel->opcflt = iopc;
05873
05874 #ifdef DEBUG
05875 if (ipixel == trace_pixel_ptr) {
05876 #ifdef COMPUTE_SHADOW_BUFFER
05877 printf("{%3d} %3d %3d", k, icount-i-count, j);
05878 #else
05879 printf("[%3d] %3d %3d", k, icount-i-count, j);
05880 #endif
05881 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
05882 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
05883 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
05884 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
05885 printf(" %3.0f %3.0f\n", iopc*255.,
05886 ipixel->rclrflt);
05887
05888
05889 printf(" ");
05890 printf(" %3.0f ",trace_gclrTL);
05891 printf(" %3.0f ",trace_gclrBL);
05892 printf(" %3.0f ",trace_gclrTR);
05893 printf(" %3.0f ",trace_gclrBR);
05894 printf(" %3.0f\n", ipixel->gclrflt);
05895 printf(" ");
05896 printf(" %3.0f ",trace_bclrTL);
05897 printf(" %3.0f ",trace_bclrBL);
05898 printf(" %3.0f ",trace_bclrTR);
05899 printf(" %3.0f ",trace_bclrBR);
05900 printf(" %3.0f\n", ipixel->bclrflt);
05901 }
05902 #endif
05903 ;
05904 # ifndef SKIP_ERT
05905 if (iopc >= max_opacity) {
05906 ASSERT(ipixel->lnk == 0);
05907 ipixel->lnk = 1;
05908 }
05909 # endif
05910 };
05911 ipixel += 1;
05912 topRLEdata += 1 * voxel_istride;
05913 botRLEdata += 1 * voxel_istride;
05914 count--;
05915 SET_VOXELS_LOADED;
05916 }
05917 break;
05918 default:
05919 VPBug("illegal value for run states in compositing loop");
05920 }
05921 #else
05922
05923 while (count > 0) {
05924 if (last_run_state == ALL_ZERO && run_state == ALL_ZERO) {
05925 ipixel += count;
05926 if (i != -1) {
05927 ;
05928 ;
05929 }
05930 count = 0;
05931 break;
05932 }
05933 if (ipixel->lnk != 0)
05934 break;
05935
05936 #ifdef DEBUG
05937 if (ipixel == trace_pixel_ptr) {
05938 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
05939 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
05940 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
05941 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
05942 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
05943 }
05944 #endif
05945 ;
05946
05947 acc_opc = 0;
05948 acc_rclr = acc_gclr = acc_bclr = 0;
05949 if (last_run_state & TOP_NONZERO) {
05950 if (!voxels_loaded) {
05951
05952 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
05953
05954
05955 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
05956 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
05957
05958
05959
05960 top_rclr =
05961 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
05962
05963 top_gclr =
05964 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
05965
05966 top_bclr =
05967 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
05968 ;
05969 ;
05970 ;
05971
05972
05973 top_rclr +=
05974 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
05975
05976 top_gclr +=
05977 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
05978
05979 top_bclr +=
05980 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
05981 ;
05982 ;
05983 ;
05984 shade_factor = top_opc * slice_depth_cueing;
05985
05986 top_rclr *= shade_factor;
05987 top_gclr *= shade_factor;
05988 top_bclr *= shade_factor;
05989 ;
05990 }
05991
05992 acc_opc += top_opc * wgtTL;
05993
05994 acc_rclr += top_rclr * wgtTL;
05995 acc_gclr += top_gclr * wgtTL;
05996 acc_bclr += top_bclr * wgtTL;
05997
05998 #ifdef DEBUG
05999 if (ipixel == trace_pixel_ptr) {
06000 trace_opcTL = top_opc;
06001 trace_rclrTL = top_rclr;
06002 trace_gclrTL = top_gclr;
06003 trace_bclrTL = top_bclr;
06004
06005 }
06006 #endif
06007 ;
06008 }
06009 if (last_run_state & BOT_NONZERO) {
06010 if (!voxels_loaded) {
06011
06012 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
06013
06014
06015 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
06016 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
06017
06018
06019
06020 bot_rclr =
06021 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
06022
06023 bot_gclr =
06024 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
06025
06026 bot_bclr =
06027 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
06028 ;
06029 ;
06030 ;
06031
06032
06033 bot_rclr +=
06034 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
06035
06036 bot_gclr +=
06037 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
06038
06039 bot_bclr +=
06040 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
06041 ;
06042 ;
06043 ;
06044 shade_factor = bot_opc * slice_depth_cueing;
06045
06046 bot_rclr *= shade_factor;
06047 bot_gclr *= shade_factor;
06048 bot_bclr *= shade_factor;
06049 ;
06050 }
06051
06052 acc_opc += bot_opc * wgtBL;
06053
06054 acc_rclr += bot_rclr * wgtBL;
06055 acc_gclr += bot_gclr * wgtBL;
06056 acc_bclr += bot_bclr * wgtBL;
06057
06058 #ifdef DEBUG
06059 if (ipixel == trace_pixel_ptr) {
06060 trace_opcBL = bot_opc;
06061 trace_rclrBL = bot_rclr;
06062 trace_gclrBL = bot_gclr;
06063 trace_bclrBL = bot_bclr;
06064
06065 }
06066 #endif
06067 ;
06068 }
06069 if (run_state & TOP_NONZERO) {
06070
06071 top_opc = opac_correct[ByteField(topRLEdata, voxel_istride-1)];
06072
06073
06074 shade_index=2*3*ShortField(topRLEdata,norm_offset);
06075 weight_index = 2 * ByteField(topRLEdata, wgt_offset);
06076
06077
06078
06079 top_rclr =
06080 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
06081
06082 top_gclr =
06083 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
06084
06085 top_bclr =
06086 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
06087 ;
06088 ;
06089 ;
06090
06091
06092 top_rclr +=
06093 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
06094
06095 top_gclr +=
06096 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
06097
06098 top_bclr +=
06099 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
06100 ;
06101 ;
06102 ;
06103 shade_factor = top_opc * slice_depth_cueing;
06104
06105 top_rclr *= shade_factor;
06106 top_gclr *= shade_factor;
06107 top_bclr *= shade_factor;
06108 ;
06109
06110 acc_opc += top_opc * wgtTR;
06111
06112 acc_rclr += top_rclr * wgtTR;
06113 acc_gclr += top_gclr * wgtTR;
06114 acc_bclr += top_bclr * wgtTR;
06115
06116 #ifdef DEBUG
06117 if (ipixel == trace_pixel_ptr) {
06118 trace_opcTR = top_opc;
06119 trace_rclrTR = top_rclr;
06120 trace_gclrTR = top_gclr;
06121 trace_bclrTR = top_bclr;
06122
06123 }
06124 #endif
06125 ;
06126 topRLEdata += 1 * voxel_istride;
06127 } else {
06128 if (i != -1) {
06129 ;
06130 }
06131 }
06132 if (run_state & BOT_NONZERO) {
06133
06134 bot_opc = opac_correct[ByteField(botRLEdata, voxel_istride-1)];
06135
06136
06137 shade_index=2*3*ShortField(botRLEdata,norm_offset);
06138 weight_index = 2 * ByteField(botRLEdata, wgt_offset);
06139
06140
06141
06142 bot_rclr =
06143 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
06144
06145 bot_gclr =
06146 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
06147
06148 bot_bclr =
06149 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
06150 ;
06151 ;
06152 ;
06153
06154
06155 bot_rclr +=
06156 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
06157
06158 bot_gclr +=
06159 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
06160
06161 bot_bclr +=
06162 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
06163 ;
06164 ;
06165 ;
06166 shade_factor = bot_opc * slice_depth_cueing;
06167
06168 bot_rclr *= shade_factor;
06169 bot_gclr *= shade_factor;
06170 bot_bclr *= shade_factor;
06171 ;
06172
06173 acc_opc += bot_opc * wgtBR;
06174
06175 acc_rclr += bot_rclr * wgtBR;
06176 acc_gclr += bot_gclr * wgtBR;
06177 acc_bclr += bot_bclr * wgtBR;
06178
06179 #ifdef DEBUG
06180 if (ipixel == trace_pixel_ptr) {
06181 trace_opcBR = bot_opc;
06182 trace_rclrBR = bot_rclr;
06183 trace_gclrBR = bot_gclr;
06184 trace_bclrBR = bot_bclr;
06185
06186 }
06187 #endif
06188 ;
06189 botRLEdata += 1 * voxel_istride;
06190 } else {
06191 if (i != -1) {
06192 ;
06193 }
06194 }
06195
06196 COUNT_RESAMPLE;
06197 if (acc_opc > min_opacity) {
06198 COUNT_COMPOSITE;
06199 iopc = ipixel->opcflt;
06200 # ifndef SKIP_ERT
06201 ASSERT(iopc < max_opacity);
06202 # endif
06203 iopc_inv = (float)1. - iopc;
06204
06205 ipixel->rclrflt += acc_rclr * iopc_inv;
06206 ipixel->gclrflt += acc_gclr * iopc_inv;
06207 ipixel->bclrflt += acc_bclr * iopc_inv;
06208 iopc += acc_opc * iopc_inv;
06209 ipixel->opcflt = iopc;
06210
06211 #ifdef DEBUG
06212 if (ipixel == trace_pixel_ptr) {
06213 #ifdef COMPUTE_SHADOW_BUFFER
06214 printf("{%3d} %3d %3d", k, icount-i-count, j);
06215 #else
06216 printf("[%3d] %3d %3d", k, icount-i-count, j);
06217 #endif
06218 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06219 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06220 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06221 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06222 printf(" %3.0f %3.0f\n", iopc*255.,
06223 ipixel->rclrflt);
06224
06225
06226 printf(" ");
06227 printf(" %3.0f ",trace_gclrTL);
06228 printf(" %3.0f ",trace_gclrBL);
06229 printf(" %3.0f ",trace_gclrTR);
06230 printf(" %3.0f ",trace_gclrBR);
06231 printf(" %3.0f\n", ipixel->gclrflt);
06232 printf(" ");
06233 printf(" %3.0f ",trace_bclrTL);
06234 printf(" %3.0f ",trace_bclrBL);
06235 printf(" %3.0f ",trace_bclrTR);
06236 printf(" %3.0f ",trace_bclrBR);
06237 printf(" %3.0f\n", ipixel->bclrflt);
06238 }
06239 #endif
06240 ;
06241 # ifndef SKIP_ERT
06242 if (iopc >= max_opacity) {
06243 ASSERT(ipixel->lnk == 0);
06244 ipixel->lnk = 1;
06245 }
06246 # endif
06247 };
06248 ipixel += 1;
06249 count--;
06250 SET_VOXELS_LOADED;
06251 last_run_state = run_state;
06252 }
06253 #endif
06254
06255 GET_HIRES_TIME(vpc, t1);
06256 STORE_HIRES_TIME(vpc, VPTIMER_PROCESS_VOXELS, t0, t1);
06257 COPY_HIRES_TIME(t0, t1);
06258
06259 if (count > 0) {
06260 Debug((vpc, VPDEBUG_COMPOSITE, "Backup(%d)\n", count));
06261 toprun_count += count;
06262 botrun_count += count;
06263 i += count;
06264 }
06265 #endif
06266
06267
06268
06269
06270
06271 last_run_state = run_state;
06272 }
06273
06274
06275
06276
06277
06278 #ifdef UNROLL_RUN_LOOP
06279 ASSERT(i == 0);
06280 #else
06281 ASSERT(i == -1);
06282 #endif
06283
06284 #ifndef SKIP_COMPOSITE
06285 #ifdef UNROLL_RUN_LOOP
06286
06287 if (last_run_state != ALL_ZERO && !PIXEL_IS_OPAQUE(ipixel)) {
06288
06289
06290 Debug((vpc, VPDEBUG_COMPOSITE, "Run(1)End\n"));
06291 switch (last_run_state) {
06292 case TOP_NONZERO:
06293
06294 if (!voxels_loaded) {
06295
06296 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
06297
06298
06299 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
06300 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
06301
06302
06303
06304 top_rclr =
06305 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
06306
06307 top_gclr =
06308 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
06309
06310 top_bclr =
06311 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
06312 ;
06313 ;
06314 ;
06315
06316
06317 top_rclr +=
06318 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
06319
06320 top_gclr +=
06321 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
06322
06323 top_bclr +=
06324 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
06325 ;
06326 ;
06327 ;
06328 shade_factor = top_opc * slice_depth_cueing;
06329
06330 top_rclr *= shade_factor;
06331 top_gclr *= shade_factor;
06332 top_bclr *= shade_factor;
06333 ;
06334 }
06335
06336 #ifdef DEBUG
06337 if (ipixel == trace_pixel_ptr) {
06338 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
06339 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
06340 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
06341 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
06342 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
06343 }
06344 #endif
06345 ;
06346
06347 acc_opc = top_opc * wgtTL;
06348
06349 acc_rclr = top_rclr * wgtTL;
06350 acc_gclr = top_gclr * wgtTL;
06351 acc_bclr = top_bclr * wgtTL;
06352
06353 #ifdef DEBUG
06354 if (ipixel == trace_pixel_ptr) {
06355 trace_opcTL = top_opc;
06356 trace_rclrTL = top_rclr;
06357 trace_gclrTL = top_gclr;
06358 trace_bclrTL = top_bclr;
06359
06360 }
06361 #endif
06362 ;
06363
06364 COUNT_RESAMPLE;
06365 if (acc_opc > min_opacity) {
06366 COUNT_COMPOSITE;
06367 iopc = ipixel->opcflt;
06368 # ifndef SKIP_ERT
06369 ASSERT(iopc < max_opacity);
06370 # endif
06371 iopc_inv = (float)1. - iopc;
06372
06373 ipixel->rclrflt += acc_rclr * iopc_inv;
06374 ipixel->gclrflt += acc_gclr * iopc_inv;
06375 ipixel->bclrflt += acc_bclr * iopc_inv;
06376 iopc += acc_opc * iopc_inv;
06377 ipixel->opcflt = iopc;
06378
06379 #ifdef DEBUG
06380 if (ipixel == trace_pixel_ptr) {
06381 #ifdef COMPUTE_SHADOW_BUFFER
06382 printf("{%3d} %3d %3d", k, icount-i-count, j);
06383 #else
06384 printf("[%3d] %3d %3d", k, icount-i-count, j);
06385 #endif
06386 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06387 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06388 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06389 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06390 printf(" %3.0f %3.0f\n", iopc*255.,
06391 ipixel->rclrflt);
06392
06393
06394 printf(" ");
06395 printf(" %3.0f ",trace_gclrTL);
06396 printf(" %3.0f ",trace_gclrBL);
06397 printf(" %3.0f ",trace_gclrTR);
06398 printf(" %3.0f ",trace_gclrBR);
06399 printf(" %3.0f\n", ipixel->gclrflt);
06400 printf(" ");
06401 printf(" %3.0f ",trace_bclrTL);
06402 printf(" %3.0f ",trace_bclrBL);
06403 printf(" %3.0f ",trace_bclrTR);
06404 printf(" %3.0f ",trace_bclrBR);
06405 printf(" %3.0f\n", ipixel->bclrflt);
06406 }
06407 #endif
06408 ;
06409 # ifndef SKIP_ERT
06410 if (iopc >= max_opacity) {
06411 ASSERT(ipixel->lnk == 0);
06412 ipixel->lnk = 1;
06413 }
06414 # endif
06415 };
06416 break;
06417 case BOT_NONZERO:
06418
06419 if (!voxels_loaded) {
06420
06421 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
06422
06423
06424 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
06425 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
06426
06427
06428
06429 bot_rclr =
06430 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
06431
06432 bot_gclr =
06433 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
06434
06435 bot_bclr =
06436 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
06437 ;
06438 ;
06439 ;
06440
06441
06442 bot_rclr +=
06443 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
06444
06445 bot_gclr +=
06446 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
06447
06448 bot_bclr +=
06449 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
06450 ;
06451 ;
06452 ;
06453 shade_factor = bot_opc * slice_depth_cueing;
06454
06455 bot_rclr *= shade_factor;
06456 bot_gclr *= shade_factor;
06457 bot_bclr *= shade_factor;
06458 ;
06459 }
06460
06461 #ifdef DEBUG
06462 if (ipixel == trace_pixel_ptr) {
06463 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
06464 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
06465 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
06466 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
06467 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
06468 }
06469 #endif
06470 ;
06471
06472 acc_opc = bot_opc * wgtBL;
06473
06474 acc_rclr = bot_rclr * wgtBL;
06475 acc_gclr = bot_gclr * wgtBL;
06476 acc_bclr = bot_bclr * wgtBL;
06477
06478 #ifdef DEBUG
06479 if (ipixel == trace_pixel_ptr) {
06480 trace_opcBL = bot_opc;
06481 trace_rclrBL = bot_rclr;
06482 trace_gclrBL = bot_gclr;
06483 trace_bclrBL = bot_bclr;
06484
06485 }
06486 #endif
06487 ;
06488
06489 COUNT_RESAMPLE;
06490 if (acc_opc > min_opacity) {
06491 COUNT_COMPOSITE;
06492 iopc = ipixel->opcflt;
06493 # ifndef SKIP_ERT
06494 ASSERT(iopc < max_opacity);
06495 # endif
06496 iopc_inv = (float)1. - iopc;
06497
06498 ipixel->rclrflt += acc_rclr * iopc_inv;
06499 ipixel->gclrflt += acc_gclr * iopc_inv;
06500 ipixel->bclrflt += acc_bclr * iopc_inv;
06501 iopc += acc_opc * iopc_inv;
06502 ipixel->opcflt = iopc;
06503
06504 #ifdef DEBUG
06505 if (ipixel == trace_pixel_ptr) {
06506 #ifdef COMPUTE_SHADOW_BUFFER
06507 printf("{%3d} %3d %3d", k, icount-i-count, j);
06508 #else
06509 printf("[%3d] %3d %3d", k, icount-i-count, j);
06510 #endif
06511 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06512 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06513 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06514 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06515 printf(" %3.0f %3.0f\n", iopc*255.,
06516 ipixel->rclrflt);
06517
06518
06519 printf(" ");
06520 printf(" %3.0f ",trace_gclrTL);
06521 printf(" %3.0f ",trace_gclrBL);
06522 printf(" %3.0f ",trace_gclrTR);
06523 printf(" %3.0f ",trace_gclrBR);
06524 printf(" %3.0f\n", ipixel->gclrflt);
06525 printf(" ");
06526 printf(" %3.0f ",trace_bclrTL);
06527 printf(" %3.0f ",trace_bclrBL);
06528 printf(" %3.0f ",trace_bclrTR);
06529 printf(" %3.0f ",trace_bclrBR);
06530 printf(" %3.0f\n", ipixel->bclrflt);
06531 }
06532 #endif
06533 ;
06534 # ifndef SKIP_ERT
06535 if (iopc >= max_opacity) {
06536 ASSERT(ipixel->lnk == 0);
06537 ipixel->lnk = 1;
06538 }
06539 # endif
06540 };
06541 break;
06542 case ALL_NONZERO:
06543
06544 if (!voxels_loaded) {
06545
06546 top_opc = opac_correct[ByteField(topRLEdata - voxel_istride, voxel_istride-1)];
06547
06548
06549 shade_index=2*3*ShortField(topRLEdata - voxel_istride,norm_offset);
06550 weight_index = 2 * ByteField(topRLEdata - voxel_istride, wgt_offset);
06551
06552
06553
06554 top_rclr =
06555 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
06556
06557 top_gclr =
06558 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
06559
06560 top_bclr =
06561 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
06562 ;
06563 ;
06564 ;
06565
06566
06567 top_rclr +=
06568 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
06569
06570 top_gclr +=
06571 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
06572
06573 top_bclr +=
06574 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
06575 ;
06576 ;
06577 ;
06578 shade_factor = top_opc * slice_depth_cueing;
06579
06580 top_rclr *= shade_factor;
06581 top_gclr *= shade_factor;
06582 top_bclr *= shade_factor;
06583 ;
06584
06585 bot_opc = opac_correct[ByteField(botRLEdata - voxel_istride, voxel_istride-1)];
06586
06587
06588 shade_index=2*3*ShortField(botRLEdata - voxel_istride,norm_offset);
06589 weight_index = 2 * ByteField(botRLEdata - voxel_istride, wgt_offset);
06590
06591
06592
06593 bot_rclr =
06594 shade_table[shade_index + 3*0 + 0] * weight_table[weight_index + 0];
06595
06596 bot_gclr =
06597 shade_table[shade_index + 3*0 + 1] * weight_table[weight_index + 0];
06598
06599 bot_bclr =
06600 shade_table[shade_index + 3*0 + 2] * weight_table[weight_index + 0];
06601 ;
06602 ;
06603 ;
06604
06605
06606 bot_rclr +=
06607 shade_table[shade_index + 3*1 + 0] * weight_table[weight_index + 1];
06608
06609 bot_gclr +=
06610 shade_table[shade_index + 3*1 + 1] * weight_table[weight_index + 1];
06611
06612 bot_bclr +=
06613 shade_table[shade_index + 3*1 + 2] * weight_table[weight_index + 1];
06614 ;
06615 ;
06616 ;
06617 shade_factor = bot_opc * slice_depth_cueing;
06618
06619 bot_rclr *= shade_factor;
06620 bot_gclr *= shade_factor;
06621 bot_bclr *= shade_factor;
06622 ;
06623 }
06624
06625 #ifdef DEBUG
06626 if (ipixel == trace_pixel_ptr) {
06627 trace_opcTL = 0.; trace_opcBL = 0.; trace_opcTR = 0.; trace_opcBR = 0.;
06628 trace_rsclrTL=0.; trace_rsclrBL=0.; trace_rsclrTR=0.; trace_rsclrBR=0.;
06629 trace_rclrTL= 0.; trace_rclrBL= 0.; trace_rclrTR= 0.; trace_rclrBR= 0.;
06630 trace_gclrTL= 0.; trace_gclrBL= 0.; trace_gclrTR= 0.; trace_gclrBR= 0.;
06631 trace_bclrTL= 0.; trace_bclrBL= 0.; trace_bclrTR= 0.; trace_bclrBR= 0.;
06632 }
06633 #endif
06634 ;
06635
06636 acc_opc = top_opc * wgtTL;
06637
06638 acc_rclr = top_rclr * wgtTL;
06639 acc_gclr = top_gclr * wgtTL;
06640 acc_bclr = top_bclr * wgtTL;
06641
06642 #ifdef DEBUG
06643 if (ipixel == trace_pixel_ptr) {
06644 trace_opcTL = top_opc;
06645 trace_rclrTL = top_rclr;
06646 trace_gclrTL = top_gclr;
06647 trace_bclrTL = top_bclr;
06648
06649 }
06650 #endif
06651 ;
06652
06653 acc_opc += bot_opc * wgtBL;
06654
06655 acc_rclr += bot_rclr * wgtBL;
06656 acc_gclr += bot_gclr * wgtBL;
06657 acc_bclr += bot_bclr * wgtBL;
06658
06659 #ifdef DEBUG
06660 if (ipixel == trace_pixel_ptr) {
06661 trace_opcBL = bot_opc;
06662 trace_rclrBL = bot_rclr;
06663 trace_gclrBL = bot_gclr;
06664 trace_bclrBL = bot_bclr;
06665
06666 }
06667 #endif
06668 ;
06669
06670 COUNT_RESAMPLE;
06671 if (acc_opc > min_opacity) {
06672 COUNT_COMPOSITE;
06673 iopc = ipixel->opcflt;
06674 # ifndef SKIP_ERT
06675 ASSERT(iopc < max_opacity);
06676 # endif
06677 iopc_inv = (float)1. - iopc;
06678
06679 ipixel->rclrflt += acc_rclr * iopc_inv;
06680 ipixel->gclrflt += acc_gclr * iopc_inv;
06681 ipixel->bclrflt += acc_bclr * iopc_inv;
06682 iopc += acc_opc * iopc_inv;
06683 ipixel->opcflt = iopc;
06684
06685 #ifdef DEBUG
06686 if (ipixel == trace_pixel_ptr) {
06687 #ifdef COMPUTE_SHADOW_BUFFER
06688 printf("{%3d} %3d %3d", k, icount-i-count, j);
06689 #else
06690 printf("[%3d] %3d %3d", k, icount-i-count, j);
06691 #endif
06692 printf(" %3.0f %3.0f %3.0f",trace_opcTL*255.,trace_rclrTL,wgtTL*100.);
06693 printf(" %3.0f %3.0f %3.0f",trace_opcBL*255.,trace_rclrBL,wgtBL*100.);
06694 printf(" %3.0f %3.0f %3.0f",trace_opcTR*255.,trace_rclrTR,wgtTR*100.);
06695 printf(" %3.0f %3.0f %3.0f",trace_opcBR*255.,trace_rclrBR,wgtBR*100.);
06696 printf(" %3.0f %3.0f\n", iopc*255.,
06697 ipixel->rclrflt);
06698
06699
06700 printf(" ");
06701 printf(" %3.0f ",trace_gclrTL);
06702 printf(" %3.0f ",trace_gclrBL);
06703 printf(" %3.0f ",trace_gclrTR);
06704 printf(" %3.0f ",trace_gclrBR);
06705 printf(" %3.0f\n", ipixel->gclrflt);
06706 printf(" ");
06707 printf(" %3.0f ",trace_bclrTL);
06708 printf(" %3.0f ",trace_bclrBL);
06709 printf(" %3.0f ",trace_bclrTR);
06710 printf(" %3.0f ",trace_bclrBR);
06711 printf(" %3.0f\n", ipixel->bclrflt);
06712 }
06713 #endif
06714 ;
06715 # ifndef SKIP_ERT
06716 if (iopc >= max_opacity) {
06717 ASSERT(ipixel->lnk == 0);
06718 ipixel->lnk = 1;
06719 }
06720 # endif
06721 };
06722 break;
06723 default:
06724 VPBug("illegal value for run state at end of scanline");
06725 }
06726 } else if (last_run_state == ALL_ZERO) {
06727 Debug((vpc, VPDEBUG_COMPOSITE, "ZeroSkip(1)End\n"));
06728 } else {
06729 Debug((vpc, VPDEBUG_COMPOSITE, "ERTSkip(1)End\n"));
06730 }
06731 #endif
06732 #endif
06733
06734 #ifndef UNROLL_RUN_LOOP
06735 run_state = final_run_state;
06736 #endif
06737
06738 if (j != 0 && ((run_state & 1) == 0)) {
06739 toprun_count = *topRLElen++;
06740 ASSERT(toprun_count == 0);
06741 }
06742 if (j != jcount && ((run_state & 2) == 0)) {
06743 botrun_count = *botRLElen++;
06744 ASSERT(botrun_count == 0);
06745 }
06746
06747
06748 #ifdef UNROLL_RUN_LOOP
06749 ipixel += intermediate_width - icount;
06750 #ifdef USE_SHADOW_BUFFER
06751 shadow_pixel += shadow_width - icount;
06752 #endif
06753 #else
06754 ipixel += intermediate_width - (icount+1);
06755 #ifdef USE_SHADOW_BUFFER
06756 shadow_pixel += shadow_width - (icount+1);
06757 #endif
06758 #endif
06759
06760 Debug((vpc, VPDEBUG_COMPOSITE, "ScanDone\n"));
06761 }
06762
06763
06764
06765
06766
06767 GET_HIRES_TIME(vpc, t1);
06768 STORE_HIRES_TIME(vpc, VPTIMER_TRAVERSE_RUNS, t0, t1);
06769
06770 Debug((vpc, VPDEBUG_COMPOSITE, "SliceDone\n"));
06771 }