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.24 by greg, Tue Jul 2 23:59:20 2024 UTC vs.
Revision 2.27 by greg, Mon Aug 12 18:57:00 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 +        RGBPRIMP primp,                         /* output primaries */
400          float   *zbf[],                         /* subimage distance array (opt.) */
401          int     x0,                             /* origin and size of subimage */
402          int     xsiz,
# Line 403 | Line 404 | drawsources(
404          int     ysiz
405   )
406   {
407 <        RREAL   spoly[MAXVERT][2], ppoly[MAXVERT][2];
408 <        int     nsv, npv;
409 <        int     xmin, xmax, ymin, ymax, x, y;
410 <        RREAL   cxy[2];
411 <        double  w;
412 <        RAY     sr;
413 <        SPLIST  *sp;
414 <        int     i;
407 >        const int       NC = primp ? 3 : NCSAMP;
408 >        RREAL           spoly[MAXVERT][2], ppoly[MAXVERT][2];
409 >        int             nsv, npv;
410 >        int             xmin, xmax, ymin, ymax, x, y;
411 >        RREAL           cxy[2];
412 >        COLOR           rcol;
413 >        double          w;
414 >        RAY             sr;
415 >        SPLIST          *sp;
416 >        int             i;
417                                          /* check each source in our list */
418          for (sp = sphead; sp != NULL; sp = sp->next) {
419                                          /* clip source poly to subimage */
# Line 434 | Line 437 | drawsources(
437                  }
438                                          /* evaluate each pixel in BBox */
439                  for (y = ymin; y <= ymax; y++) {
440 <                        COLORV  *pp = pic[y-y0] + (xmin-x0)*NCSAMP;
441 <                        for (x = xmin; x <= xmax; x++, pp += NCSAMP) {
440 >                        COLORV  *pp = pic[y-y0] + (xmin-x0)*NC;
441 >                        for (x = xmin; x <= xmax; x++, pp += NC) {
442                                                          /* subarea for pixel */
443                                  npv = box_clip_poly(spoly, nsv,
444                                                  (double)x/hres, (x+1.)/hres,
# Line 455 | Line 458 | drawsources(
458                                  rayvalue(&sr);          /* compute value */
459                                  if (sintens(sr.rcol) <= FTINY)
460                                          continue;       /* missed/blocked */
461 +                                if (NC == 3)
462 +                                        scolor_out(rcol, primp, sr.rcol);
463                                                          /* modify pixel */
464                                  w = poly_area(ppoly, npv) * hres * vres;
465                                  if (zbf[y-y0] != NULL &&
466                                                  sr.rxt < 0.99*zbf[y-y0][x-x0]) {
467                                          zbf[y-y0][x-x0] = sr.rxt;
468 <                                } else if (!sbigsdiff(sr.rcol, pp, 0.01)) { /* source sample */
468 >                                } else if (NC == 3) {
469 >                                        if (!bigdiff(rcol, pp, 0.07)) {
470 >                                                scalecolor(pp, w);
471 >                                                continue;
472 >                                        }
473 >                                } else if (!sbigsdiff(sr.rcol, pp, 0.07)) {
474                                          scalescolor(pp, w);
475                                          continue;
476                                  }
477 <                                scalescolor(sr.rcol, w);
478 <                                scalescolor(pp, 1.-w);
479 <                                saddscolor(pp, sr.rcol);
477 >                                if (NC == 3) {
478 >                                        scalecolor(rcol, w);
479 >                                        scalecolor(pp, 1.-w);
480 >                                        addcolor(pp, rcol);
481 >                                } else {
482 >                                        scalescolor(sr.rcol, w);
483 >                                        scalescolor(pp, 1.-w);
484 >                                        saddscolor(pp, sr.rcol);
485 >                                }
486                          }
487                  }
488          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines