--- ray/src/hd/rhpict.c 1999/03/08 14:09:11 3.3 +++ ray/src/hd/rhpict.c 1999/03/09 14:55:53 3.6 @@ -18,6 +18,7 @@ char *hdkfile; /* holodeck file name */ VIEW myview = STDVIEW; /* current output view */ int xres = 512, yres = 512; /* max. horizontal and vertical resolution */ char *outspec = NULL; /* output file specification */ +double randfrac = -1.; /* random resampling fraction */ double pixaspect = 1.; /* pixel aspect ratio */ int seqstart = 0; /* sequence start frame */ double expval = 1.; /* exposure value */ @@ -74,13 +75,21 @@ char *argv[]; goto userr; outspec = argv[++i]; break; + case 'r': /* random sampling */ + if (badarg(argc-i-1,argv+i+1,"f")) + goto userr; + randfrac = atof(argv[++i]); + break; + case 's': /* smooth sampling */ + randfrac = -1.; + break; case 'S': /* sequence start */ if (badarg(argc-i-1,argv+i+1,"i")) goto userr; seqstart = atoi(argv[++i]); break; case 'v': /* view file */ - if (argv[i][1]!='f' || badarg(argc-i-1,argv+i+1,"s")) + if (argv[i][2]!='f' || badarg(argc-i-1,argv+i+1,"s")) goto userr; rval = viewfile(argv[++i], &myview, NULL); if (rval < 0) { @@ -111,7 +120,7 @@ char *argv[]; quit(0); /* all done! */ userr: fprintf(stderr, -"Usage: %s [-w][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n", +"Usage: %s [-w][-r rf][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n", progname); quit(1); } @@ -171,7 +180,7 @@ int nb; bil[i].b = bl[i].bi; } hdloadbeams(bil, nb, pixBeam); - pixFlush(); + pixFinish(randfrac); free((char *)bil); } @@ -220,22 +229,29 @@ int fn; int endpicture() /* finish and write out pixels */ { - int nunrend = 0; - int v; + int lastr = -1, nunrend = 0; + int4 lastp, lastrp; + register int4 p; register double d; - register int p; /* compute final pixel values */ for (p = hres*vres; p--; ) { if (myweight[p] <= FTINY) { + if (lastr >= 0) + if (p/hres == lastp/hres) + copycolor(mypixel[p], mypixel[lastp]); + else + copycolor(mypixel[p], mypixel[lastrp]); nunrend++; continue; } d = expval/myweight[p]; scalecolor(mypixel[p], d); + if ((lastp=p)/hres != lastr) + lastr = (lastrp=p)/hres; } /* write each scanline */ - for (v = vres; v--; ) - if (fwritescan(mypixel+v*hres, hres, stdout) < 0) + for (p = vres; p--; ) + if (fwritescan(mypixel+p*hres, hres, stdout) < 0) return(-1); if (fflush(stdout) == EOF) return(-1);