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.2 by greg, Mon Apr 10 09:32:55 1989 UTC vs.
Revision 1.9 by greg, Fri Sep 29 08:16:41 1989 UTC

# Line 24 | Line 24 | static char SCCSid[] = "$SunId$ LBL";
24   VIEW  ourview = STDVIEW(512);           /* view parameters */
25  
26   int  psample = 4;                       /* pixel sample size */
27
27   double  maxdiff = .05;                  /* max. difference for interpolation */
29
28   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 93 | Line 94 | char  *oldfile;
94   {
95          COLOR  *scanbar[MAXDIV+1];      /* scanline arrays of pixel values */
96          int  ypos;                      /* current scanline */
97 +        int  xres, yres;                /* rendered x and y resolution */
98          COLOR  *colptr;
99          register int  i;
100 <
101 <        if (psample < 1)
100 >                                        /* set rendered resolution */
101 >        xres = ourview.hresolu;
102 >        yres = ourview.vresolu;
103 >                                        /* adjust for sampling */
104 >        if (psample <= 1)
105                  psample = 1;
106 <        else if (psample > MAXDIV)
107 <                psample = MAXDIV;
108 <
109 <        ourview.hresolu -= ourview.hresolu % psample;
110 <        ourview.vresolu -= ourview.vresolu % psample;
111 <                
106 >        else {
107 >                if (psample > MAXDIV)
108 >                        psample = MAXDIV;
109 >                                        /* rendered resolution may be larger */
110 >                xres += psample-1 - ((ourview.hresolu-2)%psample);
111 >                yres += psample-1 - ((ourview.vresolu-2)%psample);
112 >        }
113 >                                        /* allocate scanlines */
114          for (i = 0; i <= psample; i++) {
115 <                scanbar[i] = (COLOR *)malloc((ourview.hresolu+1)*sizeof(COLOR));
115 >                scanbar[i] = (COLOR *)malloc(xres*sizeof(COLOR));
116                  if (scanbar[i] == NULL)
117                          error(SYSTEM, "out of memory in render");
118          }
112        
119                                          /* write out boundaries */
120 <        printf("-Y %d +X %d\n", ourview.vresolu, ourview.hresolu);
120 >        fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, stdout);
121  
122 <        ypos = ourview.vresolu - salvage(oldfile);      /* find top line */
123 <        fillscanline(scanbar[0], ypos, psample);        /* top scan */
122 >        ypos = ourview.vresolu-1 - salvage(oldfile);    /* find top line */
123 >        fillscanline(scanbar[0], xres, ypos, psample);  /* top scan */
124  
125          for (ypos -= psample; ypos > -psample; ypos -= psample) {
126          
127 <                colptr = scanbar[psample];              /* get last scanline */
127 >                pctdone = 100.0*(ourview.vresolu-ypos+psample)/ourview.vresolu;
128 >
129 >                colptr = scanbar[psample];              /* move base to top */
130                  scanbar[psample] = scanbar[0];
131                  scanbar[0] = colptr;
132  
133 <                fillscanline(scanbar[0], ypos, psample);        /* base scan */
133 >                fillscanline(scanbar[0], xres, ypos, psample);  /* fill base */
134          
135 <                fillscanbar(scanbar, ypos, psample);
135 >                fillscanbar(scanbar, xres, ypos, psample);      /* fill bar */
136                  
137 <                for (i = psample-1; i >= 0; i--)
137 >                for (i = psample; (ypos>0) ? i > 0 : ypos+i >= 0; i--)
138                          if (fwritescan(scanbar[i], ourview.hresolu, stdout) < 0)
139                                  goto writerr;
140                  if (fflush(stdout) == EOF)
141                          goto writerr;
134                pctdone = 100.0*(ourview.vresolu-ypos)/ourview.vresolu;
142          }
143 +        pctdone = 100.0;
144                  
145          for (i = 0; i <= psample; i++)
146                  free((char *)scanbar[i]);
# Line 142 | Line 150 | writerr:
150   }
151  
152  
153 < fillscanline(scanline, y, xstep)                /* fill scan line at y */
153 > fillscanline(scanline, xres, y, xstep)          /* fill scan line at y */
154   register COLOR  *scanline;
155 < int  y, xstep;
155 > int  xres, y, xstep;
156   {
157          int  b = xstep;
158          register int  i;
159          
160          pixvalue(scanline[0], 0, y);
161  
162 <        for (i = xstep; i <= ourview.hresolu; i += xstep) {
162 >        for (i = xstep; i < xres; i += xstep) {
163          
164                  pixvalue(scanline[i], i, y);
165                  
# Line 160 | Line 168 | int  y, xstep;
168   }
169  
170  
171 < fillscanbar(scanbar, y, ysize)          /* fill interior */
171 > fillscanbar(scanbar, xres, y, ysize)            /* fill interior */
172   register COLOR  *scanbar[];
173 < int  y, ysize;
173 > int  xres, y, ysize;
174   {
175          COLOR  vline[MAXDIV+1];
176          int  b = ysize;
177          register int  i, j;
178          
179 <        for (i = 0; i < ourview.hresolu; i++) {
179 >        for (i = 0; i < xres; i++) {
180                  
181                  copycolor(vline[0], scanbar[0][i]);
182                  copycolor(vline[ysize], scanbar[ysize][i]);
# Line 254 | Line 262 | char  *oldfile;
262  
263          if (oldfile == NULL)
264                  return(0);
265 <        else if ((fp = fopen(oldfile, "r")) == NULL) {
265 >        
266 >        if ((fp = fopen(oldfile, "r")) == NULL) {
267                  sprintf(errmsg, "cannot open recover file \"%s\"", oldfile);
268                  error(WARNING, errmsg);
269                  return(0);
# Line 262 | Line 271 | char  *oldfile;
271                                  /* discard header */
272          getheader(fp, NULL);
273                                  /* get picture size */
274 <        if (fscanf(fp, "-Y %d +X %d\n", &y, &x) != 2) {
274 >        if (fgetresolu(&x, &y, fp) != (YMAJOR|YDECR)) {
275                  sprintf(errmsg, "bad recover file \"%s\"", oldfile);
276                  error(WARNING, errmsg);
277                  fclose(fp);
# Line 273 | Line 282 | char  *oldfile;
282                  sprintf(errmsg, "resolution mismatch in recover file \"%s\"",
283                                  oldfile);
284                  error(USER, errmsg);
276                return(0);
285          }
286  
287          scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines