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 2.1 by greg, Tue Nov 12 17:08:26 1991 UTC vs.
Revision 2.7 by greg, Wed Mar 11 09:32:40 1992 UTC

# Line 47 | Line 47 | int  vspretest = 512;                  /* virtual source pretest dens
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 70 | 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 108 | Line 111 | report()               /* report progress */
111   #else
112   report()                /* report progress */
113   {
111        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 123 | 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 */
# Line 145 | 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 176 | Line 190 | char  *zfile, *oldfile;
190   #endif
191          signal(SIGALRM, report);
192          ypos = vresolu-1 - i;
193 <        hstep = (psample*140+49)/99;            /* quincunx sampling */
180 <        ystep = (psample*99+70)/140;
181 <        fillscanline(scanbar[0], zbar[0], hresolu, ypos, hstep);
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 193 | 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, hstep);
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 */
# Line 220 | Line 233 | char  *zfile, *oldfile;
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 234 | 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 243 | 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          static int  nc = 0;             /* number of calls */
269 <        int  b = xstep;
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                                  /* zig-zag start for quincunx pattern */
276 <        for (i = nc++ & 1 ? xstep/2 : xstep; i < xres-1+xstep; i += xstep) {
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines