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

Comparing ray/src/px/pinterp.c (file contents):
Revision 1.25 by greg, Tue Mar 6 11:14:36 1990 UTC vs.
Revision 1.29 by greg, Tue Sep 4 21:16:25 1990 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include "color.h"
18  
19 #include "random.h"
20
19   #ifndef BSD
20   #define vfork           fork
21   #endif
# Line 25 | Line 23 | static char SCCSid[] = "$SunId$ LBL";
23   #define pscan(y)        (ourpict+(y)*hresolu)
24   #define zscan(y)        (ourzbuf+(y)*hresolu)
25  
28 #define PMASK           0xfffffff       /* probability mask */
29 #define sampval(x)      (long)((x)*(PMASK+1)+.5)
30 #define samp(p)         ((p) > (random()&PMASK))
31
26   #define F_FORE          1               /* fill foreground */
27   #define F_BACK          2               /* fill background */
28  
# Line 53 | Line 47 | float  *ourzbuf;                       /* corresponding z-buffer */
47   char    *progname;
48  
49   int     fillo = F_FORE|F_BACK;          /* selected fill options */
50 < long    sampprob = 0;                   /* sample probability */
50 > int     fillsamp = 0;                   /* sample separation (0 == inf) */
51   extern int      backfill(), rcalfill(); /* fill functions */
52   int     (*fillfunc)() = backfill;       /* selected fill function */
53   COLR    backcolr = BLKCOLR;             /* background color */
# Line 121 | Line 115 | char   *argv[];
115                                  break;
116                          case 's':                               /* sample */
117                                  check(3,1);
118 <                                sampprob = sampval(atof(argv[++i]));
118 >                                fillsamp = atoi(argv[++i]);
119                                  break;
120                          case 'c':                               /* color */
121                                  check(3,3);
# Line 200 | Line 194 | char   *argv[];
194                  addpicture(argv[i], argv[i+1]);
195                                                          /* fill in spaces */
196          if (fillo&F_BACK)
197 <                backpicture(fillfunc, sampprob);
197 >                backpicture(fillfunc, fillsamp);
198          else
199                  fillpicture(fillfunc);
200                                                          /* close calculation */
# Line 460 | Line 454 | double z;
454                  y1 = p0->y + c1*s1y/l1;
455                  for (c2 = l2; c2-- > 0; ) {
456                          x = x1 + c2*s2x/l2;
457 +                        if (x < 0 || x >= hresolu)
458 +                                continue;
459                          y = y1 + c2*s2y/l2;
460 +                        if (y < 0 || y >= vresolu)
461 +                                continue;
462                          if (zscan(y)[x] <= 0 || zscan(y)[x]-z
463                                                  > zeps*zscan(y)[x]) {
464                                  zscan(y)[x] = z;
# Line 471 | Line 469 | double z;
469   }
470  
471  
472 < backpicture(fill, prob)                 /* background fill algorithm */
472 > backpicture(fill, samp)                 /* background fill algorithm */
473   int     (*fill)();
474 < long    prob;
474 > int     samp;
475   {
476          int     *yback, xback;
477          int     y;
# Line 524 | Line 522 | long   prob;
522                                                  xback = x-1;
523                                  }
524                                  /*
525 <                                 * Check to see if we have no background for
526 <                                 * this pixel.  If not, or sampling was
529 <                                 * requested, use the given fill function.
525 >                                 * If we have no background for this pixel,
526 >                                 * use the given fill function.
527                                   */
528 <                                if ((xback < 0 && yback[x] < 0) || samp(prob)) {
529 <                                        (*fill)(x,y);
533 <                                        continue;
534 <                                }
528 >                                if (xback < 0 && yback[x] < 0)
529 >                                        goto fillit;
530                                  /*
531                                   * Compare, and use the background that is
532                                   * farther, unless one of them is next to us.
533 +                                 * If the background is too distant, call
534 +                                 * the fill function.
535                                   */
536                                  if ( yback[x] < 0
537                                          || (xback >= 0 && ABS(x-xback) <= 1)
538                                          || ( ABS(y-yback[x]) > 1
539                                                  && zscan(yback[x])[x]
540                                                  < zscan(y)[xback] ) ) {
541 +                                        if (samp > 0 && ABS(x-xback) >= samp)
542 +                                                goto fillit;
543                                          copycolr(pscan(y)[x],pscan(y)[xback]);
544                                          zscan(y)[x] = zscan(y)[xback];
545                                  } else {
546 +                                        if (samp > 0 && ABS(y-yback[x]) > samp)
547 +                                                goto fillit;
548                                          copycolr(pscan(y)[x],pscan(yback[x])[x]);
549                                          zscan(y)[x] = zscan(yback[x])[x];
550                                  }
551 +                                continue;
552 +                        fillit:
553 +                                (*fill)(x,y);
554 +                                if (fill == rcalfill) {         /* use it */
555 +                                        clearqueue();
556 +                                        xback = x;
557 +                                        yback[x] = y;
558 +                                }
559                          } else {                                /* full pixel */
560                                  yback[x] = -2;
561                                  xback = -2;
# Line 599 | Line 608 | char   *fname;
608                  if (donorm) {
609                          double  vx, yzn2;
610                          register int    x;
611 <                        yzn2 = y - .5*(vresolu-1);
611 >                        yzn2 = (y+.5)/vresolu + ourview.voff - .5;
612                          yzn2 = 1. + yzn2*yzn2*ourview.vn2;
613                          for (x = 0; x < hresolu; x++) {
614 <                                vx = x - .5*(hresolu-1);
614 >                                vx = (x+.5)/hresolu + ourview.hoff - .5;
615                                  zout[x] = zscan(y)[x]
616                                          * sqrt(vx*vx*ourview.hn2 + yzn2);
617                          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines