ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/srcdraw.c
(Generate patch)

Comparing ray/src/rt/srcdraw.c (file contents):
Revision 2.25 by greg, Wed Jul 3 16:46:43 2024 UTC vs.
Revision 2.26 by greg, Wed Jul 31 22:21:28 2024 UTC

# Line 396 | Line 396 | init_drawsources(
396   void                            /* add sources smaller than rad to computed subimage */
397   drawsources(
398          COLORV  *pic[],                         /* subimage pixel value array */
399 +        int     nc,                             /* number of target components */
400          float   *zbf[],                         /* subimage distance array (opt.) */
401          int     x0,                             /* origin and size of subimage */
402          int     xsiz,
# Line 407 | Line 408 | drawsources(
408          int     nsv, npv;
409          int     xmin, xmax, ymin, ymax, x, y;
410          RREAL   cxy[2];
411 +        COLOR   rcol;
412          double  w;
413          RAY     sr;
414          SPLIST  *sp;
415          int     i;
416 +                                        /* check #components */
417 +        if ((nc != 3) & (nc != NCSAMP))
418 +                error(INTERNAL, "unsupported #components in drawsources()");
419                                          /* check each source in our list */
420          for (sp = sphead; sp != NULL; sp = sp->next) {
421                                          /* clip source poly to subimage */
# Line 434 | Line 439 | drawsources(
439                  }
440                                          /* evaluate each pixel in BBox */
441                  for (y = ymin; y <= ymax; y++) {
442 <                        COLORV  *pp = pic[y-y0] + (xmin-x0)*NCSAMP;
443 <                        for (x = xmin; x <= xmax; x++, pp += NCSAMP) {
442 >                        COLORV  *pp = pic[y-y0] + (xmin-x0)*nc;
443 >                        for (x = xmin; x <= xmax; x++, pp += nc) {
444                                                          /* subarea for pixel */
445                                  npv = box_clip_poly(spoly, nsv,
446                                                  (double)x/hres, (x+1.)/hres,
# Line 455 | Line 460 | drawsources(
460                                  rayvalue(&sr);          /* compute value */
461                                  if (sintens(sr.rcol) <= FTINY)
462                                          continue;       /* missed/blocked */
463 +                                if (nc == 3)
464 +                                        scolor_rgb(rcol, sr.rcol);
465                                                          /* modify pixel */
466                                  w = poly_area(ppoly, npv) * hres * vres;
467                                  if (zbf[y-y0] != NULL &&
468                                                  sr.rxt < 0.99*zbf[y-y0][x-x0]) {
469                                          zbf[y-y0][x-x0] = sr.rxt;
470 <                                } else if (!sbigsdiff(sr.rcol, pp, 0.07)) { /* source sample */
470 >                                } else if (nc == 3) {
471 >                                        if (!bigdiff(rcol, pp, 0.07)) {
472 >                                                scalecolor(pp, w);
473 >                                                continue;
474 >                                        }
475 >                                } else if (!sbigsdiff(sr.rcol, pp, 0.07)) {
476                                          scalescolor(pp, w);
477                                          continue;
478                                  }
479 <                                scalescolor(sr.rcol, w);
480 <                                scalescolor(pp, 1.-w);
481 <                                saddscolor(pp, sr.rcol);
479 >                                if (nc == 3) {
480 >                                        scalecolor(rcol, w);
481 >                                        scalecolor(pp, 1.-w);
482 >                                        addcolor(pp, rcol);
483 >                                } else {
484 >                                        scalescolor(sr.rcol, w);
485 >                                        scalescolor(pp, 1.-w);
486 >                                        saddscolor(pp, sr.rcol);
487 >                                }
488                          }
489                  }
490          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines