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.17 by greg, Tue Jul 8 18:25:00 2014 UTC vs.
Revision 2.26 by greg, Wed Jul 31 22:21:28 2024 UTC

# Line 12 | Line 12 | static const char      RCSid[] = "$Id$";
12   #include  "ray.h"
13   #include  "view.h"
14   #include  "otypes.h"
15 + #include  "otspecial.h"
16   #include  "source.h"
17  
18  
# Line 324 | Line 325 | sourcepoly(                    /* compute image polygon for source */
325                                          ap[i] += ourview.vp[i];
326                                  }
327                          }
328 <                        viewloc(ip, &ourview, ap);      /* find image point */
329 <                        if (ip[2] <= 0.)
328 >                                                        /* find image point */
329 >                        if (viewloc(ip, &ourview, ap) != VL_GOOD)
330                                  return(0);              /* in front of view */
331                          sp[j][0] = ip[0]; sp[j][1] = ip[1];
332                  }
# Line 348 | Line 349 | sourcepoly(                    /* compute image polygon for source */
349                          if (cubeord[dir][j] & 4) ap[i] += s->ss[SW][i];
350                          else ap[i] -= s->ss[SW][i];
351                  }
352 <                viewloc(ip, &ourview, ap);      /* find image point */
353 <                if (ip[2] <= 0.)
352 >                                                /* find image point */
353 >                if (viewloc(ip, &ourview, ap) != VL_GOOD)
354                          return(0);              /* in front of view */
355                  pt[j][0] = ip[0]; pt[j][1] = ip[1];
356          }
# Line 394 | Line 395 | init_drawsources(
395  
396   void                            /* add sources smaller than rad to computed subimage */
397   drawsources(
398 <        COLOR   *pic[],                         /* subimage pixel value array */
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 406 | 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 432 | Line 438 | drawsources(
438                                  ymax = spoly[i][1]*vres - FTINY;
439                  }
440                                          /* evaluate each pixel in BBox */
441 <                for (y = ymin; y <= ymax; y++)
442 <                        for (x = xmin; x <= xmax; x++) {
441 >                for (y = ymin; y <= ymax; y++) {
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 451 | Line 458 | drawsources(
458                                  rayorigin(&sr, SHADOW, NULL, NULL);
459                                  sr.rsrc = sp->sn;
460                                  rayvalue(&sr);          /* compute value */
461 <                                if (bright(sr.rcol) <= FTINY)
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.rt < 0.99*zbf[y-y0][x-x0]) {
469 <                                        zbf[y-y0][x-x0] = sr.rt;
470 <                                } else if (!bigdiff(sr.rcol, pic[y-y0][x-x0],
471 <                                                0.01)) { /* source sample */
472 <                                        scalecolor(pic[y-y0][x-x0], w);
468 >                                                sr.rxt < 0.99*zbf[y-y0][x-x0]) {
469 >                                        zbf[y-y0][x-x0] = sr.rxt;
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 <                                scalecolor(sr.rcol, w);
480 <                                scalecolor(pic[y-y0][x-x0], 1.-w);
481 <                                addcolor(pic[y-y0][x-x0], 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          }
491   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines