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

Comparing ray/src/hd/rhpict.c (file contents):
Revision 3.1 by gwlarson, Thu Mar 4 10:30:04 1999 UTC vs.
Revision 3.4 by gwlarson, Tue Mar 9 10:55:24 1999 UTC

# Line 24 | Line 24 | double expval = 1.;            /* exposure value */
24  
25   COLOR   *mypixel;               /* pixels being rendered */
26   float   *myweight;              /* weights (used to compute final pixels) */
27 + float   *mydepth;               /* depth values (visibility culling) */
28   int     hres, vres;             /* current horizontal and vertical res. */
29  
30   extern int      nowarn;         /* turn warnings off? */
# Line 49 | Line 50 | char   *argv[];
50                  case 'p':                       /* pixel aspect/exposure */
51                          if (badarg(argc-i-1,argv+i+1,"f"))
52                                  goto userr;
53 <                        if (argv[i][1] == 'a')
53 >                        if (argv[i][2] == 'a')
54                                  pixaspect = atof(argv[++i]);
55 <                        else if (argv[i][1] == 'e') {
55 >                        else if (argv[i][2] == 'e') {
56                                  expval = atof(argv[++i]);
57                                  if (argv[i][0] == '-' | argv[i][0] == '+')
58                                          expval = pow(2., expval);
# Line 79 | Line 80 | char   *argv[];
80                          seqstart = atoi(argv[++i]);
81                          break;
82                  case 'v':                       /* view file */
83 <                        if (argv[i][1]!='f' || badarg(argc-i-1,argv+i+1,"s"))
83 >                        if (argv[i][2]!='f' || badarg(argc-i-1,argv+i+1,"s"))
84                                  goto userr;
85                          rval = viewfile(argv[++i], &myview, NULL);
86                          if (rval < 0) {
# Line 97 | Line 98 | char   *argv[];
98                  }
99          }
100                                                  /* open holodeck file */
101 <        if (i >= argc)
101 >        if (i != argc-1)
102                  goto userr;
103 <        hdkfile = argv[i++];
103 >        hdkfile = argv[i];
104          initialize();
105                                                  /* render picture(s) */
106          if (seqstart <= 0)
# Line 144 | Line 145 | int    fn;
145                  sprintf(errmsg, "error writing frame %d", fn);
146                  error(SYSTEM, errmsg);
147          }
148 + #ifdef DEBUG
149          if (blist.nb > 0 & rval > 0) {
150 <                sprintf(errmsg, "%.1f%% unrendered pixels in frame %d",
151 <                                100.*rval/(hres*vres), fn);
150 >                sprintf(errmsg, "%d unrendered pixels in frame %d (%.1f%%)",
151 >                                rval, fn, 100.*rval/(hres*vres));
152                  error(WARNING, errmsg);
153          }
154 + #endif
155   }
156  
157  
# Line 156 | Line 159 | render_frame(bl, nb)           /* render frame from beam values
159   register PACKHEAD       *bl;
160   int     nb;
161   {
162 <        extern int      render_beam();
162 >        extern int      pixBeam();
163          register HDBEAMI        *bil;
164          register int    i;
165  
# Line 167 | Line 170 | int    nb;
170                  bil[i].h = hdlist[bl[i].hd];
171                  bil[i].b = bl[i].bi;
172          }
173 <        hdloadbeams(bil, nb, render_beam);
173 >        hdloadbeams(bil, nb, pixBeam);
174 >        pixFlush();
175          free((char *)bil);
176   }
177  
# Line 209 | Line 213 | int    fn;
213                                  /* prepare image buffers */
214          bzero((char *)mypixel, hres*vres*sizeof(COLOR));
215          bzero((char *)myweight, hres*vres*sizeof(float));
216 +        bzero((char *)mydepth, hres*vres*sizeof(float));
217   }
218  
219  
220   int
221   endpicture()                    /* finish and write out pixels */
222   {
223 <        int     nunrend = 0;
224 <        int     v;
223 >        int     lastr = -1, nunrend = 0;
224 >        int4    lastp, lastrp;
225 >        register int4   p;
226          register double d;
221        register int    p;
227                                  /* compute final pixel values */
228          for (p = hres*vres; p--; ) {
229                  if (myweight[p] <= FTINY) {
230 +                        if (lastr >= 0)
231 +                                if (p/hres == lastp/hres)
232 +                                        copycolor(mypixel[p], mypixel[lastp]);
233 +                                else
234 +                                        copycolor(mypixel[p], mypixel[lastrp]);
235                          nunrend++;
236                          continue;
237                  }
238                  d = expval/myweight[p];
239                  scalecolor(mypixel[p], d);
240 +                if ((lastp=p)/hres != lastr)
241 +                        lastr = (lastrp=p)/hres;
242          }
243                                  /* write each scanline */
244 <        for (v = vres; v--; )
245 <                if (fwritescan(mypixel+v*hres, hres, stdout) < 0)
244 >        for (p = vres; p--; )
245 >                if (fwritescan(mypixel+p*hres, hres, stdout) < 0)
246                          return(-1);
247          if (fflush(stdout) == EOF)
248                  return(-1);
# Line 269 | Line 281 | initialize()                   /* initialize holodeck and buffers */
281                                          /* allocate picture buffer */
282          mypixel = (COLOR *)bmalloc(xres*yres*sizeof(COLOR));
283          myweight = (float *)bmalloc(xres*yres*sizeof(float));
284 <        if (mypixel == NULL | myweight == NULL)
284 >        mydepth = (float *)bmalloc(xres*yres*sizeof(float));
285 >        if (mypixel == NULL | myweight == NULL | mydepth == NULL)
286                  error(SYSTEM, "out of memory in initialize");
287   }
288  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines