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.31 by greg, Tue Aug 13 12:16:34 1991 UTC vs.
Revision 2.7 by greg, Wed Mar 11 09:32:40 1992 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 + double  specthresh = .15;               /* specular sampling threshold */
51 + double  specjitter = 1.;                /* specular sampling jitter */
52 +
53   int  maxdepth = 6;                      /* maximum recursion depth */
54   double  minweight = 5e-3;               /* minimum ray weight */
55  
# Line 67 | Line 73 | extern long  tstart;                   /* starting time */
73  
74   extern long  nrays;                     /* number of rays traced */
75  
76 < #define  MAXDIV         15              /* maximum sample size */
76 > #define  MAXDIV         16              /* maximum sample size */
77  
78   #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
79  
# Line 105 | Line 111 | report()               /* report progress */
111   #else
112   report()                /* report progress */
113   {
108        signal(SIGALRM, report);
114          tlastrept = time((long *)0);
115          sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n",
116                          nrays, pctdone, (tlastrept-tstart)/3600.0);
117          eputs(errmsg);
118 +        signal(SIGALRM, report);
119   }
120   #endif
121  
# Line 120 | Line 126 | char  *zfile, *oldfile;
126          extern long  lseek();
127          COLOR  *scanbar[MAXDIV+1];      /* scanline arrays of pixel values */
128          float  *zbar[MAXDIV+1];         /* z values */
129 +        char  *sampdens;                /* previous sample density */
130          int  ypos;                      /* current scanline */
131          int  ystep;                     /* current y step size */
132 +        int  hstep;                     /* h step size */
133          int  zfd;
134          COLOR  *colptr;
135          float  *zptr;
# Line 141 | Line 149 | char  *zfile, *oldfile;
149                  if (scanbar[i] == NULL)
150                          goto memerr;
151          }
152 +        hstep = (psample*140+49)/99;            /* quincunx sampling */
153 +        ystep = (psample*99+70)/140;
154 +        if (hstep > 2) {
155 +                i = hresolu/hstep + 2;
156 +                if ((sampdens = malloc(i)) == NULL)
157 +                        goto memerr;
158 +                while (i--)
159 +                        sampdens[i] = hstep;
160 +        } else
161 +                sampdens = NULL;
162                                          /* open z file */
163          if (zfile != NULL) {
164                  if ((zfd = open(zfile, O_WRONLY|O_CREAT, 0666)) == -1) {
# Line 158 | Line 176 | char  *zfile, *oldfile;
176                          zbar[i] = NULL;
177          }
178                                          /* write out boundaries */
179 <        fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout);
179 >        fprtresolu(hresolu, vresolu, stdout);
180                                          /* recover file and compute first */
181          i = salvage(oldfile);
182          if (zfd != -1 && i > 0 &&
# Line 167 | Line 185 | char  *zfile, *oldfile;
185          pctdone = 100.0*i/vresolu;
186          if (ralrm > 0)                  /* report init stats */
187                  report();
188 + #ifndef  BSD
189 +        else
190 + #endif
191 +        signal(SIGALRM, report);
192          ypos = vresolu-1 - i;
193 <        fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
172 <        ystep = psample;
193 >        fillscanline(scanbar[0], zbar[0], sampdens, hresolu, ypos, hstep);
194                                                  /* compute scanlines */
195          for (ypos -= ystep; ypos > -ystep; ypos -= ystep) {
196                                                          /* bottom adjust? */
# Line 184 | Line 205 | char  *zfile, *oldfile;
205                  zbar[ystep] = zbar[0];
206                  zbar[0] = zptr;
207                                                          /* fill base line */
208 <                fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
208 >                fillscanline(scanbar[0], zbar[0], sampdens,
209 >                                hresolu, ypos, hstep);
210                                                          /* fill bar */
211                  fillscanbar(scanbar, zbar, hresolu, ypos, ystep);
212                                                          /* write it out */
213 + #ifndef  BSD
214 +                signal(SIGALRM, SIG_IGN);       /* don't interrupt writes */
215 + #endif
216                  for (i = ystep; i > 0; i--) {
217                          if (zfd != -1 && write(zfd, (char *)zbar[i],
218                                          hresolu*sizeof(float))
# Line 202 | Line 227 | char  *zfile, *oldfile;
227                  pctdone = 100.0*(vresolu-1-ypos)/vresolu;
228                  if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm)
229                          report();
230 + #ifndef  BSD
231 +                else
232 +                        signal(SIGALRM, report);
233 + #endif
234          }
235                                                  /* clean up */
236 +        signal(SIGALRM, SIG_IGN);
237          if (zfd != -1) {
238                  if (write(zfd, (char *)zbar[0], hresolu*sizeof(float))
239                                  < hresolu*sizeof(float))
# Line 218 | Line 248 | char  *zfile, *oldfile;
248                  goto writerr;
249          for (i = 0; i <= psample; i++)
250                  free((char *)scanbar[i]);
251 +        if (sampdens != NULL)
252 +                free(sampdens);
253          pctdone = 100.0;
254          return;
255   writerr:
# Line 227 | Line 259 | memerr:
259   }
260  
261  
262 < fillscanline(scanline, zline, xres, y, xstep)   /* fill scan line at y */
262 > fillscanline(scanline, zline, sd, xres, y, xstep)       /* fill scan at y */
263   register COLOR  *scanline;
264   register float  *zline;
265 + register char  *sd;
266   int  xres, y, xstep;
267   {
268 <        int  b = xstep;
268 >        static int  nc = 0;             /* number of calls */
269 >        int  bl = xstep, b = xstep;
270          double  z;
271          register int  i;
272          
273          z = pixvalue(scanline[0], 0, y);
274          if (zline) zline[0] = z;
275 <
276 <        for (i = xstep; i < xres-1+xstep; i += xstep) {
275 >                                /* zig-zag start for quincunx pattern */
276 >        for (i = ++nc & 1 ? xstep : xstep/2; i < xres-1+xstep; i += xstep) {
277                  if (i >= xres) {
278                          xstep += xres-1-i;
279                          i = xres-1;
280                  }
281                  z = pixvalue(scanline[i], i, y);
282                  if (zline) zline[i] = z;
283 <                
284 <                b = fillsample(scanline+i-xstep, zline ? zline+i-xstep : NULL,
285 <                                i-xstep, y, xstep, 0, b/2);
283 >                if (sd) b = sd[0] > sd[1] ? sd[0] : sd[1];
284 >                if (i <= xstep)
285 >                        b = fillsample(scanline, zline, 0, y, i, 0, b/2);
286 >                else
287 >                        b = fillsample(scanline+i-xstep,
288 >                                        zline ? zline+i-xstep : NULL,
289 >                                        i-xstep, y, xstep, 0, b/2);
290 >                if (sd) *sd++ = nc & 1 ? bl : b;
291 >                bl = b;
292          }
293 +        if (sd && nc & 1) *sd = bl;
294   }
295  
296  
# Line 383 | Line 424 | char  *oldfile;
424                                  /* discard header */
425          getheader(fp, NULL);
426                                  /* get picture size */
427 <        if (fgetresolu(&x, &y, fp) != (YMAJOR|YDECR)) {
427 >        if (!fscnresolu(&x, &y, fp)) {
428                  sprintf(errmsg, "bad recover file \"%s\"", oldfile);
429                  error(WARNING, errmsg);
430                  fclose(fp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines