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.18 by greg, Wed Jan 24 04:39:52 2018 UTC vs.
Revision 2.27 by greg, Mon Aug 12 18:57:00 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 325 | Line 326 | sourcepoly(                    /* compute image polygon for source */
326                                  }
327                          }
328                                                          /* find image point */
329 <                        if (viewloc(ip, &ourview, ap) <= 0)
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 349 | Line 350 | sourcepoly(                    /* compute image polygon for source */
350                          else ap[i] -= s->ss[SW][i];
351                  }
352                                                  /* find image point */
353 <                if (viewloc(ip, &ourview, ap) <= 0)
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 >        RGBPRIMP primp,                         /* output primaries */
400          float   *zbf[],                         /* subimage distance array (opt.) */
401          int     x0,                             /* origin and size of subimage */
402          int     xsiz,
# Line 402 | 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 432 | Line 436 | drawsources(
436                                  ymax = spoly[i][1]*vres - FTINY;
437                  }
438                                          /* evaluate each pixel in BBox */
439 <                for (y = ymin; y <= ymax; y++)
440 <                        for (x = xmin; x <= xmax; x++) {
439 >                for (y = ymin; y <= ymax; y++) {
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 451 | Line 456 | drawsources(
456                                  rayorigin(&sr, SHADOW, NULL, NULL);
457                                  sr.rsrc = sp->sn;
458                                  rayvalue(&sr);          /* compute value */
459 <                                if (bright(sr.rcol) <= FTINY)
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.rt < 0.99*zbf[y-y0][x-x0]) {
467 <                                        zbf[y-y0][x-x0] = sr.rt;
468 <                                } else if (!bigdiff(sr.rcol, pic[y-y0][x-x0],
469 <                                                0.01)) { /* source sample */
470 <                                        scalecolor(pic[y-y0][x-x0], w);
466 >                                                sr.rxt < 0.99*zbf[y-y0][x-x0]) {
467 >                                        zbf[y-y0][x-x0] = sr.rxt;
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 <                                scalecolor(sr.rcol, w);
478 <                                scalecolor(pic[y-y0][x-x0], 1.-w);
479 <                                addcolor(pic[y-y0][x-x0], 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          }
489   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines