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

Comparing ray/src/rt/rpict.c (file contents):
Revision 1.29 by greg, Tue Jun 25 14:06:12 1991 UTC vs.
Revision 2.3 by greg, Tue Dec 10 17:42:01 1991 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #ifdef BSD
16   #include  <sys/time.h>
17   #include  <sys/resource.h>
18 #else
19 #include  <signal.h>
18   #endif
19 +
20 + #include  <signal.h>
21   #include  <fcntl.h>
22  
23   #include  "view.h"
24  
25 + #include  "resolu.h"
26 +
27   #include  "random.h"
28  
29   int  dimlist[MAXDIM];                   /* sampling dimensions */
# Line 40 | Line 42 | double  dstrpix = 0.67;                        /* square pixel distribution
42   double  dstrsrc = 0.0;                  /* square source distribution */
43   double  shadthresh = .05;               /* shadow threshold */
44   double  shadcert = .5;                  /* shadow certainty */
45 < int  directrelay = 0;                   /* number of source relays */
45 > int  directrelay = 1;                   /* number of source relays */
46   int  vspretest = 512;                   /* virtual source pretest density */
47 + int  directinvis = 0;                   /* sources invisible? */
48 + double  srcsizerat = .25;               /* maximum ratio source size/dist. */
49  
50   int  maxdepth = 6;                      /* maximum recursion depth */
51   double  minweight = 5e-3;               /* minimum ray weight */
# Line 66 | Line 70 | extern long  tstart;                   /* starting time */
70  
71   extern long  nrays;                     /* number of rays traced */
72  
73 < #define  MAXDIV         15              /* maximum sample size */
73 > #define  MAXDIV         16              /* maximum sample size */
74  
75   #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
76  
# Line 119 | Line 123 | char  *zfile, *oldfile;
123          extern long  lseek();
124          COLOR  *scanbar[MAXDIV+1];      /* scanline arrays of pixel values */
125          float  *zbar[MAXDIV+1];         /* z values */
126 +        char  *sampdens;                /* previous sample density */
127          int  ypos;                      /* current scanline */
128          int  ystep;                     /* current y step size */
129 +        int  hstep;                     /* h step size */
130          int  zfd;
131          COLOR  *colptr;
132          float  *zptr;
# Line 140 | Line 146 | char  *zfile, *oldfile;
146                  if (scanbar[i] == NULL)
147                          goto memerr;
148          }
149 +        hstep = (psample*140+49)/99;            /* quincunx sampling */
150 +        ystep = (psample*99+70)/140;
151 +        if (hstep > 2) {
152 +                i = hresolu/hstep + 2;
153 +                if ((sampdens = malloc(i)) == NULL)
154 +                        goto memerr;
155 +                while (i--)
156 +                        sampdens[i] = hstep;
157 +        } else
158 +                sampdens = NULL;
159                                          /* open z file */
160          if (zfile != NULL) {
161                  if ((zfd = open(zfile, O_WRONLY|O_CREAT, 0666)) == -1) {
# Line 157 | Line 173 | char  *zfile, *oldfile;
173                          zbar[i] = NULL;
174          }
175                                          /* write out boundaries */
176 <        fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout);
176 >        fprtresolu(hresolu, vresolu, stdout);
177                                          /* recover file and compute first */
178          i = salvage(oldfile);
179          if (zfd != -1 && i > 0 &&
# Line 166 | Line 182 | char  *zfile, *oldfile;
182          pctdone = 100.0*i/vresolu;
183          if (ralrm > 0)                  /* report init stats */
184                  report();
185 + #ifndef  BSD
186 +        else
187 + #endif
188 +        signal(SIGALRM, report);
189          ypos = vresolu-1 - i;
190 <        fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
171 <        ystep = psample;
190 >        fillscanline(scanbar[0], zbar[0], sampdens, hresolu, ypos, hstep);
191                                                  /* compute scanlines */
192          for (ypos -= ystep; ypos > -ystep; ypos -= ystep) {
193                                                          /* bottom adjust? */
# Line 183 | Line 202 | char  *zfile, *oldfile;
202                  zbar[ystep] = zbar[0];
203                  zbar[0] = zptr;
204                                                          /* fill base line */
205 <                fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
205 >                fillscanline(scanbar[0], zbar[0], sampdens,
206 >                                hresolu, ypos, hstep);
207                                                          /* fill bar */
208                  fillscanbar(scanbar, zbar, hresolu, ypos, ystep);
209                                                          /* write it out */
210 + #ifndef  BSD
211 +                signal(SIGALRM, SIG_IGN);       /* don't interrupt writes */
212 + #endif
213                  for (i = ystep; i > 0; i--) {
214                          if (zfd != -1 && write(zfd, (char *)zbar[i],
215                                          hresolu*sizeof(float))
# Line 201 | Line 224 | char  *zfile, *oldfile;
224                  pctdone = 100.0*(vresolu-1-ypos)/vresolu;
225                  if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm)
226                          report();
227 + #ifndef  BSD
228 +                else
229 +                        signal(SIGALRM, report);
230 + #endif
231          }
232                                                  /* clean up */
233          if (zfd != -1) {
# Line 217 | Line 244 | char  *zfile, *oldfile;
244                  goto writerr;
245          for (i = 0; i <= psample; i++)
246                  free((char *)scanbar[i]);
247 +        if (sampdens != NULL)
248 +                free(sampdens);
249          pctdone = 100.0;
250          return;
251   writerr:
# Line 226 | Line 255 | memerr:
255   }
256  
257  
258 < fillscanline(scanline, zline, xres, y, xstep)   /* fill scan line at y */
258 > fillscanline(scanline, zline, sd, xres, y, xstep)       /* fill scan at y */
259   register COLOR  *scanline;
260   register float  *zline;
261 + register char  *sd;
262   int  xres, y, xstep;
263   {
264 <        int  b = xstep;
264 >        static int  nc = 0;             /* number of calls */
265 >        int  bl = xstep, b = xstep;
266          double  z;
267          register int  i;
268          
269          z = pixvalue(scanline[0], 0, y);
270          if (zline) zline[0] = z;
271 <
272 <        for (i = xstep; i < xres-1+xstep; i += xstep) {
271 >                                /* zig-zag start for quincunx pattern */
272 >        for (i = ++nc & 1 ? xstep : xstep/2; i < xres-1+xstep; i += xstep) {
273                  if (i >= xres) {
274                          xstep += xres-1-i;
275                          i = xres-1;
276                  }
277                  z = pixvalue(scanline[i], i, y);
278                  if (zline) zline[i] = z;
279 <                
280 <                b = fillsample(scanline+i-xstep, zline ? zline+i-xstep : NULL,
281 <                                i-xstep, y, xstep, 0, b/2);
279 >                if (sd) b = sd[0] > sd[1] ? sd[0] : sd[1];
280 >                if (i <= xstep)
281 >                        b = fillsample(scanline, zline, 0, y, i, 0, b/2);
282 >                else
283 >                        b = fillsample(scanline+i-xstep,
284 >                                        zline ? zline+i-xstep : NULL,
285 >                                        i-xstep, y, xstep, 0, b/2);
286 >                if (sd) *sd++ = nc & 1 ? bl : b;
287 >                bl = b;
288          }
289 +        if (sd && nc & 1) *sd = bl;
290   }
291  
292  
# Line 353 | Line 391 | int  x, y;                     /* pixel position */
391  
392          rayorigin(&thisray, NULL, PRIMARY, 1.0);
393  
394 <        samplendx = 3*y + x;                    /* set pixel index */
394 >        samplendx = pixnumber(x,y,hresolu,vresolu);     /* set pixel index */
395  
396          rayvalue(&thisray);                     /* trace ray */
397  
# Line 382 | Line 420 | char  *oldfile;
420                                  /* discard header */
421          getheader(fp, NULL);
422                                  /* get picture size */
423 <        if (fgetresolu(&x, &y, fp) != (YMAJOR|YDECR)) {
423 >        if (!fscnresolu(&x, &y, fp)) {
424                  sprintf(errmsg, "bad recover file \"%s\"", oldfile);
425                  error(WARNING, errmsg);
426                  fclose(fp);
# Line 412 | Line 450 | char  *oldfile;
450          return(y);
451   writerr:
452          error(SYSTEM, "write error in salvage");
453 + }
454 +
455 +
456 + int
457 + pixnumber(x, y, xres, yres)             /* compute pixel index (brushed) */
458 + register int  x, y;
459 + int  xres, yres;
460 + {
461 +        x -= y;
462 +        while (x < 0)
463 +                x += xres;
464 +        return((((x>>2)*yres + y) << 2) + (x & 3));
465   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines