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.4 by greg, Wed Jun 7 21:00:57 1989 UTC vs.
Revision 1.10 by greg, Tue Oct 3 12:17:09 1989 UTC

# Line 29 | Line 29 | double  dstrpix = 0.67;                        /* square pixel distribution
29  
30   double  dstrsrc = 0.0;                  /* square source distribution */
31   double  shadthresh = .05;               /* shadow threshold */
32 + double  shadcert = .5;                  /* shadow certainty */
33  
34   int  maxdepth = 6;                      /* maximum recursion depth */
35   double  minweight = 5e-3;               /* minimum ray weight */
36  
37   COLOR  ambval = BLKCOLOR;               /* ambient value */
38   double  ambacc = 0.2;                   /* ambient accuracy */
39 < int  ambres = 128;                      /* ambient resolution */
39 > int  ambres = 32;                       /* ambient resolution */
40   int  ambdiv = 128;                      /* ambient divisions */
41   int  ambssamp = 0;                      /* ambient super-samples */
42   int  ambounce = 0;                      /* ambient bounces */
# Line 95 | Line 96 | char  *oldfile;
96          int  ypos;                      /* current scanline */
97          COLOR  *colptr;
98          register int  i;
99 <
99 >                                        /* check sampling */
100          if (psample < 1)
101                  psample = 1;
102          else if (psample > MAXDIV)
103                  psample = MAXDIV;
104 <
104 <        ourview.hresolu -= ourview.hresolu % psample;
105 <        ourview.vresolu -= ourview.vresolu % psample;
106 <                
104 >                                        /* allocate scanlines */
105          for (i = 0; i <= psample; i++) {
106 <                scanbar[i] = (COLOR *)malloc((ourview.hresolu+1)*sizeof(COLOR));
106 >                scanbar[i] = (COLOR *)malloc(ourview.hresolu*sizeof(COLOR));
107                  if (scanbar[i] == NULL)
108                          error(SYSTEM, "out of memory in render");
109          }
112        
110                                          /* write out boundaries */
111 <        printf("-Y %d +X %d\n", ourview.vresolu, ourview.hresolu);
112 <
113 <        ypos = ourview.vresolu - salvage(oldfile);      /* find top line */
114 <        fillscanline(scanbar[0], ypos, psample);        /* top scan */
115 <
116 <        for (ypos -= psample; ypos > -psample; ypos -= psample) {
111 >        fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, stdout);
112 >                                        /* recover file and compute first */
113 >        ypos = ourview.vresolu-1 - salvage(oldfile);
114 >        fillscanline(scanbar[0], ourview.hresolu, ypos, psample);
115 >                                                /* compute scanlines */
116 >        for (ypos -= psample; ypos >= 0; ypos -= psample) {
117          
118 <                colptr = scanbar[psample];              /* get last scanline */
118 >                pctdone = 100.0*(ourview.vresolu-ypos-psample)/ourview.vresolu;
119 >
120 >                colptr = scanbar[psample];              /* move base to top */
121                  scanbar[psample] = scanbar[0];
122                  scanbar[0] = colptr;
123 <
124 <                fillscanline(scanbar[0], ypos, psample);        /* base scan */
125 <        
126 <                fillscanbar(scanbar, ypos, psample);
127 <                
128 <                for (i = psample-1; i >= 0; i--)
123 >                                                        /* fill base line */
124 >                fillscanline(scanbar[0], ourview.hresolu, ypos, psample);
125 >                                                        /* fill bar */
126 >                fillscanbar(scanbar, ourview.hresolu, ypos, psample);
127 >                                                        /* write it out */
128 >                for (i = psample; i > 0; i--)
129                          if (fwritescan(scanbar[i], ourview.hresolu, stdout) < 0)
130                                  goto writerr;
131                  if (fflush(stdout) == EOF)
132                          goto writerr;
134                pctdone = 100.0*(ourview.vresolu-ypos)/ourview.vresolu;
133          }
134 <                
134 >                                                /* compute residual */
135 >        colptr = scanbar[psample];
136 >        scanbar[psample] = scanbar[0];
137 >        scanbar[0] = colptr;
138 >        if (ypos > -psample) {
139 >                fillscanline(scanbar[-ypos], ourview.hresolu,
140 >                                0, psample);
141 >                fillscanbar(scanbar-ypos, ourview.hresolu,
142 >                                0, psample+ypos);
143 >        }
144 >        for (i = psample; i+ypos >= 0; i--)
145 >                if (fwritescan(scanbar[i], ourview.hresolu, stdout) < 0)
146 >                        goto writerr;
147 >        if (fflush(stdout) == EOF)
148 >                goto writerr;
149 >        pctdone = 100.0;
150 >                                                /* free scanlines */
151          for (i = 0; i <= psample; i++)
152                  free((char *)scanbar[i]);
153          return;
# Line 142 | Line 156 | writerr:
156   }
157  
158  
159 < fillscanline(scanline, y, xstep)                /* fill scan line at y */
159 > fillscanline(scanline, xres, y, xstep)          /* fill scan line at y */
160   register COLOR  *scanline;
161 < int  y, xstep;
161 > int  xres, y, xstep;
162   {
163          int  b = xstep;
164          register int  i;
165          
166          pixvalue(scanline[0], 0, y);
167  
168 <        for (i = xstep; i <= ourview.hresolu; i += xstep) {
168 >        for (i = xstep; i < xres; i += xstep) {
169          
170                  pixvalue(scanline[i], i, y);
171                  
172                  b = fillsample(scanline+i-xstep, i-xstep, y, xstep, 0, b/2);
173          }
174 +        if (i-xstep < xres-1) {
175 +                pixvalue(scanline[xres-1], xres-1, y);
176 +                fillsample(scanline+i-xstep, i-xstep, y,
177 +                                xres-1-(i-xstep), 0, b/2);
178 +        }
179   }
180  
181  
182 < fillscanbar(scanbar, y, ysize)          /* fill interior */
182 > fillscanbar(scanbar, xres, y, ysize)            /* fill interior */
183   register COLOR  *scanbar[];
184 < int  y, ysize;
184 > int  xres, y, ysize;
185   {
186          COLOR  vline[MAXDIV+1];
187          int  b = ysize;
188          register int  i, j;
189          
190 <        for (i = 0; i < ourview.hresolu; i++) {
190 >        for (i = 0; i < xres; i++) {
191                  
192                  copycolor(vline[0], scanbar[0][i]);
193                  copycolor(vline[ysize], scanbar[ysize][i]);
# Line 254 | Line 273 | char  *oldfile;
273  
274          if (oldfile == NULL)
275                  return(0);
276 <        else if ((fp = fopen(oldfile, "r")) == NULL) {
276 >        
277 >        if ((fp = fopen(oldfile, "r")) == NULL) {
278                  sprintf(errmsg, "cannot open recover file \"%s\"", oldfile);
279                  error(WARNING, errmsg);
280                  return(0);
# Line 262 | Line 282 | char  *oldfile;
282                                  /* discard header */
283          getheader(fp, NULL);
284                                  /* get picture size */
285 <        if (fscanf(fp, "-Y %d +X %d\n", &y, &x) != 2) {
285 >        if (fgetresolu(&x, &y, fp) != (YMAJOR|YDECR)) {
286                  sprintf(errmsg, "bad recover file \"%s\"", oldfile);
287                  error(WARNING, errmsg);
288                  fclose(fp);
# Line 273 | Line 293 | char  *oldfile;
293                  sprintf(errmsg, "resolution mismatch in recover file \"%s\"",
294                                  oldfile);
295                  error(USER, errmsg);
276                return(0);
296          }
297  
298          scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines